From 36c3a0fe4f6750891cb69f9622e141b2f74f38b9 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期五, 15 十一月 2024 17:01:58 +0800 Subject: [PATCH] 码头搅拌站模版导出 --- src/views/fysp/data-product/ProdSceneReport.vue | 471 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 471 insertions(+), 0 deletions(-) diff --git a/src/views/fysp/data-product/ProdSceneReport.vue b/src/views/fysp/data-product/ProdSceneReport.vue index e69de29..4e768b9 100644 --- a/src/views/fysp/data-product/ProdSceneReport.vue +++ b/src/views/fysp/data-product/ProdSceneReport.vue @@ -0,0 +1,471 @@ +<template> + <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 + v-if="curSubtask.data && curSubtask.data.sceneTypeId == 1" + title="A銆佸熀鏈俊鎭�" + :scene="formScene" + :form-info="formSubScene" + :scene-type="1" + /> + <CompSceneWharfInfo + v-else-if="curSubtask.data && curSubtask.data.sceneTypeId == 2" + title="A銆佸熀鏈俊鎭�" + :scene="formScene" + :form-info="formSubScene" + :scene-type="2" + /> + <CompSceneMixingPlantInfo + v-else-if="curSubtask.data && curSubtask.data.sceneTypeId == 3" + title="A銆佸熀鏈俊鎭�" + :scene="formScene" + :form-info="formSubScene" + :scene-type="3" + /> + <div v-else><el-text tag="h1">A銆佸熀鏈俊鎭�</el-text></div> + <div><el-text type="">闄勫浘鐗囷細</el-text></div> + <CompImgInfo + v-model:title="imgTitle" + :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 + v-model:title="item._deviceTypeName" + :img-src="item._showStatusPic" + @change="showDevicePhotoDialog(item, i)" + ></CompImgInfo> + </el-space> + <el-divider /> + <el-text tag="h1">C銆佺幇鍦烘薄鏌撻棶棰樹笌鏁存敼鎯呭喌</el-text> + <el-space wrap> + <CompProblemTable + v-for="(item, i) in curProList" + :key="i" + :problem="item" + @change="(value) => handleProPicSelect(value, i)" + ></CompProblemTable> + </el-space> + <el-divider /> + <el-text tag="h1">D銆佹壃灏樻薄鏌撻槻娌诲缓璁�</el-text> + <div class="p-b-8"> + 閽堝璇ュ伐鍦版湰鏈熷贰鏌ュ彂鐜扮殑闂锛岃瘎浼颁负鎵皹姹℃煋闃叉不 + <el-radio-group v-model="radioStandard" size="default"> + <el-radio value="瑙勮寖" border>瑙勮寖</el-radio> + <el-radio value="鍩烘湰瑙勮寖" border>鍩烘湰瑙勮寖</el-radio> + <el-radio value="涓嶈鑼�" border>涓嶈鑼�</el-radio> + <el-radio value="涓ラ噸涓嶈鑼�" border>涓ラ噸涓嶈鑼�</el-radio> + </el-radio-group> + 宸ュ湴锛屽缓璁宸ュ湴涓ユ牸鎸夌収銆婃壃灏橀槻娌绘柟妗堛�嬨�併�婃壃灏橀槻娌绘壙璇轰功銆嬨�併�婃枃鏄庢柦宸ョ鐞嗚鑼冦�嬨�併�婄簿缁嗗寲绠$悊鎸囨爣銆嬬瓑鐩稿叧鏂囦欢钀藉疄鏁存敼銆� + </div> + <el-row justify="center" style="height: 200px"> + <el-button + icon="Download" + type="primary" + :loading="docLoading" + :disabled="!sceneImg.url" + @click="genWord()" + > + 鐢熸垚鎶ュ憡 + </el-button> + </el-row> + </el-scrollbar> + </template> + </BaseContentLayout> + <ArbitraryPhoto + v-if="anyPhotoDialog" + v-model:dialog-visible="anyPhotoDialog" + :max-select="1" + :readonly="false" + :subtask="curSubtask.data" + @submit="handleSelectAnyPhoto" + :defaultFile="[sceneImg]" + > + </ArbitraryPhoto> + <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 evaluateApi from '@/api/fysp/evaluateApi'; +import { formatDeviceList } from '@/model/fysp/device'; +import { enumDevice, toLabel } from '@/enum/device/device'; +import { enumScene } from '@/enum/scene'; +import { exportDocx } from '@/utils/doc'; +import right_triangle from '@/assets/image/right_triangle.png'; + +import CompSceneConstructionInfo from '@/views/fysp/scene/CompSceneConstructionInfo.vue'; +import CompSceneWharfInfo from '@/views/fysp/scene/CompSceneWharfInfo.vue'; +import CompSceneMixingPlantInfo from '@/views/fysp/scene/CompSceneMixingPlantInfo.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'; +import CompProblemTable from './components/CompProblemTable.vue'; +import dayjs from 'dayjs'; +import { useCloned } from '@vueuse/core'; + +/************************* 宸︿晶宸℃煡浠诲姟閫夊崟 **********************************/ +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); + fetchEvaluation(s); +} + +/************************* 鍦烘櫙鍩烘湰淇℃伅 **********************************/ +const imgTitle = ref('鏂藉伐閾墝'); +const formScene = ref({}); +const formSubScene = ref({}); +function fetchSceneInfo(sceneId) { + formSubScene.value = {}; + sceneImg.value = {}; + return sceneApi.getSceneDetail(sceneId).then((res) => { + //鍦烘櫙 + if (res.data.scense) formScene.value = 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 = data[0]; + } +} +/************************* 鍦烘櫙璁惧淇℃伅 **********************************/ + +// 璁惧鍥剧墖閫夋嫨瀵硅瘽妗� +const deiveceImgDialog = ref(false); +const showDeviceIndex = ref(0); +const showDeviceImgList = ref([]); +// 璁惧鍥剧墖鍒楄〃 +const deviceList = ref([]); + +function showDevicePhotoDialog(device, index) { + showDeviceIndex.value = index; + 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) { + deviceList.value[showDeviceIndex.value]._showStatusPic = data[0]._picUrl; + } +} + +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 problemDesc = ref(''); +//褰撳墠浠诲姟鐨勯棶棰樺垪琛� +const curProList = ref([]); +const month = ref(''); +const selectedProList = ref([]); + +function fetchProblems(s) { + curProList.value = []; + taskApi.getProBySubtask(s.data.stGuid).then((res) => { + curProList.value = res; + + // 鐢熸垚宸℃煡鎻忚堪鏂囨湰 + month.value = dayjs(s.data.stPlanTime).month() + 1; + const proCount = curProList.value.length; + problemDesc.value = `${month.value}鏈堝贰鏌ュ叡璁″彂鐜�${proCount}涓棶棰榒; + if (proCount > 0) { + problemDesc.value += '锛�'; + curProList.value.forEach((p, i) => { + problemDesc.value += `${i + 1}銆�${p.problemname}锛沗; + }); + problemDesc.value += '濡備笅鍥炬墍绀猴細'; + } else { + problemDesc.value += '銆�'; + } + + // 鐢熸垚閫変腑鐨勯棶棰樺拰鏁存敼鍥剧墖鎻忚堪 + selectedProList.value = curProList.value.map((v) => { + return {}; + }); + }); +} + +function handleProPicSelect(value, index) { + selectedProList.value[index] = value; +} +/************************* 鎵皹闃叉不寤鸿 **********************************/ +const radioStandard = ref('瑙勮寖'); +function fetchEvaluation(s) { + evaluateApi.fetchItemEvaluation(s.data.stGuid).then((res) => { + radioStandard.value = res.data.grade; + }); +} + +/************************* 鐢熸垚鎶ュ憡 **********************************/ +// 鏍囧噯鍖栧睘鎬у悕 +function convertKeys(obj) { + // 灏嗕竴涓猨s瀵硅薄涓墍鏈墂, mp, cs寮�澶寸殑灞炴�у叏閮ㄦ敼鎴愬幓鎺夎繖浜涘墠缂�骞朵笖閲嶆柊鍙樹负椹煎嘲寮忓懡鍚� + const newObj = {}; + for (const key in obj) { + let newKey = key; + if (key.startsWith('w')) { + newKey = key.substring(1); + } else if (key.startsWith('mp')) { + newKey = key.substring(2); + } else if (key.startsWith('cs')) { + newKey = key.substring(2); + } + newKey = newKey.charAt(0).toLowerCase() + newKey.slice(1); + newObj[newKey] = obj[key]; + } + return newObj; +} + +const docLoading = ref(false); +// 鐢熸垚word鎶ュ憡 +function genWord() { + // 璁╁師鏉ョ殑瀵硅薄涓嶅彈褰卞搷 + let formSceneCopy = ref(useCloned(formSubScene.value).cloned.value); + // 鏍囧噯鍖栧睘鎬у�� + let convertedFormScene = convertKeys(formSceneCopy.value); + + const _deviceList = []; + for (let i = 0; i < deviceList.value.length; i += 2) { + const d1 = deviceList.value[i]; + const d2 = + i + 1 < deviceList.value.length ? deviceList.value[i + 1] : undefined; + _deviceList.push({ + _showStatusPic_1: d1._showStatusPic, + _deviceTypeName_1: d1._deviceTypeName, + // hasPic2: d2 ? true : false, + _showStatusPic_2: d2 ? d2._showStatusPic : right_triangle, + _deviceTypeName_2: d2 ? d2._deviceTypeName : '' + }); + } + const param = { + index: formScene.value.index, + sceneName: formScene.value.name, + projectType: convertedFormScene.projectType, + stage: convertedFormScene.siExtension1, + startTime: convertedFormScene.startTime, + endTime: convertedFormScene.endTime, + leftTime: convertedFormScene.leftTime, + location: formScene.value.location, + floorSpace: convertedFormScene.floorSpace, + constructionArea: convertedFormScene.constructionArea, + constructionAreaPerMonth: convertedFormScene.constructionAreaPerMonth, + contacts: formScene.value.contacts, + contactst: formScene.value.contactst, + securityOfficer: convertedFormScene.securityOfficer, + securityOfficerTel: convertedFormScene.securityOfficerTel, + constructionUnit: convertedFormScene.constructionUnit, + employerUnit: convertedFormScene.employerUnit, + + planningArea: convertedFormScene.planningArea, + rentUnit: convertedFormScene.rentUnit, + + greenPlant: convertedFormScene.greenPlant, + civillyPlant: convertedFormScene.civillyPlant, + + sceneType: formScene.value.type, + imgTitle: imgTitle.value, + imgTitle_url: sceneImg.value.url, + deviceList: _deviceList, + problemDesc: problemDesc.value, + problemList: selectedProList.value.map((v) => { + return { + month: month.value, + ...v + }; + }), + standard_1: radioStandard.value == '瑙勮寖', + standard_2: radioStandard.value == '鍩烘湰瑙勮寖', + standard_3: radioStandard.value == '涓嶈鑼�', + standard_4: radioStandard.value == '涓ラ噸瑙勮寖' + }; + for (const key in param) { + if (param[key] == undefined) { + param[key] = ''; + } + } + const date = dayjs(curSubtask.value.data.stPlanTime).format('MM鏈圖D鏃�'); + console.log(param); + + docLoading.value = true; + // 鏍规嵁鍦烘櫙绫诲瀷閫夋嫨妯℃澘 + const sceneTypes = enumScene(2, false); + const type = sceneTypes.filter( + (item) => item.value == formScene.value.typeid + )[0].label; + const docxTemplatepath = `/鍗曚綋妯$増锛�${type}锛�.docx`; + exportDocx( + docxTemplatepath, + param, + `${param.sceneName}鍗曚綋锛�${date}锛�.docx`, + { + horizontalHeight: 368, + verticalWidth: 266 + } + ).finally(() => (docLoading.value = false)); +} +</script> -- Gitblit v1.9.3