|
|
@ -1,10 +1,11 @@ |
|
|
|
import {getStaffbasicinfo} from "../../utils/api"; |
|
|
|
|
|
|
|
const app = getApp() |
|
|
|
import {getOwnedRolesOfStaffId} from '../../utils/statisticsApi.js' |
|
|
|
import {getOwnedRolesOfStaffId,editstaffinit} from '../../utils/statisticsApi.js' |
|
|
|
|
|
|
|
Component({ |
|
|
|
data: { |
|
|
|
manageOrgNameList:[], |
|
|
|
selected: 0, |
|
|
|
color: "#999", |
|
|
|
selectedColor: "#3A80E7", |
|
|
@ -52,28 +53,58 @@ Component({ |
|
|
|
}, |
|
|
|
attached() { |
|
|
|
}, |
|
|
|
ready: function () { |
|
|
|
ready: async function () { |
|
|
|
this.setData({ |
|
|
|
selected: app.globalData.selected |
|
|
|
}) |
|
|
|
console.log(app.globalData.roleList,"dskldlsk"); |
|
|
|
// secretary 书记 admin 管理员
|
|
|
|
console.log( app.globalData.roleList.filter(item => item.roleKey === 'secretary')) |
|
|
|
if(app.globalData.roleList.length <= 0) { |
|
|
|
const res = await getStaffbasicinfo(); |
|
|
|
// 处理员工信息
|
|
|
|
const res4 = await editstaffinit({ |
|
|
|
agencyId: res.data.agencyId, |
|
|
|
staffId: res.data.id |
|
|
|
}); |
|
|
|
console.log(res4.data.manageOrgNameList, "dsfkljdsf"); |
|
|
|
// 确保数据是数组,避免 undefined
|
|
|
|
this.setData({ |
|
|
|
manageOrgNameList: res4.data.manageOrgNameList || [] |
|
|
|
}); |
|
|
|
console.log(this.data.manageOrgNameList, "第二次"); |
|
|
|
// 获取角色信息
|
|
|
|
const res2 = await getOwnedRolesOfStaffId(res.data.id); |
|
|
|
// 更新全局数据
|
|
|
|
app.globalData.user = res.data; |
|
|
|
// 更新 UI 数据
|
|
|
|
this.setData({ |
|
|
|
"list[3].show": res2.data.some(item => |
|
|
|
['secretary', 'administrator', 'street_secretary'].includes(item.roleKey) |
|
|
|
) || this.data.manageOrgNameList.length > 0 |
|
|
|
}); |
|
|
|
|
|
|
|
getStaffbasicinfo().then(res=>{ |
|
|
|
getOwnedRolesOfStaffId(res.data.id).then(res2 => { |
|
|
|
app.globalData.user = res.data |
|
|
|
this.setData({ |
|
|
|
"list[3].show": res2.data.filter(item => item.roleKey === 'secretary' || item.roleKey === 'administrator' || item.roleKey === 'street_secretary').length > 0 |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log( |
|
|
|
res2.data.some(item => |
|
|
|
['secretary', 'administrator', 'street_secretary'].includes(item.roleKey) |
|
|
|
) || this.data.manageOrgNameList.length > 0, |
|
|
|
"dskjvdsljk" |
|
|
|
); |
|
|
|
} else { |
|
|
|
editstaffinit({ |
|
|
|
agencyId: app.globalData.user.agencyId, |
|
|
|
staffId: app.globalData.user.id |
|
|
|
}).then(res4 => { |
|
|
|
this.setData({ |
|
|
|
"list[3].show": app.globalData.roleList.filter(item => item.roleKey === 'secretary' || item.roleKey === 'administrator' || item.roleKey === 'street_secretary').length > 0 |
|
|
|
}) |
|
|
|
manageOrgNameList: res4.data.manageOrgNameList || [] |
|
|
|
}, () => { |
|
|
|
this.setData({ |
|
|
|
"list[3].show": app.globalData.roleList.some(item => |
|
|
|
['secretary', 'administrator', 'street_secretary'].includes(item.roleKey) |
|
|
|
) || this.data.manageOrgNameList.length > 0 |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
console.log(app.globalData.roleList, 'userss') |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
switchTab(e) { |
|
|
|