<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>
|