Browse Source

货品信息

howie 3 năm trước cách đây
mục cha
commit
e3f40e70c7
1 tập tin đã thay đổi với 94 bổ sung90 xóa
  1. 94 90
      src/views/sales_policy/components/AddPolicy.vue

+ 94 - 90
src/views/sales_policy/components/AddPolicy.vue

@@ -166,13 +166,15 @@
                 <el-select
                   size="small"
                   v-model="scope.row.materialNumber"
-                  @change="handleK3List($event,scope.row)"
+                  @change="handleK3List($event, scope.row)"
                   filterable
                 >
-                  <el-option v-for="item in k3List"
+                  <el-option
+                    v-for="item in k3List"
                     :key="item.id"
                     :label="item.number"
-                    :value="item.id">
+                    :value="item.id"
+                  >
                   </el-option>
                 </el-select>
               </template>
@@ -192,13 +194,15 @@
                 <el-select
                   size="small"
                   v-model="scope.row.specification"
-                  @change="handleK3List($event,scope.row)"
+                  @change="handleK3List($event, scope.row)"
                   filterable
                 >
-                  <el-option v-for="item in k3List"
+                  <el-option
+                    v-for="item in k3List"
                     :key="item.id"
                     :label="item.specification"
-                    :value="item.id">
+                    :value="item.id"
+                  >
                   </el-option>
                 </el-select>
               </template>
@@ -245,7 +249,7 @@
             <el-table-column prop="price" label="单价" align="center">
               <template slot-scope="scope">
                 <el-input
-                type="number"
+                  type="number"
                   v-model.number="scope.row.price"
                   placeholder="请输入单价"
                   size="small"
@@ -260,10 +264,12 @@
                   v-model="scope.row.walletIds"
                   filterable
                 >
-                  <el-option v-for="item in NoRebateWalletList"
+                  <el-option
+                    v-for="item in NoRebateWalletList"
                     :key="item.id"
                     :label="item.name"
-                    :value="item.id">
+                    :value="item.id"
+                  >
                   </el-option>
                 </el-select>
                 <!-- <el-tag
@@ -313,11 +319,12 @@
             "
           >
             <div>
-                <el-button type="primary" size="small" @click="handleNewInfo"
-              >添加</el-button
-            > <el-button type="primary" size="small" @click="handleSave"
-              >保存</el-button
-            >
+              <el-button type="primary" size="small" @click="handleNewInfo"
+                >添加</el-button
+              >
+              <el-button type="primary" size="small" @click="handleSave"
+                >保存</el-button
+              >
             </div>
             <el-pagination
               @size-change="handleSizeChange"
