ConfigForm 修改

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

@ -38,31 +38,46 @@
type: Array, type: Array,
default: () => { default: () => {
return [] return []
} },
}, },
// id // id
id: { id: {
type: String, type: String,
default: '' default: '',
}, },
// //
name: { name: {
type: String, type: String,
default: '' default: '',
} },
isTransfer: {
type: Boolean,
default: false,
},
}, },
setup(props) { emits: ['TransferData'],
setup(props, context) {
const { t } = useI18n() const { t } = useI18n()
// //
const addFormToSet = () => { 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 = { const res = {
defaultValue: item.defaultValue || '', defaultValue: item.defaultValue || '',
field: item.field || '', field: item.field || '',
label: item.label || '', label: item.label || '',
required: item.required || false, required: item.required || false,
colProps: item.colProps || { span: 24 }, colProps: item.colProps || { span: 24 },
component: item.component component: item.component,
} }
// //
if (item.show !== false) { if (item.show !== false) {
@ -80,22 +95,25 @@
templateName: props.name, templateName: props.name,
permissionName: permissionsInfo().permissionName, permissionName: permissionsInfo().permissionName,
content: JSON.stringify({ content: JSON.stringify({
columns: columns columns: columns,
}) }),
} }
editCodeGoodsType(Apidata).then(res => { editCodeGoodsType(Apidata)
if (res.succeeded) { .then((res) => {
createMessage.success('添加成功!') if (res.succeeded) {
} createMessage.success('添加成功!')
}).catch(() => { }
createMessage.error('添加失败!') })
}) .catch(() => {
createMessage.error('添加失败!')
})
} }
return { return {
t, t,
addFormToSet addFormToSet,
FnaddFormToSet,
} }
} },
}) })
</script> </script>
@ -103,4 +121,4 @@
.config-form { .config-form {
cursor: pointer; cursor: pointer;
} }
</style> </style>

@ -2,6 +2,15 @@
<div class="basic-info"> <div class="basic-info">
<XCard style="padding-top: 15px"> <XCard style="padding-top: 15px">
<div style="margin-top: -24px"> <div style="margin-top: -24px">
<ConfigForm
@TransferData="TransferData"
isviews="海运出口"
:form-schema="basicInfoFormSchema"
:isTransfer="true"
name="基础表单"
id="1"
ref="RefChilrenRef"
></ConfigForm>
<BasicForm @register="registerForm" /> <BasicForm @register="registerForm" />
<!-- <a-form <!-- <a-form
style="margin-bottom: 10px" style="margin-bottom: 10px"
@ -808,6 +817,24 @@
// --------------created ||beforeCreate-------------- // --------------created ||beforeCreate--------------
init() 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 }) { function getSelectViewRes({ type, res }) {
console.log(props.details, type, res) console.log(props.details, type, res)

Loading…
Cancel
Save