| | |
| | | <div class="custom-name"> |
| | | <el-input v-model="editConfig.infomation.name"></el-input> |
| | | <!-- <div class="common-select-btn"><i class="el-icon-house" title="工商查询"></i></div> --> |
| | | <div class="common-select-btn"><i class="el-icon-search" title="查重"></i></div> |
| | | <!-- <div class="common-select-btn"><i class="el-icon-search" title="查重"></i></div> --> |
| | | </div> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getAllData, getAddClient, getUpdateClient } from "@/api/client/client" |
| | | import { getAllData, getAddClient, getUpdateClient, checkNameClient } from "@/api/client/client" |
| | | import { getCityList } from "@/api/common/address" |
| | | export default { |
| | | name: "AddClientManageDialog", |
| | |
| | | dialogWidth: "80%", |
| | | editConfig: this.editClientManageConfig, |
| | | rules: { |
| | | name: [{ required: true, message: "请输入客户名称", trigger: "blur" }], |
| | | name: [ |
| | | { required: true, message: "请输入客户名称", trigger: "blur" }, |
| | | { |
| | | validator: this.checkNameClient, |
| | | trigger: "blur" |
| | | } |
| | | ], |
| | | client_status_id: [{ required: true, message: "请选择客户状态", trigger: "change" }], |
| | | member_id: [{ required: true, message: "请选择销售负责人", trigger: "change" }], |
| | | approvalOpinion: [{ required: true, message: "请输入审批意见", trigger: "blur" }], |
| | |
| | | provinceOptions: [], // 省份 |
| | | cityOptions: [], // 城市 |
| | | regionOptions: [], // 区域 |
| | | approvalWorkflowOptions: [] // 审批流程 |
| | | approvalWorkflowOptions: [], // 审批流程 |
| | | clientName: this.editClientManageConfig.infomation.name |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | const params = this.saveParams() |
| | | console.log(params) |
| | | if (this.editConfig.title === "新建") { |
| | | getAddClient(params) |
| | | .then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message({ |
| | | message: "添加成功", |
| | | type: "success" |
| | | }) |
| | | if (this.editConfig.isSalesOpportunity) { |
| | | this.$emit("salesOpportunityClick", this.editConfig.infomation) |
| | | } else if (this.editConfig.title === "新建" && this.editConfig.infomation.sales_leads_id) { |
| | | this.$parent.handleClose() |
| | | } else { |
| | | this.$parent.getData() |
| | | } |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | } else { |
| | | getUpdateClient(params) |
| | | .then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message({ |
| | | message: "编辑成功", |
| | | type: "success" |
| | | }) |
| | | getAddClient(params).then((res) => { |
| | | console.log(res) |
| | | this.editConfig.visible = false |
| | | if (res.code === 200) { |
| | | this.$message.success("添加成功") |
| | | if (this.editConfig.isSalesOpportunity) { |
| | | this.$emit("salesOpportunityClick", this.editConfig.infomation) |
| | | } else if (this.editConfig.title === "新建" && this.editConfig.infomation.sales_leads_id) { |
| | | this.$parent.handleClose() |
| | | } else { |
| | | this.$parent.getData() |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | getUpdateClient(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") |
| | |
| | | remark: data.remark || "", |
| | | representative: data.representative || "", |
| | | service_member_id: data.service_member_id || 0, |
| | | sales_leads_id: data.sales_leads_id || 0 |
| | | sales_leads_id: data.sales_leads_id || 0, |
| | | contact_id: data.contact_id || 0 |
| | | } |
| | | return params |
| | | }, |
| | |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | // 查重 |
| | | async checkNameClient(rule, value, callback) { |
| | | if (this.editConfig.title === "新建" || this.clientName !== this.editConfig.infomation.name) { |
| | | await checkNameClient({ name: value }).then((res) => { |
| | | if (res.data.code === 700001) { |
| | | return callback(new Error("客户名称重复")) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |