Commit a0114205 by zhaochengxiang

分支项目成员只允许模型设置

parent 13205385
......@@ -728,7 +728,7 @@ const ModelTree = (props) => {
return <span title={nodeData?.remark||''}>{nodeData?.name||''}</span>;
}}
onRightClick={({event, node}) => {
if ((viewSelectedKey==='dir'&&(isAdmin||isCatalogAdmin)) || (viewSelectedKey === 'branch'&&(node?.deletable||node?.editable))) {
if ((viewSelectedKey==='dir'&&(isAdmin||isCatalogAdmin)) || (viewSelectedKey === 'branch')) {
setCurrentRightClickDir(node);
displayMenu(event);
}
......@@ -759,7 +759,7 @@ const ModelTree = (props) => {
{
(refrence!=='recatalog') && <RcMenu id={MENU_ID}>
{
(viewSelectedKey==='dir'||currentRightClickDir?.editable) && <RcItem id="edit" onClick={update}>
(viewSelectedKey==='dir'||viewSelectedKey==='branch') && <RcItem id="edit" onClick={update}>
{ viewSelectedKey==='branch' ? '修改项目' : '修改目录'}
</RcItem>
}
......@@ -774,7 +774,7 @@ const ModelTree = (props) => {
</RcItem>
}
{
(viewSelectedKey==='dir'||currentRightClickDir?.deletable) && <RcItem id="delete" onClick={deleteNode}>
(viewSelectedKey==='dir'||(viewSelectedKey==='branch'&&currentRightClickDir?.deletable)) && <RcItem id="delete" onClick={deleteNode}>
{ viewSelectedKey==='branch' ? '删除项目' : '删除目录'}
</RcItem>
}
......
......@@ -126,7 +126,7 @@ const FC = (props) => {
onCancel={() => { close() }}
>
<Spin spinning={loading||loadingUser||waiting}>
<Basic ref={basicRef} type={type} item={branch} user={user} />
<Basic ref={basicRef} type={type} item={branch?branch:item} user={user} />
</Spin>
</Modal>
)
......@@ -195,8 +195,8 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
}, [item])
const marginBottom = React.useMemo(() => {
return (type === 'detail') ? 5 : 15
}, [type])
return (type==='update' && !item?.editable) ? 5 : 15
}, [type, item])
const getUsers = () => {
setLoadingUsers(true)
......@@ -236,14 +236,18 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
rules={[{ required: true, message: '请输入项目名称!' }]}
style={{ marginBottom }}
>
<Input placeholder="请输入项目名称" />
{
(type==='update'&&!item?.editable) ? <span>{item?.name}</span> : <Input placeholder="请输入项目名称" />
}
</Form.Item>
<Form.Item
label='项目说明'
name='remark'
style={{ marginBottom }}
>
<Input placeholder="请输入项目说明" />
{
(type==='update'&&!item?.editable) ? <span>{item?.remark}</span> : <Input placeholder="请输入项目说明" />
}
</Form.Item>
<Form.Item
label='项目负责人'
......@@ -252,7 +256,7 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
rules={[{ required: (type==='update'), message: '请选择项目负责人!' }]}
>
{
type === 'add' ? <span>{user?.userName}</span> : <UsersItem loading={loadingUsers} users={users} />
type === 'add' ? <span>{user?.userName}</span> : <UsersItem loading={loadingUsers} users={users} readonly={(type==='update'&&!item?.editable)} />
}
</Form.Item>
<Form.Item
......@@ -261,7 +265,7 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
style={{ marginBottom }}
// rules={[{ required: true, message: '请选择项目成员!' }]}
>
<UsersItem loading={loadingUsers} users={users} />
<UsersItem loading={loadingUsers} users={users} readonly={(type==='update'&&!item?.editable)} />
</Form.Item>
<Form.Item
label='模型设置'
......@@ -274,7 +278,7 @@ const Basic = React.forwardRef(function ({ type, item, user }, ref) {
)
})
export const UsersItem = ({ loading, users, value, onChange }) => {
export const UsersItem = ({ loading, users, value, onChange, readonly = false }) => {
const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState()
......@@ -290,22 +294,26 @@ export const UsersItem = ({ loading, users, value, onChange }) => {
}, [searchValue, users], { wait: 300 })
return (
<Select loading={loading} mode='multiple' allowClear
placeholder='请选择用户'
value={(options??[]).length>0?value?.map(item => item.id):[]}
searchValue={searchValue}
onSearch={(val) => {
setSearchValue(val)
}}
onClear={() => {
setSearchValue()
}}
filterOption={false}
options={options}
onChange={(val) => {
onChange?.((users??[]).filter(item => (val??[]).indexOf(item.id) !== -1))
}}
/>
<>
{
readonly ? <span>{value?.map(item => item.name).toString()}</span> : <Select loading={loading} mode='multiple' allowClear
placeholder='请选择用户'
value={(options??[]).length>0?value?.map(item => item.id):[]}
searchValue={searchValue}
onSearch={(val) => {
setSearchValue(val)
}}
onClear={() => {
setSearchValue()
}}
filterOption={false}
options={options}
onChange={(val) => {
onChange?.((users??[]).filter(item => (val??[]).indexOf(item.id) !== -1))
}}
/>
}
</>
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment