From fa7044f3ccc9a91bc2bc117d1a06f650d86554f2 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@iotlink.com> Date: 星期二, 15 六月 2021 16:07:16 +0800 Subject: [PATCH] 优化联动规则加载场景列表的操作 --- src/pages/cameraAccess/components/LinkageRule.vue | 98 ++++++++++++++++++++++++++---------------------- 1 files changed, 53 insertions(+), 45 deletions(-) diff --git a/src/pages/cameraAccess/components/LinkageRule.vue b/src/pages/cameraAccess/components/LinkageRule.vue index 57a7fa9..490536a 100644 --- a/src/pages/cameraAccess/components/LinkageRule.vue +++ b/src/pages/cameraAccess/components/LinkageRule.vue @@ -17,8 +17,8 @@ /> </div> </div> - </div> --> - <div class="top" > + </div>--> + <div class="top"> <p class="task-css"> <b style="font-size: 14px; line-height: 18px;">鍦烘櫙</b> </p> @@ -36,7 +36,7 @@ :ShowLocalVedio="cameraType === 'dataStack'" v-if="showSysInfo" style="margin-top:-10px" - /> --> + />--> </div> </div> </div> @@ -109,6 +109,7 @@ :tableRuleList="tableRuleList" :onSaveScene="saveSceneRule" @delete-rule="showRules" + v-loading="loadingRuleList" ></scene-rule> </div> </div> @@ -139,26 +140,13 @@ }, computed: { selectedCameraIds() { - let ids = []; - if (this.TreeDataPool.treeActiveName == 'dataStack') { - if (this.TreeDataPool.checkedLocalVedio.length > 0) { - ids = this.TreeDataPool.checkedLocalVedio.map(i => { - return i.id; - }) - - } - } else { - if (this.TreeDataPool.selectedNodes.length > 0) { - ids = this.TreeDataPool.selectedNodes; - } - } - - return ids; + return this.TreeDataPool.selectedNodes; } }, data() { return { loading: false, + loadingRuleList: false, Carmeras: [], Camera: new VideoRuleData(), tasksTable: {}, @@ -189,7 +177,8 @@ prevEl: ".pre-border" } }, - showSysInfo: false + showSysInfo: false, + requestSeq: "" }; }, watch: { @@ -208,17 +197,12 @@ initCameraData() { this.$nextTick(() => { this.Carmeras = []; - this.loading = false; this.showSysInfo = true; - if (this.TreeDataPool.treeActiveName == 'dataStack') { - this.TreeDataPool.checkedLocalVedio.forEach(camera => { - this.Carmeras.push(new VideoRuleData(camera.id)); - }); - } else { - this.TreeDataPool.selectedNodes.forEach(camera => { - this.Carmeras.push(new VideoRuleData(camera)); - }); - } + + this.selectedCameraIds.forEach(cid => { + this.Carmeras.push(new VideoRuleData(cid)); + }); + this.$refs.timeSlider.activeTab = this.VideoManageData.TimeRules[0].id; this.showRules(); }) @@ -237,22 +221,36 @@ } this.swipercanvasData = swipers; }, - refresh(url,id) { - this.swipercanvasData.forEach(data=>{ - if(data.cameraId == id){ + refresh(url, id) { + this.swipercanvasData.forEach(data => { + if (data.cameraId == id) { data.baseImg = url; } }) //this.Camera.baseImg = url }, getCanvasData() { }, + newUid() { + + let originStr = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + let originChar = "0123456789abcdef"; + let len = originChar.length; + return originStr.replace(/x/g, function (match) { + return originChar.charAt(Math.floor(Math.random() * len)); + }); + }, showRules() { this.tableRuleList = []; if (this.selectedCameraIds.length > 0) { + this.loadingRuleList = true; + let seq = this.newUid(); + this.requestSeq = seq; + getLinkSceneRule({ cameraIds: this.selectedCameraIds }).then( rsp => { - if (rsp && rsp.success) { + this.loadingRuleList = false; + if (rsp && rsp.success && seq === this.requestSeq) { this.tableRuleList = rsp.data; @@ -263,19 +261,30 @@ } // this.TreeDataPool.fetchTreeData(); } - ); + ).catch(() => { + this.loadingRuleList = false; + }); } - }, saveSceneRule(groupRule) { const payload = { ...groupRule } + if (!payload.rules) { + this.$message({ + type: "warning", + message: "瑙勫垯鍙傛暟鏈夎" + }); + + return + } + payload.cameraIds = this.selectedCameraIds; saveLinkScene(payload).then(rsp => { if (rsp && rsp.success) { //this.Camera.update(); this.initCameraData(); + // this.showRules(); this.$notify({ type: "success", message: "浠诲姟淇濆瓨鎴愬姛锛�" @@ -289,7 +298,7 @@ }).catch(err => { this.$message({ type: "error", - message: "淇濆瓨澶辫触锛�" + err.data + message: "淇濆瓨澶辫触锛�" }); }); }, @@ -305,9 +314,9 @@ //height: 100%; //padding: 13px 0 20px; position: relative; - .devide{ + .devide { height: 10px; - background: #E9EBF2; + background: #e9ebf2; } .top { width: 100%; @@ -405,14 +414,14 @@ float: right; width: 54%; height: 144px; - .card-box{ - width: 54%!important; + .card-box { + width: 54% !important; } - .eCharts-box{ + .eCharts-box { width: 45%; - canvas{ - width: 98%!important; - } + canvas { + width: 98% !important; + } } } .task-css { @@ -577,7 +586,6 @@ .add-btn:hover { color: #2249b4; } - } </style> <style lang="scss" scoped> -- Gitblit v1.8.0