From c1adf27fbabbff1d76b60993521c765ef1ed79ef Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期二, 15 八月 2023 20:03:21 +0800 Subject: [PATCH] 新建客户管理 客户名称查重 --- src/views/client/client/index.vue | 7 - src/common/untils/request.js | 3 src/api/client/client.js | 9 + src/views/client/followupRecords/AddFollowupRecordsDialog.vue | 2 src/views/sales/contractManage/AddContractManageDialog.vue | 167 +++++++++++++++++++++----------- src/views/service/clientServiceOrder/AddCientServiceOrderDialog.vue | 2 src/views/client/client/AddClientManageDialog.vue | 79 ++++++++------- 7 files changed, 166 insertions(+), 103 deletions(-) diff --git a/src/api/client/client.js b/src/api/client/client.js index 24473aa..6255964 100644 --- a/src/api/client/client.js +++ b/src/api/client/client.js @@ -56,3 +56,12 @@ method: "get" }) } + +// 妫�鏌ュ鎴峰悕绉版槸鍚﹂噸澶� +export function checkNameClient(data) { + return request({ + url: "/api/client/checkName", + method: "post", + data + }) +} diff --git a/src/common/untils/request.js b/src/common/untils/request.js index 9270bbc..9418a79 100644 --- a/src/common/untils/request.js +++ b/src/common/untils/request.js @@ -30,6 +30,9 @@ /* //瀵瑰搷搴旀暟鎹仛浜涗簨 */ if (res.data.code === 200) { return res.data ? res.data : {} + } else if (res.data.code === 700001) { + console.log("瀹㈡埛鍚嶇О閲嶅") + return res } else { Message({ message: res.data.msg, diff --git a/src/views/client/client/AddClientManageDialog.vue b/src/views/client/client/AddClientManageDialog.vue index fd10291..f4180f8 100644 --- a/src/views/client/client/AddClientManageDialog.vue +++ b/src/views/client/client/AddClientManageDialog.vue @@ -490,7 +490,7 @@ </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", @@ -518,7 +518,13 @@ 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: "璇烽�夋嫨閿�鍞礋璐d汉", trigger: "change" }], approvalOpinion: [{ required: true, message: "璇疯緭鍏ュ鎵规剰瑙�", trigger: "blur" }], @@ -603,43 +609,29 @@ 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") @@ -691,7 +683,8 @@ 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 }, @@ -719,6 +712,16 @@ } } }) + }, + // 鏌ラ噸 + async checkNameClient(rule, value, callback) { + if (this.editConfig.title === "鏂板缓") { + await checkNameClient({ name: value }).then((res) => { + if (res.data.code === 700001) { + return callback(new Error("瀹㈡埛鍚嶇О閲嶅")) + } + }) + } } } } diff --git a/src/views/client/client/index.vue b/src/views/client/client/index.vue index 2b858d5..4830133 100644 --- a/src/views/client/client/index.vue +++ b/src/views/client/client/index.vue @@ -2,11 +2,8 @@ <div class="custom-manage"> <div class="tab-view"> <el-tabs v-model="activeName" @tab-click="tabsClick"> - <el-tab-pane label="鍏ㄩ儴(鍚墍鏈夊叕娴�)" name="first" disabled></el-tab-pane> - <el-tab-pane label="鍏ㄩ儴(鍚叕娴�)" name="second" disabled></el-tab-pane> - <el-tab-pane label="鍏ㄩ儴(涓嶅惈鍏捣)" name="third" disabled></el-tab-pane> - <el-tab-pane label="鍏捣宸插垎閰�" name="fourth" disabled></el-tab-pane> - <el-tab-pane label="鍏湭鍒嗛厤" name="aaa" disabled></el-tab-pane> + <el-tab-pane label="鍏捣瀹㈡埛" name="first"></el-tab-pane> + <el-tab-pane label="鎴戠殑瀹㈡埛" name="second"></el-tab-pane> </el-tabs> <div class="sel-gonghai"> <el-select v-model="gonghaiValue" placeholder="璇烽�夋嫨" class="query-class-sel" size="mini" disabled> diff --git a/src/views/client/followupRecords/AddFollowupRecordsDialog.vue b/src/views/client/followupRecords/AddFollowupRecordsDialog.vue index a26cc11..a50d001 100644 --- a/src/views/client/followupRecords/AddFollowupRecordsDialog.vue +++ b/src/views/client/followupRecords/AddFollowupRecordsDialog.vue @@ -335,7 +335,7 @@ number: [{ required: true, message: "璇疯緭鍏ヨ窡杩涜褰曠紪鍙�", trigger: "blur" }], member_id: [{ required: true, message: "璇烽�夋嫨璐熻矗浜�", trigger: "change" }], record: [{ required: true, message: "璇疯緭鍏ヨ窡杩涜褰�", trigger: "blur" }], - content: [{ required: true, message: "璇疯緭鍏ュ唴瀹�", trigger: "blur" }], + // content: [{ required: true, message: "璇疯緭鍏ュ唴瀹�", trigger: "blur" }], phoneNumber: [ { required: false, message: "", trigger: "blur" }, { len: 11, message: "闀垮害鍦�11涓瓧绗�", trigger: "blur" }, diff --git a/src/views/sales/contractManage/AddContractManageDialog.vue b/src/views/sales/contractManage/AddContractManageDialog.vue index 31dfc60..9338216 100644 --- a/src/views/sales/contractManage/AddContractManageDialog.vue +++ b/src/views/sales/contractManage/AddContractManageDialog.vue @@ -25,14 +25,18 @@ <div class="custom-name"> <el-autocomplete v-model="editConfig.infomation.client_name" - :fetch-suggestions="querySearchAsync" + :fetch-suggestions=" + (queryString, callback) => { + querySearchAsync(queryString, callback, 'client') + } + " value-key="name" - @select="handleSelectClient" + @select="handleSelectClient('client', $event)" ></el-autocomplete> - <div class="common-select-btn" @click="selClientClick"> + <div class="common-select-btn" @click="selClientClick('client')"> <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i> </div> - <div class="common-select-btn" @click="clearupClient"> + <div class="common-select-btn" @click="clearupClient('client')"> <i class="el-icon-edit-outline" title="娓呴櫎"></i> </div> </div> @@ -73,11 +77,24 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="閿�鍞姤浠峰崟" prop="quotation_id"> + <el-form-item label="閿�鍞姤浠峰崟" prop="quotationId"> <div class="custom-name"> - <el-input v-model="editConfig.infomation.quotation_id"></el-input> - <div class="common-select-btn"><i class="el-icon-circle-plus-outline" title="閫夋嫨"></i></div> - <div class="common-select-btn"><i class="el-icon-edit" title="缂栬緫"></i></div> + <el-autocomplete + v-model="editConfig.infomation.quotation_number" + :fetch-suggestions=" + (queryString, callback) => { + querySearchAsync(queryString, callback, 'quotation') + } + " + value-key="number" + @select="handleSelectClient('quotation', $event)" + ></el-autocomplete> + <div class="common-select-btn" @click="selClientClick('quotation')"> + <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i> + </div> + <div class="common-select-btn" @click="clearupClient('quotation')"> + <i class="el-icon-edit-outline" title="娓呴櫎"></i> + </div> </div> </el-form-item> </el-col> @@ -168,6 +185,12 @@ :edit-common-config="editSelectClientConfig" @selClient="selClient" /> + <!-- 鎶ヤ环鍗� --> + <SelectCommonDialog + v-if="editSelCommonConfig.editVisible" + :edit-common-config="editSelCommonConfig" + @selClient="selClient" + /> </el-dialog> </div> </template> @@ -176,6 +199,7 @@ import { getAllData } from "@/api/client/client" import { getAddContract, getUpdateContract } from "@/api/sales/contractManage" import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog" +import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog" export default { name: "AddContractManageDialog", props: { @@ -190,10 +214,13 @@ } } }, - components: { SelectClientDialog }, + components: { SelectClientDialog, SelectCommonDialog }, computed: { clientList() { return this.$store.state.getClientName.clientList + }, + quotationList() { + return this.$store.state.getClientName.quotationList } }, data() { @@ -213,11 +240,19 @@ editVisible: false, title: "", infomation: {} - } + }, + editSelCommonConfig: { + editVisible: false, + title: "", + infomation: {} + }, + clientId: this.editCommonConfig.infomation.clientId, + quotationId: this.editCommonConfig.infomation.quotationId } }, created() { this.$store.dispatch("geClient") + this.$store.dispatch("geQuotation") this.getCommonData() }, methods: { @@ -239,37 +274,23 @@ const params = this.saveParams() console.log(params) if (this.editConfig.title === "鏂板缓") { - getAddContract(params) - .then((res) => { - console.log(res) - this.editConfig.visible = false - if (res.code === 200) { - this.$message({ - message: "娣诲姞鎴愬姛", - type: "success" - }) - this.$parent.getData() - } - }) - .catch((err) => { - console.log(err) - }) + getAddContract(params).then((res) => { + console.log(res) + this.editConfig.visible = false + if (res.code === 200) { + this.$message.success("娣诲姞鎴愬姛") + this.$parent.getData() + } + }) } else { - getUpdateContract(params) - .then((res) => { - console.log(res) - this.editConfig.visible = false - if (res.code === 200) { - this.$message({ - message: "缂栬緫鎴愬姛", - type: "success" - }) - this.$parent.getData() - } - }) - .catch((err) => { - console.log(err) - }) + getUpdateContract(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") @@ -281,11 +302,11 @@ let data = this.editConfig.infomation let params = { id: this.editConfig.title === "鏂板缓" ? 0 : data.id, - client_id: parseInt(data.client_id) || 0, + client_id: this.clientId || 0, file: "", member_id: data.member_id || 0, number: data.number || "", - quotation_id: data.quotation_id || 0, + quotation_id: this.quotationId || 0, status_id: data.status_id || 0 } return params @@ -294,31 +315,61 @@ this.editConfig.visible = false }, // 閫夋嫨瀹㈡埛鐩稿叧鏂规硶 - querySearchAsync(queryString, cb) { - var restaurants = this.clientList - var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants + querySearchAsync(queryString, cb, value) { + var restaurants = [] + if (value === "client") { + restaurants = this.clientList + } else if (value === "quotation") { + restaurants = this.quotationList + } + var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants cb(results) }, - createStateFilter(queryString) { + createStateFilter(queryString, value) { return (state) => { - return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0 + if (value === "contract" || value === "quotation") { + return state.number.toLowerCase().indexOf(queryString.toLowerCase()) === 0 + } else { + return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0 + } } }, - handleSelectClient(item) { - this.editConfig.infomation.client_id = item.id + handleSelectClient(value, item) { + console.log(value) + if (value === "client") { + this.clientId = item.id + } else if (value === "quotation") { + this.quotationId = item.id + } }, - selClientClick() { - this.editSelectClientConfig.editVisible = true + selClientClick(value) { + if (value === "client") { + this.editSelectClientConfig.editVisible = true + } else if (value === "quotation") { + this.editSelCommonConfig.title = "鎶ヤ环鍗�" + this.editSelCommonConfig.editVisible = true + this.editSelCommonConfig.tableInfomation = [...this.quotationList] + } }, - selClient(row) { - console.log(row) - this.editConfig.infomation.client_name = row.name - this.editConfig.infomation.client_id = row.id + selClient(row, value) { + console.log(value) + if (value === "contact") { + this.editConfig.infomation.contact_name = row.name + this.contactId = row.id + } else if (value === "quotation") { + this.editConfig.infomation.quotation_number = row.number + this.quotationId = row.id + } }, // 娓呴櫎宸查�夋嫨鐢ㄦ埛 - clearupClient() { - this.editConfig.infomation.client_name = "" - this.editConfig.infomation.client_id = 0 + clearupClient(value) { + if (value === "client") { + this.editConfig.infomation.client_name = "" + this.clientId = 0 + } else if (value === "quotation") { + this.editConfig.infomation.quotation_number = "" + this.quotationId = 0 + } }, // 娣诲姞闄勪欢 addAnnexClick() {}, diff --git a/src/views/service/clientServiceOrder/AddCientServiceOrderDialog.vue b/src/views/service/clientServiceOrder/AddCientServiceOrderDialog.vue index eda11e6..0a56e12 100644 --- a/src/views/service/clientServiceOrder/AddCientServiceOrderDialog.vue +++ b/src/views/service/clientServiceOrder/AddCientServiceOrderDialog.vue @@ -877,7 +877,7 @@ this.editConfig.infomation.client_name = "" this.clientId = 0 } else if (value === "serviceContract") { - this.editConfig.infomation.service_number = "" + this.editConfig.infomation.serviceContract_Number = "" this.serviceContractId = 0 } else if (value === "contract") { this.editConfig.infomation.number = "" -- Gitblit v1.8.0