仿钉钉流程设计器-修复一些问题

This commit is contained in:
jason 2024-04-28 21:53:34 +08:00
parent ee895d0752
commit 0d8d043250
6 changed files with 54 additions and 34 deletions

View File

@ -152,7 +152,7 @@ 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 { defaultProps, handleTree } from '@/utils/tree'
import { defaultProps } from '@/utils/tree'
defineOptions({
name: 'CopyTaskNodeConfig'
})
@ -175,8 +175,8 @@ const postOptions = inject<Ref<PostApi.PostVO[]>>('postList') // 岗位列表
const userOptions = inject<Ref<UserApi.UserVO[]>>('userList') //
const deptOptions = inject<Ref<DeptApi.DeptVO[]>>('deptList') //
const userGroupOptions = inject<Ref<UserGroupApi.UserGroupVO[]>>('userGroupList') //
const deptTreeOptions = ref() //
deptTreeOptions.value = handleTree(deptOptions?.value as DeptApi.DeptVO[], 'id')
const deptTreeOptions = inject('deptTree') //
//
const copyUserStrategies = computed( ()=> {
return getIntDictOptions(DICT_TYPE.BPM_TASK_CANDIDATE_STRATEGY)
@ -285,7 +285,6 @@ const getShowText = () : string => {
}
onMounted(async () => {
console.log('candidateParam', currentNode.value.attributes?.candidateParam)
candidateParamArray.value = currentNode.value.attributes?.candidateParam?.split(',').map(item=> +item)
console.log('candidateParamArray.value', candidateParamArray.value)

View File

@ -164,7 +164,7 @@
<script setup lang="ts">
import { SimpleFlowNode, APPROVE_METHODS,CandidateStrategy } from '../consts'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import { defaultProps } from '@/utils/tree'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as PostApi from '@/api/system/post'
@ -186,12 +186,12 @@ const emits = defineEmits<{
const notAllowedMultiApprovers = ref(false)
const currentNode = ref<SimpleFlowNode>(props.flowNode)
const settingVisible = ref(false)
const roleOptions = ref<RoleApi.RoleVO[]>([]) //
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
let deptOptions: DeptApi.DeptVO[] = []//
const deptTreeOptions = ref() //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const roleOptions = inject<Ref<RoleApi.RoleVO[]>>('roleList') //
const postOptions = inject<Ref<PostApi.PostVO[]>>('postList') //
const userOptions = inject<Ref<UserApi.UserVO[]>>('userList') //
const deptOptions = inject<Ref<DeptApi.DeptVO[]>>('deptList') //
const userGroupOptions = inject<Ref<UserGroupApi.UserGroupVO[]>>('userGroupList') //
const deptTreeOptions = inject('deptTree') //
const candidateParamArray = ref<any[]>([])
const closeDrawer = () => {
@ -210,7 +210,7 @@ const getShowText = () : string => {
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.USER) {
if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = []
userOptions.value.forEach((item) => {
userOptions?.value.forEach((item) => {
if (candidateParamArray.value.includes(item.id)) {
candidateNames.push(item.nickname)
}
@ -223,7 +223,7 @@ const getShowText = () : string => {
if (currentNode.value.attributes.candidateStrategy === 10) {
if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = []
roleOptions.value.forEach((item) => {
roleOptions?.value.forEach((item) => {
if (candidateParamArray.value.includes(item.id)) {
candidateNames.push(item.name)
}
@ -236,7 +236,7 @@ const getShowText = () : string => {
|| currentNode.value.attributes.candidateStrategy === CandidateStrategy.DEPT_LEADER ) {
if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = []
deptOptions.forEach((item) => {
deptOptions?.value.forEach((item) => {
if (candidateParamArray.value.includes(item.id)) {
candidateNames.push(item.name)
}
@ -253,7 +253,7 @@ const getShowText = () : string => {
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.POST) {
if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = []
postOptions.value.forEach((item) => {
postOptions?.value.forEach((item) => {
if (candidateParamArray.value.includes(item.id)) {
candidateNames.push(item.name)
}
@ -265,7 +265,7 @@ const getShowText = () : string => {
if (currentNode.value.attributes.candidateStrategy === CandidateStrategy.USER_GROUP) {
if (candidateParamArray.value?.length > 0) {
const candidateNames: string[] = []
userGroupOptions.value.forEach((item) => {
userGroupOptions?.value.forEach((item) => {
if (candidateParamArray.value.includes(item.id)) {
candidateNames.push(item.name)
}
@ -311,15 +311,15 @@ const changedCandidateUsers = () => {
}
onMounted(async () => {
//
roleOptions.value = await RoleApi.getSimpleRoleList()
postOptions.value = await PostApi.getSimplePostList()
//
userOptions.value = await UserApi.getSimpleUserList()
//
deptOptions = await DeptApi.getSimpleDeptList()
deptTreeOptions.value = handleTree(deptOptions, 'id')
//
userGroupOptions.value = await UserGroupApi.getUserGroupSimpleList()
// roleOptions.value = await RoleApi.getSimpleRoleList()
// postOptions.value = await PostApi.getSimplePostList()
// //
// userOptions.value = await UserApi.getSimpleUserList()
// //
// deptOptions = await DeptApi.getSimpleDeptList()
// deptTreeOptions.value = handleTree(deptOptions, 'id')
// //
// userGroupOptions.value = await UserGroupApi.getUserGroupSimpleList()
console.log('candidateParam', currentNode.value.attributes?.candidateParam)
candidateParamArray.value = currentNode.value.attributes?.candidateParam?.split(',').map(item=> +item)
console.log('candidateParamArray.value', candidateParamArray.value)

View File

@ -28,7 +28,7 @@
</div>
<div class="node-toolbar">
<!-- <div class="toolbar-icon"><Icon icon="ep:document-copy" @click="copyNode" /></div> -->
<div class="toolbar-icon"><Icon icon="ep:delete" @click="deleteNode" /></div>
<div class="toolbar-icon"><Icon icon="ep:circle-close" :size="18" @click="deleteNode" /></div>
</div>
</div>
@ -47,6 +47,7 @@
import { SimpleFlowNode, NodeType, NODE_DEFAULT_TEXT, NODE_DEFAULT_NAME } from '../consts'
import NodeHandler from '../NodeHandler.vue'
import CopyTaskNodeConfig from '../nodes-config/CopyTaskNodeConfig.vue';
import { generateUUID } from '@/utils'
defineOptions({
name: 'CopyTaskNode'
})
@ -88,9 +89,25 @@ const openNodeConfig = () => {
//
const deleteNode = () => {
console.log('the child node is ', currentNode.value.childNode)
emits('update:modelValue', currentNode.value.childNode)
}
//
const copyNode = () => {
const newCopyNode: SimpleFlowNode = {
id: generateUUID(),
name: currentNode.value.name,
showText: currentNode.value.showText,
type: currentNode.value.type,
//
attributes: {
candidateStrategy: currentNode.value.attributes?.candidateStrategy,
candidateParam: currentNode.value.attributes?.candidateParam
},
childNode: currentNode.value
}
currentNode.value = newCopyNode
emits('update:modelValue', currentNode.value)
}
//
const handleModelValueUpdate = (updateValue) => {
emits('update:modelValue', updateValue)

View File

@ -27,8 +27,8 @@
<Icon icon="ep:arrow-right-bold" />
</div>
<div class="node-toolbar">
<div class="toolbar-icon"><Icon icon="ep:document-copy" @click="copyNode" /></div>
<div class="toolbar-icon"><Icon icon="ep:delete" @click="deleteNode" /></div>
<!-- <div class="toolbar-icon"><Icon icon="ep:document-copy" @click="copyNode" /></div> -->
<div class="toolbar-icon"><Icon icon="ep:circle-close" :size="18" @click="deleteNode" /></div>
</div>
</div>
<!-- 传递子节点给添加节点组件会在子节点前面添加节点 -->

View File

@ -178,15 +178,14 @@
.node-toolbar {
opacity: 0;
position: absolute;
top: -26px;
right: 10px;
top: -5px;
right: -8px;
display: flex;
.toolbar-icon {
text-align: center;
vertical-align: middle;
color: #000;
border-radius: 4px;
color: #6d6c6e;
}
}
}

View File

@ -5,6 +5,7 @@
import { SimpleProcessDesigner } from '@/components/SimpleProcessDesignerV2/src/';
import { getModel } from '@/api/bpm/model'
import { getForm, FormVO } from '@/api/bpm/form'
import { handleTree } from '@/utils/tree'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as PostApi from '@/api/system/post'
@ -21,6 +22,7 @@ const roleOptions = ref<RoleApi.RoleVO[]>([]) // 角色列表
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
const deptOptions = ref<DeptApi.DeptVO[]>([]) //
const deptTreeOptions = ref()
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
provide('formFields', formFields)
provide('formType', formType)
@ -29,6 +31,7 @@ provide('postList', postOptions)
provide('userList', userOptions)
provide('deptList', deptOptions)
provide('userGroupList', userGroupOptions)
provide('deptTree', deptTreeOptions)
onMounted( async () => {
const bpmnModel = await getModel(modelId);
if (bpmnModel) {
@ -45,7 +48,9 @@ onMounted( async () => {
userOptions.value = await UserApi.getSimpleUserList()
//
deptOptions.value = await DeptApi.getSimpleDeptList()
console.log('index deptOptions value is' , deptOptions.value)
deptTreeOptions.value = handleTree(deptOptions.value as DeptApi.DeptVO[], 'id');
//
userGroupOptions.value = await UserGroupApi.getUserGroupSimpleList()
})