cgp 1 неделя назад
Родитель
Сommit
7bb1d39a51
1 измененных файлов с 93 добавлено и 17 удалено
  1. 93 17
      src/views/qw/companyCustomer/index.vue

+ 93 - 17
src/views/qw/companyCustomer/index.vue

@@ -259,7 +259,6 @@
 
     <!-- 制单弹窗 -->
     <el-dialog :title="createOrder.title" :visible.sync="createOrder.open" width="1000px" append-to-body :close-on-click-modal="false" @close="createOrderCancel">
-      <!-- 内容不变,省略... -->
       <el-form ref="createOrderForm" :model="createOrderForm" :rules="createOrderRules" label-width="120px">
         <el-form-item label="收货人姓名" prop="realName" required>
           <el-input v-model="createOrderForm.realName" placeholder="请输入收货人姓名" />
@@ -366,7 +365,12 @@
         </el-form-item>
         <el-form-item label="抵扣金额" prop="receiveMoneyId">
           <el-select v-model="createOrderForm.receiveMoneyId" placeholder="请选择收款记录" @change="handleReceiptChange" clearable>
-            <el-option v-for="item in receiptList" :key="item.id" :label="`${parseTime(item.saleTime)} - ${item.totalFee}元`" :value="item.id" />
+            <el-option
+              v-for="item in receiptList"
+              :key="item.id"
+              :label="getReceiptLabel(item)"
+              :value="item.id"
+            />
           </el-select>
         </el-form-item>
         <el-form-item label="抵扣金额" prop="reduceAmount">
@@ -407,8 +411,8 @@
             <span>{{ orderStatusFormat(scope.row.status) }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="实付金额" align="center" prop="payMoney" width="120">
-          <template slot-scope="scope">¥{{ scope.row.payMoney }}</template>
+        <el-table-column label="实付金额" align="center" prop="payPrice" width="120">
+          <template slot-scope="scope">¥{{ scope.row.payPrice }}</template>
         </el-table-column>
         <el-table-column label="下单时间" align="center" prop="createTime" width="160">
           <template slot-scope="scope">{{ parseTime(scope.row.createTime) }}</template>
@@ -418,8 +422,7 @@
         <el-table-column label="收货地址" align="center" prop="userAddress" show-overflow-tooltip />
         <el-table-column label="支付方式" align="center" prop="payType" width="100">
           <template slot-scope="scope">
-            <span v-if="scope.row.payType">{{ scope.row.payType }}</span>
-            <span v-else>-</span>
+            <span>{{ payTypeFormat(scope.row.payType) }}</span>
           </template>
         </el-table-column>
         <el-table-column label="操作" align="center" width="120" fixed="right">
@@ -433,7 +436,7 @@
     </el-dialog>
 
     <!-- 二维码展示弹窗 -->
-    <el-dialog title="订单二维码" :visible.sync="qrCodeDialogVisible" width="450px" append-to-body :close-on-click-modal="false">
+    <el-dialog title="订单二维码" :visible.sync="qrCodeDialogVisible" width="450px" append-to-body :close-on-click-modal="false" @close="onQrCodeDialogClose">
       <div style="text-align: center; padding-bottom: 15px;">
         <img v-if="qrCodeImage" :src="qrCodeImage" style="width: 100%; max-width: 300px;" />
         <div v-else style="text-align: center; padding: 30px;">生成二维码中...</div>
@@ -592,12 +595,13 @@ export default {
       },
       // 订单状态映射(根据后端 FsStoreOrderVO.status 字段)
       orderStatusMap: {
-        '-2': '退货成功',
-        '-1': '申请退款',
-        '0': '待发货',
-        '1': '待收货',
-        '2': '已收货',
-        '3': '已完成'
+        '-3':'已取消',
+        '-2': '已退款',
+        '-1': '退款中',
+        '0': '待支付',
+        '1': '待发货',
+        '2': '待收货',
+        '3': '交易完成'
       },
       // 二维码弹窗
       qrCodeDialogVisible: false,
@@ -613,6 +617,26 @@ export default {
     });
   },
   methods: {
+    // 支付方式格式化
+    payTypeFormat(payType) {
+      if (!payType) return '-';
+      const option = this.payTypeOptions.find(item => String(item.dictValue) === String(payType));
+      return option ? option.dictLabel : payType;
+    },
+    // 格式化收款记录显示文本
+    getReceiptLabel(item) {
+      if (!item.saleTime) return `无时间 - ${item.totalFee}元`;
+      const date = new Date(item.saleTime);
+      if (isNaN(date.getTime())) return `无效时间 - ${item.totalFee}元`;
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0');
+      const day = String(date.getDate()).padStart(2, '0');
+      const hours = String(date.getHours()).padStart(2, '0');
+      const minutes = String(date.getMinutes()).padStart(2, '0');
+      const seconds = String(date.getSeconds()).padStart(2, '0');
+      const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+      return `${formattedTime} - ${item.totalFee}元`;
+    },
     // 订单状态格式化方法
     orderStatusFormat(status) {
       const key = String(status);
@@ -641,6 +665,7 @@ export default {
         this.createOrderForm.reduceAmount = 0;
       }
     },
+
     createOrderSubmitForm() {
       this.$refs["createOrderForm"].validate(valid => {
         // 手动校验地址联动
@@ -664,10 +689,24 @@ export default {
           };
           createUserOrder(params).then(response => {
             if (response.code === 200) {
-              this.msgSuccess("创建成功");
-              this.createOrder.open = false;
-              this.createOrderReset();
-              this.getList();
+              // 获取返回的订单数据
+              const order = response.order;
+              const payLimitTime = response.payLimitTime;
+
+              // 判断是否需要显示支付二维码(全款支付且订单未支付)
+              // 注意:payType === '1' 表示全款支付
+              if (this.createOrderForm.payType === '1' && order && order.paid === 0) {
+                // 关闭制单弹窗
+                this.createOrder.open = false;
+                this.createOrderReset();
+                // 显示二维码弹窗
+                this.showOrderQrCode(order.id);
+              } else {
+                this.msgSuccess("创建成功");
+                this.createOrder.open = false;
+                this.createOrderReset();
+                this.getList();
+              }
             }
           }).catch(err => {
             this.$message.error(err.message || '创建订单失败');
@@ -675,6 +714,43 @@ export default {
         }
       });
     },
+
+    //显示订单二维码弹窗
+    showOrderQrCode(orderId) {
+      this.currentOrderId = orderId;
+      this.qrCodeImage = null;
+      this.qrCodeDialogVisible = true;
+
+      const loading = this.$loading({
+        lock: true,
+        text: '正在生成二维码...',
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      });
+
+      getQRCode(orderId).then(response => {
+        if (response.url) {
+          this.qrCodeImage = response.url;
+        } else {
+          this.$message.error('获取二维码失败:返回数据无效');
+          this.qrCodeDialogVisible = false;
+          // 二维码生成失败时刷新列表
+          this.getList();
+        }
+      }).catch(error => {
+        this.$message.error(error.msg || error.message || '生成二维码失败');
+        this.qrCodeDialogVisible = false;
+        // 二维码生成失败时刷新列表
+        this.getList();
+      }).finally(() => {
+        loading.close();
+      });
+    },
+
+    onQrCodeDialogClose() {
+      // 关闭二维码弹窗时刷新客户列表
+      this.getList();
+    },
     createOrderCancel() {
       this.createOrder.open = false;
       this.createOrderReset();