From c0db1d4fa603e227695ffc8738a30843c28f5dd6 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期二, 07 四月 2026 16:30:06 +0800
Subject: [PATCH] 新增和编辑页面工资定额输入验证,确保其不小于0
---
src/views/productionManagement/productionProcess/Edit.vue | 25 +++++++++++++++++++++++--
src/views/productionManagement/productionProcess/New.vue | 25 +++++++++++++++++++++++--
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/src/views/productionManagement/productionProcess/Edit.vue b/src/views/productionManagement/productionProcess/Edit.vue
index fb0ee74..c2c4186 100644
--- a/src/views/productionManagement/productionProcess/Edit.vue
+++ b/src/views/productionManagement/productionProcess/Edit.vue
@@ -40,8 +40,17 @@
<el-option label="璁′欢" :value="1" />
</el-select>
</el-form-item>
- <el-form-item label="宸ヨ祫瀹氶" prop="salaryQuota">
- <el-input v-model="formState.salaryQuota" type="number" :step="0.001" />
+ <el-form-item
+ label="宸ヨ祫瀹氶"
+ prop="salaryQuota"
+ :rules="[
+ {
+ validator: validateSalaryQuota,
+ trigger: ['blur', 'change']
+ }
+ ]"
+ >
+ <el-input v-model="formState.salaryQuota" type="number" :step="0.001" :min="0" />
</el-form-item>
<el-form-item label="鏄惁璐ㄦ" prop="isQuality">
<el-switch v-model="formState.isQuality" :active-value="true" inactive-value="false"/>
@@ -130,6 +139,18 @@
let { proxy } = getCurrentInstance()
+const validateSalaryQuota = (rule, value, callback) => {
+ if (value === '' || value === null || value === undefined) {
+ callback();
+ return;
+ }
+ if (Number(value) < 0) {
+ callback(new Error('宸ヨ祫瀹氶涓嶈兘灏忎簬0'));
+ return;
+ }
+ callback();
+};
+
const closeModal = () => {
isShow.value = false;
};
diff --git a/src/views/productionManagement/productionProcess/New.vue b/src/views/productionManagement/productionProcess/New.vue
index a5f00aa..0688f10 100644
--- a/src/views/productionManagement/productionProcess/New.vue
+++ b/src/views/productionManagement/productionProcess/New.vue
@@ -40,8 +40,17 @@
<el-option label="璁′欢" :value="1" />
</el-select>
</el-form-item>
- <el-form-item label="宸ヨ祫瀹氶" prop="salaryQuota">
- <el-input v-model="formState.salaryQuota" type="number" :step="0.001">
+ <el-form-item
+ label="宸ヨ祫瀹氶"
+ prop="salaryQuota"
+ :rules="[
+ {
+ validator: validateSalaryQuota,
+ trigger: ['blur', 'change']
+ }
+ ]"
+ >
+ <el-input v-model="formState.salaryQuota" type="number" :step="0.001" :min="0">
<template #append>鍏�</template>
</el-input>
</el-form-item>
@@ -95,6 +104,18 @@
let { proxy } = getCurrentInstance()
+const validateSalaryQuota = (rule, value, callback) => {
+ if (value === '' || value === null || value === undefined) {
+ callback();
+ return;
+ }
+ if (Number(value) < 0) {
+ callback(new Error('宸ヨ祫瀹氶涓嶈兘灏忎簬0'));
+ return;
+ }
+ callback();
+};
+
const closeModal = () => {
isShow.value = false;
};
--
Gitblit v1.9.3