Ver código fonte

feat:update: id=>orderId

叶静 1 mês atrás
pai
commit
85cd20a74b
1 arquivos alterados com 176 adições e 220 exclusões
  1. 176 220
      src/app/shop/admin/order/order/dispatch.vue

+ 176 - 220
src/app/shop/admin/order/order/dispatch.vue

@@ -9,12 +9,8 @@
         <template #title>温馨提示:如果该商品处在售后状态,请先处理完售后再进行发货。</template>
       </el-alert>
       <div v-if="state.dispatch_type == 'express'">
-        <el-table
-          ref="expressTableRef"
-          class="sa-table"
-          :data="state.nosendItem"
-          @selection-change="handleSelectionChange"
-        >
+        <el-table ref="expressTableRef" class="sa-table" :data="state.nosendItem"
+          @selection-change="handleSelectionChange">
           <template #empty>
             <sa-empty />
           </template>
@@ -84,40 +80,16 @@
                 </el-radio-group>
               </el-form-item>
             </el-form>
-            <el-form
-              v-if="state.method == 'input'"
-              ref="expressRef"
-              :inline="true"
-              :model="express"
-              :rules="state.method == 'input' ? state.expressRules : {}"
-            >
+            <el-form v-if="state.method == 'input'" ref="expressRef" :inline="true" :model="express"
+              :rules="state.method == 'input' ? state.expressRules : {}">
               <el-form-item label="快递公司" prop="code">
-                <el-select
-                  v-model="express.code"
-                  placeholder="请选择快递公司"
-                  @change="onChangeExpressCode"
-                  filterable
-                  remote
-                  reserve-keyword
-                  :remote-method="remoteMethod"
-                  :loading="deliverCompany.loading"
-                  autocomplete="none"
-                >
-                  <el-option
-                    v-for="dc in deliverCompany.data"
-                    :key="dc"
-                    :label="dc.name"
-                    :value="dc.code"
-                    :ref="`dc-${dc.code}`"
-                    :data-name="dc.name"
-                    >{{ dc.name }}&nbsp;({{ dc.code }})</el-option
-                  >
+                <el-select v-model="express.code" placeholder="请选择快递公司" @change="onChangeExpressCode" filterable remote
+                  reserve-keyword :remote-method="remoteMethod" :loading="deliverCompany.loading" autocomplete="none">
+                  <el-option v-for="dc in deliverCompany.data" :key="dc" :label="dc.name" :value="dc.code"
+                    :ref="`dc-${dc.code}`" :data-name="dc.name">{{ dc.name }}&nbsp;({{ dc.code }})</el-option>
                   <div class="sa-p-l-15 sa-p-r-27">
-                    <sa-pagination
-                      layout="total, prev, pager, next"
-                      :pageData="deliverCompany.pageData"
-                      @updateFn="getDeliverCompany"
-                    />
+                    <sa-pagination layout="total, prev, pager, next" :pageData="deliverCompany.pageData"
+                      @updateFn="getDeliverCompany" />
                   </div>
                 </el-select>
               </el-form-item>
@@ -129,12 +101,8 @@
         </div>
       </div>
       <div v-if="state.dispatch_type == 'custom'">
-        <el-table
-          ref="customTableRef"
-          class="sa-table"
-          :data="state.customItem"
-          @selection-change="handleSelectionChange"
-        >
+        <el-table ref="customTableRef" class="sa-table" :data="state.customItem"
+          @selection-change="handleSelectionChange">
           <el-table-column type="selection" width="48"></el-table-column>
           <el-table-column label="商品信息" min-width="360">
             <template #default="scope">
@@ -171,12 +139,7 @@
                 <div class="key">内容</div>
                 <div class="oper">操作</div>
               </div>
-              <draggable
-                v-model="state.custom_content"
-                :animation="300"
-                handle=".sortable-drag"
-                item-key="element"
-              >
+              <draggable v-model="state.custom_content" :animation="300" handle=".sortable-drag" item-key="element">
                 <template #item="{ element, index }">
                   <div class="item">
                     <el-form-item class="key">
