|
@@ -0,0 +1,41 @@
|
|
|
|
|
+import { defineStore } from 'pinia'
|
|
|
|
|
+import { clientPost } from '@/utils/request.ts'
|
|
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
|
|
+
|
|
|
|
|
+interface PermissionReponse extends BaseResponse {
|
|
|
|
|
+ data: {
|
|
|
|
|
+ success: boolean
|
|
|
|
|
+ code: number
|
|
|
|
|
+ data: {
|
|
|
|
|
+ personName: string
|
|
|
|
|
+ deptName: string
|
|
|
|
|
+ deptId: string
|
|
|
|
|
+ errorCode: number
|
|
|
|
|
+ personCode: string
|
|
|
|
|
+ userName: string
|
|
|
|
|
+ isBusinessAtt: boolean
|
|
|
|
|
+ message: string
|
|
|
|
|
+ }
|
|
|
|
|
+ message: string
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export const usePermissionStore = defineStore('permission', () => {
|
|
|
|
|
+ const getUserPermission = async () => {
|
|
|
|
|
+ const res = await clientPost<null, PermissionReponse>('/userPermissions/queryUserPermissions')
|
|
|
|
|
+ if (res.code !== 200) {
|
|
|
|
|
+ ElMessage.error(res.msg)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (res.data.code !== 200) {
|
|
|
|
|
+ ElMessage.error(res.data.message)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ localStorage.setItem('userInfo', JSON.stringify(res.data.data))
|
|
|
|
|
+ return res.data
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ getUserPermission,
|
|
|
|
|
+ }
|
|
|
|
|
+})
|