Pārlūkot izejas kodu

优化搭销会员历史订单、处理记录页面

cgp 2 nedēļas atpakaļ
vecāks
revīzija
5469237f68
1 mainītis faili ar 69 papildinājumiem un 90 dzēšanām
  1. 69 90
      src/views/task/unprocessed.vue

+ 69 - 90
src/views/task/unprocessed.vue

@@ -22,15 +22,15 @@
             size="mini"
             type="text"
             icon="el-icon-finished"
-            @click="handleViewHistoryOrders(scope.row)"
-          >历史订单
+            @click="getHandleRecordsList(scope.row)"
+          >处理记录
           </el-button>
           <el-button
             size="mini"
             type="text"
             icon="el-icon-more"
-            @click="getHandleRecordsList(scope.row)"
-          >处理记录
+            @click="handleViewHistoryOrders(scope.row)"
+          >历史订单
           </el-button>
         </template>
       </el-table-column>
@@ -167,7 +167,7 @@
             </el-select>
           </el-form-item>
           <el-form-item>
-            <el-button type="primary" @click="handleRecordsQuery">搜索</el-button>
+            <el-button type="primary" @click="loadHandleRecords">搜索</el-button>
             <el-button @click="resetRecordsQuery">重置</el-button>
           </el-form-item>
         </el-form>
@@ -231,7 +231,7 @@
             />
           </el-form-item>
           <el-form-item>
-            <el-button type="primary" @click="handleHistoryQuery">搜索</el-button>
+            <el-button type="primary" @click="loadHistoryOrders">搜索</el-button>
             <el-button @click="resetHistoryQuery">重置</el-button>
           </el-form-item>
         </el-form>
