zuozhengqing
2023-11-30 8335a9090a51564c954c2995a3ec6a761c48b1d3
add:新增编辑时若当前供应商没有该产品,添加弹窗提醒
2个文件已修改
124 ■■■■ 已修改文件
src/views/purchaseManage/purchase/components/AddPurchase.vue 121 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/index.vue 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -376,7 +376,8 @@
      },
      total:0,
      totalTwo:0,
      productListIdx:0
      productListIdx:0,
      lacks:[],
    };
  },
  created() {
@@ -518,22 +519,91 @@
            this.$message.error("产品名称不能为空");
          } else {
            const params = this.saveParams();
            //新建
            if (this.editConfig.title === "创建") {
              addPurchase(params).then((res) => {
                this.editConfig.visible = false;
                if (res.code === 200) {
                  this.$message.success("添加成功");
                  this.$parent.getData();
              this.tableData.forEach((item)=>{
                if(this.productTableList.tableProductList.map(obj => obj.number).includes(item.number)) {
                    console.log(`${item.name} 在数组中存在`);
                } else {
                  this.lacks.push(item.name)
                }
              });
              })
              if(this.lacks.length>0){
                this.$confirm(`当前供应商不能提供您选择的产品:${this.lacks},    是否继续创建采购单?`, '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  console.log("确定创建")
                  //创建采购单
                  addPurchase(params).then((res) => {
                    this.editConfig.visible = false;
                    if (res.code === 200) {
                      this.$message.success("创建成功");
                      this.$parent.getData();
                    }
                  });
                }).catch(() => {
                  console.log("取消创建")
                });
              }else{
                addPurchase(params).then((res) => {
                  this.editConfig.visible = false;
                  if (res.code === 200) {
                    this.$message.success("创建成功");
                    this.$parent.getData();
                  }
                });
              }
            } else {
              updatePurchase(params).then((res) => {
                this.editConfig.visible = false;
                if (res.code === 200) {
                  this.$message.success("编辑成功");
                  this.$parent.getData();
              // 编辑
              getProductList({
                supplierId:this.editConfig.infomation.supplierId,
                page:1,
                pageSize:100
              }).then((res)=>{
                if(res.code===200){
                  // 编辑前先看看当前供应商对应的产品列表
                  this.productTableList.tableProductList = res.data.list
                  //当前产品是否在当前供应商下存在
                  this.tableData.forEach((item)=>{
                    if(this.productTableList.tableProductList.map(obj => obj.number).includes(item.number)) {
                      console.log(`${item.name} 在数组中存在`);
                    } else {
                      this.lacks.push(item.name)
                    }
                  })
                  // 不存在的产品信息
                  if(this.lacks.length>0){
                    this.$confirm(`当前供应商不能提供您选择的产品:${this.lacks},    是否继续更新采购单?`, '提示', {
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'warning'
                    }).then(() => {
                      console.log("确定更新")
                      //更新采购单
                      updatePurchase(params).then((res) => {
                        this.editConfig.visible = false;
                        if (res.code === 200) {
                          this.$message.success("更新成功");
                          this.$parent.getData();
                        }
                      });
                    }).catch(() => {
                      console.log("取消更新")
                    });
                  }else {
                    updatePurchase(params).then((res) => {
                      this.editConfig.visible = false;
                      if (res.code === 200) {
                        this.$message.success("更新成功");
                        this.$parent.getData();
                      }
                    });
                  }
                }
              });
              })
            }
          }
        } else {
@@ -569,6 +639,8 @@
          priceAdjustment:data.priceAdjustment?Number(data.priceAdjustment):0,
          realTotalPrice:this.total?Number(this.total):0,
          totalPrice:this.totalTwo?Number(this.totalTwo):0,
          status:data.status,
          quantity:data.quantity, // 采购数量
        }
      };
      if(data.ID){
@@ -598,6 +670,7 @@
        );
      };
    },
    // 选择供应商
    async handleSelectClient(value, item) {
      this.productTableList.supplierId=item.ID
      if (value === "client") {
@@ -622,11 +695,10 @@
      this.$set(this.editConfig.infomation,'supplierName',row.name)
      this.editConfig.infomation.contact = row.contact;
      this.editConfig.infomation.phone = row.phone;
      this.supplierId = row.ID;
      this.editConfig.infomation.supplierId = row.ID;
    },
    // 清除已选择用户
    clearupClient(value) {
      this.emptyProductClick()
      if (value == "client") {
        this.$set(this.editConfig.infomation, "supplierName", "");
        this.supplierId = null;
@@ -640,15 +712,21 @@
      ) {
        this.tableData = [
          {
            purchaseId:0,
            productId: this.productId,
            productIndex:this.productIndex,
            id: 0,
            amount: 0,
            desc: "",
            name: "",
            number: "",
            price: 0,
            total: 0,
            remark:'',
            unit:'',
            purchasePrice:'',
            deliveryTime:"",
            shippingDuration:"",
            specifications:"",
            modelNumber:"",
          },
        ];
      } else {
@@ -693,13 +771,16 @@
    inputContent(val, prop, row) {
      // this.productId = row.productId;
      this.productIndex=row.productIndex;
      console.log(row,val,prop,"产品ID",this.tableData)
      let num=0
      this.tableData.map((item) => {
        num+=item.amount
        if (item.productIndex === row.productIndex) {
          item[prop] = val;
        }
      });
      if(prop==="amount"){
        this.editConfig.infomation.quantity=num
      }
    },
    getSummaries(total){
      this.totalTwo= JSON.parse(JSON.stringify(total));
@@ -749,7 +830,7 @@
          productId: '',
          productIndex:this.productIndex,
          id: 0,
          amount: 0,
          amount: "0",
          desc: "",
          name: "",
          number: "",
src/views/purchaseManage/purchase/index.vue
@@ -261,6 +261,9 @@
          this.tableLoading = false
          this.editConfig.visible = true
          this.editConfig.title = "编辑"
          res.data.productList.map((item,index)=>{
            item.productIndex=index
          })
          this.editConfig.infomation = {
            productList: res.data.productList,
            supplierName: res.data.purchase.supplier.name,