WXL
2024-11-26 007d3884ad259883d7a5db6714876e46525ae717
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!-- 表格组件封装 -->
<template>
  <el-table
    ref="multipleTableson"
    :data="
      currentList.filter(
        (data) =>
          !search || data.name.toLowerCase().includes(search.toLowerCase())
      )
    "
    @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"
      fixed="left"
      type="selection"
      width="50"
      align="center"
    />
    <el-table-column
      v-if="serialnumber"
      label="序号"
      align="center"
      key="id"
      prop="id"
    />
    <div v-for="(item, index) in tableLabel">
      <el-table-column
        v-if="item.label == '出院日期'"
        :key="index"
        :prop="item.prop"
        :width="item.width"
        :label="item.label"
        :formatter="formatData"
      >
        <template slot-scope="scope">
          <span>{{ formatTime(scope.row.endtime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="item.label == '性别'"
        :key="index"
        :prop="item.prop"
        :width="item.width"
        :label="item.label"
        :formatter="formatData"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.sex == 1 ? "男" : "女" }}</span>
        </template>
      </el-table-column>
 
      <el-table-column
        v-if="item.label != '性别' && item.label != '出院日期'"
        :key="index"
        :prop="item.prop"
        :width="item.width"
        :label="item.label"
        :formatter="formatData"
      >
      </el-table-column>
    </div>
    <!-- <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 && !searchTrue"
      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-column
      v-if="center && searchTrue"
      label="操作"
      fixed="right"
      align="right"
      width="200"
      class-name="small-padding fixed-width"
    >
      <template slot="header" slot-scope="scope">
        <el-input v-model="search" size="mini" placeholder="输入患者名称搜索" />
      </template>
      <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: [],
      search: "",
    };
  },
  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,
    },
    searchTrue: {
      type: Boolean,
      default: false,
    },
  },
  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) {
      console.log(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>