feat:【antd】【bpm】processInstance/create 代码评审
This commit is contained in:
@@ -9,6 +9,7 @@ export namespace BpmProcessDefinitionApi {
|
|||||||
key?: string;
|
key?: string;
|
||||||
version: number;
|
version: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
category: string;
|
||||||
description: string;
|
description: string;
|
||||||
deploymentTime: number;
|
deploymentTime: number;
|
||||||
suspensionState: number;
|
suspensionState: number;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
|||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
|
import { groupBy } from '@vben/utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@@ -28,45 +29,33 @@ defineOptions({ name: 'BpmProcessInstanceCreate' });
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
// 当前搜索关键字
|
const loading = ref(true); // 加载中
|
||||||
const searchName = ref('');
|
const processInstanceId: any = route.query.processInstanceId; // 流程实例编号。场景:重新发起时
|
||||||
const isSearching = ref(false);
|
|
||||||
// 流程实例编号。场景:重新发起时
|
const categoryList: any = ref([]); // 分类的列表
|
||||||
const processInstanceId: any = route.query.processInstanceId;
|
const activeCategory = ref(''); // 当前选中的分类
|
||||||
// 加载中
|
|
||||||
const loading = ref(true);
|
const searchName = ref(''); // 当前搜索关键字
|
||||||
// 分类的列表
|
|
||||||
const categoryList: any = ref([]);
|
|
||||||
// 当前选中的分类
|
|
||||||
const activeCategory = ref('');
|
|
||||||
// 流程定义的列表
|
|
||||||
const processDefinitionList = ref<BpmProcessDefinitionApi.ProcessDefinition[]>(
|
const processDefinitionList = ref<BpmProcessDefinitionApi.ProcessDefinition[]>(
|
||||||
[],
|
[],
|
||||||
);
|
); // 流程定义的列表
|
||||||
|
const filteredProcessDefinitionList = ref<
|
||||||
|
BpmProcessDefinitionApi.ProcessDefinition[]
|
||||||
|
>([]); // 用于存储搜索过滤后的流程定义
|
||||||
|
|
||||||
// 实现 groupBy 功能
|
const selectProcessDefinition = ref(); // 选择的流程定义
|
||||||
function groupBy(array: any[], key: string) {
|
const processDefinitionDetailRef = ref();
|
||||||
const result: Record<string, any[]> = {};
|
|
||||||
for (const item of array) {
|
|
||||||
const groupKey = item[key];
|
|
||||||
if (!result[groupKey]) {
|
|
||||||
result[groupKey] = [];
|
|
||||||
}
|
|
||||||
result[groupKey].push(item);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
async function getList() {
|
async function getList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
// 所有流程分类数据
|
// 1.1 所有流程分类数据
|
||||||
await getCategoryList();
|
await loadCategoryList();
|
||||||
// 所有流程定义数据
|
// 1.2 所有流程定义数据
|
||||||
await handleGetProcessDefinitionList();
|
await loadProcessDefinitionList();
|
||||||
|
|
||||||
// 如果 processInstanceId 非空,说明是重新发起
|
// 2. 如果 processInstanceId 非空,说明是重新发起
|
||||||
if (processInstanceId?.length > 0) {
|
if (processInstanceId?.length > 0) {
|
||||||
const processInstance = await getProcessInstance(processInstanceId);
|
const processInstance = await getProcessInstance(processInstanceId);
|
||||||
if (!processInstance) {
|
if (!processInstance) {
|
||||||
@@ -88,65 +77,34 @@ async function getList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 获取所有流程分类数据 */
|
/** 获取所有流程分类数据 */
|
||||||
async function getCategoryList() {
|
async function loadCategoryList() {
|
||||||
try {
|
categoryList.value = await getCategorySimpleList();
|
||||||
// 流程分类
|
|
||||||
categoryList.value = await getCategorySimpleList();
|
|
||||||
} catch {
|
|
||||||
// 错误处理
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取所有流程定义数据 */
|
/** 获取所有流程定义数据 */
|
||||||
async function handleGetProcessDefinitionList() {
|
async function loadProcessDefinitionList() {
|
||||||
try {
|
// 流程定义
|
||||||
// 流程定义
|
processDefinitionList.value = await getProcessDefinitionList({
|
||||||
processDefinitionList.value = await getProcessDefinitionList({
|
suspensionState: 1,
|
||||||
suspensionState: 1,
|
});
|
||||||
});
|
|
||||||
// 初始化过滤列表为全部流程定义
|
|
||||||
filteredProcessDefinitionList.value = processDefinitionList.value;
|
|
||||||
|
|
||||||
// 在获取完所有数据后,设置第一个有效分类为激活状态
|
// 空搜索,初始化相关数据
|
||||||
if (availableCategories.value.length > 0 && !activeCategory.value) {
|
handleQuery();
|
||||||
activeCategory.value = availableCategories.value[0].code;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// 错误处理
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 用于存储搜索过滤后的流程定义 */
|
|
||||||
const filteredProcessDefinitionList = ref<
|
|
||||||
BpmProcessDefinitionApi.ProcessDefinition[]
|
|
||||||
>([]);
|
|
||||||
|
|
||||||
/** 搜索流程 */
|
/** 搜索流程 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
if (searchName.value.trim()) {
|
if (searchName.value.trim()) {
|
||||||
// 如果有搜索关键字,进行过滤
|
// 如果有搜索关键字,进行过滤
|
||||||
isSearching.value = true;
|
|
||||||
filteredProcessDefinitionList.value = processDefinitionList.value.filter(
|
filteredProcessDefinitionList.value = processDefinitionList.value.filter(
|
||||||
(definition: any) =>
|
(definition: any) =>
|
||||||
definition.name.toLowerCase().includes(searchName.value.toLowerCase()),
|
definition.name.toLowerCase().includes(searchName.value.toLowerCase()),
|
||||||
);
|
);
|
||||||
|
// 如果有匹配,切换到第一个包含匹配结果的分类
|
||||||
// 获取搜索结果中的分类
|
activeCategory.value = availableCategories.value[0]?.name;
|
||||||
const searchResultGroups = groupBy(
|
|
||||||
filteredProcessDefinitionList.value,
|
|
||||||
'category',
|
|
||||||
);
|
|
||||||
const availableCategoryCodes = Object.keys(searchResultGroups);
|
|
||||||
|
|
||||||
// 如果有匹配的分类,切换到第一个包含匹配结果的分类
|
|
||||||
if (availableCategoryCodes.length > 0 && availableCategoryCodes[0]) {
|
|
||||||
activeCategory.value = availableCategoryCodes[0];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// 如果没有搜索关键字,恢复所有数据
|
// 如果没有搜索关键字,恢复所有数据
|
||||||
isSearching.value = false;
|
|
||||||
filteredProcessDefinitionList.value = processDefinitionList.value;
|
filteredProcessDefinitionList.value = processDefinitionList.value;
|
||||||
|
|
||||||
// 恢复到第一个可用分类
|
// 恢复到第一个可用分类
|
||||||
if (availableCategories.value.length > 0) {
|
if (availableCategories.value.length > 0) {
|
||||||
activeCategory.value = availableCategories.value[0].code;
|
activeCategory.value = availableCategories.value[0].code;
|
||||||
@@ -154,20 +112,13 @@ function handleQuery() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 判断流程定义是否匹配搜索 */
|
|
||||||
function isDefinitionMatchSearch(definition: any) {
|
|
||||||
if (!isSearching.value) return false;
|
|
||||||
return definition.name.toLowerCase().includes(searchName.value.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 流程定义的分组 */
|
/** 流程定义的分组 */
|
||||||
const processDefinitionGroup = computed(() => {
|
const processDefinitionGroup = computed(() => {
|
||||||
if (!processDefinitionList.value?.length) {
|
if (!processDefinitionList.value?.length) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const grouped = groupBy(filteredProcessDefinitionList.value, 'category');
|
|
||||||
// 按照 categoryList 的顺序重新组织数据
|
// 按照 categoryList 的顺序重新组织数据
|
||||||
|
const grouped = groupBy(filteredProcessDefinitionList.value, 'category');
|
||||||
const orderedGroup: Record<
|
const orderedGroup: Record<
|
||||||
string,
|
string,
|
||||||
BpmProcessDefinitionApi.ProcessDefinition[]
|
BpmProcessDefinitionApi.ProcessDefinition[]
|
||||||
@@ -182,17 +133,6 @@ const processDefinitionGroup = computed(() => {
|
|||||||
return orderedGroup;
|
return orderedGroup;
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 通过分类 code 获取对应的名称 */
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
function _getCategoryName(categoryCode: string) {
|
|
||||||
return categoryList.value?.find((ctg: any) => ctg.code === categoryCode)
|
|
||||||
?.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 表单相关 ==========
|
|
||||||
const selectProcessDefinition = ref(); // 选择的流程定义
|
|
||||||
const processDefinitionDetailRef = ref();
|
|
||||||
|
|
||||||
/** 处理选择流程的按钮操作 */
|
/** 处理选择流程的按钮操作 */
|
||||||
async function handleSelect(
|
async function handleSelect(
|
||||||
row: BpmProcessDefinitionApi.ProcessDefinition,
|
row: BpmProcessDefinitionApi.ProcessDefinition,
|
||||||
@@ -210,21 +150,14 @@ const availableCategories = computed(() => {
|
|||||||
if (!categoryList.value?.length || !processDefinitionGroup.value) {
|
if (!categoryList.value?.length || !processDefinitionGroup.value) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有有流程的分类代码
|
// 获取所有有流程的分类代码
|
||||||
const availableCategoryCodes = Object.keys(processDefinitionGroup.value);
|
const availableCategoryCodes = Object.keys(processDefinitionGroup.value);
|
||||||
|
|
||||||
// 过滤出有流程的分类
|
// 过滤出有流程的分类
|
||||||
return categoryList.value.filter((category: BpmCategoryApi.Category) =>
|
return categoryList.value.filter((category: BpmCategoryApi.Category) =>
|
||||||
availableCategoryCodes.includes(category.code),
|
availableCategoryCodes.includes(category.code),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 获取 tab 的位置 */
|
|
||||||
const tabPosition = computed(() => {
|
|
||||||
return window.innerWidth < 768 ? 'top' : 'left';
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 监听可用分类变化,自动设置正确的活动分类 */
|
/** 监听可用分类变化,自动设置正确的活动分类 */
|
||||||
watch(
|
watch(
|
||||||
availableCategories,
|
availableCategories,
|
||||||
@@ -251,7 +184,7 @@ onMounted(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<!-- TODO @ziye:【优先级:低】这里交互,可以做成类似 vue3 + element-plus 那个一样,滚动切换分类哈?对标钉钉、飞书哈; -->
|
<!-- TODO @jason:这里交互,可以做成类似 vue3 + element-plus 那个一样,滚动切换分类哈?对标钉钉、飞书哈; -->
|
||||||
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
|
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
|
||||||
<template v-if="!selectProcessDefinition">
|
<template v-if="!selectProcessDefinition">
|
||||||
<Card
|
<Card
|
||||||
@@ -275,8 +208,8 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div v-if="filteredProcessDefinitionList?.length">
|
<div v-if="filteredProcessDefinitionList?.length" class="-ml-6">
|
||||||
<Tabs v-model:active-key="activeCategory" :tab-position="tabPosition">
|
<Tabs v-model:active-key="activeCategory" tab-position="left">
|
||||||
<Tabs.TabPane
|
<Tabs.TabPane
|
||||||
v-for="category in availableCategories"
|
v-for="category in availableCategories"
|
||||||
:key="category.code"
|
:key="category.code"
|
||||||
@@ -297,7 +230,7 @@ onMounted(() => {
|
|||||||
hoverable
|
hoverable
|
||||||
class="definition-item-card w-full cursor-pointer"
|
class="definition-item-card w-full cursor-pointer"
|
||||||
:class="{
|
:class="{
|
||||||
'search-match': isDefinitionMatchSearch(definition),
|
'search-match': searchName.trim().length > 0,
|
||||||
}"
|
}"
|
||||||
:body-style="{
|
:body-style="{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -311,7 +244,6 @@ onMounted(() => {
|
|||||||
class="flow-icon-img object-contain"
|
class="flow-icon-img object-contain"
|
||||||
alt="流程图标"
|
alt="流程图标"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div v-else class="flow-icon flex-shrink-0">
|
<div v-else class="flow-icon flex-shrink-0">
|
||||||
<span class="text-xs text-white">
|
<span class="text-xs text-white">
|
||||||
{{ definition.name?.slice(0, 2) }}
|
{{ definition.name?.slice(0, 2) }}
|
||||||
@@ -351,6 +283,7 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
// @jason:看看能不能通过 tailwindcss 简化下
|
||||||
.process-definition-container {
|
.process-definition-container {
|
||||||
.definition-item-card {
|
.definition-item-card {
|
||||||
.flow-icon-img {
|
.flow-icon-img {
|
||||||
|
|||||||
@@ -49,12 +49,9 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['cancel']);
|
const emit = defineEmits(['cancel']);
|
||||||
|
|
||||||
// 增加表单就绪状态变量 表单就绪后再渲染form-create
|
|
||||||
const isFormReady = ref(false);
|
|
||||||
|
|
||||||
const { closeCurrentTab } = useTabs();
|
const { closeCurrentTab } = useTabs();
|
||||||
|
|
||||||
|
const isFormReady = ref(false); // 表单就绪状态变量:表单就绪后再渲染 form-create
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return `流程表单 - ${props.selectProcessDefinition.name}`;
|
return `流程表单 - ${props.selectProcessDefinition.name}`;
|
||||||
});
|
});
|
||||||
@@ -64,54 +61,51 @@ const detailForm = ref<ProcessFormData>({
|
|||||||
option: {},
|
option: {},
|
||||||
value: {},
|
value: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
const fApi = ref<any>();
|
const fApi = ref<any>();
|
||||||
|
|
||||||
const startUserSelectTasks = ref<UserTask[]>([]);
|
const startUserSelectTasks = ref<UserTask[]>([]);
|
||||||
const startUserSelectAssignees = ref<Record<string, string[]>>({});
|
const startUserSelectAssignees = ref<Record<string, string[]>>({});
|
||||||
const tempStartUserSelectAssignees = ref<Record<string, string[]>>({});
|
const tempStartUserSelectAssignees = ref<Record<string, string[]>>({});
|
||||||
|
|
||||||
const bpmnXML = ref<string | undefined>(undefined);
|
const bpmnXML = ref<string | undefined>(undefined);
|
||||||
const simpleJson = ref<string | undefined>(undefined);
|
const simpleJson = ref<string | undefined>(undefined);
|
||||||
|
|
||||||
const timelineRef = ref<any>();
|
const timelineRef = ref<any>();
|
||||||
const activeTab = ref('form');
|
const activeTab = ref('form');
|
||||||
const activityNodes = ref<BpmProcessInstanceApi.ApprovalNodeInfo[]>([]);
|
const activityNodes = ref<BpmProcessInstanceApi.ApprovalNodeInfo[]>([]);
|
||||||
const processInstanceStartLoading = ref(false);
|
const processInstanceStartLoading = ref(false);
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
async function submitForm() {
|
async function submitForm() {
|
||||||
if (!fApi.value || !props.selectProcessDefinition) {
|
if (!fApi.value || !props.selectProcessDefinition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 流程表单校验
|
||||||
|
await fApi.value.validate();
|
||||||
|
|
||||||
try {
|
// 校验指定审批人
|
||||||
// 流程表单校验
|
if (startUserSelectTasks.value?.length > 0) {
|
||||||
await fApi.value.validate();
|
for (const userTask of startUserSelectTasks.value) {
|
||||||
|
const assignees = startUserSelectAssignees.value[userTask.id];
|
||||||
// 校验指定审批人
|
if (Array.isArray(assignees) && assignees.length === 0) {
|
||||||
if (startUserSelectTasks.value?.length > 0) {
|
message.warning(`请选择${userTask.name}的候选人`);
|
||||||
for (const userTask of startUserSelectTasks.value) {
|
return;
|
||||||
const assignees = startUserSelectAssignees.value[userTask.id];
|
|
||||||
if (Array.isArray(assignees) && assignees.length === 0) {
|
|
||||||
message.warning(`请选择${userTask.name}的候选人`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processInstanceStartLoading.value = true;
|
||||||
|
try {
|
||||||
// 提交请求
|
// 提交请求
|
||||||
processInstanceStartLoading.value = true;
|
|
||||||
await createProcessInstance({
|
await createProcessInstance({
|
||||||
processDefinitionId: props.selectProcessDefinition.id,
|
processDefinitionId: props.selectProcessDefinition.id,
|
||||||
variables: detailForm.value.value,
|
variables: detailForm.value.value,
|
||||||
startUserSelectAssignees: startUserSelectAssignees.value,
|
startUserSelectAssignees: startUserSelectAssignees.value,
|
||||||
});
|
});
|
||||||
|
// 关闭并提示
|
||||||
message.success('发起流程成功');
|
message.success('发起流程成功');
|
||||||
|
await closeCurrentTab();
|
||||||
// TODO @ziye:有告警哈;
|
|
||||||
closeCurrentTab();
|
|
||||||
|
|
||||||
await router.push({ name: 'BpmTaskMy' });
|
await router.push({ name: 'BpmTaskMy' });
|
||||||
} catch (error) {
|
|
||||||
console.error('发起流程失败:', error);
|
|
||||||
} finally {
|
} finally {
|
||||||
processInstanceStartLoading.value = false;
|
processInstanceStartLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -139,6 +133,7 @@ async function initProcessInfo(row: any, formVariables?: any) {
|
|||||||
setConfAndFields2(detailForm, row.formConf, row.formFields, formVariables);
|
setConfAndFields2(detailForm, row.formConf, row.formFields, formVariables);
|
||||||
|
|
||||||
// 设置表单就绪状态
|
// 设置表单就绪状态
|
||||||
|
// TODO @jason:这个变量是必须的,有没可能简化掉?
|
||||||
isFormReady.value = true;
|
isFormReady.value = true;
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
@@ -191,53 +186,45 @@ async function getApprovalDetail(row: {
|
|||||||
id: string;
|
id: string;
|
||||||
processVariablesStr: string;
|
processVariablesStr: string;
|
||||||
}) {
|
}) {
|
||||||
try {
|
const data = await getApprovalDetailApi({
|
||||||
const data = await getApprovalDetailApi({
|
processDefinitionId: row.id,
|
||||||
processDefinitionId: row.id,
|
activityId: BpmNodeIdEnum.START_USER_NODE_ID,
|
||||||
activityId: BpmNodeIdEnum.START_USER_NODE_ID,
|
processVariablesStr: row.processVariablesStr,
|
||||||
processVariablesStr: row.processVariablesStr,
|
});
|
||||||
|
if (!data) {
|
||||||
|
message.error('查询不到审批详情信息!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取审批节点
|
||||||
|
activityNodes.value = data.activityNodes;
|
||||||
|
|
||||||
|
// 获取发起人自选的任务
|
||||||
|
startUserSelectTasks.value = (data.activityNodes?.filter(
|
||||||
|
(node) =>
|
||||||
|
BpmCandidateStrategyEnum.START_USER_SELECT === node.candidateStrategy,
|
||||||
|
) || []) as unknown as UserTask[];
|
||||||
|
|
||||||
|
// 恢复之前的选择审批人
|
||||||
|
if (startUserSelectTasks.value.length > 0) {
|
||||||
|
for (const node of startUserSelectTasks.value) {
|
||||||
|
const tempAssignees = tempStartUserSelectAssignees.value[node.id];
|
||||||
|
startUserSelectAssignees.value[node.id] = tempAssignees?.length
|
||||||
|
? tempAssignees
|
||||||
|
: [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置表单字段权限
|
||||||
|
const formFieldsPermission = data.formFieldsPermission;
|
||||||
|
if (formFieldsPermission) {
|
||||||
|
Object.entries(formFieldsPermission).forEach(([field, permission]) => {
|
||||||
|
setFieldPermission(field, permission as string);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
message.error('查询不到审批详情信息!');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取审批节点
|
|
||||||
activityNodes.value = data.activityNodes;
|
|
||||||
|
|
||||||
// 获取发起人自选的任务
|
|
||||||
startUserSelectTasks.value = (data.activityNodes?.filter(
|
|
||||||
(node) =>
|
|
||||||
BpmCandidateStrategyEnum.START_USER_SELECT === node.candidateStrategy,
|
|
||||||
) || []) as unknown as UserTask[];
|
|
||||||
|
|
||||||
// 恢复之前的选择审批人
|
|
||||||
if (startUserSelectTasks.value.length > 0) {
|
|
||||||
for (const node of startUserSelectTasks.value) {
|
|
||||||
const tempAssignees = tempStartUserSelectAssignees.value[node.id];
|
|
||||||
startUserSelectAssignees.value[node.id] = tempAssignees?.length
|
|
||||||
? tempAssignees
|
|
||||||
: [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置表单字段权限
|
|
||||||
const formFieldsPermission = data.formFieldsPermission;
|
|
||||||
if (formFieldsPermission) {
|
|
||||||
Object.entries(formFieldsPermission).forEach(([field, permission]) => {
|
|
||||||
setFieldPermission(field, permission as string);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
message.error('获取审批详情失败');
|
|
||||||
console.error('获取审批详情失败:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 设置表单权限 */
|
||||||
* 设置表单权限
|
|
||||||
*/
|
|
||||||
function setFieldPermission(field: string, permission: string) {
|
function setFieldPermission(field: string, permission: string) {
|
||||||
if (permission === BpmFieldPermissionType.READ) {
|
if (permission === BpmFieldPermissionType.READ) {
|
||||||
fApi.value?.disabled(true, field);
|
fApi.value?.disabled(true, field);
|
||||||
@@ -315,7 +302,6 @@ defineExpose({ initProcessInfo });
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
|
|
||||||
<Tabs.TabPane
|
<Tabs.TabPane
|
||||||
tab="流程图"
|
tab="流程图"
|
||||||
key="flow"
|
key="flow"
|
||||||
|
|||||||
@@ -87,3 +87,16 @@ export function copyValueToTarget(target: any, source: any) {
|
|||||||
// 更新目标对象值
|
// 更新目标对象值
|
||||||
Object.assign(target, newObj);
|
Object.assign(target, newObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 实现 groupBy 功能 */
|
||||||
|
export function groupBy(array: any[], key: string) {
|
||||||
|
const result: Record<string, any[]> = {};
|
||||||
|
for (const item of array) {
|
||||||
|
const groupKey = item[key];
|
||||||
|
if (!result[groupKey]) {
|
||||||
|
result[groupKey] = [];
|
||||||
|
}
|
||||||
|
result[groupKey].push(item);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user