Browse Source

添加批量发货

lex-xin 4 months ago
parent
commit
60e83d0ee4

+ 2 - 2
config/index.js

@@ -3,8 +3,8 @@
 // see http://vuejs-templates.github.io/webpack for documentation.
 
 const path = require('path')
-// const proxyUrl = 'https://dev.dayaedu.com'
-const proxyUrl = 'https://test.dayaedu.com'
+const proxyUrl = 'https://dev.gym.lexiaoya.cn'
+// const proxyUrl = 'https://test.dayaedu.com'
 
 module.exports = {
   dev: {

File diff suppressed because it is too large
+ 0 - 0
dist/static/js/0.1fe88b33e49bf917e7ad.js.map


File diff suppressed because it is too large
+ 1 - 13739
package-lock.json


+ 71 - 9
src/views/oms/order/deliverOrderList.vue

@@ -6,7 +6,7 @@
       <span>发货列表</span>
     </el-card>
     <div class="table-container">
-      <el-table ref="deliverOrderTable" style="width: 100%" :data="list" border>
+      <el-table ref="deliverOrderTable" style="width: 100%" :data="list" border :row-class-name="tableRowClassName">
         <el-table-column label="订单编号" width="180" align="center">
           <template slot-scope="scope">{{ scope.row.orderSn }}</template>
         </el-table-column>
@@ -48,12 +48,38 @@
             <el-input size="small" v-model="scope.row.deliverySn"></el-input>
           </template>
         </el-table-column>
+        <el-table-column label="操作" width="180" align="center">
+          <template slot-scope="scope">
+            <p class="table-btn-group">
+            <el-button
+              size="mini"
+              type="danger"
+              @click="handleViewRemove(scope.$index, scope.row)"
+              >移除</el-button
+            >
+            </p>
+          </template>
+        </el-table-column>
       </el-table>
       <div style="margin-top: 15px; text-align: center">
         <el-button @click="cancel">取消</el-button>
-        <el-button @click="confirm" type="primary">确定</el-button>
+        <el-button @click="confirm" :disabled="list.length <= 0" type="primary">确定</el-button>
       </div>
     </div>
+
+    <el-dialog
+      title="提示"
+      :visible.sync="dialogVisible"
+      width="50%">
+      <el-table style="width: 100%" :data="listError" border>
+        <el-table-column label="编号" width="180" align="center">
+          <template slot-scope="scope">{{ scope.row.id }}</template>
+        </el-table-column>
+        <el-table-column label="内容"  align="center">
+          <template slot-scope="scope">{{ scope.row.text }}</template>
+        </el-table-column>
+      </el-table>
+    </el-dialog>
   </div>
 </template>
 <script>
@@ -69,6 +95,8 @@ export default {
   data() {
     return {
       list: [],
+      listError: [],
+      dialogVisible: false,
       companyOptions: defaultLogisticsCompanies,
     };
   },
@@ -78,8 +106,19 @@ export default {
     if (this.list instanceof Array === false) {
       this.list = [];
     }
+    console.log( this.list)
   },
   methods: {
+    tableRowClassName(row) {
+      if(row.row.isError) {
+        return 'warning-row'
+      }
+      return ''
+    },
+    handleViewRemove(index, row) {
+      console.log(this.list, index, row)
+      this.list.splice(index, 1)
+    },
     cancel() {
       this.$router.back();
     },
@@ -91,12 +130,32 @@ export default {
       })
         .then(() => {
           deliveryOrder(this.list).then((response) => {
-            this.$router.back();
-            this.$message({
-              type: "success",
-              message: "发货成功!",
-            });
-          });
+            const result = response.data
+            if(!result) {
+              this.$router.back();
+              this.$message({
+                type: "success",
+                message: "发货成功!",
+              });
+            } else {
+              this.list.forEach((item) => {
+                if(result[item.orderSn]) {
+                  item.isError = true
+                }
+              })
+
+              this.dialogVisible = true;
+              const temp = []
+              for(let i in result) {
+                temp.push({
+                  id: i,
+                  text: result[i]
+                })
+              }
+              this.listError = temp
+            }
+          })
+           
         })
         .catch(() => {
           this.$message({
@@ -108,6 +167,9 @@ export default {
   },
 };
 </script>
-<style></style>
+<style>
+.el-table .warning-row {
+    background: oldlace;
+  }</style>
 
 

+ 107 - 8
src/views/oms/order/index.vue

@@ -118,21 +118,34 @@
       </div>
     </el-card>
     <el-card class="operate-container" shadow="never">
-      <i class="el-icon-tickets"></i>
-      <span>数据列表</span>
+      <div style="display: flex; align-items: center;"><div>
+        <i class="el-icon-tickets"></i>
+        <span>数据列表</span>
+      </div>
+        <el-button
+          style="margin-left: 15px;"
+          type="primary"
+           @click="handleBatchOperate()"
+          size="small"
+        >
+          批量发货
+        </el-button></div>
     </el-card>
     <div class="table-container">
+      <!-- @selection-change="handleSelectionChange" -->
       <el-table
         ref="orderTable"
         :data="list"
         style="width: 100%"
-        @selection-change="handleSelectionChange"
+        @select="onTableSelect"
+        @select-all="onTableSelectALL"
         v-loading="listLoading"
         border
       >
         <el-table-column
           type="selection"
-          width="60"
+          width="55"
+          :selectable="checkSelectable"
           align="center"
         ></el-table-column>
         <el-table-column label="编号" width="80" align="center">
@@ -331,7 +344,7 @@ export default {
       listLoading: true,
       list: null,
       total: null,
-      operateType: null,
+      operateType: 1,  // 默认批量发货
       multipleSelection: [],
       closeOrder: {
         dialogVisible: false,
@@ -467,6 +480,9 @@ export default {
     },
   },
   methods: {
+    checkSelectable(row) {
+      return row.status === 1 ? true : false;
+    },
     handleResetSearch() {
       this.listQuery = Object.assign({}, defaultListQuery);
     },
@@ -474,8 +490,69 @@ export default {
       this.listQuery.pageNum = 1;
       this.getList();
     },
-    handleSelectionChange(val) {
-      this.multipleSelection = val;
+    // handleSelectionChange(val) {
+    //   console.log(val, 'val')
+    //   this.multipleSelection = val;
+    // },
+    onTableSelectALL(val) {
+      const list = this.list || []
+
+      if(val.length > 0) {
+        const sIds = this.multipleSelection.map((item) => {
+          return item.id
+        })
+        val.forEach((item) => {
+          if(sIds.indexOf(item.id) == -1) {
+            this.multipleSelection.push(item)
+          }
+        })
+      } else {
+        const ids = list.map((item) => {
+          return item.id
+        })
+
+        const sIds = this.multipleSelection.map((item) => {
+          return item.id
+        })
+
+        const removeIds = []
+        ids.forEach((item) => {
+          if(sIds.indexOf(item) !== -1) {
+            removeIds.push(item)
+          }
+        })
+
+        console.log(ids, sIds, 'sids', removeIds)
+        const temp = []
+        this.multipleSelection.forEach((item) => {
+          if(removeIds.indexOf(item.id) === -1) {
+            temp.push(item)
+          }
+        })
+
+        this.multipleSelection = temp
+      }
+    },
+    onTableSelect(rows, row) {
+      let idList = this.multipleSelection.map((group) => {
+        return group.id;
+      });
+
+
+      let inIdList = rows.map((group) => {
+        return group.id;
+      });
+      const isAdd = inIdList.indexOf(row.id) === -1 ? false : true
+
+      if(isAdd) {
+        if(idList.indexOf(row.id) === -1) {
+          this.multipleSelection.push(row)
+        }
+      } else {
+        if(idList.indexOf(row.id) !== -1) {
+          this.multipleSelection.splice(idList.indexOf(row.id), 1)
+        }
+      }
     },
     handleViewOrder(index, row) {
       this.$router.push({ path: "/oms/orderDetail", query: { id: row.id } });
@@ -553,6 +630,7 @@ export default {
             list.push(this.covertOrder(this.multipleSelection[i]));
           }
         }
+        // 
         if (list.length === 0) {
           this.$message({
             message: "选中订单中没有可以发货的订单",
@@ -640,9 +718,29 @@ export default {
         endTime: endTime,
         ...res
       }).then((response) => {
-        this.listLoading = false;
+        // this.listLoading = false;
         this.list = response.data.list;
         this.total = response.data.total;
+
+        this.$nextTick(() => {
+            if (this.multipleSelection) {
+              let idList = this.multipleSelection.map((item, index) => {
+                return item.id;
+              });
+              this.list.forEach((item, index) => {
+                if (idList.indexOf(item.id) != -1) {
+                  // 判断当前选中的是否为已发货数据
+                  if(item.status === 1) {
+                    this.$refs.orderTable.toggleRowSelection(item, true);
+                  } else {
+                    const mId = this.multipleSelection.findIndex((c) => c.id === item.id)
+                    this.multipleSelection.splice(mId, 1)
+                  }
+                }
+              });
+            }
+            this.listLoading = false;
+          });
       });
     },
     deleteOrder(ids) {
@@ -681,6 +779,7 @@ export default {
         address: address,
         deliveryCompany: null,
         deliverySn: null,
+        isError: false
       };
       return listItem;
     },

Some files were not shown because too many files changed in this diff