15 changed files with 448 additions and 93 deletions
@ -0,0 +1,48 @@ |
|||
'use strict'; |
|||
|
|||
export const processState = { |
|||
wait: 'WAIT', //保存待发
|
|||
active: 'ACTIVE', // 正在运行中
|
|||
suspended: 'SUSPENDED', // 流程暂停
|
|||
completed: 'COMPLETED', //流程正常结束
|
|||
externally: 'EXTERNALLY_TERMINATED', // 手动结束流程
|
|||
internally: 'INTERNALLY_TERMINATED' //流程异常结束
|
|||
} |
|||
|
|||
export const judgmentProcessState = (record, activeKey) => { |
|||
let content = ''; |
|||
const { state, status } = record |
|||
const state_ = state || status |
|||
switch (state_) { |
|||
case processState.wait: |
|||
content = '草稿' |
|||
break; |
|||
case processState.active: |
|||
content = '待审批' |
|||
break; |
|||
case processState.completed: |
|||
content = '审批通过'; |
|||
break; |
|||
case processState.externally: |
|||
content = '审批驳回'; |
|||
break; |
|||
case processState.suspended: |
|||
content = '撤销'; |
|||
break; |
|||
case processState.internally: |
|||
content = '异常流程'; |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
if (state_ == processState.active && record.reviewTime != '') { |
|||
content = '审批中' |
|||
} |
|||
if (activeKey == 'review' && record.reviewTime == '') { |
|||
content = '待审批' |
|||
} |
|||
if (activeKey == 'review' && record.reviewTime != '') { |
|||
content = '审批中' |
|||
} |
|||
return content |
|||
} |
@ -0,0 +1,99 @@ |
|||
'use strict'; |
|||
|
|||
const schemaRecursionObj = (obj, target, schemaPath) => { |
|||
let schemaPath_ = JSON.parse(JSON.stringify(schemaPath)) |
|||
if (obj.properties) { |
|||
for (let prKey in obj.properties) { |
|||
if (obj.properties[prKey].title == target) { |
|||
schemaPath_.push({ |
|||
prKey, |
|||
...obj.properties[prKey] |
|||
}) |
|||
return schemaPath_ |
|||
} |
|||
const hasProperties = obj.properties[prKey].properties |
|||
const isGroup = obj.properties[prKey].type == 'array' && obj.properties[prKey].title == '分组' |
|||
if (hasProperties || isGroup) { |
|||
schemaPath_.push({ |
|||
prKey, |
|||
...obj.properties[prKey], |
|||
isGroup: isGroup, |
|||
}) |
|||
schemaPath_ = schemaRecursionObj( |
|||
isGroup ? |
|||
obj.properties[prKey].items |
|||
: obj.properties[prKey], |
|||
target, |
|||
schemaPath_ |
|||
) |
|||
if (!schemaPath_) { |
|||
return [] |
|||
} |
|||
if (schemaPath_.length > schemaPath.length) { |
|||
return schemaPath_ |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
return schemaPath_ |
|||
} |
|||
} |
|||
|
|||
const dataRecursionObj = (dataObj, index, needData, lastKeyObj, nd) => { |
|||
const keyObj = needData[nd].schemaPath[index] |
|||
if (dataObj.hasOwnProperty(keyObj.prKey)) { |
|||
if (lastKeyObj.prKey == keyObj.prKey) { |
|||
let gotValue = dataObj[keyObj.prKey] |
|||
if (keyObj.enum && !needData[nd].fromDataSource) { |
|||
let vIndex = keyObj.enum.findIndex(ke => ke == gotValue) |
|||
gotValue = keyObj.enumNames[vIndex] |
|||
} |
|||
return gotValue |
|||
} else { |
|||
if (keyObj.isGroup) { |
|||
for (let item of dataObj[keyObj.prKey]) { |
|||
const gotValue = dataRecursionObj(item, index + 1, needData, lastKeyObj, nd) |
|||
if (gotValue) { |
|||
return gotValue |
|||
} |
|||
} |
|||
} else { |
|||
return dataRecursionObj(dataObj[keyObj.prKey], index + 1, needData, lastKeyObj, nd) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
const getData = (applyDetail, needData) => { |
|||
for (let nd in needData) { |
|||
if (needData[nd].noProcess) { |
|||
continue |
|||
} |
|||
needData[nd].schemaPath = schemaRecursionObj(applyDetail.formSchema.jsonSchema, needData[nd]['keyWord'], []) |
|||
if (needData[nd].schemaPath && needData[nd].schemaPath.length) { |
|||
const lastKeyObj = needData[nd].schemaPath[ |
|||
needData[nd].schemaPath.length - 1 |
|||
] |
|||
needData[nd].value = dataRecursionObj(applyDetail.formData, 0, needData, lastKeyObj, nd) |
|||
} else { |
|||
// 记录错误 关键数据没找到
|
|||
} |
|||
} |
|||
} |
|||
|
|||
export const parseProcessData = (applyDetail, pomsNeedData = { |
|||
title: { |
|||
keyWord: '标题', |
|||
}, |
|||
pomsProjectId: { |
|||
keyWord: '关联项目', |
|||
fromDataSource: true |
|||
}, |
|||
expectTime: { |
|||
keyWord: '期望完成时间' |
|||
} |
|||
}) => { |
|||
let needData = JSON.parse(JSON.stringify(pomsNeedData)) |
|||
getData(applyDetail, needData) |
|||
return needData |
|||
} |
Loading…
Reference in new issue