Browse Source

fix:表单校验

master
guoapeng 3 days ago
parent
commit
ab2d02c271
  1. 18
      src/components/formula/FormulaConfig.vue
  2. 15
      src/components/formula/RunFormulaConfig.vue
  3. 15
      src/components/formula/SettingFormulaConfig.vue
  4. 4
      src/stores/homeStore.ts

18
src/components/formula/FormulaConfig.vue

@ -38,6 +38,7 @@ const registerGrandsonMethods = inject<(methods: any) => void>('registerGrandson
* 配方配置列表
*/
const formulaConfigList = ref(formulaStore.formulaConfigList)
console.log('formulaConfigList', formulaConfigList.value)
/**
* 标签单位映射表用于显示各参数的单位
@ -175,7 +176,9 @@ defineExpose({
addFormula,
})
const validatePass = (rule: any, value: any, callback: any, config: Formula.FormulaConfig) => {
console.log(config)
if (!value && value !== 0 && value !== '0') {
console.log(config)
callback(new Error('此为必填项'))
}
else if (value.substring(0, 1) === '.' || value.split('.').length > 2) {
@ -187,6 +190,21 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
callback(new Error(`输入范围为${config.val_lower_limit}-${config.val_upper_limit}`))
}
}
if (config.setting_id === 'continued_satur') {
if (Number(value) > Number(formData.value.stoped_satur)) {
callback(new Error('继续值不能大于停止值'))
}
}
if (config.setting_id === 'continued_gs') {
if (Number(value) > Number(formData.value.stoped_gs)) {
callback(new Error('继续值不能大于停止值'))
}
}
if (config.setting_id === 'continued_humi') {
if (Number(value) > Number(formData.value.stoped_humi)) {
callback(new Error('继续值不能大于停止值'))
}
}
callback()
}
const validateName = (rule: any, value: any, callback: any) => {

15
src/components/formula/RunFormulaConfig.vue

@ -55,6 +55,21 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
callback(new Error(`输入范围为${config.val_lower_limit}-${config.val_upper_limit}`))
}
}
if (config.setting_id === 'continued_satur') {
if (Number(value) > Number(formData.value.stoped_satur)) {
callback(new Error('继续值不能大于停止值'))
}
}
if (config.setting_id === 'continued_gs') {
if (Number(value) > Number(formData.value.stoped_gs)) {
callback(new Error('继续值不能大于停止值'))
}
}
if (config.setting_id === 'continued_humi') {
if (Number(value) > Number(formData.value.stoped_humi)) {
callback(new Error('继续值不能大于停止值'))
}
}
callback()
}
</script>

15
src/components/formula/SettingFormulaConfig.vue

@ -76,6 +76,21 @@ const validatePass = (rule: any, value: any, callback: any, config: Formula.Form
callback(new Error(`输入范围为${config.val_lower_limit}-${config.val_upper_limit}`))
}
}
if (config.setting_id === 'continued_satur') {
if (Number(value) > Number(formData.value.stoped_satur)) {
callback(new Error('继续值不能大于停止值'))
}
}
if (config.setting_id === 'continued_gs') {
if (Number(value) > Number(formData.value.stoped_gs)) {
callback(new Error('继续值不能大于停止值'))
}
}
if (config.setting_id === 'continued_humi') {
if (Number(value) > Number(formData.value.stoped_humi)) {
callback(new Error('继续值不能大于停止值'))
}
}
callback()
}

4
src/stores/homeStore.ts

@ -179,7 +179,7 @@ export const useHomeStore = defineStore('home', () => {
* @desc 湿
*/
const updateHomeData = (data: Home.DisplayrelyMgr[]) => {
console.log(data)
// console.log(data)
data.forEach((item, index) => {
h2O2SensorData.value[index] = {
...h2O2SensorData.value[index],
@ -225,7 +225,7 @@ export const useHomeStore = defineStore('home', () => {
* @desc 3
*/
const updateHomeDisinfectionState = (disinfectState: Home.DisinfectState) => {
console.log(disinfectState)
// console.log(disinfectState)
disinfectionState.value = disinfectState
if (!renderTimer) {
renderTimer = setTimeout(() => {

Loading…
Cancel
Save