store_tree_data

master
luoJunYong.123 3 years ago
parent 00eef97493
commit 007ae3ba14
  1. 69
      src/views/Transaction.vue

@ -353,6 +353,7 @@
import quill from "@/components/quill"; import quill from "@/components/quill";
import MyTree from "@/components/myTree/src/tree"; import MyTree from "@/components/myTree/src/tree";
import {deepCopy} from "@/utils/deepCopy"; import {deepCopy} from "@/utils/deepCopy";
import { mapState } from 'vuex'
export default { export default {
components: {quill, MyTree}, components: {quill, MyTree},
@ -401,6 +402,11 @@ export default {
loading:true, loading:true,
}; };
}, },
computed: {
...mapState({
treeDataStore: state => state.treeDataStore
})
},
mounted() { mounted() {
this.$route.query.token && this.$store.commit("setParam", { this.$route.query.token && this.$store.commit("setParam", {
token: atob(decodeURI(this.$route.query.token)) token: atob(decodeURI(this.$route.query.token))
@ -671,23 +677,51 @@ export default {
} }
}, },
getTreeData() { // getTreeData() { //
this.$get(this.api.getLcRecord).then(res => {
if (res.status == 200 && res.list.length>0) { if(this.treeDataStore.length) {
if (res.list.length>0) { const tmp = [...this.treeDataStore]
this.treeData = this.toTreeId(res.list, res.list[0].parentId); this.treeData = this.toTreeId(tmp, this.treeDataStore[0].parentId);
if (this.$route.query.lcId) { if (this.$route.query.lcId) {
this.lcId = this.$route.query.lcId; this.lcId = this.$route.query.lcId;
this.getInfoData(this.$route.query.lcId); this.getInfoData(this.$route.query.lcId);
} else { }
this.loading = false }else {
this.$get(this.api.getLcRecord).then(res => {
if (res.status == 200 && res.list.length>0) {
if (res.list.length>0) {
this.$store.commit('setTreeDataStore', { treeDataStore: res.list})
this.treeData = this.toTreeId(res.list, res.list[0].parentId);
if (this.$route.query.lcId) {
this.lcId = this.$route.query.lcId;
this.getInfoData(this.$route.query.lcId);
}
} }
} else {
this.$message.warning(res.message);
} }
} else { }).catch(err => {
this.$message.warning(res.message); // console.log(err);
} });
}).catch(err => { }
// console.log(err);
});
// this.$get(this.api.getLcRecord).then(res => {
// if (res.status == 200 && res.list.length>0) {
// if (res.list.length>0) {
// this.treeData = this.toTreeId(res.list, res.list[0].parentId);
// if (this.$route.query.lcId) {
// this.lcId = this.$route.query.lcId;
// this.getInfoData(this.$route.query.lcId);
// } else {
// this.loading = false
// }
// }
// } else {
// this.$message.warning(res.message);
// }
// }).catch(err => {
// // console.log(err);
// });
}, },
toTreeId(data, parentId) { // id++,便key,id toTreeId(data, parentId) { // id++,便key,id
let result = []; let result = [];
@ -840,7 +874,10 @@ export default {
}) })
} }
addSuffix(treeData) addSuffix(treeData)
this.$refs.tree.setCheckedKeys([]) this.$nextTick(() => {
this.$refs.tree.setCheckedKeys([])
})
}, },
addRule() { // addRule() { //
this.changeArr.splice(0, this.changeArr.length) this.changeArr.splice(0, this.changeArr.length)

Loading…
Cancel
Save