| | |
| | | <div class="basic-info-title">产品信息</div> |
| | | <div class="basic-info-view"> |
| | | <CommonFormTableView |
| | | ref="productTable" |
| | | :product-table-list="productTableList" |
| | | :detail-enter="detailEnter" |
| | | @inputContent="inputContent" |
| | |
| | | computed: {}, |
| | | data() { |
| | | return { |
| | | dialogWidth: "80%", |
| | | dialogWidth: "60%", |
| | | editConfig: this.addCommonConfig, |
| | | productTableList: {}, |
| | | tableData: [], |
| | | productId: 1, |
| | | isNoProduct: true, |
| | | supplierId: this.addCommonConfig.infomation.supplierId, |
| | | detailEnter: true |
| | | detailEnter: true, |
| | | deliveryTime: this.addCommonConfig.infomation.deliveryTime, // 供货时长 |
| | | shippingDuration: this.addCommonConfig.infomation.shippingDuration, // 物流时长 |
| | | purchasePrice: this.addCommonConfig.infomation.purchasePrice // 采购价格 |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | }, |
| | | // 保存 |
| | | saveClick() { |
| | | console.log(this.editConfig.infomation) |
| | | if (this.editConfig.title === "添加") { |
| | | createProduct({ |
| | | list: this.tableData |
| | | }).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getProductList() |
| | | this.$refs.productTable.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | console.log(this.editConfig.infomation) |
| | | for (let i = 0; i < this.tableData.length; i++) { |
| | | if (this.tableData[i].name.length === 0) { |
| | | this.isNoProduct = true |
| | | break |
| | | } else { |
| | | this.isNoProduct = false |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | const params = this.saveParams() |
| | | updateProduct(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("编辑成功") |
| | | this.$parent.getProductList() |
| | | if (this.isNoProduct) { |
| | | this.$message.error("产品名称不能为空") |
| | | } else { |
| | | if (this.editConfig.title === "添加") { |
| | | createProduct({ |
| | | list: this.tableData |
| | | }) |
| | | .then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getProductList() |
| | | } |
| | | }) |
| | | .catch((e) => { |
| | | console.log(e) |
| | | }) |
| | | } else { |
| | | const params = this.saveParams() |
| | | updateProduct(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("编辑成功") |
| | | this.$parent.getProductList() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | saveParams() { |
| | | let data = this.editConfig.infomation |
| | | let params = { |
| | | deliveryTime: data.deliveryTime || 0, |
| | | deliveryTime: this.deliveryTime || 0, |
| | | id: data.ID || 0, |
| | | maximumStock: data.maximumStock || 0, |
| | | minimumStock: data.minimumStock || 0, |
| | |
| | | name: data.name || "", |
| | | number: data.number || "", |
| | | productType: data.productType || "", |
| | | purchasePrice: data.purchasePrice || 0, |
| | | purchasePrice: this.purchasePrice || 0, |
| | | remark: data.remark || "", |
| | | shippingDuration: data.shippingDuration || 0, |
| | | shippingDuration: this.shippingDuration || 0, |
| | | specifications: data.specifications || "", |
| | | supplierId: this.supplierId || 0, |
| | | unit: data.unit || "" |
| | |
| | | this.productTableList = { |
| | | tableData: this.tableData, |
| | | tableColumn: [ |
| | | { label: "产品名称", prop: "name", productName: true, isRequird: true }, |
| | | { label: "产品名称", prop: "name", productName: true, isRequird: true, width: 250 }, |
| | | { label: "产品编码", prop: "number" }, |
| | | { label: "计量单位", prop: "unit" }, |
| | | { label: "规格型号", prop: "specifications" }, |
| | |
| | | // 产品列表输入 |
| | | inputContent(val, prop, row) { |
| | | this.productId = row.productId |
| | | this.deliveryTime = row.deliveryTime |
| | | this.shippingDuration = row.shippingDuration |
| | | this.purchasePrice = row.purchasePrice |
| | | this.tableData.map((item) => { |
| | | if (item.productId === row.productId) { |
| | | item[prop] = val |
| | | item.supplierId = this.supplierId |
| | | item.deliveryTime = this.deliveryTime |
| | | item.shippingDuration = this.shippingDuration |
| | | item.purchasePrice = this.purchasePrice |
| | | } |
| | | }) |
| | | }, |
| | |
| | | desc: "", |
| | | name: "", |
| | | number: "", |
| | | price: 0, |
| | | purchasePrice: 0, |
| | | total: 0, |
| | | deliveryTime: 0, |
| | | shippingDuration: 0, |
| | | supplierId: this.supplierId |
| | | }) |
| | | }, |
| | |
| | | desc: "", |
| | | name: "", |
| | | number: "", |
| | | price: 0, |
| | | purchasePrice: 0, |
| | | total: 0, |
| | | deliveryTime: 0, |
| | | shippingDuration: 0, |
| | | supplierId: this.supplierId |
| | | } |
| | | ] |