From 2e363f3f1a3394f73077c4113541df2f72373519 Mon Sep 17 00:00:00 2001 From: yuanteng <1876787513@qq.com> Date: Mon, 18 Aug 2025 09:46:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performanceRanking/performanceRanking.js | 275 +++++++++--------- .../performanceRanking.wxml | 3 +- .../employeeApplyQuery/employeeApplyQuery.js | 120 +++++--- 3 files changed, 206 insertions(+), 192 deletions(-) diff --git a/pages/dashboardModule/performanceRanking/performanceRanking.js b/pages/dashboardModule/performanceRanking/performanceRanking.js index 383357e..6c0736c 100644 --- a/pages/dashboardModule/performanceRanking/performanceRanking.js +++ b/pages/dashboardModule/performanceRanking/performanceRanking.js @@ -14,15 +14,143 @@ Page({ sortOrder: 'descend', sortOrders: ['升序', '降序'], items: [], // 用于存储查询结果 + allItems: [], // 用于存储所有查询数据(用于模糊查询) role: '', // 假设初始为主管角色,可以根据实际情况动态设置 k: 1, showRole: '' }, - // 主管名称输入 + // 页面加载时查询 + onLoad(options) { + const role = options.role; + this.setData({ k: options.k }) + if (role === 'staff') this.setData({ selectedSortField: '推广人数' }) + this.setData({ role }); + let showRole = ''; + switch (options.role) { + case 'manager': + showRole = '主管'; + break; + case 'supervisor': + showRole = '员工'; + break; + case 'staff': + showRole = '员工' + } + this.setData({ showRole }); + + // 执行搜索获取所有数据 + this.onSearch() + }, + + // 搜索按钮点击 + onSearch() { + const { showRole, role } = this.data; + + // 显示加载中 + wx.showLoading({ + title: '加载中...', + mask: true // 显示遮罩层 + }); + + if (showRole === '员工') { + this.setData({ sortField: 'promoCount' }) + } + + const requestData = { + nickName: this.data.nickName, + phoneNumber: this.data.phoneNumber, + sortField: this.data.sortField || '', + sortOrder: this.data.sortOrder || 'ascend' + }; + + if (role === 'manager') { + wx.request({ + url: baseUrl + '/perform/rank/supervisor', // 替换为实际API地址 + method: 'POST', + header: { + Authorization: wx.getStorageSync('token') + }, + data: requestData, + success: (res) => { + wx.hideLoading(); + if (res.data.code === 1) { + this.setData({ + items: res.data.data, + allItems: res.data.data // 将所有数据存储以便后续模糊查询 + }); + } else { + notLogin(res.data.message) + } + }, + fail: () => { + wx.hideLoading(); + wx.showToast({ + title: '请求失败', + icon: 'none' + }); + } + }); + } else if (role === 'supervisor' || role === 'staff') { + wx.request({ + url: baseUrl + '/perform/rank/staff', // 替换为实际API地址 + method: 'POST', + header: { + Authorization: wx.getStorageSync('token') + }, + data: requestData, + success: (res) => { + wx.hideLoading(); + if (res.data.code === 1) { + this.setData({ + items: res.data.data, + allItems: res.data.data // 将所有数据存储以便后续模糊查询 + }); + } else { + wx.showToast({ + title: '没有数据', + icon: 'none' + }); + } + }, + fail: () => { + wx.hideLoading(); + wx.showToast({ + title: '请求失败', + icon: 'none' + }); + } + }); + } + }, + + // 输入主管名称时保存值 onNameInput(e) { + const inputValue = e.detail.value; this.setData({ - nickName: e.detail.value + nickName: inputValue + }); + }, + + // 模糊查询 + onSearchWithFilter() { + const { nickName, allItems } = this.data; + + // 如果没有输入主管名称,则直接显示所有数据 + if (!nickName) { + this.setData({ + items: allItems + }); + return; + } + + // 模糊查询 + const filteredItems = allItems.filter(item => + item.nickName.includes(nickName) // 根据主管名称进行模糊匹配 + ); + + this.setData({ + items: filteredItems }); }, @@ -61,149 +189,10 @@ Page({ this.onSearch() }, - // 搜索按钮点击 - onSearch() { - const { showRole, role } = this.data; -// // —— 新增:校验主管名称 —— -// const nameRegex = /^[\u4e00-\u9fa5]+$/; -// if (!this.data.nickName) { -// wx.showToast({ title: '主管名称不能为空', icon: 'none' }); -// return; -// } -// if (!nameRegex.test(this.data.nickName)) { -// wx.showToast({ title: '主管名称只能为汉字', icon: 'none' }); -// return; -// } - -// // —— 新增:校验手机号 —— -// if (!this.data.phoneNumber) { -// wx.showToast({ title: '手机号不能为空', icon: 'none' }); -// return; -// } -// if (this.data.phoneNumber.length < 11) { -// wx.showToast({ title: '手机号不够11位', icon: 'none' }); -// return; -// } - -// 原排序条件校验,保持不变 -// if (this.data.selectedSortField === '待选择') { -// wx.showToast({ -// title: '排序条件不能为空', -// icon: 'none' -// }); -// return; -// } - - // 显示加载中 - wx.showLoading({ - title: '加载中...', - mask: true // 显示遮罩层 - }); - - if (showRole === '员工') { - this.setData({ sortField: 'promoCount' }) - } - - const requestData = { - nickName: this.data.nickName, - phoneNumber: this.data.phoneNumber, - sortField: this.data.sortField || '', - sortOrder: this.data.sortOrder || 'ascend' - }; - console.log('requestData====>', requestData) - - if(role === 'manager') { - wx.request({ - url: baseUrl + '/perform/rank/supervisor', // 替换为实际API地址 - method: 'POST', - header: { - Authorization: wx.getStorageSync('token') - }, - data: requestData, - success: (res) => { - console.log('看看后端--->', res.data); - // 请求成功后,隐藏loading - wx.hideLoading(); - - if (res.data.code === 1) { - this.setData({ - items: res.data.data - }); - } else { - notLogin(res.data.message) - } - }, - fail: () => { - // 请求失败后,隐藏loading - wx.hideLoading(); - wx.showToast({ - title: '请求失败', - icon: 'none' - }); - } - }); - } else if( role === 'supervisor' || role === 'staff') { - wx.request({ - url: baseUrl + '/perform/rank/staff', // 替换为实际API地址 - method: 'POST', - header: { - Authorization: wx.getStorageSync('token') - }, - data: requestData, - success: (res) => { - console.log('看看后端--->', res.data); - // 请求成功后,隐藏loading - wx.hideLoading(); - - if (res.data.code === 1) { - this.setData({ - items: res.data.data - }); - } else { - wx.showToast({ - title: '没有数据', - icon: 'none' - }); - } - }, - fail: () => { - // 请求失败后,隐藏loading - wx.hideLoading(); - - wx.showToast({ - title: '请求失败', - icon: 'none' - }); - } - }); - } - }, - - onLoad(options) { - // 根据身份确定角色 - const role = options.role; - this.setData({k: options.k}) - if (role === 'staff') this.setData({selectedSortField: '推广人数'}) - console.log('角色---->',options.role); - this.setData({ role }); - let showRole = ''; - switch (options.role) { - case 'manager': - showRole = '主管'; - break; - case 'supervisor': - showRole = '员工'; - break; - case 'staff': - showRole = '员工' - } - this.setData({ showRole }); - this.onSearch() - }, - + // 下拉刷新 onPullDownRefresh() { this.onSearch() wx.stopPullDownRefresh(); }, +}); -}); \ No newline at end of file diff --git a/pages/dashboardModule/performanceRanking/performanceRanking.wxml b/pages/dashboardModule/performanceRanking/performanceRanking.wxml index 076f3ea..0dca975 100644 --- a/pages/dashboardModule/performanceRanking/performanceRanking.wxml +++ b/pages/dashboardModule/performanceRanking/performanceRanking.wxml @@ -76,7 +76,8 @@ - 搜索 + 搜索 + diff --git a/pages/loginModule/employeeApplyQuery/employeeApplyQuery.js b/pages/loginModule/employeeApplyQuery/employeeApplyQuery.js index d6773f8..77602e4 100644 --- a/pages/loginModule/employeeApplyQuery/employeeApplyQuery.js +++ b/pages/loginModule/employeeApplyQuery/employeeApplyQuery.js @@ -7,62 +7,86 @@ Page({ }, // 输入框事件 - onInput(e) { +onInput(e) { + const inputIdCard = e.detail.value; + // 只允许输入数字 + const isValidInput = /^[0-9]*$/.test(inputIdCard); + + if (!isValidInput) { this.setData({ - inputIdCard: e.detail.value // 获取身份证输入 + inputIdCard: inputIdCard.slice(0, -1) // 删除非数字字符 }); - }, + wx.showToast({ + title: '请输入有效的身份证号码', + icon: 'none' + }); + } else { + this.setData({ + inputIdCard + }); + } +}, - // 查询操作 - onSearch() { - const inputIdCard = this.data.inputIdCard; - if (!inputIdCard) { - wx.showToast({ - title: '请输入身份证', - icon: 'none' - }); - return; - } +// 查询操作 +onSearch() { + const inputIdCard = this.data.inputIdCard; - // 查询的接口 - wx.request({ - url: baseUrl + '/advancementApply/query/credential', // 替换为你的后端查询接口 - method: 'POST', - data: { templateString: inputIdCard }, - success: (res) => { - console.log('后端返回---->',res.data); - if (res.data.code === 1) { - // 假设返回的查询结果是以下格式 - const result = res.data.data; // 获取返回的数据 - - // 更新审核状态和查询结果 - this.setData({ - status: result.reviewStatus, // 审核状态 - result: { - name: result.name, // 姓名 - phone: result.phone, // 手机号 - idCard: result.idCard, // 身份证号 - failureReason: result.rejectReason, // 失败原因 - password: result.userPassword, // 密码(如果有的话) - userRole: result.userRole, // 用户级别 - id: result.id - } - }); - } else { - wx.showToast({ - title: res.data.message, - icon: 'none' - }); - } - }, - fail: () => { + // 校验身份证号的有效性 + if (!inputIdCard) { + wx.showToast({ + title: '请输入身份证', + icon: 'none' + }); + return; + } + + if (inputIdCard.length !== 18) { + wx.showToast({ + title: '请输入18位身份证号码', + icon: 'none' + }); + return; + } + + // 查询的接口 + wx.request({ + url: baseUrl + '/advancementApply/query/credential', // 替换为你的后端查询接口 + method: 'POST', + data: { templateString: inputIdCard }, + success: (res) => { + console.log('后端返回---->', res.data); + if (res.data.code === 1) { + // 假设返回的查询结果是以下格式 + const result = res.data.data; // 获取返回的数据 + + // 更新审核状态和查询结果 + this.setData({ + status: result.reviewStatus, // 审核状态 + result: { + name: result.name, // 姓名 + phone: result.phone, // 手机号 + idCard: result.idCard, // 身份证号 + failureReason: result.rejectReason, // 失败原因 + password: result.userPassword, // 密码(如果有的话) + userRole: result.userRole, // 用户级别 + id: result.id + } + }); + } else { wx.showToast({ - title: '请求失败,请重试', + title: res.data.message, icon: 'none' }); } - }); - }, + }, + fail: () => { + wx.showToast({ + title: '请求失败,请重试', + icon: 'none' + }); + } + }); +}, // 重新申请操作 onReapply() {