From 14f8b7b32ed9133152780eb072adbc32df2eb242 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期一, 07 十一月 2022 17:42:16 +0800 Subject: [PATCH] 音柱、手持设备修改 --- src/views/systemSetting/device/loudspeaker/components/dialogForm.vue | 81 +++++++++++----------------------------- 1 files changed, 23 insertions(+), 58 deletions(-) diff --git a/src/views/systemSetting/device/loudspeaker/components/dialogForm.vue b/src/views/systemSetting/device/loudspeaker/components/dialogForm.vue index 39a5e0e..22090d6 100644 --- a/src/views/systemSetting/device/loudspeaker/components/dialogForm.vue +++ b/src/views/systemSetting/device/loudspeaker/components/dialogForm.vue @@ -58,7 +58,7 @@ <el-button type="primary" class="btn submit" - @click.native.prevent="handleUpdateLawCar" + @click.native.prevent="handleSave" >纭 </el-button> </div> @@ -69,6 +69,8 @@ </div> </template> <script> +import { createNamespacedHelpers } from "vuex"; +const { mapActions } = createNamespacedHelpers("loudspeaker"); export default { data() { const checkName = (rule, value, callback) => { @@ -113,77 +115,40 @@ }; }, created() { - // 鍒濆鍖栨暟鎹� - - this.form = JSON.parse(JSON.stringify(this.info)); + this.form = this.info; + }, + watch: { + info(newVal) { + this.form = newVal; //瀵圭埗缁勪欢浼犺繃鏉ョ殑鍊艰繘琛岀洃鍚紝濡傛灉鏀瑰彉涔熷瀛愮粍浠跺唴閮ㄧ殑鍊艰繘琛屾敼鍙� + }, }, methods: { - // 淇敼鎵ф硶杞� - handleUpdateLawCar() { + ...mapActions(["saveLoudspeaker", "updateLoudspeaker"]), + // 淇濆瓨 + handleSave() { this.$refs.formRef.validate((valid) => { if (valid) { const { form } = this; - this.$axios({ - method: "put", - url: "sccg/car_Manage/modification_enforce", - data: { - ...form, - }, - }).then((res) => { - console.log(res); - if (res.code === 200) { + if (form.id > 0) { + this.updateLoudspeaker(form).then((res) => { this.$message({ type: "success", - message: "淇敼杞﹁締鎴愬姛", + message: "淇敼闊虫煴鎴愬姛", }); this.$emit("closeDialog", { flag: false, index: 1 }); - } else { + }); + } else { + this.saveLoudspeaker(form).then((res) => { this.$message({ - type: "error", - message: res.message, + type: "success", + message: "淇濆瓨闊虫煴鎴愬姛", }); - } - }); + this.$emit("closeDialog", { flag: false, index: 1 }); + }); + } } else { return false; } - }); - }, - // 閮ㄩ棬淇敼 - handleCheck(data, checked) { - console.log(data); - this.form.departId = data.id; - this.form.departName = data.departName; - // 鑾峰彇褰撳墠閫夋嫨鐨刬d鍦ㄦ暟缁勪腑鐨勭储寮� - const indexs = this.selectOrg.orgsid.indexOf(data.id); - // 濡傛灉涓嶅瓨鍦ㄦ暟缁勪腑锛屽苟涓旀暟缁勪腑宸茬粡鏈変竴涓猧d骞朵笖checked涓簍rue鐨勬椂鍊欙紝浠h〃涓嶈兘鍐嶆閫夋嫨銆� - if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) { - this.$message({ - message: "鍙兘閫夋嫨涓�涓儴闂紒", - type: "warning", - showClose: true, - }); - // 璁剧疆宸查�夋嫨鐨勮妭鐐逛负false 寰堥噸瑕� - this.$refs.tree.setChecked(data, false); - } else if (this.selectOrg.orgsid.length === 0 && checked) { - // 鍙戠幇鏁扮粍涓虹┖ 骞朵笖鏄凡閫夋嫨 - // 闃叉鏁扮粍鏈夊�硷紝棣栧厛娓呯┖锛屽啀push - this.selectOrg.orgsid = []; - this.selectOrg.orgsid.push(data.id); - } else if ( - indexs >= 0 && - this.selectOrg.orgsid.length === 1 && - !checked - ) { - // 鍐嶆鐩存帴杩涜璧嬪�间负绌烘搷浣� - this.selectOrg.orgsid = []; - this.form.departName = ""; - } - }, - // 鑾峰彇閮ㄩ棬鏍� - getDepartTree() { - this.$axios.get("/sccg/depart/tree").then((res) => { - this.departList = res.data; }); }, }, -- Gitblit v1.8.0