@@ -450,7 +457,7 @@ export default {
       isCondition: 0,
       searchForm: {
         code: "",
-        endTime: "2100-01-01 00:00:00",
+        endTime: "",
         imgSrc: "",
         remark: "",
         startTime: "",
@@ -460,7 +467,7 @@ export default {
         type: "",
       },
       dataList: [],
-      addList:[],
+      addList: [],
       listLoading: false,
       dialogVisible: false,
       importFileList: [],
@@ -481,8 +488,8 @@ export default {
       ],
       conditionList: [],
       dictList: [],
-      k3List:[],
-      NoRebateWalletList:[],
+      k3List: [],
+      NoRebateWalletList: [],
     };
   },
   computed: {
@@ -524,18 +531,18 @@ export default {
     },
     getCommonApi() {
       getK3List({
-         pageNum: 1,
-        pageSize:10,
-        keyword: '',
+        pageNum: 1,
+        pageSize: 10,
+        keyword: "",
       }).then((res) => {
-        this.k3List = res.data.records
+        this.k3List = res.data.records;
       });
       // 非返利钱包
       getNoRebateWalletList({ walletName: "" }).then((res) => {
         this.NoRebateWalletList = res.data;
-        console.log(this.NoRebateWalletList,'kkkk');
+        console.log(this.NoRebateWalletList, "kkkk");
       });
-       const params = {
+      const params = {
         pageNum: 1,
         pageSize: -1,
         saleCode: "",
@@ -576,7 +583,7 @@ export default {
       })[0];
 
       this.$set(row, "saleTypeCode", item.saleCode);
-      this.$set(row,'saleTypeName',item.saleName)
+      this.$set(row, "saleTypeName", item.saleName);
       // this.$set(row,'saleTypeId',item.id)
     },
     //修改条件名称
@@ -624,8 +631,8 @@ export default {
         this.$alert(result.message, "导入成功", {
           confirmButtonText: "确定",
         });
-         this.dataList = [];
-          this.listTotal = 0;
+        this.dataList = [];
+        this.listTotal = 0;
         this.handletwoList();
       } else {
         this.$alert(result.message, "导入失败", {
@@ -650,19 +657,19 @@ export default {
 
       getMaterialList(paramss)
         .then((result) => {
-          result.data.records.forEach(k=>{
-            k.walletIds = []
-            k.materialNumber = k.materialNumber
-            k.specification =  k.specification
-            k.materialId = k.materialId
-              k.walletRelaList.forEach(l=>{
-              l.id = l.walletId
-              l.name = l.walletName
-              k.walletIds = [...k.walletIds,l.walletId]
-            })
-          })
+          result.data.records.forEach((k) => {
+            k.walletIds = [];
+            k.materialNumber = k.materialNumber;
+            k.specification = k.specification;
+            k.materialId = k.materialId;
+            k.walletRelaList.forEach((l) => {
+              l.id = l.walletId;
+              l.name = l.walletName;
+              k.walletIds = [...k.walletIds, l.walletId];
+            });
+          });
 
-          this.dataList = [...this.dataList,...result.data.records];
+          this.dataList = [...this.dataList, ...result.data.records];
           this.listTotal = result.data.total;
         })
         .catch((err) => {
@@ -671,7 +678,6 @@ export default {
     },
     // 提交审核
     handleAddPolicy(policyCustomers) {
-
       if (!this.searchForm.title) {
         this.$errorMsg("请输入说明");
         return;
@@ -718,6 +724,7 @@ export default {
           title: "",
           type: "",
           ...this.searchForm,
+          endTime: this.searchForm.endTime || "2100-01-01 00:00:00",
           imgSrc: this.fileList.length ? this.fileList[0].url : "",
         };
         console.log(this.fileList);
@@ -737,17 +744,17 @@ export default {
       if (id) {
         const params = { policyMaterialId: id };
         deleteMaterialPolicy(params).then((res) => {
-          this.$successMsg("删除成功");
-          this.handletwoList();
+          this.dataList.splice(index, 1);
         });
-      } else {
-        this.dataList.splice(index, 1);
       }
+      this.dataList.splice(index, 1);
+      this.listTotal -= 1;
+      this.$successMsg("删除成功");
     },
     handleNewInfo() {
-        // 物料列表
+      // 物料列表
       this.dataList.push({
-        id:'',
+        id: "",
         discAmount: "",
         materialId: "",
         materialName: "",
@@ -762,55 +769,52 @@ export default {
         walletIds: "",
         walletRelaList: [],
       });
-      this.listTotal +=1
+      this.listTotal += 1;
       // this.dataList.push(this.addList[this.addList.length-1])
     },
-    handleSave(){
-      this.dataList.forEach(k=>{
-          if (!k.materialId) {
-            this.$errorMsg('请选择货品')
-            return
-          }
-            if (!k.saleTypeId) {
-            this.$errorMsg('请选择销售类型')
-            return
-          }
-           if (!k.discAmount) {
-            this.$errorMsg('请输入格力折扣')
-            return
-          }
-           if (!k.price) {
-            this.$errorMsg('请输入单价')
-            return
-          }
-          if (!k.walletIds.length) {
-              this.$errorMsg('请选择钱包')
-            return
-          }
-
-          if ( typeof k.walletIds == 'object') {
-            console.log(44444);
-               k.walletIds = k.walletIds.join(',')
-          }
+    handleSave() {
+      this.dataList.forEach((k) => {
+        if (!k.materialId) {
+          this.$errorMsg("请选择货品");
+          return;
+        }
+        if (!k.saleTypeId) {
+          this.$errorMsg("请选择销售类型");
+          return;
+        }
+        if (!k.discAmount) {
+          this.$errorMsg("请输入格力折扣");
+          return;
+        }
+        if (!k.price) {
+          this.$errorMsg("请输入单价");
+          return;
+        }
+        if (!k.walletIds.length) {
+          this.$errorMsg("请选择钱包");
+          return;
+        }
 
-      })
-      savePolicy(
-        this.dataList
-      ).then(res=>{
-        this.dataList = []
-        this.$successMsg('保存成功')
-        this.handletwoList()
-      })
+        if (typeof k.walletIds == "object") {
+          console.log(44444);
+          k.walletIds = k.walletIds.join(",");
+        }
+      });
+      savePolicy(this.dataList).then((res) => {
+        this.dataList = [];
+        this.$successMsg("保存成功");
+        this.handletwoList();
+      });
     },
-    handleK3List(e,row){
-     const item = this.k3List.filter(k=>{
-        return k.id ==e
-      })[0]
+    handleK3List(e, row) {
+      const item = this.k3List.filter((k) => {
+        return k.id == e;
+      })[0];
       // this.$set(row,'materialNumber',item.number)
-      this.$set(row,'materialName',item.name)
-      this.$set(row,'specification',item.specification)
-      this.$set(row,'materialId',item.id)
-    }
+      this.$set(row, "materialName", item.name);
+      this.$set(row, "specification", item.specification);
+      this.$set(row, "materialId", item.id);
+    },
   },
   components: {
     Transfer,