WAPC2FLIVE 创建企微审批 POC 样件
这个提交包含在:
@@ -143,31 +143,47 @@ function fixtureNumber(targetKey, generatedAt) {
|
||||
return `WAPC2F-${targetKey}-${generatedAt.slice(0, 10).replace(/-/g, "")}`;
|
||||
}
|
||||
|
||||
function fixtureControlIds() {
|
||||
return {
|
||||
type: "Text-01",
|
||||
date: "Date-01",
|
||||
reason: "Textarea-01",
|
||||
};
|
||||
}
|
||||
|
||||
function buildTemplateControl(control, id, title, options = {}) {
|
||||
return {
|
||||
property: {
|
||||
control,
|
||||
id,
|
||||
title: localized(title),
|
||||
placeholder: localized(options.placeholder || title),
|
||||
require: options.require ? 1 : 0,
|
||||
un_print: 1,
|
||||
},
|
||||
config: options.config || {},
|
||||
};
|
||||
}
|
||||
|
||||
function dayTimestamp(generatedAt) {
|
||||
const date = new Date(`${generatedAt.slice(0, 10)}T00:00:00.000Z`);
|
||||
return String(Math.floor(date.getTime() / 1000));
|
||||
}
|
||||
|
||||
function buildTemplateFixturePayload(target, generatedAt) {
|
||||
const label = targetLabel(target.key);
|
||||
const number = fixtureNumber(target.key, generatedAt);
|
||||
const controlIds = fixtureControlIds();
|
||||
return {
|
||||
template_names: localized(`OA-POC-${label}-${generatedAt.slice(0, 10)}`),
|
||||
template_name: localized(`OA-POC-${label}-${generatedAt.slice(0, 10)}`),
|
||||
template_content: {
|
||||
controls: [
|
||||
{
|
||||
control: "Text",
|
||||
id: "fixture_type",
|
||||
title: localized("类型"),
|
||||
require: 1,
|
||||
},
|
||||
{
|
||||
control: "Date",
|
||||
id: "fixture_date",
|
||||
title: localized("日期"),
|
||||
require: 1,
|
||||
},
|
||||
{
|
||||
control: "Textarea",
|
||||
id: "fixture_reason",
|
||||
title: localized("说明"),
|
||||
require: 0,
|
||||
},
|
||||
buildTemplateControl("Text", controlIds.type, "类型", { require: true }),
|
||||
buildTemplateControl("Date", controlIds.date, "日期", {
|
||||
require: true,
|
||||
config: { date: { type: "day" } },
|
||||
}),
|
||||
buildTemplateControl("Textarea", controlIds.reason, "说明", { require: false }),
|
||||
],
|
||||
},
|
||||
fixture_marker: {
|
||||
@@ -182,39 +198,38 @@ function buildTemplateFixturePayload(target, generatedAt) {
|
||||
function buildApplyFixturePayload({ target, templateId, applicantUserId, approverUserId, generatedAt }) {
|
||||
const label = targetLabel(target.key);
|
||||
const number = fixtureNumber(target.key, generatedAt);
|
||||
const controlIds = fixtureControlIds();
|
||||
return {
|
||||
creator_userid: applicantUserId,
|
||||
template_id: templateId,
|
||||
use_template_approver: 0,
|
||||
approver: [
|
||||
{
|
||||
attr: 2,
|
||||
attr: 1,
|
||||
userid: [approverUserId],
|
||||
},
|
||||
],
|
||||
notifyer: [
|
||||
{
|
||||
userid: [approverUserId],
|
||||
},
|
||||
approverUserId,
|
||||
],
|
||||
notify_type: 1,
|
||||
apply_data: {
|
||||
contents: [
|
||||
{
|
||||
control: "Text",
|
||||
id: "fixture_type",
|
||||
id: controlIds.type,
|
||||
title: localized("类型"),
|
||||
value: { text: label },
|
||||
},
|
||||
{
|
||||
control: "Date",
|
||||
id: "fixture_date",
|
||||
id: controlIds.date,
|
||||
title: localized("日期"),
|
||||
value: { date: generatedAt.slice(0, 10) },
|
||||
value: { date: { type: "day", s_timestamp: dayTimestamp(generatedAt) } },
|
||||
},
|
||||
{
|
||||
control: "Textarea",
|
||||
id: "fixture_reason",
|
||||
id: controlIds.reason,
|
||||
title: localized("说明"),
|
||||
value: { text: `${number} low-risk dry-run fixture` },
|
||||
},
|
||||
@@ -234,7 +249,7 @@ function summarizeFixturePayload(payload, kind) {
|
||||
: payload?.apply_data?.contents || [];
|
||||
const controlTypes = {};
|
||||
for (const control of controls) {
|
||||
const key = toSafeString(control?.control || "unknown", 80) || "unknown";
|
||||
const key = toSafeString(control?.control || control?.property?.control || "unknown", 80) || "unknown";
|
||||
controlTypes[key] = (controlTypes[key] || 0) + 1;
|
||||
}
|
||||
return {
|
||||
|
||||
在新工单中引用
屏蔽一个用户