From 8e66053c17b6582ec9ce68f73bd9e17f2d42d9f2 Mon Sep 17 00:00:00 2001
From: pch <75729660@qq.com>
Date: Mon, 16 Dec 2024 19:39:04 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=8D=95?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/bpm/task/index.ts | 13 +
.../descriptor/flowableDescriptor.json | 7 +-
.../package/penal/PropertiesPanel.vue | 2 +-
.../package/penal/PropertiesPanelbk.vue | 2 +-
.../package/penal/form/ElementForm.vue | 266 ++--------
.../package/penal/form/ElementForm2.vue | 288 +++++++++++
.../package/penal/form/ElementFormbk.vue | 478 ++++++++++++++++++
.../penal/properties/ElementProperties.vue | 1 +
.../penal/task/task-components/UserTask.vue | 2 +-
src/utils/dict.ts | 2 +-
src/views/Home/qjgl/QjglDetail.vue | 91 ++--
.../bpm/processInstance/detail/index.vue | 13 +-
12 files changed, 900 insertions(+), 265 deletions(-)
create mode 100644 src/components/bpmnProcessDesigner/package/penal/form/ElementForm2.vue
create mode 100644 src/components/bpmnProcessDesigner/package/penal/form/ElementFormbk.vue
diff --git a/src/api/bpm/task/index.ts b/src/api/bpm/task/index.ts
index f3cda9f..f5bf3f9 100644
--- a/src/api/bpm/task/index.ts
+++ b/src/api/bpm/task/index.ts
@@ -34,6 +34,19 @@ export const getTaskListByProcessInstanceId = async (processInstanceId: string)
export const getTaskListByReturn = async (id: string) => {
return await request.get({ url: '/bpm/task/list-by-return', params: { id } })
}
+//得到当前处理人
+export const getTaskAssignee = async (taskId: string) => {
+ return await request.get({ url: '/bpm/task/getTaskAssignee', params: { taskId } })
+}
+//得到当前任务id列表
+export const getTaskIdsForProcessInstance = async (processinstanceId: string) => {
+ return await request.get({ url: '/bpm/task/getTaskIdsForProcessInstance', params: { processinstanceId } })
+}
+
+//得到当前处理人
+export const getTaskConfigFromBpmn = async (taskId: string,itemStr:string) => {
+ return await request.get({ url: '/bpm/task/getTaskConfigFromBpmn', params: { taskId,itemStr } })
+}
// 回退
export const returnTask = async (data: any) => {
diff --git a/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json b/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json
index 1ed6e92..6ff5e62 100644
--- a/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json
+++ b/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json
@@ -170,7 +170,12 @@
"type": "String"
},
{
- "name": "formType",
+ "name": "itemType",
+ "isAttr": true,
+ "type": "String"
+ },
+ {
+ "name": "itemContent",
"isAttr": true,
"type": "String"
},
diff --git a/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue b/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue
index ea3ccbc..4369969 100644
--- a/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue
+++ b/src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue
@@ -90,7 +90,7 @@ import FlowCondition from './flow-condition/FlowCondition.vue'
import SignalAndMassage from './signal-message/SignalAndMessage.vue'
import ElementListeners from './listeners/ElementListeners.vue'
import ElementProperties from './properties/ElementProperties.vue'
-// import ElementForm from './form/ElementForm.vue'
+// import ElementForm from './form/ElementForm2.vue'
import UserTaskListeners from './listeners/UserTaskListeners.vue'
// 切换tab自动刷新实现 begin+++++++++++++
export type TabRefresh = {
diff --git a/src/components/bpmnProcessDesigner/package/penal/PropertiesPanelbk.vue b/src/components/bpmnProcessDesigner/package/penal/PropertiesPanelbk.vue
index 86a1cf7..0d57945 100644
--- a/src/components/bpmnProcessDesigner/package/penal/PropertiesPanelbk.vue
+++ b/src/components/bpmnProcessDesigner/package/penal/PropertiesPanelbk.vue
@@ -66,7 +66,7 @@ import FlowCondition from './flow-condition/FlowCondition.vue'
import SignalAndMassage from './signal-message/SignalAndMessage.vue'
import ElementListeners from './listeners/ElementListeners.vue'
import ElementProperties from './properties/ElementProperties.vue'
-// import ElementForm from './form/ElementForm.vue'
+// import ElementForm from './form/ElementForm2.vue'
import UserTaskListeners from './listeners/UserTaskListeners.vue'
defineOptions({ name: 'MyPropertiesPanel' })
diff --git a/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue b/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue
index 33f0bc0..a84a0b4 100644
--- a/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue
+++ b/src/components/bpmnProcessDesigner/package/penal/form/ElementForm.vue
@@ -2,231 +2,35 @@
-
-
-
-
-
-
-
+
+
+
+
+ {{ dict.label }}
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/components/bpmnProcessDesigner/package/penal/form/ElementFormbk.vue b/src/components/bpmnProcessDesigner/package/penal/form/ElementFormbk.vue
new file mode 100644
index 0000000..33f0bc0
--- /dev/null
+++ b/src/components/bpmnProcessDesigner/package/penal/form/ElementFormbk.vue
@@ -0,0 +1,478 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue b/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue
index 494b3d9..d056f93 100644
--- a/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue
+++ b/src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue
@@ -92,6 +92,7 @@ const resetAttributesList = () => {
(pre, current) => pre.concat(current.values),
[]
)
+ console.log(JSON.stringify(bpmnElementPropertyList.value ?? []),"bpmnElementPropertyList.value ?? []")
// 复制 显示
elementPropertyList.value = JSON.parse(JSON.stringify(bpmnElementPropertyList.value ?? []))
}
diff --git a/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue b/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue
index eb45fc4..ca94d50 100644
--- a/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue
+++ b/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue
@@ -32,7 +32,6 @@
{{ dict.label }}
-
{
if (!businessObject) {
return
}
+
if (businessObject.candidateStrategy != undefined) {
userTaskForm.value.candidateStrategy = parseInt(businessObject.candidateStrategy) as any
} else {
diff --git a/src/utils/dict.ts b/src/utils/dict.ts
index 9ed54ea..de7d960 100644
--- a/src/utils/dict.ts
+++ b/src/utils/dict.ts
@@ -176,7 +176,7 @@ export enum DICT_TYPE {
BPM_PROCESS_LISTENER_TYPE = 'bpm_process_listener_type',
BPM_PROCESS_LISTENER_VALUE_TYPE = 'bpm_process_listener_value_type',
BPM_TASK_CANDIDATE_RANGE = 'bpm_task_candidate_range',
- OA_PROJECT_TYPE ='oa_project_type',
+ BPM_TASK_FORM_ITEM_TYPE ='bpm_task_form_item_type',
// ========== PAY 模块 ==========
PAY_CHANNEL_CODE = 'pay_channel_code', // 支付渠道编码类型
PAY_ORDER_STATUS = 'pay_order_status', // 商户支付订单状态
diff --git a/src/views/Home/qjgl/QjglDetail.vue b/src/views/Home/qjgl/QjglDetail.vue
index 9f54144..1e3431b 100644
--- a/src/views/Home/qjgl/QjglDetail.vue
+++ b/src/views/Home/qjgl/QjglDetail.vue
@@ -11,12 +11,12 @@
-
+
-
+
@@ -24,11 +24,11 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -83,8 +83,9 @@ import { QjglApi, QjglVO } from '@/api/home/qjgl'
import { propTypes } from '@/utils/propTypes'
import {getUserProfile, ProfileVO} from "@/api/system/user/profile";
import {DeptVO, getDept} from "@/api/system/dept";
-import * as DefinitionApi from '@/api/bpm/definition'
-import * as UserApi from '@/api/system/user'
+import * as TaskApi from '@/api/bpm/task'
+import { getAccessToken } from '@/utils/auth'
+import {useUserStore} from "@/store/modules/user";
/** 请假管理 表单 */
defineOptions({ name: 'QjglDetail' })
@@ -128,39 +129,12 @@ const deptInfo = ref({} as DeptVO )
const formRef = ref() // 表单 Ref
const { query } = useRoute() // 查询参数
const queryId = query.id as unknown as number // 从 URL 传递过来的 id 编号
-/** 打开弹窗 */
-// const open = async (type: string, id?: number) => {
-// dialogVisible.value = true
-// dialogTitle.value = t('action.' + type)
-// formType.value = type
-// resetForm()
-// // 修改时,设置数据
-// if (id) {
-// formLoading.value = true
-// try {
-// formData.value = await QjglApi.getQjgl(id)
-// } finally {
-// formLoading.value = false
-// }
-// }
-// }
-// defineExpose({ open }) // 提供 open 方法,用于打开弹窗
+// pch begin
+const startUserSelectTasks = ref([]) // 发起人需要选择审批人的用户任务列表
+const userId = useUserStore().getUser.id // 当前登录的编号
+//pch end
const getUserInfo = async () => {
const users = await getUserProfile()
- // if ( formData.value.deptId == '' ){
- // userInfo.value = users
- // formData.value.deptId= users.dept.id
- //
- // deptInfo.value = {} as DeptVO
- // }else{
- // const dept = await getDept(formData.value.deptId)
- // deptInfo.value = dept
- // userInfo.value = {} as ProfileVO
- // }
- // if (formData.value.userName == ''){
- // const users = await getUserProfile()
- // formData.value.userName= users.nickname
- // }
if (formData.value.deptId == ''||formData.value.deptId == undefined){
formData.value.deptId= users.dept.id
@@ -180,10 +154,15 @@ const getUserInfo = async () => {
}
}
+const editableFields = ref([])
+const isEditable = (field) => {
+ return editableFields.value.includes(field); // 如果字段在 editableFields 中,则返回 true
+}
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 校验表单
+ alert("update.....")
await formRef.value.validate()
// 提交请求
formLoading.value = true
@@ -230,11 +209,37 @@ onMounted(async () => {
formLoading.value = true
try {
formData.value = await QjglApi.getQjgl(id)
+ console.log(userId,"userId")
+ console.log(queryId,"queryId")
+ let flag = false
+ let itemType = ""
+ if (queryId.length > 33 ) { //流程中打开表单
+ const taskids = await TaskApi.getTaskIdsForProcessInstance( queryId ) //通过流程实例id得到待办任务列表
+ const token = getAccessToken()
+ for (const taskid of taskids) {
+ // 在 for...of 中可以使用 await
+ const assignee = await TaskApi.getTaskAssignee(taskid); //通过待办任务id得到审批人
+ console.log(assignee, "assignee");
+ if ( assignee == userId ) {
+ flag = true
+ itemType = await TaskApi.getTaskConfigFromBpmn( taskid ,"itemType")
+ console.log(itemType,"itemType")
+ }
+ }
+ if ( flag ) { //当然用户是审批人
+ if ( itemType == "1") { //表单字段0:禁用,1:允许
+ editableFields.value.push("title")
+
+ }
+
+ }
+ }
+
+ // TaskApi.getTaskAssignee()
} finally {
formLoading.value = false
}
}
- //await getUserInfo()
- // await getKnowtypeTree()
+
})
diff --git a/src/views/bpm/processInstance/detail/index.vue b/src/views/bpm/processInstance/detail/index.vue
index fe7eb0a..4deea84 100644
--- a/src/views/bpm/processInstance/detail/index.vue
+++ b/src/views/bpm/processInstance/detail/index.vue
@@ -259,18 +259,26 @@ const handleAudit = async (task, pass) => {
// 1.1 获得对应表单
const index = runningTasks.value.indexOf(task)
const auditFormRef = proxy.$refs['form' + index][0]
+
// 1.2 校验表单
const elForm = unref(auditFormRef)
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
-
+ console.log( BusinessFormComponent.value,"BusinessFormComponent.value" )
+ console.log(BusinessFormComponent.value.submit,"BusinessFormComponent.value.submit")
+ if (BusinessFormComponent.value && BusinessFormComponent.value.submit) {
+ console.log("submit.....")
+ BusinessFormComponent.value.submit() // 调用表单的提交方法
+ }
+ return
// 2.1 提交审批
const data = {
id: task.id,
reason: auditForms.value[index].reason,
copyUserIds: auditForms.value[index].copyUserIds
}
+
if (pass) {
// 审批通过,并且有额外的 approveForm 表单,需要校验 + 拼接到 data 表单里提交
const formCreateApi = approveFormFApis.value[index]
@@ -370,6 +378,8 @@ const getProcessInstance = async () => {
if ( formCreatePath ) {
const formCustomViewPaht = await FormProcessMappingApi.getFormCustomViewPath( formCreatePath )
if ( formCustomViewPaht ) {
+ console.log(formCustomViewPaht,"formCustomViewPaht")
+ console.log(registerComponent(formCustomViewPaht),"registerComponent(formCustomViewPaht)")
BusinessFormComponent.value = registerComponent(formCustomViewPaht)
}
}
@@ -459,6 +469,7 @@ const loadRunningTask = (tasks) => {
approveForms.value.push({}) // 占位,避免为空
}
})
+ console.log(runningTasks,"runningTasks")
}
/** 初始化 */
From dccb2410b6ba3942acd6a46efd620505112ffb2c Mon Sep 17 00:00:00 2001
From: pch <75729660@qq.com>
Date: Tue, 17 Dec 2024 13:53:28 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=8D=95?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/Home/qjgl/QjglDetail.vue | 87 ++++++++++---------
.../bpm/processInstance/detail/index.vue | 18 ++--
2 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/src/views/Home/qjgl/QjglDetail.vue b/src/views/Home/qjgl/QjglDetail.vue
index 1e3431b..1375221 100644
--- a/src/views/Home/qjgl/QjglDetail.vue
+++ b/src/views/Home/qjgl/QjglDetail.vue
@@ -28,24 +28,25 @@
-
+
-
+
@@ -160,29 +161,21 @@ const isEditable = (field) => {
}
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
-const submitForm = async () => {
+const updatetForm = async () => {
// 校验表单
- alert("update.....")
await formRef.value.validate()
// 提交请求
formLoading.value = true
try {
const data = formData.value as unknown as QjglVO
- if (formType.value === 'create') {
- await QjglApi.createQjgl(data)
- message.success(t('common.createSuccess'))
- } else {
- await QjglApi.updateQjgl(data)
- message.success(t('common.updateSuccess'))
- }
- dialogVisible.value = false
+ await QjglApi.updateQjgl(data)
// 发送操作成功的事件
- emit('success')
+ //emit('success')
} finally {
formLoading.value = false
}
}
-
+defineExpose({updatetForm})
/** 重置表单 */
const resetForm = () => {
formData.value = {
@@ -202,6 +195,41 @@ const resetForm = () => {
}
formRef.value?.resetFields()
}
+const itemControl = async () => {
+ // console.log(userId,"userId")
+ // console.log(queryId,"queryId")
+ let flag = false
+ let itemType = ""
+ let itemContent = ""
+ if (queryId.length > 33 ) { //流程中打开表单
+ const taskids = await TaskApi.getTaskIdsForProcessInstance( queryId ) //通过流程实例id得到待办任务列表
+ const token = getAccessToken()
+ for (const taskid of taskids) {
+ // 在 for...of 中可以使用 await
+ const assignee = await TaskApi.getTaskAssignee(taskid); //通过待办任务id得到审批人
+ //console.log(assignee, "assignee");
+ if ( assignee == userId ) {
+ flag = true
+ itemType = await TaskApi.getTaskConfigFromBpmn( taskid ,"itemType")
+ //console.log(itemType,"itemType")
+ if ( itemType == "1") {
+ itemContent = await TaskApi.getTaskConfigFromBpmn( taskid ,"itemContent")
+ }
+ }
+ }
+ if ( flag ) { //当然用户是审批人
+ if ( itemType == "1") { //表单字段0:禁用,1:允许
+ //editableFields.value.push("userName")
+ const parsedObject = JSON.parse(itemContent);
+ Object.entries(parsedObject).forEach(([key, value]) => {
+ editableFields.value.push( key )
+ //console.log(key);
+ });
+ }
+
+ }
+ }
+}
onMounted(async () => {
const id = props.id || queryId
console.log("id",id)
@@ -209,32 +237,7 @@ onMounted(async () => {
formLoading.value = true
try {
formData.value = await QjglApi.getQjgl(id)
- console.log(userId,"userId")
- console.log(queryId,"queryId")
- let flag = false
- let itemType = ""
- if (queryId.length > 33 ) { //流程中打开表单
- const taskids = await TaskApi.getTaskIdsForProcessInstance( queryId ) //通过流程实例id得到待办任务列表
- const token = getAccessToken()
- for (const taskid of taskids) {
- // 在 for...of 中可以使用 await
- const assignee = await TaskApi.getTaskAssignee(taskid); //通过待办任务id得到审批人
- console.log(assignee, "assignee");
- if ( assignee == userId ) {
- flag = true
- itemType = await TaskApi.getTaskConfigFromBpmn( taskid ,"itemType")
- console.log(itemType,"itemType")
- }
- }
- if ( flag ) { //当然用户是审批人
- if ( itemType == "1") { //表单字段0:禁用,1:允许
- editableFields.value.push("title")
-
- }
-
- }
- }
-
+ await itemControl()
// TaskApi.getTaskAssignee()
} finally {
formLoading.value = false
diff --git a/src/views/bpm/processInstance/detail/index.vue b/src/views/bpm/processInstance/detail/index.vue
index 4deea84..2456a9d 100644
--- a/src/views/bpm/processInstance/detail/index.vue
+++ b/src/views/bpm/processInstance/detail/index.vue
@@ -18,7 +18,7 @@
-
+
@@ -253,7 +253,7 @@ watch(
deep: true
}
)
-
+const businessForm = ref()
/** 处理审批通过和不通过的操作 */
const handleAudit = async (task, pass) => {
// 1.1 获得对应表单
@@ -265,13 +265,7 @@ const handleAudit = async (task, pass) => {
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
- console.log( BusinessFormComponent.value,"BusinessFormComponent.value" )
- console.log(BusinessFormComponent.value.submit,"BusinessFormComponent.value.submit")
- if (BusinessFormComponent.value && BusinessFormComponent.value.submit) {
- console.log("submit.....")
- BusinessFormComponent.value.submit() // 调用表单的提交方法
- }
- return
+
// 2.1 提交审批
const data = {
id: task.id,
@@ -287,6 +281,10 @@ const handleAudit = async (task, pass) => {
data.variables = approveForms.value[index].value
}
+ if (businessForm.value && businessForm.value.updatetForm) {
+ businessForm.value.updatetForm() // 调用异步组件的提交方法
+ }
+
await TaskApi.approveTask(data)
message.success('审批通过成功')
} else {
@@ -294,7 +292,7 @@ const handleAudit = async (task, pass) => {
message.success('审批不通过成功')
}
// 2.2 加载最新数据
- getDetail()
+ //getDetail()
delView(unref(currentRoute))
back()
}