Bladeren bron

订单导入列表优化,批量库存相关规则

lucky-lzx 2 jaren geleden
bovenliggende
commit
f83890466b
2 gewijzigde bestanden met toevoegingen van 217 en 185 verwijderingen
  1. 1 0
      src/apis/service/orderEntry/orderEnter/index.js
  2. 216 185
      src/views/orderEntry/orderEnter/index.vue

+ 1 - 0
src/apis/service/orderEntry/orderEnter/index.js

@@ -16,4 +16,5 @@ export default {
     detail: (data, params) => http(api + "orderimportinfo", data, "post", params),
     // 提交导入数据
     orderimportlist: (data, params) => http(api + "orderimportlist", data, "post", params),
+    relationstockbatch: (data, params) => http(api + "relationstockbatch", data, "post", params),
 };

+ 216 - 185
src/views/orderEntry/orderEnter/index.vue

@@ -1,104 +1,8 @@
 <template>
   <div class="box">
-    <!-- <template #table-header="{}">
-    <div class="searchBox">
-      <el-form
-        ref="form"
-        :model="ruleForm"
-        label-width="80px"
-        size="medium "
-        class="form"
-      >
-        <el-row>
-          <el-col :span="7">
-            <el-form-item label="销售方" prop="status" label-width="100px">
-              <el-select
-                v-model="ruleForm.status"
-                style="width: 100%"
-                placeholder="咨询类型"
-              >
-                <el-option
-                  v-for="item in statusArr"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value"
-                >
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="7">
-            <el-form-item
-              label="平台订单号"
-              prop="platform_code"
-              label-width="110px"
-            >
-              <el-input
-                v-model="ruleForm.platform_code"
-                placeholder="平台订单号"
-              ></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="10">
-            <el-form-item label="平台下单时间" label-width="120px">
-              <period-date-picker
-                :start="ruleForm.platform_time_start"
-                :end="ruleForm.platform_time_end"
-                :width="'130px'"
-                :size="searchSize"
-                @timeReturned="platformTime"
-              />
-            </el-form-item>
-          </el-col>
-          <el-col :span="7">
-            <el-form-item label="PO编号" prop="po_code" label-width="100px">
-              <el-input
-                v-model="ruleForm.po_code"
-                placeholder="PO编号"
-              ></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="7">
-            <el-form-item
-              label="平台商品编号"
-              prop="plat_code"
-              label-width="110px"
-            >
-              <el-input
-                v-model="ruleForm.plat_code"
-                placeholder="平台商品编号"
-              ></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="10">
-            <el-form-item label="导入时间" label-width="120px">
-              <period-date-picker
-                :start="ruleForm.addtime_start"
-                :end="ruleForm.addtime_end"
-                :width="'130px'"
-                :size="searchSize"
-                @timeReturned="addtime"
-              />
-            </el-form-item>
-          </el-col>
-        </el-row>
-      </el-form>
-      <div class="rightBtn">
-        <el-button type="primary" icon="el-icon-search" class="btn" @click="selectStock"
-          >批量关联库存</el-button
-        >
-        <el-button type="primary" icon="el-icon-search" class="btn" @click="search"
-          >搜索</el-button
-        >
-        <el-button type="primary" icon="el-icon-download" class="btn"
-          ><a href="./static/C端订单导入模板.xlsx">下载导入模板</a></el-button
-        >
-        <el-button icon="el-icon-refresh-right" class="btn" @click="reset">重置</el-button>
-      </div>
-    </div>
-    </template> -->
     <div class="tableBox">
       <ex-table
+        ref="multipleTable"
         v-loading="loading"
         v-if="
           powers && powers.length > 0 && powers.some((item) => item == '001')
@@ -112,33 +16,38 @@
         @page-size-change="handleSizeChange"
         @screen-reset="
           pageInfo.curr = 1;
-          ruleForm.page = 1;
-          initHttp();
+          parmValue.page = 1;
+          searchList();
         "
         @screen-submit="
           pageInfo.curr = 1;
-          ruleForm.page = 1;
-          initHttp();
+          parmValue.page = 1;
+          searchList();
         "
         @selection="selection_change"
         ><template #table-header="{}">
           <div class="searchBox">
             <el-form
               ref="form"
