|
|
@ -4,7 +4,7 @@ import SelectModal from 'components/common/SelectModal/index.vue' |
|
|
|
import SoftKeyboard from 'components/common/SoftKeyboard/index.vue' |
|
|
|
import { formulaNameMap } from 'libs/constant' |
|
|
|
import { cloneDeep } from 'lodash' |
|
|
|
import { inject, onMounted, ref, watch, watchEffect } from 'vue' |
|
|
|
import { inject, nextTick, onMounted, ref, watch, watchEffect } from 'vue' |
|
|
|
|
|
|
|
import { FtMessage } from '@/libs/message' |
|
|
|
import { compareJSON, convertValuesToInt, convertValuesToString } from '@/libs/utils' |
|
|
@ -134,7 +134,6 @@ watchEffect(() => { |
|
|
|
isFlip.value = formulaStore.flip |
|
|
|
// 后端给的数据类型是字符串型,前端需要的是int型,后端开发说(赵贺)后端不好转换,由前端进行转换. |
|
|
|
formData.value = convertValuesToInt(formData.value) |
|
|
|
options.value = formulaStore.logLevelOptions |
|
|
|
}) |
|
|
|
|
|
|
|
/** |
|
|
@ -177,6 +176,7 @@ watch(formData, (newValue) => { |
|
|
|
inputValue.value = newValue[focusedInput.value].toString() |
|
|
|
} |
|
|
|
}, { deep: true }) |
|
|
|
const formRef = ref(null) |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理表单提交 |
|
|
@ -187,7 +187,11 @@ const handleSubmit = () => { |
|
|
|
FtMessage.warning('请输入配方名称') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 表单验证 |
|
|
|
if (formData.value.name && formData.value.name.length > 20) { |
|
|
|
FtMessage.warning('配方名称1-20字符') |
|
|
|
return |
|
|
|
} |
|
|
|
// 配方管理的【确定】 |
|
|
|
if (props.type === 'formula') { |
|
|
|
onSaveFormula() |
|
|
@ -359,21 +363,41 @@ const handleLogCancel = () => { |
|
|
|
const openKeyboardType = (labelName: string) => { |
|
|
|
keyboardType.value = labelName === 'name' ? 'text' : 'number' |
|
|
|
} |
|
|
|
const size = 'default' |
|
|
|
// 新增配方方法 |
|
|
|
const addFormula = async () => { |
|
|
|
const formulaInfo = cloneDeep(formulaStore.defaultFormulaInfo) |
|
|
|
console.log(formulaInfo) |
|
|
|
formData.value = formulaInfo |
|
|
|
await nextTick() // 等待DOM更新 |
|
|
|
// 移除左侧列表的选中 |
|
|
|
formData.value.name = '' |
|
|
|
formData.value.formula_id = null |
|
|
|
console.log('子组件方法被调用') |
|
|
|
} |
|
|
|
|
|
|
|
// 暴露方法给父组件 |
|
|
|
defineExpose({ |
|
|
|
addFormula, |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<transition name="slide-right"> |
|
|
|
<div v-if="isFlip" class="formula-form"> |
|
|
|
<el-form :model="formData" label-width="auto" label-position="right" class="formulaFormItem" inline> |
|
|
|
<el-form-item v-if="type !== 'setting'" label="配方名称" style="margin-top:20px"> |
|
|
|
<el-form ref="formRef" :model="formData" label-width="auto" label-position="right" :size="size" inline> |
|
|
|
<el-form-item v-if="type !== 'setting'" label="配方名称" style="width: 100%;"> |
|
|
|
<el-input |
|
|
|
v-model="formData.name" |
|
|
|
v-prevent-keyboard |
|
|
|
:rules="[ |
|
|
|
{ required: true, message: '配方名称必填', trigger: 'blur' }, |
|
|
|
{ min: '1', max: '20', message: '配方名称1-20个字符', trigger: 'blur' }, |
|
|
|
]" |
|
|
|
name="name" |
|
|
|
prop="name" |
|
|
|
placeholder="配方名称" |
|
|
|
maxlength="10" |
|
|
|
:disabled="type === 'home'" |
|
|
|
class="formdata-input-home" |
|
|
|
@focus="openKeyboard" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
@ -381,7 +405,7 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
v-for="(item) in formulaConfigList" |
|
|
|
:key="item.setting_id" |
|
|
|
:label="formulaNameMap[item.setting_id]" |
|
|
|
style="margin-top:20px" |
|
|
|
style="width: 50%;" |
|
|
|
> |
|
|
|
<template v-if="item.val_type === 'int'"> |
|
|
|
<el-input |
|
|
@ -390,7 +414,6 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
type="number" |
|
|
|
:name="item.setting_id" |
|
|
|
:controls="false" |
|
|
|
class="formdata-input-home" |
|
|
|
:disabled="!item.is_visible_in_setting_page" |
|
|
|
@focus="(e) => openKeyboard(e, item)" |
|
|
|
> |
|
|
@ -404,7 +427,6 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
v-model="formData[item.setting_id]" |
|
|
|
v-prevent-keyboard |
|
|
|
placeholder="请选择" |
|
|
|
class="formdata-input-home" |
|
|
|
readonly |
|
|
|
@focus="openModal" |
|
|
|
> |
|
|
@ -416,7 +438,6 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
<template v-else-if="item.val_type === 'boolean'"> |
|
|
|
<el-radio-group |
|
|
|
v-model="formData[item.setting_id]" |
|
|
|
class="formdata-input-home" |
|
|
|
:disabled="!item.is_visible_in_setting_page" |
|
|
|
> |
|
|
|
<el-radio :label="true"> |
|
|
@ -429,7 +450,7 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
</template> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<div v-if="type !== 'home'" class="formula-form-btn" :style="{ marginLeft: '33%' }"> |
|
|
|
<div v-if="type !== 'home'" :style="{ marginLeft: '33%' }"> |
|
|
|
<slot name="formulaBtn"> |
|
|
|
<div class="default-btn"> |
|
|
|
<el-button v-if="type === 'setting'" class="config-btn" @click="handleResetDefault"> |
|
|
@ -473,13 +494,11 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
font-size: 20px !important; |
|
|
|
padding: 5px; |
|
|
|
padding-left: 15px; |
|
|
|
align-items: center; |
|
|
|
//height: 81vh; |
|
|
|
overflow: auto; |
|
|
|
.formulaFormItem{ |
|
|
|
display: grid; |
|
|
|
grid-template-columns: 1fr 1fr; |
|
|
|
} |
|
|
|
.formula-form-btn{ |
|
|
|
// display: grid; |
|
|
|
// grid-template-columns: 1fr 1fr; |
|
|
|
} |
|
|
|
.default-btn{ |
|
|
|
margin-top: 1rem; |
|
|
@ -490,10 +509,6 @@ const openKeyboardType = (labelName: string) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.formdata-input-home{ |
|
|
|
width: 15vw; |
|
|
|
} |
|
|
|
|
|
|
|
.formula-form-item{ |
|
|
|
display: grid; |
|
|
|
grid-template-columns: 1fr 1fr; |
|
|
|