| | |
| | | >保存</el-button |
| | | > |
| | | <el-divider /> |
| | | <div class="menuTreeBox"> |
| | | <div class="depTreeBox"> |
| | | <el-tree |
| | | ref="tree" |
| | | :props="defaultProps" |
| | |
| | | <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.name" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | |
| | | <el-input v-model="itemdetail.bak" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <div class="btnBox"> |
| | | <el-button type="primary" @click="updDep">保存</el-button> |
| | | <el-button type="primary" @click="reset">取消</el-button> |
| | | <el-button type="primary" @click="updDep('itemdetail')" |
| | | >保存</el-button |
| | | > |
| | | <el-button type="primary" @click="reset('itemdetail')" |
| | | >取消</el-button |
| | | > |
| | | </div> |
| | | </el-form> |
| | | </div> |
| | | </div> |
| | | <el-dialog title="新增子目录" :visible.sync="dialogFormVisible"> |
| | | <el-dialog |
| | | width="30%" |
| | | top="5vh" |
| | | title="新增子目录" |
| | | :visible.sync="dialogFormVisible" |
| | | > |
| | | <el-form :model="ruleForm" ref="ruleForm" :rules="rules"> |
| | | <el-form-item |
| | | label="目录名称" |
| | | prop="name" |
| | | :label-width="formLabelWidth" |
| | | > |
| | | <el-form-item prop="name" label="名称" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.name" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="目录说明" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.descr" autocomplete="off"></el-input> |
| | | <el-form-item label="简称" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.sname" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="目录备注" :label-width="formLabelWidth"> |
| | | <el-form-item label="编码" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.code" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="机构代码" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.uncode" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="地址" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.addr" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="联系方式" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.contact" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="传真" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.fax" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="电子邮件" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.email" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="邮政编码" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.post" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="网站地址" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.website" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="备注" :label-width="formLabelWidth"> |
| | | <el-input v-model="ruleForm.bak" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | updateDepTree, |
| | | updateDepTrees, |
| | | queryMaxId, |
| | | insertDep, |
| | | deleteDep, |
| | | } from "../../api/api"; |
| | | export default { |
| | | //import引入的组件需要注入到对象中才能使用 |
| | |
| | | }, |
| | | data() { |
| | | let validName = (rule, value, callback) => { |
| | | if (value === "") { |
| | | return callback(new Error("目录名称不能为空")); |
| | | if (value === "" || value === null || value === undefined) { |
| | | return callback(new Error("名称不能为空")); |
| | | } else { |
| | | callback(); |
| | | } |
| | |
| | | uncode: "", |
| | | website: "", |
| | | }, |
| | | backUpData: {}, |
| | | formLabelWidth: "170px", |
| | | deleteIDs: "", |
| | | backUpData: "", |
| | | formLabelWidth: "130px", |
| | | delChildID: "", |
| | | delChildIDs: [], |
| | | dialogFormVisible: false, |
| | | ruleForm: { |
| | | level: null, |
| | | orderNum: null, |
| | | pid: null, |
| | | name: "", |
| | | descr: "", |
| | | addr: "", |
| | | bak: "", |
| | | code: "", |
| | | contact: "", |
| | | email: "", |
| | | fax: "", |
| | | name: "", |
| | | post: "", |
| | | sname: "", |
| | | uncode: "", |
| | | website: "", |
| | | }, |
| | | rules: { |
| | | name: [{ validator: validName, trigger: "blur" }], |
| | | name: [{ required: true, validator: validName, trigger: "blur" }], |
| | | }, |
| | | }; |
| | | }, |
| | |
| | | this.newData = res.result; |
| | | this.depList = this.treeData(res.result); |
| | | } else { |
| | | console.log("接口报错"); |
| | | this.$notify.error({ |
| | | title: res.code, |
| | | message: "无法获取单位列表", |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | // 循环所有项 |
| | | let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据 |
| | | branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值 |
| | | return father.pid == 1; // 返回一级菜单 |
| | | return father.pid == 0; // 返回一级菜单 |
| | | }); |
| | | }, |
| | | append(node, data) { |
| | |
| | | }, |
| | | resetForm(formName) { |
| | | this.dialogFormVisible = false; |
| | | this.$refs[formName].resetFields(); |
| | | this.$nextTick(() => { |
| | | this.ruleForm = {}; |
| | | this.$refs[formName].resetFields(); |
| | | }); |
| | | }, |
| | | submitForm(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | this.fullscreenLoading = true; |
| | | // console.log(this.ruleForm); |
| | | // insertDir(this.ruleForm) |
| | | // .then((res) => { |
| | | // setTimeout(() => { |
| | | // this.fullscreenLoading = false; |
| | | // if (res.code == 200) { |
| | | // this.$message({ |
| | | // message: "添加成功", |
| | | // type: "success", |
| | | // }); |
| | | // } |
| | | // }, 2000); |
| | | // }) |
| | | // .catch((res) => { |
| | | // console.log(res); |
| | | // this.fullscreenLoading = false; |
| | | // }); |
| | | |
| | | // this.validCode = ""; //清空验证码输入框的内容 |
| | | this.fullscreenLoading = true; |
| | | insertDep(this.ruleForm) |
| | | .then((res) => { |
| | | setTimeout(() => { |
| | | this.fullscreenLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "添加成功", |
| | | type: "success", |
| | | }); |
| | | this.itemdetail = {}; |
| | | this.ruleForm = {}; |
| | | this.dialogFormVisible = false; |
| | | this.$refs[formName].resetFields(); |
| | | } |
| | | }, 500); |
| | | }) |
| | | .catch((res) => { |
| | | this.itemdetail = {}; |
| | | this.$message.error("添加失败"); |
| | | this.fullscreenLoading = false; |
| | | console.log(res); |
| | | }); |
| | | } else { |
| | | // alert("目录名称不能为空"); |
| | | return false; |
| | |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | // console.log(node); |
| | | // console.log(data); |
| | | |
| | | //兄弟重新排序 |
| | | const parent = node.parent; |
| | | const children = parent.data.children || parent.data; |
| | | children.splice(data.orderNum - 1, 1); |
| | |
| | | item.orderNum = index + 1; |
| | | }); |
| | | |
| | | this.traverseArr(data); |
| | | console.log(this.deleteIDs); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "删除成功!", |
| | | }); |
| | | this.traverseArr(data); //获取删除的子ID |
| | | this.delChildIDs.push(data.id); //要删除的全部ID |
| | | let delIDs = this.delChildIDs; |
| | | Promise.all([ |
| | | deleteDep({ ids: delIDs.toString() }), |
| | | updateDepTrees(children), |
| | | ]) |
| | | .then((res) => { |
| | | console.log(res); |
| | | if (res[0].code == 200 && res[1].code == 200) { |
| | | this.$message({ |
| | | 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.error("删除失败"); |
| | | this.itemdetail = {}; |
| | | }); |
| | | |
| | | //重置要删除的子ID |
| | | 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.deleteIDs += "id=" + item.id + "&"; |
| | | // this.delChildID += "id=" + item.id + "&"; |
| | | this.delChildIDs.push(item.id); |
| | | this.traverseArr(item); |
| | | }); |
| | | } |
| | |
| | | arr.push(e); |
| | | }); |
| | | this.newData = arr; |
| | | this.sendChange(); |
| | | }) |
| | | .catch(() => { |
| | | this.$message({ |
| | |
| | | sendChange() { |
| | | updateDepTrees(this.newData) |
| | | .then((res) => { |
| | | // console.log(res); |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | type: "success", |
| | | message: "更新成功!", |
| | | }); |
| | | alert("调整完成。请及时刷新页面!"); |
| | | return; |
| | | } else { |
| | | alert("调整失败,请重试!"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | |
| | | this.backUpData = JSON.stringify(data); |
| | | this.itemdetail = JSON.parse(JSON.stringify(data)); |
| | | }, |
| | | updDep() { |
| | | updateDepTree(this.itemdetail).then((res) => { |
| | | console.log(res); |
| | | updDep(formName) { |
| | | this.$nextTick(() => { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | this.fullscreenLoading = true; |
| | | updateDepTree(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.itemdetail = JSON.parse(this.backUpData); |
| | | this.$refs[formName].resetFields(); |
| | | if (this.backUpData != "") { |
| | | this.itemdetail = JSON.parse(this.backUpData); |
| | | } |
| | | }, |
| | | }, |
| | | mounted() { |
| | |
| | | left: 250px; |
| | | top: 23px; |
| | | } |
| | | .menuTreeBox { |
| | | .depTreeBox { |
| | | height: 88%; |
| | | width: 100%; |
| | | overflow: auto; |
| | |
| | | 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> |