GridEtyPromptDialog.vue 2.04 KB
Newer Older
1
<template>
zhengxiaokui committed
2 3 4 5 6 7 8 9 10
  <el-dialog
    :title="promptData.title"
    :visible.sync="show"
    custom-class="grid-ety"
    :highlight-current-row="true"
    width="60%"
    :before-close="beforeClose"
  >
    <el-table
11
      :data="tableData"
zhengxiaokui committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25
      border
      @row-dblclick="selectEty"
    >
      <el-table-column
        v-for="(item, idx) in tableColumn"
        :key="idx"
        :property="item.prop"
        :label="item.label"
        :width="item.width"
      >
      </el-table-column>
    </el-table>
    <el-pagination
      layout="prev, pager, next, total, jumper"
suwenhao committed
26
      :total="this.promptData.data.length"
zhengxiaokui committed
27 28 29 30 31 32 33
      :page-sizes="pageSizes"
      :page-size="pageSize"
      :current-page="currentPage"
      @current-change="currentChange"
    >
    </el-pagination>
  </el-dialog>
34 35 36 37
</template>

<script>
export default {
zhengxiaokui committed
38 39 40 41 42
  props: {
    promptData: {
      required: true,
      type: Object,
      default: () => {
43
        return {
zhengxiaokui committed
44
          title: "",
45
          columns: "",
zhengxiaokui committed
46 47 48
          data: [],
          rulePath: "",
          modelUrl: "", //非机构处理需要回填的字段路劲信息,isPty为false时必输
49
          defaultColumn: "",
zhengxiaokui committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
        };
      },
    },
    isPty: {
      //默认为机构处理
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      show: false,
      currentPage: 1,
      pageSizes: [5, 10, 20, 30, 40, 50, 100],
      pageSize: 5,
    };
  },
  computed: {
    tableColumn() {
69
      return this.promptData.columns
zhengxiaokui committed
70 71
    },
    tableData() {
suwenhao committed
72
      return this.promptData.data.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize)
zhengxiaokui committed
73 74 75 76 77
    },
  },
  methods: {
    currentChange(currentPage) {
      this.currentPage = currentPage;
78
    },
79 80 81 82 83
    selectEty(row) {
      this.$emit("select-ety", {
        ...row,
        role: this.promptData.type
      });
zhengxiaokui committed
84 85 86 87 88 89 90 91 92 93
      this.show = false;
      this.currentPage = 1;
    },
    beforeClose(done) {
      this.show = false;
      this.currentPage = 1;
      done();
    },
  },
};
94 95 96
</script>

<style>
zhengxiaokui committed
97 98
.grid-ety .el-table .cell {
  white-space: pre-wrap;
99 100
}
</style>