|
@@ -1,9 +1,11 @@
|
|
|
|
|
+import { STATUS_OPTIONS } from '@/defines';
|
|
|
import { fetchCreateRole, fetchDeleteRole, fetchRoleList, fetchUpdateRole } from '@/services/role';
|
|
import { fetchCreateRole, fetchDeleteRole, fetchRoleList, fetchUpdateRole } from '@/services/role';
|
|
|
import {
|
|
import {
|
|
|
ActionType,
|
|
ActionType,
|
|
|
DrawerForm,
|
|
DrawerForm,
|
|
|
ProColumns,
|
|
ProColumns,
|
|
|
ProFormDigit,
|
|
ProFormDigit,
|
|
|
|
|
+ ProFormSelect,
|
|
|
ProFormText,
|
|
ProFormText,
|
|
|
ProTable,
|
|
ProTable,
|
|
|
} from '@ant-design/pro-components';
|
|
} from '@ant-design/pro-components';
|
|
@@ -33,6 +35,7 @@ const RoleForm = ({ mode, record, trigger, productCode, onSuccess }: RoleFormPro
|
|
|
name: values.name,
|
|
name: values.name,
|
|
|
permsLevel: values.permsLevel,
|
|
permsLevel: values.permsLevel,
|
|
|
remark: values.remark,
|
|
remark: values.remark,
|
|
|
|
|
+ status: values.status,
|
|
|
});
|
|
});
|
|
|
if (!res.success) return false;
|
|
if (!res.success) return false;
|
|
|
} else {
|
|
} else {
|
|
@@ -60,21 +63,33 @@ const RoleForm = ({ mode, record, trigger, productCode, onSuccess }: RoleFormPro
|
|
|
tooltip="数字越小权限越高,范围 2-999"
|
|
tooltip="数字越小权限越高,范围 2-999"
|
|
|
/>
|
|
/>
|
|
|
<ProFormText name="remark" label="备注" />
|
|
<ProFormText name="remark" label="备注" />
|
|
|
|
|
+ {mode === 'edit' && (
|
|
|
|
|
+ <ProFormSelect
|
|
|
|
|
+ name="status"
|
|
|
|
|
+ label="状态"
|
|
|
|
|
+ options={STATUS_OPTIONS}
|
|
|
|
|
+ rules={[{ required: true }]}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
</DrawerForm>
|
|
</DrawerForm>
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
interface RoleTabProps {
|
|
interface RoleTabProps {
|
|
|
productCode: string;
|
|
productCode: string;
|
|
|
|
|
+ onRoleChange?: () => void;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export const RoleTab = ({ productCode }: RoleTabProps) => {
|
|
|
|
|
|
|
+export const RoleTab = ({ productCode, onRoleChange }: RoleTabProps) => {
|
|
|
const actionRef = useRef<ActionType>();
|
|
const actionRef = useRef<ActionType>();
|
|
|
const [permDrawer, setPermDrawer] = useState<{ open: boolean; roleId: number }>({
|
|
const [permDrawer, setPermDrawer] = useState<{ open: boolean; roleId: number }>({
|
|
|
open: false,
|
|
open: false,
|
|
|
roleId: 0,
|
|
roleId: 0,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const reload = () => actionRef.current?.reload();
|
|
|
|
|
|
|
+ const reload = () => {
|
|
|
|
|
+ actionRef.current?.reload();
|
|
|
|
|
+ onRoleChange?.();
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const columns: ProColumns<API.RoleItem>[] = [
|
|
const columns: ProColumns<API.RoleItem>[] = [
|
|
|
{ title: '名称', dataIndex: 'name', width: 160 },
|
|
{ title: '名称', dataIndex: 'name', width: 160 },
|
|
@@ -119,7 +134,7 @@ export const RoleTab = ({ productCode }: RoleTabProps) => {
|
|
|
const res = await fetchDeleteRole({ id: r.id });
|
|
const res = await fetchDeleteRole({ id: r.id });
|
|
|
if (!res.success) return;
|
|
if (!res.success) return;
|
|
|
message.success('删除成功');
|
|
message.success('删除成功');
|
|
|
- actionRef.current?.reload();
|
|
|
|
|
|
|
+ reload();
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<a>删除</a>
|
|
<a>删除</a>
|