| | |
| | | |
| | | <script> |
| | | import {getTreeList} from "@/api/MasterData/master"; |
| | | import {mapMutations, mapState} from "vuex"; |
| | | import {TableData,MasterTable} from "@/api/GetItem"; |
| | | import {TableData, MasterTable} from "@/api/GetItem"; |
| | | |
| | | export default { |
| | | name: "MasterTree", |
| | | props:{ |
| | | pageSize:{ |
| | | type:String, |
| | | default:"10" |
| | | props: { |
| | | pageSize: { |
| | | type: String, |
| | | default: "10" |
| | | }, |
| | | currentPage:{ |
| | | type:String, |
| | | default:"1" |
| | | currentPage: { |
| | | type: String, |
| | | default: "1" |
| | | }, |
| | | templateOid:{ |
| | | type:String, |
| | | default:'' |
| | | templateOid: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | }, |
| | | data(){ |
| | | return{ |
| | | idData:'', |
| | | masterVrBtnList:[], |
| | | tableHeadFindData:[], |
| | | tableHeadDataFateher:[], |
| | | templateOids:"", |
| | | tableDataArray:[], |
| | | codeClassifyOid:"", |
| | | coderuleoid:"", |
| | | CloneTreeAvueform:{}, |
| | | loading:false, |
| | | Treedata:[], |
| | | data() { |
| | | return { |
| | | idData: '', |
| | | masterVrBtnList: [], |
| | | tableHeadFindData: [], |
| | | tableHeadDataFateher: [], |
| | | templateOids: "", |
| | | tableDataArray: [], |
| | | codeClassifyOid: "", |
| | | coderuleoid: "", |
| | | CloneTreeAvueform: {}, |
| | | loading: false, |
| | | Treedata: [], |
| | | nodeClickList: "", |
| | | Treeoption: { |
| | | addBtn: false, |
| | |
| | | // console.log(node) |
| | | // console.log(resolve) |
| | | // } |
| | | treeLoad:function (node, resolve){ |
| | | if(node.data != false){ |
| | | treeLoad: function (node, resolve) { |
| | | if (node.data != false) { |
| | | const parentId = (node.level === 0) ? 0 : node.data.oid; |
| | | const parentBtmName = node.data.attributes.btmname |
| | | getTreeList({parentOid:parentId,parentBtmName:parentBtmName}).then(res=>{ |
| | | resolve(res.data.map(item=>{ |
| | | getTreeList({parentOid: parentId, parentBtmName: parentBtmName}).then(res => { |
| | | resolve(res.data.map(item => { |
| | | return { |
| | | ...item, |
| | | label:item.text |
| | | label: item.text |
| | | } |
| | | })) |
| | | }) |
| | |
| | | created() { |
| | | this.getTreeLists() |
| | | }, |
| | | computed:{ |
| | | }, |
| | | methods:{ |
| | | computed: {}, |
| | | methods: { |
| | | //获取数据 |
| | | getTreeLists(){ |
| | | getTreeLists() { |
| | | const index = this.$route.query.id.indexOf('@'); |
| | | const result = this.$route.query.id.substring(0, index); |
| | | this.idData=result |
| | | this.idData = result |
| | | // console.log(this.$route) |
| | | getTreeList({'conditionMap[id]':this.idData }).then(res=>{ |
| | | this.Treedata=res.data; |
| | | getTreeList({'conditionMap[id]': this.idData}).then(res => { |
| | | this.Treedata = res.data; |
| | | const [firstProperty] = res.data; |
| | | this.ModifyProperties(this.Treedata, 'text', 'label'); |
| | | this.codeClassifyOid=firstProperty.oid; |
| | | this.coderuleoid=firstProperty.attributes.coderuleoid; |
| | | this.$emit("coderuleoid", this.coderuleoid ) |
| | | }).catch(res=>{ |
| | | this.codeClassifyOid = firstProperty.oid; |
| | | this.coderuleoid = firstProperty.attributes.coderuleoid; |
| | | this.$emit("coderuleoid", this.coderuleoid) |
| | | this.$emit('Treedata', this.Treedata) |
| | | }).catch(res => { |
| | | this.$message.error(res) |
| | | }) |
| | | }, |
| | |
| | | } |
| | | }, |
| | | //表格刷新 |
| | | TableRend(){ |
| | | TableRend() { |
| | | TableData({ |
| | | templateOid: this.templateOids, |
| | | codeClassifyOid: this.nodeClickList.oid, |
| | | page: this.currentPage, |
| | | limit: this.pageSize, |
| | | }).then(res => { |
| | | this.tableDataArray=res.data.data; |
| | | this.$emit('tableDataArray',this.tableDataArray) |
| | | this.$emit('total',res.data.total) |
| | | this.tableDataArray = res.data.data; |
| | | this.$emit('tableDataArray', this.tableDataArray) |
| | | this.$emit('total', res.data.total) |
| | | }) |
| | | }, |
| | | //表格头部 |
| | |
| | | return new Promise((resolve, reject) => { |
| | | MasterTable({ |
| | | codeClassifyOid: this.nodeClickList.oid, |
| | | functionId:result, |
| | | functionId: result, |
| | | }).then(res => { |
| | | const flagsToDeleteBtn = ["CODEIMPORTHISTORY", "CODEEXPORT", "CODEQUERY","batchApplyCode"]; |
| | | const flagsToDeleteBtn = ["CODEIMPORTHISTORY", "CODEEXPORT", "CODEQUERY", "batchApplyCode"]; |
| | | //不同节点显示不同按钮 |
| | | if (!res.data.leaf) { |
| | | this.masterVrBtnList = res.data.buttons.filter(obj => flagsToDeleteBtn.includes(obj.uniqueFlag)); |
| | |
| | | async nodeClick(data) { |
| | | try { |
| | | this.nodeClickList = data; |
| | | this.tableHeadDataFateher=[] |
| | | this.tableHeadFindData=[] |
| | | this.tableHeadDataFateher = [] |
| | | this.tableHeadFindData = [] |
| | | await this.TableHeadRend(); // 先执行 TableHeadRend() |
| | | this.TableRend(); // TableHeadRend() 方法完成后再执行 TableRend() |
| | | this.$emit('nodeClick',this.templateOids) |
| | | this.$emit("codeClassifyOid", this.nodeClickList.oid ) |
| | | this.$emit('nodeClick', this.templateOids) |
| | | this.$emit("codeClassifyOid", this.nodeClickList.oid) |
| | | } catch (error) { |
| | | // 处理错误 |
| | | this.$message.error(error) |