Commit 3cae61f7 by zhaochengxiang

增加操作

parent afe7beab
import React from "react" import React from "react"
import { Space, Select, Button, Tooltip, Input, Typography, Modal, Pagination } from 'antd' import { Space, Select, Button, Tooltip, Input, Typography, Modal, Pagination, Divider } from 'antd'
import LocalStorage from 'local-storage' import LocalStorage from 'local-storage'
import { useDebounceEffect } from 'ahooks' import { useDebounceEffect } from 'ahooks'
...@@ -8,6 +8,7 @@ import { dispatch } from '../../../model' ...@@ -8,6 +8,7 @@ import { dispatch } from '../../../model'
import Table from '../ResizeableTable' import Table from '../ResizeableTable'
import { isSzseEnv, showMessage } from "../../../util" import { isSzseEnv, showMessage } from "../../../util"
import { AssetItem } from "../AssetManage/Component/AssetTable" import { AssetItem } from "../AssetManage/Component/AssetTable"
import { recommandEnglishWords } from "../../../service/datamodeler"
const isAdmin = false const isAdmin = false
const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人'] const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人']
...@@ -27,6 +28,7 @@ const FC = (props) => { ...@@ -27,6 +28,7 @@ const FC = (props) => {
const [loading, setLoading] = React.useState(false) const [loading, setLoading] = React.useState(false)
const [data, setData] = React.useState() const [data, setData] = React.useState()
const [users, setUsers] = React.useState() const [users, setUsers] = React.useState()
const [row, setRow] = React.useState()
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
...@@ -48,6 +50,25 @@ const FC = (props) => { ...@@ -48,6 +50,25 @@ const FC = (props) => {
} }
}, [currentTemplateValue, keyword, currentElementValue, pagination], { wait: 300 }) }, [currentTemplateValue, keyword, currentElementValue, pagination], { wait: 300 })
const actionCol = {
title: '操作',
dataIndex: 'action',
width: 120,
fixed: 'right',
render: (_, record) => (
<Space size={5} split={<Divider type='vertical' style={{margin:0}} />}>
<a onClick={(e) => {
e.stopPropagation()
onEditClick(record)
}}>编辑</a>
<a onClick={(e) => {
e.stopPropagation()
onDeleteClick(record)
}}>删除</a>
</Space>
)
}
const [columns, tableData, total] = React.useMemo(() => { const [columns, tableData, total] = React.useMemo(() => {
const [newColumns, newTableData] = [[], []] const [newColumns, newTableData] = [[], []]
...@@ -95,6 +116,8 @@ const FC = (props) => { ...@@ -95,6 +116,8 @@ const FC = (props) => {
} }
} }
newColumns.push(actionCol)
if (!loadingFilterElements) { if (!loadingFilterElements) {
for (const item of (data?.data??[])) { for (const item of (data?.data??[])) {
let index = 0 let index = 0
...@@ -122,7 +145,7 @@ const FC = (props) => { ...@@ -122,7 +145,7 @@ const FC = (props) => {
} }
return [newColumns, newTableData, data?.total??0] return [newColumns, newTableData, data?.total??0]
}, [filterElements, data, loadingFilterElements, users]) }, [filterElements, data, loadingFilterElements, users, actionCol])
const getUsers = () => { const getUsers = () => {
dispatch({ dispatch({
...@@ -260,6 +283,31 @@ const FC = (props) => { ...@@ -260,6 +283,31 @@ const FC = (props) => {
}) })
} }
const onEditClick = (record) => {
}
const onDeleteClick = (record) => {
modal.confirm({
title: '是否确认删除该条资产目录',
onOk: () => {
dispatch({
type: 'assetmanage.deleteDrafts',
payload: {
params: {
isAdmin,
},
data: record?.id
},
callback: () => {
showMessage("success","删除成功")
getDrafts()
}
})
}
})
}
return ( return (
<div style={{ backgroundColor: '#fff', height: '100%' }}> <div style={{ backgroundColor: '#fff', height: '100%' }}>
<div className='flex p-3' style={{ <div className='flex p-3' style={{
...@@ -326,6 +374,16 @@ const FC = (props) => { ...@@ -326,6 +374,16 @@ const FC = (props) => {
setSelectedRows(selectedRows) setSelectedRows(selectedRows)
} }
}} }}
onRow={(record) => {
return {
onClick: (e) => {
setRow(record)
}
}
}}
rowClassName={(record, index) => {
return (record?.id === row?.id) ? 'yy-table-select-row' : ''
}}
scroll={{ y: 'calc(100vh - 209px - 72px)' }} scroll={{ y: 'calc(100vh - 209px - 72px)' }}
/> />
<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