@@ -338,7 +338,7 @@ export default {
       recordsQueryParams: {
         pageNum: 1,
         pageSize: 10,
-        doctorMemberSalesId: null,
+        doctorMemberSalesId: null, // 用于查询,由打开弹窗时注入
         handleType: null
       },
 
@@ -350,7 +350,7 @@ export default {
       historyQueryParams: {
         pageNum: 1,
         pageSize: 10,
-        userId: null,
+        userId: null, // 用于查询,由打开弹窗时注入
         orderCode: null
       },
 
@@ -550,152 +550,131 @@ export default {
     },
 
     /**
-     * 查询搭销会员任务处理记录
+     * 查询搭销会员任务处理记录 - 打开弹窗入口点
      */
     getHandleRecordsList(row) {
-      // 重置查询参数
+      // 初始化查询参数,注入必要的ID
       this.recordsQueryParams = {
         pageNum: 1,
         pageSize: 10,
-        doctorMemberSalesId: this.globalVarDoctorMemberSalesId,
+        doctorMemberSalesId: this.globalVarDoctorMemberSalesId, // 注入关键ID
         handleType: null
       };
-
       // 打开弹窗
       this.recordsDialogVisible = true;
-      this.recordsLoading = true;
-
-      // 调用内部加载方法
-      this.loadHandleRecords();
-    },
-
-    /**
-     * 处理记录搜索
-     */
-    handleRecordsQuery() {
-      this.recordsQueryParams.pageNum = 1;
-      this.getHandleRecordsList();
-    },
-
-    /**
-     * 重置处理记录查询条件
-     */
-    resetRecordsQuery() {
-      this.recordsQueryParams = {
-        pageNum: 1,
-        pageSize: 10,
-        doctorMemberSalesId: this.recordsQueryParams.doctorMemberSalesId,
-        handleType: null
-      };
-      // 调用内部加载方法
+      // 加载数据
       this.loadHandleRecords();
     },
 
     /**
-     * 处理记录分页
-     */
-    handleRecordsPagination(pagination) {
-      this.recordsQueryParams.pageNum = pagination.page;
-      this.recordsQueryParams.pageSize = pagination.limit;
-      this.loadHandleRecords();
-    },
-
-    /**
-     * 加载处理记录数据(内部方法)
+     * 加载处理记录数据(核心查询方法)
      */
     loadHandleRecords() {
       this.recordsLoading = true;
-
-      // 调用API获取处理记录
       selectFsSopDoctorTaskVoListHandleRecords(this.recordsQueryParams)
         .then(response => {
-          // 根据接口返回的数据结构调整
           this.recordsList = response.rows || [];
           this.recordsTotal = response.total || 0;
-          this.recordsLoading = false;
         })
         .catch(error => {
           console.error('获取处理记录失败:', error);
           this.$message.error('获取处理记录失败');
-          this.recordsLoading = false;
           this.recordsList = [];
           this.recordsTotal = 0;
+        })
+        .finally(() => {
+          this.recordsLoading = false;
         });
     },
 
     /**
-     * 查看历史订单
+     * 处理记录分页
      */
-    handleViewHistoryOrders(row) {
-      // 重置查询参数,并设置userId
-      this.historyQueryParams = {
-        pageNum: 1,
-        pageSize: 10,
-        userId: this.fsUserId, // 使用页面初始化时获取的fsUserId
-        orderCode: null // 清空搜索条件
-      };
-
-      // 打开弹窗
-      this.historyDialogVisible = true;
-      this.historyLoading = true;
-
-      // 调用内部加载方法
-      this.loadHistoryOrders();
+    handleRecordsPagination() {
+      // pageNum 和 pageSize 已通过 sync 绑定自动更新到 recordsQueryParams
+      // 直接调用查询方法即可
+      this.loadHandleRecords();
     },
 
     /**
-     * 历史订单搜索
+     * 重置处理记录查询条件
      */
-    handleHistoryQuery() {
-      this.historyQueryParams.pageNum = 1;
-      this.loadHistoryOrders();
+    resetRecordsQuery() {
+      const doctorMemberSalesId = this.recordsQueryParams.doctorMemberSalesId; // 保留关键ID
+      this.recordsQueryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        doctorMemberSalesId: doctorMemberSalesId, // 重置其他条件,但保留ID
+        handleType: null
+      };
+      // 重置后重新查询
+      this.loadHandleRecords();
     },
 
+
     /**
-     * 重置历史订单查询条件
+     * 查看历史订单 - 打开弹窗入口点
      */
-    resetHistoryQuery() {
+    handleViewHistoryOrders(row) {
+      // 初始化查询参数,注入必要的ID
       this.historyQueryParams = {
         pageNum: 1,
         pageSize: 10,
-        userId: this.historyQueryParams.userId, // 保持userId不变
+        userId: this.fsUserId, // 注入关键ID
         orderCode: null
       };
+      // 打开弹窗
+      this.historyDialogVisible = true;
+      // 加载数据
       this.loadHistoryOrders();
     },
 
     /**
-     * 历史订单分页
-     */
-    handleHistoryPagination(pagination) {
-      this.historyQueryParams.pageNum = pagination.page;
-      this.historyQueryParams.pageSize = pagination.limit;
-      this.loadHistoryOrders();
-    },
-
-    /**
-     * 加载历史订单数据(内部方法)
+     * 加载历史订单数据(核心查询方法)
      */
     loadHistoryOrders() {
       this.historyLoading = true;
-
-      // 调用API获取历史订单
       userHistoryOrderList(this.historyQueryParams)
         .then(response => {
-          // 根据接口返回的数据结构调整
           this.historyList = response.rows || [];
           this.historyTotal = response.total || 0;
-          this.historyLoading = false;
         })
         .catch(error => {
           console.error('获取历史订单失败:', error);
           this.$message.error('获取历史订单失败');
-          this.historyLoading = false;
           this.historyList = [];
           this.historyTotal = 0;
+        })
+        .finally(() => {
+          this.historyLoading = false;
         });
     },
 
+    /**
+     * 历史订单分页
+     */
+    handleHistoryPagination() {
+      // pageNum 和 pageSize 已通过 sync 绑定自动更新到 historyQueryParams
+      // 直接调用查询方法即可
+      this.loadHistoryOrders();
+    },
+
+    /**
+     * 重置历史订单查询条件
+     */
+    resetHistoryQuery() {
+      const userId = this.historyQueryParams.userId; // 保留关键ID
+      this.historyQueryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        userId: userId, // 重置其他条件,但保留ID
+        orderCode: null
+      };
+      // 重置后重新查询
+      this.loadHistoryOrders();
+    },
+
+
     /** 提交处理 */
     submitForm() {
       this.$refs.form.validate(valid => {