基础资料模块优化

main
GaoF 2024-08-01 09:06:30 +08:00
parent c565f0acbf
commit 090141d19f
3 changed files with 37 additions and 16 deletions

View File

@ -122,6 +122,7 @@ export default function useFormHandler(formItems, api) {
detailData,
onSubmit,
handleBack,
fetchData
fetchData,
initializeFormData
}
}

View File

@ -107,11 +107,16 @@
</a-form>
</a-tab-pane>
<a-tab-pane key="5" tab="扩展字段" force-render>
<a-form layout="vertical">
<a-form layout="vertical" :model="extendFormData">
<a-row :gutter="16">
<a-col :span="item.span || 6" v-for="(item, index) in extendData" :key="index">
<a-form-item :label="item.label" :name="item.name" :rules="item.rules">
<component style="width: 100%" :is="item.type" v-model:value="item.defaultValue" v-bind="item.attrs" />
<component
style="width: 100%"
:is="item.type"
v-model:value="extendFormData[item.name]"
v-bind="item.attrs"
/>
</a-form-item>
</a-col>
</a-row>
@ -146,6 +151,7 @@
promoteEnabledState: 'ENABLE'
})
let extendData = ref([]) //
let extendFormData = ref({}) //
onMounted(async () => {
formRefs.value = [formRef1.value, formRef2.value, formRef3.value]
@ -170,6 +176,11 @@
unitOptions = unitList
dataSource.value = packageData
if (res.extJson) {
extendFormData.value = JSON.parse(res.extJson)
console.log(extendFormData.value, 'extendFormData.value')
}
}
})
@ -232,21 +243,29 @@
.then((res) => {
if (res) {
res.forEach((item) => {
const showValues = JSON.parse(item.showValues)
let options = []
showValues.forEach((value) => {
options.push({
value: value.name,
label: value.name
})
})
extendData.value.push({
label: item.fieldName,
label: item.name,
name: item.fieldName,
type: 'ASelect',
type: item.showType,
span: 6,
attrs: {
placeholder: '请输入内容',
options: [],
fieldNames: {
label: 'name',
value: 'id'
}
options
}
})
})
extendData.value.forEach((item) => {
if (item.fieldName) extendFormData.value[item.fieldName] = null
})
}
})
})
@ -279,12 +298,13 @@
}
const onSubmitForm = () => {
console.log(productFormData.value, 'productFormData.value')
console.log(extendFormData.value, 'extendFormData.value')
onSubmit({
isDeep: true,
materialPackageList: dataSource.value,
...formData,
...productFormData.value
...productFormData.value,
extJson: JSON.stringify(extendFormData.value)
})
}

View File

@ -28,7 +28,7 @@
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="字段" name="fieldType">
<a-form-item label="字段类型" name="fieldType">
<a-input v-model:value="formData.fieldType" placeholder="请输入字段名" allow-clear />
</a-form-item>
</a-col>
@ -69,7 +69,7 @@
<a-button type="primary" danger @click="delSelectableData(index)" v-if="index !== 0">
<MinusOutlined />
</a-button>
<a-input style="width: 100%" v-model:value="item.filedName" placeholder="请输入内容"></a-input>
<a-input style="width: 100%" v-model:value="item.name" placeholder="请输入内容"></a-input>
</a-space>
</div>
</a-col>
@ -102,13 +102,13 @@
//
let selectableData = ref([
{
filedName: ''
name: '',
}
])
const addSelectableData = () => {
selectableData.value.push({
filedName: ''
name: '',
})
}