chore: [workflow] 提交工作区代码
This commit is contained in:
1 parent
2ff588a65d
commit
01f3d7aaf7
131 files changed
+24306
-1320
No files matched your search
@@ -4134,6 +4134,23 @@ kbd {
|
||||
box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.08);
|
||||
}
|
||||
|
||||
.run-date-range {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.run-date-range input {
|
||||
min-width: 0;
|
||||
flex: 1 1 0;
|
||||
}
|
||||
|
||||
.run-date-range > span {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.field small {
|
||||
margin-top: 5px;
|
||||
color: var(--muted);
|
||||
|
||||
+103
-11
@@ -128,6 +128,49 @@
|
||||
return workflow?.id === "product.tmall_baibu_apply";
|
||||
}
|
||||
|
||||
function isDateRangeWorkflow(workflow) {
|
||||
return workflow?.date_range_mode === "date_range";
|
||||
}
|
||||
|
||||
function runStoreConfig(workflow) {
|
||||
if (isDateRangeWorkflow(workflow) && workflow.store_config) {
|
||||
return workflow.store_config;
|
||||
}
|
||||
if (workflow?.id === "product.video_upload") {
|
||||
return {
|
||||
label: "上传店铺",
|
||||
hint: "先扫描飞书并按所选店铺规则筛选;存在未上传附件时才登录该店铺账号。",
|
||||
options: [
|
||||
{ value: "flagship", label: "光影行星旗舰店" },
|
||||
{ value: "luggage", label: "光影行星鑫华达专卖店:龙虾仔" },
|
||||
],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function syncRunStoreField(workflow) {
|
||||
const field = byId("run-store-field");
|
||||
const select = byId("run-store");
|
||||
const config = runStoreConfig(workflow);
|
||||
field.hidden = !config;
|
||||
if (!config) {
|
||||
select.replaceChildren();
|
||||
return;
|
||||
}
|
||||
byId("run-store-label").textContent = config.label || "店铺";
|
||||
byId("run-store-hint").textContent = config.hint || "选择本次运行使用的店铺。";
|
||||
select.replaceChildren(
|
||||
...(config.options || []).map((option) => {
|
||||
const element = document.createElement("option");
|
||||
element.value = option.value;
|
||||
element.textContent = option.label;
|
||||
return element;
|
||||
}),
|
||||
);
|
||||
select.value = config.options?.[0]?.value || "";
|
||||
}
|
||||
|
||||
function runPeriodLabel(workflow) {
|
||||
return isRepeatableTmallBaibu(workflow) ? "运行记录日期" : "业务日期";
|
||||
}
|
||||
@@ -274,6 +317,11 @@
|
||||
|
||||
function syncRunPeriodHint() {
|
||||
const workflow = selectedWorkflow();
|
||||
if (isDateRangeWorkflow(workflow)) {
|
||||
byId("run-date-hint").textContent =
|
||||
workflow.date_range_hint || "按所选日期范围采集;平台会按可查询区间拆分。";
|
||||
return;
|
||||
}
|
||||
if (workflow?.run_date_mode !== "month") return;
|
||||
const range = naturalMonthRange(byId("run-business-date").value);
|
||||
byId("run-date-hint").textContent = range
|
||||
@@ -312,6 +360,7 @@
|
||||
source: "console",
|
||||
label: String(operationId),
|
||||
businessDate: workflow.active_run?.business_date || "正在确认",
|
||||
businessDateEnd: workflow.active_run?.business_date_end || null,
|
||||
};
|
||||
}
|
||||
if (workflow?.scheduler_job?.status === "running" && workflow.scheduler_job?.cancellable) {
|
||||
@@ -322,6 +371,7 @@
|
||||
source: "scheduler",
|
||||
label: "项目定时调度",
|
||||
businessDate: workflow.scheduler_job.business_date || "正在确认",
|
||||
businessDateEnd: null,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@@ -3167,6 +3217,7 @@
|
||||
const isAllShopDaily = workflow.id === "product.erp_all_shop_daily";
|
||||
const isNoteInventory = isNotesMasterWorkflow(workflow);
|
||||
const repeatableTmallBaibu = isRepeatableTmallBaibu(workflow);
|
||||
const dateRangeMode = isDateRangeWorkflow(workflow);
|
||||
byId("run-modal-title").textContent = isNoteInventory
|
||||
? `同步「${workflow.name}」`
|
||||
: isAllShopDaily
|
||||
@@ -3175,36 +3226,52 @@
|
||||
byId("run-workflow-id").textContent = workflow.id;
|
||||
const monthMode = workflow.run_date_mode === "month";
|
||||
const periodInput = byId("run-business-date");
|
||||
const periodEndInput = byId("run-business-date-end");
|
||||
byId("run-period-field").hidden = repeatableTmallBaibu;
|
||||
periodInput.required = !repeatableTmallBaibu;
|
||||
periodEndInput.hidden = !dateRangeMode;
|
||||
byId("run-date-range-separator").hidden = !dateRangeMode;
|
||||
periodEndInput.required = dateRangeMode;
|
||||
const defaultDate = todayForTimezone(workflow.schedule?.business_date_offset_days || 0);
|
||||
periodInput.type = monthMode ? "month" : "date";
|
||||
periodInput.value = monthMode ? defaultDate.slice(0, 7) : defaultDate;
|
||||
periodEndInput.value = defaultDate;
|
||||
const dateRangeConstraints = workflow.date_range_constraints || null;
|
||||
for (const input of [periodInput, periodEndInput]) {
|
||||
if (dateRangeMode && dateRangeConstraints) {
|
||||
input.min = dateRangeConstraints.min;
|
||||
input.max = dateRangeConstraints.max;
|
||||
} else {
|
||||
input.removeAttribute("min");
|
||||
input.removeAttribute("max");
|
||||
}
|
||||
}
|
||||
byId("run-period-label").textContent = isNoteInventory
|
||||
? "运行记录日期"
|
||||
: repeatableTmallBaibu
|
||||
? "运行记录日期"
|
||||
: monthMode
|
||||
? "业务月份"
|
||||
: isAllShopDaily ? "补采日期" : "业务日期";
|
||||
: isAllShopDaily ? "补采日期"
|
||||
: dateRangeMode ? "执行开始日期"
|
||||
: "业务日期";
|
||||
byId("run-date-hint").textContent = isNoteInventory
|
||||
? "仅用于标记本次运行记录;正式同步始终扫描当前各款式的合作达人和自营笔记表。"
|
||||
: repeatableTmallBaibu
|
||||
? "仅用于平台内部记录和归档,不参与百补导入防重;每次都会重新下载并提交。"
|
||||
: isAllShopDaily
|
||||
? "默认选择昨天;也可以选择任意一天,正式执行后将全选聚水潭全部店铺并幂等覆盖该日款式数据。"
|
||||
: dateRangeMode
|
||||
? (workflow.date_range_hint || "按所选店铺和日期范围逐日采集;每个业务日独立幂等。")
|
||||
: workflow.schedule?.business_date_offset_days
|
||||
? `已按计划偏移 ${workflow.schedule.business_date_offset_days} 天预填;手动选择的是业务日期。`
|
||||
: "本次数据处理所对应的业务日期。";
|
||||
const storeField = byId("run-store-field");
|
||||
const supportsStoreSelection = workflow.id === "product.video_upload";
|
||||
storeField.hidden = !supportsStoreSelection;
|
||||
byId("run-store").value = "flagship";
|
||||
syncRunStoreField(workflow);
|
||||
syncTmallTopicField(workflow);
|
||||
syncTmallBaibuImportField(workflow);
|
||||
byId("run-preview-title").textContent = isNoteInventory ? "同步预演" : "安全预演";
|
||||
byId("run-preview-description").textContent = isNoteInventory ? "检查执行计划,不写入数据库" : "检查流程但不执行外部效果";
|
||||
if (monthMode) syncRunPeriodHint();
|
||||
if (monthMode || dateRangeMode) syncRunPeriodHint();
|
||||
document.querySelector(`input[name="execute"][value="${forceRefresh ? "true" : "false"}"]`).checked = true;
|
||||
byId("run-shadow").checked = false;
|
||||
byId("run-confirmed").checked = false;
|
||||
@@ -3280,7 +3347,9 @@
|
||||
byId("stop-modal-title").textContent = `停止「${workflow.name}」`;
|
||||
byId("stop-workflow-id").textContent = workflow.id;
|
||||
byId("stop-workflow-name").textContent = workflow.name;
|
||||
byId("stop-business-date").textContent = operation.businessDate;
|
||||
byId("stop-business-date").textContent = operation.businessDateEnd
|
||||
? `${operation.businessDate} 至 ${operation.businessDateEnd}`
|
||||
: operation.businessDate;
|
||||
byId("stop-operation-id").textContent = operation.label;
|
||||
byId("stop-form-error").hidden = true;
|
||||
syncStopDialogSubmitting(false);
|
||||
@@ -3382,10 +3451,13 @@
|
||||
const execute = document.querySelector('input[name="execute"]:checked')?.value === "true";
|
||||
const forceRefresh = !isRepeatableTmallBaibu(workflow) && byId("run-force").checked;
|
||||
const repeatableTmallBaibu = isRepeatableTmallBaibu(workflow);
|
||||
const dateRangeMode = isDateRangeWorkflow(workflow);
|
||||
const selectedPeriod = byId("run-business-date").value;
|
||||
const selectedPeriodEnd = byId("run-business-date-end").value;
|
||||
const monthMode = workflow.run_date_mode === "month";
|
||||
const businessDate = repeatableTmallBaibu ? todayForTimezone(0) : monthMode ? `${selectedPeriod}-01` : selectedPeriod;
|
||||
const store = workflow.id === "product.video_upload" ? byId("run-store").value : null;
|
||||
const businessDateEnd = dateRangeMode ? selectedPeriodEnd : null;
|
||||
const store = runStoreConfig(workflow) ? byId("run-store").value : null;
|
||||
const tmallTopicKeyword = workflow.id === "product.video_upload"
|
||||
? byId("run-tmall-topic-keyword").value.trim()
|
||||
: null;
|
||||
@@ -3394,6 +3466,7 @@
|
||||
: null;
|
||||
const errorBox = byId("run-form-error");
|
||||
byId("run-business-date").removeAttribute("aria-invalid");
|
||||
byId("run-business-date-end").removeAttribute("aria-invalid");
|
||||
errorBox.hidden = true;
|
||||
if (!repeatableTmallBaibu && !selectedPeriod) {
|
||||
byId("run-business-date").setAttribute("aria-invalid", "true");
|
||||
@@ -3402,6 +3475,21 @@
|
||||
byId("run-business-date").focus();
|
||||
return;
|
||||
}
|
||||
if (dateRangeMode && !selectedPeriodEnd) {
|
||||
byId("run-business-date-end").setAttribute("aria-invalid", "true");
|
||||
errorBox.textContent = "请选择执行结束日期";
|
||||
errorBox.hidden = false;
|
||||
byId("run-business-date-end").focus();
|
||||
return;
|
||||
}
|
||||
if (dateRangeMode && selectedPeriodEnd < selectedPeriod) {
|
||||
byId("run-business-date").setAttribute("aria-invalid", "true");
|
||||
byId("run-business-date-end").setAttribute("aria-invalid", "true");
|
||||
errorBox.textContent = "结束日期不能早于开始日期";
|
||||
errorBox.hidden = false;
|
||||
byId("run-business-date-end").focus();
|
||||
return;
|
||||
}
|
||||
state.launchingWorkflows.add(workflow.id);
|
||||
if (forceRefresh) state.forceLaunchingWorkflows.add(workflow.id);
|
||||
renderModuleNav();
|
||||
@@ -3413,6 +3501,7 @@
|
||||
method: "POST",
|
||||
body: {
|
||||
business_date: businessDate,
|
||||
...(businessDateEnd ? { business_date_end: businessDateEnd } : {}),
|
||||
execute,
|
||||
shadow: byId("run-shadow").checked,
|
||||
confirmed: execute && byId("run-confirmed").checked,
|
||||
@@ -3427,7 +3516,9 @@
|
||||
},
|
||||
});
|
||||
closeRun();
|
||||
const storeLabel = store === "flagship" ? "光影行星旗舰店" : store === "luggage" ? "光影行星鑫华达专卖店:龙虾仔" : "";
|
||||
const storeLabel = store
|
||||
? byId("run-store").selectedOptions[0]?.textContent || store
|
||||
: "";
|
||||
const topicLabel = tmallTopicKeyword ? `话题关键词 ${tmallTopicKeyword}` : "";
|
||||
const tmallBaibuImportLabel = tmallBaibuImportMode
|
||||
? byId("run-tmall-baibu-mode").selectedOptions[0]?.textContent || ""
|
||||
@@ -3436,11 +3527,12 @@
|
||||
const successTitle = forceRefresh
|
||||
? noteInventory ? "已提交强制同步" : "已提交强制重跑"
|
||||
: noteInventory ? "已提交笔记清单同步" : "已提交运行";
|
||||
const periodLabel = isRepeatableTmallBaibu(workflow) ? "运行记录" : "业务日期";
|
||||
const periodLabel = isRepeatableTmallBaibu(workflow) ? "运行记录" : dateRangeMode ? "执行日期范围" : "业务日期";
|
||||
const periodText = dateRangeMode ? `${businessDate} 至 ${businessDateEnd}` : businessDate;
|
||||
toast(
|
||||
"success",
|
||||
successTitle,
|
||||
`${execute ? forceRefresh ? "强制重跑" : noteInventory ? "正式同步" : "正式执行" : noteInventory ? "同步预演" : "安全预演"}${storeLabel ? ` · ${storeLabel}` : ""}${topicLabel ? ` · ${topicLabel}` : ""}${tmallBaibuImportLabel ? ` · ${tmallBaibuImportLabel}` : ""} · ${periodLabel} ${businessDate} · 操作 ${result.operation_id}`,
|
||||
`${execute ? forceRefresh ? "强制重跑" : noteInventory ? "正式同步" : "正式执行" : noteInventory ? "同步预演" : "安全预演"}${storeLabel ? ` · ${storeLabel}` : ""}${topicLabel ? ` · ${topicLabel}` : ""}${tmallBaibuImportLabel ? ` · ${tmallBaibuImportLabel}` : ""} · ${periodLabel} ${periodText} · 操作 ${result.operation_id}`,
|
||||
);
|
||||
await loadOverview({ silent: true });
|
||||
openDrawer(workflow.id, "steps");
|
||||
|
||||
@@ -462,17 +462,21 @@
|
||||
<div class="modal__body">
|
||||
<label class="field" id="run-period-field">
|
||||
<span id="run-period-label">业务日期</span>
|
||||
<input id="run-business-date" name="business_date" type="date" required>
|
||||
<div class="run-date-range">
|
||||
<input id="run-business-date" name="business_date" type="date" required>
|
||||
<span id="run-date-range-separator" aria-hidden="true">至</span>
|
||||
<input id="run-business-date-end" name="business_date_end" type="date" aria-label="执行结束日期" hidden>
|
||||
</div>
|
||||
<small id="run-date-hint">本次数据处理所对应的业务日期。</small>
|
||||
</label>
|
||||
|
||||
<label class="field" id="run-store-field" hidden>
|
||||
<span>上传店铺</span>
|
||||
<span id="run-store-label">上传店铺</span>
|
||||
<select id="run-store" name="store">
|
||||
<option value="flagship">光影行星旗舰店</option>
|
||||
<option value="luggage">光影行星鑫华达专卖店:龙虾仔</option>
|
||||
</select>
|
||||
<small>先扫描飞书并按所选店铺规则筛选;存在未上传附件时才登录该店铺账号。</small>
|
||||
<small id="run-store-hint">先扫描飞书并按所选店铺规则筛选;存在未上传附件时才登录该店铺账号。</small>
|
||||
</label>
|
||||
|
||||
<label class="field" id="run-tmall-topic-field" hidden>
|
||||
|
||||
Reference in new issue
Block a user