Просмотр исходного кода

需退回订单的取消订单和订单日志功能

Alex 10 месяцев назад
Родитель
Сommit
79c3c67b8e

+ 32 - 10
src/views/recycleOrder/components/order-log.vue

@@ -3,14 +3,14 @@
   <ele-modal :width="1080" v-model="visible" title="订单日志">
     <ele-data-table :data="orderLog" :columns="columns">
       <template #status="{ row }">
-          <el-tag type="danger" v-if="row.cancelStatus == 1">已取消</el-tag>
-          <dict-data
-            v-else
-            code="order_status"
-            type="text"
-            :model-value="row.status"
-          />
-        </template>
+        <el-tag type="danger" v-if="row.cancelStatus == 1">已取消</el-tag>
+        <dict-data
+          v-else
+          code="order_status"
+          type="text"
+          :model-value="row.status"
+        />
+      </template>
     </ele-data-table>
 
     <template #footer>
@@ -23,6 +23,14 @@
   import { ref, reactive, nextTick, getCurrentInstance } from 'vue';
 
   import { pagePosts } from '@/api/system/post';
+
+  const props = defineProps({
+    type: {
+      type: String,
+      default: 'order'
+    }
+  });
+
   let { proxy } = getCurrentInstance();
   /** 弹窗是否打开 */
   const visible = ref(false);
@@ -36,7 +44,9 @@
   const handleOpen = (orderId) => {
     if (orderId) {
       visible.value = true;
-      getOrderLog(orderId);
+      props.type == 'refund'
+        ? getRefundOrderLog(orderId)
+        : getOrderLog(orderId);
     }
   };
 
@@ -53,10 +63,22 @@
         }
       });
   }
+  //退回订单日志
+  function getRefundOrderLog(orderId) {
+    proxy.$http
+      .get(`/order/orderInfo/refund/getOrderLogList?refundOrderId=${orderId}`)
+      .then((res) => {
+        if (res.data.code === 200) {
+          orderLog.value = res.data.data;
+        } else {
+          EleMessage.error(res.data.msg || '获取订单日志失败');
+        }
+      });
+  }
 
   const columns = reactive([
     { label: '订单编号', prop: 'orderId', width: 150 },
-    { label: '状态', prop: 'status', width: 160, slot: 'status', },
+    { label: '状态', prop: 'status', width: 160 },
     { label: '操作者', prop: 'createName', width: 100 },
     { label: '日志描述', prop: 'content' },
     { label: '操作时间', prop: 'createTime', width: 180 }

+ 16 - 3
src/views/recycleOrder/needReturned/index.vue

@@ -93,6 +93,7 @@
             <el-button
               type="danger"
               link
+              v-if="row.status == '0'"
               v-permission="'recycleOrder:needReturned:cancel'"
               @click="cancelOrder(row)"
             >
@@ -113,7 +114,7 @@
 
     <slot></slot>
     <orderRemarks ref="remarksRef" />
-    <orderLog ref="logRef" />
+    <orderLog ref="logRef" type="refund" />
     <manualDelivery ref="deliveryRef" @success="reload()" />
     <orderRefundDetail ref="orderDetailRef" />
   </ele-page>
@@ -121,6 +122,7 @@
 
 <script setup>
   import { ref, getCurrentInstance } from 'vue';
+  import { EleMessage } from 'ele-admin-plus/es';
   import { ElMessageBox } from 'element-plus/es';
   import { Flag, ChatDotSquare } from '@element-plus/icons-vue';
   import returnSearch from './return-search.vue';
@@ -238,13 +240,24 @@
       cancelButtonText: '关闭',
       type: 'warning'
     }).then(() => {
-      console.log(row, 'row');
+      proxy.$http.post(url, { orderIds: [row.refundOrderId] }).then((res) => {
+        if (res.data.code === 200) {
+          EleMessage.success('操作成功');
+          reload();
+        } else {
+          EleMessage.error(res.data.msg || '操作失败');
+        }
+      });
     });
   }
 
   //取消订单
   function cancelOrder(row) {
-    messageBoxConfirm({ message: '确认取消?', url: '', row });
+    messageBoxConfirm({
+      message: '确认取消?',
+      url: '/order/orderInfo/refund/cancel',
+      row
+    });
   }
   //人工发货
   const deliveryRef = ref(null);