lanjianrong 1 year ago
parent
commit
3adc113bac

+ 4 - 4
.vscode/settings.json

@@ -13,7 +13,7 @@
   "editor.minimap.maxColumn": 300,
   "editor.minimap.showSlider": "always",
   "editor.cursorBlinking": "phase",
-  "editor.cursorSmoothCaretAnimation": true,
+  "editor.cursorSmoothCaretAnimation": "on",
   "editor.detectIndentation": false,
   "editor.defaultFormatter": "esbenp.prettier-vscode",
   "diffEditor.ignoreTrimWhitespace": false,
@@ -168,12 +168,12 @@
     "editor.defaultFormatter": "esbenp.prettier-vscode"
   },
   "editor.codeActionsOnSave": {
-    "source.fixAll.eslint": true
+    "source.fixAll.eslint": "explicit"
   },
   "[vue]": {
     "editor.codeActionsOnSave": {
-      "source.fixAll.eslint": false,
-      "source.fixAll.stylelint": true
+      "source.fixAll.eslint": "never",
+      "source.fixAll.stylelint": "explicit"
     }
   },
   "i18n-ally.localesPaths": ["src/locales/lang"],

+ 1 - 0
src/api/sys/model/projectModel.ts

@@ -35,6 +35,7 @@ export type ProjectUpdateOrCreateParams = {
   categoryId?: string
   category: string
   staffName: string
+  staffId?: string
   remark: string
   status: string
 }

+ 4 - 8
src/enums/roleEnum.ts

@@ -1,11 +1,7 @@
 export enum RoleEnum {
-  // super admin
-  // SUPER = 'super',
-
-  // tester
-  // TEST = 'test',
   ADMIN = 'admin',
-  SHOWPROJECT = 'showProject',
-  SHOWSTAFF = 'showStaff',
-  SHOWPERMISSION = 'showPermission'
+  SHOW_PROJECT = 'showProject',
+  ADD_PROJECT = 'addProject',
+  SHOW_STAFF = 'showStaff',
+  SHOW_PERMISSION = 'showPermission'
 }

+ 2 - 2
src/router/routes/modules/dashboard.ts

@@ -20,7 +20,7 @@ const dashboard: AppRouteModule = {
       meta: {
         icon: 'clarity:users-solid-badged',
         title: '项目',
-        roles: [RoleEnum.ADMIN, RoleEnum.SHOWPROJECT]
+        roles: [RoleEnum.ADMIN, RoleEnum.SHOW_PROJECT]
       }
     },
     {
@@ -30,7 +30,7 @@ const dashboard: AppRouteModule = {
       meta: {
         title: '项目详情',
         hideMenu: true,
-        roles: [RoleEnum.ADMIN, RoleEnum.SHOWPROJECT]
+        roles: [RoleEnum.ADMIN, RoleEnum.SHOW_PROJECT]
       }
     }
   ]

+ 4 - 4
src/router/routes/modules/manager.ts

