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/sales/contractManage/AddContractManageDialog.vue | 167 ++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 109 insertions(+), 58 deletions(-) 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() {}, -- Gitblit v1.8.0