|
@ -6,7 +6,7 @@ import { ElMessage } from 'element-plus' |
|
|
import { formulaNameMap } from 'libs/constant' |
|
|
import { formulaNameMap } from 'libs/constant' |
|
|
import { cloneDeep } from 'lodash' |
|
|
import { cloneDeep } from 'lodash' |
|
|
import { useHomeStore } from 'stores/homeStore' |
|
|
import { useHomeStore } from 'stores/homeStore' |
|
|
import { computed, inject, nextTick, onMounted, ref, watch, watchEffect } from 'vue' |
|
|
|
|
|
|
|
|
import { computed, inject, nextTick, onMounted, ref, watch } from 'vue' |
|
|
|
|
|
|
|
|
import { FtMessage } from '@/libs/message' |
|
|
import { FtMessage } from '@/libs/message' |
|
|
import { compareJSON, convertValuesToInt, convertValuesToString } from '@/libs/utils' |
|
|
import { compareJSON, convertValuesToInt, convertValuesToString } from '@/libs/utils' |
|
@ -25,7 +25,7 @@ const props = defineProps<{ |
|
|
}>() |
|
|
}>() |
|
|
const homeStore = useHomeStore() |
|
|
const homeStore = useHomeStore() |
|
|
|
|
|
|
|
|
const nameLeng = 10 |
|
|
|
|
|
|
|
|
const nameLength = 10 |
|
|
|
|
|
|
|
|
const formulaStore = useFormulaStore() |
|
|
const formulaStore = useFormulaStore() |
|
|
|
|
|
|
|
@ -105,26 +105,7 @@ const currentFormulaItem = ref() |
|
|
* 组件挂载时注册方法供父组件调用 |
|
|
* 组件挂载时注册方法供父组件调用 |
|
|
*/ |
|
|
*/ |
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
registerGrandsonMethods && registerGrandsonMethods({ getFormData }) |
|
|
|
|
|
}) |
|
|
|
|
|
/** |
|
|
|
|
|
* 模态框是否打开 |
|
|
|
|
|
*/ |
|
|
|
|
|
const isModalOpen = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 打开模态框 |
|
|
|
|
|
*/ |
|
|
|
|
|
const openModal = () => { |
|
|
|
|
|
isModalOpen.value = true |
|
|
|
|
|
} |
|
|
|
|
|
const disinfectionState = ref(homeStore.disinfectionState) // 消毒状态 |
|
|
|
|
|
/** |
|
|
|
|
|
* 监听配方配置列表和表单数据变化 |
|
|
|
|
|
* 根据不同的type属性值初始化表单数据 |
|
|
|
|
|
*/ |
|
|
|
|
|
watchEffect(() => { |
|
|
|
|
|
formulaConfigList.value = formulaStore.formulaConfigList |
|
|
|
|
|
|
|
|
initFormulaConfig() |
|
|
if (props.type === 'home') { |
|
|
if (props.type === 'home') { |
|
|
formData.value = cloneDeep(formulaStore.selectedFormulaInfo) || cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
formData.value = cloneDeep(formulaStore.selectedFormulaInfo) || cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
} |
|
|
} |
|
@ -136,15 +117,36 @@ watchEffect(() => { |
|
|
formData.value = cloneDeep(formulaStore.resetFormulaInfo) |
|
|
formData.value = cloneDeep(formulaStore.resetFormulaInfo) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
formData.value = cloneDeep(formulaStore.currentSelectedFormulaInfo) || cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
|
|
|
|
|
|
formData.value = cloneDeep(formulaStore.currentSelectedFormulaInfo) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
isFlip.value = formulaStore.flip |
|
|
isFlip.value = formulaStore.flip |
|
|
// 后端给的数据类型是字符串型,前端需要的是int型,后端开发说(赵贺)后端不好转换,由前端进行转换. |
|
|
// 后端给的数据类型是字符串型,前端需要的是int型,后端开发说(赵贺)后端不好转换,由前端进行转换. |
|
|
formData.value = convertValuesToInt(formData.value) |
|
|
formData.value = convertValuesToInt(formData.value) |
|
|
|
|
|
registerGrandsonMethods && registerGrandsonMethods({ getFormData }) |
|
|
|
|
|
}) |
|
|
|
|
|
watch(() => formulaStore.currentSelectedFormulaInfo, () => { |
|
|
|
|
|
formData.value = cloneDeep(formulaStore.currentSelectedFormulaInfo) |
|
|
}) |
|
|
}) |
|
|
|
|
|
const initFormulaConfig = () => { |
|
|
|
|
|
if (!formulaStore.formulaList.length) { |
|
|
|
|
|
formulaStore.getFormualDefaultData() |
|
|
|
|
|
console.log(formulaStore.formulaConfigList) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 模态框是否打开 |
|
|
|
|
|
*/ |
|
|
|
|
|
const isModalOpen = ref(false) |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
* 打开模态框 |
|
|
|
|
|
*/ |
|
|
|
|
|
const openModal = () => { |
|
|
|
|
|
isModalOpen.value = true |
|
|
|
|
|
} |
|
|
|
|
|
const disinfectionState = ref(homeStore.disinfectionState) // 消毒状态 |
|
|
|
|
|
/** |
|
|
* 监听软键盘输入值变化,更新表单数据 |
|
|
* 监听软键盘输入值变化,更新表单数据 |
|
|
* @param {string | number} newVal - 新的输入值 |
|
|
* @param {string | number} newVal - 新的输入值 |
|
|
*/ |
|
|
*/ |
|
@ -158,7 +160,7 @@ watch(inputValue, (newVal: string | number) => { |
|
|
formData.value[focusedInput.value] = newVal |
|
|
formData.value[focusedInput.value] = newVal |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
if (newVal && newVal.toString().length > nameLeng) { |
|
|
|
|
|
|
|
|
if (newVal && newVal.toString().length > nameLength) { |
|
|
inputValue.value = formData.value[focusedInput.value] |
|
|
inputValue.value = formData.value[focusedInput.value] |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|