-              :model="ruleForm"
+              :model="parmValue"
               label-width="80px"
               size="medium "
               class="form"
             >
               <el-row>
-                <el-col :span="7">
+                <el-col :span="5">
                   <el-form-item
                     label="销售方"
                     prop="status"
                     label-width="100px"
                   >
                     <el-select
-                      v-model="ruleForm.status"
+                      @change="
+                        pageInfo.curr = 1;
+                        parmValue.page = 1;
+                        searchList();
+                      "
+                      v-model="parmValue.status"
                       style="width: 100%"
                       placeholder="咨询类型"
                     >
@@ -152,14 +61,19 @@
                     </el-select>
                   </el-form-item>
                 </el-col>
-                <el-col :span="7">
+                <el-col :span="5">
                   <el-form-item
                     label="平台订单号"
                     prop="platform_code"
                     label-width="110px"
                   >
                     <el-input
-                      v-model="ruleForm.platform_code"
+                      v-model="parmValue.platform_code"
+                      @blur="
+                        pageInfo.curr = 1;
+                        parmValue.page = 1;
+                        searchList();
+                      "
                       placeholder="平台订单号"
                     ></el-input>
                   </el-form-item>
@@ -167,34 +81,74 @@
                 <el-col :span="10">
                   <el-form-item label="平台下单时间" label-width="120px">
                     <period-date-picker
-                      :start="ruleForm.platform_time_start"
-                      :end="ruleForm.platform_time_end"
-                      :width="'130px'"
+                      :start="parmValue.platform_time_start"
+                      :end="parmValue.platform_time_end"
+                      :width="'135px'"
                       :size="searchSize"
                       @timeReturned="platformTime"
                     />
                   </el-form-item>
                 </el-col>
-                <el-col :span="7">
+                <el-col :span="3">
+                  <el-button
+                    size="mini"
+                    type="primary"
+                    icon="el-icon-search"
+                    class="btn"
+                    @click="selectStock"
+                    >批量关联库存</el-button
+                  >
+                </el-col>
+                <el-col :span="1">
+                  <el-button
+                    size="mini"
+                    type="primary"
+                    icon="el-icon-search"
+                    class="btn"
+                    @click="search"
+                    >搜索</el-button
+                  >
+                </el-col>
+              </el-row>
+            </el-form>
+            <el-form
+              ref="form"
+              :model="parmValue"
+              label-width="80px"
+              size="medium "
+              class="form"
+            >
+              <el-row justify="space-around">
+                <el-col :span="5">
                   <el-form-item
                     label="PO编号"
                     prop="po_code"
                     label-width="100px"
                   >
                     <el-input
-                      v-model="ruleForm.po_code"
+                      v-model="parmValue.po_code"
+                      @blur="
+                        pageInfo.curr = 1;
+                        parmValue.page = 1;
+                        searchList();
+                      "
                       placeholder="PO编号"
                     ></el-input>
                   </el-form-item>
                 </el-col>
-                <el-col :span="7">
+                <el-col :span="5">
                   <el-form-item
                     label="平台商品编号"
                     prop="plat_code"
                     label-width="110px"
                   >
                     <el-input
-                      v-model="ruleForm.plat_code"
+                      v-model="parmValue.plat_code"
+                      @blur="
+                        pageInfo.curr = 1;
+                        parmValue.page = 1;
+                        searchList();
+                      "
                       placeholder="平台商品编号"
                     ></el-input>
                   </el-form-item>
@@ -202,40 +156,36 @@
                 <el-col :span="10">
                   <el-form-item label="导入时间" label-width="120px">
                     <period-date-picker
-                      :start="ruleForm.addtime_start"
-                      :end="ruleForm.addtime_end"
-                      :width="'130px'"
+                      :start="parmValue.addtime_start"
+                      :end="parmValue.addtime_end"
+                      :width="'135px'"
                       :size="searchSize"
                       @timeReturned="addtime"
                     />
                   </el-form-item>
                 </el-col>
