瀏覽代碼

调整货品下拉加载新增保存

howie 3 年之前
父節點
當前提交
ae9d565a19
共有 1 個文件被更改,包括 59 次插入22 次删除
  1. 59 22
      src/views/sales_policy/components/AddPolicy.vue

+ 59 - 22
src/views/sales_policy/components/AddPolicy.vue

@@ -167,6 +167,7 @@
                   size="small"
                   v-model="scope.row.materialNumber"
                   @change="handleK3List($event, scope.row)"
+                  v-el-select-loadmore="loadmore"
                   filterable
                 >
                   <el-option
@@ -449,6 +450,30 @@ import { type } from "os";
 
 export default {
   mixins: [Minxin],
+    directives: {
+    "el-select-loadmore": {
+      bind(el, binding) {
+        // 获取element-ui定义好的scroll盒⼦
+        const SELECTWRAP_DOM = el.querySelector(
+          ".el-select-dropdown .el-select-dropdown__wrap"
+        );
+        SELECTWRAP_DOM.addEventListener("scroll", function () {
+          /**
+           * scrollHeight 获取元素内容⾼度(只读)
+           * scrollTop 获取或者设置元素的偏移值,常⽤于, 计算滚动条的位置, 当⼀个元素的容器没有产⽣垂直⽅向的滚动条, 那它的scrollTop的值默认为0.
+           * clientHeight 读取元素的可见⾼度(只读)
+           * 如果元素滚动到底, 下⾯等式返回true, 没有则返回false:
+           * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
+           */
+          const condition =
+            this.scrollHeight - this.scrollTop <= this.clientHeight;
+          if (condition) {
+            binding.value();
+          }
+        });
+      },
+    },
+  },
   data() {
     return {
       fang: false,
@@ -490,6 +515,7 @@ export default {
       dictList: [],
       k3List: [],
       NoRebateWalletList: [],
+      sleectBox:{currentPage:1}
     };
   },
   computed: {
@@ -529,14 +555,22 @@ export default {
         this.$successMsg("删除成功");
       });
     },
-    getCommonApi() {
-      getK3List({
-        pageNum: 1,
+    loadmore() {
+      this.sleectBox.currentPage++;
+      this.getK3List();
+    },
+    getK3List(){
+    getK3List({
+        pageNum: this.sleectBox.currentPage,
         pageSize: 10,
         keyword: "",
       }).then((res) => {
-        this.k3List = res.data.records;
+        this.k3List = [...this.k3List,...res.data.records];
       });
+    },
+
+    getCommonApi() {
+     this.getK3List()
       // 非返利钱包
       getNoRebateWalletList({ walletName: "" }).then((res) => {
         this.NoRebateWalletList = res.data;
@@ -633,6 +667,7 @@ export default {
         });
         this.dataList = [];
         this.listTotal = 0;
+        this.sleectBox.currentPage=1
         this.handletwoList();
       } else {
         this.$alert(result.message, "导入失败", {
@@ -659,8 +694,8 @@ export default {
         .then((result) => {
           result.data.records.forEach((k) => {
             k.walletIds = [];
-            k.materialNumber = k.materialNumber;
-            k.specification = k.specification;
+            k.materialNumber = k.materialId;
+            k.specification = k.materialId;
             k.materialId = k.materialId;
             k.walletRelaList.forEach((l) => {
               l.id = l.walletId;
@@ -769,39 +804,41 @@ export default {
         walletIds: "",
         walletRelaList: [],
       });
+       this.sleectBox.currentPage =1
       this.listTotal += 1;
       // this.dataList.push(this.addList[this.addList.length-1])
     },
     handleSave() {
-      this.dataList.forEach((k) => {
-        if (!k.materialId) {
+      if (!this.dataList.length) {
+          return
+      }
+      for (let i = 0; i < this.dataList.length; i++) {
+           if (!this.dataList[i].materialId) {
           this.$errorMsg("请选择货品");
-          return;
+          return
         }
-        if (!k.saleTypeId) {
+        if (!this.dataList[i].saleTypeId) {
           this.$errorMsg("请选择销售类型");
-          return;
+          return
         }
-        if (!k.discAmount) {
+        if (!this.dataList[i].discAmount) {
           this.$errorMsg("请输入格力折扣");
-          return;
+          return
         }
-        if (!k.price) {
+        if (!this.dataList[i].price) {
           this.$errorMsg("请输入单价");
-          return;
+          return
         }
-        if (!k.walletIds.length) {
+        if (!this.dataList[i].walletIds.length) {
           this.$errorMsg("请选择钱包");
-          return;
+          return
         }
 
-        if (typeof k.walletIds == "object") {
-          console.log(44444);
-          k.walletIds = k.walletIds.join(",");
-        }
-      });
+      }
+
       savePolicy(this.dataList).then((res) => {
         this.dataList = [];
+        this.sleectBox.currentPage =1
         this.$successMsg("保存成功");
         this.handletwoList();
       });