[update] 树形弹框
This commit is contained in:
@@ -23,15 +23,15 @@
|
|||||||
@check="onCheck"
|
@check="onCheck"
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
@expand="onExpand"
|
@expand="onExpand"
|
||||||
@loadData="loadData"
|
:loadData="loadData"
|
||||||
:expandedKeys="expandedKeys"
|
:expandedKeys="expandedKeys"
|
||||||
:checkedKeys="checkedKeys">
|
:checkedKeys="checkedKeys">
|
||||||
|
|
||||||
<template slot="title" slot-scope="{name}">
|
<template slot="title" slot-scope="{dataRef}">
|
||||||
<span v-if="searchValue && name.indexOf(searchValue) > -1">
|
<span v-if="searchValue && dataRef[replaceFields.title].indexOf(searchValue) > -1">
|
||||||
<span style="color: #f50">{{ name }}</span>
|
<span style="color: #f50">{{ dataRef[replaceFields.title] }}</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-else>{{name}}</span>
|
<span v-else>{{ dataRef[replaceFields.title] }}</span>
|
||||||
</template>
|
</template>
|
||||||
</a-tree>
|
</a-tree>
|
||||||
</div>
|
</div>
|
||||||
@@ -81,12 +81,6 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
// 查询传的字段名
|
|
||||||
searchFieldName: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'name'
|
|
||||||
},
|
|
||||||
// 存储字段 [key field]
|
// 存储字段 [key field]
|
||||||
storeField: {
|
storeField: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -103,12 +97,6 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
|
||||||
// 懒加载接口,默认是涉及系统/部件的懒加载接口
|
|
||||||
lazyLoadHref: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: '/laws/dictTree/getChild'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -130,13 +118,24 @@ export default {
|
|||||||
if (val) {
|
if (val) {
|
||||||
this.checkedKeys = val.split(',')
|
this.checkedKeys = val.split(',')
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
optionsHref: {
|
||||||
mounted () {
|
immediate: true,
|
||||||
if (this.optionsHref === '/laws/standard/partName/') {
|
handler (val) {
|
||||||
this.replaceFields = { children: 'childPartNameList', title: 'name', key: 'id' }
|
console.log('-------------optionsHref', val)
|
||||||
} else { // 标签库
|
if (val === '/laws/standard/partName/') {
|
||||||
this.replaceFields = { children: 'childrenList', title: 'itemText', key: 'id' }
|
// 是涉及系统/部件
|
||||||
|
this.replaceFields = { children: 'childPartNameList', title: 'name', key: 'id' }
|
||||||
|
this.lazyLoadHref = ''
|
||||||
|
this.searchFieldName = 'name'
|
||||||
|
this.lazyLoadPidFieldName = ''
|
||||||
|
} else { // 标签库
|
||||||
|
this.replaceFields = { children: 'childrenList', title: 'itemText', key: 'id' }
|
||||||
|
this.lazyLoadHref = '/laws/dictTree/getChild'
|
||||||
|
this.searchFieldName = 'nodeName'
|
||||||
|
this.lazyLoadPidFieldName = 'dictItemId'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
@@ -152,7 +151,11 @@ export default {
|
|||||||
checkedRows: [],
|
checkedRows: [],
|
||||||
loadedKeys: [], // 已经加载的节点
|
loadedKeys: [], // 已经加载的节点
|
||||||
searchValue: '', // 查询框内容
|
searchValue: '', // 查询框内容
|
||||||
replaceFields: {}
|
replaceFields: {},
|
||||||
|
dataSourceRight: [],
|
||||||
|
lazyLoadHref: '', // 懒加载接口
|
||||||
|
searchFieldName: '', // 查询传的字段名
|
||||||
|
lazyLoadPidFieldName: '' // 懒加载传父级的字段名
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -203,18 +206,22 @@ export default {
|
|||||||
},
|
},
|
||||||
// 异步加载
|
// 异步加载
|
||||||
loadData (node) {
|
loadData (node) {
|
||||||
|
console.log('-------node', node)
|
||||||
if (node.dataRef.children) {
|
if (node.dataRef.children) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.confirmLoading = true
|
this.confirmLoading = true
|
||||||
const params = {}
|
const params = {}
|
||||||
|
params.dictId = this.dictId
|
||||||
// 查询条件的名称
|
// 查询条件的名称
|
||||||
params[this.searchFieldName] = this.searchValue
|
if (this.searchValue) {
|
||||||
|
params[this.searchFieldName] = this.searchValue
|
||||||
|
}
|
||||||
// 父节点id
|
// 父节点id
|
||||||
params.pid = node.dataRef.id
|
params.dictItemId = node.dataRef.id
|
||||||
getAction(this.optionsHref, params).then(res => {
|
getAction(this.lazyLoadHref, params).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
node.childPartNameList = res.result.record
|
node[this.replaceFields.children] = res.result.record
|
||||||
this.loadedKeys.push(node.id)
|
this.loadedKeys.push(node.id)
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
@@ -228,6 +235,7 @@ export default {
|
|||||||
this.visible = false
|
this.visible = false
|
||||||
this.checkedKeys = []
|
this.checkedKeys = []
|
||||||
this.expandedKeys = []
|
this.expandedKeys = []
|
||||||
|
this.dataSourceRight = []
|
||||||
this.treeData = []
|
this.treeData = []
|
||||||
this.searchValue = ''
|
this.searchValue = ''
|
||||||
},
|
},
|
||||||
@@ -334,4 +342,10 @@ export default {
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-content-title {
|
||||||
|
color: #1D2129;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-right: 12px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user