Bläddra i källkod

调价单编辑

howie 3 år sedan
förälder
incheckning
e712099cc0
1 ändrade filer med 226 tillägg och 224 borttagningar
  1. 226 224
      src/views/basic_data/material/components/modify_list-apply.vue

+ 226 - 224
src/views/basic_data/material/components/modify_list-apply.vue

@@ -1,7 +1,8 @@
 <template>
   <div>
     <div>
-      <el-page-header @back="goBack" :content="!cid?'存货调价单':'编辑'"> </el-page-header>
+      <el-page-header @back="goBack" :content="!cid ? '存货调价单' : '编辑'">
+      </el-page-header>
     </div>
     <br /><br />
     <div>
@@ -113,39 +114,35 @@
             >
               <template slot-scope="scope">
                 <el-form-item>
-                      <template v-if="!cid">
-                           <el-select
-                    placeholder="请选择销售类型"
-                    @change="
-                      handleSale($event, scope.$index, scope.row.saleTypes)
-                    "
-                    v-model="scope.row.mainId"
-                  >
-                    <el-option
-                      v-for="item in scope.row.saleTypes"
-                      :label="item.saleName"
-                      :value="item.id"
-                    ></el-option>
-                  </el-select>
-                      </template>
-
-                    <template   v-else>
-                      <el-select
-
-                    @change="
-                      handleSale($event, scope.$index, scope.row.id)
-                    "
-                    placeholder="请选择销售类型"
-                    v-model="scope.row.saleTypeId"
-                  >
-                    <el-option
-                      v-for="item in typeList"
-                      :label="item.saleName"
-                      :value="item.id"
-                    ></el-option>
-                  </el-select>
+                  <template v-if="!cid">
+                    <el-select
+                      placeholder="请选择销售类型"
+                      @change="
+                        handleSale($event, scope.$index, scope.row.saleTypes)
+                      "
+                      v-model="scope.row.mainId"
+                    >
+                      <el-option
+                        v-for="item in scope.row.saleTypes"
+                        :label="item.saleName"
+                        :value="item.id"
+                      ></el-option>
+                    </el-select>
+                  </template>
 
-                    </template>
+                  <template v-else>
+                    <el-select
+                      @change="handleSale($event, scope.$index, scope.row.id)"
+                      placeholder="请选择销售类型"
+                      v-model="scope.row.saleTypeId"
+                    >
+                      <el-option
+                        v-for="item in typeList"
+                        :label="item.saleName"
+                        :value="item.id"
+                      ></el-option>
+                    </el-select>
+                  </template>
                 </el-form-item>
               </template>
             </el-table-column>
@@ -340,39 +337,38 @@
               show-overflow-tooltip
               ><template slot-scope="scope">
                 <el-form-item>
-                 <template v-if="!cid">
+                  <template v-if="!cid">
                     <el-select
-                    multiple
-                    clearable
-                    v-model="scope.row.walletsId"
-                    @change="handelWallets($event, scope.$index, scope.row)"
-                    placeholder="请选择现金钱包"
-                  >
-                    <el-option
-                      v-for="item in scope.row.walleList"
-                      :key="item.id"
-                      :value="item.id"
-                      :label="item.name"
+                      multiple
+                      clearable
+                      v-model="scope.row.walletsId"
+                      @change="handelWallets($event, scope.$index, scope.row)"
+                      placeholder="请选择现金钱包"
                     >
-                    </el-option>
-                  </el-select></template>
+                      <el-option
+                        v-for="item in scope.row.walleList"
+                        :key="item.id"
+                        :value="item.id"
+                        :label="item.name"
+                      >
+                      </el-option> </el-select
+                  ></template>
                   <template v-else>
                     <el-select
-                    multiple
-                    clearable
-                    v-model="scope.row.walletsId"
-                    @change="handelWallets($event, scope.$index, scope.row)"
-                    placeholder="请选择现金钱包"
-                  >
-                    <el-option
-                      v-for="item in scope.row.walleList"
-                      :key="item.walletId"
-                      :value="item.walletId"
-                      :label="item.walletName"
+                      multiple
+                      clearable
+                      v-model="scope.row.walletsId"
+                      @change="handelWallets($event, scope.$index, scope.row)"
+                      placeholder="请选择现金钱包"
                     >
-                    </el-option>
-                  </el-select></template>
-
+                      <el-option
+                        v-for="item in scope.row.walleList"
+                        :key="item.walletId"
+                        :value="item.walletId"
+                        :label="item.walletName"
+                      >
+                      </el-option> </el-select
+                  ></template>
                 </el-form-item>
               </template>
             </el-table-column>
@@ -694,15 +690,15 @@
     </div>
     <div class="btn-group clearfix">
       <template v-if="!cid">
