ConfigForm 修改

szh-new
张同海 6 months ago
parent 4bf0a7908a
commit b138e57752

@ -38,31 +38,46 @@
type: Array,
default: () => {
return []
}
},
},
// id
id: {
type: String,
default: ''
default: '',
},
//
name: {
type: String,
default: ''
}
default: '',
},
setup(props) {
isTransfer: {
type: Boolean,
default: false,
},
},
emits: ['TransferData'],
setup(props, context) {
const { t } = useI18n()
//
const addFormToSet = () => {
const columns = props.formSchema.map((item: FormSchema) => {
if (props.isTransfer) {
context.emit('TransferData')
} else {
FnaddFormToSet(null)
}
}
const FnaddFormToSet = (e) => {
let data: any = e ? e : props.formSchema
console.log(data)
const columns = data.map((item: FormSchema) => {
const res = {
defaultValue: item.defaultValue || '',
field: item.field || '',
label: item.label || '',
required: item.required || false,
colProps: item.colProps || { span: 24 },
component: item.component
component: item.component,
}
//
if (item.show !== false) {
@ -80,22 +95,25 @@
templateName: props.name,
permissionName: permissionsInfo().permissionName,
content: JSON.stringify({
columns: columns
})
columns: columns,
}),
}
editCodeGoodsType(Apidata).then(res => {
editCodeGoodsType(Apidata)
.then((res) => {
if (res.succeeded) {
createMessage.success('添加成功!')
}
}).catch(() => {
})
.catch(() => {
createMessage.error('添加失败!')
})
}
return {
t,
addFormToSet
}
addFormToSet,
FnaddFormToSet,
}
},
})
</script>

@ -2,6 +2,15 @@
<div class="basic-info">
<XCard style="padding-top: 15px">
<div style="margin-top: -24px">
<ConfigForm
@TransferData="TransferData"
isviews="海运出口"
:form-schema="basicInfoFormSchema"
:isTransfer="true"
name="基础表单"
id="1"
ref="RefChilrenRef"
></ConfigForm>
<BasicForm @register="registerForm" />
<!-- <a-form
style="margin-bottom: 10px"
@ -808,6 +817,24 @@
// --------------created ||beforeCreate--------------
init()
// ---------------------------------------------------
const RefChilrenRef = ref('')
function TransferData() {
let Arr: any = []
basicInfoFormSchema.forEach((item) => {
Object.keys(getFieldsValue()).forEach((item2) => {
if (item2 == item.field && item2 !== 'id') {
Arr.push({ ...item, defaultValue: getFieldsValue()[item2] })
}
})
})
RefChilrenRef.value.FnaddFormToSet(Arr)
// updateSchema(Arr).then(() => {
// // console.log(RefChilrenRef.value)
// // console.log(Arr, basicInfoFormSchema)
// })
// // console.log(Arr, 'TransferData')
}
function getSelectViewRes({ type, res }) {
console.log(props.details, type, res)

Loading…
Cancel
Save