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/check/components/ArbitraryPhoto.vue | 116 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 72 insertions(+), 44 deletions(-) diff --git a/src/views/fysp/check/components/ArbitraryPhoto.vue b/src/views/fysp/check/components/ArbitraryPhoto.vue index 854296c..bd24994 100644 --- a/src/views/fysp/check/components/ArbitraryPhoto.vue +++ b/src/views/fysp/check/components/ArbitraryPhoto.vue @@ -1,49 +1,50 @@ <template> <div class="main"> - <div class="filters" v-if="false"> - <el-select - v-for="(key_select, index_select) of filters.keys()" - :placeholder="key_select.text" + <el-row justify="end" class="btns" v-if="!readonly"> + <el-text size="small" type="info" class="m-r-8" + >鏈�澶氶�夋嫨{{ maxSelect }}寮犲浘鐗�</el-text > - <el-option - v-for="(key_option) in filters.get(key_select.key)" - :key="key_option.key" - :value="key_option.value" - :label="key_option.label" - > - </el-option> - </el-select> - </div> - <div class="btns" v-if="!readonly"> - <el-button size="small" type="primary" @click="sendSelectedImg(true)">纭畾</el-button> - <el-button size="small" type="primary" @click="sendSelectedImg(false)">鍙栨秷</el-button> - </div> + <el-button + size="small" + type="primary" + @click="sendSelectedImg(true)" + :disabled="selectedImgUrlList.length == 0" + >纭畾</el-button + > + <el-button size="small" type="primary" @click="sendSelectedImg(false)" + >鍙栨秷</el-button + > + </el-row> <div class="center"> - <el-descriptions> + <!-- <el-descriptions> <el-descriptions-item label="鎬绘暟"> <span>{{ this.imgUrlList.length }}</span> </el-descriptions-item> - </el-descriptions> + </el-descriptions> --> <el-tabs v-model="activeId" type="card"> <el-tab-pane v-for="item in typeList" - :label="item.businesstype" + :key="item.businesstypeid" + :label=" + item.businesstype + ' (' + typeImgMap.get(activeId).length + ')' + " :name="item.businesstypeid" > </el-tab-pane> </el-tabs> <el-empty v-if="isEmpty" description="鏆傛棤璁板綍" /> - <div class="imgs"> + <el-scrollbar class="imgs"> <el-image v-for="(img, i) in typeImgMap.get(activeId)" + :key="i" :class="[Boolean(img.isSelect) ? 'selected' : 'noActive', 'image']" fit="cover" :src="img.url" lazy @click="onSelect(img, i)" /> - </div> + </el-scrollbar> </div> </div> </template> @@ -70,6 +71,11 @@ defaultFile: { type: Array, default: () => [] + }, + // 鍥剧墖鍙�夋暟閲忥紝褰撲紶鍏ユ暟瀛楁椂锛屼唬琛ㄥ浘鐗囨暟閲� + maxSelect: { + type: Number, + default: 3 } }, data() { @@ -95,10 +101,19 @@ // { businesstypeid: 60, businesstype: '鎵╁睍绫诲崄' } ], typeImgMap: new Map(), - imgUrlList: [] + imgUrlList: [], + selectedImgUrlList: [] }; }, watch: { + subtask: { + handler(nV, oV) { + if (nV != oV && nV) { + this.getAllImgList(); + } + }, + immediate: true + }, defaultFile: { handler(newFileList, oldFileList) { if (this.isClose) { @@ -128,9 +143,9 @@ } }, mounted() { - if (this.subtask) { - this.getAllImgList(); - } + // if (this.subtask) { + // this.getAllImgList(); + // } }, methods: { // 鍒濆鍖栧垰寮�濮嬮�変腑鐨勬爣绛� @@ -139,11 +154,13 @@ this.activeId = this.typeList[0].businesstypeid; } }, - async getAllImgList() { + getAllImgList() { // for(var k of this.typeImgMap.keys()) { // this.typeImgMap.set(k, []) // } - await mediafileApi.getRoutineByStGuid(this.subtask.stGuid).then((res) => { + this.typeImgMap.clear(); + this.typeList = []; + mediafileApi.getRoutineByStGuid(this.subtask.stGuid).then((res) => { this.isEmpty = false; let data = res.data; if (data.length == 0) { @@ -179,7 +196,6 @@ this.imgUrlList.push(e); // TODO imgUrl鍏ㄥ眬閰嶇疆 e.url = $fysp.imgUrl + e.extension1 + e.guid + '.jpg'; - // e.url = "http://47.100.191.150:9005/images/" + e.extension1 + e.guid + '.jpg' e.isSelect = false; } this.initSelectedTab(); @@ -217,20 +233,31 @@ }); }, onSelect(img, i) { - // if (i == 2 && !this.isAll) { - // this.getAllImgList(); - // this.isAll = true; - // } else { - // if (this.readonly) { - // return; - // } - // img.isSelect = !Boolean(img.isSelect); - // } - if (this.readonly) { return; } - img.isSelect = !img.isSelect; + const index = this.selectedImgUrlList.indexOf(img); + if (index == -1) { + if (this.maxSelect == 1) { + img.isSelect = true; + this.selectedImgUrlList.push(img); + if (this.selectedImgUrlList.length > 1) { + this.selectedImgUrlList.splice(0, 1).forEach((e) => { + e.isSelect = false; + }); + } + } else if (this.maxSelect > 1) { + if (this.selectedImgUrlList.length < this.maxSelect) { + img.isSelect = true; + this.selectedImgUrlList.push(img); + } + } + } else { + this.selectedImgUrlList.splice(index, 1); + img.isSelect = false; + } + + // img.isSelect = !img.isSelect; }, sendSelectedImg(isOk) { let result = []; @@ -280,7 +307,7 @@ } */ .imgs { - height: 650px; + height: 50vh; width: 90%; min-height: 100px !important; /* border-style:solid; @@ -295,6 +322,7 @@ } .image { + margin: 5px; height: 210px; width: 200px; border-radius: 4px; @@ -308,10 +336,10 @@ } .selected { - padding: 5px; + margin: 3px; color: #4abe84; box-shadow: 0 2px 7px 0 rgba(85, 110, 97, 0.35); - border: 1px solid rgba(74, 190, 132, 1); + border: 2px solid rgba(74, 190, 132, 1); } .selected:before { @@ -338,7 +366,7 @@ } .noActive { - padding: 5px; + /* padding: 5px; */ } .blurry { -- Gitblit v1.9.3