WXL
2024-05-31 f6cedc29e915445bbdd0923d8315941f8abbd6ed
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!-- 表格组件封装 -->
<template>
  <el-table
    ref="multipleTableson"
    :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
      v-if="serialnumber"
      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"
      key="isavailable"
      prop="isavailable"
      width="120"
    >
      <template slot-scope="scope">
        <dict-tag :options="qyoptions" :value="scope.row.usestate" />
      </template>
    </el-table-column> -->
    <el-table-column
      v-if="center"
      label="操作"
      fixed="right"
      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('selectfn', scope.row, typeinfo)"
          ><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, typeinfo)"
          ><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";
import store from "@/store";
export default {
  data() {
    return {
      ids: [],
      mode: [],
      languagelist: [],
      editabshape: [],
      qyoptions: [],
      precedencetype: [],
    };
  },
  props: {
    currentList: {
      type: Array,
      required: true,
    },
    tableLabel: {
      type: Array,
      default: () => [],
    },
    controlsc: {
      type: Boolean,
      default: true,
    },
    center: {
      type: Boolean,
      default: true,
    },
    controlxz: {
      type: Boolean,
      default: true,
    },
    multiplechoice: {
      type: Boolean,
      default: true,
    },
    serialnumber: {
      type: Boolean,
      default: true,
    },
    // 1模版列表 2选中患者 3患者列表
    typeinfo: {
      type: Number,
      default: 1,
    },
  },
  created() {
    this.mode = store.getters.mode;
    this.languagelist = store.getters.languagelist;
    this.qyoptions = store.getters.usable;
    this.precedencetype = store.getters.precedencetype;
    this.editabshape = store.getters.editabshape;
  },
 
  methods: {
    //   数据过滤
    formatData(row, column, cellValue) {
      if (column.property === "createType") {
        if (cellValue === 1) {
          return "自动";
        }
        return "手动";
      }
      if (
        column.property === "createTime" ||
        column.property === "inhosptime"
      ) {
        if (cellValue === null) {
          return "";
        }
        return dayjs(cellValue).format("YYYY-MM-DD ");
      }
      return cellValue;
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.$emit("handleSelectionChange", selection);
    },
    toggleRowSelection(row, selected) {
      this.$refs.multipleTableson.toggleRowSelection(row, selected);
    },
    clearSelection() {
      // 在这里编写清除选择的逻辑
      this.$refs.multipleTableson.clearSelection();
    },
  },
};
</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>