From 1acb2169d78d74e347bdfc2e962a88e6cb585bb7 Mon Sep 17 00:00:00 2001 From: hanbaoshan <hanbaoshan@aiotlink.com> Date: 星期五, 30 十月 2020 14:22:34 +0800 Subject: [PATCH] 修复数据栈文件删除列表仍有遗留的bug --- src/pages/labelMark/components/RightSide.vue | 401 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 352 insertions(+), 49 deletions(-) diff --git a/src/pages/labelMark/components/RightSide.vue b/src/pages/labelMark/components/RightSide.vue index 2839f63..fddcff1 100644 --- a/src/pages/labelMark/components/RightSide.vue +++ b/src/pages/labelMark/components/RightSide.vue @@ -1,82 +1,275 @@ <template> <div class="right-side"> - <div class="tool-bar"> - <div> - <!-- <input type="color" ref="colorPicker" v-model="color"> --> - <label for>鎷捐壊鍣�:</label> - <el-color-picker v-model="color" show-alpha size="mini"></el-color-picker> - </div> - <div style="width:250px;"> - <label for>绗旇Е:</label> - <el-slider v-model="dotSize" :min="1" :max="20"></el-slider> - </div> + <div class="figure"> + <el-collapse v-model="actPage" @change="chnageActPage"> + <el-collapse-item title="鎽勫儚鏈烘爣娉�" name="1"> + <div class="action-bar"> + <div class="tool-bar"> + <div> + <!-- <input type="color" ref="colorPicker" v-model="color"> --> + <label for>鎷捐壊鍣�:</label> + <el-color-picker v-model="colorPick" show-alpha size="mini"></el-color-picker> + </div> + <div style="width:250px;"> + <label for>绗旇Е:</label> + <el-slider v-model="dotSize" :min="1" :max="20"></el-slider> + </div> + <div> + <el-button + class="drawboard-trigger" + size="small" + @click="isEdit=!isEdit" + :icon="isEdit?'el-icon-lock':'el-icon-edit'" + >{{isEdit?'閿佸畾':'缂栬緫'}}</el-button> + </div> + </div> + </div> + <div class="drawboard"> + <div class="mask" :class="{'edit-status-mask':isEdit}" ref="editBoard"> + <div + class="label" + @click="editLabel(item)" + v-for="(item,index) in labels" + :key="index" + :style="{left:`${item.x}px`, top:`${item.y}px`, backgroundColor: colorPick, width: `${dotSize}px`, height: `${dotSize}px` }" + ></div> + </div> + <img v-show="snapshot_url" :src="`/httpImage/${snapshot_url}`" alt /> + <div + class="popBox" + v-show="isShowPop" + :style="`top:${curLabel.y + 22}px;left:${curLabel.x}px`" + > + <div class="title">鏍囨敞淇℃伅</div> + <div class="details"> + <div class="detail-item"> + <div class="left"> + <label for>骞抽潰鍧愭爣X:</label> + <span class="fix-width">{{curLabel.x}}</span> + <i>px</i> + </div> + <span class="devide"></span> + <div class="right"> + <label for>瀹為檯鍧愭爣X:</label> + <el-input type="text" size="mini" style="width:90px" v-model="curLabel.posX"></el-input> + </div> + </div> + <div class="detail-item"> + <div class="left"> + <label for>骞抽潰鍧愭爣Y:</label> + <span class="fix-width">{{curLabel.y}}</span> + <i>px</i> + </div> + <span class="devide"></span> + <div class="right"> + <label for>瀹為檯鍧愭爣Y:</label> + <el-input type="text" size="mini" style="width:90px" v-model="curLabel.posY"></el-input> + </div> + </div> + <div class="btns"> + <el-button size="mini" type="danger" @click="deleteLabel">鍒犻櫎</el-button> + <el-button size="mini" type="primary" @click="cancle">鍙栨秷</el-button> + <el-button size="mini" type="success" @click="submitInfo">纭畾</el-button> + </div> + </div> + </div> + </div> + </el-collapse-item> + <el-collapse-item title="杩借釜瀹炴櫙鍧愭爣" name="2"> + <div class="user-upload"> + <div class="img-card"> + <el-upload + class="upload-demo" + drag + action="https://jsonplaceholder.typicode.com/posts/" + :http-request="definedUpload" + :on-change="onChange" + :show-file-list="false" + > + <el-image + class="preview" + v-if="userImg" + :src="userImg" + fit="contain" + @mousemove="showCurPos" + @mouseout="isShowCurPos=false" + ></el-image> + <div class="el-upload__text"> + 灏嗘枃浠舵嫋鍒版澶勶紝鎴� + <em>鐐瑰嚮涓婁紶</em> + </div> + </el-upload> + </div> + <div class="info" v-show="isShowCurPos">褰撳墠浣嶇疆:{{traceX}},{{traceY}}</div> + </div> + </el-collapse-item> + </el-collapse> </div> - <div class="action-bar"> - <el-button type size="mini" @click="newLabel">鏍囨敞</el-button> - <el-button type size="mini" @click="isEdit=!isEdit">{{isEdit?'閿佸畾':'缂栬緫'}}</el-button> - </div> - <div class="drawboard"> - <div class="mask" v-show="isEdit" ref="editBoard"> - <div class="label" v-for="(item,index) in labels" :key="index" :style="{left:`${item.x}px`, top:`${item.y}px`}"></div> - </div> - <img :src="baseUrl" alt /> - </div> - <el-dialog> - - </el-dialog> </div> </template> <script> +import { getCamerasByServer } from '@/api/pollConfig' import TreeDataPool from "@/Pool/TreeData"; export default { data () { return { labels: [], - color: '#79f2fb', + colorPick: '#79f2fb', dotSize: 3, isEdit: false, + isShowPop: false, isNewLabel: false, - baseUrl: '' + curLabel: { + id: '', + posX: '', + posY: '', + x: '', + y: '' + }, + baseUrl: '', + snapshot_url: '', + userImg: '', + cameraData: [], + traceX: 0, + traceY: 0, + isShowCurPos: false, + actPage: ['1', '2'] } }, computed: { - + }, - watch:{ - isEdit(n,o){ - if(n){ - this.$refs['editBoard'].addEventListener('click',(e)=>{ - this.newLabel(e); - }) + mounted () { + this.getAllCameraData(); + setTimeout(() => { + let mockData = [{ id: 'a1', x: 15, y: 33, posX: 150, posY: 330 }, { id: 'b2', x: 56, y: 87, posX: 560, posY: 870 }]; + this.labels = mockData; + }, 1000); + }, + watch: { + 'TreeDataPool.selectedNode': { + handler (n, o) { + debugger + let curCamera = this.cameraData.find(item => item.id == n.id); + this.snapshot_url = curCamera.snapshot_url; + }, + deep: true + }, + isEdit (n, o) { + if (n) { + this.$refs['editBoard'].addEventListener('click', this.bindListen); + } else { + this.$refs['editBoard'].removeEventListener('click', this.bindListen); } } }, methods: { - newLabel(e){ - this.labels.push({x,y}); + chnageActPage () { + + }, + showCurPos (e) { + console.log(e); + this.isShowCurPos = true; + this.traceX = e.offsetX; + this.traceY = e.offsetY; + }, + onChange (file, fileList) { + fileList = [file] + //fileList.push(file) + }, + definedUpload (params) { + let _file = params.file + let fileReader = new FileReader() + fileReader.onload = () => { + this.userImg = fileReader.result + } + if (_file) { + fileReader.readAsDataURL(_file) + } + }, + getAllCameraData () { + getCamerasByServer().then(res => { + if (res.success) { + debugger + this.cameraData = res.data; + } + }).catch(e => { + console.log(e) + }) + }, + bindListen (e) { + this.newLabel(e); + }, + newLabel (e) { + console.log('鐐瑰嚮浜嗙敾鏉�') + if (this.isShowPop) return; + //鑾峰彇榧犳爣鐩稿浜庣敾鏉跨殑瀹氫綅 + console.log('鑾峰彇褰撳墠瀹氫綅淇℃伅'); + let target = { + id: '', + x: e.offsetX, + y: e.offsetY, + posX: '', + posY: '' + }; + this.labels.push(target); + this.curLabel = target; + this.isShowPop = true; this.isNewLabel = true; + }, + editLabel (label) { + debugger + if (!this.isEdit) return; + this.isShowPop = true; + this.curLabel = JSON.parse(JSON.stringify(label)); + }, + cancle () { + this.isShowPop = false; + //濡傛灉鏄湭淇濆瓨杩囩殑label鐩存帴鍒犻櫎(鏈繚瀛樼殑灏辨槸labels鏁扮粍涓渶鍚庝竴涓�) + if (!this.curLabel.id) { + this.labels.pop(); + } + }, + deleteLabel () { + if (this.curLabel.id) { + //璇锋眰鍚庡彴鍒犻櫎 + } else { + this.labels.pop(); + this.isShowPop = false; + } + }, + submitInfo () { + } } } </script> <style lang="scss"> -.right-side { - height: 100%; +.el-collapse-item__content{ background: #d2dcea; +} +.figure .el-collapse-item__header{ + padding-left: 14px; +} +.right-side { + background: #d2dcea; + .figure { + } .tool-bar { - width: 100%; - height: 60px; - padding: 10px 20px; + //width: 40px; + height: 100%; + padding: 10px 0 10px 20px; box-sizing: border-box; - background: rgb(250, 250, 250); - margin-bottom: 40px; + //background: rgb(250, 250, 250); + //margin-bottom: 40px; display: flex; align-items: center; + justify-content: flex-end; > div { cursor: pointer; - background: rgb(245, 245, 245); + background: rgba(245, 245, 245, 0.3); padding: 0 5px; height: 40px; margin: 7px; @@ -91,29 +284,139 @@ } } } - .action-bar{ + .action-bar { width: 960px; margin: auto; - margin-bottom: 20px; + //margin-bottom: 20px; text-align: right; + .drawboard-trigger { + background: transparent; + color: #fff; + border-color: rgba(255, 255, 255, 0.3); + } } .drawboard { margin: auto; width: 960px; height: 540px; + margin-bottom: 130px; position: relative; - background: #fff; + //background: #fff; + background: #f0ffca; box-shadow: 3px 3px 3px 1px rgba(0, 0, 0, 0.1); - .mask{ + .mask { position: absolute; - background: rgba(20, 181, 255, 0.1); + background: transparent; width: 100%; height: 100%; + overflow: hidden; + &.edit-status-mask { + background: rgba(20, 181, 255, 0.1); + } + .label { + position: absolute; + z-index: 2; + border-radius: 50%; + } } - img{ + img { width: 960px; height: 540px; - background:#f0ffca; + background: #f0ffca; + } + .popBox { + position: absolute; + z-index: 99; + padding: 14px; + border-radius: 3px; + color: #fff; + background: rgba(0, 0, 0, 0.7); + .title { + font-weight: bold; + text-align: left; + font-size: 15px; + } + .details { + .detail-item { + display: flex; + align-items: center; + margin: 5px 0; + label { + color: #a9a9a9; + width: 65px; + display: inline-block; + } + .left { + width: 110px; + text-align: left; + line-height: 28px; + .fix-width { + display: inline-block; + width: 23px; + } + } + .right { + width: 160px; + } + .devide { + width: 10px; + height: 1px; + background: #a9a9a9; + margin: 0 3px; + } + } + .btns { + margin-top: 10px; + } + } + } + } + .user-upload { + margin: auto; + padding: 50px; + display: flex; + .img-card{ + + } + .upload-demo, + .el-upload { + height: 100%; + width: 100%; + margin: 0 auto; + } + .upload-demo .el-upload__input { + visibility: hidden; + } + .upload-demo .el-upload-dragger { + width: 100%; + height: 90%; + width: 962px; + height: 542px; + margin: 20px 0 0; + background: transparent; + /* border: none; */ + //position: relative; + overflow: visible; + } + .upload-demo .el-upload__text { + position: absolute; + top: -24px; + left: 50%; + margin-left: -91px; + } + .upload-demo .preview { + object-fit: contain; + //position: relative; + // width: 100%; + // height: 100%; + } + .upload-demo .preview img { + // position: absolute; + // top: 50%; + // left: 50%; + // transform: translate(-50%, -50%); + // width: 100%; + // height: 100%; } } } -- Gitblit v1.8.0