From d5d594b967d4b7f4735bebd8669eff910ee6fb10 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Mon, 6 May 2024 15:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=AE=A2=E6=88=B7=E5=AD=A6?= =?UTF-8?q?=E6=A0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/api.js | 4 + src/views/customer/AddCustomer.vue | 157 ++++++++++++++++++----------- 2 files changed, 103 insertions(+), 58 deletions(-) diff --git a/src/utils/api.js b/src/utils/api.js index 671890b..aaa9f12 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -51,6 +51,10 @@ export default { exportSubscribedRecords: `nakadai/nakadai/order/exportSubscribedRecords`, addNewCustomersByOneself: `nakadai/nakadai/school/addNewCustomersByOneself`, exportClient: `${host}nakadai/nakadai/customer/exportClient`, + customerSettingsList: `nakadai/nakadai/customer/customerSettingsList`, + clientSettingsEditClient: `nakadai/nakadai/customer/clientSettingsEditClient`, + delClientsOrSchools: `nakadai/nakadai/school/delClientsOrSchools`, + editClientsOrSchools: `nakadai/nakadai/school/editClientsOrSchools`, resetPwdCustomer: `nakadai/nakadai/customer/resetPwd`, queryCustomerIsExists: `nakadai/nakadai/customer/queryCustomerIsExists`, diff --git a/src/views/customer/AddCustomer.vue b/src/views/customer/AddCustomer.vue index 51ea7d4..4913d6e 100644 --- a/src/views/customer/AddCustomer.vue +++ b/src/views/customer/AddCustomer.vue @@ -60,13 +60,14 @@ :label="item.schoolName" :value="item.schoolId"> - - + 设置 --> + @click="setCustomer">设置 - - + :value="item.provinceId"> - + :disabled="customerForm.provinceId ? false : true"> + :value="item.cityId"> @@ -568,11 +569,14 @@ class="dialog" :close-on-click-modal="false" custom-class="customer-dia"> -
- + +
+ @@ -627,12 +635,6 @@ :page-size="pageSizeCustomer"> - - 取消 - 确定 -
@@ -860,16 +862,17 @@ export default { cities: [], customerForm: { schoolName: '', - provinceName: '', - cityName: '', + provinceId: '', + cityId: '', }, customerListVisible: false, - customers: [{}], + customers: [], pageCustomer: 1, pageSizeCustomer: 10, totalCustomer: 0, customerKeyword: '', + curRow: null }; }, watch: { @@ -899,6 +902,12 @@ export default { this.getBm() }, 500) }, + customerKeyword: function (val) { + clearTimeout(this.searchTimer) + this.searchTimer = setTimeout(() => { + this.initCustomer() + }, 500) + }, }, mounted () { this.getIndustryClass() @@ -1051,66 +1060,98 @@ export default { this.handlePage() this.$router.push(`addcustomer?id=${this.customerId}&type=tab2&page=${val}`) }, - // 创建客户 - addCustomer () { - // this.customerListVisible = true - this.customerVisible = true + // 设置客户 + setCustomer () { + this.initCustomer() + this.customerListVisible = true + // this.customerVisible = true }, handleCurrentChangeCustomer (val) { this.pageCustomer = val - // this.getCustomer() + this.getCustomer() }, // 获取客户列表 getCustomer () { - this.$get(this.api.queryCity, { - provinceId: this.provinceList.find(e => e.provinceName == name).provinceId - }).then(({ list }) => { - this.cities = list - this.customerForm.cityName = '' + this.$post(this.api.customerSettingsList, { + pageNum: this.pageCustomer, + pageSize: this.pageSizeCustomer, + keyword: this.customerKeyword, + }).then(({ page }) => { + this.customers = page.records + this.totalCustomer = page.total }).catch(res => { }); }, + initCustomer () { + this.pageCustomer = 1 + this.getCustomer() + }, + // 创建客户 + addCustomer () { + this.curRow = null + this.customerVisible = true + }, // 编辑客户 editCustomer (row) { + this.curRow = row this.customerVisible = true - // this.customerForm = { - // schoolName: '', - // provinceName: '', - // cityName: '', - // } + this.customerForm = { + schoolName: row.customerName || row.schoolName, + provinceId: row.provinceId, + cityId: row.cityId, + customerId: row.customerId || '', + schoolId: row.schoolId || '', + } + row.provinceId && this.provinceChange() }, // 删除客户 delCustomer (row, i) { this.$confirm('确定要删除吗?', '提示', { type: 'warning' - }).then(() => { - + }).then(async () => { + await this.$post(`${this.api.delClientsOrSchools}?schoolId=${row.schoolId}`).then(res => { + this.$message.success('删除成功') + this.getCustomer() + }) }).catch(() => { }) }, // 获取城市 - provinceChange (name) { + provinceChange (e) { this.$get(this.api.queryCity, { - provinceId: this.provinceList.find(e => e.provinceName == name).provinceId + provinceId: this.customerForm.provinceId }).then(({ list }) => { this.cities = list - this.customerForm.cityName = '' + if (e) this.customerForm.cityId = '' }).catch(res => { }); }, // 客户新增提交 - submitCustomer () { + async submitCustomer () { if (this.submiting) return false const form = this.customerForm if (!form.schoolName) return this.$message.warning('请输入客户名称') - if (!form.provinceName) return this.$message.warning('请选择省份') - if (!form.cityName) return this.$message.warning('请选择城市') + if (!form.provinceId) return this.$message.warning('请选择省份') + if (!form.cityId) return this.$message.warning('请选择城市') this.submiting = true - this.$get(this.api.addNewCustomersByOneself, form).then(res => { - this.customerVisible = false - this.submiting = false - this.$message.success('添加成功') - this.getSchoolData(res.schoolId) - }).catch((res) => { - this.submiting = false - }) + + const row = this.curRow + form.customerName = form.schoolName + if (this.curRow) { + if (row.bindOrNot) { + // 编辑客户 + await this.$post(this.api.clientSettingsEditClient, form) + } else { + // 编辑学校 + await this.$post(this.api.editClientsOrSchools, form) + } + } else { + // 新增学校 + await this.$get(this.api.addNewCustomersByOneself, form) + } + + this.customerVisible = false + this.submiting = false + this.$message.success('添加成功') + this.getCustomer() + this.getSchoolData(res.schoolId) }, // 获取产品分类 getCategory () { @@ -1509,7 +1550,7 @@ export default { .plus-cus { margin-left: 10px; font-size: 18px; - color: #666; + color: #9076ff; cursor: pointer; } /deep/.customer-dia {