| | |
| | | */ |
| | | const initFormData = (newForm) => { |
| | | formData.value = { ...newForm }; |
| | | console.log(formData.value) |
| | | // 处理 coalFieldList 字段:编辑时需要将字符串转换为数组供多选组件使用 |
| | | if (newForm.coalFields) { |
| | | if (typeof newForm.coalFields === 'string') { |
| | | if (newForm.fieldIds) { |
| | | if (typeof newForm.fieldIds === 'string') { |
| | | // 将字符串转换为ID数组,然后匹配对应的选项对象 |
| | | const ids = parseCoalFields(newForm.coalFields); |
| | | const ids = parseCoalFields(newForm.fieldIds); |
| | | formData.value.coalFieldList = ids.map(id => { |
| | | const option = fieldOptions.find(opt => opt.value === id); |
| | | return option || { fields: `字段${id}`, value: id }; |