From f2138817fdd6e9141c5911514280b8d0b6ca08f1 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期三, 20 十一月 2024 14:48:49 +0800 Subject: [PATCH] 子组件刷新父组件不刷新页面,表单验证,upload组件预览图片,弹窗放在组件内部,bug修复 --- src/views/fysp/check/ProCheck.vue | 173 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 136 insertions(+), 37 deletions(-) diff --git a/src/views/fysp/check/ProCheck.vue b/src/views/fysp/check/ProCheck.vue index f0c4e53..cd3678f 100644 --- a/src/views/fysp/check/ProCheck.vue +++ b/src/views/fysp/check/ProCheck.vue @@ -3,7 +3,7 @@ <template #header> <SearchBar @on-submit="search"> <template #summary> - <CompSubTaskStatistic :subtasks="subtasks"/> + <CompSubTaskStatistic :subtasks="subtasks" /> </template> </SearchBar> </template> @@ -22,40 +22,78 @@ :loading="mainLoading" ></ToolBar> <el-scrollbar - v-if="curProList.length > 0" - class="el-scrollbar" - v-loading="mainLoading" - > - <CompProblemCard - v-for="(p, i) in curProList" - :key="i" - :index="i+1" - :problem="p" - @submit="updateSubtask" - ></CompProblemCard> - </el-scrollbar> + v-if="curProList.length > 0" + class="el-scrollbar" + v-loading="mainLoading" + > + <CompProblemCard + :key="i" + v-for="(p, i) in curProList" + :index="i + 1" + :problem="p" + :subtask="curSubtask.data" + :topTask="topTask" + @submit="updateSubtask" + ></CompProblemCard> + </el-scrollbar> <el-empty v-else description="鏆傛棤璁板綍" v-loading="mainLoading" /> </template> </BaseContentLayout> + <CompProblemAddOrUpd + title="鏂板闂" + v-if="proAddOrUpdDialogVisible" + v-model:visible="proAddOrUpdDialogVisible" + :subtask="curSubtask.data" + :topTask="topTask" + ref="compProblemAddOrUpdRef" + @submit="updateSubtask" + /> + <ArbitraryPhoto + v-if="anyPhotoDialog" + v-model:dialog-visible="anyPhotoDialog" + :readonly="true" + :subtask="curSubtask.data" + ref="arbitraryPhotoRef" + ></ArbitraryPhoto> + <CompDeviceShowTest + title="璁炬柦璁惧" + v-model:visible="deviceShowDialog" + v-if="deviceShowDialog" + ref="deviceShowRef" + > + </CompDeviceShowTest> </template> <script> +import ArbitraryPhoto from './components/ArbitraryPhoto.vue'; import taskApi from '@/api/fysp/taskApi'; import ProCheckProxy from './ProCheckProxy'; - -import { ElMessageBox, ElNotification, ElMessage } from 'element-plus'; - +import CompProblemAddOrUpd from './components/CompProblemAddOrUpd.vue'; import CompProblemCard from './components/CompProblemCard.vue'; import CompSubTaskStatistic from './components/CompSubTaskStatistic.vue'; - +import CompDeviceShowTest from './components/CompDeviceShowTest.vue'; export default { - components: { CompProblemCard, CompSubTaskStatistic }, + components: { + CompProblemCard, + CompSubTaskStatistic, + CompProblemAddOrUpd, + ArbitraryPhoto, + CompDeviceShowTest + }, data() { return { + // 璁惧鍥� + deviceShowDialog: false, + // 浠绘剰鍥� + anyPhotoDialog: false, + // 鏂板闂 + proAddOrUpdDialogVisible: false, //宸︿晶鑿滃崟鏍忓姞杞界姸鎬� sideLoading: false, //鍙充晶鍐呭鏍忓姞杞界姸鎬� mainLoading: false, + // 鎬讳换鍔� + topTask: {}, //瀛愪换鍔″垪琛� subtasks: [], //褰撳墠閫変腑鐨勪换鍔� @@ -67,16 +105,30 @@ { name: '鏂板闂', color: 'success', + click: () => { + this.proAddOrUpdDialogVisible = true; + } }, { - name: '浠绘剰鍥剧墖', + name: '鍦烘櫙鍥剧墖', color: 'warning', + click: () => { + this.anyPhotoDialog = true; + } }, { - name: '鎵归噺瀹℃牳', - color: 'primary', - }, - ], + name: '璁炬柦璁惧', + color: 'info', + click: () => { + this.openDeviceShowDialog(); + } + } + // { + // name: '鎵归噺瀹℃牳', + // color: 'primary', + // click: () => {} + // } + ] }; }, computed: { @@ -90,50 +142,50 @@ { name: '浠诲姟鎬昏', value: 0, - type: 'info', + type: 'info' }, { name: '闂鏈鏍�', value: 0, type: 'success', - icon: 'SuccessFilled', + icon: 'SuccessFilled' }, { name: '闂閮ㄥ垎瀹℃牳', value: 0, type: 'success', - icon: 'SuccessFilled', + icon: 'SuccessFilled' }, { name: '闂鍏ㄩ儴瀹℃牳', value: 0, type: 'success', - icon: 'SuccessFilled', + icon: 'SuccessFilled' }, { name: '鏈暣鏀�', value: 0, type: 'info', - icon: 'WarningFilled', + icon: 'WarningFilled' }, { name: '鏁存敼鏈鏍�', value: 0, type: 'info', - icon: 'WarningFilled', + icon: 'WarningFilled' }, { name: '鏁存敼閮ㄥ垎瀹℃牳', value: 0, type: 'warning', - icon: 'WarningFilled', + icon: 'WarningFilled' }, { name: '鏁存敼鍏ㄩ儴瀹℃牳', value: 0, type: 'warning', - icon: 'WarningFilled', - }, + icon: 'WarningFilled' + } ]; this.subtasks.forEach((s) => { @@ -158,16 +210,28 @@ }); return _summary; - }, + } }, methods: { + // 鎵撳紑璁惧鍥� + openDeviceShowDialog() { + this.deviceShowDialog = true; + this.$nextTick(() => { + this.$refs.deviceShowRef.init(this.curSubtask.data.scene); + }); + }, //鏌ヨ瀛愪换鍔$粺璁′俊鎭� search(formSearch) { + this.topTask = formSearch.topTask; this.sideLoading = true; this.mainLoading = true; this.curProList = []; this.curSubtask = {}; - taskApi.getSubtaskSummary(formSearch).then((res) => { + const param = { + topTaskId: formSearch.topTask.tguid, + sceneTypeId: formSearch.sceneTypeId + }; + taskApi.getSubtaskSummary(param).then((res) => { const list = []; res.forEach((s) => { const t = this.getSubtaskType(s); @@ -175,7 +239,7 @@ type: t, title: s.stName, categoly: s.stPlanTime.split('T')[0], - data: s, + data: s }); }); this.subtasks = list; @@ -201,6 +265,7 @@ }, //鐐瑰嚮宸︿晶鑿滃崟浠诲姟浜嬩欢 chooseSubtask(s) { + // this.currInsGuid = s.data.insGuid this.sideLoading = false; this.mainLoading = true; // const controller = new AbortController(); @@ -214,12 +279,46 @@ this.mainLoading = false; }); }, - updateSubtask() { + // 闂鍗$墖缁勪欢涓诲姩鍙戣捣鍒锋柊鐖剁粍浠舵暟鎹� + updateSubtask(refresh = false) { this.curSubtask.data.proCheckedNum++; this.curSubtask.type = this.getSubtaskType(this.curSubtask.data); + if (this.proAddOrUpdDialogVisible) { + this.proAddOrUpdDialogVisible = false + } + this.refreshCurrSubtask(refresh); + }, + // 鍒锋柊褰撳墠閫変腑瀛愪换鍔� + refreshCurrSubtask(refresh) { + this.sideLoading = false; + this.mainLoading = true; + setTimeout(() => { + taskApi + .getProBySubtask(this.curSubtask.data.stGuid) + .then((res) => { + if (refresh) { + this.curProList = res; + return; + } + const currProLen = this.curProList.length; + // 涓嶆敼鍙樻暟缁勫鍍忓紩鐢ㄧ殑鍓嶆彁涓嬮噸鏂拌祴鍊� + for (let index = 0; index < res.length; index++) { + const element = res[index]; + if (currProLen < index + 1) { + this.curProList.push(element); + } else { + this.curProList[index] = element; + } + } + // this.curSubtask = s; + }) + .finally(() => { + this.mainLoading = false; + }); + }, 150); } }, - mounted() {}, + mounted() {} }; </script> -- Gitblit v1.9.3