Commit 6774c726 by zhaochengxiang

资源列表操作按钮

parent be9a0e36
......@@ -294,6 +294,10 @@ export function* getResourceDraft(payload) {
return yield call(service.getResourceDraft, payload)
}
export function* syncResourceDraft(payload) {
return yield call(service.syncResourceDraft, payload)
}
export function* getTasks(payload) {
return yield call(service.getTasks, payload)
}
\ No newline at end of file
......@@ -284,6 +284,10 @@ export function getPreviewRangeByDirId(payload) {
return GetJSON("/dataassetmanager/resourceApi/getDraft", payload)
}
export function syncResourceDraft(payload) {
return PostJSON("/dataassetmanager/resourceApi/syncDraft", payload)
}
export function getTasks(payload) {
return GetJSON("/dataassetmanager/resource/taskApi/listTasksByPage", payload)
}
\ No newline at end of file
......@@ -415,7 +415,9 @@ export function getAssetType(reference) {
}
export function getAssetRange(menuName) {
if (menuName === ResourceManageReference || menuName === AssetManageReference) {
if (menuName === ResourceManageReference ) {
return 'dataAsset_resourceManage';
} else if (menuName === AssetManageReference) {
return 'dataAsset_dataAssetManage';
} else if (menuName === AssetBrowseReference) {
return 'dataAsset_dataAssetBrowse';
......
......@@ -4,6 +4,7 @@ import { Tooltip, Typography, Space, Dropdown, Button, Menu, Checkbox, Input, Se
import ResizeObserver from 'rc-resize-observer'
import { debounceTime, Subject } from 'rxjs'
import { DownOutlined, UpOutlined } from "@ant-design/icons"
import LocalStorage from 'local-storage'
import { defaultPage, usePage } from '../../../util/hooks/page'
import Table from '../../../util/Component/Table'
......@@ -28,6 +29,25 @@ import TagCell from '../Model/Component/tag-help'
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 { type = ResourceManageReference, node, onClick, onFullScreenChange } = props
const [args, setArgs] = React.useState(() => ({
......@@ -52,6 +72,7 @@ const FC = (props) => {
const [total, setTotal] = React.useState()
const [selectedRows, setSelectedRows] = React.useState([])
const [row, setRow] = React.useState()
const [rightRow, setRightRow] = React.useState()
const [permissions, setPermissions] = React.useState([])
const [loadingSortStatus, setLoadingSortStatus] = React.useState(false)
const [sortStatus, setSortStatus] = React.useState()
......@@ -96,7 +117,7 @@ const FC = (props) => {
})
const [page, setPage] = usePage()
const [ modal, contextHolder ] = Modal.useModal()
const [modal, contextHolder] = Modal.useModal()
const locationIdRef = React.useRef(getQueryParam('id', props?.location?.search))
const locationDidRef = React.useRef(getQueryParam('did', props?.location?.search))
......@@ -235,6 +256,16 @@ const FC = (props) => {
return [_addAble, _importAble, _exportAble, _changeDiretoryAble, _deleteAble]
}, [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 = [
{
title: '梳理状态',
......@@ -452,7 +483,7 @@ const FC = (props) => {
if (locationIdRef.current) {
const index = (data?.data??[]).findIndex(item => item.id === locationIdRef.current)
console.log('index', index)
if (index !== -1) {
onClick?.(data?.data[index])
setRow(data?.data[index])
......@@ -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 }) => {
if (key === 'addToAsset') {
onAddToAssetClick()
......@@ -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 = (
<Menu onClick={onMenuClick}>
{
......@@ -966,6 +1120,9 @@ const FC = (props) => {
setRow(value)
onClick?.(value)
}}
onSyncClick={() => {
getAssets()
}}
/>
),
rowExpandable: (record) => record.resourceExtraAttribute?.existDraft,
......@@ -982,6 +1139,19 @@ const FC = (props) => {
columnWidth: 30,
} : 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>
</div>
......@@ -1089,10 +1259,12 @@ const FC = (props) => {
export default FC
const ExpandedRow = ({ id, columns, onRowClick }) => {
const ExpandedRow = ({ id, columns, onRowClick, onSyncClick }) => {
const [loading, setLoading] = React.useState(false)
const [data, setData] = React.useState()
const [modal, contextHolder] = Modal.useModal()
const tableData = React.useMemo(() => {
const newTableData = []
if (data) {
......@@ -1113,6 +1285,16 @@ const ExpandedRow = ({ id, columns, onRowClick }) => {
}
}, [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 = () => {
setLoading(true)
dispatch({
......@@ -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 (
<div style={{ padding: 10 }}>
<Table
......@@ -1138,7 +1364,20 @@ const ExpandedRow = ({ id, columns, onRowClick }) => {
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>
)
}
\ 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