7 changed files with 218 additions and 10 deletions
@ -0,0 +1,122 @@
@@ -0,0 +1,122 @@
|
||||
<template> |
||||
<PageWrapper |
||||
contentClass="flex" |
||||
contentFullHeight |
||||
fixedHeight |
||||
dense |
||||
> |
||||
<BasicTree class="m-4 mr-0 overflow-hidden bg-white w-1/4 xl:w-1/5" |
||||
title="流程分类" |
||||
toolbar |
||||
search |
||||
defaultExpandAll |
||||
:clickRowToExpand="false" |
||||
:treeData="state.treeData" |
||||
:fieldNames="{ key: 'id', title: 'name' }" |
||||
@select="handleSelect" |
||||
/> |
||||
<BasicTable class="w-3/4 xl:w-4/5" @register="registerTable"> |
||||
<template #bodyCell="{ column, record }"> |
||||
<template v-if="column.key === 'action'"> |
||||
<TableAction |
||||
:actions="[ |
||||
{ |
||||
label: '启动流程', |
||||
icon: 'fa-brands:discord', |
||||
onClick: handleProcessDefinitionStart.bind(null, record) |
||||
}]" |
||||
/> |
||||
</template> |
||||
</template> |
||||
</BasicTable> |
||||
</PageWrapper> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
/** |
||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* 采用vben-动态表格表单封装组件编写,不采用 setup 写法 |
||||
* Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved. |
||||
* author wangxiang4 |
||||
*/ |
||||
import { defineComponent, onMounted, reactive } from 'vue'; |
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||
import { listProcessDef } from '/@/api/platform/workflow/controller/process'; |
||||
import { columns, searchFormSchema } from './process.data'; |
||||
import { PageWrapper } from '/@/components/Page'; |
||||
import { BasicTree, TreeItem } from '/@/components/Tree'; |
||||
import { listToTree } from '/@/utils/helper/treeHelper'; |
||||
import { listProcessCategory } from '/@/api/platform/workflow/extension/controller/processCategory'; |
||||
|
||||
/** 类型规范统一声明定义区域 */ |
||||
interface TableState { |
||||
treeData: TreeItem[]; |
||||
} |
||||
|
||||
export default defineComponent({ |
||||
name: 'WorkflowProcess', |
||||
components: { |
||||
PageWrapper, |
||||
BasicTable, |
||||
TableAction, |
||||
BasicTree |
||||
}, |
||||
setup() { |
||||
/** 通用变量统一声明区域 */ |
||||
const state = reactive<TableState>({ |
||||
treeData: [] |
||||
}); |
||||
const [registerTable, { reload, getForm }] = useTable({ |
||||
title: '流程定义列表', |
||||
api: listProcessDef, |
||||
rowKey: 'id', |
||||
columns, |
||||
formConfig: { |
||||
compact: true, |
||||
labelWidth: 100, |
||||
schemas: searchFormSchema, |
||||
autoSubmitOnEnter: true, |
||||
showAdvancedButton: true, |
||||
autoAdvancedLine: 3 |
||||
}, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
bordered: true, |
||||
clickToRowSelect: false, |
||||
showIndexColumn: false, |
||||
actionColumn: { |
||||
width: 240, |
||||
title: '操作', |
||||
dataIndex: 'action', |
||||
fixed: false |
||||
} |
||||
}); |
||||
|
||||
onMounted(async () => { |
||||
state.treeData = listToTree(await listProcessCategory()); |
||||
}); |
||||
|
||||
function handleProcessDefinitionStart(record?: Recordable) { |
||||
} |
||||
|
||||
function handleSelect(selectedKeys: string[]) { |
||||
getForm().setFieldsValue({ |
||||
categoryId: selectedKeys[0] |
||||
}); |
||||
getForm().submit(); |
||||
} |
||||
|
||||
function handleRefreshTable() { |
||||
reload(); |
||||
} |
||||
|
||||
return { |
||||
state, |
||||
registerTable, |
||||
handleRefreshTable, |
||||
handleProcessDefinitionStart, |
||||
handleSelect, |
||||
}; |
||||
} |
||||
}); |
||||
</script> |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table'; |
||||
import { h } from 'vue'; |
||||
import { Tag } from 'ant-design-vue'; |
||||
import { listProcessCategory } from '/@/api/platform/workflow/extension/controller/processCategory'; |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '流程名称', |
||||
dataIndex: 'name', |
||||
width: 200, |
||||
}, |
||||
{ |
||||
title: '流程KEY', |
||||
dataIndex: 'key', |
||||
width: 200, |
||||
}, |
||||
{ |
||||
title: '流程分类', |
||||
dataIndex: 'category', |
||||
width: 150, |
||||
customRender: ({ record }) => { |
||||
const category = record.category; |
||||
return h(Tag, { color: 'processing' }, () => String(record.category).split(',')[1] || '未分类'); |
||||
} |
||||
}, |
||||
{ |
||||
title: '流程版本', |
||||
dataIndex: 'version', |
||||
width: 150, |
||||
customRender: ({ record }) => { |
||||
const version = record.version; |
||||
return h(Tag, { color: version ? 'success' : 'warning' }, () => version || '版本未发布'); |
||||
} |
||||
}, |
||||
{ |
||||
title: '上次发布时间', |
||||
dataIndex: 'deploymentTime', |
||||
width: 200 |
||||
} |
||||
]; |
||||
|
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
field: 'categoryId', |
||||
label: '流程分类', |
||||
component: 'ApiTreeSelect', |
||||
componentProps: { |
||||
placeholder: '请选择流程分类', |
||||
fieldNames:{ |
||||
label: 'name', |
||||
key: 'id', |
||||
value: 'id' |
||||
}, |
||||
api: listProcessCategory, |
||||
listToTree: true |
||||
}, |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
field: 'name', |
||||
label: '流程名称', |
||||
component: 'Input', |
||||
componentProps: { |
||||
placeholder: '请输入流程名称' |
||||
}, |
||||
colProps: { span: 8 } |
||||
} |
||||
]; |
Loading…
Reference in new issue