qa-prevention-xgf-app/utils/submitHomeworkProcess.js

77 lines
2.4 KiB
JavaScript
Raw Normal View History

2024-07-04 17:57:31 +08:00
import {getCurrentNextOperation, setTaskSave} from "../api/index";
// 处理表单数据
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',
})
await resolveNextOperation(taskIds[0], CORP_ID, TYPE)
}
// 处理选择人员数据
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++) {
const item = list[i]
form.push({
TYPE_NAME: item.desc,
TYPE: item.code,
DEPARTMENT_ID: list[i].type === '1' ? formData[item.key_id] : '',
DEPARTMENT_NAME: list[i].type === '1' ? formData[item.key_name] : '',
USER_ID: list[i].type === '0' ? formData[item.key_id] : '',
USER_NAME: list[i].type === '0' ? formData[item.key_name] : '',
isDepartment: list[i].type
})
}
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',
})
await resolveNextOperation(taskId, CORP_ID, TYPE)
}
// 决定下一步操作 EW_RU_TASK_ID当前任务id CORP_ID 选择的企业id TYPE作业类型
const resolveNextOperation = async (EW_RU_TASK_ID, CORP_ID, TYPE) => {
const {info} = await getCurrentNextOperation({EW_RU_TASK_ID})
// 选人
if (info.chooseNextFlag === '1') {
uni.navigateTo({
url: '/pages/eight_assignments/select_review_personnel',
success: ({eventChannel}) => {
eventChannel.emit('nextNodes', {nextNodes: info.nextNodes, taskId: EW_RU_TASK_ID, CORP_ID, TYPE})
}
})
return
}
// 填写安全措施
if (info.completeFlag === '1') {
return
}
// 填写其它安全措施
if (info.canAddFlag === '1') {
return
}
console.log('没有下一步了')
}