yxh
2023-12-01 02aa4d157d800650f1dc2fa2b7fbee52837df074
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!-- 表格组件封装 -->
<template>
  <el-table
    :data="currentList"
    @selection-change="handleSelectionChange"
    :header-cell-style="{
      background: '#f3f6fb',
      color: '#666',
      height: '42px',
      'font-weight': 400,
    }"
    :highlight-current-row="true"
    empty-text="暂无数据"
  >
    <el-table-column v-if="multiplechoice" type="selection" width="50" align="center" />
    <el-table-column label="序号" align="center" key="id" prop="id" />
    <el-table-column
      v-for="(item, index) in tableLabel"
      :key="index"
      :prop="item.prop"
      :width="item.width"
      :label="item.label"
      :formatter="formatData"
    >
    </el-table-column>
    <el-table-column
      label="操作"
      align="center"
      width="120"
      class-name="small-padding fixed-width"
    >
      <template slot-scope="scope">
        <el-button
          v-if="controlxz"
          size="medium"
          type="text"
          @click.native="$emit('handleUpdate', scope.row)"
          ><span class="button-zx"
            ><i class="el-icon-s-promotion"></i>选择</span
          ></el-button
        >
        <el-button
          v-if="controlsc"
          size="medium"
          type="text"
          @click.native="$emit('details', scope.row)"
          ><span style="color: red"
            ><i class="el-icon-delete"></i>删除</span
          ></el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>
 
<script>
import dayjs from "dayjs";
export default {
  data() {
    return {
      ids: [],
    };
  },
  props: {
    currentList: {
      type: Array,
      required: true,
    },
    tableLabel: {
      type: Array,
      default: () => [],
    },
    controlsc: {
      type: Boolean,
      default: true,
    },
    controlxz: {
      type: Boolean,
      default: true,
    },
    multiplechoice:{
      type: Boolean,
      default: true,
    }
 
  },
  created() {},
 
  methods: {
    //   数据过滤
    formatData(row, column, cellValue) {
      if (column.property === "createType") {
        if (cellValue === 1) {
          return "自动";
        }
        return "手动";
      }
      if (column.property === "createTime") {
        return dayjs(cellValue).format("YYYY.MM.DD HH:mm:ss");
      }
      return cellValue;
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      $emit("handleSelectionChange", selection);
    },
  },
};
</script>
 
<style lang="scss">
.el-table td,
.el-table th.is-leaf {
  border-bottom: unset;
}
.el-table td,
.el-table th {
  padding: 5px 0;
}
.el-table thead {
  font-weight: 400;
  color: #666;
}
.dialog-footer {
  width: 100%;
  padding: 10px 20px 20px;
  text-align: center !important;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
</style>