| | |
| | | <el-form-item> |
| | | |
| | | <el-button |
| | | v-show="directoryFlag" |
| | | icon="el-icon-download" |
| | | type="info" |
| | | size="small" |
| | | @click="setDirectoryDownload" |
| | | >{{ $t("shuJuGuanLi.butten.directoryDownload") }}</el-button> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | |
| | | <el-button |
| | | icon="el-icon-download" |
| | | type="info" |
| | | size="small" |
| | |
| | | import MyBread from "../../components/MyBread.vue"; |
| | | import clone from "@turf/clone"; |
| | | import $ from 'jquery' |
| | | import { getToken } from '../../utils/auth'; |
| | | export default { |
| | | name: "catalogueManage", |
| | | components: { |
| | |
| | | } |
| | | }; |
| | | return { |
| | | directoryData: null, |
| | | directoryFlag: false, |
| | | menuStatus: { |
| | | delete: false, |
| | | insert: false, |
| | |
| | | exts: res[i].exts, |
| | | orderNum: null, |
| | | pid: null, |
| | | tid: parseInt(value[2]) + 1, |
| | | sid: parseInt(value[3]) + 1 |
| | | }) |
| | | } |
| | | |
| | | this.tableData = arr; |
| | | this.setInsertData(this.tableData); |
| | | |
| | |
| | | } |
| | | } |
| | | if (chLevel == 1) { |
| | | return [res['L' + chLevel], null] |
| | | return [res['L' + chLevel], null, flag, -1] |
| | | } else { |
| | | faLevel = chLevel - 1; |
| | | for (var i = flag; i >= 0; i--) { |
| | | var val = result[i] |
| | | if (val['L' + faLevel]) { |
| | | return [res['L' + chLevel], val['L' + faLevel]] |
| | | return [res['L' + chLevel], val['L' + faLevel], flag, i] |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | setInsertData(res) { |
| | | |
| | | var list = this.excelData(res); |
| | | |
| | | if (list.length != 0) { |
| | |
| | | return this.$message.error("上传数据错误,第一条数据不为空"); |
| | | } |
| | | |
| | | this.getAllNodeId(list); |
| | | this.getAllNodeId(res); |
| | | } |
| | | }, |
| | | async getAllNodeId(res) { |
| | |
| | | val.orderNum = this.dirList[this.dirList.length - 1].orderNum + 1; |
| | | val.pid = 0; |
| | | } else { |
| | | |
| | | this.tableData.filter((child) => { |
| | | if (child.name == val.pname) { |
| | | if (child.tid == val.sid) { |
| | | val.pid = child.id; |
| | | val.orderNum = i + 1; |
| | | } |
| | |
| | | const data = await insertDir(val); |
| | | if (data.code != 200) { |
| | | } |
| | | |
| | | this.tableData.filter((child) => { |
| | | if (child.name == val.name && child.pname == val.pname) { |
| | | |
| | | if (child.name == val.name && child.tid == val.tid) { |
| | | child.id = data.result; |
| | | } |
| | | }); |
| | | this.itemaName = data.result; |
| | | this.getDirTree(); |
| | | |
| | | if (res[i].children) { |
| | | this.getAllNodeId(res[i].children); |
| | | } |
| | | // if (res[i].children) { |
| | | // this.getAllNodeId(res[i].children); |
| | | // } |
| | | } |
| | | }, |
| | | excelData(source) { |
| | | let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆 |
| | | return cloneData.filter((father) => { |
| | | // 循环所有项 |
| | | let branchArr = cloneData.filter((child) => father.name == child.pname); // 对比ID,分别上下级菜单,并返回数据 |
| | | let branchArr = cloneData.filter((child) => father.tid == child.sid); // 对比ID,分别上下级菜单,并返回数据 |
| | | |
| | | branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值 |
| | | // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2; |
| | | // 由此循环多次后,就能形成相应的树形数据结构 |
| | | return father.pname == null; // 返回一级菜单 |
| | | return father.sid == 0; // 返回一级菜单 |
| | | }); |
| | | }, |
| | | readFile(file) { |
| | |
| | | this.$message.error("修改失败,请重试!"); |
| | | }); |
| | | }, |
| | | |
| | | setDirectoryDownload() { |
| | | var url = BASE_URL + '/dir/downloadDir?token=' + getToken() + '&id=' + this.directoryData.id |
| | | console.log(url) |
| | | $("#Iframe1").attr("src", url).click() |
| | | }, |
| | | handleNodeClick(data, node) { |
| | | // console.log(data); |
| | | |
| | | if (data.pid == 0) { |
| | | this.directoryData = data; |
| | | this.directoryFlag = true; |
| | | } else { |
| | | this.directoryFlag = false; |
| | | } |
| | | this.newNode = node; |
| | | this.backUpData = JSON.stringify(data); |
| | | this.itemdetail = JSON.parse(JSON.stringify(data)); |