Commit cd6a21e3 by zhaochengxiang

资产非结构化模板字段动态显示

parent 4fd612c1
......@@ -190,6 +190,10 @@ export function* loadDataAssets(payload) {
return yield call(service.loadDataAssets, payload);
}
export function* listBusinessColumnElements(payload) {
return yield call(service.listBusinessColumnElements, payload)
}
export function* listDraftStates() {
return yield call(service.listDraftStates)
}
......
......@@ -92,6 +92,10 @@ export function loadDataAssets(payload) {
return PostJSON("/dataassetmanager/dataAssetApi/loadDataAssets", payload);
}
export function listBusinessColumnElements(payload) {
return GetJSON("/dataassetmanager/elementApi/listBusinessColumnElements", payload);
}
export function listDraftStates() {
return GetJSON("/dataassetmanager/draftApi/listDraftStates")
}
......
......@@ -11,7 +11,7 @@ import { highlightSearchContentByTerms, showMessage, paginate, isPostAsset } fro
import { AppContext, appId } from '../../../../App';
import Tag from '../../Tag';
import Separate from './Separate';
import { AnchorId, AnchorDirId, AssetManageReference, AssetRecycleReference, AssetDraftReference } from '../../../../util/constant';
import { AnchorId, AnchorDirId, AssetManageReference, AssetRecycleReference, AssetDraftReference, Action } from '../../../../util/constant';
import IndexCode from './IndexCode';
import Upload from './Upload';
import Table from '../../ResizeableTable';
......@@ -64,6 +64,8 @@ const AssetAction = React.forwardRef(function (props, ref) {
const [publishedAssetPaths, setPublishedAssetPaths] = useState([]);
const [publishedAsset, setPublishedAsset] = useState();
const [isStructured, setStructured] = useState();
const [businessElements, setBusinessElements] = useState();
const [businessColumns, setBusinessColumns] = useState();
const [loadingSaveAsDraft, setLoadingSaveAsDraft] = React.useState(false)
const [needSaveAsDraft, setNeedSaveAsDraft] = React.useState()
......@@ -141,64 +143,6 @@ const AssetAction = React.forwardRef(function (props, ref) {
},
];
const businessColumns = [
{
title: <span>
<span style={{
marginRight: 4,
color: '#ff4d4f',
}}>*</span>
英文名称
</span>,
dataIndex: 'enName',
ellipsis: true,
render: (text, record, index) => {
columnForm?.setFieldsValue({ [`column${index}`]: text })
return (
<Form.Item name={`column${index}`}
rules={[{ required: true, message: '请填写英文名称!' }]}
style={{ marginBottom: 0 }}
>
<MetadataColumnEditableItem
value={text}
isEdit={currentAction!=='detail'}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, 'enName', index)
}}
/>
</Form.Item>
)
}
},
{
title: '中文名称',
dataIndex: 'cnName',
ellipsis: true,
render: (text, _, index) => <MetadataColumnEditableItem
value={text}
isEdit={currentAction!=='detail'}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, 'cnName', index)
}}
/>
},
{
title: '备注',
dataIndex: 'remarks',
ellipsis: true,
render: (text, _, index) => <MetadataColumnEditableItem
value={text}
isEdit={currentAction!=='detail'}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, 'remarks', index)
}}
/>
},
];
const businessActionCol = {
title: '操作',
dataIndex: 'action',
......@@ -266,6 +210,51 @@ const AssetAction = React.forwardRef(function (props, ref) {
return [];
}, [currentDomainGroup, treeDataMap])
useEffect(() => {
if ((businessElements??[]).length>0) {
setBusinessColumns(
(businessElements??[]).map(item => ({
...item,
title: <span>
{
item.required==='是' && <span style={{
marginRight: 4,
color: '#ff4d4f',
}}>*</span>
}
{ item.name }
</span>,
dataIndex: item.enName,
ellipsis: true,
render: (text, record, index) => {
let value = ''
const _index = (record.columnElements??[]).findIndex(_item => item.id === _item.id)
if (_index !== -1) {
value = record.columnElements[_index].value
}
columnForm?.setFieldsValue({ [`column${item.enName}${index}`]: value })
return (
<Form.Item name={`column${item.enName}${index}`}
rules={[{ required: (item.required==='是')?true:false, message: `请填写${item.enName}!` }]}
style={{ marginBottom: 0 }}
>
<MetadataColumnEditableItem
value={value}
isEdit={currentAction!=='detail'}
terms={terms}
onChange={(e) => {
onMetadataColumnEditableItemChange(e.target.value, item.enName, index)
}}
/>
</Form.Item>
)
}
}))
)
}
}, [businessElements, currentAction, terms, modifyMetadataColumnList])
const businessData = useMemo(() => {
if (currentDomainGroup && currentBussinessDomain && treeDataMap) {
const currentLevel2Data = treeDataMap[currentDomainGroup];
......@@ -280,7 +269,13 @@ const AssetAction = React.forwardRef(function (props, ref) {
}, [currentDomainGroup, currentBussinessDomain, treeDataMap])
useEffect(() => {
setStructured(template?.structedStateEnum==='structured'||assets?.structedState==='structured')
let _isStructured = template?.structedStateEnum==='structured'||assets?.structedState==='structured'
setStructured(_isStructured)
if (!_isStructured) {
getBusinessColumns()
}
}, [assets, template])
useEffect(() => {
......@@ -293,7 +288,7 @@ const AssetAction = React.forwardRef(function (props, ref) {
const cols = useMemo(() => {
let newCols = []
newCols = isStructured?[...columns]:[...businessColumns]
newCols = isStructured?[...columns]:[...businessColumns??[]]
if (!isStructured && currentAction!=='detail') {
newCols.push(businessActionCol)
}
......@@ -382,6 +377,20 @@ const AssetAction = React.forwardRef(function (props, ref) {
})
}
const getBusinessColumns = () => {
if (template?.type||assets?.templateType) {
dispatch({
type: 'assetmanage.listBusinessColumnElements',
payload: {
templateType: template?.type||assets?.templateType,
},
callback: (data) => {
setBusinessElements(data)
}
})
}
}
const getElements = () => {
setLoading(true);
dispatch({
......@@ -555,7 +564,12 @@ const AssetAction = React.forwardRef(function (props, ref) {
setModifyMetadataColumnList(
produce(modifyMetadataColumnList, (draft) => {
if ((draft??[]).length > _index) {
draft[_index][`${dataIndex}`] = val
const columnElements = draft[_index].columnElements
const __index = (columnElements??[]).findIndex(item => item.enName === dataIndex)
if (__index !== -1) {
columnElements[__index].value = val
}
}
})
)
......@@ -957,7 +971,7 @@ const AssetAction = React.forwardRef(function (props, ref) {
await columnForm?.validateFields()
setModifyMetadataColumnList(prev => {
return [{
columnElements: [...businessColumns??[]]
}, ...prev??[]]
})
} catch (errInfo) {
......
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