Commit fdb006f4 by zhaochengxiang

草稿右键操作

parent 24c17156
......@@ -378,6 +378,18 @@ export function* saveAsDraft(payload) {
return yield call(service.saveAsDraft, payload);
}
export function* distributeTask(payload) {
return yield call(service.distributeTask, payload);
}
export function* reDistributeTask(payload) {
return yield call(service.reDistributeTask, payload);
}
export function* submitDraft(payload) {
return yield call(service.submitDraft, payload);
}
export function* addSubscribe(payload) {
return yield call(service.addSubscribe, payload);
}
......
......@@ -21,3 +21,6 @@ export function* userGroups() {
export function* getGroupUsers(payload) {
return yield call(service.getGroupUsers, payload);
}
export function* getUsers() {
return yield call(service.getUsers)
}
\ No newline at end of file
......@@ -385,6 +385,18 @@ export function saveAsDraft(payload) {
return PostJSON("/dataassetmanagertest/draftApi/saveAsDraft", payload)
}
export function distributeTask(payload) {
return PostJSON("/dataassetmanagertest/draftApi/distributeTask", payload)
}
export function reDistributeTask(payload) {
return PostJSON("/dataassetmanagertest/draftApi/reDistributeTask", payload)
}
export function submitDraft(payload) {
return PostJSON("/dataassetmanagertest/draftApi/submit", payload)
}
export function addSubscribe(payload) {
return PostJSON("/informationmanagement/subscribe/add", payload)
}
......
......@@ -30,3 +30,7 @@ export function userGroups() {
export function getGroupUsers(payload) {
return GetJSON(`/authservice/userGroups/${payload.id}/users`)
}
export function getUsers() {
return GetJSON('/authservice/users')
}
\ No newline at end of file
import React from "react"
import { Modal, Button, Form, Select, Spin, Checkbox, Space, Row } from "antd"
import { debounceTime, Subject } from 'rxjs'
import { dispatch } from '../../../model'
import { showMessage } from "../../../util"
const FC = (props) => {
const { visible, items, onCancel } = props
const [waiting, setWaiting] = React.useState(false)
const basicRef = React.useRef()
const close = (refresh = false) => {
setWaiting(false)
onCancel?.(refresh)
}
const save = async() => {
try {
const rows = await basicRef.current?.validate()
setWaiting(true)
dispatch({
type: 'assetmanage.distributeTask',
payload: {
data: {
resourceIds: (items??[]).map(item => item.id),
nextProcessUsers: rows.users,
}
},
callback: (data) => {
setWaiting(false)
showMessage('success', '分配成功')
onCancel(true)
},
error: () => {
setWaiting(false)
}
})
} catch (e) {
}
}
const footer = React.useMemo(() => {
return [
<Button key={'cancel'}
onClick={() => close()}
>取消</Button>,
<Button key={'save'} type='primary'
onClick={() => save()}
>发起流程</Button>
]
}, [close, save])
return (
<Modal
visible={visible}
footer={footer}
width='800px'
bodyStyle={{ padding: '15px', overflowX: 'auto', maxHeight: '80vh' }}
title='任务分配'
centered destroyOnClose
onCancel={() => { close() }}
>
<Spin spinning={waiting}>
<Basic ref={basicRef} />
</Spin>
</Modal>
)
}
export default FC
export const Basic = React.forwardRef(function ({ items }, ref) {
const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({
validate: async () => {
return await form.validateFields()
},
}), [form])
const onValuesChange = (changedValues, allValues) => {
console.log('all values', allValues)
}
return (
<Form
form={form}
labelCol={{ span: 3 }}
wrapperCol={{ span: 21 }}
autoComplete="off"
onValuesChange={onValuesChange}
>
<Form.Item
label='分配用户'
name='users'
rules={[{ required: true, message: '请选择用户!' }]}
>
<HandlersItem />
</Form.Item>
{/* <Form.Item
label='通知方式'
name='noticeTypes'
rules={[{ required: true, message: '请选择通知方式!' }]}
>
<NoticeItem />
</Form.Item> */}
</Form>
)
})
export const HandlersItem = ({ value, onChange }) => {
const [loading, setLoading] = React.useState(false)
const [users, setUsers] = React.useState()
const [options, setOptions] = React.useState([])
React.useEffect(() => {
getHandlers()
}, [])
const getHandlers = () => {
setLoading(true)
dispatch({
type: 'user.getUsers',
callback: (data) => {
setLoading(false)
setUsers(data)
setOptions(
(data??[]).map(item => ({
label: item.name,
value: item.id,
}))
)
},
error: () => {
setLoading(false)
}
})
}
const onHandleChange = (val) => {
const newUsers = (users??[]).filter(item => (val??[]).includes(item.id)).map(item => ({...item, displayName: item.dname}))
onChange?.(newUsers)
}
return (
<Select
placeholder='请选择用户'
loading={loading}
value={value?value.map(item => item.id):undefined}
onChange={onHandleChange}
allowClear
mode='multiple'
filterOption={true}
optionFilterProp='label'
options={options??[]}
/>
)
}
const NoticeItem = ({ value, onChange }) => {
const [noticeTypes, setNoticeTypes] = React.useState()
const [modal, contextHolder] = Modal.useModal()
React.useEffect(() => {
getNoticeTypes()
}, [])
const getNoticeTypes = () => {
dispatch({
type: 'assetmanage.getNoticeTypes',
callback: (data) => {
setNoticeTypes(data)
}
})
}
return (
<div style={{ lineHeight: '32px' }}>
{
(noticeTypes??[]).map((item, index) => (
<Row key={index}>
<Space>
<Checkbox checked={(value??[]).indexOf(item.type) !== -1} value={item.type} style={{ width: 100 }} onChange={(e) => {
if (e.target.checked) {
onChange?.([...value??[], item.type])
} else {
onChange?.((value??[]).filter(item => item !== e.target.value))
}
}}>{item.desc}</Checkbox>
<a onClick={() => {
dispatch({
type: 'assetmanage.getNoticeTemplate',
payload: {
module: 'dataAsset',
type: item.desc
},
callback: (content) => {
modal.info({
title: '模版信息',
content: content??'',
})
}
})
}}>查看通知模版</a>
</Space>
</Row>
))
}
{contextHolder}
</div>
)
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ import UpdateAsset from "../AssetManage/Component/AssetDetailDrawer"
import { AssetDraftReference } from "../../../util/constant"
import StartProcess from "./start-process"
import ImportAsset from "./import"
import DistributeTask from './distribute-task'
import RedistributeTask from './redistribute-task'
// const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人']
const specialCol = ['创建人', '更新人']
......@@ -19,11 +21,11 @@ const specialCol = ['创建人', '更新人']
const operationMap = {
view: '查看',
edit: '编辑',
delete: '删除',
// delete: '删除',
distribute: '分配',
reDistribute: '转分配',
submit: '提交',
publish: '发布',
// publish: '发布',
changeToPendingSubmit: '转为待提交',
}
......@@ -58,6 +60,14 @@ const FC = (props) => {
visible: false,
items: undefined,
})
const [distributeTaskParams, setDistributeTaskParams] = React.useState({
visible: false,
items: undefined,
})
const [redistributeTaskParams, setRedistributeTaskParams] = React.useState({
visible: false,
items: undefined
})
const [rightRow, setRightRow] = React.useState()
const [modal, contextHolder] = Modal.useModal();
......@@ -81,21 +91,23 @@ const FC = (props) => {
}
}, [currentTemplateValue, keyword, currentElementValue, pagination, isAdmin], { wait: 300 })
const canPublish = React.useMemo(() => {
let newSelectedRows = (selectedRows??[]).filter(item => item.draftState==='draft')
const [canPublish, canDelete] = React.useMemo(() => {
if ((selectedRows??[]).length === 0) return [false, false]
//非管理员不能操作停用状态的草稿
if (!isAdmin) {
newSelectedRows = (newSelectedRows??[]).filter(item => item.draftOperation!=='offline')
let [_canPublish, _canDelete] = [true, true]
for (const item of (selectedRows??[])) {
const publishIndex = (item.allowActions??[]).findIndex(item => item==='publish')
const deleteIndex = (item.allowActions??[]).findIndex(item => item==='delete')
if (publishIndex === -1) {
_canPublish = false
}
if (deleteIndex === -1) {
_canDelete = false
}
}
return (newSelectedRows??[]).length !== 0
}, [selectedRows, isAdmin])
const canDelete = React.useMemo(() => {
let newSelectedRows = (selectedRows??[]).filter(item => isAdmin || item.draftDeletable)
return (newSelectedRows??[]).length !== 0
}, [selectedRows, isAdmin])
return [_canPublish, _canDelete]
}, [selectedRows])
const menuData = React.useMemo(() => {
const newMenuData = []
......@@ -141,9 +153,9 @@ const FC = (props) => {
width: 120,
fixed: 'right',
render: (text, record) => {
if (text === 'release') return '新增'
if (text === 'change') return '修改'
if (text === 'offline') return '停用'
if (text === 'release') return '发布'
if (text === 'change') return '变更'
if (text === 'offline') return '下线'
return ''
}
......@@ -155,8 +167,10 @@ const FC = (props) => {
width: 120,
fixed: 'right',
render: (text, record) => {
if (text === 'draft') return '待提交'
if (text === 'auditing') return '审批中'
if (text === 0) return '待提交'
if (text === 1) return '处理中'
if (text === 2) return '已完成'
if (text === 3) return '已发布'
return ''
}
......@@ -347,7 +361,7 @@ const FC = (props) => {
const onPublishClick = () => {
if (isAdmin) {
modal.confirm({
title: '是否确认发布选中的资产目录',
title: '是否确认发布选中的资产',
onOk: () => {
dispatch({
type: 'assetmanage.publishDrafts',
......@@ -414,21 +428,54 @@ const FC = (props) => {
})
}
const onRightDistributeClick = () => {
if (rightRow) {
setDistributeTaskParams({
visible: true,
items: [rightRow]
})
}
}
const onRightRedistributeClick = () => {
if (rightRow) {
setRedistributeTaskParams({
visible: true,
items: [rightRow]
})
}
}
const onRightSubmitClick = () => {
modal.confirm({
title: '提示',
content: '是否确认提交选中的资产?',
onOk: () => {
dispatch({
type: 'assetmanage.submitDraft',
payload: {
data: [rightRow?.id]
},
callback: (data) => {
showMessage('success', '提交成功')
getDrafts()
}
})
}
})
}
const onRightMenuItemClick = (key, record) => {
if (key === '查看') {
onRightDetailClick()
} else if (key === '编辑') {
onRightEditClick()
} else if (key === '删除') {
} else if (key === '分配') {
onRightDistributeClick()
} else if (key === '转分配') {
onRightRedistributeClick()
} else if (key === '提交') {
} else if (key === '发布') {
onRightSubmitClick()
} else if (key === '转为待提交') {
}
......@@ -456,10 +503,10 @@ const FC = (props) => {
<Tooltip title={((selectedRows??[]).length === 0) ? '请先选择资产' : ''}>
<Button onClick={onExportClick} disabled={(selectedRows??[]).length === 0}>导出</Button>
</Tooltip>
<Tooltip title={canPublish?'':(isAdmin?'请先选择待提交的资产':'请先选择待提交并且不是停用类型的资产')}>
<Tooltip title={((selectedRows??[]).length === 0) ? '请先选择资产' : ''}>
<Button onClick={onPublishClick} disabled={!canPublish}>发布</Button>
</Tooltip>
<Tooltip title={canDelete ? '':(isAdmin?'请先选择资产':'请选择自己创建的资产')}>
<Tooltip title={((selectedRows??[]).length === 0) ? '请先选择资产' : ''}>
<Button onClick={onDeletesClick} disabled={!canDelete}>删除</Button>
</Tooltip>
</Space>
......@@ -577,6 +624,28 @@ const FC = (props) => {
refresh && getDrafts()
}}
/>
<DistributeTask
{...distributeTaskParams}
onCancel={(refresh) => {
setDistributeTaskParams({
visible: false,
items: undefined,
})
refresh && getDrafts()
}}
/>
<RedistributeTask
{...redistributeTaskParams}
onCancel={(refresh) => {
setRedistributeTaskParams({
visible: false,
items: undefined,
})
refresh && getDrafts()
}}
/>
{contextHolder}
</div>
)
......
import React from "react"
import { Modal, Button, Form, Select, Spin } from "antd"
import { dispatch } from '../../../model'
import { HandlersItem } from "./distribute-task"
import { showMessage } from "../../../util"
const FC = (props) => {
const { visible, items, onCancel } = props
const [waiting, setWaiting] = React.useState(false)
const basicRef = React.useRef()
const close = (refresh = false) => {
setWaiting(false)
onCancel?.(refresh)
}
const save = async() => {
try {
const rows = await basicRef.current?.validate()
setWaiting(true)
dispatch({
type: 'assetmanage.reDistributeTask',
payload: {
data: {
resourceIds: (items??[]).map(item => item.id),
taskUserList: rows.users,
}
},
callback: () => {
setWaiting(false)
showMessage('success', '转分配成功')
onCancel(true)
},
error: () => {
setWaiting(false)
}
})
} catch (e) {
}
}
const footer = React.useMemo(() => {
return [
<Button key={'cancel'}
onClick={() => close()}
>取消</Button>,
<Button key={'save'} type='primary'
onClick={() => save()}
>确定</Button>
]
}, [close, save])
return (
<Modal
visible={visible}
footer={footer}
width='800px'
bodyStyle={{ padding: '15px', overflowX: 'auto', maxHeight: '80vh' }}
title='任务转分配'
centered destroyOnClose
onCancel={() => { close() }}
>
<Spin spinning={waiting}>
<Basic ref={basicRef} />
</Spin>
</Modal>
)
}
export default FC
export const Basic = React.forwardRef(function ({ items }, ref) {
const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({
validate: async () => {
return await form.validateFields()
},
}), [form])
const onValuesChange = (changedValues, allValues) => {
console.log('all values', allValues)
}
return (
<Form
form={form}
labelCol={{ span: 3 }}
wrapperCol={{ span: 21 }}
autoComplete="off"
onValuesChange={onValuesChange}
>
<Form.Item
label='分配用户'
name='users'
rules={[{ required: true, message: '请选择用户!' }]}
>
<HandlersItem />
</Form.Item>
</Form>
)
})
\ 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