2024-07-09 18:01:48 +08:00
|
|
|
import {getCurrentNextOperation, setTaskSave} from "@/api";
|
2024-07-04 17:57:31 +08:00
|
|
|
|
|
|
|
// 处理表单数据
|
|
|
|
const processFormData = (formData, formItems) => {
|
|
|
|
const form = []
|
|
|
|
for (let i = 0; i < formItems.length; i++) {
|
|
|
|
const formItem = formItems[i]
|
|
|
|
form.push({
|
|
|
|
ITEM: formItem.name,
|
|
|
|
ITEM_NAME: formItem.key_name,
|
|
|
|
ITEM_VALUE: formData[formItem.key_name],
|
|
|
|
FK_NAME: formItem.key_id || '',
|
|
|
|
FK_VALUE: formData[formItem.key_id] || '',
|
|
|
|
TYPE: formItem.type,
|
|
|
|
SORT: i + 1
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return form
|
|
|
|
}
|
|
|
|
// 提交表单基础信息
|
|
|
|
export const setSubmitForm = async ({form, formItems, TYPE, CORP_ID}) => {
|
|
|
|
const {taskIds} = await setTaskSave({
|
|
|
|
data: [{form: processFormData(form, formItems)}],
|
|
|
|
TYPE,
|
|
|
|
postMethod: 'application/json',
|
|
|
|
})
|
2024-07-09 18:01:48 +08:00
|
|
|
await resolveNextOperation({
|
|
|
|
EW_RU_TASK_ID: taskIds[0],
|
|
|
|
CORP_ID,
|
|
|
|
TYPE
|
|
|
|
})
|
2024-07-04 17:57:31 +08:00
|
|
|
}
|
|
|
|
// 处理选择人员数据
|
2024-07-04 18:00:02 +08:00
|
|
|
const processSelectedPersonnelData = (formData, list) => {
|
2024-07-04 17:57:31 +08:00
|
|
|
const form = []
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
2024-07-08 17:59:08 +08:00
|
|
|
for (let j = 0; j < list[i].list.length; j++) {
|
|
|
|
const item = list[i].list[j]
|
|
|
|
const link = item.key_id.substring(item.key_id.indexOf('&&') + 2)
|
|
|
|
form.push({
|
|
|
|
TYPE_NAME: item.value,
|
|
|
|
TYPE: item.code,
|
|
|
|
TYPE_DESCRIBE: item.desc,
|
|
|
|
DEPARTMENT_ID: item.type === '1' ? formData[item.key_id] : '',
|
|
|
|
DEPARTMENT_NAME: item.type === '1' ? formData[item.key_name] : '',
|
|
|
|
USER_ID: item.type === '0' ? formData[item.key_id] : '',
|
|
|
|
USER_NAME: item.type === '0' ? formData[item.key_name] : '',
|
|
|
|
isDepartment: item.type,
|
|
|
|
link: list[i].multiple === '1' ? link : '',
|
|
|
|
})
|
|
|
|
}
|
2024-07-04 17:57:31 +08:00
|
|
|
}
|
|
|
|
return form
|
|
|
|
}
|
|
|
|
// 提交人员信息
|
|
|
|
export const setPersonnelForm = async ({form, list, taskId, CORP_ID, TYPE}) => {
|
|
|
|
await setTaskSave({
|
2024-07-04 18:00:02 +08:00
|
|
|
data: [{jobs: processSelectedPersonnelData(form, list), task: {EW_RU_TASK_ID: taskId}}],
|
2024-07-04 17:57:31 +08:00
|
|
|
postMethod: 'application/json',
|
|
|
|
})
|
2024-07-09 18:01:48 +08:00
|
|
|
await resolveNextOperation({
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
CORP_ID,
|
|
|
|
TYPE
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// 提交安全措施
|
|
|
|
export const setSecurityMeasures = async ({questionnaires, questionnaireInfo, taskId, EW_RU_JOB_ID, CORP_ID, TYPE}) => {
|
|
|
|
await setTaskSave({
|
|
|
|
data: [{
|
|
|
|
questionnaires: [{items: questionnaires, questionnaire: questionnaireInfo}],
|
|
|
|
task: {EW_RU_TASK_ID: taskId}
|
|
|
|
}],
|
|
|
|
JOB_ID: EW_RU_JOB_ID,
|
|
|
|
postMethod: 'application/json',
|
|
|
|
})
|
|
|
|
await resolveNextOperation({
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
CORP_ID,
|
|
|
|
TYPE,
|
|
|
|
EW_RU_JOB_ID
|
|
|
|
})
|
2024-07-04 17:57:31 +08:00
|
|
|
}
|
2024-07-09 18:01:48 +08:00
|
|
|
// 结束当前操作人流程提交
|
2024-07-05 18:01:23 +08:00
|
|
|
const endCurrentPersonnelTechnologicalProcess = async ({EW_RU_TASK_ID}) => {
|
|
|
|
await setTaskSave({
|
|
|
|
COMPLETE_FLAG: '1',
|
|
|
|
data: [{task: {EW_RU_TASK_ID}}],
|
|
|
|
postMethod: 'application/json',
|
|
|
|
})
|
|
|
|
}
|
2024-07-08 17:59:08 +08:00
|
|
|
// 决定下一步操作
|
|
|
|
// EW_RU_TASK_ID当前任务id
|
|
|
|
// CORP_ID选择的企业id
|
|
|
|
// TYPE作业类型
|
|
|
|
// EW_RU_JOB_ID当前操作节点的人员id
|
|
|
|
export const resolveNextOperation = async ({EW_RU_TASK_ID, CORP_ID, TYPE, EW_RU_JOB_ID}, isLastStep = true) => {
|
|
|
|
if (isLastStep) {
|
2024-07-09 13:36:05 +08:00
|
|
|
const {info} = await getCurrentNextOperation({EW_RU_TASK_ID, EW_RU_JOB_ID})
|
2024-07-08 17:59:08 +08:00
|
|
|
// 选人
|
|
|
|
if (info.chooseNextFlag === '1') {
|
|
|
|
uni.navigateTo({
|
|
|
|
url: '/pages/eight_assignments/select_review_personnel',
|
|
|
|
success: ({eventChannel}) => {
|
2024-07-09 18:01:48 +08:00
|
|
|
eventChannel.emit('nextNodes', {
|
|
|
|
nextNodes: info.nextNodes,
|
|
|
|
taskId: EW_RU_TASK_ID,
|
|
|
|
CORP_ID,
|
|
|
|
TYPE
|
|
|
|
})
|
2024-07-08 17:59:08 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// 填写安全措施
|
|
|
|
if (info.completeFlag === '1') {
|
2024-07-09 18:01:48 +08:00
|
|
|
uni.navigateTo({
|
|
|
|
url: '/pages/eight_assignments/security_measures',
|
|
|
|
success: ({eventChannel}) => {
|
|
|
|
eventChannel.emit('questionnaire', {
|
|
|
|
questionnaire: info.questionnaire[0],
|
|
|
|
taskId: EW_RU_TASK_ID,
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
TYPE,
|
|
|
|
CORP_ID
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2024-07-08 17:59:08 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
// 填写其它安全措施
|
|
|
|
if (info.canAddFlag === '1') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// 签字
|
|
|
|
if (info.submitFlag === '1') {
|
|
|
|
uni.$u.route({
|
|
|
|
url: '/pages/eight_assignments/sign',
|
|
|
|
params: {taskId: EW_RU_TASK_ID, EW_RU_JOB_ID, TYPE}
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// 没有下一步,结束流程,因为无法确定之前有多少步骤,跳转了多少页面,所以直接跳转到首页
|
|
|
|
await endCurrentPersonnelTechnologicalProcess({EW_RU_TASK_ID})
|
2024-07-04 17:57:31 +08:00
|
|
|
}
|
2024-07-05 18:01:23 +08:00
|
|
|
uni.$u.toast('提交成功')
|
|
|
|
setTimeout(() => {
|
|
|
|
uni.switchTab({
|
|
|
|
url: '/pages/index/index'
|
|
|
|
})
|
|
|
|
}, 1500)
|
2024-07-04 17:57:31 +08:00
|
|
|
}
|