浏览代码

feat(forecast): 添加编辑权限检查并优化表单显示逻辑

yz 1 月之前
父节点
当前提交
f3e1afe15b
共有 3 个文件被更改,包括 23 次插入14 次删除
  1. 7 4
      src/components/forecast-form/index.vue
  2. 8 1
      src/views/forecast/forecastIndex.js
  3. 8 9
      src/views/forecast/index.vue

+ 7 - 4
src/components/forecast-form/index.vue

@@ -1,8 +1,10 @@
 <template>
-  <!-- 销售预测表单容器 - AvueJS版本 -->
-  <div class="forecast-form-container basic-container">
-    <!-- 表单内容区域 -->
-    <div class="forecast-form-content">
+  <div v-if="visible" class="forecast-form-container">
+    
+    <!-- 销售预测表单容器 - AvueJS版本 -->
+    <div class="forecast-form-container basic-container">
+      <!-- 表单内容区域 -->
+      <div class="forecast-form-content">
       <avue-form
         ref="forecastForm"
         v-model="formData"
@@ -48,6 +50,7 @@
           </div>
         </template>
       </avue-form>
+      </div>
     </div>
   </div>
 </template>

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

@@ -291,6 +291,14 @@ export default {
 
   methods: {
     /**
+     * 检查是否可以编辑
+     * @param {ForecastRecord} row - 预测记录行数据
+     * @returns {boolean} 是否可以编辑
+     */
+    canEdit(row) {
+        return canEdit(row.approvalStatus || APPROVAL_STATUS.PENDING)
+    },
+    /**
      * 加载客户选项
      * @this {Vue & {customerLoading: boolean, customerOptions: Array<CustomerOption>, $message: any}}
      * @returns {Promise<void>}
@@ -621,7 +629,6 @@ export default {
         return
       }
 
-      console.log('编辑预测申报', row, index)
       this.editMode = 'edit'
       this.editTitle = '编辑预测申报'
       this.currentForecastId = row.id

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

@@ -95,7 +95,7 @@
       <!-- 使用销售预测表单组件 - AvueJS版本 -->
       <forecast-form-avue
         ref="forecastForm"
-        :visible="true"
+        :visible="editVisible"
         :is-edit="editMode === 'edit'"
         :edit-data="form"
         @close="handleFormClose"
@@ -108,6 +108,7 @@
 <script>
 import forecastMixin from './forecastIndex.js'
 import { canEdit } from '@/constants/forecast.js'
+import ForecastFormAvue from '@/components/forecast-form/index.vue'
 
 /**
  * 经销商销售预测申报页面
@@ -116,11 +117,9 @@ import { canEdit } from '@/constants/forecast.js'
 export default {
   name: 'ForecastIndex',
   mixins: [forecastMixin],
-    methods: {
-        canEdit(row) {
-            return canEdit(row.approvalStatus)
-        }
-    }
+  components: {
+    ForecastFormAvue
+  },
 }
 </script>
 
@@ -151,7 +150,7 @@ export default {
     border-radius: 4px;
     padding: 8px 16px;
     font-size: 13px;
-    
+
     &:hover {
       background-color: #f5f7fa;
       border-color: #c0c4cc;
@@ -173,12 +172,12 @@ export default {
     flex-direction: column;
     align-items: flex-start;
     gap: 12px;
-    
+
     .form-title {
       margin-left: 0;
       font-size: 14px;
     }
-    
+
     .el-button {
       width: 100%;
       justify-content: center;