| | |
| | | this.$refs[formName].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 |
| | | } |
| | | } |
| | | if (this.isNoProduct) { |
| | | this.$message.error("产品名称不能为空") |
| | | // for (let i = 0; i < this.tableData.length; i++) { |
| | | // if (this.tableData[i].name.length === 0) { |
| | | // this.isNoProduct = true |
| | | // break |
| | | // } else { |
| | | // this.isNoProduct = false |
| | | // } |
| | | // } |
| | | // if (this.isNoProduct) { |
| | | // this.$message.error("产品名称不能为空") |
| | | // } else { |
| | | const params = this.saveParams() |
| | | if (this.editConfig.title === "新建") { |
| | | getAddServiceContract(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } else { |
| | | const params = this.saveParams() |
| | | if (this.editConfig.title === "新建") { |
| | | getAddServiceContract(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } else { |
| | | getUpdateServiceContract(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("编辑成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } |
| | | getUpdateServiceContract(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("编辑成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } |
| | | } else { |
| | | console.log("error submit") |
| | | return false |
| | | } |
| | | // } else { |
| | | // console.log("error submit") |
| | | // return false |
| | | // } |
| | | }) |
| | | }, |
| | | 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, |
| | | clientId: this.clientId || 0, |
| | |
| | | endTime: data.endTime || "", |
| | | memberId: data.memberId || 0, |
| | | number: data.number || "", |
| | | products: this.tableData, |
| | | products: products, |
| | | quotationId: this.quotationId || 0, |
| | | remark: data.remark || "", |
| | | saleChanceId: this.saleChanceId || 0, |