Blame view

src/components/NCC-table/index.vue 1.39 KB
0af91599   monkeyhouyi   弹框请求优化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  <template>
    <el-table :data="data" ref="NCCTable" class="NCC-common-table" :height="height"
      :element-loading-text="$t('common.loadingText')" v-bind="$attrs" v-on="$listeners"
      :border="border">
      <el-table-column type="selection" width="50" v-if="hasC" align="center" />
      <el-table-column type="index" width="50" label="序号" v-if="hasNO" align="center" />
      <slot></slot>
      <template slot="empty">
        <el-empty description="暂无数据" :image-size="120"></el-empty>
      </template>
    </el-table>
  </template>
  
  <script>
  export default {
    name: 'NCC-table',
    props: {
      data: {
        type: Array,
        default: () => []
      },
      columnData: {
        type: Array,
        default: () => []
      },
      // 序号 默认有
      hasNO: {
        type: Boolean,
        default: true
      },
      // 多选框 默认无
      hasC: {
        type: Boolean,
        default: false
      },
      border: {
        type: Boolean,
        default: false
      },
      height: {
        default: '100%'
      }
    },
    watch: {
      data: {
        handler(val) {
          if (!val) return
          this.doLayout()
        },
        deep: true
      },
      columnData: {
        handler(val) {
          if (!val) return
          this.doLayout()
        },
        deep: true
      }
    },
    methods: {
      doLayout() {
        setTimeout(() => {
          this.$nextTick(() => {
            this.$refs.NCCTable.doLayout()
          })
        }, 50)
      }
    }
  }
  </script>