Pārlūkot izejas kodu

update: 用户增加审核权限字段

xyh 2 gadi atpakaļ
vecāks
revīzija
b1a7069475

+ 1 - 1
src/components/login-field/upload/index.tsx

@@ -1,4 +1,4 @@
-import {VNodeRef, defineComponent} from 'vue';
+import {defineComponent} from 'vue';
 import placeholder from '@assets/images/register/imgPlaceholder.webp';
 import {useI18n} from 'vue-i18n';
 import {useDropFile, useUpload} from './hooks';

+ 3 - 1
src/components/modal-field/select/index.tsx

@@ -20,9 +20,10 @@ export default defineComponent({
     loading: selectProps.loading,
     options: selectProps.options,
     onSearch: selectProps.onSearch,
+    multiple: selectProps.multiple,
   },
   setup(props) {
-    const {value, setValue, errorMessage} = useField<string>(
+    const {value, setValue, errorMessage} = useField<string | string[]>(
       props.name,
       void 0,
       {validateOnMount: false, validateOnValueUpdate: false},
@@ -65,6 +66,7 @@ export default defineComponent({
         <div class="ld-modal-field-group">
           <label class={props?.optional ? 'optional' : ''}>{props.label}</label>
           <NSelect
+            multiple={props.multiple}
             bordered={false}
             filterable
             remote

+ 6 - 4
src/locales/user.ts

@@ -1,8 +1,8 @@
 export default {
   zh: {
     label: '用户',
-    filter: ['用户名称', '真实姓名', '角色名称', '邮箱', '手机号'],
-    table: ['用户名称', '真实姓名', '邮箱', '手机号', '角色'],
+    filter: ['用户名称', '真实姓名', '角色名称', '邮箱', '手机号', '审核权限'],
+    table: ['用户名称', '真实姓名', '邮箱', '手机号', '角色', '审核权限'],
     modal: {
       title: ['新增用户', '修改用户'],
       errors: [
@@ -17,11 +17,12 @@ export default {
     tableOperation: ['重置密码'],
     resetTips: '重置密码会将密码修改为123456',
     resetSuccess: '重置成功',
+    authorityOptions: ['入库质检审批', '采购单审批'],
   },
   ko: {
     label: '用户',
-    filter: ['用户名称kr', '真实姓名kr', '角色名称kr', '邮箱kr', '手机号kr'],
-    table: ['用户名称', '真实姓名', '邮箱', '手机号', '角色'],
+    filter: ['用户名称kr', '真实姓名kr', '角色名称kr', '邮箱kr', '手机号kr', '审核权限'],
+    table: ['用户名称', '真实姓名', '邮箱', '手机号', '角色', '审核权限'],
     modal: {
       title: ['新增用户', '修改用户'],
       errors: [
@@ -36,5 +37,6 @@ export default {
     tableOperation: ['重置密码'],
     resetTips: '重置密码会将密码修改为123456',
     resetSuccess: '重置成功',
+    authorityOptions: ['入库质检审批2', '采购单审批2'],
   },
 };

+ 4 - 0
src/models/request/user.ts

@@ -30,6 +30,8 @@ export type GetUserListParams = {
   email: string;
   /** 手机号 */
   phone: string;
+  /** 用户审核权限 */
+  auditAuthority: string;
 } & ListParams;
 
 /** 新增用户信息 */
@@ -44,6 +46,8 @@ export type AddUserParams = {
   phone: string;
   /** 角色 */
   role: string;
+  /** 用户审核权限 */
+  auditAuthority: string | null;
 };
 
 /** 修改用户信息 */

+ 2 - 0
src/models/response/user.ts

@@ -43,4 +43,6 @@ export type UserListData = {
   menu: string;
   /** 用户菜单权限 antd用 */
   menuBefore: string;
+  /** 用户审核权限 */
+  auditAuthority: string;
 } & ModifyData;

+ 10 - 1
src/pages/user/filter/hooks.ts

@@ -1,5 +1,5 @@
 import {useI18n} from 'vue-i18n';
-import {computed} from 'vue';
+import {computed, ref} from 'vue';
 import {type LDFilterTool} from '@components';
 import {useQuery} from '@tanstack/vue-query';
 import {getAllRole} from '@apis';
@@ -23,6 +23,15 @@ export function useExtendsTools() {
   const tools: LDFilterTool<OriginalListParams<GetUserListParams>>[] = [
     {type: 'field', label: computed(() => t('user.filter[0]')), name: 'userName'},
     {type: 'field', label: computed(() => t('user.filter[1]')), name: 'realName'},
+    {
+      type: 'select',
+      label: computed(() => t('user.filter[5]')),
+      name: 'auditAuthority',
+      options: ref([
+        {label: t('user.authorityOptions[0]'), value: '1'},
+        {label: t('user.authorityOptions[1]'), value: '2'},
+      ]),
+    },
   ];
 
   const extendsTools: LDFilterTool<OriginalListParams<GetUserListParams>>[] = [

+ 1 - 0
src/pages/user/state.ts

@@ -9,6 +9,7 @@ export const filterState: OriginalListParams<GetUserListParams> = {
   role: '',
   email: '',
   phone: '',
+  auditAuthority: '',
 };
 /** 页码信息key */
 export const pageSymbol = Symbol('page');

+ 16 - 0
src/pages/user/table/hooks.ts

@@ -12,6 +12,7 @@ import {UserListData} from '@models';
 import {TABLE_CELL_WIDTH, lightVariable} from '@utils';
 import {LDTableButton} from '@components';
 import {useMutation} from '@tanstack/vue-query';
+import {trimStart} from 'lodash-es';
 
 export function useTableData() {
   return useFetchTableList({
@@ -91,6 +92,21 @@ export function useColumns(refetch: () => void) {
         key: 'role',
         width: TABLE_CELL_WIDTH.normal,
       },
+      {
+        title: t('user.table[5]'),
+        key: 'auditAuthority',
+        width: TABLE_CELL_WIDTH.normal,
+        render({auditAuthority}) {
+          return auditAuthority?.length > 0
+            ? trimStart(auditAuthority.split(',').reduce(
+              function(prev, next) {
+                return prev + ',' + t(`user.authorityOptions[${Number(next) - 1}]`);
+              },
+              '',
+            ), ',')
+            : '';
+        },
+      },
       {
         title: t('user.table[2]'),
         key: 'email',

+ 17 - 2
src/pages/user/table/modal/Info.vue

@@ -4,14 +4,14 @@ import {useQueryDataInfo} from '@hooks';
 import {getAllRole, getUserInfo} from '@apis';
 import {computed, watchEffect} from 'vue';
 import {useI18n} from 'vue-i18n';
-import type {AddUserParams} from '@models';
+import type {FormState} from './hooks';
 import {useQuery} from '@tanstack/vue-query';
 
 defineOptions({name: 'UserPageModalInfo'});
 
 type Props = {
   id: string;
-  setValues: (fields: AddUserParams) => void
+  setValues: (fields: FormState) => void
 };
 
 const props = defineProps<Props>();
@@ -31,6 +31,7 @@ watchEffect(function() {
     roleId = '',
     email = '',
     phone = '',
+    auditAuthority = '',
   } = data.value ?? {};
 
   props.setValues({
@@ -39,6 +40,7 @@ watchEffect(function() {
     role: roleId,
     email,
     phone,
+    auditAuthority: auditAuthority?.length > 0 ? auditAuthority.split(',') : [],
   });
 });
 
@@ -63,6 +65,13 @@ const optionList = computed(function() {
   });
 });
 
+const authorityOptions = computed(function() {
+  return [
+    {label: t('user.authorityOptions[0]'), value: '1'},
+    {label: t('user.authorityOptions[1]'), value: '2'},
+  ];
+});
+
 </script>
 
 <template>
@@ -74,6 +83,12 @@ const optionList = computed(function() {
     :loading="isLoading"
     :options="optionList"
   />
+  <LDModalSelect
+    name="auditAuthority"
+    :label="t('user.table[5]')"
+    :options="authorityOptions"
+    multiple
+  />
   <LDModalInput name="email" :label="t('user.table[2]')" />
   <LDModalInput name="phone" :label="t('user.table[3]')" />
 </template>

+ 25 - 4
src/pages/user/table/modal/hooks.ts

@@ -7,18 +7,22 @@ import {useForm} from 'vee-validate';
 import {Ref, watchEffect} from 'vue';
 import {object, string} from 'zod';
 
+export type FormState = Omit<AddUserParams, 'auditAuthority'>
+& {auditAuthority: string[]};
+
 export function useFormState(
   id: Ref<string>,
   visible: Ref<boolean>,
   options: {onFetch: () => void, onClose: () => void},
 ) {
-  const {handleSubmit, setErrors, setValues} = useForm<AddUserParams>({
+  const {handleSubmit, setErrors, setValues} = useForm<FormState>({
     initialValues: {
       userName: '',
       realName: '',
       email: '',
       phone: '',
       role: '',
+      auditAuthority: [] as string[],
     },
     validationSchema: toTypedSchema(object({
       userName: string(formatValidateError('user.modal.errors[0]'))
@@ -31,6 +35,7 @@ export function useFormState(
         .min(1, 'user.modal.errors[4]'),
       role: string(formatValidateError('user.modal.errors[5]'))
         .min(1, 'user.modal.errors[5]'),
+      auditAuthority: string().array(),
     })),
   });
 
@@ -55,10 +60,26 @@ export function useFormState(
     onClose,
   });
 
-  const onSubmit = handleSubmit(function(val) {
+  const onSubmit = handleSubmit(function({
+    userName,
+    realName,
+    email,
+    phone,
+    role,
+    auditAuthority,
+  }) {
+    const parasm: AddUserParams = {
+      userName,
+      realName,
+      email,
+      phone,
+      role,
+      auditAuthority: auditAuthority.join(','),
+    };
+
     id.value.length > 0
-      ? editMutate({id: id.value, ...val})
-      : addMutate(val);
+      ? editMutate({id: id.value, ...parasm})
+      : addMutate(parasm);
   });
 
   return [isLoading, {setValues, onSubmit}] as const;

+ 1 - 1
src/pages/user/table/modal/index.vue

@@ -41,7 +41,7 @@ const {t} = useI18n();
     @submit="onSubmit"
     :isLoading="isLoading"
   >
-    <ErrorBoundary>
+    <ErrorBoundary propagation>
       <template #fallback="{error, reset}">
         <LDErrorBoundary :msg="error.message" @reset="reset" />
       </template>