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

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

View File

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

View File

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

View File

@ -27,8 +27,8 @@
<Icon icon="ep:arrow-right-bold" /> <Icon icon="ep:arrow-right-bold" />
</div> </div>
<div class="node-toolbar"> <div class="node-toolbar">
<div class="toolbar-icon"><Icon icon="ep:document-copy" @click="copyNode" /></div> <!-- <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>
</div> </div>
<!-- 传递子节点给添加节点组件会在子节点前面添加节点 --> <!-- 传递子节点给添加节点组件会在子节点前面添加节点 -->

View File

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

View File

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