@@ -186,13 +149,8 @@
                       <el-input placeholder="请输入" v-model="element.content"> </el-input>
                     </el-form-item>
                     <el-form-item class="oper">
-                      <el-popconfirm
-                        width="fit-content"
-                        confirm-button-text="确认"
-                        cancel-button-text="取消"
-                        title="确认删除这条记录?"
-                        @confirm="onDeleteContent(index)"
-                      >
+                      <el-popconfirm width="fit-content" confirm-button-text="确认" cancel-button-text="取消"
+                        title="确认删除这条记录?" @confirm="onDeleteContent(index)">
                         <template #reference>
                           <el-button type="danger" link @click.stop>删除 </el-button>
                         </template>
@@ -202,8 +160,7 @@
                   </div>
                 </template>
               </draggable>
-              <el-button class="add-params" type="primary" plain icon="Plus" @click="onAddContent"
-                >添加
+              <el-button class="add-params" type="primary" plain icon="Plus" @click="onAddContent">添加
               </el-button>
             </div>
           </el-form-item>
@@ -211,197 +168,196 @@
       </div>
     </el-main>
     <el-footer class="sa-footer--submit">
-      <el-button
-        type="primary"
-        :loading="state.sendLoading"
-        :disabled="state.expressItem.length == 0 || state.sendLoading"
-        @click="onSend"
-        >立即发货</el-button
-      >
+      <el-button type="primary" :loading="state.sendLoading"
+        :disabled="state.expressItem.length == 0 || state.sendLoading" @click="onSend">立即发货</el-button>
     </el-footer>
   </el-container>
 </template>
 <script setup>
-  import { computed, getCurrentInstance, onMounted, reactive, ref, watch, nextTick } from 'vue';
-  import { api } from '../order.service';
-  import useExpress from '@/app/shop/admin/data/express/express.js';
-  import draggable from 'vuedraggable';
+import { computed, getCurrentInstance, onMounted, reactive, ref, watch, nextTick } from 'vue';
+import { api } from '../order.service';
+import useExpress from '@/app/shop/admin/data/express/express.js';
+import draggable from 'vuedraggable';
 
-  const emit = defineEmits(['modalCallBack']);
-  const props = defineProps(['modal']);
+const emit = defineEmits(['modalCallBack']);
+const props = defineProps(['modal']);
 
-  const { proxy } = getCurrentInstance();
+const { proxy } = getCurrentInstance();
 
-  // 表格引用
-  const expressTableRef = ref();
-  const customTableRef = ref();
+// 表格引用
+const expressTableRef = ref();
+const customTableRef = ref();
 
-  const state = reactive({
-    nosendItem: computed(() => {
-      console.log('发货弹窗接收到的数据:', props.modal);
-      console.log('订单详情数据:', props.modal?.params?.data);
-      console.log('商品信息数据:', props.modal?.params?.data?.orderInfoVO);
-      console.log('地址信息数据:', props.modal?.params?.data?.orderAddressVO);
-      if (!props.modal?.params?.data?.orderInfoVO) return [];
-      return props.modal.params?.data.orderInfoVO;
-    }),
-    method: 'input',
-    expressItem: [],
-    expressRules: {
-      code: [{ required: true, message: '请选择', trigger: 'none' }],
-      no: [{ required: true, message: '请输入快递单号', trigger: 'none' }],
-    },
-    sendLoading: false,
+const state = reactive({
+  nosendItem: computed(() => {
+    console.log('发货弹窗接收到的数据:', props.modal);
+    console.log('订单详情数据:', props.modal?.params?.data);
+    console.log('商品信息数据:', props.modal?.params?.data?.orderInfoVO);
+    console.log('地址信息数据:', props.modal?.params?.data?.orderAddressVO);
+    if (!props.modal?.params?.data?.orderInfoVO) return [];
+    return props.modal.params?.data.orderInfoVO;
+  }),
+  method: 'input',
+  expressItem: [],
+  expressRules: {
+    code: [{ required: true, message: '请选择', trigger: 'none' }],
+    no: [{ required: true, message: '请输入快递单号', trigger: 'none' }],
+  },
+  sendLoading: false,
 
-    dispatch_type: 'express',
-    customItem: computed(() => {
-      // 手动发货暂不支持,返回空数组
-      return [];
-    }),
-    custom_type: 'text',
-    custom_content: [],
-  });
+  dispatch_type: 'express',
+  customItem: computed(() => {
+    // 手动发货暂不支持,返回空数组
+    return [];
+  }),
+  custom_type: 'text',
+  custom_content: [],
+});
 
