6 changed files with 145 additions and 90 deletions
@ -1,10 +1,10 @@
@@ -1,10 +1,10 @@
|
||||
import type { R } from '/#/axios'; |
||||
import type { TreeEntity, Page } from '/@/api/common/data/entity'; |
||||
|
||||
export type FormCategoryParams = Page & FormCategory; |
||||
export type ProcessCategoryParams = Page & ProcessCategory; |
||||
|
||||
export interface FormCategory extends TreeEntity<FormCategory> { |
||||
export interface ProcessCategory extends TreeEntity<ProcessCategory> { |
||||
[key: string]: any; |
||||
} |
||||
|
||||
export type FormCategoryResult = R<FormCategory[]>; |
||||
export type ProcessCategoryResult = R<ProcessCategory[]>; |
||||
|
@ -1,60 +1,102 @@
@@ -1,60 +1,102 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
width="720px" |
||||
title="设置流程分类" |
||||
minHeight="100px" |
||||
@register="registerModal" |
||||
@ok="handleSubmit" |
||||
@register="registerModal" |
||||
> |
||||
待实现 |
||||
<Form :model="modelRef" :rules="rulesRef"> |
||||
<FormItem name="category" :wrapperCol="{ style: { padding:'8px' } }" v-bind="validateInfos.category"> |
||||
<ApiTreeSelect |
||||
placeholder="请选择流程分类" |
||||
:fieldNames="{ |
||||
label: 'name', |
||||
key: 'id', |
||||
value: 'id' |
||||
}" |
||||
:treeDefaultExpandAll="true" |
||||
:api="listProcessCategory" |
||||
:listToTree="true" |
||||
@change="handleValueBind" |
||||
/> |
||||
</FormItem> |
||||
</Form> |
||||
</BasicModal> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
/** |
||||
/** |
||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||
* 采用ant-design-vue原生组件编写表单,采用 setup 写法 |
||||
* Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved. |
||||
* author wangxiang4 |
||||
*/ |
||||
import { ref, unref } from 'vue'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
import { reactive } from 'vue'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
import { Form } from 'ant-design-vue'; |
||||
import { setProcessCategory } from '/@/api/platform/workflow/controller/process'; |
||||
import { listProcessCategory } from '/@/api/platform/workflow/extension/controller/processCategory'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
import ApiTreeSelect from '/@/components/Form/src/components/ApiTreeSelect.vue'; |
||||
import type { ChangeEventExtra } from 'ant-design-vue/lib/vc-tree-select/TreeSelect'; |
||||
|
||||
/** 通用变量统一声明区域 */ |
||||
const tag = ref<Nullable<string>>(''); |
||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||
const emit = defineEmits(['success', 'register']); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => { |
||||
// 处理设置数据 |
||||
tag.value = data._tag; |
||||
const rootTree = { id: '0', name: '顶级分类', children: [] }; |
||||
|
||||
const id = data.record?.id; |
||||
/** 类型规范统一声明定义区域 */ |
||||
interface WindowState { |
||||
processDefKeys: string; |
||||
category: string; |
||||
} |
||||
/** 通用变量统一声明区域 */ |
||||
const { createMessage } = useMessage(); |
||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||
const emit = defineEmits(['success', 'register']); |
||||
const FormItem = Form.Item; |
||||
const useForm = Form.useForm; |
||||
const modelRef = reactive<WindowState>({ |
||||
processDefKeys: '', |
||||
category: '' |
||||
}); |
||||
|
||||
const rulesRef = reactive<Recordable>({ |
||||
category: [ |
||||
{ |
||||
required: true, |
||||
whitespace: true, |
||||
message: '请选择流程分类!', |
||||
} |
||||
] |
||||
}); |
||||
const { resetFields, clearValidate, validate, validateInfos } = useForm(modelRef, rulesRef); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner( (data: BoxPayload) => { |
||||
// 处理清除脏数据 |
||||
resetFields(); |
||||
clearValidate(); |
||||
// 处理设置数据 |
||||
modelRef.processDefKeys = data.id; |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
props.title = '设置流程表单分类'; |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
}); |
||||
|
||||
function handleValueBind(value: string, label: string[] = [], extra: ChangeEventExtra) { |
||||
label.unshift(value); |
||||
modelRef.category = label.join(','); |
||||
} |
||||
|
||||
/** 处理弹出框提交 */ |
||||
async function handleSubmit() { |
||||
/** 处理模态框提交 */ |
||||
async function handleSubmit() { |
||||
try { |
||||
// 验证数据 |
||||
await validate(); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
// 采用tag标签区分操作 |
||||
switch (unref(tag)) { |
||||
case 'add': |
||||
|
||||
break; |
||||
case 'edit': |
||||
|
||||
break; |
||||
} |
||||
if (!modelRef.processDefKeys) return createMessage.error('流程定义key不存在,请检查!'); |
||||
await setProcessCategory(modelRef); |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
Loading…
Reference in new issue