feat: model table

pull/12/head
xingyu 2023-05-11 15:10:00 +08:00
parent 7219895d9f
commit 833443b813
2 changed files with 81 additions and 8 deletions

View File

@ -37,11 +37,7 @@ export function updateModel(data: ModelVO) {
}
// 任务状态修改
export function updateModelState(id: number, state: number) {
const data = {
id: id,
state: state
}
export function updateModelState(data) {
return defHttp.put({ url: '/bpm/model/update-state', data })
}

View File

@ -1,10 +1,15 @@
import { updateModelState } from '@/api/bpm/model'
import { BasicColumn, FormSchema, useRender } from '@/components/Table'
import { useMessage } from '@/hooks/web/useMessage'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { Button, Switch } from 'ant-design-vue'
import { h } from 'vue'
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'id',
defaultHidden: true,
width: 100
},
{
@ -15,12 +20,12 @@ export const columns: BasicColumn[] = [
{
title: '流程名称',
dataIndex: 'name',
width: 200
width: 180
},
{
title: '流程分类',
dataIndex: 'category',
width: 180,
width: 120,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.BPM_MODEL_CATEGORY, 'string')
}
@ -28,7 +33,16 @@ export const columns: BasicColumn[] = [
{
title: '表单信息',
dataIndex: 'formType',
width: 200
width: 180,
customRender: ({ record }) => {
if (record.formId) {
return h(Button, { type: 'link', onClick: handleFormDetail.bind(null, record) }, () => record.formName)
} else if (record.formCustomCreatePath) {
return h(Button, { type: 'link', onClick: handleFormDetail.bind(null, record) }, () => record.formCustomCreatePath)
} else {
return useRender.renderTag('暂无表单')
}
}
},
{
title: '创建时间',
@ -37,6 +51,65 @@ export const columns: BasicColumn[] = [
customRender: ({ text }) => {
return useRender.renderDate(text)
}
},
{
title: '最新部署的流程定义',
children: [
{
title: '流程版本',
dataIndex: 'processDefinition.version',
width: 160,
customRender: ({ record }) => {
if (record.processDefinition) {
return useRender.renderTag('v' + record.processDefinition.version)
} else {
return useRender.renderTag('未部署')
}
}
},
{
title: '激活状态',
dataIndex: 'processDefinition.suspensionState',
width: 100,
customRender: ({ record }) => {
if (record.processDefinition) {
if (!Reflect.has(record, 'suspensionState')) {
record.pendingStatus = false
}
return h(Switch, {
checked: record.processDefinition.suspensionState === 1,
checkedChildren: '激活',
unCheckedChildren: '挂起',
onChange(checked: boolean) {
const newStatus = checked ? 0 : 1
const { createMessage } = useMessage()
updateModelState({ id: record.id, state: newStatus })
.then(() => {
record.status = newStatus
createMessage.success(`已成功修改流程状态`)
})
.catch(() => {
createMessage.error('修改流程状态失败')
})
.finally(() => {
record.pendingStatus = false
})
}
})
}
}
},
{
title: '部署时间',
dataIndex: 'processDefinition.deploymentTim',
width: 180,
customRender: ({ record }) => {
if (record.processDefinition) {
return useRender.renderDate(record.processDefinition.deploymentTime)
}
}
}
]
}
]
@ -99,3 +172,7 @@ export const formSchema: FormSchema[] = [
component: 'InputTextArea'
}
]
function handleFormDetail() {
console.info('handleFormDetail')
}