From c1d2051abc8ca88cd07f0d7c56c0dbf8165d5c33 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 18 九月 2025 17:02:22 +0800 Subject: [PATCH] 2025.9.18 数据产品(待完成) --- src/views/fysp/check/components/CompDevicePhoto.vue | 107 ++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/views/fysp/check/components/CompDevicePhoto.vue b/src/views/fysp/check/components/CompDevicePhoto.vue index 94d2112..275e866 100644 --- a/src/views/fysp/check/components/CompDevicePhoto.vue +++ b/src/views/fysp/check/components/CompDevicePhoto.vue @@ -1,29 +1,35 @@ <template> <FYImageSelectDialog + v-loading="loading" + title="璁惧鍥剧墖" :typeList="typeList" :typeImgMap="typeImgMap" - :maxSelect="1" ></FYImageSelectDialog> </template> <script setup> -import { ref, watch, computed } from 'vue'; - +import { ref, computed, onMounted } from 'vue'; +import deviceApi from '@/api/fysp/deviceApi'; +import { useCloned } from '@vueuse/core'; +import { $fysp } from '@/api/index.js'; +const loading = ref(true) const props = defineProps({ // 灞曠ず妯″紡 mode: { type: Number, default: 0 }, - pics: Array + subtask: { + type: Array, + default: () => [] + } }); -// typeList: [ -// { id: 0, label: '鐩戞帶璁惧' }, -// { id: 1, label: '娌荤悊璁惧' }, -// { id: 2, label: '鐢熶骇璁惧' } -// ], const typeList = computed(() => { if (props.mode == 0) { - return [{ typeId: 0, typeName: '鐩戞帶璁惧' }]; + return [ + { typeId: 0, typeName: '鐩戞帶璁惧' }, + { typeId: 1, typeName: '娌荤悊璁惧' }, + { typeId: 2, typeName: '鐢熶骇璁惧' } + ]; } else if (props.mode == 1) { return [{ typeId: 1, typeName: '鏁存敼' }]; } else { @@ -31,23 +37,70 @@ } }); const typeImgMap = ref(new Map()); +// 鏍囧噯鍖栧睘鎬у悕 +function convertKeys(obj) { + // 灏嗕竴涓猨s瀵硅薄涓墍鏈塪i锛寃i锛宲i寮�澶寸殑灞炴�у叏閮ㄦ敼鎴愬幓鎺夎繖浜涘墠缂�骞朵笖閲嶆柊鍙樹负椹煎嘲寮忓懡鍚� + const newObj = {}; + for (const key in obj) { + let newKey = key; + if (key.startsWith('di')) { + newKey = key.substring(2); + } else if (key.startsWith('wi')) { + newKey = key.substring(2); + } else if (key.startsWith('pi')) { + newKey = key.substring(2); + } + newKey = newKey.charAt(0).toLowerCase() + newKey.slice(1); + newObj[newKey] = obj[key]; + } + return newObj; +} +// 淇濆瓨鐘舵�佷俊鎭� +function saveStatus(device, status) { + var _picUrl = $fysp.imgUrl + status.dlPicUrl; + device.url = _picUrl; +} +function getDeviceImgList() { + let deviceImgMap = typeImgMap.value; + for (const deviceTopTypeElement of typeList.value) { + const topTypeId = deviceTopTypeElement.typeId; + deviceImgMap.set(topTypeId, []); + deviceApi.fetchDevices(props.subtask.sceneId, topTypeId).then((result) => { + loading.value = true; + // 鏍囧噯鍖栧睘鎬у悕 + for (let i = 0; i < result.data.length; i++) { + var element = convertKeys(result.data[i]); + // 鑾峰彇璁惧鐘舵�佷俊鎭� + let data = { + deviceId: element.id, + sceneId: element.sceneGuid, + deviceTypeId: topTypeId + }; + deviceApi.fetchDeviceStatus(data).then((status) => { + var statusData = status.data; + if (statusData) { + if (statusData.length == 0) { + return; + } + element = convertKeys(result.data[i]); + for (let j = 0; j < statusData.length; j++) { + // 澶嶅埗鍑轰竴涓澶囧璞� + var newDevice = useCloned(element).cloned.value; + const statusItem = statusData[j]; + // 璁惧瀵硅薄娣诲姞涓�涓睘鎬у垪琛ㄥ睘鎬х敤鏉ヤ繚瀛樿澶囩姸鎬� + saveStatus(newDevice, statusItem); + newDevice.dlLocation = statusItem.dlLocation; + newDevice.topTypeId = topTypeId; -watch( - () => props.pics, - (nV, oV) => { - nV.forEach(e => { - if (!typeImgMap.value.has(e.topTypeId)) { - typeImgMap.value.set(e.topTypeId, []) + deviceImgMap.get(topTypeId).push(newDevice); + } + } + }).finally(() => (loading.value = false)); } - typeImgMap.value.get(r.topTypeId).push({}) }); - typeImgMap.value.set( - 1, - nV.map((v) => { - return { url: v }; - }) - ); - }, - { immediate: true } -); -</script> \ No newline at end of file + } +} +onMounted(() => { + getDeviceImgList(); +}); +</script> -- Gitblit v1.9.3