From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/components/SimpleProcessDesignerV2/src/node.ts | 617 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 617 insertions(+), 0 deletions(-)
diff --git a/src/components/SimpleProcessDesignerV2/src/node.ts b/src/components/SimpleProcessDesignerV2/src/node.ts
new file mode 100644
index 0000000..73534f6
--- /dev/null
+++ b/src/components/SimpleProcessDesignerV2/src/node.ts
@@ -0,0 +1,617 @@
+import { TaskStatusEnum } from '@/api/bpm/task'
+import * as RoleApi from '@/api/system/role'
+import * as DeptApi from '@/api/system/dept'
+import * as PostApi from '@/api/system/post'
+import * as UserApi from '@/api/system/user'
+import * as UserGroupApi from '@/api/bpm/userGroup'
+import {
+ SimpleFlowNode,
+ CandidateStrategy,
+ NodeType,
+ ApproveMethodType,
+ RejectHandlerType,
+ NODE_DEFAULT_NAME,
+ AssignStartUserHandlerType,
+ AssignEmptyHandlerType,
+ FieldPermissionType,
+ HttpRequestParam,
+ ProcessVariableEnum,
+ ConditionType,
+ ConditionGroup,
+ COMPARISON_OPERATORS
+} from './consts'
+import { parseFormFields } from '@/components/FormCreate/src/utils'
+
+export function useWatchNode(props: { flowNode: SimpleFlowNode }): Ref<SimpleFlowNode> {
+ const node = ref<SimpleFlowNode>(props.flowNode)
+ watch(
+ () => props.flowNode,
+ (newValue) => {
+ node.value = newValue
+ }
+ )
+ return node
+}
+
+// 瑙f瀽 formCreate 鎵�鏈夎〃鍗曞瓧娈�, 骞惰繑鍥�
+const parseFormCreateFields = (formFields?: string[]) => {
+ const result: Array<Record<string, any>> = []
+ if (formFields) {
+ formFields.forEach((fieldStr: string) => {
+ parseFormFields(JSON.parse(fieldStr), result)
+ })
+ }
+ return result
+}
+
+/**
+ * @description 琛ㄥ崟鏁版嵁鏉冮檺閰嶇疆锛岀敤浜庡彂璧蜂汉鑺傜偣 銆佸鎵硅妭鐐广�佹妱閫佽妭鐐�
+ */
+export function useFormFieldsPermission(defaultPermission: FieldPermissionType) {
+ // 瀛楁鏉冮檺閰嶇疆. 闇�瑕佹湁 field, title, permissioin 灞炴��
+ const fieldsPermissionConfig = ref<Array<Record<string, any>>>([])
+
+ const formType = inject<Ref<number | undefined>>('formType', ref()) // 琛ㄥ崟绫诲瀷
+
+ const formFields = inject<Ref<string[]>>('formFields', ref([])) // 娴佺▼琛ㄥ崟瀛楁
+
+ const getNodeConfigFormFields = (nodeFormFields?: Array<Record<string, string>>) => {
+ nodeFormFields = toRaw(nodeFormFields)
+ if (!nodeFormFields || nodeFormFields.length === 0) {
+ fieldsPermissionConfig.value = getDefaultFieldsPermission(unref(formFields))
+ } else {
+ fieldsPermissionConfig.value = mergeFieldsPermission(nodeFormFields, unref(formFields))
+ }
+ }
+ // 鍚堝苟宸茬粡璁剧疆鐨勮〃鍗曞瓧娈垫潈闄愶紝褰撳墠娴佺▼琛ㄥ崟瀛楁 (鍙兘鏂板锛屾垨鍒犻櫎浜嗗瓧娈�)
+ const mergeFieldsPermission = (
+ formFieldsPermisson: Array<Record<string, string>>,
+ formFields?: string[]
+ ) => {
+ let mergedFieldsPermission: Array<Record<string, any>> = []
+ if (formFields) {
+ mergedFieldsPermission = parseFormCreateFields(formFields).map((item) => {
+ const found = formFieldsPermisson.find(
+ (fieldPermission) => fieldPermission.field == item.field
+ )
+ return {
+ field: item.field,
+ title: item.title,
+ permission: found ? found.permission : defaultPermission
+ }
+ })
+ }
+ return mergedFieldsPermission
+ }
+
+ // 榛樿鐨勮〃鍗曟潈闄愶細 鑾峰彇琛ㄥ崟鐨勬墍鏈夊瓧娈碉紝璁剧疆瀛楁榛樿鏉冮檺涓哄彧璇�
+ const getDefaultFieldsPermission = (formFields?: string[]) => {
+ let defaultFieldsPermission: Array<Record<string, any>> = []
+ if (formFields) {
+ defaultFieldsPermission = parseFormCreateFields(formFields).map((item) => {
+ return {
+ field: item.field,
+ title: item.title,
+ permission: defaultPermission
+ }
+ })
+ }
+ return defaultFieldsPermission
+ }
+
+ // 鑾峰彇琛ㄥ崟鐨勬墍鏈夊瓧娈碉紝浣滀负涓嬫媺妗嗛�夐」
+ const formFieldOptions = parseFormCreateFields(unref(formFields))
+
+ return {
+ formType,
+ fieldsPermissionConfig,
+ formFieldOptions,
+ getNodeConfigFormFields
+ }
+}
+
+/**
+ * @description 鑾峰彇娴佺▼琛ㄥ崟鐨勫瓧娈�
+ */
+export function useFormFields() {
+ const formFields = inject<Ref<string[]>>('formFields', ref([])) // 娴佺▼琛ㄥ崟瀛楁
+ return parseFormCreateFields(unref(formFields))
+}
+
+// TODO @鑺嬭壙锛氬悗缁渶瑕佹妸鍚勭绫讳技 useFormFieldsPermission 鐨勯�昏緫锛屾娊鎴愪竴涓�氱敤鏂规硶銆�
+/**
+ * @description 鑾峰彇娴佺▼琛ㄥ崟鐨勫瓧娈靛拰鍙戣捣浜哄瓧娈�
+ */
+export function useFormFieldsAndStartUser() {
+ const injectFormFields = inject<Ref<string[]>>('formFields', ref([])) // 娴佺▼琛ㄥ崟瀛楁
+ const formFields = parseFormCreateFields(unref(injectFormFields))
+ // 娣诲姞鍙戣捣浜�
+ formFields.unshift({
+ field: ProcessVariableEnum.START_USER_ID,
+ title: '鍙戣捣浜�',
+ required: true
+ })
+ return formFields
+}
+
+export type UserTaskFormType = {
+ candidateStrategy: CandidateStrategy
+ approveMethod: ApproveMethodType
+ roleIds?: number[] // 瑙掕壊
+ deptIds?: number[] // 閮ㄩ棬
+ deptLevel?: number // 閮ㄩ棬灞傜骇
+ userIds?: number[] // 鐢ㄦ埛
+ userGroups?: number[] // 鐢ㄦ埛缁�
+ postIds?: number[] // 宀椾綅
+ expression?: string // 娴佺▼琛ㄨ揪寮�
+ formUser?: string // 琛ㄥ崟鍐呯敤鎴峰瓧娈�
+ formDept?: string // 琛ㄥ崟鍐呴儴闂ㄥ瓧娈�
+ approveRatio?: number
+ rejectHandlerType?: RejectHandlerType
+ returnNodeId?: string
+ timeoutHandlerEnable?: boolean
+ timeoutHandlerType?: number
+ assignEmptyHandlerType?: AssignEmptyHandlerType
+ assignEmptyHandlerUserIds?: number[]
+ assignStartUserHandlerType?: AssignStartUserHandlerType
+ timeDuration?: number
+ maxRemindCount?: number
+ buttonsSetting: any[]
+ taskCreateListenerEnable?: boolean
+ taskCreateListenerPath?: string
+ taskCreateListener?: {
+ header: HttpRequestParam[]
+ body: HttpRequestParam[]
+ }
+ taskAssignListenerEnable?: boolean
+ taskAssignListenerPath?: string
+ taskAssignListener?: {
+ header: HttpRequestParam[]
+ body: HttpRequestParam[]
+ }
+ taskCompleteListenerEnable?: boolean
+ taskCompleteListenerPath?: string
+ taskCompleteListener?: {
+ header: HttpRequestParam[]
+ body: HttpRequestParam[]
+ }
+ signEnable: boolean
+ reasonRequire: boolean
+ skipExpression?: string
+}
+
+export type CopyTaskFormType = {
+ candidateStrategy: CandidateStrategy
+ roleIds?: number[] // 瑙掕壊
+ deptIds?: number[] // 閮ㄩ棬
+ deptLevel?: number // 閮ㄩ棬灞傜骇
+ userIds?: number[] // 鐢ㄦ埛
+ userGroups?: number[] // 鐢ㄦ埛缁�
+ postIds?: number[] // 宀椾綅
+ formUser?: string // 琛ㄥ崟鍐呯敤鎴峰瓧娈�
+ formDept?: string // 琛ㄥ崟鍐呴儴闂ㄥ瓧娈�
+ expression?: string // 娴佺▼琛ㄨ揪寮�
+}
+
+/**
+ * @description 鑺傜偣琛ㄥ崟鏁版嵁銆� 鐢ㄤ簬瀹℃壒鑺傜偣銆佹妱閫佽妭鐐�
+ */
+export function useNodeForm(nodeType: NodeType) {
+ const roleOptions = inject<Ref<RoleApi.RoleVO[]>>('roleList', ref([])) // 瑙掕壊鍒楄〃
+ const postOptions = inject<Ref<PostApi.PostVO[]>>('postList', ref([])) // 宀椾綅鍒楄〃
+ const userOptions = inject<Ref<UserApi.UserVO[]>>('userList', ref([])) // 鐢ㄦ埛鍒楄〃
+ const deptOptions = inject<Ref<DeptApi.DeptVO[]>>('deptList', ref([])) // 閮ㄩ棬鍒楄〃
+ const userGroupOptions = inject<Ref<UserGroupApi.UserGroupVO[]>>('userGroupList', ref([])) // 鐢ㄦ埛缁勫垪琛�
+ const deptTreeOptions = inject('deptTree', ref()) // 閮ㄩ棬鏍�
+ const formFields = inject<Ref<string[]>>('formFields', ref([])) // 娴佺▼琛ㄥ崟瀛楁
+ const configForm = ref<UserTaskFormType | CopyTaskFormType>()
+ if (nodeType === NodeType.USER_TASK_NODE || nodeType === NodeType.TRANSACTOR_NODE) {
+ configForm.value = {
+ candidateStrategy: CandidateStrategy.USER,
+ approveMethod: ApproveMethodType.SEQUENTIAL_APPROVE,
+ approveRatio: 100,
+ rejectHandlerType: RejectHandlerType.FINISH_PROCESS,
+ assignStartUserHandlerType: AssignStartUserHandlerType.START_USER_AUDIT,
+ returnNodeId: '',
+ timeoutHandlerEnable: false,
+ timeoutHandlerType: 1,
+ timeDuration: 6, // 榛樿 6灏忔椂
+ maxRemindCount: 1, // 榛樿 鎻愰啋 1娆�
+ buttonsSetting: []
+ }
+ } else {
+ configForm.value = {
+ candidateStrategy: CandidateStrategy.USER
+ }
+ }
+
+ const getShowText = (): string => {
+ let showText = ''
+ // 鎸囧畾鎴愬憳
+ if (configForm.value?.candidateStrategy === CandidateStrategy.USER) {
+ if (configForm.value?.userIds!.length > 0) {
+ const candidateNames: string[] = []
+ userOptions?.value.forEach((item) => {
+ if (configForm.value?.userIds!.includes(item.id)) {
+ candidateNames.push(item.nickname)
+ }
+ })
+ showText = `鎸囧畾鎴愬憳锛�${candidateNames.join(',')}`
+ }
+ }
+ // 鎸囧畾瑙掕壊
+ if (configForm.value?.candidateStrategy === CandidateStrategy.ROLE) {
+ if (configForm.value.roleIds!.length > 0) {
+ const candidateNames: string[] = []
+ roleOptions?.value.forEach((item) => {
+ if (configForm.value?.roleIds!.includes(item.id)) {
+ candidateNames.push(item.name)
+ }
+ })
+ showText = `鎸囧畾瑙掕壊锛�${candidateNames.join(',')}`
+ }
+ }
+ // 鎸囧畾閮ㄩ棬
+ if (
+ configForm.value?.candidateStrategy === CandidateStrategy.DEPT_MEMBER ||
+ configForm.value?.candidateStrategy === CandidateStrategy.DEPT_LEADER ||
+ configForm.value?.candidateStrategy === CandidateStrategy.MULTI_LEVEL_DEPT_LEADER
+ ) {
+ if (configForm.value?.deptIds!.length > 0) {
+ const candidateNames: string[] = []
+ deptOptions?.value.forEach((item) => {
+ if (configForm.value?.deptIds!.includes(item.id!)) {
+ candidateNames.push(item.name)
+ }
+ })
+ if (configForm.value.candidateStrategy === CandidateStrategy.DEPT_MEMBER) {
+ showText = `閮ㄩ棬鎴愬憳锛�${candidateNames.join(',')}`
+ } else if (configForm.value.candidateStrategy === CandidateStrategy.DEPT_LEADER) {
+ showText = `閮ㄩ棬鐨勮礋璐d汉锛�${candidateNames.join(',')}`
+ } else {
+ showText = `澶氱骇閮ㄩ棬鐨勮礋璐d汉锛�${candidateNames.join(',')}`
+ }
+ }
+ }
+
+ // 鎸囧畾宀椾綅
+ if (configForm.value?.candidateStrategy === CandidateStrategy.POST) {
+ if (configForm.value.postIds!.length > 0) {
+ const candidateNames: string[] = []
+ postOptions?.value.forEach((item) => {
+ if (configForm.value?.postIds!.includes(item.id!)) {
+ candidateNames.push(item.name)
+ }
+ })
+ showText = `鎸囧畾宀椾綅: ${candidateNames.join(',')}`
+ }
+ }
+ // 鎸囧畾鐢ㄦ埛缁�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.USER_GROUP) {
+ if (configForm.value?.userGroups!.length > 0) {
+ const candidateNames: string[] = []
+ userGroupOptions?.value.forEach((item) => {
+ if (configForm.value?.userGroups!.includes(item.id)) {
+ candidateNames.push(item.name)
+ }
+ })
+ showText = `鎸囧畾鐢ㄦ埛缁�: ${candidateNames.join(',')}`
+ }
+ }
+
+ // 琛ㄥ崟鍐呯敤鎴峰瓧娈�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.FORM_USER) {
+ const formFieldOptions = parseFormCreateFields(unref(formFields))
+ const item = formFieldOptions.find((item) => item.field === configForm.value?.formUser)
+ showText = `琛ㄥ崟鐢ㄦ埛锛�${item?.title}`
+ }
+
+ // 琛ㄥ崟鍐呴儴闂ㄨ礋璐d汉
+ if (configForm.value?.candidateStrategy === CandidateStrategy.FORM_DEPT_LEADER) {
+ showText = `琛ㄥ崟鍐呴儴闂ㄨ礋璐d汉`
+ }
+
+ // 瀹℃壒浜鸿嚜閫�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.APPROVE_USER_SELECT) {
+ showText = `瀹℃壒浜鸿嚜閫塦
+ }
+
+ // 鍙戣捣浜鸿嚜閫�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.START_USER_SELECT) {
+ showText = `鍙戣捣浜鸿嚜閫塦
+ }
+ // 鍙戣捣浜鸿嚜宸�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.START_USER) {
+ showText = `鍙戣捣浜鸿嚜宸盽
+ }
+ // 鍙戣捣浜虹殑閮ㄩ棬璐熻矗浜�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.START_USER_DEPT_LEADER) {
+ showText = `鍙戣捣浜虹殑閮ㄩ棬璐熻矗浜篳
+ }
+ // 鍙戣捣浜虹殑閮ㄩ棬璐熻矗浜�
+ if (
+ configForm.value?.candidateStrategy === CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER
+ ) {
+ showText = `鍙戣捣浜鸿繛缁儴闂ㄨ礋璐d汉`
+ }
+ // 娴佺▼琛ㄨ揪寮�
+ if (configForm.value?.candidateStrategy === CandidateStrategy.EXPRESSION) {
+ showText = `娴佺▼琛ㄨ揪寮忥細${configForm.value.expression}`
+ }
+ return showText
+ }
+
+ /**
+ * 澶勭悊鍊欓�変汉鍙傛暟鐨勮祴鍊�
+ */
+ const handleCandidateParam = () => {
+ let candidateParam: undefined | string = undefined
+ if (!configForm.value) {
+ return candidateParam
+ }
+ switch (configForm.value.candidateStrategy) {
+ case CandidateStrategy.USER:
+ candidateParam = configForm.value.userIds!.join(',')
+ break
+ case CandidateStrategy.ROLE:
+ candidateParam = configForm.value.roleIds!.join(',')
+ break
+ case CandidateStrategy.POST:
+ candidateParam = configForm.value.postIds!.join(',')
+ break
+ case CandidateStrategy.USER_GROUP:
+ candidateParam = configForm.value.userGroups!.join(',')
+ break
+ case CandidateStrategy.FORM_USER:
+ candidateParam = configForm.value.formUser!
+ break
+ case CandidateStrategy.EXPRESSION:
+ candidateParam = configForm.value.expression!
+ break
+ case CandidateStrategy.DEPT_MEMBER:
+ case CandidateStrategy.DEPT_LEADER:
+ candidateParam = configForm.value.deptIds!.join(',')
+ break
+ // 鍙戣捣浜洪儴闂ㄨ礋璐d汉
+ case CandidateStrategy.START_USER_DEPT_LEADER:
+ case CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER:
+ candidateParam = configForm.value.deptLevel + ''
+ break
+ // 鎸囧畾杩炵画澶氱骇閮ㄩ棬鐨勮礋璐d汉
+ case CandidateStrategy.MULTI_LEVEL_DEPT_LEADER: {
+ // 鍊欓�変汉鍙傛暟鏍煎紡: | 鍒嗛殧 銆傚乏杈逛负閮ㄩ棬锛堝涓儴闂ㄧ敤 , 鍒嗛殧锛夈�� 鍙宠竟涓洪儴闂ㄥ眰绾�
+ const deptIds = configForm.value.deptIds!.join(',')
+ candidateParam = deptIds.concat('|' + configForm.value.deptLevel + '')
+ break
+ }
+ // 琛ㄥ崟鍐呴儴闂ㄧ殑璐熻矗浜�
+ case CandidateStrategy.FORM_DEPT_LEADER: {
+ // 鍊欓�変汉鍙傛暟鏍煎紡: | 鍒嗛殧 銆傚乏杈逛负琛ㄥ崟鍐呴儴闂ㄥ瓧娈点�� 鍙宠竟涓洪儴闂ㄥ眰绾�
+ const deptFieldOnForm = configForm.value.formDept!
+ candidateParam = deptFieldOnForm.concat('|' + configForm.value.deptLevel + '')
+ break
+ }
+ default:
+ break
+ }
+ return candidateParam
+ }
+ /**
+ * 瑙f瀽鍊欓�変汉鍙傛暟
+ */
+ const parseCandidateParam = (
+ candidateStrategy: CandidateStrategy,
+ candidateParam: string | undefined
+ ) => {
+ if (!configForm.value || !candidateParam) {
+ return
+ }
+ switch (candidateStrategy) {
+ case CandidateStrategy.USER: {
+ configForm.value.userIds = candidateParam.split(',').map((item) => +item)
+ break
+ }
+ case CandidateStrategy.ROLE:
+ configForm.value.roleIds = candidateParam.split(',').map((item) => +item)
+ break
+ case CandidateStrategy.POST:
+ configForm.value.postIds = candidateParam.split(',').map((item) => +item)
+ break
+ case CandidateStrategy.USER_GROUP:
+ configForm.value.userGroups = candidateParam.split(',').map((item) => +item)
+ break
+ case CandidateStrategy.FORM_USER:
+ configForm.value.formUser = candidateParam
+ break
+ case CandidateStrategy.EXPRESSION:
+ configForm.value.expression = candidateParam
+ break
+ case CandidateStrategy.DEPT_MEMBER:
+ case CandidateStrategy.DEPT_LEADER:
+ configForm.value.deptIds = candidateParam.split(',').map((item) => +item)
+ break
+ // 鍙戣捣浜洪儴闂ㄨ礋璐d汉
+ case CandidateStrategy.START_USER_DEPT_LEADER:
+ case CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER:
+ configForm.value.deptLevel = +candidateParam
+ break
+ // 鎸囧畾杩炵画澶氱骇閮ㄩ棬鐨勮礋璐d汉
+ case CandidateStrategy.MULTI_LEVEL_DEPT_LEADER: {
+ // 鍊欓�変汉鍙傛暟鏍煎紡: | 鍒嗛殧 銆傚乏杈逛负閮ㄩ棬锛堝涓儴闂ㄧ敤 , 鍒嗛殧锛夈�� 鍙宠竟涓洪儴闂ㄥ眰绾�
+ const paramArray = candidateParam.split('|')
+ configForm.value.deptIds = paramArray[0].split(',').map((item) => +item)
+ configForm.value.deptLevel = +paramArray[1]
+ break
+ }
+ // 琛ㄥ崟鍐呯殑閮ㄩ棬璐熻矗浜�
+ case CandidateStrategy.FORM_DEPT_LEADER: {
+ // 鍊欓�変汉鍙傛暟鏍煎紡: | 鍒嗛殧 銆傚乏杈逛负琛ㄥ崟鍐呯殑閮ㄩ棬瀛楁銆� 鍙宠竟涓洪儴闂ㄥ眰绾�
+ const paramArray = candidateParam.split('|')
+ configForm.value.formDept = paramArray[0]
+ configForm.value.deptLevel = +paramArray[1]
+ break
+ }
+ default:
+ break
+ }
+ }
+ return {
+ configForm,
+ roleOptions,
+ postOptions,
+ userOptions,
+ userGroupOptions,
+ deptTreeOptions,
+ handleCandidateParam,
+ parseCandidateParam,
+ getShowText
+ }
+}
+
+/**
+ * @description 鎶藉眽閰嶇疆
+ */
+export function useDrawer() {
+ // 鎶藉眽閰嶇疆鏄惁鍙
+ const settingVisible = ref(false)
+ // 鍏抽棴閰嶇疆鎶藉眽
+ const closeDrawer = () => {
+ settingVisible.value = false
+ }
+ // 鎵撳紑閰嶇疆鎶藉眽
+ const openDrawer = () => {
+ settingVisible.value = true
+ }
+ return {
+ settingVisible,
+ closeDrawer,
+ openDrawer
+ }
+}
+
+/**
+ * @description 鑺傜偣鍚嶇О閰嶇疆
+ */
+export function useNodeName(nodeType: NodeType) {
+ // 鑺傜偣鍚嶇О
+ const nodeName = ref<string>()
+ // 鑺傜偣鍚嶇О杈撳叆妗�
+ const showInput = ref(false)
+ // 鐐瑰嚮鑺傜偣鍚嶇О缂栬緫鍥炬爣
+ const clickIcon = () => {
+ showInput.value = true
+ }
+ // 鑺傜偣鍚嶇О杈撳叆妗嗗け鍘荤劍鐐�
+ const blurEvent = () => {
+ showInput.value = false
+ nodeName.value = nodeName.value || (NODE_DEFAULT_NAME.get(nodeType) as string)
+ }
+ return {
+ nodeName,
+ showInput,
+ clickIcon,
+ blurEvent
+ }
+}
+
+export function useNodeName2(node: Ref<SimpleFlowNode>, nodeType: NodeType) {
+ // 鏄剧ず鑺傜偣鍚嶇О杈撳叆妗�
+ const showInput = ref(false)
+ // 鑺傜偣鍚嶇О杈撳叆妗嗗け鍘荤劍鐐�
+ const blurEvent = () => {
+ showInput.value = false
+ node.value.name = node.value.name || (NODE_DEFAULT_NAME.get(nodeType) as string)
+ }
+ // 鐐瑰嚮鑺傜偣鏍囬杩涜杈撳叆
+ const clickTitle = () => {
+ showInput.value = true
+ }
+ return {
+ showInput,
+ clickTitle,
+ blurEvent
+ }
+}
+
+/**
+ * @description 鏍规嵁鑺傜偣浠诲姟鐘舵�侊紝鑾峰彇鑺傜偣浠诲姟鐘舵�佹牱寮�
+ */
+export function useTaskStatusClass(taskStatus: TaskStatusEnum | undefined): string {
+ if (!taskStatus) {
+ return ''
+ }
+ if (taskStatus === TaskStatusEnum.APPROVE) {
+ return 'status-pass'
+ }
+ if (taskStatus === TaskStatusEnum.RUNNING) {
+ return 'status-running'
+ }
+ if (taskStatus === TaskStatusEnum.REJECT) {
+ return 'status-reject'
+ }
+ if (taskStatus === TaskStatusEnum.CANCEL) {
+ return 'status-cancel'
+ }
+ return ''
+}
+
+/** 鏉′欢缁勪欢鏂囧瓧灞曠ず */
+export function getConditionShowText(
+ conditionType: ConditionType | undefined,
+ conditionExpression: string | undefined,
+ conditionGroups: ConditionGroup | undefined,
+ fieldOptions: Array<Record<string, any>>
+) {
+ let showText = ''
+ if (conditionType === ConditionType.EXPRESSION) {
+ if (conditionExpression) {
+ showText = `琛ㄨ揪寮忥細${conditionExpression}`
+ }
+ }
+ if (conditionType === ConditionType.RULE) {
+ // 鏉′欢缁勬槸鍚︿负涓庡叧绯�
+ const groupAnd = conditionGroups?.and
+ let warningMessage: undefined | string = undefined
+ const conditionGroup = conditionGroups?.conditions.map((item) => {
+ return (
+ '(' +
+ item.rules
+ .map((rule) => {
+ if (rule.leftSide && rule.rightSide) {
+ return (
+ getFormFieldTitle(fieldOptions, rule.leftSide) +
+ ' ' +
+ getOpName(rule.opCode) +
+ ' ' +
+ rule.rightSide
+ )
+ } else {
+ // 鏈変竴鏉¤鍒欎笉瀹屽杽銆傛彁绀洪敊璇�
+ warningMessage = '璇峰畬鍠勬潯浠惰鍒�'
+ return ''
+ }
+ })
+ .join(item.and ? ' 涓� ' : ' 鎴� ') +
+ ' ) '
+ )
+ })
+ if (warningMessage) {
+ showText = ''
+ } else {
+ showText = conditionGroup!.join(groupAnd ? ' 涓� ' : ' 鎴� ')
+ }
+ }
+ return showText
+}
+
+/** 鑾峰彇琛ㄥ崟瀛楁鍚嶇О*/
+const getFormFieldTitle = (fieldOptions: Array<Record<string, any>>, field: string) => {
+ const item = fieldOptions.find((item) => item.field === field)
+ return item?.title
+}
+
+/** 鑾峰彇鎿嶄綔绗﹀悕绉� */
+const getOpName = (opCode: string): string => {
+ const opName = COMPARISON_OPERATORS.find((item: any) => item.value === opCode)
+ return opName?.label
+}
--
Gitblit v1.8.0