2024-07-11 18:04:46 +08:00
|
|
|
|
import {
|
2024-09-13 16:41:36 +08:00
|
|
|
|
getCurrentNextOperation, getTaskInfo,
|
2024-07-11 18:04:46 +08:00
|
|
|
|
setOtherSecurityMeasuresSave,
|
|
|
|
|
setSecurityMeasuresSave,
|
|
|
|
|
setTaskFile,
|
|
|
|
|
setTaskSave
|
|
|
|
|
} from "@/api";
|
2024-09-03 14:49:32 +08:00
|
|
|
|
import {addFormInfo} from "../api";
|
2024-11-04 15:25:07 +08:00
|
|
|
|
import {filePath} from '@/utils/tools.js'
|
2024-07-04 17:57:31 +08:00
|
|
|
|
|
|
|
|
|
// 处理表单数据
|
2024-07-11 18:04:46 +08:00
|
|
|
|
// TYPE 0 纯文本 1 图片 2 视频 3 divider标签 4 动态添加 5 签字
|
|
|
|
|
const processFormData = async (formData, formItems) => {
|
2024-07-04 17:57:31 +08:00
|
|
|
|
const form = []
|
|
|
|
|
for (let i = 0; i < formItems.length; i++) {
|
|
|
|
|
const formItem = formItems[i]
|
2024-07-11 18:04:46 +08:00
|
|
|
|
const obj = {
|
|
|
|
|
ITEM: formItem.name || '',
|
|
|
|
|
ITEM_NAME: formItem.key_name || '',
|
|
|
|
|
ITEM_VALUE: formData[formItem.key_name] || '',
|
2024-07-04 17:57:31 +08:00
|
|
|
|
FK_NAME: formItem.key_id || '',
|
|
|
|
|
FK_VALUE: formData[formItem.key_id] || '',
|
|
|
|
|
TYPE: formItem.type,
|
|
|
|
|
SORT: i + 1
|
2024-07-11 18:04:46 +08:00
|
|
|
|
}
|
|
|
|
|
if (formItem.type === 1 || formItem.type === 2) {
|
|
|
|
|
if (typeof formData[formItem.key_name] === 'object') {
|
|
|
|
|
const currentItem = uni.$u.deepClone(formData[formItem.key_name])
|
|
|
|
|
const codeList = []
|
|
|
|
|
for (let j = 0; j < currentItem.length; j++) {
|
2024-11-05 08:33:11 +08:00
|
|
|
|
const {CODE} = await setTaskFile({formData: {type: currentItem[j].oldUrl}, name: 'files', filePath: currentItem[j].url})
|
2024-07-11 18:04:46 +08:00
|
|
|
|
codeList.push(CODE)
|
|
|
|
|
}
|
2024-07-12 16:24:51 +08:00
|
|
|
|
obj.ITEM_VALUE = ''
|
|
|
|
|
obj.picList = codeList
|
2024-07-11 18:04:46 +08:00
|
|
|
|
} else {
|
|
|
|
|
throw Error('图片和视频只支持数组')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (formItem.type === 4) {
|
|
|
|
|
if (typeof formData[formItem.key_name] === 'object') {
|
|
|
|
|
const currentItem = uni.$u.deepClone(formData[formItem.key_name])
|
|
|
|
|
const itemList = []
|
|
|
|
|
for (let j = 0; j < currentItem.length; j++) {
|
|
|
|
|
itemList.push(await processFormData(currentItem[j], formItem.listStructure))
|
|
|
|
|
}
|
2024-07-12 16:24:51 +08:00
|
|
|
|
obj.ITEM_VALUE = ''
|
|
|
|
|
obj.list = itemList
|
2024-07-11 18:04:46 +08:00
|
|
|
|
} else {
|
|
|
|
|
throw Error('动态表单只支持数组')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (formItem.type === 5) {
|
|
|
|
|
if (typeof formData[formItem.key_name] === 'string') {
|
2024-11-05 08:33:11 +08:00
|
|
|
|
const {CODE} = await setTaskFile({formData: {type: formData[formItem.key_name + 'oldUrl']}, name: 'files', filePath: formData[formItem.key_name]})
|
2024-07-11 18:04:46 +08:00
|
|
|
|
obj.ITEM_VALUE = CODE
|
|
|
|
|
} else {
|
|
|
|
|
throw Error('签字只支持字符串')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
form.push(obj)
|
2024-07-04 17:57:31 +08:00
|
|
|
|
}
|
|
|
|
|
return form
|
|
|
|
|
}
|
|
|
|
|
// 提交表单基础信息
|
2024-09-11 13:44:06 +08:00
|
|
|
|
export const setSubmitForm = async ({form, formItems, TYPE, CORP_ID, EW_RU_TASK_ID}) => {
|
2024-07-04 17:57:31 +08:00
|
|
|
|
const {taskIds} = await setTaskSave({
|
2024-09-11 13:44:06 +08:00
|
|
|
|
data: [{form: await processFormData(form, formItems),task:{EW_RU_TASK_ID:EW_RU_TASK_ID}}],
|
2024-07-04 17:57:31 +08:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
// 提交人员信息
|
2024-11-04 11:34:13 +08:00
|
|
|
|
export const setPersonnelForm = async ({form, list, taskId, EW_RU_JOB_ID, CORP_ID, TYPE,vernier}) => {
|
2024-09-05 18:07:01 +08:00
|
|
|
|
await addFormInfo({
|
|
|
|
|
job: processSelectedPersonnelData(form,list),
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
TYPE,
|
|
|
|
|
postMethod: 'application/json'
|
|
|
|
|
}
|
|
|
|
|
)
|
2024-07-09 18:01:48 +08:00
|
|
|
|
await resolveNextOperation({
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
CORP_ID,
|
2024-09-05 18:07:01 +08:00
|
|
|
|
TYPE,
|
2024-11-04 11:34:13 +08:00
|
|
|
|
EW_RU_JOB_ID,
|
2024-09-05 18:07:01 +08:00
|
|
|
|
vernier
|
2024-07-09 18:01:48 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 提交安全措施
|
2024-09-06 10:34:50 +08:00
|
|
|
|
export const setSecurityMeasures = async ({questionnaires, questionnaireInfo, taskId, EW_RU_JOB_ID, CORP_ID, TYPE, vernier}) => {
|
2024-07-11 18:04:46 +08:00
|
|
|
|
await setSecurityMeasuresSave({
|
|
|
|
|
questionnaires: [{items: questionnaires, questionnaire: questionnaireInfo}],
|
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
postMethod: 'application/json',
|
|
|
|
|
})
|
|
|
|
|
await resolveNextOperation({
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
CORP_ID,
|
|
|
|
|
TYPE,
|
2024-09-06 10:34:50 +08:00
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
vernier
|
2024-07-11 18:04:46 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 提交其它安全措施
|
2024-09-05 18:07:01 +08:00
|
|
|
|
export const setOtherSecurityMeasures = async ({value, taskId, EW_RU_JOB_ID, CORP_ID, TYPE, vernier}) => {
|
2024-07-11 18:04:46 +08:00
|
|
|
|
const ADDITIONAL_COMMENT = value.map(item => item.value)
|
|
|
|
|
await setOtherSecurityMeasuresSave({
|
|
|
|
|
ADDITIONAL_COMMENT,
|
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
2024-07-09 18:01:48 +08:00
|
|
|
|
postMethod: 'application/json',
|
|
|
|
|
})
|
|
|
|
|
await resolveNextOperation({
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
CORP_ID,
|
|
|
|
|
TYPE,
|
2024-09-05 18:07:01 +08:00
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
vernier
|
2024-07-09 18:01:48 +08:00
|
|
|
|
})
|
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-09-03 14:49:32 +08:00
|
|
|
|
// 在审批过程中指定下一节点人
|
2024-11-04 11:34:13 +08:00
|
|
|
|
export const addFlowInfo = async ({form, list, taskId, EW_RU_JOB_ID, TYPE,CORP_ID, vernier}) => {
|
2024-09-03 14:49:32 +08:00
|
|
|
|
// 在审批过程中添加节点信息
|
|
|
|
|
await addFormInfo({
|
|
|
|
|
job: processSelectedPersonnelData(form,list),
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
TYPE,
|
|
|
|
|
postMethod: 'application/json'
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
// 结束后续流程
|
|
|
|
|
await resolveNextOperation({
|
|
|
|
|
EW_RU_TASK_ID: taskId,
|
|
|
|
|
CORP_ID,
|
|
|
|
|
TYPE,
|
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
vernier
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-07-08 17:59:08 +08:00
|
|
|
|
// 决定下一步操作
|
|
|
|
|
// EW_RU_TASK_ID当前任务id
|
|
|
|
|
// CORP_ID选择的企业id
|
|
|
|
|
// TYPE作业类型
|
|
|
|
|
// EW_RU_JOB_ID当前操作节点的人员id
|
2024-07-11 18:04:46 +08:00
|
|
|
|
// isLastStep是否还有下一步,纯前端确定,不去后台获取
|
2024-09-03 14:49:32 +08:00
|
|
|
|
export const resolveNextOperation = async ({EW_RU_TASK_ID = '', CORP_ID = '', TYPE = '', EW_RU_JOB_ID = '',vernier = ''}, isLastStep = true) => {
|
2024-09-06 10:34:50 +08:00
|
|
|
|
let stepNum = 0
|
2024-07-08 17:59:08 +08:00
|
|
|
|
if (isLastStep) {
|
2024-11-06 15:57:42 +08:00
|
|
|
|
const {info} = await getCurrentNextOperation({EW_RU_TASK_ID, EW_RU_JOB_ID, VERNIER: vernier, REQUEST_SOURCE: '2'})
|
2024-07-08 17:59:08 +08:00
|
|
|
|
// 选人
|
|
|
|
|
if (info.chooseNextFlag === '1') {
|
|
|
|
|
uni.navigateTo({
|
2024-09-03 14:49:32 +08:00
|
|
|
|
url: '/pages/eight_assignments/select_review_personnel?vernier='+ info.vernier,
|
2024-07-08 17:59:08 +08:00
|
|
|
|
success: ({eventChannel}) => {
|
2024-07-09 18:01:48 +08:00
|
|
|
|
eventChannel.emit('nextNodes', {
|
|
|
|
|
nextNodes: info.nextNodes,
|
2024-09-03 14:49:32 +08:00
|
|
|
|
initFlag: info.initFlag,
|
2024-07-09 18:01:48 +08:00
|
|
|
|
taskId: EW_RU_TASK_ID,
|
2024-09-03 14:49:32 +08:00
|
|
|
|
EW_RU_JOB_ID: EW_RU_JOB_ID,
|
2024-07-09 18:01:48 +08:00
|
|
|
|
CORP_ID,
|
2024-11-05 14:03:55 +08:00
|
|
|
|
TYPE
|
2024-07-09 18:01:48 +08:00
|
|
|
|
})
|
2024-07-08 17:59:08 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 填写安全措施
|
|
|
|
|
if (info.completeFlag === '1') {
|
2024-07-09 18:01:48 +08:00
|
|
|
|
uni.navigateTo({
|
2024-09-06 10:34:50 +08:00
|
|
|
|
url: '/pages/eight_assignments/security_measures?vernier=' + info.vernier,
|
2024-07-09 18:01:48 +08:00
|
|
|
|
success: ({eventChannel}) => {
|
|
|
|
|
eventChannel.emit('questionnaire', {
|
|
|
|
|
questionnaire: info.questionnaire[0],
|
|
|
|
|
taskId: EW_RU_TASK_ID,
|
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
TYPE,
|
2024-09-05 18:07:01 +08:00
|
|
|
|
CORP_ID,
|
|
|
|
|
vernier: info.vernier
|
2024-07-09 18:01:48 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-07-08 17:59:08 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 填写其它安全措施
|
|
|
|
|
if (info.canAddFlag === '1') {
|
2024-07-11 18:04:46 +08:00
|
|
|
|
uni.$u.route({
|
|
|
|
|
url: '/pages/eight_assignments/other_security_measures',
|
2024-09-05 18:07:01 +08:00
|
|
|
|
params: {taskId: EW_RU_TASK_ID, EW_RU_JOB_ID, TYPE, CORP_ID,vernier: info.vernier}
|
2024-07-11 18:04:46 +08:00
|
|
|
|
})
|
2024-07-08 17:59:08 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 签字
|
|
|
|
|
if (info.submitFlag === '1') {
|
|
|
|
|
uni.$u.route({
|
|
|
|
|
url: '/pages/eight_assignments/sign',
|
2024-09-05 18:07:01 +08:00
|
|
|
|
params: {taskId: EW_RU_TASK_ID, EW_RU_JOB_ID, TYPE,vernier: info.vernier}
|
2024-07-08 17:59:08 +08:00
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-08-31 17:28:32 +08:00
|
|
|
|
// 流程特殊权限校验
|
2024-08-30 09:12:18 +08:00
|
|
|
|
if (info.otherFlag !== null && info.otherFlag.redirectFlag === '1') {
|
2024-07-11 18:04:46 +08:00
|
|
|
|
uni.$u.route({
|
2024-08-29 18:02:20 +08:00
|
|
|
|
url: info.otherFlag.url,
|
2024-09-05 18:07:01 +08:00
|
|
|
|
params: {taskId: EW_RU_TASK_ID, EW_RU_JOB_ID, TYPE,vernier: info.vernier}
|
2024-07-11 18:04:46 +08:00
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-09-06 10:34:50 +08:00
|
|
|
|
// 根据后端返回的页数退回到指定页面
|
|
|
|
|
stepNum = info.stepNum
|
2024-07-04 17:57:31 +08:00
|
|
|
|
}
|
2024-09-06 10:34:50 +08:00
|
|
|
|
|
2024-07-05 18:01:23 +08:00
|
|
|
|
uni.$u.toast('提交成功')
|
|
|
|
|
setTimeout(() => {
|
2024-09-06 10:34:50 +08:00
|
|
|
|
uni.navigateBack(
|
|
|
|
|
{
|
|
|
|
|
delta: stepNum
|
|
|
|
|
}
|
|
|
|
|
)
|
2024-07-05 18:01:23 +08:00
|
|
|
|
}, 1500)
|
2024-07-04 17:57:31 +08:00
|
|
|
|
}
|
2024-09-13 16:41:36 +08:00
|
|
|
|
|
|
|
|
|
export const getData = async (taskId) => {
|
|
|
|
|
const resData = await getTaskInfo({ EW_RU_TASK_ID: taskId });
|
|
|
|
|
if (resData.list.fromTrans && resData.list.fromTrans.length > 0) {
|
|
|
|
|
const form = {};
|
|
|
|
|
resData.list.fromTrans.forEach((item) => {
|
|
|
|
|
form[item.ITEM_NAME] = item.ITEM_VALUE;
|
|
|
|
|
if (item.FK_NAME) {
|
|
|
|
|
form[item.FK_NAME] = item.FK_VALUE;
|
|
|
|
|
}
|
|
|
|
|
if (item.TYPE === 1) {
|
|
|
|
|
form[item.ITEM_NAME] = item.list.map((item) => ({
|
2024-11-04 15:25:07 +08:00
|
|
|
|
url: filePath + item.ITEM_VALUE,
|
2024-11-05 08:33:11 +08:00
|
|
|
|
oldUrl: item.ITEM_VALUE
|
2024-09-13 16:41:36 +08:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
if (item.TYPE === 4) {
|
|
|
|
|
form[item.ITEM_NAME] = [];
|
|
|
|
|
for (let i = 0; i < item.list.length; i++) {
|
|
|
|
|
form[item.ITEM_NAME].push({});
|
|
|
|
|
for (let j = 0; j < item.list[i].list.length; j++) {
|
|
|
|
|
form[item.ITEM_NAME][i][item.list[i].list[j].ITEM_NAME] =
|
|
|
|
|
item.list[i].list[j].ITEM_VALUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (item.TYPE === 5) {
|
2024-11-04 15:25:07 +08:00
|
|
|
|
form[item.ITEM_NAME] = filePath + item.ITEM_VALUE;
|
2024-11-05 08:33:11 +08:00
|
|
|
|
form[item.ITEM_NAME + 'oldUrl'] = item.ITEM_VALUE;
|
2024-09-13 16:41:36 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return form;
|
|
|
|
|
}
|
|
|
|
|
};
|
2024-11-04 11:34:13 +08:00
|
|
|
|
// 针对在某些节点要新增报表信息
|
|
|
|
|
export const addReport = async ({form, formItems, TYPE, CORP_ID, EW_RU_TASK_ID, EW_RU_JOB_ID, vernier}) => {
|
|
|
|
|
// 在审批过程中添加节点信息
|
|
|
|
|
await addFormInfo({
|
|
|
|
|
reports: await processFormData(form,formItems),
|
|
|
|
|
EW_RU_TASK_ID: EW_RU_TASK_ID,
|
|
|
|
|
EW_RU_JOB_ID: EW_RU_JOB_ID,
|
|
|
|
|
TYPE,
|
|
|
|
|
postMethod: 'application/json'
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
// 结束后续流程
|
|
|
|
|
await resolveNextOperation({
|
|
|
|
|
EW_RU_TASK_ID: EW_RU_TASK_ID,
|
|
|
|
|
CORP_ID,
|
|
|
|
|
TYPE,
|
|
|
|
|
EW_RU_JOB_ID,
|
|
|
|
|
vernier
|
|
|
|
|
})
|
|
|
|
|
}
|