wangxy před 1 týdnem
rodič
revize
5d38576703

+ 15 - 0
src/api/store/externalOrder.js

@@ -52,3 +52,18 @@ export function exportExternalOrder(query) {
     params: query
   })
 }
+
+export function getExternalOrderExpress(orderId) {
+  return request({
+    url: '/store/externalOrder/getExpress/' + orderId,
+    method: 'get'
+  })
+}
+
+export function syncExternalOrderExpress(orderId) {
+  return request({
+    url: '/store/externalOrder/syncExpress/' + orderId,
+    method: 'get'
+  })
+}
+

+ 98 - 3
src/views/store/externalOrder/index.vue

@@ -115,7 +115,20 @@
           <dict-tag :options="statusOptions" :value="scope.row.status" />
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="240px">
+      <el-table-column label="物流单号" align="center" prop="deliverySn" width="150" show-overflow-tooltip />
+      <el-table-column label="物流状态" align="center" prop="deliveryStatus">
+        <template slot-scope="scope">
+          <dict-tag v-if="scope.row.deliveryStatus != null" :options="deliveryStatusOptions" :value="scope.row.deliveryStatus" />
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="物流跟踪状态" align="center" prop="deliveryType" width="120">
+        <template slot-scope="scope">
+          <dict-tag v-if="scope.row.deliveryType != null" :options="deliveryTypeOptions" :value="scope.row.deliveryType" />
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="280px">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -135,8 +148,15 @@
             type="text"
             v-hasPermi="['store:externalOrder:approveOrder']"
             @click="handleApprove(scope.row)"
-            v-if="scope.row.status == 3 && !scope.row.isApplyAudit"
+            v-if="scope.row.status == 3 && !scope.row.isApplyAudit && isAbnormalDelivery(scope.row.deliveryType)"
           >申请审核</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            v-hasPermi="['store:externalOrder:express']"
+            @click="handleExpress(scope.row)"
+            v-if="scope.row.deliverySn"
+          >查看物流</el-button>
           <el-button
             size="mini"
             type="text"
@@ -293,6 +313,15 @@
         <el-descriptions-item label="订单状态">
           <dict-tag :options="statusOptions" :value="detailData.status" />
         </el-descriptions-item>
+        <el-descriptions-item label="物流单号">{{ detailData.deliverySn || '-' }}</el-descriptions-item>
+        <el-descriptions-item label="物流状态">
+          <dict-tag v-if="detailData.deliveryStatus != null" :options="deliveryStatusOptions" :value="detailData.deliveryStatus" />
+          <span v-else>-</span>
+        </el-descriptions-item>
+        <el-descriptions-item label="物流跟踪状态">
+          <dict-tag v-if="detailData.deliveryType != null" :options="deliveryTypeOptions" :value="detailData.deliveryType" />
+          <span v-else>-</span>
+        </el-descriptions-item>
         <el-descriptions-item label="创建时间">{{ detailData.externalCreateTime }}</el-descriptions-item>
       </el-descriptions>
       <el-divider content-position="left">商品信息</el-divider>
@@ -308,6 +337,23 @@
       </el-table>
     </el-dialog>
 
+    <el-dialog :title="expressDialog.title" :visible.sync="expressDialog.open" width="700px" append-to-body>
+      <div style="margin-bottom: 10px;">
+        <el-button
+          size="mini"
+          type="primary"
+          v-hasPermi="['store:externalOrder:syncExpress']"
+          @click="handleSyncExpress(expressDialog.row)"
+          v-if="expressDialog.row && expressDialog.row.deliverySn"
+        >同步快递鸟物流状态</el-button>
+      </div>
+      <el-table style="width: 100%" :data="traces" border>
+        <el-table-column label="操作时间" width="160" align="center" prop="AcceptTime" />
+        <el-table-column label="位置" align="center" prop="Location" />
+        <el-table-column label="描述" align="center" prop="AcceptStation" />
+      </el-table>
+    </el-dialog>
+
     <el-dialog :title="user.title" v-if="user.open" :visible.sync="user.open" width="500px" append-to-body>
       <add-external-user @addUser="addUser" />
     </el-dialog>
@@ -391,7 +437,7 @@
 </template>
 
 <script>
-import { listExternalOrder, createExternalOrder, getExternalOrder, auditExternalOrder, cancelExternalOrder, approveExternalOrder, exportExternalOrder } from "@/api/store/externalOrder";
+import { listExternalOrder, createExternalOrder, getExternalOrder, auditExternalOrder, cancelExternalOrder, approveExternalOrder, exportExternalOrder, getExternalOrderExpress, syncExternalOrderExpress } from "@/api/store/externalOrder";
 import { getCompanyList } from "@/api/company/company";
 import { listUserAddress } from "@/api/store/userAddress";
 import { listStoreProduct, listStore } from "@/api/store/storeProduct";
@@ -416,6 +462,13 @@ export default {
       title: "",
       detailOpen: false,
       detailData: {},
+      expressDialog: {
+        title: "物流信息",
+        open: false,
+        row: null
+      },
+      express: null,
+      traces: [],
       phone: null,
       userloading: false,
       users: [],
@@ -496,6 +549,8 @@ export default {
       headers: { Authorization: "Bearer " + this.$store.getters.token },
       payTypeOptions: [],
       statusOptions: [],
+      deliveryStatusOptions: [],
+      deliveryTypeOptions: [],
       userStatusOptions: []
     };
   },
@@ -508,6 +563,12 @@ export default {
     this.getDicts("sys_externalOrder_status").then(response => {
       this.statusOptions = response.data;
     });
+    this.getDicts("sys_store_order_delivery_status").then(response => {
+      this.deliveryStatusOptions = response.data;
+    });
+    this.getDicts("sys_delivery_type").then(response => {
+      this.deliveryTypeOptions = response.data;
+    });
     this.getDicts("sys_company_status").then(response => {
       this.userStatusOptions = response.data;
     });
@@ -755,6 +816,35 @@ export default {
         this.detailOpen = true;
       });
     },
+    handleExpress(row) {
+      this.expressDialog.row = row;
+      this.expressDialog.open = true;
+      this.express = null;
+      this.traces = [];
+      getExternalOrderExpress(row.orderId).then(response => {
+        this.express = response.data;
+        if (this.express != null && this.express.Traces != null) {
+          this.traces = this.express.Traces;
+        }
+      });
+    },
+    handleSyncExpress(row) {
+      if (!row || !row.orderId) {
+        this.msgError("请选择订单");
+        return;
+      }
+      this.$confirm("确定同步物流状态吗?", "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        return syncExternalOrderExpress(row.orderId);
+      }).then(() => {
+        this.msgSuccess("操作成功");
+        this.expressDialog.open = false;
+        this.getList();
+      }).catch(function() {});
+    },
     handleAudit(row) {
       this.$confirm("确认审核该订单?审核后订单将变为待发货状态", "提示", {
         confirmButtonText: "确定",
@@ -824,6 +914,11 @@ export default {
         }
       });
     },
+    isAbnormalDelivery(deliveryType) {
+      if (deliveryType == null) return false;
+      const type = Number(deliveryType);
+      return type === 4 || (type >= 401 && type <= 423);
+    },
     handleExport() {
       const queryParams = this.queryParams;
       this.$confirm("是否确认导出外部订单数据项?", "警告", {