| | |
| | | saleChancelist: [] |
| | | } |
| | | }, |
| | | mounted(){ |
| | | this.getSaleChanceList() |
| | | }, |
| | | created() { |
| | | this.$store.dispatch("geClient") |
| | | this.$store.dispatch("geContact") |
| | |
| | | saveClick(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | // 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 { |
| | | 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 { |
| | | for (let i = 0; i < this.tableData.length; i++) { |
| | | if (this.tableData[i].cost) { |
| | | let reg =/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/; |
| | | if (!reg.test(this.tableData[i].cost)) { |
| | | this.$message.error("成本单价需要填写大于0的2位小数!") |
| | | return true |
| | | } |
| | | if (this.tableData[i].cost) { |
| | | let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/ |
| | | if (!reg.test(this.tableData[i].cost)) { |
| | | this.$message.error("成本单价需要填写大于0的2位小数!") |
| | | return true |
| | | } |
| | | } |
| | | const params = this.saveParams() |
| | | if (this.editConfig.title === "新建") { |
| | | getAddQuotation(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } else { |
| | | getUpdateQuotation(params).then((res) => { |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("编辑成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | console.log("error submit") |
| | | return false |
| | | const params = this.saveParams() |
| | | if (this.editConfig.title === "新建") { |
| | | getAddQuotation(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } else { |
| | | getUpdateQuotation(params).then((res) => { |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("编辑成功") |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | // } 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, |
| | | quotationName: data.quotationName || "", |
| | |
| | | quotation_status_id: data.quotation_status_id || 0, |
| | | sale_chance_id: this.saleChanceId || 0, |
| | | validity_date: data.validity_date || "", |
| | | products: this.tableData, |
| | | products: products, |
| | | codeStandID: data.ID, |
| | | client_id: this.clientId || 0 |
| | | } |
| | |
| | | } |
| | | }, |
| | | handleSelectClient(value, item) { |
| | | console.log(value) |
| | | console.log(item,'item') |
| | | if (value === "client") { |
| | | this.clientId = item.id |
| | | this.editConfig.infomation.client_name = item.name |
| | | this.getSaleChanceList(item) |
| | | } else if (value === "chance") { |
| | | this.saleChanceId = item.id |
| | | this.editConfig.infomation.sale_chance_name = item.name |
| | | this.editConfig.infomation.client_name = item.client.name |
| | | this.clientId = item.client.id |
| | | this.getSaleChanceList({id:this.clientId}) |
| | | this.productTableList.tableData = item.products ? item.products : [] |
| | | this.tableData = item.products ? item.products : [] |
| | | } else { |
| | | this.contactId = item.id |
| | | } |
| | |
| | | this.contactId = row.id |
| | | } else if (value === "chance") { |
| | | this.editConfig.infomation.sale_chance_name = row.name |
| | | this.editConfig.infomation.client_name=row.client.name |
| | | this.editConfig.infomation.client_name = row.client.name |
| | | this.clientId = row.client.id |
| | | this.saleChanceId = row.id |
| | | this.productTableList.tableData = row.products ? row.products : [] |
| | | this.tableData = row.products ? row.products : [] |
| | | } else { |
| | | this.editConfig.infomation.client_name = row.name |
| | | this.clientId = row.id |
| | |
| | | if (value === "client") { |
| | | this.editConfig.infomation.client_name = "" |
| | | this.clientId = 0 |
| | | this.getSaleChanceList() |
| | | } else if (value === "chance") { |
| | | this.editConfig.infomation.sale_chance_name = "" |
| | | this.saleChanceId = 0 |
| | | this.getSaleChanceList({id:this.clientId}) |
| | | } else { |
| | | this.editConfig.infomation.contact_name = "" |
| | | this.contactId = 0 |
| | | } |
| | | |
| | | this.productTableList.tableData = [] |
| | | this.tableData = [] |
| | | this.refresh() |
| | | }, |
| | | // 销售机会列表 |
| | | async getSaleChanceList(item) { |
| | | await getSaleChanceList({ |
| | | page: 1, |
| | | pageSize: 15, |
| | | search_map: { |
| | | let params={} |
| | | if(item){ |
| | | params={ |
| | | page: 0, |
| | | pageSize: 0, |
| | | } |
| | | params.search_map={ |
| | | client_id: item.id |
| | | } |
| | | }).then((res) => { |
| | | }else{ |
| | | params={ |
| | | page: 0, |
| | | pageSize: 0, |
| | | } |
| | | } |
| | | await getSaleChanceList(params).then((res) => { |
| | | console.log(res) |
| | | this.saleChancelist = res.data.list |
| | | }) |
| | |
| | | } |
| | | 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, min: 110 }, |
| | | { label: "产品编号", prop: "number" }, |
| | | { label: "单位", prop: "unit" }, |
| | |
| | | }, |
| | | // 产品列表输入 |
| | | 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 (this.tableData.length == 1 && this.tableData[0].number.length == 0) { |
| | | this.tableData = [] |
| | | } |
| | | this.tableData = this.tableData.concat(val) |
| | | 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 |
| | | }, |