feat: parent to parentLabel

pull/12/head
xingyu 2023-05-10 20:19:42 +08:00
parent 20dca104bb
commit cfd4ac840e
3 changed files with 5 additions and 5 deletions

View File

@ -23,8 +23,8 @@ const props = defineProps({
immediate: { type: Boolean, default: true },
resultField: propTypes.string.def(''),
handleTree: { type: String, default: '' },
parent: { type: String, default: '' },
parentId: { type: Number, default: 0 },
parentLabel: { type: String, default: '' },
parentFiled: { type: String, default: 'name' }
})
const emit = defineEmits(['options-change', 'change'])
@ -82,9 +82,9 @@ async function fetch() {
if (props.handleTree) {
result = handleTree(result, props.handleTree)
}
if (props.parent) {
if (props.parentLabel) {
let tree: Recordable = { id: props.parentId, children: [] }
tree = set(tree, props.parentFiled, props.parent)
tree = set(tree, props.parentFiled, props.parentLabel)
tree.children = (result as Recordable[]) || []
treeData.value.push(tree)
} else {

View File

@ -90,7 +90,7 @@ export const formSchema: FormSchema[] = [
component: 'ApiTreeSelect',
componentProps: {
api: () => listSimpleDept(),
parent: '主类目',
parentLabel: '主类目',
fieldNames: {
label: 'name',
key: 'id',

View File

@ -84,7 +84,7 @@ export const formSchema: FormSchema[] = [
component: 'ApiTreeSelect',
componentProps: {
api: () => listSimpleMenus(),
parent: '主类目',
parentLabel: '主类目',
fieldNames: {
label: 'name',
key: 'id',