|
|
@ -7,7 +7,7 @@ import { useHomeStore } from 'stores/homeStore' |
|
|
|
import { computed, inject, nextTick, onMounted, ref, watch, watchEffect } from 'vue' |
|
|
|
|
|
|
|
import { FtMessage } from '@/libs/message' |
|
|
|
import { convertValuesToInt, convertValuesToString } from '@/libs/utils' |
|
|
|
import { convertValuesToString } from '@/libs/utils' |
|
|
|
import { useFormulaStore } from '@/stores/formulaStore' |
|
|
|
|
|
|
|
const homeStore = useHomeStore() |
|
|
@ -72,14 +72,14 @@ onMounted(() => { |
|
|
|
*/ |
|
|
|
watchEffect(() => { |
|
|
|
if (formulaStore.currentSelectedIndex === null) { |
|
|
|
formData.value = cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
|
formData.value = cloneDeep(formulaStore.defaultFormulaInfo || {}) |
|
|
|
} |
|
|
|
else { |
|
|
|
formData.value = cloneDeep(formulaStore.currentSelectedFormulaInfo) |
|
|
|
formData.value = cloneDeep(formulaStore.currentSelectedFormulaInfo || {}) |
|
|
|
} |
|
|
|
isFlip.value = formulaStore.flip |
|
|
|
// 后端给的数据类型是字符串型,前端需要的是int型,后端开发说(赵贺)后端不好转换,由前端进行转换. |
|
|
|
formData.value = convertValuesToInt(formData.value) |
|
|
|
formData.value = convertValuesToString(formData.value, 'name') |
|
|
|
}) |
|
|
|
|
|
|
|
const disinfectionState = ref(homeStore.disinfectionState) // 消毒状态 |
|
|
@ -126,7 +126,15 @@ const handleSubmit = async () => { |
|
|
|
return |
|
|
|
} |
|
|
|
const formulaForm: Record<string, any> = convertValuesToString(formData.value, 'name') |
|
|
|
formulaStore.editFormula(formulaForm.formula_id, formulaForm as Formula.FormulaItem) |
|
|
|
formulaStore |
|
|
|
.editFormula(formulaForm.formula_id, formulaForm as Formula.FormulaItem) |
|
|
|
.then(() => { |
|
|
|
FtMessage.success('操作成功') |
|
|
|
formulaStore.initFormulaList('edit') |
|
|
|
}) |
|
|
|
.catch((e) => { |
|
|
|
console.log(e) |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
// 新增配方 |
|
|
@ -135,9 +143,14 @@ const handleSubmit = async () => { |
|
|
|
const item = res.rely |
|
|
|
const formulaForm: Record<string, any> = convertValuesToString(formData.value, 'name') |
|
|
|
formulaForm.formula_id = item.formula_id |
|
|
|
formulaStore.editFormula(item.formula_id, formulaForm as Formula.FormulaItem).then(() => { |
|
|
|
formulaStore |
|
|
|
.editFormula(item.formula_id, formulaForm as Formula.FormulaItem) |
|
|
|
.then(() => { |
|
|
|
FtMessage.success('操作成功') |
|
|
|
formulaStore.initFormulaList() |
|
|
|
formulaStore.initFormulaList('add') |
|
|
|
}) |
|
|
|
.catch((e) => { |
|
|
|
console.log(e) |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
@ -167,8 +180,8 @@ const handleConfirm = (value: string) => { |
|
|
|
const size = 'default' |
|
|
|
// 新增配方方法 |
|
|
|
const addFormula = async () => { |
|
|
|
const formulaInfo = cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
|
formData.value = convertValuesToInt(formulaInfo) |
|
|
|
formData.value = cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
|
// formData.value = convertValuesToInt(formulaInfo) |
|
|
|
await nextTick() // 等待DOM更新 |
|
|
|
formData.value.name = '' |
|
|
|
formData.value.formula_id = null |
|
|
@ -238,7 +251,7 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form |
|
|
|
</ft-input> |
|
|
|
</template> |
|
|
|
<template v-if="item.val_type === 'float'"> |
|
|
|
<ft-input v-model.number="formData[item.setting_id]" layout-name="number" style="width: 80%" type="number"> |
|
|
|
<ft-input v-model="formData[item.setting_id]" layout-name="number" style="width: 80%"> |
|
|
|
<template v-if="labelUnitMap[item.setting_id]" #append> |
|
|
|
{{ labelUnitMap[item.setting_id] }} |
|
|
|
</template> |
|
|
@ -267,7 +280,7 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form |
|
|
|
</template> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<div :style="{ marginLeft: '33%' }"> |
|
|
|
<div> |
|
|
|
<slot name="formulaBtn"> |
|
|
|
<div class="default-btn"> |
|
|
|
<el-button type="primary" class="config-btn" @click="handleSubmit"> |
|
|
@ -295,11 +308,12 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form |
|
|
|
<style lang="scss" scoped> |
|
|
|
.formula-form { |
|
|
|
font-size: 20px !important; |
|
|
|
padding: 5px; |
|
|
|
padding-left: 15px; |
|
|
|
padding: 5px 5px 5px 15px; |
|
|
|
align-items: center; |
|
|
|
.default-btn { |
|
|
|
margin-top: 1rem; |
|
|
|
display: flex; |
|
|
|
justify-content: center; |
|
|
|
} |
|
|
|
.config-btn { |
|
|
|
height: 3rem; |
|
|
@ -320,7 +334,7 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form |
|
|
|
height: 40px; |
|
|
|
} |
|
|
|
:deep(.el-select__wrapper) { |
|
|
|
height: 40px; |
|
|
|
height: 42px; |
|
|
|
} |
|
|
|
:deep(.el-form-item) { |
|
|
|
margin-right: 0; |
|
|
|