| | |
| | | saveClick(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | const hasProduct = this.tableData.every((ele) => !!ele.name) |
| | | if (!hasProduct) { |
| | | this.$message.error("产品名称不能为空") |
| | | return |
| | | } |
| | | // const hasProduct = this.tableData.every((ele) => !!ele.name) |
| | | // if (!hasProduct) { |
| | | // this.$message.error("产品名称不能为空") |
| | | // return |
| | | // } |
| | | |
| | | const params = this.saveParams() |
| | | console.log(params) |
| | |
| | | }, |
| | | saveParams() { |
| | | let data = this.editConfig.infomation |
| | | let products = [] |
| | | this.tableData.map((item) => { |
| | | if (item.number.length > 0) { |
| | | products.push(item) |
| | | } |
| | | }) |
| | | let params = { |
| | | id: this.editConfig.title === "新建" ? 0 : data.id, |
| | | advantages: data.advantages || "", |
| | |
| | | detail_address: data.detail_address || "", |
| | | |
| | | codeStandID: data.ID, |
| | | products: this.tableData |
| | | products: products |
| | | } |
| | | return params |
| | | }, |
| | |
| | | } |
| | | this.productTableList = { |
| | | tableData: this.tableData, |
| | | isReturn: true, |
| | | tableColumn: [ |
| | | { label: "#", prop: "productId", width: 40 }, |
| | | // { label: "#", prop: "productId", width: 40 }, |
| | | { label: "产品名称", prop: "name", productName: true, isRequird: true }, |
| | | { label: "产品编号", prop: "number" }, |
| | | { label: "数量", prop: "amount", inputNumber: true, isRequird: true }, |
| | |
| | | }, |
| | | // 产品列表输入 |
| | | inputContent(val, prop, row) { |
| | | this.productId = row.productId |
| | | // this.productId = row.productId |
| | | this.tableData.map((item) => { |
| | | if (item.productId === row.productId) { |
| | | if (item.number === row.number) { |
| | | item[prop] = val |
| | | } |
| | | }) |
| | |
| | | // this.showSummary.show = true |
| | | }, |
| | | // 新增方式修改 |
| | | getSelectArray(val) { |
| | | if (val.length > 0) { |
| | | val.map((item, index) => { |
| | | item.productId = this.tableData.length + index + 1 |
| | | }) |
| | | getSelectArray(val, index) { |
| | | // if (val.length > 0) { |
| | | // val.map((item, index) => { |
| | | // item.productId = this.tableData.length + index + 1 |
| | | // }) |
| | | // } |
| | | // this.tableData = this.tableData.concat(val) |
| | | // this.productTableList.tableData = this.tableData |
| | | // this.showSummary.show = true |
| | | if (this.tableData.length == 1 && this.tableData[0].number.length == 0) { |
| | | this.tableData = [] |
| | | } |
| | | if (index < this.tableData.length) { |
| | | this.tableData.splice(index, 1) |
| | | val.map((item, ind) => { |
| | | this.tableData.splice(index + ind, 0, item) |
| | | }) |
| | | } else { |
| | | this.tableData = this.tableData.concat(val) |
| | | } |
| | | this.productTableList.tableData = this.tableData |
| | | this.showSummary.show = true |
| | | }, |