Forráskód Böngészése

feat: RoleMenu增加itemCount参数对删除操作存在关联人是进行提示

lanjianrong 4 éve
szülő
commit
47cba6ae3a

+ 1 - 1
src/pages/Role/Customer/index.tsx

@@ -102,7 +102,7 @@ const Customer = () => {
 
   return (
     <div className="h-full w-full flex flex-row">
-      <RoleMenu menuId={menuId} onSelect={onSelect} />
+      <RoleMenu menuId={menuId} onSelect={onSelect} itemCount={state.roleStaff?.length || 0} />
       <div className="w-max-3/4">
         <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a relative">
           <div className="absolute right-4 top-4 z-100">

+ 8 - 2
src/pages/Role/System/components/RoleMenu/roleMenu.tsx

@@ -14,9 +14,10 @@ import { ModalForm, ProFormText } from '@ant-design/pro-form'
 type RoleMenuProps = {
   menuId: string
   onSelect?: (id: string) => void
+  itemCount?: number
 }
 
-const RoleMenu: React.FC<RoleMenuProps> = ({ menuId, onSelect }) => {
+const RoleMenu: React.FC<RoleMenuProps> = ({ menuId, onSelect, itemCount }) => {
   const [state, setState] = useState({
     value: ''
   })
@@ -141,7 +142,12 @@ const RoleMenu: React.FC<RoleMenuProps> = ({ menuId, onSelect }) => {
                         title="确认删除吗?"
                         okText="确认"
                         cancelText="取消"
-                        onConfirm={() => tryDeleteRole(item.id)}>
+                        onConfirm={() => {
+                          if (itemCount && itemCount !== 0) {
+                            return message.warning('请先移除已经关联的员工')
+                          }
+                          return tryDeleteRole(item.id)
+                        }}>
                         <li className="text-red-500">删除</li>
                       </Popconfirm>
                     </ul>

+ 1 - 1
src/pages/Role/System/index.tsx

@@ -132,7 +132,7 @@ const System = () => {
 
   return (
     <div className="h-full w-full flex flex-row">
-      <RoleMenu menuId={menuId} onSelect={onSelect} />
+      <RoleMenu menuId={menuId} onSelect={onSelect} itemCount={state.roleStaff?.length || 0} />
       <div className="w-max-3/4">
         <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a relative">
           <div className="absolute right-4 top-4 z-100">