123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- tabShow: true,
- auth: {}, //权限
- butText: "", //按钮类型
- content: {
- "pageNumber": 1,
- "pageSize": 20,
- "pageTotal": 1,
- "where": {
- "condition": ""
- }
- }
- },
- onLoad(options) {
- let auth = options.auth ? JSON.parse(options.auth) : getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心'])[0].apps[0].meta.auth,
- authList = auth.map(v => v.optionname);
- let tabShow = false,
- butText = '账号';
- if (authList.includes('查看账号') && authList.includes('查看角色')) {
- tabShow = true;
- } else {
- butText = authList.includes('查看角色') ? '角色' : '账号';
- }
- this.setData({
- tabShow,
- butText,
- authList
- })
- this.getList();
- getApp().globalData.Language.getLanguagePackage(this, '团队管理');
- },
- /* 获取列表 */
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) this.setData({
- ['content.pageNumber']: 1
- })
- if (this.data.content.pageNumber > this.data.content.pageTotal) return;
- _Http.basic({
- "id": this.data.butText == '账号' ? "20221107094704" : "20221109091404",
- "content": this.data.content
- }).then(res => {
- this.selectComponent('#ListBox').RefreshToComplete();
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- if (this.data.butText == '账号') {
- for (let i = 0; i < res.data.length; i++) {
- res.data[i].attinfos = res.data[i].attinfos.filter(v => v.usetype == 'headportrait');
- }
- }
- this.setData({
- list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
- ['content.pageNumber']: res.pageNumber + 1,
- ['content.pageTotal']: res.pageTotal
- })
- })
- },
- /* 新建账号/角色 */
- newItem() {
- if (this.data.butText == '账号') {
- wx.navigateTo({
- url: '/pages/teams/addUsers'
- })
- } else {
- wx.navigateTo({
- url: '/pages/teams/addRole'
- })
- }
- },
- /* tab切换 */
- tabChange(e) {
- this.setData({
- butText: e.detail.name.slice(0, 2),
- list: [],
- })
- this.getList(true);
- },
- /* 修改角色 */
- changeRole(e) {
- let {
- item
- } = e.currentTarget.dataset;
- wx.navigateTo({
- url: `./addRole?item=${JSON.stringify(item)}&update=${this.data.authList.includes("角色修改")}&userDelete=${this.data.authList.includes("角色删除")}`
- })
- },
- /* 修改账号 */
- changeUser(e) {
- let {
- item
- } = e.currentTarget.dataset;
- delete(item.attinfos);
- wx.navigateTo({
- url: `./addUsers?item=${JSON.stringify(item)}&update=${this.data.authList.includes("账号修改")}`
- })
- },
- onReady() {
- this.selectComponent("#ListBox").setHeight(".tabs", this);
- }
- })
|