@@ -11,7 +11,7 @@ const manager: AppRouteModule = {
   meta: {
     title: '后台用户',
     icon: 'fa-solid:user-cog',
-    roles: [RoleEnum.ADMIN, RoleEnum.SHOWSTAFF, RoleEnum.SHOWPERMISSION]
+    roles: [RoleEnum.ADMIN, RoleEnum.SHOW_STAFF, RoleEnum.SHOW_PERMISSION]
   },
   children: [
     {
@@ -20,7 +20,7 @@ const manager: AppRouteModule = {
       component: () => import('/@/views/manager/user/list/index.vue'),
       meta: {
         title: '用户列表',
-        roles: [RoleEnum.ADMIN, RoleEnum.SHOWSTAFF]
+        roles: [RoleEnum.ADMIN, RoleEnum.SHOW_STAFF]
       }
     },
     // {
@@ -37,7 +37,7 @@ const manager: AppRouteModule = {
       component: () => import('/@/views/manager/permission/index.vue'),
       meta: {
         title: '权限组',
-        roles: [RoleEnum.ADMIN, RoleEnum.SHOWPERMISSION]
+        roles: [RoleEnum.ADMIN, RoleEnum.SHOW_PERMISSION]
       }
     },
     {
@@ -46,7 +46,7 @@ const manager: AppRouteModule = {
       component: () => import('/@/views/manager/version/index.vue'),
       meta: {
         title: '版本发布',
-        roles: [RoleEnum.ADMIN, RoleEnum.SHOWPERMISSION]
+        roles: [RoleEnum.ADMIN, RoleEnum.SHOW_PERMISSION]
       }
     }
   ]

+ 1 - 1
src/store/modules/office.ts

@@ -42,7 +42,7 @@ export const useOfficeStore = defineStore({
     // 获取办事处对应员工列表
     async getStaffWithCategoryIdAction(params: OfficeListParams) {
       const { staff = [] } = await getOfficeList(params)
-      this.setStaffList(staff.map(item => ({ value: item.username, label: item.username })))
+      this.setStaffList(staff.map(item => ({ value: item.sid, label: item.username })))
     },
     checkStaffList() {
       if (!this.getCategories.length) {

+ 3 - 2
src/views/dashboard/project-detail/components/account.vue

@@ -3,7 +3,7 @@
     <template #toolbar>
       <div class="w-2/5 flex justify-end">
         <!-- <Search @search="value => handleSearch('search', value)" placeholder="项目名称/项目编号" /> -->
-        <a-button @click="syncAccount" class="ml-3">同步计量账号</a-button>
+        <a-button @click="syncAccount" class="ml-3" v-if="hasPermission">同步计量账号</a-button>
         <a-button type="primary" v-if="hasPermission" @click="showModalFn" class="ml-3"
           ><PlusOutlined />新增账号</a-button
         >
@@ -44,6 +44,7 @@
   import { AddOrUpdateProjectAccountParams, ProjectAccountItem } from '/@/api/sys/model/projectModel'
   import { useMessage } from '/@/hooks/web/useMessage'
   import { useUserStore } from '/@/store/modules/user'
+  import { RoleEnum } from '/@/enums/roleEnum'
 
   export default defineComponent({
     name: 'ProjectDetailAccount',
@@ -245,7 +246,7 @@
         await saveProjectAccount(values)
       }
 
-      return { formElRef, registerTable, registerModal, registerForm, showModalFn, submitModal, syncAccount }
+      return { formElRef, registerTable, registerModal, registerForm, showModalFn, submitModal, syncAccount, RoleEnum }
     }
   })
 </script>

+ 4 - 4
src/views/dashboard/project-detail/components/info.vue

@@ -107,7 +107,7 @@
           required: true
         },
         {
-          field: 'staffName',
+          field: 'staffId',
           component: 'Select',
           disabledLabelWidth: true,
           componentProps: {
@@ -214,9 +214,9 @@
         if (values.category) {
           newVal.category = options.value.find(item => item.value === values.category)?.label || ''
         }
-        // if (values.staffName) {
-        //   newVal.staffName = staffOptions.value.find(item => item.value === values.staffId)?.label || ''
-        // }
+        if (values.staffId) {
+          newVals.staffName = values.staffId
+        }
         try {
           await updateProject(newVal)
         } catch (error) {

+ 5 - 4
src/views/dashboard/workbench/index.vue

@@ -4,9 +4,10 @@
       <template #toolbar>
         <div class="w-2/5 flex">
           <Search @search="value => handleSearch('search', value)" placeholder="项目名称/项目编号" />
-          <a-button v-if="hasPermission([RoleEnum.ADMIN])" @click="showModalFn" class="ml-3"
-            ><PlusOutlined />新增项目</a-button
-          >
+          <a-button v-auth="[RoleEnum.ADMIN, RoleEnum.ADD_PROJECT]" @click="showModalFn" class="ml-3">
+            <PlusOutlined />
+            新增项目
+          </a-button>
         </div>
       </template>
       <template #filterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters }">
@@ -199,7 +200,7 @@
           newVals.insideCategory = options.value.find(item => item.value === values.insideCategoryId)?.label || ''
         }
         if (values.staffId) {
-          newVals.staffName = staffOptions.value.find(item => item.value === values.staffId)?.label || ''
+          newVals.staffName = values.staffId
         }
         try {
           await addProject(newVals)

+ 5 - 3
src/views/manager/permission/tableData.tsx

@@ -4,6 +4,7 @@ import { Icon } from '/@/components/Icon/index'
 import { deletePermGroup } from '/@/api/sys/manager'
 import { computed } from 'vue'
 import { FormSchema } from '/@/components/Form'
+import { RoleEnum } from '/@/enums/roleEnum'
 
 enum PermMap {
   showProject = '项目',
@@ -96,9 +97,10 @@ export function getPermSchemas() {
       label: '权限设置',
       componentProps: {
         options: [
-          { label: '项目', value: 'showProject' },
-          { label: '用户列表', value: 'showStaff' },
-          { label: '权限组', value: 'showPermission' }
+          { label: '项目', value: RoleEnum.SHOW_PROJECT },
+          { label: '新增项目', value: RoleEnum.ADD_PROJECT },
+          { label: '用户列表', value: RoleEnum.SHOW_STAFF },
+          { label: '权限组', value: RoleEnum.SHOW_PERMISSION }
         ]
       }
     },