Commit 47a6bdd9 by zhaochengxiang

字段编辑

parent 1812b954
...@@ -275,6 +275,10 @@ export function* getMetadataAttributes(payload) { ...@@ -275,6 +275,10 @@ export function* getMetadataAttributes(payload) {
return yield call(metadataService.getAttributes, payload); return yield call(metadataService.getAttributes, payload);
} }
export function* batchUpdateAttributes(payload) {
return yield call(metadataService.batchUpdateAttributes, payload);
}
export function* exportMetadataAttributes(payload) { export function* exportMetadataAttributes(payload) {
return yield call(metadataService.exportAttributes, payload); return yield call(metadataService.exportAttributes, payload);
} }
......
...@@ -24,6 +24,10 @@ export function getAttributes(payload) { ...@@ -24,6 +24,10 @@ export function getAttributes(payload) {
return PostJSON("/metadatarepo/rest/metadata/getByIdList", payload); return PostJSON("/metadatarepo/rest/metadata/getByIdList", payload);
} }
export function batchUpdateAttributes(payload) {
return PostJSON("/metadatarepo/rest/metadata/batchToUpdate", payload)
}
export function exportAttributes(payload) { export function exportAttributes(payload) {
return callFetchRawByFormData('post', '/metadatarepo/rest/download/exportAssetInfo', payload) return callFetchRawByFormData('post', '/metadatarepo/rest/download/exportAssetInfo', payload)
} }
......
...@@ -141,25 +141,14 @@ const AssetAction = (props) => { ...@@ -141,25 +141,14 @@ const AssetAction = (props) => {
dataIndex: 'cnName', dataIndex: 'cnName',
// width: 200, // width: 200,
ellipsis: true, ellipsis: true,
render: (text, _, index) => { render: (text, _, index) => <MetadataColumnEditableItem
if (isMetadataEdit) { value={text}
return ( isEdit={isMetadataEdit}
<Input size='small' allowClear value={text} terms={terms}
onChange={(e) => { onChange={(e) => {
setModifyMetadataColumnList( onMetadataColumnEditableItemChange(e.target.value, 'cnName', index)
produce(modifyMetadataColumnList, (draft) => {
if ((draft??[]).length > index) {
draft[index].cnName = e.target.value
}
})
)
}} }}
/> />
)
}
return highlightSearchContentByTerms(text||'', terms)
}
}, },
{ {
title: '是否有权限', title: '是否有权限',
...@@ -180,19 +169,40 @@ const AssetAction = (props) => { ...@@ -180,19 +169,40 @@ const AssetAction = (props) => {
dataIndex: 'businessRules', dataIndex: 'businessRules',
width: 240, width: 240,
ellipsis: true, ellipsis: true,
render: (text, _) => highlightSearchContentByTerms(text||'', terms) render: (text, _, index) => <MetadataColumnEditableItem
value={text}
isEdit={isMetadataEdit}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, 'businessRules', index)
}}
/>
}, },
{ {
title: '计量单位', title: '计量单位',
dataIndex: 'unitOfMeasurement', dataIndex: 'unitOfMeasurement',
ellipsis: true, ellipsis: true,
render: (text, _) => highlightSearchContentByTerms(text||'', terms) render: (text, _, index) => <MetadataColumnEditableItem
value={text}
isEdit={isMetadataEdit}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, 'unitOfMeasurement', index)
}}
/>
}, },
{ {
title: '备注信息', title: '备注信息',
dataIndex: 'remarks', dataIndex: 'remarks',
ellipsis: true, ellipsis: true,
render: (text, _) => highlightSearchContentByTerms(text||'', terms) render: (text, _, index) => <MetadataColumnEditableItem
value={text}
isEdit={isMetadataEdit}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, 'remarks', index)
}}
/>
}, },
{ {
title: '类型', title: '类型',
...@@ -542,8 +552,7 @@ const AssetAction = (props) => { ...@@ -542,8 +552,7 @@ const AssetAction = (props) => {
payload: { payload: {
data: ids, data: ids,
params: { params: {
// catalog: app?.env?.domainId||catalog||LocalStorage.get('assetsEnv'), catalog: app?.env?.domainId||catalog||LocalStorage.get('assetsEnv'),
catalog: '1810295967'
} }
}, },
callback: data => { callback: data => {
...@@ -593,6 +602,16 @@ const AssetAction = (props) => { ...@@ -593,6 +602,16 @@ const AssetAction = (props) => {
}) })
} }
const onMetadataColumnEditableItemChange = (val, dataIndex, index) => {
setModifyMetadataColumnList(
produce(modifyMetadataColumnList, (draft) => {
if ((draft??[]).length > index) {
draft[index][`${dataIndex}`] = val
}
})
)
}
const onCancelButtonClick = () => { const onCancelButtonClick = () => {
setCurrentAction('detail'); setCurrentAction('detail');
getAsset(); getAsset();
...@@ -1161,6 +1180,39 @@ const AssetAction = (props) => { ...@@ -1161,6 +1180,39 @@ const AssetAction = (props) => {
<Space style={{ marginLeft: 'auto' }}> <Space style={{ marginLeft: 'auto' }}>
{ {
(reference===AssetManageReference||(reference!==AssetDraftReference&&canEdit)) && <React.Fragment> (reference===AssetManageReference||(reference!==AssetDraftReference&&canEdit)) && <React.Fragment>
{
isMetadataEdit ? <React.Fragment>
<Button onClick={() => {
setMetadataEdit(false)
}}>
取消
</Button>
<Button onClick={() => {
setLoadingMetadataColumnList(true)
dispatch({
type: 'assetmanage.batchUpdateAttributes',
payload: {
data: modifyMetadataColumnList
},
callback: () => {
setLoadingMetadataColumnList(false)
setMetadataEdit(false)
getMetadataAttributes()
},
error: () => {
setLoadingMetadataColumnList(false)
}
})
}}>
保存
</Button>
</React.Fragment> : <Button onClick={() => {
setModifyMetadataColumnList(metadataColumnList)
setMetadataEdit(true)
}}>
编辑
</Button>
}
<Button <Button
onClick={() => { onClick={() => {
if (metadata?.metadataTableId) { if (metadata?.metadataTableId) {
...@@ -1175,12 +1227,6 @@ const AssetAction = (props) => { ...@@ -1175,12 +1227,6 @@ const AssetAction = (props) => {
> >
字段级维护 字段级维护
</Button> </Button>
<Button onClick={() => {
setModifyMetadataColumnList(metadataColumnList)
setMetadataEdit(true)
}}>
编辑
</Button>
</React.Fragment> </React.Fragment>
} }
<Input size="middle" <Input size="middle"
...@@ -1287,3 +1333,18 @@ const CascaderItem = ({ value = null, data, onChange, ...restProps }) => { ...@@ -1287,3 +1333,18 @@ const CascaderItem = ({ value = null, data, onChange, ...restProps }) => {
/> />
) )
} }
const MetadataColumnEditableItem = ({ value, isEdit, terms, onChange }) => {
return (
<React.Fragment>
{
isEdit ? <Input size='small'
value={value}
onChange={(e) => { onChange?.(e) }}
/> : <span>
{highlightSearchContentByTerms(value, terms)}
</span>
}
</React.Fragment>
)
}
\ No newline at end of file
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