<template>
  <div>
    <el-dialog :title="$t('btns.edit_print')" :visible.sync="editPrintVisible" width="40%" :before-close="handleClose" :append-to-body="isNested">
      <div>
        <div class="obpm-title">
          <div class="bar d-inline-block float-left">
            <span>{{$t('msg.print_list')}}</span>
          </div>
        </div>
        <div class="obpm-main mt-3">
          <div class="dialog-content">
            <el-form :inline="true" :model="editPrint" class="demo-form-inline">
              <el-form-item :label="$t('label.name')">
                <el-input v-model="editPrint.sm_name" size="mini"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="onSearch" size="mini">{{$t("btns.query")}}</el-button>
              </el-form-item>
            </el-form>
            <el-table :data="editPrintData.datas" style="width: 100%">
              <el-table-column :label="$t('label.name')">
                <template slot-scope="scope">
                  <el-link :style="{ color: '#66b1ff' }" @click="handleClick(scope.row)">{{ scope.row.name }}</el-link>
                </template>
              </el-table-column>
              <el-table-column :label="$t('label.description')" prop="desc"></el-table-column>
            </el-table>
            <!-- 页码 -->
            <div style="text-align: right">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="editPrintData.pageNo"
                :page-sizes="[10, 25, 50, 100]"
                :page-size="10"
                background
                layout="total, prev, pager, next, sizes"
                :total="editPrintData.rowCount"
              ></el-pagination>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      editPrint: {
        sm_name: "", // 名称
      },
    };
  },
  methods: {
    // 弹框关闭回调
    handleClose() {
      this.editPrint.sm_name = "";
      this.$emit("closeEditPrintDialog");
    },
    // 表格查询
    onSearch() {
      this.$emit("searchReportByName", this.editPrint.sm_name);
    },
    handleSizeChange(val) {
      this.$emit("searchReportByPageNo", val);
    },
    handleCurrentChange(val) {
      this.$emit("searchReportByLinesPerPage", val);
    },
    /**
     * 将值写入input
     */
    handleClick(row){
      this.$emit('printValue', row)
    }
  },
  props: {
    editPrintVisible: Boolean,
    editPrintData: Object,
    isNested: {
      type: Boolean,
      default: false,
    },
  },
};
</script>
<style scoped></style>
