| | |
| | | <template> |
| | | <avue-input-tree ref="referTree" :props="props" :disabled="disabled" :lazy="lazy" :tree-load="treeLoad" :node-click="nodeClick" :checked="checked" :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> |
| | | <avue-input-tree ref="referTree" :props="props" :disabled="disabled" :lazy="lazy" :tree-load="treeLoad" :node-click="nodeClick" :checked="checked" :blur="valueChange" :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | }, |
| | | treeUrl: this.referConfig.options.url || '/api/ubcs-code/mdmEngineController/defaultReferTree', |
| | | treeData: [], |
| | | selectionList: [], |
| | | checkedData:[], |
| | | currentNode:{}, |
| | | params: {}, |
| | | loadType: {'all': 'all', 'node': 'node'}, |
| | |
| | | }, |
| | | created() { |
| | | this.getParams(); |
| | | // console.log('referConfig:') |
| | | // console.log(this.referConfig) |
| | | }, |
| | | mounted() { |
| | | if(!this.lazy){ |
| | |
| | | queryParams['loadType'] = this.options.loadType; |
| | | queryParams['multipleSelect'] = this.isMuti; |
| | | queryParams['isMuti'] = queryParams['multipleSelect']; |
| | | if (this.options.remoteSort && this.options.initSort) { |
| | | if (this.options.initSort) { |
| | | queryParams['order'] = this.options.initSort.type;//方法 |
| | | queryParams['sort'] = this.options.initSort.field;//字段 |
| | | } |
| | | if(this.options.sortField){ |
| | | queryParams['sort'] = this.options.sortField;//字段 |
| | | } |
| | | if(this.options.sortType){ |
| | | queryParams['order'] = this.options.sortType;//方法 |
| | | } |
| | | if (this.options.rootParams) { |
| | | for (var key in this.options.rootParams) { |
| | |
| | | queryParams['replaceMap["' + key + '"]'] = this.options.replaceParams[key];//新的方式 |
| | | } |
| | | } |
| | | queryParams['parentValue']='\\IN(SELECT oid from PL_CODE_CLASSIFY where id =\'hesuanfenlei\')' |
| | | this.params=queryParams; |
| | | |
| | | }, |
| | | getTree(){ |
| | | getTree(this.params,this.treeUrl).then(res => { |
| | | this.treeData=res.data |
| | | getTree() { |
| | | getTree(this.params, this.treeUrl).then(res => { |
| | | res.data.map(item => { |
| | | if (!item.attribute) { |
| | | item.attribute = { |
| | | data: {} |
| | | } |
| | | } else { |
| | | item.attribute.data = item.attribute.data || {} |
| | | } |
| | | return { |
| | | ...item, |
| | | leaf: !item.hasChildren |
| | | } |
| | | }) |
| | | this.treeData = res.data |
| | | }) |
| | | }, |
| | | treeLoad: function (treeNode, resolve) { |
| | | const parentOid = (treeNode.level === 0) ? 0 : treeNode.data.oid; |
| | |
| | | } |
| | | getLazyTree(this.params,this.treeUrl).then(res => { |
| | | resolve(res.data.data.map(item => { |
| | | if(!item.attribute){ |
| | | item.attribute={ |
| | | data:{} |
| | | } |
| | | }else{ |
| | | item.attribute.data=item.attribute.data || {} |
| | | } |
| | | return { |
| | | ...item, |
| | | leaf: !item.hasChildren |
| | |
| | | if(!this.isMuti) { |
| | | this.setValue({checkedNodes:[data]}) |
| | | } |
| | | }, |
| | | }, |
| | | checked(checkedNode, checkedData) { |
| | | this.setValue(checkedData) |
| | | this.checkedData=checkedData |
| | | }, |
| | | valueChange(){ |
| | | if(this.isMuti){ |
| | | // this.setValue(this.checkedData) |
| | | } |
| | | }, |
| | | setValue:function (checkedData){ |
| | | var value = []; |
| | |
| | | } |
| | | text.push(tempRaw.join(textSep)); |
| | | } |
| | | let mapFields =this.referConfig.fieldMap || {}; |
| | | try { |
| | | if(!validatenull(this.options.mapFields)){ |
| | | mapFields =Object.assign(this.referConfig.fieldMap,JSON.parse(this.options.mapFields)) ; |
| | | } |
| | | }catch (e) { |
| | | |
| | | } |
| | | this.value = value.join(','); |
| | | this.text = text.join(',') |
| | | this.text = text.join(','); |
| | | this.$emit("setValue", { |
| | | field: this.referConfig.field, |
| | | showField: this.referConfig.showField, |
| | |
| | | text: this.text || '', |
| | | isTreeMuti:this.isMuti, |
| | | rawData: checkedData.checkedNodes, |
| | | fieldMap:this.referConfig.fieldMap |
| | | fieldMap:mapFields |
| | | }); |
| | | } |
| | | }, |