diff --git a/package-lock.json b/package-lock.json index 4a12221..086daec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7142,10 +7142,9 @@ } }, "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "lodash.defaultsdeep": { "version": "4.6.1", diff --git a/package.json b/package.json index 9061954..83eff5f 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "core-js": "^3.6.5", "element-ui": "^2.14.0", "lib-flexible": "^0.3.2", + "lodash": "^4.17.21", "mavon-editor": "^2.10.4", "postcss-px2rem": "^0.3.0", "postcss-pxtorem": "^5.1.1", diff --git a/src/utils/http.js b/src/utils/http.js index 295b513..5641223 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -18,7 +18,7 @@ if(isKd){ host = 'http://124.71.12.62:9000'; // 巢湖版 } else if (dev) { host = 'http://121.37.12.51'; - // host = 'http://192.168.31.217:9000'; + host = 'http://192.168.31.217:9000'; } } diff --git a/src/views/Transaction.vue b/src/views/Transaction.vue index 99ee79c..ac59c6a 100644 --- a/src/views/Transaction.vue +++ b/src/views/Transaction.vue @@ -488,7 +488,7 @@ import quill from "@/components/quill"; import MyTree from "@/components/myTree/src/tree"; import { deepCopy } from "@/utils/deepCopy"; import { mapState } from 'vuex' - +import _ from 'lodash' export default { components: { quill, MyTree }, data () { @@ -554,7 +554,7 @@ export default { SelectedObj: [], counts: 0, loading: true, - moneys: [100, 50, 20, 10, 5, 1, 0.5, 0.1] + moneys: [100, 50, 20, 10, 5, 1, 0.5, 0.1], }; }, computed: { @@ -568,6 +568,7 @@ export default { localStorage.setItem('token', atob(decodeURI(token))) localStorage.setItem('referrer', atob(decodeURI(referrer))) } + if (this.isSt) { this.leftSymbols = [ { @@ -626,38 +627,25 @@ export default { this.tableData.forEach(async (item, index) => { item.i = index // 勾选树节点 - //let lists = JSON.parse(JSON.stringify(this.treeData)) - // let lists = this.treeData if (item.operationIds) { - let list = JSON.parse(JSON.stringify(this.treeData)) + let list = _.cloneDeep(this.treeData) item.operationIData = [] - let findOut = null - let testObj = {} - for (let i = 0; i < list.length; i++) { - const id = item.operationIds.split(',') - if (list[i].id == id[0]) { - findOut = this.filterRule(id, list, testObj) - } - } - item.operationIData.push(testObj.children[0]) - } - // 根据题目id,获取题目信息 - if (item.isSubject && item.type && item.type != 4 && item.emptyOne) { - // await this.getSubjectData(item.emptyOne, index); + let result = {} + let serial = 0 + this.handleRule(item.operationIds.split(','), list, result, serial) + item.operationIData.push(result.children[0]) } }); this.setIndex() this.$nextTick(() => { this.loading = false }) - console.log("🚀 ~ file: Transaction.vue:646 ~ this.tableData.forEach ~ this.tableData:", this.treeData) } else { this.$message.warning(res.message); this.loading = false } }).catch(err => { this.loading = false - // console.log(err); }); }, // 获取业务 @@ -685,11 +673,12 @@ export default { handleSelectionChange (val) { this.multipleSelection = val }, - filterRule (id, obj = [], needObj) { - let first = id.shift() - let tmp = obj.find(item => item.id == first) - needObj.children = obj.filter(item => item.id == first) - if (tmp) return this.filterRule(id, tmp.children, needObj.children.length ? needObj.children[0] : []) + handleRule (id, list, result, serial) { + const curId = id[serial] + const cur = list.find(e => e.id == curId) + result.children = cur ? [cur] : [] + ++serial + cur && cur.children && this.handleRule(id, cur.children, result.children[0], serial) }, //计算此节点的距离思路1.计算出当前节点据顶部的高度+当前节点在树的位置的高度-盒子高度的一半 scrollToDepTree (deptCode) { @@ -721,17 +710,13 @@ export default { this.getSubjectData(item.subjectId, index); } if (item.operationIds) { - let list = JSON.parse(JSON.stringify(this.treeData)) + let list = _.cloneDeep(this.treeData) item.operationIData = [] - let testObj = {} - let findOut = null - for (let i = 0; i < list.length; i++) { - let id = item.operationIds.split(',') - if (list[i].id == id[0]) { - findOut = this.filterRule(id, list, testObj) - } - } - testObj.children && item.operationIData.push(testObj.children[0]) + + let result = {} + let serial = 0 + this.handleRule(item.operationIds.split(','), list, result, serial) + result.children && item.operationIData.push(result.children[0]) } }); this.setIndex() @@ -891,7 +876,6 @@ export default { this.$set(this.tableData, index, item); } }).catch(err => { - // console.log(err); }); } }, @@ -956,7 +940,6 @@ export default { const name = this.isSt ? 'recordChildren' : 'children' let result = []; data.forEach(item => { - // console.log("🚀 ~ file: Transaction.vue:866 ~ toTreeId ~ name:", item[name]) item.label = item.name if (item.isNode === 0) { item.showCheckbox = false; @@ -986,9 +969,7 @@ export default { } else { this.isNameRepeat = true; } - }).catch(err => { - // console.log(err); - }); + }).catch(err => { }); } }, saveAll () { // 保存判分点 @@ -1078,9 +1059,7 @@ export default { } else { this.$message.warning(res.message); } - }).catch(err => { - // console.log(err); - }); + }).catch(err => { }); } else if (this.isEdit) { // 编辑判分点 this.$post(this.api.updateJudgmentPoint, this.formData).then(res => { if (res.status === 200) { @@ -1089,9 +1068,7 @@ export default { } else { this.$message.warning(res.message); } - }).catch(err => { - // console.log(err); - }); + }).catch(err => { }); } }, // 新增判分点