use-order-operation.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { getCurrentInstance, ref } from 'vue';
  2. import { ElMessageBox } from 'element-plus/es';
  3. import { EleMessage } from 'ele-admin-plus/es';
  4. import { useRouter } from 'vue-router';
  5. //订单日志
  6. import orderLog from '@/views/recycleOrder/components/order-log.vue';
  7. //订单详情
  8. import orderDetail from '@/views/recycleOrder/components/order-detail.vue';
  9. export function useOrderOperation(pageRef) {
  10. const { proxy } = getCurrentInstance();
  11. const router = useRouter();
  12. // 组件引用
  13. const orderLogRef = ref(null);
  14. const orderDetailRef = ref(null);
  15. function messageBoxConfirm({ message, fetch }) {
  16. ElMessageBox.confirm(message, '提示', {
  17. confirmButtonText: '确定',
  18. cancelButtonText: '关闭',
  19. type: 'warning'
  20. }).then(() => {
  21. fetch().then((res) => {
  22. if (res.data.code === 200) {
  23. EleMessage.success('操作成功');
  24. pageRef.value?.reload();
  25. } else {
  26. EleMessage.error(res.data.msg);
  27. }
  28. });
  29. });
  30. }
  31. return {
  32. // 组件引用
  33. orderLogRef,
  34. orderDetailRef,
  35. orderLog,
  36. orderDetail,
  37. //订单详情
  38. toOrderDetail(row) {
  39. orderDetailRef.value?.handleOpen(row);
  40. },
  41. //订单日志
  42. openOrderLog(row) {
  43. orderLogRef.value?.handleOpen(row);
  44. },
  45. //取消订单
  46. handleCancelOrder(row) {
  47. const rows = row == null ? [] : [row];
  48. if (!rows.length) {
  49. EleMessage.error('请至少选择一条数据');
  50. return;
  51. }
  52. messageBoxConfirm({
  53. message: '是否确认取消订单?',
  54. fetch: () => proxy.$http.post('/order/orderInfo/adminCancel', {
  55. orderIds: rows.map(item => item.orderId)
  56. })
  57. });
  58. },
  59. //申请拦截退出
  60. applyForInterception(row) {
  61. messageBoxConfirm({
  62. message: '确认拦截?',
  63. fetch: () => proxy.$http.post(`/order/orderInfo/intercept/${row.orderId}`)
  64. });
  65. },
  66. //物流签收
  67. handleLogisticsSigning(row) {
  68. messageBoxConfirm({
  69. message: '确认签收?',
  70. fetch: () => proxy.$http.post('/order/orderInfo/adminSigned', {
  71. orderIds: [row.orderId]
  72. })
  73. });
  74. },
  75. //回退状态
  76. fallbackOrder(row) {
  77. messageBoxConfirm({
  78. message: '确认回退?',
  79. fetch: () => proxy.$http.post(`/order/orderInfo/statusBack/${row.orderId}`)
  80. });
  81. },
  82. //确认收货
  83. handleConfirmReceipt(row) {
  84. const rows = row == null ? [] : [row];
  85. if (!rows.length) {
  86. EleMessage.error('请至少选择一条数据');
  87. return;
  88. }
  89. messageBoxConfirm({
  90. message: '确认收货?',
  91. fetch: () => proxy.$http.post('/order/orderInfo/adminConfirm', {
  92. orderIds: rows.map(item => item.orderId)
  93. })
  94. });
  95. },
  96. //物流揽件
  97. materialPickup(row) {
  98. messageBoxConfirm({
  99. message: '确认物流揽件?',
  100. fetch: () => proxy.$http.post('/order/orderInfo/adminPickup', {
  101. orderIds: [row.orderId]
  102. })
  103. });
  104. },
  105. //取消拦截退出
  106. cancelInterception(row) {
  107. messageBoxConfirm({
  108. message: '确认取消拦截?',
  109. fetch: () => proxy.$http.post(`/order/orderInfo/interceptBack/${row.orderId}`)
  110. });
  111. }
  112. };
  113. }