Commit 1a49688f by zhaochengxiang

bug fix

parent 8f0a0408
...@@ -70,6 +70,51 @@ const AssetAction = (props) => { ...@@ -70,6 +70,51 @@ const AssetAction = (props) => {
const app = useContext(AppContext); const app = useContext(AppContext);
const uploadRef = useRef(undefined); const uploadRef = useRef(undefined);
const actionCol = {
title: '操作',
dataIndex: 'action',
width: 170,
fixed: 'right',
render: (_, record) => {
return (reference===AssetManageReference||canEdit) ? <Space>
<Button
size='small'
onClick={() => {
setSelectStandardParam({ visible: true, id: record._id });
}}
>
关联标准
</Button>
{
record.standard?.standardId && <Button
size='small'
onClick={() => {
modal.confirm({
title: '您确定要取消关联标准吗?',
onOk: () => {
dispatch({
type: 'assetmanage.deleteStandardBatchMetadata',
payload: {
params: {
ids: record.standard?.id
}
},
callback: () => {
showMessage("success","取消成功");
getMetadataStandardList();
}
})
}
})
}}
>
取消关联
</Button>
}
</Space>: null;
}
}
const columns = [ const columns = [
{ {
title: '技术ID(英文名称)', title: '技术ID(英文名称)',
...@@ -159,54 +204,33 @@ const AssetAction = (props) => { ...@@ -159,54 +204,33 @@ const AssetAction = (props) => {
} }
</AppContext.Consumer> </AppContext.Consumer>
} }
},
{
title: '操作',
dataIndex: 'action',
width: 170,
fixed: 'right',
render: (_, record) => {
return (reference===AssetManageReference||canEdit) ? <Space>
<Button
size='small'
onClick={() => {
setSelectStandardParam({ visible: true, id: record._id });
}}
>
关联标准
</Button>
{
record.standard?.standardId && <Button
size='small'
onClick={() => {
modal.confirm({
title: '您确定要取消关联标准吗?',
onOk: () => {
dispatch({
type: 'assetmanage.deleteStandardBatchMetadata',
payload: {
params: {
ids: record.standard?.id
}
},
callback: () => {
showMessage("success","取消成功");
getMetadataStandardList();
}
})
}
})
}}
>
取消关联
</Button>
}
</Space>: null;
}
} }
]; ];
const [cols, setCols] = useState(columns) const cols = useMemo(() => {
let newCols = [...columns]
if (!permissionId) {
newCols = newCols.filter(item => item.dataIndex !== 'permission')
}
const haveCode = (metadataColumnList??[]).some(item => item.code)
//字段有编号才显示
if (haveCode) {
newCols.splice(2, 0, {
title: '编号',
dataIndex: 'code',
width: 100,
ellipsis: true,
render: (text, _) => highlightSearchContentByTerms(text||'', terms)
});
}
if (reference===AssetManageReference || (reference!==AssetDraftReference&&canEdit)) {
newCols.push(actionCol)
}
return newCols
}, [columns, actionCol, canEdit, metadataColumnList, reference, permissionId ])
useEffect(() => { useEffect(() => {
getSystems(); getSystems();
...@@ -501,23 +525,7 @@ const AssetAction = (props) => { ...@@ -501,23 +525,7 @@ const AssetAction = (props) => {
}); });
} }
setMetadataColumnList(newData); setMetadataColumnList(newData);
const haveCode = (newData??[]).some(item => item.code)
//字段有编号才显示
if (haveCode) {
setCols(prevCols => {
const newCols = [...prevCols]
newCols.splice(2, 0, {
title: '编号',
dataIndex: 'code',
width: 100,
ellipsis: true,
render: (text, _) => highlightSearchContentByTerms(text||'', terms)
});
return newCols
})
}
}, },
error: () => { error: () => {
setLoadingMetadataColumnList(false); setLoadingMetadataColumnList(false);
...@@ -1071,7 +1079,7 @@ const AssetAction = (props) => { ...@@ -1071,7 +1079,7 @@ const AssetAction = (props) => {
<Space style={{ marginLeft: 'auto' }}> <Space style={{ marginLeft: 'auto' }}>
{ {
(reference===AssetManageReference||canEdit) && <Button (reference===AssetManageReference||(reference!==AssetDraftReference&&canEdit)) && <Button
type='primary' type='primary'
onClick={() => { onClick={() => {
if (metadata?.metadataTableId) { if (metadata?.metadataTableId) {
...@@ -1133,7 +1141,7 @@ const AssetAction = (props) => { ...@@ -1133,7 +1141,7 @@ const AssetAction = (props) => {
<Table <Table
className='mt-3' className='mt-3'
loading={loadingMetadataColumnList} loading={loadingMetadataColumnList}
columns={permissionId?cols:cols.filter(item => item.dataIndex !== 'permission')} columns={cols??[]}
rowKey='_id' rowKey='_id'
dataSource={tableData||[]} dataSource={tableData||[]}
pagination={{ pagination={{
......
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