WXL (wul)
2026-06-15 741805d8daa2d2baa0b6b75bc1724488baf9c6bc
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<template>
  <div>
    <el-dialog
      title="适用疾病选择"
      :visible.sync="dialogVisiblepatient"
      width="70%"
      :before-close="handleClosehz"
    >
      <div class="examine-jic">
        <div style="margin: 0 10px 20px 10px">
          <el-card class="box-card">
            <el-tag
              v-for="item in overallCase"
              :key="item.icdid"
              type="warning"
              closable
              @close="handleClose(item)"
            >
              {{ item.icdname }}
            </el-tag>
            <div style="margin-top: 20px; text-align: right">
              共选择<span
                style="font-size: 18px; color: #409eff; margin: 0 10px"
                >{{ overallCase.length }}</span
              >条数据
            </div>
          </el-card>
        </div>
        <div class="jic-value">
          <el-row :gutter="20">
            <!--用户数据-->
            <el-form
              :model="patientqueryParams"
              ref="queryForm"
              size="small"
              :inline="true"
              label-width="98px"
            >
              <el-form-item label="疾病名称" prop="name">
                <el-input
                  v-model="patientqueryParams.icdname"
                  placeholder="请输入疾病名称"
                  @keyup.enter.native="handleAddpatient"
                />
              </el-form-item>
 
              <el-form-item>
                <el-button
                  type="primary"
                  icon="el-icon-search"
                  size="medium"
                  @click="handleAddpatient"
                  >搜索</el-button
                >
                <el-button
                  icon="el-icon-refresh"
                  size="medium"
                  @click="resetQuery"
                  >重置</el-button
                >
              </el-form-item>
            </el-form>
            <!-- 选择器官列表 -->
            <el-table
              ref="multipleTable"
              :data="donorchargeList"
              tooltip-effect="dark"
              style="width: 100%"
              @select="handleSelect"
              @select-all="handleSelectAll"
              @selection-change="handleSelectionChange"
            >
              <el-table-column
                class="checkall"
                type="selection"
                width="55"
                :selectable="checkSelectable"
              >
              </el-table-column>
              <el-table-column
                prop="icdid"
                label="疾病编号"
                width="100"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column label="疾病名称" show-overflow-tooltip>
                <template slot-scope="scope">{{ scope.row.icdname }}</template>
              </el-table-column>
 
              <el-table-column prop="icdcode" label="疾病编码" width="150">
              </el-table-column>
            </el-table>
          </el-row>
          <pagination
            v-show="patienttotal > 0"
            :total="patienttotal"
            :page.sync="patientqueryParams.pageNum"
            :limit.sync="patientqueryParams.pageSize"
            @pagination="handleAddpatient"
          />
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('addoption')">取 消</el-button>
        <el-button type="primary" @click="AddDispatchpatients"
          >确定添加</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { getillnesslist, deltargetillness } from "@/api/AiCentre/index";
export default {
  name: "Diseasetotality",
  data() {
    return {
      patienttotal: 0, //
      // 当前页选中数据
      multipleSelection: [],
      // 总选中数据
      // overallCase: [],
      patientqueryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      donorchargeList: [],
      donorchargeanlList: [], //案例列表
      // 新增:是否正在处理全选操作的标志
      isSelectAllProcessing: false,
    };
  },
 
  props: {
    dialogVisiblepatient: {
      type: Boolean,
      default: () => {
        return false;
      },
    },
    overallCase: {
      type: Array,
      required: true,
      default: () => [],
    },
    // 5问卷模板、3随访模板、6宣教
    type: {
      type: Number,
      default: () => {
        return 5;
      },
    },
  },
 
  created() {},
 
  mounted() {
    // this.handleAddpatient();
  },
 
  watch: {},
 
  methods: {
    handleClosehz() {
      this.$emit("addoption");
    },
    // 选择数据标签删除事件
    handleClose(item) {
      console.log(item);
      if (this.multipleSelection.indexOf(item) == -1 && !item.outid) {
        console.log(1);
        this.overallCase.splice(this.overallCase.indexOf(item), 1);
      } else if (item.outid) {
        this.$modal
          .confirm('是否确认删除名称为"' + item.icd10name + '"的数据项?')
          .then(() => {
            this.multipleSelection.splice(
              this.multipleSelection.indexOf(item),
              1
            );
            deltargetillness(item.id).then((res) => {
              if (res.code == 200) {
                this.$modal.msgSuccess("删除成功");
                this.overallCase.splice(this.overallCase.indexOf(item), 1);
              }
            });
            // 取消挂载状态
            this.$refs.multipleTable.toggleRowSelection(item, false);
          })
          .catch(() => {});
      } else {
        this.overallCase.splice(this.overallCase.indexOf(item), 1);
        this.multipleSelection.splice(this.multipleSelection.indexOf(item), 1);
        // 取消挂载状态
        this.$refs.multipleTable.toggleRowSelection(item, false);
      }
    },
    resetQuery() {
      this.patientqueryParams.icdname = null;
      this.handleAddpatient();
    },
    // 触发查询事件
    handleAddpatient(row) {
      this.$emit("kkoption");
 
      getillnesslist(this.patientqueryParams).then((res) => {
        this.donorchargeList = res.rows;
        this.patienttotal = res.total;
        this.Restorecheck();
      });
    },
 
    // 新增:处理单个选择
    handleSelect(selection, row) {
      if (this.isSelectAllProcessing) return;
 
      const isSelected = selection.includes(row);
      this.handleItemSelection(row, isSelected);
    },
 
    // 新增:处理全选/全不选
    handleSelectAll(selection) {
      this.isSelectAllProcessing = true;
 
      if (selection.length === 0) {
        // 全不选:移除当前页所有数据
        this.donorchargeList.forEach(item => {
          this.removeFromSelections(item);
        });
      } else {
        // 全选:添加当前页所有数据
        this.donorchargeList.forEach(item => {
          this.addToSelections(item);
        });
      }
 
      this.$nextTick(() => {
        this.isSelectAllProcessing = false;
      });
    },
 
    // 新增:处理单个项目的选择/取消选择
    handleItemSelection(row, isSelected) {
      if (isSelected) {
        this.addToSelections(row);
      } else {
        this.removeFromSelections(row);
      }
    },
 
    // 新增:添加到选中列表
    addToSelections(row) {
      // 如果已经在多选数组中,不再添加
      if (this.multipleSelection.some(item => item.icdid === row.icdid)) {
        return;
      }
 
      this.multipleSelection.push(row);
 
      // 添加到总数组
      if (this.overallCase.every(item => item.icdid !== row.icdid)) {
        this.overallCase.push({...row});
      }
    },
 
    // 新增:从选中列表移除
    removeFromSelections(row) {
      const index = this.multipleSelection.findIndex(item => item.icdid === row.icdid);
      if (index > -1) {
        this.multipleSelection.splice(index, 1);
      }
 
      // 从总数组中移除
      const overallIndex = this.overallCase.findIndex(item => item.icdid === row.icdid);
      if (overallIndex > -1) {
        this.overallCase.splice(overallIndex, 1);
      }
    },
 
    // 保留原有的selection-change事件处理,但简化逻辑
    handleSelectionChange(selection) {
      // 如果正在处理全选操作,不执行这里的逻辑
      if (this.isSelectAllProcessing) return;
 
      // 原有的复杂逻辑可以保留,但为了清晰,建议使用上面的新方法
      console.log('selection changed:', selection.length);
    },
 
    // 切换页后恢复选中
    Restorecheck() {
      console.log(this.overallCase, "this.overallCase");
      const allid = this.overallCase.map((item) => item.icdname);
      const overlap = this.donorchargeList.filter((value) => {
        return allid.includes(value.icdname);
      });
      // 保持ids和当前页面的同步性
      this.multipleSelection = overlap;
      console.log(this.multipleSelection, "进入分页multipleSelection");
 
      this.toggleSelection(overlap);
    },
    // 挂载选择状态
    toggleSelection(rows) {
      if (rows) {
        this.decision = true;
        this.$nextTick(() => {
          rows.forEach((row) => {
            this.$refs.multipleTable.toggleRowSelection(row, true);
          });
          this.decision = false;
        });
        console.log(123);
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    AddDispatchpatients() {
      this.$emit("addoption");
    },
 
    // 新增:检查是否可以选择(可选,用于控制某些行不可选)
    checkSelectable(row, index) {
      return true; // 所有行都可选
    }
  },
};
</script>
 
<style lang="scss" scoped>
.examine-jic {
  .headline {
    font-size: 24px;
    border-left: 5px solid #41a1be;
    padding-left: 5px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .Add-details {
      font-size: 18px;
      color: #02a7f0;
      cursor: pointer;
    }
  }
  .jic-value {
    font-size: 20px;
    border-top: 1px solid #a7abac;
    padding: 10px;
    margin-bottom: 10px;
    .details-jic {
      padding: 10px 15px;
      border: 1px solid #dcdfe6;
      -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
        0 0 6px 0 rgba(0, 0, 0, 0.04);
      .details-title {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
        div:nth-child(2) {
          color: #02a7f0;
          cursor: pointer;
        }
      }
      .details-renw {
        background: #e4ebfc;
        padding: 15px 5px;
        border-radius: 5px;
        margin-bottom: 20px;
      }
    }
  }
}
::v-deep.el-table .el-table__header th:first-child .el-checkbox {
  display: inline-block; /* 修改这里,显示全选复选框 */
}
.el-tag + .el-tag {
  margin-left: 10px;
  margin-bottom: 10px;
}
</style>