医嘱项:
{{item.entrust.entrust}}
@@ -299,7 +299,10 @@
//先让所有项目都同时选中,以后可能会调用接口查询 然后再更新此变量
MainInfo.value.forEach((v, i) => {
v.itemInfo.forEach((v2, i2) => {
- EnableGroupItem.value.push(v2.item)
+ // 确保EnableGroupItem数组只包含唯一id的项目
+ if (!EnableGroupItem.value.some(item2 => item2.id === v2.item.id)) {
+ EnableGroupItem.value.push(v2.item)
+ }
})
})
SelectedEntrustFunc()
@@ -368,11 +371,75 @@
}
})
}
+ //点击左侧医嘱项
+ const EntrustItemClick = (item, index, index1) => {
+ // 切换当前项目的选中状态
+ item.selected = !item.selected
+
+ // 更新EnableGroupItem数组,使用组合key确保唯一性
+ updateEnableGroupItem()
+
+ // 更新检查项目和请求号源
+ updateYuYueInfoAndRequest()
+ }
+
+ // 更新EnableGroupItem数组
+ const updateEnableGroupItem = () => {
+ EnableGroupItem.value = []
+ MainInfo.value.forEach((v, i) => {
+ v.itemInfo.forEach((v2, i2) => {
+ if (v2.selected) {
+ EnableGroupItem.value.push(v2.item)
+ }
+ })
+ })
+ }
+
+ // 更新预约信息并请求号源
+ const updateYuYueInfoAndRequest = () => {
+ startYuYueInfo.value.entrustItems = ''
+ startYuYueInfo.value.entrustids = []
+ startYuYueInfo.value.mainListids = []
+
+ let hasSelected = false
+
+ MainInfo.value.forEach((v, i) => {
+ v.itemInfo.forEach((v2, i2) => {
+ if (v2.selected) {
+ hasSelected = true
+ startYuYueInfo.value.entrustItems += v2.item.item_name + ' , '
+ startYuYueInfo.value.entrustids.push(v2.entrust.entrust_id)
+ startYuYueInfo.value.mainListids.push(v2.entrust.id)
+ }
+ })
+ })
+
+ // 如果没有选中任何项目,清空号源信息且不请求接口
+ if (!hasSelected) {
+ // 清空号源表格数据
+ tableData1.value = { plan_list: [] }
+ tableData2.value = { plan_list: [] }
+ // 清空预约信息
+ startYuYueInfo.value.planInfo = {
+ id: 0,
+ date: '',
+ timeRange: '',
+ department_resources_name: ''
+ }
+ } else {
+ // 请求号源
+ NearestEnablePlanDateFunc()
+ }
+ }
+
//选中左侧医嘱
const SelectedEntrustFunc = () => {
startYuYueInfo.value.entrustItems = ''
startYuYueInfo.value.entrustids = []
startYuYueInfo.value.mainListids = []
+
+ let hasSelected = false
+
MainInfo.value.forEach((v, i) => {
v.itemInfo.forEach((v2, i2) => {
let isok = false;
@@ -381,8 +448,11 @@
isok = true;
}
})
+ // 更新所有项目的选中状态
+ MainInfo.value[i].itemInfo[i2].selected = isok
+
if (isok) {
- MainInfo.value[i].itemInfo[i2].selected = true
+ hasSelected = true
startYuYueInfo.value.entrustItems += v2.item.item_name + ' , '
startYuYueInfo.value.entrustids.push(v2.entrust.entrust_id)
startYuYueInfo.value.mainListids.push(v2.entrust.id)
@@ -390,7 +460,22 @@
})
})
- NearestEnablePlanDateFunc()
+
+ // 如果没有选中任何项目,清空号源信息且不请求接口
+ if (!hasSelected) {
+ // 清空号源表格数据
+ tableData1.value = { plan_list: [] }
+ tableData2.value = { plan_list: [] }
+ // 清空预约信息
+ startYuYueInfo.value.planInfo = {
+ id: 0,
+ date: '',
+ timeRange: '',
+ department_resources_name: ''
+ }
+ } else {
+ NearestEnablePlanDateFunc()
+ }
}
//切换日期