Prechádzať zdrojové kódy

refactor(forecast): 优化年份验证逻辑并重构编辑按钮显示控制

yz 2 týždňov pred
rodič
commit
a24aacb822

+ 12 - 2
src/constants/forecast.js

@@ -117,7 +117,17 @@ export const FORECAST_FORM_RULES = {
   /** 年份验证规则 */
   year: [
     { required: true, message: '请选择年份', trigger: 'change' },
-    { type: 'number', min: 2020, max: 2050, message: '年份必须在2020-2050之间', trigger: 'change' }
+    {
+      validator: (rule, value, callback) => {
+        const year = parseInt(value)
+        if (isNaN(year) || year < 2020 || year > 2050) {
+          callback(new Error('年份必须在2020-2050之间'))
+        } else {
+          callback()
+        }
+      },
+      trigger: 'change'
+    }
   ],
   /** 月份验证规则 */
   month: [
@@ -169,4 +179,4 @@ export const DEFAULT_FORECAST_FORM = {
   forecastQuantity: null,
   currentInventory: null,
   approvalStatus: APPROVAL_STATUS.PENDING
-}
+}

+ 11 - 1
src/views/forecast/forecastIndex.js

@@ -60,7 +60,7 @@ export default {
         viewBtn: false,
         selection: false,
         addBtn: true,
-        editBtn: true,
+        editBtn: false, // 禁用内置编辑按钮
         delBtn: false,
         excelBtn: false,
         columnBtn: false,
@@ -68,6 +68,8 @@ export default {
         dialogClickModal: false,
         addBtnText: '新增预测申报',
         editBtnText: '编辑',
+        // 添加这个配置来完全隐藏操作列
+        menu: false,
         column: [
           {
             label: '预测编码',
@@ -200,6 +202,14 @@ export default {
             format: 'yyyy-MM-dd HH:mm:ss',
             search: false,
             width: 160
+          },
+          // 添加自定义编辑按钮列
+          {
+            label: '操作',
+            prop: 'editBtn',
+            slot: true,
+            width: 120,
+            fixed: 'right'
           }
         ]
       },

+ 9 - 3
src/views/forecast/index.vue

@@ -33,7 +33,7 @@
       <!-- 自定义编辑按钮 -->
       <template slot-scope="{row, index}" slot="editBtn">
         <el-button
-          v-if="canEditRow(row)"
+          v-if="canEdit(row)"
           type="primary"
           size="small"
           icon="el-icon-edit"
@@ -339,6 +339,7 @@
 
 <script>
 import forecastMixin from './forecastIndex.js'
+import { canEdit } from '@/constants/forecast.js'
 
 /**
  * 经销商销售预测申报页面
@@ -346,10 +347,15 @@ import forecastMixin from './forecastIndex.js'
  */
 export default {
   name: 'ForecastIndex',
-  mixins: [forecastMixin]
+  mixins: [forecastMixin],
+    methods: {
+        canEdit(row) {
+            return canEdit(row.approvalStatus)
+        }
+    }
 }
 </script>
 
 <style lang="scss">
 @import './index.scss';
-</style>
+</style>