|
@@ -1,12 +1,25 @@
|
|
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
-import { Button, Checkbox, Form, FormInstance, Input, InputNumber, Modal, Radio } from 'antd'
|
|
|
+import {
|
|
|
+ Button,
|
|
|
+ Checkbox,
|
|
|
+ Form,
|
|
|
+ FormInstance,
|
|
|
+ Input,
|
|
|
+ InputNumber,
|
|
|
+ Modal,
|
|
|
+ Radio,
|
|
|
+ Select
|
|
|
+} from 'antd'
|
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
import { Z5_APIgetAddTreeList, Z5_APIgetInfo, Z5_APIsave } from '@/store/action/Z5role'
|
|
|
import { TypeZ5Role } from './type'
|
|
|
import classNmaes from 'classnames'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
|
+import { useDispatch, useSelector } from 'react-redux'
|
|
|
+import { D2_APIgetList } from '@/store/action/D2storSet'
|
|
|
+import { RootState } from '@/store'
|
|
|
|
|
|
type Props = {
|
|
|
sId: number
|
|
@@ -23,8 +36,16 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
const getInfoFu = useCallback(async (id: number) => {
|
|
|
const res = await Z5_APIgetInfo(id)
|
|
|
if (res.code === 0) {
|
|
|
- FormBoxRef.current?.setFieldsValue(res.data.role)
|
|
|
- setRoleArr(res.data.permission)
|
|
|
+ const data: any = res.data
|
|
|
+
|
|
|
+ FormBoxRef.current?.setFieldsValue(data.role)
|
|
|
+ setRoleArr(data.permission)
|
|
|
+
|
|
|
+ setScopeGoodsFile(data.role.scopeGoodsFile)
|
|
|
+ setScopeGoodsFileDownload(data.role.scopeGoodsFileDownload)
|
|
|
+ setScopeStorage(data.role.scopeStorage)
|
|
|
+ if (data.role.scopeStorageIds)
|
|
|
+ setScopeStorageIds(data.role.scopeStorageIds.split(',').map((v: string) => Number(v)))
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
@@ -55,6 +76,9 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
} else {
|
|
|
FormBoxRef.current?.setFieldsValue({ sort: 999, dataScope: 2 })
|
|
|
getAddInfoFu()
|
|
|
+ setScopeGoodsFile(1)
|
|
|
+ setScopeGoodsFileDownload(2)
|
|
|
+ setScopeStorage(1)
|
|
|
}
|
|
|
}, [getAddInfoFu, getInfoFu, sId])
|
|
|
|
|
@@ -93,13 +117,37 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
// return MessageFu.warning("有表单不符号规则!");
|
|
|
}, [])
|
|
|
|
|
|
+ // 藏品附件权限
|
|
|
+ const [scopeGoodsFile, setScopeGoodsFile] = useState(-1)
|
|
|
+ const [scopeGoodsFileDownload, setScopeGoodsFileDownload] = useState(-1)
|
|
|
+
|
|
|
+ // 库房权限
|
|
|
+ const [scopeStorage, setScopeStorage] = useState(-1)
|
|
|
+ // 指定库房数据
|
|
|
+ const [scopeStorageIds, setScopeStorageIds] = useState<number[]>([])
|
|
|
+ const dispatch = useDispatch()
|
|
|
+ useEffect(() => {
|
|
|
+ dispatch(D2_APIgetList({ pageNum: 1, pageSize: 99999 }))
|
|
|
+ }, [dispatch])
|
|
|
+
|
|
|
+ const { list: storSetList } = useSelector((state: RootState) => state.D2storSet.tableInfo)
|
|
|
+
|
|
|
// 通过校验点击确定
|
|
|
const onFinish = useCallback(
|
|
|
async (values: any) => {
|
|
|
+ if (scopeStorage === 3) {
|
|
|
+ if (!scopeStorageIds || scopeStorageIds.length === 0)
|
|
|
+ return MessageFu.warning('至少选中一个指定库房')
|
|
|
+ }
|
|
|
+
|
|
|
const obj = {
|
|
|
...values,
|
|
|
id: sId > 0 ? sId : null,
|
|
|
- resources: checkIds
|
|
|
+ resources: checkIds,
|
|
|
+ scopeGoodsFile,
|
|
|
+ scopeGoodsFileDownload,
|
|
|
+ scopeStorage,
|
|
|
+ scopeStorageIds: scopeStorageIds.join(',')
|
|
|
}
|
|
|
|
|
|
const res = await Z5_APIsave(obj)
|
|
@@ -110,7 +158,17 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
closeFu()
|
|
|
}
|
|
|
},
|
|
|
- [addTableFu, checkIds, closeFu, editTableFu, sId]
|
|
|
+ [
|
|
|
+ addTableFu,
|
|
|
+ checkIds,
|
|
|
+ closeFu,
|
|
|
+ editTableFu,
|
|
|
+ sId,
|
|
|
+ scopeGoodsFile,
|
|
|
+ scopeGoodsFileDownload,
|
|
|
+ scopeStorage,
|
|
|
+ scopeStorageIds
|
|
|
+ ]
|
|
|
)
|
|
|
|
|
|
return (
|
|
@@ -157,7 +215,42 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <Form.Item label='数据权限' name='dataScope' rules={[{ required: true, message: '' }]}>
|
|
|
+ <div className='Z5ebox'>
|
|
|
+ <div className='Z5eboxll'>
|
|
|
+ <span> * </span> 功能权限:
|
|
|
+ </div>
|
|
|
+ <div className='Z5eboxrr'>
|
|
|
+ {roleArr.map(v => (
|
|
|
+ <div key={v.id} className='Z5eRow'>
|
|
|
+ <div className='Z5eRow1'>{v.name}</div>
|
|
|
+ <div className='Z5eRow2'>
|
|
|
+ {v.children.map(c => (
|
|
|
+ <Checkbox
|
|
|
+ disabled={c.name === '角色管理'}
|
|
|
+ key={c.id}
|
|
|
+ checked={c.authority}
|
|
|
+ onChange={e => onChange(e.target.checked, v.id, c.id)}
|
|
|
+ >
|
|
|
+ {c.name}
|
|
|
+ {c.name === '角色管理' ? '(超级管理员才有)' : ''}
|
|
|
+ </Checkbox>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+
|
|
|
+ <div className={classNmaes('Z5eErr', checkIds.length <= 0 ? 'Z5eErrAc' : '')}>
|
|
|
+ 至少选中一个
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <br />
|
|
|
+ <Form.Item
|
|
|
+ className='Z5ebox0'
|
|
|
+ label='数据权限'
|
|
|
+ name='dataScope'
|
|
|
+ rules={[{ required: true, message: '' }]}
|
|
|
+ >
|
|
|
<Radio.Group>
|
|
|
<Radio value={0} className='Z5Rtit'>
|
|
|
流程可见权限
|
|
@@ -167,6 +260,63 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
</Radio.Group>
|
|
|
</Form.Item>
|
|
|
|
|
|
+ <div className='Z5ebox Z5ebox1'>
|
|
|
+ <div className='Z5eboxll'>藏品附件权限</div>
|
|
|
+ <div className='Z5eboxrr'>
|
|
|
+ <div>
|
|
|
+ <Radio.Group
|
|
|
+ value={scopeGoodsFile}
|
|
|
+ onChange={e => setScopeGoodsFile(e.target.value)}
|
|
|
+ options={[
|
|
|
+ { value: 1, label: '可见' },
|
|
|
+ { value: 0, label: '不可见' }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='Z5eboxrr_1'>
|
|
|
+ <Radio.Group
|
|
|
+ disabled={scopeGoodsFile === 0}
|
|
|
+ value={scopeGoodsFileDownload}
|
|
|
+ onChange={e => setScopeGoodsFileDownload(e.target.value)}
|
|
|
+ options={[
|
|
|
+ { value: 1, label: '下载原图和缩略图' },
|
|
|
+ { value: 2, label: '仅下载缩略图' }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <br />
|
|
|
+ <div className='Z5ebox Z5ebox1'>
|
|
|
+ <div className='Z5eboxll'>库房权限</div>
|
|
|
+ <div className='Z5eboxrr'>
|
|
|
+ <div>
|
|
|
+ <Radio.Group
|
|
|
+ value={scopeStorage}
|
|
|
+ onChange={e => setScopeStorage(e.target.value)}
|
|
|
+ options={[
|
|
|
+ { value: 1, label: '全部库房' },
|
|
|
+ { value: 2, label: '相关库房' },
|
|
|
+ { value: 3, label: '指定库房' }
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='Z5eboxrr_1' hidden={scopeStorage !== 3}>
|
|
|
+ <Select
|
|
|
+ showSearch={false}
|
|
|
+ mode='multiple'
|
|
|
+ allowClear
|
|
|
+ style={{ width: '100%' }}
|
|
|
+ placeholder='请选择'
|
|
|
+ value={scopeStorageIds}
|
|
|
+ onChange={value => setScopeStorageIds(value)}
|
|
|
+ options={storSetList}
|
|
|
+ fieldNames={{ value: 'id', label: 'name' }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
{/* 确定和取消按钮 */}
|
|
|
<br />
|
|
|
<Form.Item wrapperCol={{ offset: 9, span: 16 }} className='Z5eBtn'>
|
|
@@ -178,36 +328,6 @@ function Z5edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
|
|
|
<MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
-
|
|
|
- <div className='Z5ebox Z5ebox0'>
|
|
|
- <div className='Z5eboxll'>
|
|
|
- <span> * </span> 功能权限:
|
|
|
- </div>
|
|
|
- <div className='Z5eboxrr'>
|
|
|
- {roleArr.map(v => (
|
|
|
- <div key={v.id} className='Z5eRow'>
|
|
|
- <div className='Z5eRow1'>{v.name}</div>
|
|
|
- <div className='Z5eRow2'>
|
|
|
- {v.children.map(c => (
|
|
|
- <Checkbox
|
|
|
- disabled={c.name === '角色管理'}
|
|
|
- key={c.id}
|
|
|
- checked={c.authority}
|
|
|
- onChange={e => onChange(e.target.checked, v.id, c.id)}
|
|
|
- >
|
|
|
- {c.name}
|
|
|
- {c.name === '角色管理' ? '(超级管理员才有)' : ''}
|
|
|
- </Checkbox>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- ))}
|
|
|
-
|
|
|
- <div className={classNmaes('Z5eErr', checkIds.length <= 0 ? 'Z5eErrAc' : '')}>
|
|
|
- 至少选中一个
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
</div>
|
|
|
</Modal>
|
|
|
)
|