From 11afca8596fb63b037abff6199c4f109d0714752 Mon Sep 17 00:00:00 2001 From: hrx <18603305412@163.com> Date: Tue, 18 Nov 2025 17:51:40 +0800 Subject: [PATCH 1/2] updata --- .../customerInformationList/index.vue | 568 ++++++++++++------ 1 file changed, 390 insertions(+), 178 deletions(-) diff --git a/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue b/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue index 4fb5dcc..512b270 100644 --- a/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue +++ b/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue @@ -1,110 +1,174 @@ @@ -159,197 +223,345 @@ export default { total: null, dataOne: null, dataTwo: null, + startPickerOpts: { + disabledDate: (time) => { + if (this.dataTwo) { + return time.getTime() > new Date(this.dataTwo).getTime(); + } + return time.getTime() > Date.now(); + } + }, endPickerOpts: { - disabledDate(time) { + disabledDate: (time) => { + if (this.dataOne) { + return time.getTime() < new Date(this.dataOne).getTime() || time.getTime() > Date.now(); + } return time.getTime() > Date.now(); } }, }; }, mounted() { - this.loading = true + this.loading = true; this.getuserList(); + + // 设置默认查询日期为最近一个月 + const end = new Date(); + const start = new Date(); + start.setMonth(start.getMonth() - 1); + this.dataOne = start; + this.dataTwo = end; }, methods: { handleCurrentChange(index) { - this.current_page = index - this.lookUp() + this.current_page = index; + this.lookUp(); }, lookBill(row) { - this.currentRow = row - this.lookBillVisible = true - this.lookUp() + this.currentRow = row; + this.lookBillVisible = true; + this.lookUp(); }, lookUp(dataOne, dataTwo) { let params = { user_orgid: this.currentRow.id, - start_time: dataOne, - end_time: dataTwo, + start_time: dataOne || this.dataOne, + end_time: dataTwo || this.dataTwo, page_size: 10, current_page: this.current_page - } + }; + userGetbillAPI(params).then(res => { - console.log(res); if (res.status) { if (res.data.total_page != 0) { - - this.billList = res.data.bill_list - this.total = res.data.total_num + this.billList = res.data.bill_list; + this.total = res.data.total_num; } else { - this.billList = [] - this.total = 0 + this.billList = []; + this.total = 0; this.$message({ message: "暂无数据", type: 'warning' - }) + }); } - } else { this.$message({ message: res.msg, type: 'error' - }) + }); } - }) + }).catch(error => { + this.$message({ + message: "请求失败,请稍后重试", + type: 'error' + }); + console.error(error); + }); }, onsubmit() { if (!this.dataOne || !this.dataTwo) { this.$message({ - message: "请选择时间", + message: "请选择完整的时间范围", type: 'warning' - }) - } else { - this.lookUp(this.dataOne, this.dataTwo) + }); + return; } + + if (this.dataOne > this.dataTwo) { + this.$message({ + message: "开始日期不能大于结束日期", + type: 'warning' + }); + return; + } + + this.current_page = 1; + this.lookUp(); }, - expandChangeHandler(row, expandedRows) {// 点击展开的时候就会触发这个方法 - var orgid = { - orgid: row.id, - }; - getZJUserInfoAPI(orgid).then((res) => { - this.tableData = res.data; - }); + expandChangeHandler(row, expandedRows) { if (expandedRows.length) { this.expands = []; if (row) { this.expands.push(row.id); + + // 只在需要时请求数据 + var orgid = { + orgid: row.id, + }; + getZJUserInfoAPI(orgid).then((res) => { + this.tableData = res.data; + }).catch(error => { + console.error("获取客户详情失败:", error); + }); } } else { this.expands = []; } }, - - getuserList() {//获取所有客户 + getuserList() { var userid = { userid: sessionStorage.getItem("userId"), - // kv: "zj", }; getZJsaleGetUsersAPI(userid).then((res) => { - this.loading = false + this.loading = false; this.userList = res.data; + }).catch(error => { + this.loading = false; + console.error("获取客户列表失败:", error); + this.$message({ + message: "获取客户列表失败", + type: 'error' + }); }); }, - - open4(str) { //错误提示 - this.$message.error(str); - }, - getBusinessOp(data) { - switch (data) { - case 'BUY': - return "购买"; - case 'RECHARGE': - return "充值"; - case 'RECHARGE_ALIPAY': - return "支付宝充值"; - case 'REFUND': - return "退款"; - } - }, getBillstate(data) { switch (data) { case 0: return { message: '未支付', - type: 'info' + type: 'warning' }; case 1: return { message: '已支付', type: 'success' - } + }; case 2: return { message: '已取消', type: 'info' - } + }; case null: return { message: '已取消', type: 'info' - } + }; default: return { message: '未知', type: 'info' - } + }; } }, - }, }; - From 72a1659037d76de823457dad0c73210b0b3a9a64 Mon Sep 17 00:00:00 2001 From: hrx <18603305412@163.com> Date: Wed, 19 Nov 2025 16:10:12 +0800 Subject: [PATCH 2/2] updata --- f/web-kboss/src/store/modules/user.js | 69 ++++++---- .../customerInformationList/index.vue | 127 ++++++++++-------- 2 files changed, 113 insertions(+), 83 deletions(-) diff --git a/f/web-kboss/src/store/modules/user.js b/f/web-kboss/src/store/modules/user.js index 7cf77e2..c80c0b0 100644 --- a/f/web-kboss/src/store/modules/user.js +++ b/f/web-kboss/src/store/modules/user.js @@ -7,6 +7,12 @@ import store from "@/store"; import {myBalanceAPI} from "@/api/finance/customerRechargeManagement"; import {testData} from "@/views/homePage/components/topBox/testData"; +// 安全转换为字符串的辅助函数 +const safeToString = (value, defaultValue = '') => { + if (value == null) return defaultValue; + return value.toString(); +}; + // 从sessionStorage恢复状态 const getStoredState = () => { return { @@ -75,9 +81,18 @@ const mutations = { state.userType = userType; sessionStorage.setItem("userType", userType); }, - // 新增:设置组织类型 + // 修复:设置组织类型 - 添加防御性检查 SET_ORG_TYPE: (state, orgType) => { state.orgType = orgType; + + // 防御性检查,确保 orgType 不为 null 或 undefined + if (orgType == null) { + console.warn('SET_ORG_TYPE: orgType is null or undefined, setting to empty string'); + sessionStorage.setItem("orgType", ''); + return; + } + + // 安全地调用 toString() sessionStorage.setItem("orgType", orgType.toString()); }, // 新增:设置用户角色 @@ -120,7 +135,8 @@ const actions = { const userRoles = org_type == 2 ? ['客户'] : ['管理员']; commit("SET_USER_TYPE", userType); - commit("SET_ORG_TYPE", org_type); + // 确保 org_type 不为 undefined + commit("SET_ORG_TYPE", org_type || ''); commit("SET_ROLES", userRoles); // 新增:设置用户角色 console.log("登录用户类型:", userType, "org_type:", org_type, "用户角色:", userRoles); @@ -171,7 +187,9 @@ const actions = { commit("SET_USER_TYPE", userType); } if (orgType) { - commit("SET_ORG_TYPE", parseInt(orgType)); + // 确保 orgType 不为 null 或 undefined + const safeOrgType = orgType ? parseInt(orgType) : ''; + commit("SET_ORG_TYPE", safeOrgType); } if (roles) { commit("SET_ROLES", JSON.parse(roles)); @@ -190,34 +208,28 @@ const actions = { // user logout logout({commit, state, dispatch}) { return new Promise((resolve, reject) => { - // logout(state.token) - // .then(() => { - commit("SET_TOKEN", ""); - commit("SET_ROLES", []); - commit("SET_USER_TYPE", ""); // 新增:清除用户类型 - commit("SET_ORG_TYPE", ""); // 新增:清除组织类型 - commit("SET_USER", ""); - commit("SET_AUTHS", []); - removeToken(); - resetRouter(); + commit("SET_TOKEN", ""); + commit("SET_ROLES", []); + commit("SET_USER_TYPE", ""); // 新增:清除用户类型 + commit("SET_ORG_TYPE", ""); // 新增:清除组织类型 + commit("SET_USER", ""); + commit("SET_AUTHS", []); + removeToken(); + resetRouter(); - // 清除sessionStorage - sessionStorage.removeItem('user'); - sessionStorage.removeItem('auths'); - sessionStorage.removeItem('userType'); - sessionStorage.removeItem('orgType'); - sessionStorage.removeItem('mybalance'); - sessionStorage.removeItem('roles'); // 新增:清除角色信息 + // 清除sessionStorage + sessionStorage.removeItem('user'); + sessionStorage.removeItem('auths'); + sessionStorage.removeItem('userType'); + sessionStorage.removeItem('orgType'); + sessionStorage.removeItem('mybalance'); + sessionStorage.removeItem('roles'); // 新增:清除角色信息 - // reset visited views and cached views - // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 - dispatch("tagsView/delAllViews", null, {root: true}); + // reset visited views and cached views + // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 + dispatch("tagsView/delAllViews", null, {root: true}); - resolve(); - // }) - // .catch((error) => { - // reject(error); - // }); + resolve(); }); }, @@ -272,3 +284,4 @@ export default { mutations, actions, }; + \ No newline at end of file diff --git a/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue b/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue index 512b270..939e66d 100644 --- a/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue +++ b/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue @@ -14,57 +14,57 @@ -