-         <el-button size="small" @click="handleReseat">重置</el-button>
-      <el-button size="small" type="primary" @click="hanleSbumit"
-        >提交</el-button
-      >
+        <el-button size="small" @click="handleReseat">重置</el-button>
+        <el-button size="small" type="primary" @click="hanleSbumit"
+          >提交</el-button
+        >
       </template>
       <template v-else>
-  <el-button size="small" type="primary" @click="hanleSave"
-        >保存</el-button
-      >
+        <el-button size="small" type="primary" @click="hanleSave"
+          >保存</el-button
+        >
       </template>
       <el-button
         style="float: right"
@@ -864,14 +860,14 @@ import {
   getUserList,
   getMaterialDetail,
   getWalletList,
-  handleEdit
+  handleEdit,
 } from "@/api/basic_data/material";
 
 import MaterialListDetail from "./material_list-detail.vue";
 import Mixin from "@/mixin/index";
 export default {
   mixins: [Mixin],
-  props:['cid'],
+  props: ["cid"],
   data() {
     return {
       listLoading: false,
@@ -913,8 +909,8 @@ export default {
       selectData: [],
       walleList: [],
       fang: true,
-      wall1:[],
-      wall2:[]
+      wall1: [],
+      wall2: [],
     };
   },
   mounted() {
@@ -927,7 +923,6 @@ export default {
     };
     getTypeList(params).then((res) => {
       this.typeList = res.data.records;
-      console.log(this.typeList,'84545');
     });
     getUserList({
       pageNum: 1,
@@ -943,117 +938,85 @@ export default {
     // getWalletList({ mainId: "", walletName: "" }).then((res) => {
     //   this.walleList = res.data;
     // });
-    let rebateParams = {
-      pageNum: 1,
-      pageSize: -1,
-      mainName: "",
-      saleTypeCode: "",
-      saleTypeName: "",
-      status: "",
-    };
-    getRebate(rebateParams).then((res) => {
-      this.rebateList = res.data.records;
-    });
   },
   methods: {
     handleSale(e, index, saleTypes) {
+      // console.log(this.rebateList);
+      let linshi = [];
       let saleArr = [];
-      let rebateList =[]
-     rebateList = this.rebateList.filter((k) => {
+      let rebateList = [];
+      this.rebateList.forEach((k) => {
+        k.saleTypes.forEach((j) => {
+          if (!linshi.includes(j.saleTypeId) && j.saleTypeId == e) {
+            rebateList.push(k);
+          }
+        });
+      });
 
-        return e === k.saleTypeId;
+      saleArr = this.typeList.filter((i) => {
+        return e == i.id;
       });
-        saleArr = this.typeList.filter((i) => {
-               return e == i.id;
-          });
-          console.log(rebateList);
+      console.log(rebateList, "4444", this.rebateList, e);
       // this.items[index].mainName = saleArr[0].mainName;
-      this.items[index].saleTypeId = saleArr[0].id;
-       this.items[index].fang= false
+      this.items[index].saleTypeId = e;
+      this.items[index].fang = false;
       this.items[index].saleTypeName = saleArr[0].saleName;
       this.$set(this.items[index], "rebateList", rebateList);
       // this.fang = false;
     },
     // xua
     handelWallets(e, index, row) {
-        let id = row.cid
-
-              if (!this.wall1.includes(e[e.length-1])) {
-               this.items[index].wallets.push(  {
-                  type: "COMMONLY",
-                  id: "",
-                  updPriceBillId: id,
-                  updPriceBillItemId: id,
-                  walletId: e[e.length-1],
-                })
-            }
-
-        // if ( this.items[index].wallets.length) {
-        //   for (let j = 0; j < this.items[index].wallets.length; j++) {
-        //     if (row.walleList[i].id !== this.items[index].wallets[j].walletId) {
-
-        //       // this.$set(this.items[index], 'wallets',[
-        //       //   ...this.items[index].wallets,
-        //       //    {
-        //       //     type: "COMMONLY",
-        //       //     id: "",
-        //       //     updPriceBillId: id,
-        //       //     updPriceBillItemId: id,
-        //       //     walletId: e[i],
-        //       //   },
-        //       // ]
-
-        //       // );
-        //     }
-        //   }
-        // } else {
-
-        // }
-      // }
+      let id = row.cid;
 
+      if (!this.wall1.includes(e[e.length - 1])) {
+        this.items[index].wallets.push({
+          type: "COMMONLY",
+          id: "",
+          updPriceBillId: id,
+          updPriceBillItemId: id,
+          walletId: e[e.length - 1],
+        });
+      }
     },
     handelRebateList(e, index, row) {
-
-        // let id = row.cid
-
-        //       if (!this.wall1.includes(e[e.length-1])) {
-        //        this.items[index].wallets.push(  {
-        //           type: "COMMONLY",
-        //           id: "",
-        //           updPriceBillId: id,
-        //           updPriceBillItemId: id,
-        //           walletId: e[e.length-1],
-        //         })
-        //     }
-
-      for (let i = 0; i < e.length; i++) {
-        if (this.items[index].wallets.length) {
-          for (let j = 0; j < this.items[index].wallets.length; j++) {
-            if (e[i] !== this.items[index].wallets[j].walletId) {
-              this.$set(this.items[index], "wallets", [
-                ...this.items[index].wallets,
-                {
-                  type: "REBATE",
-                  id: "",
-                  updPriceBillId: row.cid,
-                  updPriceBillItemId: row.cid,
-                  walletId: e[i],
-                },
-              ]);
-            }
-          }
-        } else {
-          this.$set(this.items[index], "rebateWallets", [
-            {
-              type: "REBATE",
-              id: "",
-              updPriceBillId: row.id,
-              updPriceBillItemId: row.id,
-              walletId: e[0],
-            },
-          ]);
-        }
+      let id = row.cid;
+      if (!this.wall2.includes(e[e.length - 1])) {
+        this.items[index].rebateWallets.push({
+          type: "REBATE",
+          id: "",
+          updPriceBillId: id,
+          updPriceBillItemId: id,
+          walletId: e[e.length - 1],
+        });
       }
+      // for (let i = 0; i < e.length; i++) {
+      //   if (this.items[index].wallets.length) {
+      //     for (let j = 0; j < this.items[index].wallets.length; j++) {
+      //       if (e[i] !== this.items[index].wallets[j].walletId) {
+      //         this.$set(this.items[index], "wallets", [
+      //           ...this.items[index].wallets,
+      //           {
+      //             type: "REBATE",
+      //             id: "",
+      //             updPriceBillId: row.cid,
+      //             updPriceBillItemId: row.cid,
+      //             walletId: e[i],
+      //           },
+      //         ]);
+      //       }
+      //     }
+      //   } else {
+      //     this.$set(this.items[index], "rebateWallets", [
+      //       {
+      //         type: "REBATE",
+      //         id: "",
+      //         updPriceBillId: row.id,
+      //         updPriceBillItemId: row.id,
+      //         walletId: e[0],
+      //       },
+      //     ]);
+      //   }
+      // }
     },
     handleUser(e) {
       const adminCompany = this.userList.filter((k) => {
@@ -1065,7 +1028,7 @@ export default {
       this.serviceId = adminCompany.roleId;
     },
     goBack() {
-      this.$parent.cid=''
+      this.$parent.cid = "";
       this.$parent.show = 1;
       // 更新父组件数据
       this.$parent.getList();
@@ -1145,7 +1108,7 @@ export default {
               },
             ],
             cid: this.selectData[i].id,
-            fang:true
+            fang: true,
           });
         }
 
@@ -1180,15 +1143,32 @@ export default {
         this.$errorMsg("请选择产品");
       }
     },
-    getList() {
+    async getList() {
+      let rebateParams = {
+        pageNum: 1,
+        pageSize: -1,
+        mainName: "",
+        saleTypeCode: "",
+        saleTypeName: "",
+        status: "",
+      };
+      const ress = await getRebate(rebateParams);
+      this.rebateList = ress.data.records;
+      const wall = await getWalletList({ mainId: "", walletName: "" });
+      for (let u = 0; u < wall.data.length; u++) {
+        wall.data[u].walletId = wall.data[u].id;
+        wall.data[u].walletName = wall.data[u].name;
+      }
+      this.walleList = wall.data;
 
+      let linshi = [];
       if (this.$parent.show == 5) {
-            let  rebateList= []
-        getProductRriceDetail({ id:this.cid }).then((res) => {
+        let rebateList = [];
+        getProductRriceDetail({ id: this.cid }).then((res) => {
           //  this.editData = res.data;
 
           for (let i = 0; i < res.data.items.length; i++) {
-            res.data.items[i].isPublishArr= [
+            res.data.items[i].isPublishArr = [
               {
                 value: "是",
                 bool: true,
@@ -1197,8 +1177,8 @@ export default {
                 value: "否",
                 bool: false,
               },
-            ]
-           res.data.items[i].isPromoteArr=[
+            ];
+            res.data.items[i].isPromoteArr = [
               {
                 value: "是",
                 bool: true,
@@ -1207,46 +1187,66 @@ export default {
                 value: "否",
                 bool: false,
               },
-            ]
-            let walletIds=[]
-             res.data.items[i].walletsId = ''
-             for (let p = 0; p < res.data.items[i].wallets2.length; p++) {
-               walletIds.push(res.data.items[i].wallets2[p].walletIds)
-             }
-             this.$set(res.data.items[i],'walletsId',walletIds)
+            ];
+
+            let walletIds = [];
+            let walletRebateIds = [];
+            res.data.items[i].walletsId = [];
+            res.data.items[i].walletRebateId = [];
+            for (let p = 0; p < res.data.items[i].wallets2.length; p++) {
+              if (res.data.items[i].wallets2[p].type == "COMMONLY") {
+                walletIds.push(res.data.items[i].wallets2[p].walletId);
+                this.$set(res.data.items[i], "walletsId", walletIds);
+              } else {
+                walletRebateIds.push(res.data.items[i].wallets2[p].walletId);
+                this.$set(res.data.items[i], "walletRebateId", walletRebateIds);
+              }
+            }
 
-             rebateList = this.rebateList.filter((k) => {
-              return res.data.items[i].saleTypeId === k.saleTypeId;
+            this.rebateList.forEach((k) => {
+              k.saleTypes.forEach((j) => {
+                console.log(
+                  j.saleTypeId == res.data.items[i].saleTypeId,
+                  "545454"
+                );
+                if (
+                  !linshi.includes(j.saleTypeId) &&
+                  j.saleTypeId == res.data.items[i].saleTypeId
+                ) {
+                  rebateList.push(k);
+                }
+              });
             });
-            this.items =res.data.items
-            this.base = res.data
-            res.data.items[i].wallets =[]
-            res.data.items[i].walleList = res.data.items[i].wallets2
-            res.data.items[i].rebateWallets=[]
-            res.data.items[i].rebateList=rebateList
-            res.data.items[i].fang = false;
+            console.log(rebateList, "444878787");
+            res.data.items[i].rebateWallets = [];
+            res.data.items[i].wallets = res.data.items[i].wallets2;
+            res.data.items[i].walleList = this.walleList;
+            res.data.items[i].rebateList = rebateList;
+            //  rebateList = this.rebateList.filter((k) => {
+            //   return res.data.items[i].saleTypeId === k.saleTypeId;
+            // });
+            this.items = res.data.items;
+            this.base = res.data;
 
+            res.data.items[i].fang = false;
           }
 
-
           this.listLoading = false;
-
-      });
-      }else{
-          this.listLoading = true;
+        });
+      } else {
+        this.listLoading = true;
         let params = {
-        pageNum: this.currentPage,
-        pageSize: 10 || this.pageSize,
-        keyword: this.screenForm.keyword,
-        bindMain: true,
-      };
-      getMaterialList(params).then((res) => {
-        this.dataList = res.data.records;
-        this.listTotal = res.data.total;
-        this.listLoading = false;
-      });
+          pageNum: this.currentPage,
+          pageSize: 10 || this.pageSize,
+          keyword: this.screenForm.keyword,
+          bindMain: true,
+        };
+        getMaterialList(params).then((res) => {
+          this.dataList = res.data.records;
+          this.listTotal = res.data.total;
+          this.listLoading = false;
+        });
       }
-
     },
     /**
      * 根据条件禁用行复选框
@@ -1267,13 +1267,16 @@ export default {
       // 如果没有返回值则默认返回false(全部无法选中)
     },
     hanleSbumit() {
-
       for (let i = 0; i < this.items.length; i++) {
-        this.items[i].wallets = [
-          ...this.items[i].rebateWallets,
-          ...this.items[i].wallets,
-        ];
-        console.log(this.items,45454);
+        if (!cid) {
+          this.items[i].wallets = [
+            ...this.items[i].rebateWallets,
+            ...this.items[i].wallets,
+          ];
+        } else {
+        }
+
+        console.log(this.items, 45454);
         if (!this.items[i].mainId) {
           this.$errorMsg("请选择销售类型");
           return;
@@ -1289,21 +1292,20 @@ export default {
         serviceName: this.nickName,
       };
       getProductRriceAdd(params).then((res) => {
-          this.$successMsg("成功");
-          this.$parent.show = 1;
-          this.$parent.getList();
+        this.$successMsg("成功");
+        this.$parent.show = 1;
+        this.$parent.getList();
       });
     },
-    hanleSave(){
+    hanleSave() {
       handleEdit({
-        ...this.base
-      }).then(res=>{
+        ...this.base,
+      }).then((res) => {
         this.$successMsg("成功");
-        this.$parent.cid=''
-         this.$parent.show = 1;
-          this.$parent.getList();
-      })
-
+        this.$parent.cid = "";
+        this.$parent.show = 1;
+        this.$parent.getList();
+      });
     },
     handleReseat() {
       this.base = {