-  function handleSelectionChange(val) {
-    state.expressItem = val;
-  }
+function handleSelectionChange(val) {
+  state.expressItem = val;
+}
 
-  const { express, deliverCompany, getDeliverCompany, onChangeExpressCode, remoteMethod } =
-    useExpress();
-  // TODO
-  async function onSend() {
-    let order_item_ids = [];
-    state.expressItem.forEach((item) => {
-      order_item_ids.push(item.id);
-    });
-    if (state.dispatch_type == 'express') {
-      if (state.method == 'input') {
-        proxy.$refs.expressRef &&
-          proxy.$refs.expressRef.validate(async (valid) => {
-            if (valid) {
-              const { name, no } = express;
-              state.sendLoading = true;
-              const { code } = await api.order.dispatch([
-                {
-                  orderId: props.modal.params?.data?.id,
-                  deliveryName: name,
-                  deliveryNo: no,
-                },
-              ]);
-              state.sendLoading = false;
-              if (code == '200') {
-                emit('modalCallBack', { event: 'confirm' });
-              }
+const { express, deliverCompany, getDeliverCompany, onChangeExpressCode, remoteMethod } =
+  useExpress();
+// TODO
+async function onSend() {
+  let order_item_ids = [];
+  state.expressItem.forEach((item) => {
+    order_item_ids.push(item.id);
+  });
+  if (state.dispatch_type == 'express') {
+    if (state.method == 'input') {
+      proxy.$refs.expressRef &&
+        proxy.$refs.expressRef.validate(async (valid) => {
+          if (valid) {
+            const { name, no } = express;
+            state.sendLoading = true;
+            const { code } = await api.order.dispatch([
+              {
+                orderId: props.modal.params?.data?.orderId,
+                deliveryName: name,
+                deliveryNo: no,
+              },
+            ]);
+            state.sendLoading = false;
+            if (code == '200') {
+              emit('modalCallBack', { event: 'confirm' });
             }
-          });
-      } else if (state.method == 'api') {
-        state.sendLoading = true;
-        const { code } = await api.order.dispatch({
-          order_id: props.modal.data.id,
-          order_item_ids,
-          action: 'confirm',
-          method: 'api',
+          }
         });
-        state.sendLoading = false;
-        if (code == '200') {
-          emit('modalCallBack', { event: 'confirm' });
-        }
-      }
-    } else if (state.dispatch_type == 'custom') {
-      const { code } = await api.order.customDispatch({
+    } else if (state.method == 'api') {
+      state.sendLoading = true;
+      const { code } = await api.order.dispatch({
         order_id: props.modal.data.id,
         order_item_ids,
-        custom_type: state.custom_type,
-        custom_content: state.custom_content,
+        action: 'confirm',
+        method: 'api',
       });
       state.sendLoading = false;
       if (code == '200') {
         emit('modalCallBack', { event: 'confirm' });
       }
     }
-  }
-
-  function onChangeAutosendType(type) {
-    state.custom_content = type == 'text' ? '' : [];
-  }
-  function onAddContent() {
-    if (!state.custom_content) {
-      state.custom_content = [];
-    }
-    state.custom_content.push({
-      title: '',
-      content: '',
+  } else if (state.dispatch_type == 'custom') {
+    const { code } = await api.order.customDispatch({
+      order_id: props.modal.data.id,
+      order_item_ids,
+      custom_type: state.custom_type,
+      custom_content: state.custom_content,
     });
+    state.sendLoading = false;
+    if (code == '200') {
+      emit('modalCallBack', { event: 'confirm' });
+    }
   }
-  function onDeleteContent(index) {
-    state.custom_content.splice(index, 1);
+}
+
+function onChangeAutosendType(type) {
+  state.custom_content = type == 'text' ? '' : [];
+}
+function onAddContent() {
+  if (!state.custom_content) {
+    state.custom_content = [];
   }
+  state.custom_content.push({
+    title: '',
+    content: '',
+  });
+}
+function onDeleteContent(index) {
+  state.custom_content.splice(index, 1);
+}
 
-  // 监听发货类型变化,自动选中所有商品
-  watch(
-    () => state.dispatch_type,
-    (newType) => {
-      nextTick(() => {
-        if (newType === 'express' && expressTableRef.value && state.nosendItem.length) {
-          state.nosendItem.forEach((row) => {
-            expressTableRef.value.toggleRowSelection(row, true);
-          });
-        } else if (newType === 'custom' && customTableRef.value && state.customItem.length) {
-          state.customItem.forEach((row) => {
-            customTableRef.value.toggleRowSelection(row, true);
-          });
-        }
-      });
-    },
-  );
+// 监听发货类型变化,自动选中所有商品
+watch(
+  () => state.dispatch_type,
+  (newType) => {
+    nextTick(() => {
+      if (newType === 'express' && expressTableRef.value && state.nosendItem.length) {
+        state.nosendItem.forEach((row) => {
+          expressTableRef.value.toggleRowSelection(row, true);
+        });
+      } else if (newType === 'custom' && customTableRef.value && state.customItem.length) {
+        state.customItem.forEach((row) => {
+          customTableRef.value.toggleRowSelection(row, true);
+        });
+      }
+    });
+  },
+);
 
-  onMounted(() => {
-    if (state.nosendItem.length) {
-      state.dispatch_type = 'express';
-      // 默认选中所有快递发货商品
-      nextTick(() => {
-        if (expressTableRef.value) {
-          state.nosendItem.forEach((row) => {
-            expressTableRef.value.toggleRowSelection(row, true);
-          });
-        }
-      });
-    } else if (state.customItem.length) {
-      state.dispatch_type = 'custom';
-      // 默认选中所有手动发货商品
-      nextTick(() => {
-        if (customTableRef.value) {
-          state.customItem.forEach((row) => {
-            customTableRef.value.toggleRowSelection(row, true);
-          });
-        }
-      });
-    }
-  });
+onMounted(() => {
+  if (state.nosendItem.length) {
+    state.dispatch_type = 'express';
+    // 默认选中所有快递发货商品
+    nextTick(() => {
+      if (expressTableRef.value) {
+        state.nosendItem.forEach((row) => {
+          expressTableRef.value.toggleRowSelection(row, true);
+        });
+      }
+    });
+  } else if (state.customItem.length) {
+    state.dispatch_type = 'custom';
+    // 默认选中所有手动发货商品
+    nextTick(() => {
+      if (customTableRef.value) {
+        state.customItem.forEach((row) => {
+          customTableRef.value.toggleRowSelection(row, true);
+        });
+      }
+    });
+  }
+});
 </script>
 <style lang="scss" scoped>
-  .send {
-    .address,
-    .express {
-      line-height: 16px;
+.send {
+
+  .address,
+  .express {
+    line-height: 16px;
+    font-size: 12px;
+    font-weight: 400;
+
+    .title {
+      height: 32px;
+      line-height: 32px;
+      padding: 0 16px;
+      background: var(--sa-table-header-bg);
+      border-radius: 4px;
       font-size: 12px;
       font-weight: 400;
-      .title {
-        height: 32px;
-        line-height: 32px;
-        padding: 0 16px;
-        background: var(--sa-table-header-bg);
-        border-radius: 4px;
-        font-size: 12px;
-        font-weight: 400;
-        color: var(--sa-subtitle);
-      }
-      .label {
-        color: var(--sa-subfont);
-      }
-      .content {
-        color: var(--sa-subtitle);
-      }
+      color: var(--sa-subtitle);
+    }
+
+    .label {
+      color: var(--sa-subfont);
+    }
+
+    .content {
+      color: var(--sa-subtitle);
     }
   }
+}
 </style>