|
@@ -17,6 +17,7 @@ import { formatPermission } from '@/utils/utils'
|
|
|
import RoleMenu from '../System/components/RoleMenu'
|
|
|
import ConnectModal from '../System/components/ConnectModal'
|
|
|
import FormItem from 'antd/lib/form/FormItem'
|
|
|
+import { PageContainer } from '@ant-design/pro-layout'
|
|
|
|
|
|
export const permData = [
|
|
|
{
|
|
@@ -169,183 +170,185 @@ const Customer = () => {
|
|
|
]
|
|
|
|
|
|
return (
|
|
|
- <div className="h-full w-full flex flex-row">
|
|
|
- <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">
|
|
|
- {state.id && (
|
|
|
- <ConnectModal
|
|
|
- title="关联员工"
|
|
|
- dataId={state.id}
|
|
|
- postUrl="/role/staff/add"
|
|
|
- closeAfterSelect={false}
|
|
|
- onReload={() => tryGetRoleStaffList(state.id)}
|
|
|
- />
|
|
|
- )}
|
|
|
- </div>
|
|
|
- <Tabs
|
|
|
- defaultActiveKey="1"
|
|
|
- type="card"
|
|
|
- onChange={key => setState({ ...state, activeKey: key })}>
|
|
|
- <TabPane tab="员工列表" key="1">
|
|
|
- <Table<API.RoleStaffListItem>
|
|
|
- dataSource={state.roleStaff}
|
|
|
- columns={columns}
|
|
|
- rowKey={row => row.staffId}
|
|
|
- />
|
|
|
- </TabPane>
|
|
|
- <TabPane tab="角色权限" key="2">
|
|
|
- <div className="ml-4">
|
|
|
- {state.id && (
|
|
|
- <ProForm
|
|
|
- formRef={formRef}
|
|
|
- layout="horizontal"
|
|
|
- onFinish={async values => {
|
|
|
- const newValues = formatPermission('submit', values)
|
|
|
- await updateRolePermission({
|
|
|
- permission: JSON.stringify(newValues),
|
|
|
- id: state.id
|
|
|
- })
|
|
|
- message.success('设置成功')
|
|
|
- }}>
|
|
|
- <ProFormSwitch
|
|
|
- fieldProps={{
|
|
|
- onChange(checked) {
|
|
|
- if (!checked) {
|
|
|
- formRef.current?.setFieldsValue({ client: [] })
|
|
|
+ <PageContainer title={false} breadcrumb={false}>
|
|
|
+ <div className="h-full w-full flex flex-row">
|
|
|
+ <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">
|
|
|
+ {state.id && (
|
|
|
+ <ConnectModal
|
|
|
+ title="关联员工"
|
|
|
+ dataId={state.id}
|
|
|
+ postUrl="/role/staff/add"
|
|
|
+ closeAfterSelect={false}
|
|
|
+ onReload={() => tryGetRoleStaffList(state.id)}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ <Tabs
|
|
|
+ defaultActiveKey="1"
|
|
|
+ type="card"
|
|
|
+ onChange={key => setState({ ...state, activeKey: key })}>
|
|
|
+ <TabPane tab="员工列表" key="1">
|
|
|
+ <Table<API.RoleStaffListItem>
|
|
|
+ dataSource={state.roleStaff}
|
|
|
+ columns={columns}
|
|
|
+ rowKey={row => row.staffId}
|
|
|
+ />
|
|
|
+ </TabPane>
|
|
|
+ <TabPane tab="角色权限" key="2">
|
|
|
+ <div className="ml-4">
|
|
|
+ {state.id && (
|
|
|
+ <ProForm
|
|
|
+ formRef={formRef}
|
|
|
+ layout="horizontal"
|
|
|
+ onFinish={async values => {
|
|
|
+ const newValues = formatPermission('submit', values)
|
|
|
+ await updateRolePermission({
|
|
|
+ permission: JSON.stringify(newValues),
|
|
|
+ id: state.id
|
|
|
+ })
|
|
|
+ message.success('设置成功')
|
|
|
+ }}>
|
|
|
+ <ProFormSwitch
|
|
|
+ fieldProps={{
|
|
|
+ onChange(checked) {
|
|
|
+ if (!checked) {
|
|
|
+ formRef.current?.setFieldsValue({ client: [] })
|
|
|
+ }
|
|
|
}
|
|
|
+ }}
|
|
|
+ name="showClient"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <EveryUser className="mr-1" className="flex items-baseline mr-1" />
|
|
|
+ 客户
|
|
|
+ </span>
|
|
|
}
|
|
|
- }}
|
|
|
- name="showClient"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <EveryUser className="mr-1" className="flex items-baseline mr-1" />
|
|
|
- 客户
|
|
|
- </span>
|
|
|
- }
|
|
|
- />
|
|
|
- <ProFormDependency name={['showClient']}>
|
|
|
- {({ showClient }) => (
|
|
|
- <ProFormCheckbox.Group
|
|
|
- wrapperCol={{ offset: 1 }}
|
|
|
- name="client"
|
|
|
- options={[
|
|
|
- { value: 'access', label: '查看', disabled: !showClient },
|
|
|
- { value: 'add', label: '添加客户', disabled: !showClient },
|
|
|
- // { value: 'delete', label: '删除客户', disabled: !showClient },
|
|
|
- {
|
|
|
- value: 'edit_team_tags',
|
|
|
- label: '编辑协作标签',
|
|
|
- disabled: !showClient
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['showClient']}>
|
|
|
+ {({ showClient }) => (
|
|
|
+ <ProFormCheckbox.Group
|
|
|
+ wrapperCol={{ offset: 1 }}
|
|
|
+ name="client"
|
|
|
+ options={[
|
|
|
+ { value: 'access', label: '查看', disabled: !showClient },
|
|
|
+ { value: 'add', label: '添加客户', disabled: !showClient },
|
|
|
+ // { value: 'delete', label: '删除客户', disabled: !showClient },
|
|
|
+ {
|
|
|
+ value: 'edit_team_tags',
|
|
|
+ label: '编辑协作标签',
|
|
|
+ disabled: !showClient
|
|
|
+ }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </ProFormDependency>
|
|
|
+ <ProFormSwitch
|
|
|
+ fieldProps={{
|
|
|
+ onChange(checked) {
|
|
|
+ if (!checked) {
|
|
|
+ formRef.current?.setFieldsValue({ company: [] })
|
|
|
}
|
|
|
- ]}
|
|
|
- />
|
|
|
- )}
|
|
|
- </ProFormDependency>
|
|
|
- <ProFormSwitch
|
|
|
- fieldProps={{
|
|
|
- onChange(checked) {
|
|
|
- if (!checked) {
|
|
|
- formRef.current?.setFieldsValue({ company: [] })
|
|
|
}
|
|
|
+ }}
|
|
|
+ name="showCompany"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <EveryUser className="mr-1" className="flex items-baseline mr-1" />
|
|
|
+ 单位
|
|
|
+ </span>
|
|
|
}
|
|
|
- }}
|
|
|
- name="showCompany"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <EveryUser className="mr-1" className="flex items-baseline mr-1" />
|
|
|
- 单位
|
|
|
- </span>
|
|
|
- }
|
|
|
- />
|
|
|
- <ProFormDependency name={['showCompany']}>
|
|
|
- {({ showCompany }) => (
|
|
|
- <ProFormCheckbox.Group
|
|
|
- wrapperCol={{ offset: 1 }}
|
|
|
- // initialValue={}
|
|
|
- name="company"
|
|
|
- options={[
|
|
|
- { value: 'access', label: '查看', disabled: !showCompany },
|
|
|
- { value: 'add', label: '添加单位', disabled: !showCompany },
|
|
|
- // { value: 'delete', label: '删除单位', disabled: !showCompany },
|
|
|
- {
|
|
|
- value: 'edit_team_tags',
|
|
|
- label: '编辑协作标签',
|
|
|
- disabled: !showCompany
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['showCompany']}>
|
|
|
+ {({ showCompany }) => (
|
|
|
+ <ProFormCheckbox.Group
|
|
|
+ wrapperCol={{ offset: 1 }}
|
|
|
+ // initialValue={}
|
|
|
+ name="company"
|
|
|
+ options={[
|
|
|
+ { value: 'access', label: '查看', disabled: !showCompany },
|
|
|
+ { value: 'add', label: '添加单位', disabled: !showCompany },
|
|
|
+ // { value: 'delete', label: '删除单位', disabled: !showCompany },
|
|
|
+ {
|
|
|
+ value: 'edit_team_tags',
|
|
|
+ label: '编辑协作标签',
|
|
|
+ disabled: !showCompany
|
|
|
+ }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </ProFormDependency>
|
|
|
+ <ProFormSwitch
|
|
|
+ fieldProps={{
|
|
|
+ onChange(checked) {
|
|
|
+ if (!checked) {
|
|
|
+ formRef.current?.setFieldsValue({ bisiness: [] })
|
|
|
}
|
|
|
- ]}
|
|
|
- />
|
|
|
- )}
|
|
|
- </ProFormDependency>
|
|
|
- <ProFormSwitch
|
|
|
- fieldProps={{
|
|
|
- onChange(checked) {
|
|
|
- if (!checked) {
|
|
|
- formRef.current?.setFieldsValue({ bisiness: [] })
|
|
|
}
|
|
|
+ }}
|
|
|
+ name="showBusiness"
|
|
|
+ label={
|
|
|
+ <span className="flex items-center">
|
|
|
+ <EveryUser className="mr-1" className="flex items-baseline mr-1" />
|
|
|
+ 商机
|
|
|
+ </span>
|
|
|
}
|
|
|
- }}
|
|
|
- name="showBusiness"
|
|
|
- label={
|
|
|
- <span className="flex items-center">
|
|
|
- <EveryUser className="mr-1" className="flex items-baseline mr-1" />
|
|
|
- 商机
|
|
|
- </span>
|
|
|
+ />
|
|
|
+ <ProFormDependency name={['showBusiness']}>
|
|
|
+ {({ showBusiness }) => (
|
|
|
+ <ProFormCheckbox.Group
|
|
|
+ wrapperCol={{ offset: 1 }}
|
|
|
+ name="business"
|
|
|
+ options={[
|
|
|
+ { value: 'access', label: '查看', disabled: !showBusiness },
|
|
|
+ { value: 'add', label: '添加商机', disabled: !showBusiness }
|
|
|
+ // { value: 'delete', label: '删除商机', disabled: !showBusiness }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </ProFormDependency>
|
|
|
+ </ProForm>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ </TabPane>
|
|
|
+ <TabPane tab="数据权限" key="3">
|
|
|
+ {state.id && (
|
|
|
+ <ProForm
|
|
|
+ formRef={formRef2}
|
|
|
+ layout="vertical"
|
|
|
+ onFinish={async values => {
|
|
|
+ try {
|
|
|
+ await updatePermDataByRoleId({
|
|
|
+ id: state.id,
|
|
|
+ dataPermission: JSON.stringify(values)
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ return message.error(error.toString())
|
|
|
}
|
|
|
- />
|
|
|
- <ProFormDependency name={['showBusiness']}>
|
|
|
- {({ showBusiness }) => (
|
|
|
- <ProFormCheckbox.Group
|
|
|
- wrapperCol={{ offset: 1 }}
|
|
|
- name="business"
|
|
|
- options={[
|
|
|
- { value: 'access', label: '查看', disabled: !showBusiness },
|
|
|
- { value: 'add', label: '添加商机', disabled: !showBusiness }
|
|
|
- // { value: 'delete', label: '删除商机', disabled: !showBusiness }
|
|
|
- ]}
|
|
|
- />
|
|
|
- )}
|
|
|
- </ProFormDependency>
|
|
|
+ message.success('设置成功')
|
|
|
+ return true
|
|
|
+ }}>
|
|
|
+ <FormItem name="access" label="客户模块可见" required>
|
|
|
+ <Radio.Group>
|
|
|
+ <Space direction="vertical">
|
|
|
+ {permData.map(item => (
|
|
|
+ <Radio key={item.value} value={item.value}>
|
|
|
+ {item.label}
|
|
|
+ </Radio>
|
|
|
+ ))}
|
|
|
+ </Space>
|
|
|
+ </Radio.Group>
|
|
|
+ </FormItem>
|
|
|
</ProForm>
|
|
|
)}
|
|
|
- </div>
|
|
|
- </TabPane>
|
|
|
- <TabPane tab="数据权限" key="3">
|
|
|
- {state.id && (
|
|
|
- <ProForm
|
|
|
- formRef={formRef2}
|
|
|
- layout="vertical"
|
|
|
- onFinish={async values => {
|
|
|
- try {
|
|
|
- await updatePermDataByRoleId({
|
|
|
- id: state.id,
|
|
|
- dataPermission: JSON.stringify(values)
|
|
|
- })
|
|
|
- } catch (error) {
|
|
|
- return message.error(error.toString())
|
|
|
- }
|
|
|
- message.success('设置成功')
|
|
|
- return true
|
|
|
- }}>
|
|
|
- <FormItem name="access" label="客户模块可见" required>
|
|
|
- <Radio.Group>
|
|
|
- <Space direction="vertical">
|
|
|
- {permData.map(item => (
|
|
|
- <Radio key={item.value} value={item.value}>
|
|
|
- {item.label}
|
|
|
- </Radio>
|
|
|
- ))}
|
|
|
- </Space>
|
|
|
- </Radio.Group>
|
|
|
- </FormItem>
|
|
|
- </ProForm>
|
|
|
- )}
|
|
|
- </TabPane>
|
|
|
- </Tabs>
|
|
|
+ </TabPane>
|
|
|
+ </Tabs>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </PageContainer>
|
|
|
)
|
|
|
}
|
|
|
|