+                <el-col :span="3">
+                  <el-button
+                    type="primary"
+                    icon="el-icon-download"
+                    class="btn"
+                    size="mini"
+                    ><a href="./static/C端订单导入模板.xlsx"
+                      >下载导入模板</a
+                    ></el-button
+                  >
+                </el-col>
+                <el-col :span="1">
+                  <el-button
+                    icon="el-icon-refresh-right"
+                    class="btn"
+                    @click="reset"
+                    size="mini"
+                    >重置</el-button
+                  >
+                </el-col>
               </el-row>
             </el-form>
-            <div class="rightBtn">
-              <el-button
-                type="primary"
-                icon="el-icon-search"
-                class="btn"
-                @click="selectStock"
-                >批量关联库存</el-button
-              >
-              <el-button
-                type="primary"
-                icon="el-icon-search"
-                class="btn"
-                @click="search"
-                >搜索</el-button
-              >
-              <el-button type="primary" icon="el-icon-download" class="btn"
-                ><a href="./static/C端订单导入模板.xlsx"
-                  >下载导入模板</a
-                ></el-button
-              >
-              <el-button icon="el-icon-refresh-right" class="btn" @click="reset"
-                >重置</el-button
-              >
-            </div>
           </div>
         </template>
         <template #operation="{ scope }">
@@ -271,6 +221,15 @@
           </el-tooltip>
         </template>
       </ex-table>
+
+      <el-dialog
+        title="当前可用库存"
+        :visible.sync="centerDialogVisible"
+        width="30%"
+        center
+      >
+        <span>等待数据返回</span>
+      </el-dialog>
     </div>
   </div>
 </template>
