From 3a7d2ac354afb614ced5d7fa811b1f266315715e Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Fri, 2 Sep 2022 22:02:14 +0800 Subject: [PATCH] =?UTF-8?q?:rocket:=20=E4=BC=98=E9=9B=85=E7=9A=84=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AMap/src/AMapDesigner/index.vue | 26 ++++++++++-------- .../AMap/src/components/MapTaskModal.vue | 27 ++++++++++++++----- .../src/components/MapTaskPresetModal.vue | 22 +++++++++++---- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/components/AMap/src/AMapDesigner/index.vue b/src/components/AMap/src/AMapDesigner/index.vue index 66b4181..3faf376 100644 --- a/src/components/AMap/src/AMapDesigner/index.vue +++ b/src/components/AMap/src/AMapDesigner/index.vue @@ -155,7 +155,7 @@ const emit = defineEmits(['success']); const userStore = useUserStore(); const instance = getCurrentInstance(); - const { createMessage } = useMessage(); + const { notification } = useMessage(); const { mapDesigner } = componentSetting; const mapState = reactive({ /** 遮罩层状态 */ @@ -619,10 +619,12 @@ mapState.mapData.mapTask.forEach(item => { const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId); const org = mapState.orgList.find(e => e.value == item.orgId); - // 下级医院必选,没有数据说明数据被更新过了 + // 下级医院必选,所以必须查到,没有数据说明数据被更新过了 if (!hospital) { - createMessage.error('当前机构数据或者医院数据已经更新,请重新刷新页面!'); - throw Error('当前机构数据或者医院数据已经更新,请重新刷新页面!'); + throw notification.error({ + message: '当前机构数据或者医院数据已经更新,请重新刷新页面!', + duration: 2 + }); } pointData.push({ lng: hospital.mapLng, @@ -630,6 +632,7 @@ sort: undefined, type: '0', key: item.key, + taskType: item.taskType, hospitalId: hospital.value, hospitalName: hospital.label }); @@ -639,6 +642,7 @@ sort: undefined, type: '1', key: item.key, + taskType: item.taskType, hospitalId: org.value, hospitalName: org.label }); @@ -683,10 +687,10 @@ async function handleMapSave() { await formElRef.value.validate(); const mapData = toRaw(mapState.mapData); - mapData.fileId = (mapData.fileId as [] || []).join(','); + mapData.fileId = (mapData.fileId as[])?.join(','); mapData.mapTask.forEach(item => { - const hospital = mapState.hospitalList.find(e => e.value == item.hospitalId), - org = mapState.orgList.find(e => e.value == item.orgId); + const hospital = item.hospitalId && mapState.hospitalList.find(e => e.value == item.hospitalId), + org = item.orgId && mapState.orgList.find(e => e.value == item.orgId); item.courierUserId = mapData.courierUserId; hospital && Object.assign(item,{ hospitalName: hospital.label, @@ -698,11 +702,11 @@ orgLng: org.mapLng, orgLat: org.mapLat }); - item.fileId = (item.fileId as [] || []).join(','); + item.fileId = (item.fileId as [])?.join(','); if (~~item.taskType == 1) { item?.mapTaskPreset?.forEach(childItem => { - const childHospital = mapState.hospitalList.find(e => e.value == childItem.hospitalId), - childOrg = mapState.orgList.find(e => e.value == childItem.orgId); + const childHospital = childItem.hospitalId && mapState.hospitalList.find(e => e.value == childItem.hospitalId), + childOrg = childItem.orgId && mapState.orgList.find(e => e.value == childItem.orgId); childItem.courierUserId = mapData.courierUserId; childHospital && Object.assign(item,{ orginPresetName: childHospital.label, @@ -714,7 +718,7 @@ destinationPresetLng: childOrg.mapLng, destinationPresetLat: childOrg.mapLat }); - childItem.fileId = (childItem.fileId as [] || [])?.join(','); + childItem.fileId = (childItem.fileId as [])?.join(','); }); } }); diff --git a/src/components/AMap/src/components/MapTaskModal.vue b/src/components/AMap/src/components/MapTaskModal.vue index 8cb76e9..e098c10 100644 --- a/src/components/AMap/src/components/MapTaskModal.vue +++ b/src/components/AMap/src/components/MapTaskModal.vue @@ -94,7 +94,7 @@ // 尾部:设置处理后的最终配置数据 setModalProps(props); }); - const { createMessage } = useMessage(); + const { notification } = useMessage(); const [taskPresetRegisterModal, { openModal }] = useModal(); const [taskOrdinaryRegisterTable, { getDataSource: getTaskOrdinaryDataSource, @@ -162,7 +162,10 @@ const index = getTaskOrdinaryDataSource().findIndex(item => item.key == record.key); if (index != -1) { getTaskOrdinaryDataSource().splice(record.index, 1); - } else createMessage.error(`找不到key:${record.key}的数据,请刷新页面重试!`); + } else notification.error({ + message: `找不到key:${record.key}的数据,请刷新页面重试!`, + duration: 2 + }); } /** 处理交接任务新增 */ @@ -182,7 +185,10 @@ const index = getTaskPresetDataSource().findIndex(item => item.key == record.key); if (index != -1) { getTaskPresetDataSource().splice(record.index, 1); - } else createMessage.error(`找不到key:${record.key}的数据,请刷新页面重试!`); + } else notification.error({ + message: `找不到key:${record.key}的数据,请刷新页面重试!`, + duration: 2 + }); } /** 创建普通任务操作列 */ @@ -299,8 +305,14 @@ setModalProps({ confirmLoading: true }); const taskOrdinaryData = toRaw(getTaskOrdinaryDataSource()); const taskPresetData = toRaw(getTaskPresetDataSource()); - if (state.taskOrdinaryCurrentEditRowRef || state.taskPresetCurrentEditRowRef) return createMessage.error('表格行未保存,请检查!'); - if (taskOrdinaryData.length === 0 && taskPresetData.length === 0) return createMessage.error('表格数据不能为空!'); + if (state.taskOrdinaryCurrentEditRowRef || state.taskPresetCurrentEditRowRef) throw notification.error({ + message: '表格行未保存,请检查!', + duration: 2 + }); + if (taskOrdinaryData.length === 0 && taskPresetData.length === 0) throw notification.error({ + message: '表格数据不能为空!', + duration: 2 + }); // 校验表格是否通过 const validateData:Promise[] = []; taskOrdinaryData.forEach(item => { @@ -310,7 +322,10 @@ validateData.push(item.onValid?.() || Promise.resolve(true)); }); const validateResult = await Promise.all(validateData); - if (!validateResult.every(item => item)) return createMessage.error('表格行校验未通过,请检查!'); + if (!validateResult.every(item => item)) throw notification.error({ + message: '表格行校验未通过,请检查!', + duration: 2 + }); state.mapData.mapTask = [...taskOrdinaryData, ...taskPresetData]; // 处理提交完成之后逻辑 closeModal(); diff --git a/src/components/AMap/src/components/MapTaskPresetModal.vue b/src/components/AMap/src/components/MapTaskPresetModal.vue index 4cee1ac..2837fb0 100644 --- a/src/components/AMap/src/components/MapTaskPresetModal.vue +++ b/src/components/AMap/src/components/MapTaskPresetModal.vue @@ -78,7 +78,7 @@ const ASelect = Select; const formElRef = ref(); const emit = defineEmits(['success', 'register']); - const { createMessage } = useMessage(); + const { notification } = useMessage(); const [registerModal, { setModalProps, closeModal }] = useModalInner(async data => { // 处理清除脏数据 formElRef.value.resetFields(); @@ -170,7 +170,10 @@ const index = getDataSource().findIndex(item => item.key == record.key); if (index != -1) { getDataSource().splice(record.index, 1); - } else createMessage.error(`找不到key:${record.key}的数据,请刷新页面重试!`); + } else notification.error({ + message: `找不到key:${record.key}的数据,请刷新页面重试!`, + duration: 2 + }); } /** 创建转办任务操作列 */ @@ -233,8 +236,14 @@ // 处理提交之前逻辑 setModalProps({ confirmLoading: true }); const mapTaskPresetData = toRaw(getDataSource()); - if (state.currentEditRowRef) return createMessage.error('表格行未保存,请检查!'); - if (mapTaskPresetData.length === 0) return createMessage.error('表格数据不能为空!'); + if (state.currentEditRowRef) throw notification.error({ + message: '表格行未保存,请检查!', + duration: 2 + }); + if (mapTaskPresetData.length === 0) throw notification.error({ + message: '表格数据不能为空!', + duration: 2 + }); const formData = await formElRef.value.validate(); const validateData:Promise[] = []; // 清除旧的上级医检医院 @@ -248,7 +257,10 @@ } }); const validateResult = await Promise.all(validateData); - if (!validateResult.every(item => item)) return createMessage.error('表格行校验未通过,请检查!'); + if (!validateResult.every(item => item)) throw notification.error({ + message: '表格行校验未通过,请检查!', + duration: 2 + }); // 自动填充交接最终到达上级医检医院 const lastElement = mapTaskPresetData[mapTaskPresetData.length - 1]; const option = state.orgList.find(item => item.value == formData.destinationPresetId);