From f7f0e44c4be8eb0e77fd310296c3b43bde21e4f9 Mon Sep 17 00:00:00 2001 From: ZZJ <10913410+zzj2100@user.noreply.gitee.com> Date: 星期四, 23 六月 2022 14:17:01 +0800 Subject: [PATCH] 新增联动场景 --- src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 103 insertions(+), 10 deletions(-) diff --git a/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue b/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue index 8ef23dc..e000ca1 100644 --- a/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue +++ b/src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue @@ -30,7 +30,11 @@ :key="index" > <div class="relation" v-if="item.rule_with_pre"> - <el-select v-model="item.rule_with_pre" placeholder="閫夊叧绯�"> + <el-select + v-model="item.rule_with_pre" + placeholder="閫夊叧绯�" + @change="update" + > <el-option v-for="item in sdkConnects" :value="item.value" @@ -39,14 +43,24 @@ :key="item.id" ></el-option> </el-select> + <div> + <el-checkbox + v-show=" + item.rule_with_pre == '=>' || item.rule_with_pre == '!=>' + " + v-model="item.is_save_anyhow" + @change="update" + >淇濆瓨杩囩▼鏁版嵁</el-checkbox + > + </div> </div> <div class="imgBox"> <img :src="item.icon_blob" alt="" /> <div class="mask"> <div class="mask_del"> - <i class="iconfont"></i> + <i class="iconfont" @click="delSdk(index)"></i> </div> - <div class="mask_edit"> + <div class="mask_edit" @click="editSdk(index)"> <i class="iconfont"></i> </div> </div> @@ -66,17 +80,18 @@ <div class="empty" @dragover="dragover($event)" @drop="drop" v-else> <img src="/images/hashrate/鏈厤缃畻娉曠┖椤甸潰.png" alt="" /> <div class="des"> - 鏆傛湭閰嶇疆绛栫暐锛岀偣鍑讳笂鏂规搷浣滈潰鏉挎寜閽紝浠庢搷浣滈潰鏉挎嫋鍒扮畻娉曞埌姝ゅ锛屽嵆鍙厤缃� + 鏆傛湭閰嶇疆绛栫暐锛岀偣鍑讳笂鏂规搷浣滈潰鏉挎寜閽紝浠庢搷浣滈潰鏉挎嫋鍔ㄧ畻娉曞埌姝ゅ锛屽嵆鍙厤缃� </div> </div> </div> </div> <div class="control"> <div class="title">鍦烘櫙鎿嶄綔</div> + <span class="close iconfont" @click="deleteRule"></span> <div class="content"> <div class="btns"> <div class="button cancel" @click="backToOrigin">鍙栨秷</div> - <div class="button submit">淇濆瓨</div> + <div class="button submit" @click="save">淇濆瓨</div> </div> </div> </div> @@ -86,16 +101,18 @@ <script> import bus from "@/plugin/bus"; -import { logout } from "@/api/login"; +import { saveLinkScene, saveCameraScene, deleteCameraScene } from "@/api/scene"; + export default { props: { rule: {}, + ruleType: {}, + cameraId: {}, }, created() { - this.originRule = JSON.parse(JSON.stringify(this.rule)); this.getSdkConnection(); bus.$on("addSdk", () => { - if (this.rule.rules.length < 4) { + if (this.rule.rules && this.rule.rules.length < 4) { this.showAddBox = true; } }); @@ -132,7 +149,6 @@ }, ], showAddBox: false, - originRule: {}, }; }, computed: { @@ -173,8 +189,70 @@ edit() { this.$emit("edit"); }, + delSdk(index) { + this.rule.rules.splice(index, 1); + + if (this.rule.rules[index]) { + this.rule.rules[index].rule_with_pre = ""; + } + + this.update(); + + console.log(this.rule.rules); + }, backToOrigin() { - this.$emit("backToOrigin", this.originRule); + this.$emit("backToOrigin"); + }, + editSdk(index) { + this.$emit("editSdk", index); + }, + save() { + if (this.ruleType === "separate") { + this.rule.cameraIds = [this.cameraId]; + saveCameraScene(this.rule).then((rsp) => { + if (rsp && rsp.success) { + this.$notify({ + type: "success", + message: "绛栫暐淇濆瓨鎴愬姛锛�", + }); + this.backToOrigin(); + } + }); + } else { + delete this.rule.camera_polygons; + saveLinkScene(this.rule).then((rsp) => { + if (rsp && rsp.success) { + this.$notify({ + type: "success", + message: "浠诲姟淇濆瓨鎴愬姛锛�", + }); + this.backToOrigin(); + } else { + this.$notify({ + type: "error", + message: rsp.data, + }); + } + }); + } + }, + async deleteRule() { + if (!this.rule.id) { + console.log("87878"); + this.backToOrigin(); + return; + } + const res = await deleteCameraScene(this.rule.id); + if (res && res.success) { + this.$notify({ + type: "success", + message: "鍒犻櫎鎴愬姛", + }); + this.$emit("deletRule"); + } + }, + update() { + this.$forceUpdate(); }, }, }; @@ -324,7 +402,17 @@ } .control { + position: relative; width: 128px; + + .close { + position: absolute; + top: 12px; + right: 15px; + font-size: 12px; + color: #e34d59; + cursor: pointer; + } .btns { display: flex; @@ -376,5 +464,10 @@ margin: 10px 0 10px 20px; border-right: 1px solid #e9ebee; } + + .el-checkbox { + margin-top: 5px; + margin-left: 10px; + } } </style> \ No newline at end of file -- Gitblit v1.8.0