Commit 6774c726 by zhaochengxiang

资源列表操作按钮

parent be9a0e36
...@@ -294,6 +294,10 @@ export function* getResourceDraft(payload) { ...@@ -294,6 +294,10 @@ export function* getResourceDraft(payload) {
return yield call(service.getResourceDraft, payload) return yield call(service.getResourceDraft, payload)
} }
export function* syncResourceDraft(payload) {
return yield call(service.syncResourceDraft, payload)
}
export function* getTasks(payload) { export function* getTasks(payload) {
return yield call(service.getTasks, payload) return yield call(service.getTasks, payload)
} }
\ No newline at end of file
...@@ -284,6 +284,10 @@ export function getPreviewRangeByDirId(payload) { ...@@ -284,6 +284,10 @@ export function getPreviewRangeByDirId(payload) {
return GetJSON("/dataassetmanager/resourceApi/getDraft", payload) return GetJSON("/dataassetmanager/resourceApi/getDraft", payload)
} }
export function syncResourceDraft(payload) {
return PostJSON("/dataassetmanager/resourceApi/syncDraft", payload)
}
export function getTasks(payload) { export function getTasks(payload) {
return GetJSON("/dataassetmanager/resource/taskApi/listTasksByPage", payload) return GetJSON("/dataassetmanager/resource/taskApi/listTasksByPage", payload)
} }
\ No newline at end of file
...@@ -415,7 +415,9 @@ export function getAssetType(reference) { ...@@ -415,7 +415,9 @@ export function getAssetType(reference) {
} }
export function getAssetRange(menuName) { export function getAssetRange(menuName) {
if (menuName === ResourceManageReference || menuName === AssetManageReference) { if (menuName === ResourceManageReference ) {
return 'dataAsset_resourceManage';
} else if (menuName === AssetManageReference) {
return 'dataAsset_dataAssetManage'; return 'dataAsset_dataAssetManage';
} else if (menuName === AssetBrowseReference) { } else if (menuName === AssetBrowseReference) {
return 'dataAsset_dataAssetBrowse'; return 'dataAsset_dataAssetBrowse';
......
...@@ -4,6 +4,7 @@ import { Tooltip, Typography, Space, Dropdown, Button, Menu, Checkbox, Input, Se ...@@ -4,6 +4,7 @@ import { Tooltip, Typography, Space, Dropdown, Button, Menu, Checkbox, Input, Se
import ResizeObserver from 'rc-resize-observer' import ResizeObserver from 'rc-resize-observer'
import { debounceTime, Subject } from 'rxjs' import { debounceTime, Subject } from 'rxjs'
import { DownOutlined, UpOutlined } from "@ant-design/icons" import { DownOutlined, UpOutlined } from "@ant-design/icons"
import LocalStorage from 'local-storage'
import { defaultPage, usePage } from '../../../util/hooks/page' import { defaultPage, usePage } from '../../../util/hooks/page'
import Table from '../../../util/Component/Table' import Table from '../../../util/Component/Table'
...@@ -28,6 +29,25 @@ import TagCell from '../Model/Component/tag-help' ...@@ -28,6 +29,25 @@ import TagCell from '../Model/Component/tag-help'
import '../AssetManage/Component/AssetTable.less' import '../AssetManage/Component/AssetTable.less'
// public static final String ADD_AS_ASSET_NAME = "addAsAsset";//新增为资产
// public static final String DISTRIBUTE_NAME = "distribute";//分配
// public static final String REDISTRIBUTE_NAME = "reDistribute";//转分配
// public static final String CHECK_NAME = "check";//复核
// public static final String CONVERT_TO_NON_ASSET_NAME = "convertToNonAsset";//转为非资产
// public static final String SYNC_NAME = "sync";//同步
// public static final String NOT_SYNC_NAME = "notSync";//不同步
// public static final String CONVERT_TO_UN_SORTING = "convertToUnSorting";//转为未梳理
const operationMap = {
addAsAsset: '新增为资产',
distribute: '分配',
reDistribute: '转分配',
check: '复核',
changeToNotAsset: '转为非资产',
changeToUncombed: '转为未梳理',
sync: '同步',
notSync: '不同步',
}
const FC = (props) => { const FC = (props) => {
const { type = ResourceManageReference, node, onClick, onFullScreenChange } = props const { type = ResourceManageReference, node, onClick, onFullScreenChange } = props
const [args, setArgs] = React.useState(() => ({ const [args, setArgs] = React.useState(() => ({
...@@ -52,6 +72,7 @@ const FC = (props) => { ...@@ -52,6 +72,7 @@ const FC = (props) => {
const [total, setTotal] = React.useState() const [total, setTotal] = React.useState()
const [selectedRows, setSelectedRows] = React.useState([]) const [selectedRows, setSelectedRows] = React.useState([])
const [row, setRow] = React.useState() const [row, setRow] = React.useState()
const [rightRow, setRightRow] = React.useState()
const [permissions, setPermissions] = React.useState([]) const [permissions, setPermissions] = React.useState([])
const [loadingSortStatus, setLoadingSortStatus] = React.useState(false) const [loadingSortStatus, setLoadingSortStatus] = React.useState(false)
const [sortStatus, setSortStatus] = React.useState() const [sortStatus, setSortStatus] = React.useState()
...@@ -96,7 +117,7 @@ const FC = (props) => { ...@@ -96,7 +117,7 @@ const FC = (props) => {
}) })
const [page, setPage] = usePage() const [page, setPage] = usePage()
const [ modal, contextHolder ] = Modal.useModal() const [modal, contextHolder] = Modal.useModal()
const locationIdRef = React.useRef(getQueryParam('id', props?.location?.search)) const locationIdRef = React.useRef(getQueryParam('id', props?.location?.search))
const locationDidRef = React.useRef(getQueryParam('did', props?.location?.search)) const locationDidRef = React.useRef(getQueryParam('did', props?.location?.search))
...@@ -235,6 +256,16 @@ const FC = (props) => { ...@@ -235,6 +256,16 @@ const FC = (props) => {
return [_addAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble] return [_addAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble]
}, [permissions, selectedRows]) }, [permissions, selectedRows])
const menuData = React.useMemo(() => {
const newMenuData = []
for (const key of rightRow?.allowButtons??[]) {
if (operationMap[`${key}`]) {
newMenuData.push(operationMap[`${key}`])
}
}
return newMenuData
}, rightRow)
const notElementCol = [ const notElementCol = [
{ {
title: '梳理状态', title: '梳理状态',
...@@ -452,7 +483,7 @@ const FC = (props) => { ...@@ -452,7 +483,7 @@ const FC = (props) => {
if (locationIdRef.current) { if (locationIdRef.current) {
const index = (data?.data??[]).findIndex(item => item.id === locationIdRef.current) const index = (data?.data??[]).findIndex(item => item.id === locationIdRef.current)
console.log('index', index)
if (index !== -1) { if (index !== -1) {
onClick?.(data?.data[index]) onClick?.(data?.data[index])
setRow(data?.data[index]) setRow(data?.data[index])
...@@ -651,6 +682,109 @@ const FC = (props) => { ...@@ -651,6 +682,109 @@ const FC = (props) => {
}) })
} }
const onRightAddToAssetClick = () => {
setAddToAssetParams({
visible: true,
items: [rightRow]
})
}
const onRightChangeToUncombedClick = () => {
modal.confirm({
title: '提示',
content: '是否将该条非资产的资源转为未梳理状态?',
onOk: () => {
dispatch({
type: 'assetmanage.updateResourceState',
payload: {
params: {
dataAssetId: rightRow?.id,
resourceState: 'uncombed'
}
},
callback: () => {
LocalStorage.set('assetResourceChange', !(LocalStorage.get('assetResourceChange')||false))
let event = new Event('storage')
event.key = 'assetResourceChange'
window?.dispatchEvent(event)
getAssets()
}
})
}
})
}
const onRightChangeToNotAssetClick = () => {
modal.confirm({
title: '提示',
content: '是否将该条未梳理的资源转为非资产?',
onOk: () => {
dispatch({
type: 'assetmanage.updateResourceState',
payload: {
params: {
dataAssetId: rightRow?.id,
resourceState: 'notRelatedAsset'
}
},
callback: () => {
LocalStorage.set('assetResourceChange', !(LocalStorage.get('assetResourceChange')||false))
let event = new Event('storage')
event.key = 'assetResourceChange'
window?.dispatchEvent(event)
getAssets()
}
});
}
})
}
const onRightSyncClick = () => {
modal.confirm({
title: '提示',
content: '确定同步选中内容的变更吗?',
onOk: () => {
dispatch({
type: 'assetmanage.syncResourceDraft',
payload: {
params: {
draftIds: rightRow?.id,
status: 1
}
},
callback: (data) => {
showMessage('success', '同步资源成功')
getAssets()
}
})
}
})
}
const onRightUnSyncClick = () => {
modal.confirm({
title: '提示',
content: '确定不同步选中内容的变更吗?',
onOk: () => {
dispatch({
type: 'assetmanage.syncResourceDraft',
payload: {
params: {
draftIds: rightRow?.id,
status: -1
}
},
callback: (data) => {
showMessage('success', '不同步资源成功')
getAssets()
}
})
}
})
}
const onMenuClick = ({ key }) => { const onMenuClick = ({ key }) => {
if (key === 'addToAsset') { if (key === 'addToAsset') {
onAddToAssetClick() onAddToAssetClick()
...@@ -675,6 +809,26 @@ const FC = (props) => { ...@@ -675,6 +809,26 @@ const FC = (props) => {
} }
} }
const onRightMenuItemClick = (key, record) => {
if (key === '新增为资产') {
onRightAddToAssetClick()
} else if (key === '分配') {
} else if (key === '转分配') {
} else if (key === '复核') {
} else if (key === '转为非资产') {
onRightChangeToNotAssetClick()
} else if (key === '转为未梳理') {
onRightChangeToUncombedClick()
} else if (key === '同步') {
onRightSyncClick()
} else if (key === '不同步') {
onRightUnSyncClick()
}
}
const moreMenu = ( const moreMenu = (
<Menu onClick={onMenuClick}> <Menu onClick={onMenuClick}>
{ {
...@@ -966,6 +1120,9 @@ const FC = (props) => { ...@@ -966,6 +1120,9 @@ const FC = (props) => {
setRow(value) setRow(value)
onClick?.(value) onClick?.(value)
}} }}
onSyncClick={() => {
getAssets()
}}
/> />
), ),
rowExpandable: (record) => record.resourceExtraAttribute?.existDraft, rowExpandable: (record) => record.resourceExtraAttribute?.existDraft,
...@@ -982,6 +1139,19 @@ const FC = (props) => { ...@@ -982,6 +1139,19 @@ const FC = (props) => {
columnWidth: 30, columnWidth: 30,
} : null } : null
} }
shouldRowContextMenu={(record) => {
setRightRow(record)
let allowContextMenu = false
for (const key of (record.allowButtons??[])) {
if (operationMap[`${key}`]) {
allowContextMenu = true
}
}
return allowContextMenu
}}
menuData={menuData}
menuPermissions={menuData}
onMenuItemClick={onRightMenuItemClick}
/> />
</ResizeObserver> </ResizeObserver>
</div> </div>
...@@ -1089,10 +1259,12 @@ const FC = (props) => { ...@@ -1089,10 +1259,12 @@ const FC = (props) => {
export default FC export default FC
const ExpandedRow = ({ id, columns, onRowClick }) => { const ExpandedRow = ({ id, columns, onRowClick, onSyncClick }) => {
const [loading, setLoading] = React.useState(false) const [loading, setLoading] = React.useState(false)
const [data, setData] = React.useState() const [data, setData] = React.useState()
const [modal, contextHolder] = Modal.useModal()
const tableData = React.useMemo(() => { const tableData = React.useMemo(() => {
const newTableData = [] const newTableData = []
if (data) { if (data) {
...@@ -1113,6 +1285,16 @@ const ExpandedRow = ({ id, columns, onRowClick }) => { ...@@ -1113,6 +1285,16 @@ const ExpandedRow = ({ id, columns, onRowClick }) => {
} }
}, [id]) }, [id])
const menuData = React.useMemo(() => {
const newMenuData = []
for (const key of data?.allowButtons??[]) {
if (operationMap[`${key}`]) {
newMenuData.push(operationMap[`${key}`])
}
}
return newMenuData
}, [data])
const getDraft = () => { const getDraft = () => {
setLoading(true) setLoading(true)
dispatch({ dispatch({
...@@ -1128,6 +1310,50 @@ const ExpandedRow = ({ id, columns, onRowClick }) => { ...@@ -1128,6 +1310,50 @@ const ExpandedRow = ({ id, columns, onRowClick }) => {
}) })
} }
const onMenuItemClick = (key, record) => {
if (key === '同步') {
modal.confirm({
title: '提示',
content: '确定同步选中内容的变更吗?',
onOk: () => {
dispatch({
type: 'assetmanage.syncResourceDraft',
payload: {
params: {
draftIds: record.id,
status: 1
}
},
callback: (data) => {
showMessage('success', '同步资源成功')
onSyncClick?.()
}
})
}
})
} else if (key === '不同步') {
modal.confirm({
title: '提示',
content: '确定不同步选中内容的变更吗?',
onOk: () => {
dispatch({
type: 'assetmanage.syncResourceDraft',
payload: {
params: {
draftIds: record.id,
status: -1
}
},
callback: (data) => {
showMessage('success', '不同步资源成功')
onSyncClick?.()
}
})
}
})
}
}
return ( return (
<div style={{ padding: 10 }}> <div style={{ padding: 10 }}>
<Table <Table
...@@ -1138,7 +1364,20 @@ const ExpandedRow = ({ id, columns, onRowClick }) => { ...@@ -1138,7 +1364,20 @@ const ExpandedRow = ({ id, columns, onRowClick }) => {
onRowClick={(event, value) => { onRowClick={(event, value) => {
onRowClick?.(event, value) onRowClick?.(event, value)
}} }}
shouldRowContextMenu={(record) => {
let allowContextMenu = false
for (const key of (record.allowButtons??[])) {
if (operationMap[`${key}`]) {
allowContextMenu = true
}
}
return allowContextMenu
}}
menuData={menuData}
menuPermissions={menuData}
onMenuItemClick={onMenuItemClick}
/> />
{contextHolder}
</div> </div>
) )
} }
\ 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