Flow_15zn1tu
${false}
${1}
project-plan
${true}
${environment.variables.task_id}
(async function () {
// 提交审核
try {
let owner = await this.environment.services.owner(); // 获取任务责任人
if (!owner) {
await this.environment.services.gen_warn_task('admin', '提交任务审核时未找到负责人',
`提交任务审核时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
}
// 获取任务审核人列表
let checkers = await this.environment.services.get_handlers('task_checker');
if (!checkers || checkers.length === 0) return;
let checkers_str = "";
for (var i = 0; i < checkers.length; i++) {
checkers_str += `<b>${checkers[i].name}</b> 进行${checkers[i].action};<br>`;
}
let check_type = this.environment.variables.check_type;
let check_type_str = check_type === 2 ? "并行审核": "顺序审核";
await this.environment.services.gen_remind_task(owner.id, `任务“${this.environment.variables.task_name}”的审核申请已提交`, `<b>${owner.name}</b>已于 <b>` +
this.environment.services.get_datetime() + `</b> 提交了任务<b>“${this.environment.variables.task_name}”</b>的审核申请,将由: <br> ${checkers_str}审核方式为:${check_type_str}`);
await this.environment.services.logger(owner.id, owner.name, `提交了任务<b>“${this.environment.variables.task_name}”</b>的审核申请,将由: <br> ${checkers_str}审核方式为:${check_type_str}`);
} catch (e) {
this.environment.Logger('work').error(e);
}
})();
(async function () {
try {
// 检查是否已配置了审核成员
let handlers = await this.environment.services.get_handlers('task_checker');
let outcome_count = await this.environment.services.get_outcome_count();
this.environment.Logger('work').error(handlers);
let result = handlers.length > 0 ? true: false;
if (!result && outcome_count > 0) {
return {
result: false,
message: '任务申请审核前,请先配置任务审核成员,否则无法执行审核任务。'
}
}
// 检查需要审核的文档是否都已经上传
let outcome_all_uploaded = await this.environment.services.check_all_outcome_uploaded();
this.environment.Logger('work').error(outcome_all_uploaded);
if (!outcome_all_uploaded) {
return {
result: false,
message: '任务审核前,请确保此任务的所有交付物文档都已上传。'
}
}
// 检查当前的项目状态是否允许提交任务审核
let phase_id = await this.environment.services.get_prj_phase();
switch(phase_id) {
case 'doing':
case 'reject_plan_alt':
break;
case 'apply_plan_alt':
case 'review_plan_alt':
return {
result: false,
message: '当前处于计划变更审核状态,不允许提交任务审核。'
}
case 'checking':
return {
result: false,
message: '项目验收中,不允许提交任务审核。'
}
case 'deprecated':
return {
result: false,
message: '项目已作废,不允许提交任务审核。'
}
case 'done':
return {
result: false,
message: '项目已完成,不允许提交任务审核。'
}
default:
return {
result: false,
message: '流程异常,当前项目状态下不允许提交任务审核。'
}
}
return {
result: true,
message: 'OK'
}
} catch (e) {
this.environment.Logger('work').error(e);
return {
result: false,
message: 'fail'
}
}
})();
Flow_1t45qnv
Flow_0gyvyyo
Flow_1gc46ur
Flow_1rg4oob
Flow_0bhibn0
状态变为审核中(50)
状态变为审核中(50)
${true}
${1}
project-plan
${environment.variables.prj_id}
${false}
${environment.variables.task_id}
(async function () {
try {
// 并行审核任务,多人同时执行
let owner = await this.environment.services.owner(); // 获取任务责任人
if (!owner) {
await this.environment.services.gen_warn_task('admin', '任务审核时未找到负责人',
`任务审核时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
}
this.environment.Logger('work').debug(this.content);
let checker = this.content.handlers[this.content.index]; // 获取当前审核人,这个是并行审核任务,有多个审核人并行审核
let result = this.content.output[this.content.index]; // 来自于审核人表单结果
if (result.pass) { // 如果审核通过
// 生成阅读任务
await this.environment.services.gen_remind_task(owner.id, `${checker.name}:任务“${this.environment.variables.task_name}”的${checker.action}已通过`,
`<b>${checker.name}</b>已于 <b>${this.environment.services.get_datetime()}</b> 对任务“${this.environment.variables.task_name}”的交付物进行了${checker.action}并<span style="color: rgb(20, 201, 201);">通过。</span>`);
// 生成任务动态
await this.environment.services.logger(checker.id, checker.name, `任务“${this.environment.variables.task_name}”的${checker.action}<span style="color: rgb(20, 201, 201);">已通过</span>`);
// 归档审核文件
if (result.opinion) {
await this.environment.services.place_on_files(result.opinion, `${checker.action}意见(通过)`);
}
if (result.annotated_draft) {
await this.environment.services.place_on_files(result.annotated_draft, `${checker.action}批注稿(通过)`);
}
} else {
// 生成阅读任务
await this.environment.services.gen_remind_task(owner.id, `${checker.name}任务“${this.environment.variables.task_name}”的${checker.action}已驳回`,
`<b>${checker.name}</b>已于 <b>${this.environment.services.get_datetime()}</b> 对任务“${this.environment.variables.task_name}”的交付物进行了${checker.action}并<span style="color: red;">驳回。</span>`);
// 生成任务动态
await this.environment.services.logger(checker.id, checker.name, `任务“${this.environment.variables.task_name}”在${checker.action}时<span style="color: red;">被驳回</span>`);
// 归档审核文件
if (result.opinion) {
await this.environment.services.place_on_files(result.opinion, `${checker.action}意见(驳回)`);
}
if (result.annotated_draft) {
await this.environment.services.place_on_files(result.annotated_draft, `${checker.action}批注稿(驳回)`);
}
}
} catch (e) {
this.environment.Logger('work').error(e);
}
})();
Flow_0iv9g3p
Flow_1su3b3p
${content.handlers.length}
状态变为审核中(50)
${true}
${1}
project-plan
${environment.variables.prj_id}
${false}
${environment.variables.task_id}
(async function () {
try {
// 串行审核任务,多人按顺序执行审核
let owner = await this.environment.services.owner(); // 获取任务责任人
if (!owner) {
await this.environment.services.gen_warn_task('admin', '任务审核时未找到负责人',
`任务审核时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
}
this.environment.Logger('work').debug(this.content);
let checker = this.content.handlers[this.content.index]; // 获取当前审核人,这个是并行审核任务,有多个审核人并行审核
let result = this.content.output[this.content.index]; // 来自于审核人表单结果
if (result.pass) { // 如果审核通过
// 生成阅读任务
await this.environment.services.gen_remind_task(owner.id, `${checker.name}:任务“${this.environment.variables.task_name}”的${checker.action}已通过`,
`<b>${checker.name}</b>已于 <b>${this.environment.services.get_datetime()}</b> 对任务“${this.environment.variables.task_name}”的交付物进行了${checker.action}并<span style="color: rgb(20, 201, 201);">通过。</span>。`);
// 生成任务动态
await this.environment.services.logger(checker.id, checker.name, `任务“${this.environment.variables.task_name}”的${checker.action}<span style="color: rgb(20, 201, 201);">已通过</span>`);
// 归档审核文件
if (result.opinion) {
await this.environment.services.place_on_files(result.opinion, `${checker.action}意见(通过)`);
}
if (result.annotated_draft) {
await this.environment.services.place_on_files(result.annotated_draft, `${checker.action}批注稿(通过)`);
}
} else {
// 生成阅读任务
await this.environment.services.gen_remind_task(owner.id, `${checker.name}:任务“${this.environment.variables.task_name}”的${checker.action}已驳回`,
`<b>${checker.name}</b>已于 <b>${this.environment.services.get_datetime()}</b> 对任务“${this.environment.variables.task_name}”的交付物进行了${checker.action}并<span style="color: red;">驳回。</span>。`);
// 生成任务动态
await this.environment.services.logger(checker.id, checker.name, `任务“${this.environment.variables.task_name}”在${checker.action}时<span style="color: red;">被驳回</span>`);
// 归档审核文件
if (result.opinion) {
await this.environment.services.place_on_files(result.opinion, `${checker.action}意见(驳回)`);
}
if (result.annotated_draft) {
await this.environment.services.place_on_files(result.annotated_draft, `${checker.action}批注稿(驳回)`);
}
}
} catch (e) {
this.environment.Logger('work').error(e);
}
})();
Flow_02nannf
Flow_193tusd
${content.handlers.length}
${!content.output.pass}
Flow_193tusd
Flow_1rcwh5r
Flow_0zubkyw
Flow_0nwaga3
next(null, this.environment.variables.pass===true);
审核不通过(30)
${1}
(async function() {
try{
let owner = await this.environment.services.owner(); // 获取任务责任人
if (!owner) {
await this.environment.services.gen_warn_task('admin', '任务审核申请被撤回时未找到负责人',
`任务审核申请被撤回时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
}
await this.environment.services.gen_remind_task(owner.id, `任务“${this.environment.variables.task_name}”的审核申请已被撤回`,
`${owner.name}已于 ${this.environment.services.get_datetime()} <span style="color: rgb(22,93,255);">撤回</span>了任务<b>“${this.environment.variables.task_name}”</b>的审核申请。`);
await this.environment.services.logger(owner.id, owner.name, `撤回了任务<b>“${this.environment.variables.task_name}”</b>的审核申请。`);
} catch(e){
this.environment.Logger('work').error(e);
}
})();
Flow_0bhibn0
Flow_0tj9nd6
Flow_0tj9nd6
Flow_0zubkyw
Flow_02taytj
Flow_1ucg773
Flow_0nwaga3
Flow_06cxzjx
Flow_15zn1tu
Flow_0gyvyyo
Flow_0nzbvpg
Flow_1eauhgu
Flow_1t45qnv
Flow_1ucg773
Flow_1xp7bfo
Flow_0nzbvpg
Flow_1rg4oob
Flow_02nannf
Flow_0iv9g3p
next(null, this.environment.variables.check_type===2);
Flow_0b7s3zy
Flow_0b7s3zy
Flow_1gc46ur
Flow_1su3b3p
Flow_1rcwh5r
try {
// 只要有一个未通过,就算未通过审核
var passed = true;
let a = this.environment.services.get_value('a');
for (var i = 0; i < this.environment.output.task_approve_task_sync.length; i++) {
var value = this.environment.output.task_approve_task_sync[i];
if (value && !value.pass) {
passed = false;
break;
}
}
this.environment.variables.pass = passed;
} catch (e) {
this.environment.variables.pass = false;
} finally {
next();
}
Flow_06cxzjx
Flow_09c65ah
(async function () {
try {
await this.environment.services.place_on_outcome("内部审核驳回");
} catch (e) {
this.environment.Logger('work').error(e);
} finally {
next();
}
})();
Flow_02taytj
Flow_1xp7bfo
(async function () {
try {
await this.environment.services.place_on_outcome("内部审核通过", "outcome");
} catch (e) {
this.environment.Logger('work').error(e);
} finally {
next();
}
})();
Flow_09c65ah
Flow_1eauhgu
(async function () {
try {
let owner = await this.environment.services.owner(); // 获取任务责任人
if (!owner) {
await this.environment.services.gen_warn_task('admin', '提交任务审核时未找到负责人',
`提交任务审核时未找到负责人,流程出错。case id: ${this.environment.variables.id}`);
}
// 生成阅读任务
await this.environment.services.gen_remind_task(owner.id, `任务“${this.environment.variables.task_name}”的交付物审核未通过。`,
`任务“${this.environment.variables.task_name}”的交付物审核未通过,请修改后重新提交审核。`);
// 生成任务动态
await this.environment.services.logger(checker.id, checker.name, `任务“${this.environment.variables.task_name}”的交付物审核未通过。`);
} catch (e) {
this.environment.Logger('work').error(e);
} finally {
next();
}
})();
所有人都审核通过才算通过