| | |
| | | <div class="basic-info-view"> |
| | | <CommonFormTableView |
| | | :product-table-list="productTableList" |
| | | :detail-enter="detailEnter" |
| | | @inputContent="inputContent" |
| | | @addProductClick="addProductClick" |
| | | @emptyProductClick="emptyProductClick" |
| | | @clearupProduct="clearupProduct" |
| | | @selCommonName="selCommonName" |
| | | /> |
| | | </div> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | // import { createProduct, updateProduct } from "@/api/productManage/product" |
| | | import { createProduct, updateProduct } from "@/api/productManage/product" |
| | | import CommonFormTableView from "@/components/makepager/CommonFormTableView" |
| | | export default { |
| | | name: "AddNewProduct", |
| | |
| | | productTableList: {}, |
| | | tableData: [], |
| | | productId: 1, |
| | | isNoProduct: true |
| | | isNoProduct: true, |
| | | supplierId: this.addCommonConfig.infomation.supplierId, |
| | | detailEnter: true |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | // 保存 |
| | | saveClick() { |
| | | console.log(this.editConfig.infomation) |
| | | const params = this.saveParams() |
| | | console.log(params) |
| | | if (this.editConfig.title === "添加") { |
| | | // createProduct(params).then((res) => { |
| | | // console.log(res) |
| | | // this.editConfig.visible = false |
| | | // if (res.code === 200) { |
| | | // this.$message.success("添加成功") |
| | | // this.$parent.getData() |
| | | // } |
| | | // }) |
| | | createProduct({ |
| | | list: this.tableData |
| | | }).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getProductList() |
| | | } |
| | | }) |
| | | } else { |
| | | // updateProduct(params).then((res) => { |
| | | // console.log(res) |
| | | // this.editConfig.visible = false |
| | | // if (res.code === 200) { |
| | | // this.$message.success("编辑成功") |
| | | // this.$parent.getData() |
| | | // } |
| | | // }) |
| | | 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 data = this.editConfig.infomation |
| | | let params = { |
| | | deliveryTime: 0, |
| | | id: 0, |
| | | maximumStock: 0, |
| | | minimumStock: 0, |
| | | name: "string", |
| | | number: "string", |
| | | productType: "string", |
| | | purchasePrice: 0, |
| | | remark: "string", |
| | | shippingDuration: 0, |
| | | specifications: "string", |
| | | supplierId: 0, |
| | | unit: "string" |
| | | deliveryTime: data.deliveryTime || 0, |
| | | id: data.ID || 0, |
| | | maximumStock: data.maximumStock || 0, |
| | | minimumStock: data.minimumStock || 0, |
| | | modelNumber: data.modelNumber || "", |
| | | name: data.name || "", |
| | | number: data.number || "", |
| | | productType: data.productType || "", |
| | | purchasePrice: data.purchasePrice || 0, |
| | | remark: data.remark || "", |
| | | shippingDuration: data.shippingDuration || 0, |
| | | specifications: data.specifications || "", |
| | | supplierId: this.supplierId || 0, |
| | | unit: data.unit || "" |
| | | } |
| | | return params |
| | | }, |
| | | setTableForm() { |
| | | if (this.editConfig.title === "添加" || this.editConfig.infomation.products.length === 0) { |
| | | if (this.editConfig.title === "添加") { |
| | | this.detailEnter = false |
| | | this.tableData = [ |
| | | { |
| | | productId: this.productId, |
| | |
| | | name: "", |
| | | number: "", |
| | | price: 0, |
| | | total: 0 |
| | | total: 0, |
| | | supplierId: this.supplierId |
| | | } |
| | | ] |
| | | } else { |
| | | this.tableData = this.editConfig.infomation.products |
| | | this.tableData.map((item, index) => { |
| | | item.productId = index + 1 |
| | | }) |
| | | this.tableData = [{ ...this.editConfig.infomation }] |
| | | this.detailEnter = true |
| | | } |
| | | this.productTableList = { |
| | | tableData: this.tableData, |
| | |
| | | this.tableData.map((item) => { |
| | | if (item.productId === row.productId) { |
| | | item[prop] = val |
| | | item.supplierId = this.supplierId |
| | | } |
| | | }) |
| | | }, |
| | |
| | | name: "", |
| | | number: "", |
| | | price: 0, |
| | | total: 0 |
| | | total: 0, |
| | | supplierId: this.supplierId |
| | | }) |
| | | }, |
| | | // 产品清空 |
| | |
| | | name: "", |
| | | number: "", |
| | | price: 0, |
| | | total: 0 |
| | | total: 0, |
| | | supplierId: this.supplierId |
| | | } |
| | | ] |
| | | this.productTableList.tableData = this.tableData |
| | |
| | | clearupProduct(data) { |
| | | this.tableData = data |
| | | this.productTableList.tableData = this.tableData |
| | | }, |
| | | selCommonName(row) { |
| | | console.log("1133") |
| | | console.log(row) |
| | | this.editConfig.infomation = row |
| | | } |
| | | } |
| | | } |