| | |
| | | }, |
| | | total:0, |
| | | totalTwo:0, |
| | | productListIdx:0 |
| | | productListIdx:0, |
| | | lacks:[], |
| | | }; |
| | | }, |
| | | created() { |
| | |
| | | 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 { |
| | |
| | | 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){ |
| | |
| | | ); |
| | | }; |
| | | }, |
| | | // 选择供应商 |
| | | async handleSelectClient(value, item) { |
| | | this.productTableList.supplierId=item.ID |
| | | if (value === "client") { |
| | |
| | | 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; |
| | |
| | | ) { |
| | | 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 { |
| | |
| | | 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)); |
| | |
| | | productId: '', |
| | | productIndex:this.productIndex, |
| | | id: 0, |
| | | amount: 0, |
| | | amount: "0", |
| | | desc: "", |
| | | name: "", |
| | | number: "", |