From 1c0e0b265d5e2feaab626631bc2092a02d54921d Mon Sep 17 00:00:00 2001 From: zhengw <247276359@qq.com> Date: Mon, 2 Feb 2026 16:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/app.json | 9 +- miniprogram/assets/icons/员工管理.svg | 1 + miniprogram/assets/icons/岗位角色.svg | 1 + miniprogram/assets/icons/我的权限.svg | 1 + miniprogram/assets/icons/操作日志.svg | 1 + miniprogram/assets/icons/登录日志.svg | 1 + miniprogram/assets/icons/组织架构.svg | 1 + .../components/card-plugin/card-plugin.ts | 4 +- .../components/card-plugin/card-plugin.wxml | 23 +- miniprogram/pages/logs/loginLog/loginLog.json | 15 ++ miniprogram/pages/logs/loginLog/loginLog.ts | 143 +++++++++++ miniprogram/pages/logs/loginLog/loginLog.wxml | 31 +++ miniprogram/pages/logs/loginLog/loginLog.wxss | 0 .../pages/logs/operateLog/operateLog.json | 15 ++ .../pages/logs/operateLog/operateLog.ts | 133 +++++++++++ .../pages/logs/operateLog/operateLog.wxml | 37 +++ .../pages/logs/operateLog/operateLog.wxss | 0 .../pages/manage/department/department.json | 7 + .../pages/manage/department/department.ts | 166 +++++++++++++ .../pages/manage/department/department.wxml | 32 +++ .../pages/manage/department/department.wxss | 0 miniprogram/pages/manage/group/group.json | 7 + miniprogram/pages/manage/group/group.ts | 175 ++++++++++++++ miniprogram/pages/manage/group/group.wxml | 33 +++ miniprogram/pages/manage/group/group.wxss | 0 .../pages/manage/groupDetail/groupDetail.json | 3 + .../pages/manage/groupDetail/groupDetail.ts | 114 +++++++++ .../pages/manage/groupDetail/groupDetail.wxml | 25 ++ .../pages/manage/groupDetail/groupDetail.wxss | 55 +++++ miniprogram/pages/manage/my/my.json | 4 + miniprogram/pages/manage/my/my.ts | 110 +++++++++ miniprogram/pages/manage/my/my.wxml | 25 ++ miniprogram/pages/manage/my/my.wxss | 55 +++++ miniprogram/pages/manage/staff/staff.json | 15 ++ miniprogram/pages/manage/staff/staff.ts | 223 ++++++++++++++++++ miniprogram/pages/manage/staff/staff.wxml | 65 +++++ miniprogram/pages/manage/staff/staff.wxss | 11 + miniprogram/utils/menuConfig.ts | 44 ++++ 38 files changed, 1575 insertions(+), 10 deletions(-) create mode 100644 miniprogram/assets/icons/员工管理.svg create mode 100644 miniprogram/assets/icons/岗位角色.svg create mode 100644 miniprogram/assets/icons/我的权限.svg create mode 100644 miniprogram/assets/icons/操作日志.svg create mode 100644 miniprogram/assets/icons/登录日志.svg create mode 100644 miniprogram/assets/icons/组织架构.svg create mode 100644 miniprogram/pages/logs/loginLog/loginLog.json create mode 100644 miniprogram/pages/logs/loginLog/loginLog.ts create mode 100644 miniprogram/pages/logs/loginLog/loginLog.wxml create mode 100644 miniprogram/pages/logs/loginLog/loginLog.wxss create mode 100644 miniprogram/pages/logs/operateLog/operateLog.json create mode 100644 miniprogram/pages/logs/operateLog/operateLog.ts create mode 100644 miniprogram/pages/logs/operateLog/operateLog.wxml create mode 100644 miniprogram/pages/logs/operateLog/operateLog.wxss create mode 100644 miniprogram/pages/manage/department/department.json create mode 100644 miniprogram/pages/manage/department/department.ts create mode 100644 miniprogram/pages/manage/department/department.wxml create mode 100644 miniprogram/pages/manage/department/department.wxss create mode 100644 miniprogram/pages/manage/group/group.json create mode 100644 miniprogram/pages/manage/group/group.ts create mode 100644 miniprogram/pages/manage/group/group.wxml create mode 100644 miniprogram/pages/manage/group/group.wxss create mode 100644 miniprogram/pages/manage/groupDetail/groupDetail.json create mode 100644 miniprogram/pages/manage/groupDetail/groupDetail.ts create mode 100644 miniprogram/pages/manage/groupDetail/groupDetail.wxml create mode 100644 miniprogram/pages/manage/groupDetail/groupDetail.wxss create mode 100644 miniprogram/pages/manage/my/my.json create mode 100644 miniprogram/pages/manage/my/my.ts create mode 100644 miniprogram/pages/manage/my/my.wxml create mode 100644 miniprogram/pages/manage/my/my.wxss create mode 100644 miniprogram/pages/manage/staff/staff.json create mode 100644 miniprogram/pages/manage/staff/staff.ts create mode 100644 miniprogram/pages/manage/staff/staff.wxml create mode 100644 miniprogram/pages/manage/staff/staff.wxss diff --git a/miniprogram/app.json b/miniprogram/app.json index a987251..3066e68 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -19,7 +19,14 @@ "pages/purchase/backOrder/backOrder", "pages/base/supplier/supplier", "pages/base/customer/customer", - "pages/base/account/account" + "pages/base/account/account", + "pages/manage/department/department", + "pages/manage/groupDetail/groupDetail", + "pages/manage/group/group", + "pages/manage/my/my", + "pages/logs/loginLog/loginLog", + "pages/logs/operateLog/operateLog", + "pages/manage/staff/staff" ], "window": { "navigationBarTextStyle": "black", diff --git a/miniprogram/assets/icons/员工管理.svg b/miniprogram/assets/icons/员工管理.svg new file mode 100644 index 0000000..0ceed59 --- /dev/null +++ b/miniprogram/assets/icons/员工管理.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/assets/icons/岗位角色.svg b/miniprogram/assets/icons/岗位角色.svg new file mode 100644 index 0000000..4909b09 --- /dev/null +++ b/miniprogram/assets/icons/岗位角色.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/assets/icons/我的权限.svg b/miniprogram/assets/icons/我的权限.svg new file mode 100644 index 0000000..c239ddf --- /dev/null +++ b/miniprogram/assets/icons/我的权限.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/assets/icons/操作日志.svg b/miniprogram/assets/icons/操作日志.svg new file mode 100644 index 0000000..f62e21e --- /dev/null +++ b/miniprogram/assets/icons/操作日志.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/assets/icons/登录日志.svg b/miniprogram/assets/icons/登录日志.svg new file mode 100644 index 0000000..c9c71d4 --- /dev/null +++ b/miniprogram/assets/icons/登录日志.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/assets/icons/组织架构.svg b/miniprogram/assets/icons/组织架构.svg new file mode 100644 index 0000000..b601935 --- /dev/null +++ b/miniprogram/assets/icons/组织架构.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/pages/components/card-plugin/card-plugin.ts b/miniprogram/pages/components/card-plugin/card-plugin.ts index 96629f4..bac6638 100644 --- a/miniprogram/pages/components/card-plugin/card-plugin.ts +++ b/miniprogram/pages/components/card-plugin/card-plugin.ts @@ -13,6 +13,8 @@ Component({ headerStyle: null, contentStyle: null, footerStyle: null, + showMoreBar: { type: Boolean, value: true }, + showAll: { type: Boolean, value: false }, }, lifetimes: { attached() { @@ -27,7 +29,7 @@ Component({ */ data: { showMore: false, - showMoreBar: true, + // showMoreBar: true, }, /** * 组件的方法列表 diff --git a/miniprogram/pages/components/card-plugin/card-plugin.wxml b/miniprogram/pages/components/card-plugin/card-plugin.wxml index af1934c..3c58df2 100644 --- a/miniprogram/pages/components/card-plugin/card-plugin.wxml +++ b/miniprogram/pages/components/card-plugin/card-plugin.wxml @@ -6,14 +6,21 @@ - - - - - {{showMore ? '收起' : '显示更多' }} - - + + + + + + + + + + + {{showMore ? '收起' : '显示更多' }} + + + diff --git a/miniprogram/pages/logs/loginLog/loginLog.json b/miniprogram/pages/logs/loginLog/loginLog.json new file mode 100644 index 0000000..5040513 --- /dev/null +++ b/miniprogram/pages/logs/loginLog/loginLog.json @@ -0,0 +1,15 @@ +{ + "usingComponents": { + "search-popup": "/pages/components/search-popup/search-popup", + "card-plugin": "/pages/components/card-plugin/card-plugin", + "card-item-plugin": "/pages/components/card-item-plugin/card-item-plugin", + "option-cell-plugin": "/pages/components/option-cell-plugin/option-cell-plugin", + "date-picker-plugin": "/pages/components/date-picker-plugin/date-picker-plugin", + "sort-plugin": "/pages/components/sort-plugin/sort-plugin", + "count-plugin": "/pages/components/count-plugin/count-plugin", + "total-bar-plugin": "/pages/components/total-bar-plugin/total-bar-plugin", + "pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin", + "search-input": "/pages/components/search-input/search-input" + }, + "navigationBarTitleText": "登录日志" +} \ No newline at end of file diff --git a/miniprogram/pages/logs/loginLog/loginLog.ts b/miniprogram/pages/logs/loginLog/loginLog.ts new file mode 100644 index 0000000..a55fda8 --- /dev/null +++ b/miniprogram/pages/logs/loginLog/loginLog.ts @@ -0,0 +1,143 @@ +import { loginStatus, post } from '@/utils/https'; +import { cloneLite, getAuthInfo, getDataSet, toArray, toNumber } from '@/utils/util'; + +const defaultParams = { curr_page: 1, page_count: 20 }; + +Page({ + /** + * 页面的初始数据 + */ + data: { + params: cloneLite(defaultParams) as any, + list: [] as any[], + count: 0, + sort: [{ label: '创建日期', value: 'create_date' }], + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + }, + searchChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchChange2(e: any) { + const key = getDataSet(e).key; + const val = `${e.detail.value || ''}`.trim(); + if (val) { + this.data.params[key] = val; + } else { + delete this.data.params[key]; + } + this.setData({ params: this.data.params }); + }, + onOptionChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + datePickerConfirm(e: any) { + const data = getDataSet(e); + this.data.params[data.key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchOk() { + this.getList(1); + }, + searchReset() { + this.data.params = cloneLite(defaultParams); + this.getList(1); + }, + onSort(e: any) { + this.data.params.order = e.detail.value; + this.setData({ params: this.data.params }); + this.getList(1); + }, + paginationChange(e: any) { + this.getList(e.detail.curr_page); + }, + getList(curr: number = 1) { + this.data.params.curr_page = curr; + this.setData({ params: this.data.params }); + const temp = cloneLite(this.data.params); + + post('Log/loginList', temp).then((res: any) => { + const list = toArray(res.data?.list); + if (list.length == 0 && this.data.params.curr_page > 1) { + this.getList(this.data.params.curr_page - 1); + } + this.setData({ + count: toNumber(res.data?.count), + list: list.map((el) => { + el.address = ''; + if (el.detail) { + const obj = JSON.parse(el.detail); + const arr = ['province', 'city'] + .map((key) => obj[key]) // 取出字段值 + .filter(Boolean); + el.address = arr.length ? arr.join(',') : ''; + } + return el; + }), + }); + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(_options) {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/logs/loginLog/loginLog.wxml b/miniprogram/pages/logs/loginLog/loginLog.wxml new file mode 100644 index 0000000..b3b7e8e --- /dev/null +++ b/miniprogram/pages/logs/loginLog/loginLog.wxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + {{ item.login_name }} + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/logs/loginLog/loginLog.wxss b/miniprogram/pages/logs/loginLog/loginLog.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/pages/logs/operateLog/operateLog.json b/miniprogram/pages/logs/operateLog/operateLog.json new file mode 100644 index 0000000..cf397c5 --- /dev/null +++ b/miniprogram/pages/logs/operateLog/operateLog.json @@ -0,0 +1,15 @@ +{ + "usingComponents": { + "search-popup": "/pages/components/search-popup/search-popup", + "card-plugin": "/pages/components/card-plugin/card-plugin", + "card-item-plugin": "/pages/components/card-item-plugin/card-item-plugin", + "option-cell-plugin": "/pages/components/option-cell-plugin/option-cell-plugin", + "date-picker-plugin": "/pages/components/date-picker-plugin/date-picker-plugin", + "sort-plugin": "/pages/components/sort-plugin/sort-plugin", + "count-plugin": "/pages/components/count-plugin/count-plugin", + "total-bar-plugin": "/pages/components/total-bar-plugin/total-bar-plugin", + "pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin", + "search-input": "/pages/components/search-input/search-input" + }, + "navigationBarTitleText": "操作日志" +} \ No newline at end of file diff --git a/miniprogram/pages/logs/operateLog/operateLog.ts b/miniprogram/pages/logs/operateLog/operateLog.ts new file mode 100644 index 0000000..86a34dc --- /dev/null +++ b/miniprogram/pages/logs/operateLog/operateLog.ts @@ -0,0 +1,133 @@ +import { loginStatus, post } from '@/utils/https'; +import { cloneLite, getAuthInfo, getDataSet, toArray, toNumber } from '@/utils/util'; + +const defaultParams = { curr_page: 1, page_count: 20 }; + +Page({ + /** + * 页面的初始数据 + */ + data: { + params: cloneLite(defaultParams) as any, + list: [] as any[], + count: 0, + sort: [{ label: '创建日期', value: 'create_date' }], + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + }, + searchChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchChange2(e: any) { + const key = getDataSet(e).key; + const val = `${e.detail.value || ''}`.trim(); + if (val) { + this.data.params[key] = val; + } else { + delete this.data.params[key]; + } + this.setData({ params: this.data.params }); + }, + onOptionChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + datePickerConfirm(e: any) { + const data = getDataSet(e); + this.data.params[data.key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchOk() { + this.getList(1); + }, + searchReset() { + this.data.params = cloneLite(defaultParams); + this.getList(1); + }, + onSort(e: any) { + this.data.params.order = e.detail.value; + this.setData({ params: this.data.params }); + this.getList(1); + }, + paginationChange(e: any) { + this.getList(e.detail.curr_page); + }, + getList(curr: number = 1) { + this.data.params.curr_page = curr; + this.setData({ params: this.data.params }); + const temp = cloneLite(this.data.params); + + post('Log/operateList', temp).then((res: any) => { + const list = toArray(res.data?.list); + if (list.length == 0 && this.data.params.curr_page > 1) { + this.getList(this.data.params.curr_page - 1); + } + this.setData({ + count: toNumber(res.data?.count), + list: list, + }); + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(_options) {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/logs/operateLog/operateLog.wxml b/miniprogram/pages/logs/operateLog/operateLog.wxml new file mode 100644 index 0000000..57d5ee2 --- /dev/null +++ b/miniprogram/pages/logs/operateLog/operateLog.wxml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + {{ item.menu_ch_name }}({{item.function_ch_name}}) + + + + + {{item.login_name}} + ({{item.nick_name}}) + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/logs/operateLog/operateLog.wxss b/miniprogram/pages/logs/operateLog/operateLog.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/pages/manage/department/department.json b/miniprogram/pages/manage/department/department.json new file mode 100644 index 0000000..0f2b0a8 --- /dev/null +++ b/miniprogram/pages/manage/department/department.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "t-cell": "tdesign-miniprogram/cell/cell", + "t-cell-group": "tdesign-miniprogram/cell-group/cell-group" + }, + "navigationBarTitleText": "组织架构" +} \ No newline at end of file diff --git a/miniprogram/pages/manage/department/department.ts b/miniprogram/pages/manage/department/department.ts new file mode 100644 index 0000000..a401e51 --- /dev/null +++ b/miniprogram/pages/manage/department/department.ts @@ -0,0 +1,166 @@ +import { loginStatus, post } from '@/utils/https'; +import { + cloneLite, + getAuthInfo, + getDataSet, + showModal, + sleep, + toArray, + toastSuccess, +} from '@/utils/util'; + +const defaultParams = { curr_page: 1, page_count: 20, head_type: 1 }; + +Page({ + /** + * 页面的初始数据 + */ + data: { + params: cloneLite(defaultParams) as any, + list: [] as any[], + states: [ + { value: '', label: '全部' }, + { value: '1', label: '未审核' }, + { value: '2', label: '已审核' }, + ], + sort: [{ label: '创建日期', value: 'create_date' }], + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + }, + searchChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchChange2(e: any) { + const key = getDataSet(e).key; + const val = `${e.detail.value || ''}`.trim(); + if (val) { + this.data.params[key] = val; + } else { + delete this.data.params[key]; + } + this.setData({ params: this.data.params }); + }, + onOptionChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + datePickerConfirm(e: any) { + const data = getDataSet(e); + this.data.params[data.key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchOk() { + this.getList(1); + }, + searchReset() { + this.data.params = cloneLite(defaultParams); + this.getList(1); + }, + onSort(e: any) { + this.data.params.order = e.detail.value; + this.setData({ params: this.data.params }); + this.getList(1); + }, + paginationChange(e: any) { + this.getList(e.detail.curr_page); + }, + getList(curr: number = 1) { + this.data.params.curr_page = curr; + this.setData({ params: this.data.params }); + const temp = cloneLite(this.data.params); + if (temp.order_step && temp.order_step.length) { + temp.order_step = temp.order_step.join(','); + } else { + delete temp.order_step; + } + + if (temp.process_state && temp.process_state.length) { + temp.process_state = temp.process_state.join(','); + } else { + delete temp.process_state; + } + + post('Departments/list', temp).then((res: any) => { + const list = toArray(res.data); + if (list.length == 0 && this.data.params.curr_page > 1) { + this.getList(this.data.params.curr_page - 1); + } + this.setData({ list: list }); + }); + }, + + onOrderDel(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + showModal({ content: `确认删除 ${item.name}?` }).then(() => { + post('Departments/del', { department_id: item.department_id }).then(() => { + toastSuccess('删除成功'); + sleep(() => { + this.getList(); + }, 1000); + }); + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(_options) {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/manage/department/department.wxml b/miniprogram/pages/manage/department/department.wxml new file mode 100644 index 0000000..f9ca661 --- /dev/null +++ b/miniprogram/pages/manage/department/department.wxml @@ -0,0 +1,32 @@ + + + + + + + 删除 + + + + \ No newline at end of file diff --git a/miniprogram/pages/manage/department/department.wxss b/miniprogram/pages/manage/department/department.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/pages/manage/group/group.json b/miniprogram/pages/manage/group/group.json new file mode 100644 index 0000000..d288ee8 --- /dev/null +++ b/miniprogram/pages/manage/group/group.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "t-cell": "tdesign-miniprogram/cell/cell", + "t-cell-group": "tdesign-miniprogram/cell-group/cell-group" + }, + "navigationBarTitleText": "岗位角色" +} \ No newline at end of file diff --git a/miniprogram/pages/manage/group/group.ts b/miniprogram/pages/manage/group/group.ts new file mode 100644 index 0000000..3b7cdff --- /dev/null +++ b/miniprogram/pages/manage/group/group.ts @@ -0,0 +1,175 @@ +import { loginStatus, post } from '@/utils/https'; +import { + cloneLite, + getAuthInfo, + getDataSet, + showModal, + sleep, + toArray, + toastSuccess, +} from '@/utils/util'; + +const defaultParams = { curr_page: 1, page_count: 20, head_type: 1 }; + +Page({ + /** + * 页面的初始数据 + */ + data: { + params: cloneLite(defaultParams) as any, + list: [] as any[], + states: [ + { value: '', label: '全部' }, + { value: '1', label: '未审核' }, + { value: '2', label: '已审核' }, + ], + sort: [{ label: '创建日期', value: 'create_date' }], + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + }, + searchChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchChange2(e: any) { + const key = getDataSet(e).key; + const val = `${e.detail.value || ''}`.trim(); + if (val) { + this.data.params[key] = val; + } else { + delete this.data.params[key]; + } + this.setData({ params: this.data.params }); + }, + onOptionChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + datePickerConfirm(e: any) { + const data = getDataSet(e); + this.data.params[data.key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchOk() { + this.getList(1); + }, + searchReset() { + this.data.params = cloneLite(defaultParams); + this.getList(1); + }, + onSort(e: any) { + this.data.params.order = e.detail.value; + this.setData({ params: this.data.params }); + this.getList(1); + }, + paginationChange(e: any) { + this.getList(e.detail.curr_page); + }, + getList(curr: number = 1) { + this.data.params.curr_page = curr; + this.setData({ params: this.data.params }); + const temp = cloneLite(this.data.params); + if (temp.order_step && temp.order_step.length) { + temp.order_step = temp.order_step.join(','); + } else { + delete temp.order_step; + } + + if (temp.process_state && temp.process_state.length) { + temp.process_state = temp.process_state.join(','); + } else { + delete temp.process_state; + } + + post('Groups/list', temp).then((res: any) => { + const list = toArray(res.data); + if (list.length == 0 && this.data.params.curr_page > 1) { + this.getList(this.data.params.curr_page - 1); + } + this.setData({ list: list }); + }); + }, + onGroupTap(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + wx.navigateTo({ + url: `/pages/manage/groupDetail/groupDetail?group_id=${ + item.group_id + }&name=${encodeURIComponent(item.name)}`, + }); + }, + onOrderDel(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + showModal({ content: `确认删除 ${item.name}?` }).then(() => { + post('Groups/del', { group_id: item.group_id }).then(() => { + toastSuccess('删除成功'); + sleep(() => { + this.getList(); + }, 1000); + }); + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(_options) {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/manage/group/group.wxml b/miniprogram/pages/manage/group/group.wxml new file mode 100644 index 0000000..a1b292f --- /dev/null +++ b/miniprogram/pages/manage/group/group.wxml @@ -0,0 +1,33 @@ + + + + + + + 删除 + + + + \ No newline at end of file diff --git a/miniprogram/pages/manage/group/group.wxss b/miniprogram/pages/manage/group/group.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/pages/manage/groupDetail/groupDetail.json b/miniprogram/pages/manage/groupDetail/groupDetail.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram/pages/manage/groupDetail/groupDetail.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/pages/manage/groupDetail/groupDetail.ts b/miniprogram/pages/manage/groupDetail/groupDetail.ts new file mode 100644 index 0000000..220c257 --- /dev/null +++ b/miniprogram/pages/manage/groupDetail/groupDetail.ts @@ -0,0 +1,114 @@ +import { loginStatus, post } from '@/utils/https'; +import { getAuthInfo, toArray } from '@/utils/util'; + +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [] as any[], + group_id: '', + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + }, + + getList() { + post('Groups/getGrpRights', { group_id: this.data.group_id }).then((res: any) => { + const list = toArray(res.right_tree); + const rights = `${res.rights || ''}`.split(','); + this.data.list.length = 0; + + toArray(list).forEach((menu) => { + const arr: any[] = []; + toArray(menu.children).forEach((menu2) => { + let flag = false; + toArray(menu2.children).forEach((fun) => { + fun.web_checked = rights.includes(`${fun.function_id}`); + if (fun.web_checked) { + flag = true; + } + }); + + if (flag) { + arr.push({ + menu_ch_name: menu2.menu_ch_name, + menu_id: menu2.menu_id, + functions: toArray(menu2.children), + }); + } + }); + if (arr.length) { + this.data.list.push({ + menu_ch_name: menu.menu_ch_name, + menu_id: menu.menu_id, + children: arr, + }); + } + }); + // console.log(this.data.list); + this.setData({ list: this.data.list }); + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.data.group_id = `${options.group_id}`; + wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` }); + + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() {}, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/manage/groupDetail/groupDetail.wxml b/miniprogram/pages/manage/groupDetail/groupDetail.wxml new file mode 100644 index 0000000..130909c --- /dev/null +++ b/miniprogram/pages/manage/groupDetail/groupDetail.wxml @@ -0,0 +1,25 @@ + + + + + 菜单名称 + 目录名称 + 权限点 + + + + {{item.menu_ch_name}} + + + {{item2.menu_ch_name}} + + + {{item.function_ch_name}} + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/manage/groupDetail/groupDetail.wxss b/miniprogram/pages/manage/groupDetail/groupDetail.wxss new file mode 100644 index 0000000..2c0bbbb --- /dev/null +++ b/miniprogram/pages/manage/groupDetail/groupDetail.wxss @@ -0,0 +1,55 @@ +.header, +.content { + display: flex; + font-size: 14px; + border-left: 1rpx solid #ddd; + border-right: 1rpx solid #ddd; + box-sizing: border-box; +} + +.header { + border-top: 1rpx solid #ddd; + background: #f5f5f5; + font-weight: bold; +} + +.top { + position: sticky; + top: 0; + z-index: 1; + padding-top: 24rpx; + background: #fff; +} + +.content { + /* flex-direction: column; */ + align-items: stretch; +} + +.name, +.name2 { + width: 5.5em; + flex-shrink: 0; + border-bottom: 1rpx solid #ddd; + border-right: 1rpx solid #ddd; + min-width: 0; + display: flex; + align-items: center; + padding: 12rpx 0.5em; + word-break: break-all; + box-sizing: border-box; +} + +.name2 { + width: 6.5em; +} + +.functions { + border-bottom: 1rpx solid #ddd; + flex: 1; + display: flex; + column-gap: 0.5em; + row-gap: 12rpx; + flex-wrap: wrap; + padding: 0.5em; +} diff --git a/miniprogram/pages/manage/my/my.json b/miniprogram/pages/manage/my/my.json new file mode 100644 index 0000000..8ba8a6a --- /dev/null +++ b/miniprogram/pages/manage/my/my.json @@ -0,0 +1,4 @@ +{ + "usingComponents": { }, + "navigationBarTitleText": "我的权限" +} \ No newline at end of file diff --git a/miniprogram/pages/manage/my/my.ts b/miniprogram/pages/manage/my/my.ts new file mode 100644 index 0000000..d53c3f6 --- /dev/null +++ b/miniprogram/pages/manage/my/my.ts @@ -0,0 +1,110 @@ +import { loginStatus, post } from '@/utils/https'; +import { getAuthInfo, toArray } from '@/utils/util'; + +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [] as any[], + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + }, + + getList() { + post('Groups/myAuth').then((res: any) => { + const list = toArray(res.right_tree); + const rights = `${res.rights || ''}`.split(','); + this.data.list.length = 0; + + toArray(list).forEach((menu) => { + const arr: any[] = []; + toArray(menu.children).forEach((menu2) => { + let flag = false; + toArray(menu2.children).forEach((fun) => { + fun.web_checked = rights.includes(`${fun.function_id}`); + if (fun.web_checked) { + flag = true; + } + }); + + if (flag) { + arr.push({ + menu_ch_name: menu2.menu_ch_name, + menu_id: menu2.menu_id, + functions: toArray(menu2.children), + }); + } + }); + if (arr.length) { + this.data.list.push({ + menu_ch_name: menu.menu_ch_name, + menu_id: menu.menu_id, + children: arr, + }); + } + }); + // console.log(this.data.list); + this.setData({ list: this.data.list }); + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(_options) { + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() {}, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/manage/my/my.wxml b/miniprogram/pages/manage/my/my.wxml new file mode 100644 index 0000000..130909c --- /dev/null +++ b/miniprogram/pages/manage/my/my.wxml @@ -0,0 +1,25 @@ + + + + + 菜单名称 + 目录名称 + 权限点 + + + + {{item.menu_ch_name}} + + + {{item2.menu_ch_name}} + + + {{item.function_ch_name}} + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/manage/my/my.wxss b/miniprogram/pages/manage/my/my.wxss new file mode 100644 index 0000000..2c0bbbb --- /dev/null +++ b/miniprogram/pages/manage/my/my.wxss @@ -0,0 +1,55 @@ +.header, +.content { + display: flex; + font-size: 14px; + border-left: 1rpx solid #ddd; + border-right: 1rpx solid #ddd; + box-sizing: border-box; +} + +.header { + border-top: 1rpx solid #ddd; + background: #f5f5f5; + font-weight: bold; +} + +.top { + position: sticky; + top: 0; + z-index: 1; + padding-top: 24rpx; + background: #fff; +} + +.content { + /* flex-direction: column; */ + align-items: stretch; +} + +.name, +.name2 { + width: 5.5em; + flex-shrink: 0; + border-bottom: 1rpx solid #ddd; + border-right: 1rpx solid #ddd; + min-width: 0; + display: flex; + align-items: center; + padding: 12rpx 0.5em; + word-break: break-all; + box-sizing: border-box; +} + +.name2 { + width: 6.5em; +} + +.functions { + border-bottom: 1rpx solid #ddd; + flex: 1; + display: flex; + column-gap: 0.5em; + row-gap: 12rpx; + flex-wrap: wrap; + padding: 0.5em; +} diff --git a/miniprogram/pages/manage/staff/staff.json b/miniprogram/pages/manage/staff/staff.json new file mode 100644 index 0000000..4106850 --- /dev/null +++ b/miniprogram/pages/manage/staff/staff.json @@ -0,0 +1,15 @@ +{ + "usingComponents": { + "search-popup": "/pages/components/search-popup/search-popup", + "card-plugin": "/pages/components/card-plugin/card-plugin", + "card-item-plugin": "/pages/components/card-item-plugin/card-item-plugin", + "option-cell-plugin": "/pages/components/option-cell-plugin/option-cell-plugin", + "date-picker-plugin": "/pages/components/date-picker-plugin/date-picker-plugin", + "sort-plugin": "/pages/components/sort-plugin/sort-plugin", + "count-plugin": "/pages/components/count-plugin/count-plugin", + "total-bar-plugin": "/pages/components/total-bar-plugin/total-bar-plugin", + "pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin", + "search-input": "/pages/components/search-input/search-input" + }, + "navigationBarTitleText": "员工管理" +} \ No newline at end of file diff --git a/miniprogram/pages/manage/staff/staff.ts b/miniprogram/pages/manage/staff/staff.ts new file mode 100644 index 0000000..6238b15 --- /dev/null +++ b/miniprogram/pages/manage/staff/staff.ts @@ -0,0 +1,223 @@ +import { loginStatus, post } from '@/utils/https'; +import { + cloneLite, + getAuthInfo, + getDataSet, + showModal, + sleep, + toArray, + toastSuccess, + toNumber, +} from '@/utils/util'; + +const defaultParams = { curr_page: 1, page_count: 20 }; + +Page({ + /** + * 页面的初始数据 + */ + data: { + params: cloneLite(defaultParams) as any, + list: [] as any[], + count: 0, + orderStep: [] as any[], + sort: [ + { label: '部门', value: 'dep_name' }, + { label: '岗位', value: 'group_id' }, + { label: '状态', value: 'state' }, + { label: '创建日期', value: 'create_date' }, + ], + user_id: wx.getStorageSync('user_id'), + depOption: [] as any[], + groupsOption: [] as any[], + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + this.getList(); + this.getOrderStep(); + }, + searchChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchChange2(e: any) { + const key = getDataSet(e).key; + const val = `${e.detail.value || ''}`.trim(); + if (val) { + this.data.params[key] = val; + } else { + delete this.data.params[key]; + } + this.setData({ params: this.data.params }); + }, + onOptionChange(e: any) { + const key = getDataSet(e).key; + this.data.params[key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + datePickerConfirm(e: any) { + const data = getDataSet(e); + this.data.params[data.key] = e.detail.value; + this.setData({ params: this.data.params }); + }, + searchOk() { + this.getList(1); + }, + searchReset() { + this.data.params = cloneLite(defaultParams); + this.getList(1); + }, + onSort(e: any) { + this.data.params.order = e.detail.value; + this.setData({ params: this.data.params }); + this.getList(1); + }, + onSearchState(e: any) { + const key = getDataSet(e).key; + if (key) { + this.data.params.state = key; + } else { + delete this.data.params.state; + } + this.setData({ params: this.data.params }); + this.getList(1); + }, + paginationChange(e: any) { + this.getList(e.detail.curr_page); + }, + getOrderStep() { + post('Departments/list').then((res: any) => { + this.setData({ + depOption: [ + { label: '全部', value: '' }, + ...toArray(res.data).map((el) => ({ + label: el.name, + value: el.department_id, + })), + ], + }); + }); + post('Groups/list').then((res: any) => { + this.setData({ + groupsOption: [ + { label: '全部', value: '' }, + ...toArray(res.data).map((el) => ({ + label: el.name, + value: el.group_id, + })), + ], + }); + }); + }, + getList(curr: number = 1) { + this.data.params.curr_page = curr; + this.setData({ params: this.data.params }); + const temp = cloneLite(this.data.params); + + post('Users/getStaff', temp).then((res: any) => { + const list = toArray(res.data); + if (list.length == 0 && this.data.params.curr_page > 1) { + this.getList(this.data.params.curr_page - 1); + } + this.setData({ count: toNumber(res.count), list: list }); + }); + }, + onReinstatedStaff(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + showModal({ content: `确认复职 ${item.login_name}?` }).then(() => { + post('Users/reinstatedStaff', { staff_id: item.staff_id }).then(() => { + toastSuccess('复职成功'); + sleep(() => { + this.getList(); + }, 1000); + }); + }); + }, + onFireStaff(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + showModal({ content: `确认解雇 ${item.login_name}?` }).then(() => { + post('Users/fireStaff', { staff_id: item.staff_id }).then(() => { + toastSuccess('解雇成功'); + sleep(() => { + this.getList(); + }, 1000); + }); + }); + }, + onStaffState(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + showModal({ content: `确认${item.state == 1 ? '禁用' : '启用'} ${item.login_name}?` }).then( + () => { + post('Users/setStaffState', { staff_id: item.staff_id }).then(() => { + toastSuccess(`${item.state == 1 ? '禁用' : '启用'}成功`); + sleep(() => { + this.getList(); + }, 1000); + }); + }, + ); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(_options) {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + this.setData({ loading: true }); + loginStatus() + .then(() => { + this.setData({ isLogin: true, loading: false }); + this.init(); + }) + .catch((err) => { + this.setData({ isLogin: false, loading: false }); + console.log('调用登录状态请求失败', err); + }); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/manage/staff/staff.wxml b/miniprogram/pages/manage/staff/staff.wxml new file mode 100644 index 0000000..1c09a35 --- /dev/null +++ b/miniprogram/pages/manage/staff/staff.wxml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + 在职员工 + 离职员工 + + + + + + + + {{ item.login_name }} + ({{item.nick_name}}) + + + {{ item.state== 1 ? '正常' : '禁用'}} + + + + + + + + + + + 复职 + + + 解雇 + {{ item.state== 1 ? '禁用' : '启用'}} + + + + + \ No newline at end of file diff --git a/miniprogram/pages/manage/staff/staff.wxss b/miniprogram/pages/manage/staff/staff.wxss new file mode 100644 index 0000000..63f5d29 --- /dev/null +++ b/miniprogram/pages/manage/staff/staff.wxss @@ -0,0 +1,11 @@ +button.btn-left, +button.btn-left::after { + border-bottom-right-radius: 0; + border-top-right-radius: 0; +} + +button.btn-right, +button.btn-right::after { + border-bottom-left-radius: 0; + border-top-left-radius: 0; +} diff --git a/miniprogram/utils/menuConfig.ts b/miniprogram/utils/menuConfig.ts index 1b39a9d..91f0a52 100644 --- a/miniprogram/utils/menuConfig.ts +++ b/miniprogram/utils/menuConfig.ts @@ -116,4 +116,48 @@ export const menuConfig = [ }, ], }, + { + title: '用户管理', + icon: 'usergroup', + iconColor: iconColor, + children: [ + { + title: '组织架构', + url: '/pages/manage/department/department', + auth: 'SF_ERP_DEPART_VIEW', + }, + { + title: '岗位角色', + url: '/pages/manage/group/group', + auth: 'SF_ERP_GROUP_VIEW', + }, + { + title: '员工管理', + url: '/pages/manage/staff/staff', + auth: 'SF_ERP_STAFF_VIEW', + }, + { + title: '我的权限', + url: '/pages/manage/my/my', + auth: 'SF_MY_RIGHT_VIEW', + }, + ], + }, + { + title: '日志查看', + icon: 'catalog', + iconColor: iconColor, + children: [ + { + title: '登录日志', + url: '/pages/logs/loginLog/loginLog', + auth: 'SF_ERP_LOG_VIEW', + }, + { + title: '操作日志', + url: '/pages/logs/operateLog/operateLog', + auth: 'SF_ERP_LOG_VIEW', + }, + ], + }, ];