基础资料模块优化

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, detailData,
onSubmit, onSubmit,
handleBack, handleBack,
fetchData fetchData,
initializeFormData
} }
} }

View File

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

View File

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