diff --git a/src/components/formula/FormulaConfig.vue b/src/components/formula/FormulaConfig.vue index 3a93546..502f0e5 100644 --- a/src/components/formula/FormulaConfig.vue +++ b/src/components/formula/FormulaConfig.vue @@ -176,11 +176,15 @@ const getFormData = () => { * 监听表单数据变化,同步更新软键盘输入值 * @param {Record} newValue - 新的表单数据 */ -watch(formData, (newValue) => { - if (focusedInput.value) { - inputValue.value = newValue[focusedInput.value].toString() - } -}, { deep: true }) +watch( + formData, + (newValue) => { + if (focusedInput.value) { + inputValue.value = newValue[focusedInput.value].toString() + } + }, + { deep: true }, +) const formRef = ref(null) /** @@ -229,11 +233,14 @@ const onSaveFormula = () => { const onSaveSetting = async () => { // 修改默认值 const diff = compareJSON(formulaStore.defaultFormulaInfo, formData.value) + console.log(diff) const diffKeys = Object.keys(diff) if (diffKeys.length) { - await Promise.all(diffKeys.map(async (key) => { - await setSettingFormulaConfig(key, diff[key].newVal) - })) + await Promise.all( + diffKeys.map(async (key) => { + await setSettingFormulaConfig(key, diff[key].newVal || diff[key].obj2) + }), + ) FtMessage.success('配方修改成功') } } @@ -250,7 +257,7 @@ const setSettingFormulaConfig = async (settingName: string, settingVal: string) fnName: 'setSettingVal', params: { settingName, - settingVal: settingVal.toString(), + settingVal: settingVal?.toString(), }, }) formulaStore.getFormualDefaultData() @@ -408,21 +415,21 @@ defineExpose({ />