From 87958d6d33603fa673cb7c8f5caf2394689959bf Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期四, 21 十一月 2024 11:00:43 +0800 Subject: [PATCH] 1. 图片选择组件移动到全局组件文件夹 2. 涉及到使用图片选择组件添加图片区域loading 3. 无用页面删除 --- src/views/fysp/check/components/CompDeviceShowTest.vue | 626 +++++++++++++++++++++++++------------------------------- 1 files changed, 275 insertions(+), 351 deletions(-) diff --git a/src/views/fysp/check/components/CompDeviceShowTest.vue b/src/views/fysp/check/components/CompDeviceShowTest.vue index 4c0ee18..1daa0e4 100644 --- a/src/views/fysp/check/components/CompDeviceShowTest.vue +++ b/src/views/fysp/check/components/CompDeviceShowTest.vue @@ -1,170 +1,178 @@ <template> - <div> - <!-- 閫夐」 --> - <!-- 璁惧绫诲瀷 --> - <el-row> - <!-- <el-col> - <span>璁惧绫诲瀷锛�</span> - </el-col> --> - <el-col> - <el-tabs class="child_select" placeholder="璁惧绫诲瀷" v-model="currSelect.topDeviceTypeId"> - <el-tab-pane v-for="item in deviceTopTypes" :name="item.id"> - <template #label> - <el-badge :value="item.count" :type="item.count == 0 ? 'danger' : 'primary'"> - <span class="custom-tabs-label"> - <span>{{ item.label }}</span> - </span> - </el-badge> - </template> - </el-tab-pane> - </el-tabs> - </el-col> - </el-row> - <el-collapse style="height: 100%" v-model="activeNames"> - <el-collapse-item v-for="item in formInfo" :name="item" style="height: 100%"> - <template #title> - <!-- 鎽樿鍐呭寮�濮� --> - <div class="abstract_main" v-if="activeNames.indexOf(item) === -1"> - <span class="abstract_main_title">{{ item.name }}</span> - <div class="abstract_other_item_inner"> - <!-- 渚涘簲鍟� --> - <div class="abstract_other_item"> - <span class="abstract_other_title">{{ `渚涘簲鍟哷 }}</span> - <span class="abstract_main_text">{{ item.supplier || '鏃�' }}</span> - </div> - <!-- 杩愮淮鍟� --> - <div class="abstract_other_item"> - <span class="abstract_other_title">{{ `杩愮淮鍟哷 }}</span> - <span class="abstract_main_text">{{ item.maintainer || '鏃�' }}</span> - </div> - <!-- 杩愯鐘舵�� --> - <div class="abstract_other_item"> - <span class="abstract_other_title">{{ `杩愯鐘舵�乣 }}</span> - <span class="abstract_main_text">{{ - getRunStatusValueByRunStatusKey(item.runningStatus) || '鏃�' - }}</span> - </div> - <!-- 鍥剧墖 --> - <div class="image-container"> - <el-image - v-for="status in item._statusList" - fit="cover" - class="pic-style" - :src="status._picUrl" - :preview-src-list="Array.of(status._picUrl)" - /> - </div> - </div> - </div> - <div v-else class="centerDiv"> - <el-button link type="primary" size="large">[鐐瑰嚮缂╂斁]</el-button> - </div> - <!-- 鎽樿鍐呭缁撴潫 --> - </template> - <!-- 璇︾粏鍐呭寮�濮� --> - <div class="sub-title">{{ item.name }}</div> - <el-form :model="item" class="form_class"> - <!-- <el-form-item label="绔欑偣"> - <el-input v-model="item.name" :disabled="isDisabled"></el-input> - </el-form-item> --> - <el-form-item label="渚涘簲鍟�"> - <el-input v-model="item.supplier" :disabled="isDisabled"></el-input> - </el-form-item> - <el-form-item label="杩愮淮鍟�"> - <el-input v-model="item.maintainer" :disabled="isDisabled"></el-input> - </el-form-item> - <el-form-item label="杩愮淮棰戞"> - <el-select v-model="item.maintainFrequency" :disabled="isDisabled"> - <el-option - v-for="frequency of maintainFrequencysArray" - :key="frequency.key" - :label="frequency.value" - :value="frequency.key" - ></el-option> - </el-select> - </el-form-item> - <el-form-item label="杩愮淮浜哄憳"> - <el-input v-model="item.maintainStaff" :disabled="isDisabled"></el-input> - </el-form-item> - <el-form-item label="杩愮淮鑱旂郴鏂瑰紡"> - <el-input v-model="item.maintainTel" :disabled="isDisabled"></el-input> - </el-form-item> - <el-form-item label="鍝佺墝鍨嬪彿"> - <el-input v-model="item.brandModel" :disabled="isDisabled"></el-input> - </el-form-item> - <el-form-item label="杩愯鐘舵��"> - <el-select v-model="item.runningStatus" :disabled="isDisabled"> - <el-option - v-for="status of runStatusArray" - :key="status.key" - :label="status.value" - :value="status.key" - ></el-option> - </el-select> - </el-form-item> - <el-form-item label="鎵�鏈夋潈"> - <el-select v-model="item.ownership" :disabled="isDisabled"> - <el-option - v-for="ownership of ownershipArray" - :key="ownership.key" - :label="ownership.value" - :value="ownership.key" - ></el-option> - </el-select> - </el-form-item> - <el-form-item label="鐘舵��"> - <el-tabs tab-position="top"> - <el-tab-pane v-for="(status, i) in item._statusList" :label="status.dlCreateTime.slice(0, 10)"> - <el-form :model="status" class="form-class"> - <el-form-item label="浣嶇疆"> - <el-input - v-model="status.dlLocation" + <CompGenericWrapper type="drawer"> + <template #content> + <!-- 閫夐」 --> + <!-- 璁惧绫诲瀷 --> + <el-row> + <el-col> + <el-tabs + class="child_select" + placeholder="璁惧绫诲瀷" + v-model="currSelect.topDeviceTypeId" + > + <el-tab-pane + v-for="item in deviceTopTypes" + :key="item.id" + :name="item.id" + > + <template #label> + <el-badge + :value="item.count" + :type="item.count == 0 ? 'danger' : 'primary'" + > + <span class="custom-tabs-label"> + <span>{{ item.label }}</span> + </span> + </el-badge> + </template> + </el-tab-pane> + </el-tabs> + </el-col> + </el-row> + <el-collapse v-model="activeNames" style="border: 4px"> + <el-collapse-item + v-for="item in formInfo" + :key="item.id" + :name="item.id" + class="collapse-item-class" + > + <template #title> + <div + style="display: flex; width: 100%; justify-content: space-between" + > + <div style=""> + <el-descriptions style="" :column="3" size="small" border> + <el-descriptions-item + width="64px" + :label=" + currSelect.topDeviceTypeId == 0 ? '绔欑偣鍚嶇О' : '璁惧鍚嶇О' + " + :span="3" + >{{ item.name || '鏃�' }}</el-descriptions-item + > + <el-descriptions-item label="渚涘簲鍟�">{{ + item.supplier || '鏃�' + }}</el-descriptions-item> + <el-descriptions-item label="杩愮淮鍟�">{{ + item.maintainer || '鏃�' + }}</el-descriptions-item> + <el-descriptions-item label="杩愮淮棰戞"> + <el-select + v-model="item.maintainFrequency" :disabled="isDisabled" - class="form-item-class" - ></el-input> - </el-form-item> - <el-form-item label="缁忓害"> - <el-input - v-model="status.dlLongitude" + style="width: 150px" + > + <el-option + v-for="frequency of maintainFrequencysArray" + :key="frequency.key" + :label="frequency.value" + :value="frequency.key" + ></el-option> + </el-select> + </el-descriptions-item> + <el-descriptions-item label="杩愮淮浜哄憳">{{ + item.maintainStaff || '鏃�' + }}</el-descriptions-item> + <el-descriptions-item label="杩愮淮鑱旂郴鏂瑰紡">{{ + item.maintainTel || '鏃�' + }}</el-descriptions-item> + <el-descriptions-item label="鍝佺墝鍨嬪彿">{{ + item.brandModel || '鏃�' + }}</el-descriptions-item> + <el-descriptions-item label="杩愯鐘舵��"> + <el-select + v-model="item.runningStatus" :disabled="isDisabled" - class="form-item-class" - ></el-input> - </el-form-item> - <el-form-item label="绾害"> - <el-input - v-model="status.dlLatitude" - :disabled="isDisabled" - class="form-item-class" - ></el-input> - </el-form-item> - <el-form-item> - <!-- 鍥剧墖 --> + style="width: 150px" + > + <el-option + v-for="status of runStatusArray" + :key="status.key" + :label="status.value" + :value="status.key" + ></el-option> + </el-select> + </el-descriptions-item> + <el-descriptions-item label="绫诲瀷"> + {{ item._typename || '鏃�' }} + </el-descriptions-item> + </el-descriptions> + </div> + + <div style="display: flex"> + <!-- <div class="sub-title">{{ item.name }}</div> --> + <!-- 鍥剧墖 --> + <div class="image-container"> + <div + class="block-div" + @click="onClickPic($event)" + v-for="(status, index) in item._statusList" + :key="index" + > <el-image + v-if="index == 0" fit="cover" class="pic-style" :src="status._picUrl" :preview-src-list="Array.of(status._picUrl)" /> - </el-form-item> - </el-form> - </el-tab-pane> - </el-tabs> - </el-form-item> - </el-form> - <el-divider /> - <!-- 璇︾粏鍐呭缁撴潫 --> - </el-collapse-item> - </el-collapse> - <!-- 绌虹姸鎬� --> - <el-empty v-if="isEmpty" /> - </div> + <span class="abstract_pic_text" v-if="index == 0">{{ + `鏈�鏂扮姸鎬佸浘鐗� ${status.dlCreateTime.slice(0, 10)}` + }}</span> + </div> + </div> + </div> + </div> + </template> + <!-- 璇︾粏鍐呭寮�濮� --> + <el-form :model="item" class="form_class"> + <el-form-item label="鐘舵��"> + <el-tabs tab-position="top"> + <el-tab-pane + v-for="(status, i) in item._statusList" + :label="status.dlCreateTime.slice(0, 10)" + :key="i" + > + <el-form :model="status" class="form-class"> + <el-form-item label="浣嶇疆" style="margin-bottom: 10px"> + {{ status.dlLocation }} + </el-form-item> + <el-form-item label="鍥剧墖"> + <!-- 鍥剧墖 --> + <el-space> + <div v-if="status._paths && status._paths.length > 0"> + <el-image + v-for="(path, i) in status._paths" + fit="cover" + class="pic-style" + :src="path" + :preview-src-list="Array.of(path)" + :key="i" + /> + </div> + <el-empty v-else></el-empty> + </el-space> + </el-form-item> + </el-form> + </el-tab-pane> + </el-tabs> + </el-form-item> + </el-form> + <!-- 璇︾粏鍐呭缁撴潫 --> + </el-collapse-item> + </el-collapse> + <!-- 绌虹姸鎬� --> + <el-empty v-if="isEmpty" + /></template> + </CompGenericWrapper> </template> <script> import deviceApi from '@/api/fysp/deviceApi'; import { $fysp } from '@/api/index'; +import { toLabel } from '@/enum/device/device'; export default { - components: {}, + components: { }, watch: { // 閫夋嫨鏀瑰彉鐩戝惉 currSelect: { @@ -215,79 +223,6 @@ { key: 0, value: '璐拱' }, { key: 1, value: '绉熻祦' } ], - // i-璁惧绫诲瀷 - // 涓ゅ眰map锛� { key: topType, value: { key: sceneTypeId, value: [label, value, children] } } - iDeviceTypesMap: new Map( - [ - { - topTypeId: 0, - value: new Map( - [ - { - sceneTypeId: 1, - value: [ - { - label: '鎵皹鐩戞祴', - value: 1, - children: [ - { - label: '鎵皹鐩戞祴', - value: 1 - } - ] - } - ] - }, - { - sceneTypeId: 2, - value: [ - { - label: '鎵皹鐩戞祴', - value: 1, - children: [ - { - label: '鎵皹鐩戞祴', - value: 1 - } - ] - } - ] - }, - { - sceneTypeId: 3, - value: [ - { - label: '鎵皹鐩戞祴', - value: 1, - children: [ - { - label: '鎵皹鐩戞祴', - value: 1 - } - ] - } - ] - }, - { - sceneTypeId: 14, - value: [ - { - label: '鎵皹鐩戞祴', - value: 1, - children: [ - { - label: '鎵皹鐩戞祴', - value: 1 - } - ] - } - ] - } - ].map((item) => [item.sceneTypeId, item.value]) - ) - } - ].map((item) => [item.topTypeId, item.value]) - ), scene: {} }; }, @@ -315,9 +250,6 @@ // 灞曠ず琛ㄥ崟鐨勮鎯呯殑鐐瑰嚮浜嬩欢 showDetail(item) { item._isDetail = !item._isDetail; - if (item._isDetail) { - } else { - } }, init(scene) { // 鐖剁粍浠朵富鍔ㄨ皟鐢ㄥ垵濮嬪寲瀛愮粍浠剁殑鏂规硶 @@ -336,18 +268,16 @@ // 灏嗕竴涓猨s瀵硅薄涓墍鏈塪i锛寃i锛宲i寮�澶寸殑灞炴�у叏閮ㄦ敼鎴愬幓鎺夎繖浜涘墠缂�骞朵笖閲嶆柊鍙樹负椹煎嘲寮忓懡鍚� const newObj = {}; for (const key in obj) { - if (obj.hasOwnProperty(key)) { - 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]; + 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; }, @@ -356,25 +286,25 @@ data._isDetail = false; }, getList() { - deviceApi.fetchDevices(this.scene.guid, this.currSelect.topDeviceTypeId).then((result) => { - this.initList(); - if (result.data == null || result.data.length <= 0) { - this.isEmpty = true; - return; - } - // 鏍囧噯鍖栧睘鎬у悕 - for (let index = 0; index < result.data.length; index++) { - var element = this.convertKeys(result.data[index]); - this.initFormData(element); - // 鑾峰彇璁惧鐘舵�佷俊鎭� - let data = { - deviceId: element.id, - sceneId: element.sceneGuid, - deviceTypeId: this.currSelect.topDeviceTypeId - }; - deviceApi - .fetchDeviceStatus(data) - .then((status) => { + deviceApi + .fetchDevices(this.scene.guid, this.currSelect.topDeviceTypeId) + .then((result) => { + this.initList(); + if (result.data == null || result.data.length <= 0) { + this.isEmpty = true; + return; + } + // 鏍囧噯鍖栧睘鎬у悕 + for (let index = 0; index < result.data.length; index++) { + var element = this.convertKeys(result.data[index]); + this.initFormData(element); + // 鑾峰彇璁惧鐘舵�佷俊鎭� + let data = { + deviceId: element.id, + sceneId: element.sceneGuid, + deviceTypeId: this.currSelect.topDeviceTypeId + }; + deviceApi.fetchDeviceStatus(data).then((status) => { var statusData = status.data; var imgPaths = []; if (statusData) { @@ -383,6 +313,7 @@ return; } element = this.convertKeys(result.data[index]); + element = this.setDeviceType(element); element._picUrls = imgPaths; for (let index = 0; index < statusData.length; index++) { const statusItem = statusData[index]; @@ -392,15 +323,25 @@ this.formInfo.push(element); } } - }) - .catch((err) => {}); - } - }); + }); + } + }); + }, + setDeviceType(element) { + var type = []; + type = toLabel(element.sceneTypeId, this.currSelect.topDeviceTypeId, [ + element.typeId, + element.subtypeId + ]); + element._typename = type.join('-'); + return element; }, // 淇濆瓨鐘舵�佷俊鎭� saveStatus(device, status) { var _picUrl = $fysp.imgUrl + status.dlPicUrl; status._picUrl = _picUrl; + status._paths = _picUrl.split(';'); + device._picUrls.push(_picUrl); if ('_statusList' in device) { device._statusList.push(status); } else { @@ -416,34 +357,32 @@ modifyObjectKeys(obj) { const newObj = {}; for (const key in obj) { - if (obj.hasOwnProperty(key)) { - // 璺宠繃浠� 'dl' 鎴� '_' 寮�澶寸殑灞炴�� - if (key.startsWith('dl') || key.startsWith('_')) { + // 璺宠繃浠� 'dl' 鎴� '_' 寮�澶寸殑灞炴�� + if (key.startsWith('dl') || key.startsWith('_')) { + newObj[key] = obj[key]; + continue; + } + // 鏍规嵁 topDeviceTypeId 娣诲姞鍓嶇紑 + let prefix = ''; + switch (this.currSelect.topDeviceTypeId) { + case 0: + prefix = 'di'; + break; + case 1: + prefix = 'pi'; + break; + case 2: + prefix = 'wi'; + break; + default: + // 濡傛灉 topDeviceTypeId 涓嶆槸 0, 1, 鎴� 2锛屼笉娣诲姞鍓嶇紑 newObj[key] = obj[key]; continue; - } - // 鏍规嵁 topDeviceTypeId 娣诲姞鍓嶇紑 - let prefix = ''; - switch (this.currSelect.topDeviceTypeId) { - case 0: - prefix = 'di'; - break; - case 1: - prefix = 'pi'; - break; - case 2: - prefix = 'wi'; - break; - default: - // 濡傛灉 topDeviceTypeId 涓嶆槸 0, 1, 鎴� 2锛屼笉娣诲姞鍓嶇紑 - newObj[key] = obj[key]; - continue; - } - - // 娣诲姞鍓嶇紑骞惰浆鎹负椹煎嘲寮忓懡鍚� - const newKey = `${prefix}${key.charAt(0).toUpperCase() + key.slice(1)}`; - newObj[newKey] = obj[key]; } + + // 娣诲姞鍓嶇紑骞惰浆鎹负椹煎嘲寮忓懡鍚� + const newKey = `${prefix}${key.charAt(0).toUpperCase() + key.slice(1)}`; + newObj[newKey] = obj[key]; } return newObj; }, @@ -453,58 +392,8 @@ var query = this.modifyObjectKeys(obj); return query; }, - // 鏍规嵁鎺ュ彛杩斿洖鐢熸垚 iDeviceTypesMap - generateIDeviceTypesMap() {}, - // 鑾峰彇褰撳墠topType锛屽綋鍓峴ceneTypeId涓嬫墍鏈夌埗绫诲瀷 - getAlliDeviceParentTypeArray() { - console.log('topDeviceTypeId', this.currSelect.topDeviceTypeId); - - var sceneTypeAndIDeviceTypesMap = this.iDeviceTypesMap.get(this.currSelect.topDeviceTypeId); - if (!sceneTypeAndIDeviceTypesMap) { - return ''; - } - console.log('sceneTypeId', this.scene.typeid); - console.log('scene', this.scene); - - var iDeviceTypesArray = sceneTypeAndIDeviceTypesMap.get(this.scene.typeid); - if (!iDeviceTypesArray) { - return ''; - } - return iDeviceTypesArray; - }, - // 鑾峰彇璁惧绫诲瀷 topDeviceTypeId, sceneTypeId 鍜� 鑷韩鐨勪竴浜涘弬鏁� - getIDeviceParentTypeObj(device) { - var iDeviceTypesArray = this.getAlliDeviceParentTypeArray(); - console.log('iDeviceTypesArray', this.getAlliDeviceParentTypeArray()); - var result; - iDeviceTypesArray.forEach((e) => { - if (e.value == device.typeId) { - result = e; - } - }); - return result; - }, - // 鑾峰彇璁惧瀛愮被鍨� topDeviceTypeId, sceneTypeId 鍜� 鑷韩鐨勪竴浜涘弬鏁� - getIDeviceChildrenTypeObj(device) { - console.log('device', device); - - var parentType = this.getIDeviceParentTypeObj(device); - console.log('parentType', this.getIDeviceParentTypeObj(device)); - - if (parentType == null || parentType == '' || !('children' in parentType)) { - return ''; - } - var children = parentType.children; - if (children == null || children.length <= 0) { - return ''; - } - let result; - iDeviceTypesArray.forEach((e) => { - if (e.value == device.typeId) { - result = e; - } - }); - return result; + onClickPic(e, item) { + e.stopPropagation(); } } }; @@ -512,16 +401,17 @@ <style scoped> .image-container { + justify-content: flex-end; display: flex; - flex-direction: row-reverse; - width: 100%; - height: 200px; - overflow: hidden; /* 纭繚鍥剧墖涓嶄細瓒呭嚭瀹瑰櫒 */ + /* width: 300px; */ + /* flex-direction: row-reverse; */ + /* height: 225px; */ + /* overflow: hidden; 纭繚鍥剧墖涓嶄細瓒呭嚭瀹瑰櫒 */ } .pic-style { - width: 180px; - height: 180px; - margin-right: 5%; + width: 150px; + height: 150px; + border-radius: 4px; } .card-style { height: 400px; @@ -541,35 +431,61 @@ border-radius: 50%; } .abstract_main { - width: 100%; + width: 98%; } -.abstract_other_item { +.abstract_main_item { display: flex; flex-direction: column; margin-right: 50px; margin-top: 10px; - width: 20%; + /* width: 20%; */ +} +.abstract_other_item { + /* display: flex; + flex-direction: column; */ + /* margin-left: 50px; */ + /* margin-top: 10px; + width: 100vh; */ +} +.abstract_main_item_inner { + display: flex; + justify-content: center; } .abstract_other_item_inner { margin-left: 10px; display: flex; } .abstract_main_title { - margin-left: -400px; + /* margin-left: -400px; */ color: #303133; font-size: 16px; +} +.abstract_main_title { + color: #606266; + font-size: 13px; + margin-top: 10px; } .abstract_other_title { color: #606266; font-size: 13px; + margin-top: 45px; } .abstract_main_text { color: #303133; font-size: 17px; margin-top: 5px; } +.abstract_pic_text { + display: block; + color: var(--el-text-color-secondary); + font-size: 14px; + /* margin-top: 20px; */ +} +.block-div { + display: block; +} .form_class { - margin-left: 10px; + /* margin-left: 10px; */ } .el-collapse { @@ -590,4 +506,12 @@ margin-bottom: 30px; margin-left: 20px; } +.collapse-item-class { + height: 100%; + border: 5px; +} + +::-webkit-scrollbar { + height: 0; +} </style> -- Gitblit v1.9.3