| | |
| | | <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 |
| | |
| | | <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"> |
| | |
| | | <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> |
| | |
| | | > |
| | | <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> |
| | |
| | | import { |
| | | queryDirTree, |
| | | queryMaxId, |
| | | updateDirTree, |
| | | updateDirTrees, |
| | | insertDir, |
| | | deleteDir, |
| | |
| | | }, |
| | | data() { |
| | | let validName = (rule, value, callback) => { |
| | | if (value === "") { |
| | | if (value === "" || value === null || value === undefined) { |
| | | return callback(new Error("目录名称不能为空")); |
| | | } else { |
| | | callback(); |
| | |
| | | old_dirDat: [], //el树数据(拖动前) |
| | | newData: [], //拖动后原始数据 |
| | | itemdetail: {}, |
| | | backUpData: {}, |
| | | formLabelWidth: "170px", |
| | | delChildIDs: "", |
| | | backUpData: "", |
| | | formLabelWidth: "130px", |
| | | delChildID: "", |
| | | delChildIDs: [], |
| | | dialogFormVisible: false, |
| | | ruleForm: { |
| | | level: null, |
| | |
| | | bak: "", |
| | | }, |
| | | rules: { |
| | | name: [{ validator: validName, trigger: "blur" }], |
| | | name: [{ required: true, validator: validName, trigger: "blur" }], |
| | | }, |
| | | }; |
| | | }, |
| | |
| | | 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(); |
| | | }); |
| | | }, |
| | |
| | | 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("目录名称不能为空"); |
| | |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | // console.log(node); |
| | | // console.log(data); |
| | | |
| | | //兄弟重新排序 |
| | | const parent = node.parent; |
| | | const children = parent.data.children || parent.data; |
| | |
| | | }); |
| | | |
| | | 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) { |
| | |
| | | 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 = {}; |
| | | }); |
| | | |
| | | //重置要删除的子ID |
| | | this.delChildIDs = ""; |
| | | this.delChildIDs = []; |
| | | }) |
| | | .catch(() => { |
| | | this.$message({ |
| | | type: "info", |
| | | message: "已取消删除", |
| | | }); |
| | | this.$message("已取消删除"); |
| | | }); |
| | | // this.dialogMessage="是否删除" |
| | | // this.dialogFlag = 1; |
| | |
| | | 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); |
| | | }); |
| | | } |
| | |
| | | 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() { |
| | |
| | | background-color: rgb(153, 153, 153); |
| | | } |
| | | .btnBox { |
| | | margin-left: 5px; |
| | | margin: 0 10px 0 5px; |
| | | .el-button + .el-button { |
| | | margin-left: 5px; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | /deep/ .el-dialog__body { |
| | | padding: 0 30px 0 0; |
| | | } |
| | | } |
| | | </style> |