From d4e7c11e06b643c9353444c839cec40c25945219 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期三, 30 十月 2024 17:37:05 +0800 Subject: [PATCH] 1. 场景报告模块编写(暂存) --- src/views/fysp/data-product/ProdSceneReport.vue | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 270 insertions(+), 2 deletions(-) diff --git a/src/views/fysp/data-product/ProdSceneReport.vue b/src/views/fysp/data-product/ProdSceneReport.vue index 906fad3..a6abc18 100644 --- a/src/views/fysp/data-product/ProdSceneReport.vue +++ b/src/views/fysp/data-product/ProdSceneReport.vue @@ -1,3 +1,271 @@ <template> - 鍦烘櫙鎶ュ憡绠$悊 -</template> \ No newline at end of file + <BaseContentLayout> + <template #header> + <SearchBar @on-submit="search"> </SearchBar> + </template> + <template #aside> + <SideList + :items="subtasks" + :loading="sideLoading" + @item-click="chooseSubtask" + ></SideList> + </template> + <template #main> + <el-scrollbar class="el-scrollbar" v-loading="mainLoading"> + <CompSceneConstructionInfo + title="A銆佸伐鍦板熀鏈俊鎭�" + :form-info="formSubScene" + /> + <div><el-text type="">闄勫浘鐗囷細</el-text></div> + <CompImgInfo + title="鏂藉伐閾墝" + :img-src="sceneImg.url" + @change="anyPhotoDialog = true" + ></CompImgInfo> + <el-divider /> + <el-text tag="h1">B銆佷富瑕佹薄鏌撻槻娌昏鏂�</el-text> + <el-space wrap> + <CompImgInfo + v-for="(item, i) in deviceList" + :key="i" + down-title + :title="item._deviceTypeName" + :img-src="item._showStatusPic" + @change="showDevicePhotoDialog(item)" + ></CompImgInfo> + </el-space> + <el-divider /> + <el-text tag="h1">C銆佺幇鍦烘薄鏌撻棶棰樹笌鏁存敼鎯呭喌</el-text> + </el-scrollbar> + </template> + </BaseContentLayout> + <el-dialog + v-model="anyPhotoDialog" + width="66%" + title="浠绘剰鍥剧墖" + destroy-on-close + > + <ArbitraryPhoto + :max-select="1" + :readonly="false" + :subtask="curSubtask.data" + @selectByAnyPhonoEvent="handleSelectAnyPhoto" + :defaultFile="[sceneImg]" + > + </ArbitraryPhoto> + </el-dialog> + <el-dialog + title="璁惧鍥剧墖" + width="66%" + v-model="deiveceImgDialog" + destroy-on-close + > + <CompDevicePhono + @selectPhonoEvent="handleSelectDevicePhoto" + :imgPathsDataSource="showDeviceImgList" + > + </CompDevicePhono> + </el-dialog> +</template> +<script setup> +import { ref, computed } from 'vue'; + +import { $fysp } from '@/api/index'; +import taskApi from '@/api/fysp/taskApi'; +import sceneApi from '@/api/fysp/sceneApi'; +import deviceApi from '@/api/fysp/deviceApi'; +import { formatDeviceList } from '@/model/fysp/device'; +import { enumDevice, toLabel } from '@/enum/device/device'; + +import CompSceneConstructionInfo from '@/views/fysp/scene/CompSceneConstructionInfo.vue'; +import ArbitraryPhoto from '@/views/fysp/check/components/ArbitraryPhoto.vue'; +import CompDevicePhono from '@/views/fysp/check/components/CompDevicePhono.vue'; +import CompImgInfo from '@/views/fysp/data-product/components/CompImgInfo.vue'; + +/************************* 宸︿晶宸℃煡浠诲姟閫夊崟 **********************************/ +const curSubtask = ref({}); +const subtasks = ref([]); +const sideLoading = ref(false); +const mainLoading = ref(false); +//鑾峰彇浠诲姟闂鐨勫鏍告儏鍐� +function getSubtaskType(s) { + let type = 0; + if (s.proNum == 0) { + type = 2; + } else if (s.proCheckedNum == 0) { + type = 0; + } else if (s.proCheckedNum < s.proNum) { + type = 1; + } else { + type = 2; + } + return type; +} +//鏌ヨ瀛愪换鍔$粺璁′俊鎭� +function search(formSearch) { + // this.topTask = formSearch.topTask; + sideLoading.value = true; + mainLoading.value = true; + // this.curProList = []; + curSubtask.value = {}; + const param = { + topTaskId: formSearch.topTask.tguid, + sceneTypeId: formSearch.sceneTypeId + }; + taskApi.getSubtaskSummary(param).then((res) => { + const list = []; + res.forEach((s) => { + const t = getSubtaskType(s); + list.push({ + type: t, + title: s.stName, + categoly: s.stPlanTime.split('T')[0], + data: s + }); + }); + subtasks.value = list; + if (list.length == 0) { + sideLoading.value = false; + mainLoading.value = false; + } + }); +} +//鐐瑰嚮宸︿晶鑿滃崟浠诲姟浜嬩欢 +function chooseSubtask(s) { + sideLoading.value = false; + mainLoading.value = true; + curSubtask.value = s; + + fetchSceneInfo(s.data.sceneId).finally(() => { + mainLoading.value = false; + }); + fetchDeviceList(s); + fetchProblems(s) +} + +/************************* 鍦烘櫙鍩烘湰淇℃伅 **********************************/ +const formSubScene = ref({}); +function fetchSceneInfo(sceneId) { + return sceneApi.getSceneDetail(sceneId).then((res) => { + //鍦烘櫙 + // if (res.data.scense) formScene = res.data.scense; + formSubScene.value = res.data.subScene ? res.data.subScene : {}; + // if (res.data.sceneDevice) { + // formSceneDevice = res.data.sceneDevice; + // } else { + // formSceneDevice = { + // sGuid: formScene.guid, + // }; + // } + }); +} + +// 浠绘剰鎷嶅浘鐗囬�夋嫨瀵硅瘽妗� +const anyPhotoDialog = ref(false); +const sceneImg = ref({}); +function handleSelectAnyPhoto(data) { + anyPhotoDialog.value = false; + if (data.length > 0) { + sceneImg.value = { url: data[0].url }; + } +} +/************************* 鍦烘櫙璁惧淇℃伅 **********************************/ + +// 璁惧鍥剧墖閫夋嫨瀵硅瘽妗� +const deiveceImgDialog = ref(false); +const showDeviceImg = ref({}); +const showDeviceImgList = ref([]); +// 璁惧鍥剧墖鍒楄〃 +const deviceList = ref([]); + +function showDevicePhotoDialog(device) { + deiveceImgDialog.value = true; + showDeviceImgList.value = []; + let imgList = []; + device._status + .map((s) => s._picUrls) + .forEach((pics) => { + imgList = imgList.concat( + pics.map((p) => { + return { + topTypeId: device.topTypeId, + _picUrl: p + }; + }) + ); + }); + console.log(imgList); + + showDeviceImgList.value = imgList; +} + +function handleSelectDevicePhoto(data) { + deiveceImgDialog.value = false; + if (data.length > 0) { + showDeviceImg.value = { url: data[0].url }; + } +} + +const deviceTopTypes = [ + { id: 0, label: '鐩戞帶璁惧' }, + { id: 1, label: '娌荤悊璁惧' } + // { id: 2, label: '鐢熶骇璁惧' } +]; + +function fetchDeviceList(s) { + deviceList.value = []; + for (const deviceTopTypeElement of deviceTopTypes) { + const topTypeId = deviceTopTypeElement.id; + deviceApi + .fetchDevices(s.data.sceneId, topTypeId) + .then((res) => { + return formatDeviceList(res.data); + }) + .then((result) => { + result.forEach((r) => { + const param = { + deviceId: r.id, + sceneId: r.sceneGuid, + deviceTypeId: topTypeId + }; + deviceApi + .fetchDeviceStatus(param) + .then((res) => { + res.data.forEach((e) => { + if (e.dlPicUrl && e.dlPicUrl.trim() != '') { + e._picUrls = e.dlPicUrl + .split(';') + .map((v) => $fysp.imgUrl + v); + } else { + e._picUrls = []; + } + }); + return res; + }) + .then((res) => { + if (res.data.length > 0 && res.data[0]._picUrls.length > 0) { + r._showStatusPic = res.data[0]._picUrls[0]; + } + r._status = res.data; + r.topTypeId = topTypeId; + r._deviceTypeName = toLabel(r.sceneTypeId, topTypeId, [ + r.typeId, + r.subtypeId + ]).join('-'); + deviceList.value.push(r); + }); + }); + }); + } +} +/************************* 鐜板満宸℃煡鎯呭喌锛堥棶棰樹笌鏁存敼锛� **********************************/ +//褰撳墠浠诲姟鐨勯棶棰樺垪琛� +const curProList = ref([]); + +function fetchProblems(s) { + taskApi.getProBySubtask(s.data.stGuid).then((res) => { + curProList.value = res; + }); +} +/************************* 鎵皹闃叉不寤鸿 **********************************/ +</script> -- Gitblit v1.9.3