@@ -285,15 +244,17 @@ export default {
   mixins: [mixinPage, resToken],
   data() {
     return {
+      centerDialogVisible: false,
       loading: true,
       //咨询类型
       statusArr: [
         { value: "1", label: "系统验证数据中" },
         { value: "2", label: "待确认订单信息" },
-        { value: "3", label: "信息已确认待关联库存" },
-        { value: "4", label: "订单录入成功" },
+        { value: "3", label: "待处理(待扣减库存)" },
+        { value: "4", label: "库存不足" },
+        { value: "5", label: "订单录入成功" },
       ],
-      ruleForm: {
+      parmValue: {
         status: "1",
         platform_code: "",
         // cs3: "",
@@ -304,8 +265,8 @@ export default {
         platform_time_start: "",
         addtime_end: "",
         addtime_start: "",
-        page: "",
-        size: "",
+        page: 1,
+        size: 15,
       },
       changeList: [],
       // 表格 - 分页
@@ -340,16 +301,31 @@ export default {
   },
   mounted() {
     this.tableData = [];
-    this.initHttp();
+    this.searchList();
   },
   methods: {
     //初始化请求
-    async initHttp() {
+    async searchList() {
+      if (
+        (this.parmValue.platform_time_start !== "" &&
+          this.parmValue.platform_time_end === "") ||
+        (this.parmValue.platform_time_start === "" &&
+          this.parmValue.platform_time_end !== "")
+      ) {
+        this.$message.warning("平台下单时间区间不完整!");
+        return;
+      }
+      if (
+        (this.parmValue.platform_time_start !== "" &&
+          this.parmValue.platform_time_end === "") ||
+        (this.parmValue.platform_time_start === "" &&
+          this.parmValue.platform_time_end !== "")
+      ) {
+        this.$message.warning("导入时间区间不完整!");
+        return;
+      }
       this.loading = true;
-      let model = this.ruleForm;
-      model.page = this.pageInfo.curr;
-      model.size = this.pageInfo.size;
-      let res = await asyncRequest.orderimportlist(model);
+      let res = await asyncRequest.orderimportlist(this.parmValue);
       if (res && res.code === 0 && res.data) {
         this.tableData = res.data.list;
         this.pageInfo.total = Number(res.data.count);
@@ -357,35 +333,80 @@ export default {
         await this.logout();
       } else {
         this.$message.warning(res.message);
+        this.pageInfo.total = 0;
       }
       this.loading = false;
     },
     //导入时间
     async addtime(e) {
-      this.ruleForm.addtime_start = e.startTime || "";
-      this.ruleForm.addtime_end = e.endTime || "";
-
-      // if (
-      //   (this.ruleForm.start !== "" && this.ruleForm.end !== "") ||
-      //   (this.ruleForm.start === "" && this.ruleForm.end === "")
-      // ) {
-      //   this.pageInfo.curr = 1;
-      //   this.ruleForm.page = 1;
-      //   // await this.initHttp();
-      // }
+      this.parmValue.addtime_start = e.startTime || "";
+      this.parmValue.addtime_end = e.endTime || "";
+      await this.searchList();
     },
     //平台时间
     async platformTime(e) {
-      this.ruleForm.platform_time_start = e.startTime || "";
-      this.ruleForm.platform_time_end = e.endTime || "";
+      this.parmValue.platform_time_start = e.startTime || "";
+      this.parmValue.platform_time_end = e.endTime || "";
+      await this.searchList();
     },
+    //批量关联库存规则判断
+    selectStockIf() {
+      if (this.changeList.length <= 0) {
+        this.$message.warning(`请勾选需要关联的商品`);
+        return;
+      }
+      let flag = false;
+      try { 
+        this.changeList.forEach((item, index) => {
+          if (item.status == "4") {
+            if (item.plat_code == this.changeList[0].plat_code) {
+            } else {
+              this.$message.warning(`选中的商品平台商品编号不一致`);
+              flag = false;
+              throw new Error("End Loop");
+            }
+          } else {
+            this.$message.warning(`当前第${index + 1}行状态不是库存不足品`);
+            flag = false;
+            throw new Error("End Loop");
+          }
+          flag = true;
+        });
+
+      } catch {}
+      console.log("判断函数",flag)
+      return flag
+    },
+
     //批量关联库存
-    selectStock() {
-      alert(111);
+    async selectStock() {
+      
+      
+
+      if (!this.selectStockIf()) {
+        return;
+      }
+     
+      let model = {
+        ids: this.changeList,
+      };
+      let res = await asyncRequest.relationstockbatch(model);
+      if (res && res.code === 0) {
+        console.log(res)
+        //成功展示弹窗
+        this.centerDialogVisible = true;
+        this.$message.success(res.message);
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(res.message);
+      }
+
+      
     },
     //重置按钮
     reset() {
-      this.ruleForm = {
+      this.parmValue = {
         status: "1",
         platform_code: "",
         // cs3: "",
@@ -396,18 +417,26 @@ export default {
         platform_time_start: "",
         addtime_end: "",
         addtime_start: "",
-        page: "",
-        size: "",
+        page: 1,
+        size: 15,
       };
-      this.initHttp();
+      this.pageInfo = {
+        size: 15,
+        curr: 1,
+        total: 0,
+      };
+      this.searchList();
     },
     //搜索按钮
     search() {
-      this.initHttp();
+      this.pageInfo.curr = 1;
+      this.parmValue.page = 1;
+      this.searchList();
     },
 
     //选中触发函数
     selection_change(e) {
+      console.log(e);
       const { list } = e;
       //选中的数组集合
       this.changeList = list.length > 0 ? JSON.parse(JSON.stringify(list)) : [];
@@ -423,40 +452,42 @@ export default {
 }
 .searchBox {
   width: 100%;
-  padding-left: 30px;
+  padding-right: 12px;
+
   box-sizing: border-box;
   // padding-top: 15px;
   // margin-top: 20px;
   display: flex;
+  flex-wrap: wrap;
 }
 .form {
-  width: 80%;
+  width: 100%;
+  padding-left: 50px;
+  box-sizing: border-box;
+}
+.el-row {
+  display: flex;
 }
 /deep/ .el-input__inner {
   height: 36px;
   line-height: 36px;
 }
-.rightBtn {
-  width: 20%;
+.btn {
+  height: 36px;
+  margin-left: 0px;
   display: flex;
-  flex-wrap: wrap;
-  justify-content: space-around;
-  .btn {
-    height: 36px;
-    margin-left: 0px;
-    display: flex;
-    align-items: center;
-  }
+  align-items: center;
 }
 .tableBox {
   width: 100%;
   margin-top: 20px;
 }
 /deep/ .el-dropdown-selfdefine {
-  margin-top: 4px;
   background: #63cbe7;
   color: #fff;
   font-weight: bold;
-  border:none;
+  border: none;
+  height: 36px;
+  bottom: 0;
 }
 </style>