From 8460d91255f5ff11a6c9a8199c313226b21f815a Mon Sep 17 00:00:00 2001 From: lxl <lixuliang_hd@126.com> Date: 星期四, 13 十月 2022 18:03:57 +0800 Subject: [PATCH] 11 --- src/views/datamanage/catalogueManage.vue | 159 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 98 insertions(+), 61 deletions(-) diff --git a/src/views/datamanage/catalogueManage.vue b/src/views/datamanage/catalogueManage.vue index cd522bb..628a6bf 100644 --- a/src/views/datamanage/catalogueManage.vue +++ b/src/views/datamanage/catalogueManage.vue @@ -2,9 +2,9 @@ <div class="cataSettings_box"> <div class="cataSettings_tree"> <My-bread :list="['鏁版嵁绠$悊', '鐩綍绠$悊']"></My-bread> - <el-button class="saveBtn" type="primary" size="mini" @click="sendChange" - >淇濆瓨</el-button - > + <!-- <el-button class="saveBtn" type="primary" size="mini" @click="sendChange" --> + <!-- >淇濆瓨</el-button --> + <!-- > --> <el-divider /> <div class="cataTreeBox"> <el-tree @@ -46,11 +46,15 @@ <h4>璇︾粏淇℃伅</h4> </div> <div class="form_box"> - <el-form :model="itemdetail"> + <el-form :model="itemdetail" ref="itemdetail" :rules="rules"> <!-- <el-form-item label="鐩綍缂栫爜" :label-width="formLabelWidth"> <el-input v-model="itemdetail.id" disabled /> </el-form-item> --> - <el-form-item label="鐩綍鍚嶇О" :label-width="formLabelWidth"> + <el-form-item + prop="name" + label="鐩綍鍚嶇О" + :label-width="formLabelWidth" + > <el-input v-model="itemdetail.name" /> </el-form-item> <el-form-item label="鐩綍璇存槑" :label-width="formLabelWidth"> @@ -65,8 +69,12 @@ <el-input v-model="itemdetail.bak" type="textarea" resize="none" /> </el-form-item> <div class="btnBox"> - <el-button type="primary" @click="updMenu">淇濆瓨</el-button> - <el-button type="primary" @click="reset">鍙栨秷</el-button> + <el-button type="primary" @click="updCata('itemdetail')" + >淇濆瓨</el-button + > + <el-button type="primary" @click="reset('itemdetail')" + >鍙栨秷</el-button + > </div> </el-form> </div> @@ -82,14 +90,10 @@ > <el-input v-model="ruleForm.name" autocomplete="off"></el-input> </el-form-item> - <el-form-item - prop="descr" - label="鐩綍璇存槑" - :label-width="formLabelWidth" - > + <el-form-item label="鐩綍璇存槑" :label-width="formLabelWidth"> <el-input v-model="ruleForm.descr" autocomplete="off"></el-input> </el-form-item> - <el-form-item prop="bak" label="鐩綍澶囨敞" :label-width="formLabelWidth"> + <el-form-item label="鐩綍澶囨敞" :label-width="formLabelWidth"> <el-input v-model="ruleForm.bak" autocomplete="off"></el-input> </el-form-item> </el-form> @@ -110,6 +114,7 @@ import { queryDirTree, queryMaxId, + updateDirTree, updateDirTrees, insertDir, deleteDir, @@ -122,7 +127,7 @@ }, data() { let validName = (rule, value, callback) => { - if (value === "") { + if (value === "" || value === null || value === undefined) { return callback(new Error("鐩綍鍚嶇О涓嶈兘涓虹┖")); } else { callback(); @@ -139,9 +144,10 @@ old_dirDat: [], //el鏍戞暟鎹�(鎷栧姩鍓�) newData: [], //鎷栧姩鍚庡師濮嬫暟鎹� itemdetail: {}, - backUpData: {}, - formLabelWidth: "170px", - delChildIDs: "", + backUpData: "", + formLabelWidth: "130px", + delChildID: "", + delChildIDs: [], dialogFormVisible: false, ruleForm: { level: null, @@ -152,7 +158,7 @@ bak: "", }, rules: { - name: [{ validator: validName, trigger: "blur" }], + name: [{ required: true, validator: validName, trigger: "blur" }], }, }; }, @@ -191,12 +197,11 @@ this.ruleForm.pid = data.id; this.ruleForm.orderNum = node.childNodes.length + 1; this.ruleForm.level = data.level + 1; - // console.log(data); - // console.log(node); }, resetForm(formName) { this.dialogFormVisible = false; this.$nextTick(() => { + this.ruleForm = {}; this.$refs[formName].resetFields(); }); }, @@ -214,14 +219,18 @@ message: "娣诲姞鎴愬姛", type: "success", }); + this.itemdetail = {}; + this.ruleForm = {}; this.dialogFormVisible = false; this.$refs[formName].resetFields(); } - }, 2000); + }, 500); }) .catch((res) => { - console.log(res); + this.itemdetail = {}; + this.$message.error("娣诲姞澶辫触"); this.fullscreenLoading = false; + console.log(res); }); } else { // alert("鐩綍鍚嶇О涓嶈兘涓虹┖"); @@ -237,9 +246,6 @@ type: "warning", }) .then(() => { - // console.log(node); - // console.log(data); - //鍏勫紵閲嶆柊鎺掑簭 const parent = node.parent; const children = parent.data.children || parent.data; @@ -249,9 +255,12 @@ }); this.traverseArr(data); //鑾峰彇鍒犻櫎鐨勫瓙ID - let delIDs = this.delChildIDs + "id=" + data.id; //瑕佸垹闄ょ殑鍏ㄩ儴ID - console.log(delIDs); - Promise.all([deleteDir(delIDs), updateDirTrees(children)]) + this.delChildIDs.push(data.id); //瑕佸垹闄ょ殑鍏ㄩ儴ID + let delIDs = this.delChildIDs; + Promise.all([ + deleteDir({ ids: delIDs.toString() }), + updateDirTrees(children), + ]) .then((res) => { console.log(res); if (res[0].code == 200 && res[1].code == 200) { @@ -259,23 +268,25 @@ type: "success", message: "鍒犻櫎鎴愬姛!", }); + this.itemdetail = {}; + } else if (res[0].code == 200) { + this.$message.error("鍒犻櫎鎴愬姛锛屼綅缃皟鏁村け璐�"); + } else if (res[1].code == 200) { + this.$message.error("鍒犻櫎澶辫触,浣嶇疆璋冩暣鎴愬姛"); + } else { + this.$message.error("鍒犻櫎澶辫触"); } }) .catch(() => { - this.$message({ - type: "error", - message: "鍒犻櫎澶辫触", - }); + this.$message.error("鍒犻櫎澶辫触"); + this.itemdetail = {}; }); //閲嶇疆瑕佸垹闄ょ殑瀛怚D - this.delChildIDs = ""; + this.delChildIDs = []; }) .catch(() => { - this.$message({ - type: "info", - message: "宸插彇娑堝垹闄�", - }); + this.$message("宸插彇娑堝垹闄�"); }); // this.dialogMessage="鏄惁鍒犻櫎" // this.dialogFlag = 1; @@ -296,7 +307,8 @@ if (obj.children) { return obj.children.forEach((item) => { // console.log(item.id + "---" + item.name); - this.delChildIDs += "id=" + item.id + "&"; + // this.delChildID += "id=" + item.id + "&"; + this.delChildIDs.push(item.id); this.traverseArr(item); }); } @@ -345,46 +357,68 @@ let arr = []; this.oriData.forEach((e) => { nodeData.forEach((item) => { - if (item.id === e.id) { - e = item; - } + if (item.id === e.id) e = item; }); arr.push(e); }); this.newData = arr; + this.sendChange(); }) .catch(() => { - this.$message({ - type: "info", - message: "宸插彇娑堟洿鏀�", - }); + this.$message("宸插彇娑堟洿鏀�"); this.dirList = this.old_dirDat; //灏嗗浠界殑dir閲嶆柊璧嬪�� }); }, sendChange() { - updateDirTrees(this.newData).then((res) => { - // console.log(res); - if (res.code == 200) { - this.$message({ - type: "success", - message: "鏇存柊鎴愬姛!", - }); - } - }); + updateDirTrees(this.newData) + .then((res) => { + if (res.code == 200) { + alert("璋冩暣瀹屾垚銆傝鍙婃椂鍒锋柊椤甸潰锛�"); + return; + } else { + alert("璋冩暣澶辫触锛岃閲嶈瘯锛�"); + } + }) + .catch(() => { + alert("淇敼澶辫触锛岃閲嶈瘯锛�"); + }); }, handleNodeClick(data) { // console.log(data); this.backUpData = JSON.stringify(data); this.itemdetail = JSON.parse(JSON.stringify(data)); }, - updMenu() { - this.$message({ - message: "淇敼鎴愬姛", - type: "success", + updCata(formName) { + this.$nextTick(() => { + this.$refs[formName].validate((valid) => { + if (valid) { + this.fullscreenLoading = true; + updateDirTree(this.itemdetail) + .then((res) => { + setTimeout(() => { + this.fullscreenLoading = false; + if (res.code == 200) { + alert("淇敼瀹屾垚锛岃鍙婃椂鍒锋柊椤甸潰锛�"); + this.itemdetail = {}; + this.dialogFormVisible = false; + } + }, 500); + }) + .catch((res) => { + alert("淇敼澶辫触锛岃閲嶈瘯锛�"); + this.fullscreenLoading = false; + }); + } else { + return false; + } + }); }); }, - reset() { - this.$message("宸插彇娑�"); + reset(formName) { + this.$refs[formName].resetFields(); + if (this.backUpData != "") { + this.itemdetail = JSON.parse(this.backUpData); + } }, }, mounted() { @@ -435,7 +469,7 @@ background-color: rgb(153, 153, 153); } .btnBox { - margin-left: 5px; + margin: 0 10px 0 5px; .el-button + .el-button { margin-left: 5px; } @@ -479,5 +513,8 @@ } } } + /deep/ .el-dialog__body { + padding: 0 30px 0 0; + } } </style> -- Gitblit v1.9.3