You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
4.7 KiB
149 lines
4.7 KiB
/**
|
|
* UI: only unit.isCurrent confirmable; history readonly + tag
|
|
*/
|
|
import fs from "fs";
|
|
|
|
// --- Shell ---
|
|
{
|
|
const path = "src/components/MailInstructionUnitShell.tsx";
|
|
let src = fs.readFileSync(path, "utf8");
|
|
const oldExtra = ` extra={
|
|
unit.keywords.length ? (
|
|
<Space wrap size={[4, 4]}>
|
|
{unit.keywords.slice(0, 6).map((k) => (
|
|
<Tag key={k}>{k}</Tag>
|
|
))}
|
|
</Space>
|
|
) : null
|
|
}`;
|
|
const newExtra = ` extra={
|
|
<Space wrap size={[4, 4]}>
|
|
<Tag color={unit.isCurrent ? "processing" : "default"}>
|
|
{unit.isCurrent ? "\u53ef\u786e\u8ba4" : "\u5386\u53f2\u53ea\u8bfb"}
|
|
</Tag>
|
|
{unit.keywords.slice(0, 5).map((k) => (
|
|
<Tag key={k}>{k}</Tag>
|
|
))}
|
|
</Space>
|
|
}`;
|
|
if (!src.includes(oldExtra)) throw new Error("shell extra block missing");
|
|
src = src.replace(oldExtra, newExtra);
|
|
fs.writeFileSync(path, src);
|
|
console.log("shell ok");
|
|
}
|
|
|
|
// --- MailBusinessSummary confirm gates ---
|
|
{
|
|
const path = "src/components/MailBusinessSummary.tsx";
|
|
let src = fs.readFileSync(path, "utf8");
|
|
|
|
// transfer: only current can confirm / edit WO fallback
|
|
src = src.replace(
|
|
` {blocked ? (
|
|
<CcWorkOrderForm
|
|
mode={canConfirmOps ? "edit" : "readonly"}`,
|
|
` {blocked ? (
|
|
<CcWorkOrderForm
|
|
mode={canConfirmOps && unit.isCurrent ? "edit" : "readonly"}`,
|
|
);
|
|
|
|
src = src.replace(
|
|
` if (canConfirmOps) {
|
|
actions = blocked ? (
|
|
<Button
|
|
type="primary"
|
|
loading={submitting}
|
|
onClick={() => void submitWorkOrder()}
|
|
>
|
|
\u8f6c\u4ed3\u4e0d\u53ef\u7528\uff0c\u63d0\u4ea4\u5de5\u5355
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
type="primary"
|
|
loading={submitting}
|
|
onClick={() => void submitTransfer()}
|
|
>
|
|
\u786e\u8ba4\u6279\u91cf\u8f6c\u4ed3
|
|
</Button>
|
|
);
|
|
}`,
|
|
` if (canConfirmOps && unit.isCurrent) {
|
|
actions = blocked ? (
|
|
<Button
|
|
type="primary"
|
|
loading={submitting}
|
|
onClick={() => void submitWorkOrder()}
|
|
>
|
|
\u8f6c\u4ed3\u4e0d\u53ef\u7528\uff0c\u63d0\u4ea4\u5de5\u5355
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
type="primary"
|
|
loading={submitting}
|
|
onClick={() => void submitTransfer()}
|
|
>
|
|
\u786e\u8ba4\u6279\u91cf\u8f6c\u4ed3
|
|
</Button>
|
|
);
|
|
}`,
|
|
);
|
|
|
|
// work_order mode
|
|
src = src.replace(
|
|
` <CcWorkOrderForm
|
|
mode={canConfirmOps ? "edit" : "readonly"}
|
|
value={{
|
|
...woForUnit,
|
|
// keep edits on shared state when confirming primary WO
|
|
...(mail.mail_type === "WORK_ORDER" && unit.isCurrent
|
|
? workOrderValue
|
|
: {}),
|
|
}}
|
|
onChange={(p) => setWorkOrderValue((v) => ({ ...v, ...p }))}
|
|
/>
|
|
);
|
|
if (canConfirmOps && mail.mail_type === "WORK_ORDER") {`,
|
|
` <CcWorkOrderForm
|
|
mode={canConfirmOps && unit.isCurrent ? "edit" : "readonly"}
|
|
value={{
|
|
...woForUnit,
|
|
...(unit.isCurrent ? workOrderValue : {}),
|
|
}}
|
|
onChange={(p) => setWorkOrderValue((v) => ({ ...v, ...p }))}
|
|
/>
|
|
);
|
|
if (canConfirmOps && unit.isCurrent) {`,
|
|
);
|
|
|
|
// do_upload
|
|
src = src.replace(
|
|
` <CcDoUploadPanel
|
|
mode={canConfirmOps ? "edit" : "readonly"}
|
|
value={
|
|
mail.mail_type === "DO_UPLOAD" && unit.isCurrent
|
|
? doValue
|
|
: doForUnit
|
|
}
|
|
onChange={(p) => setDoValue((v) => ({ ...v, ...p }))}
|
|
/>
|
|
);
|
|
if (
|
|
canConfirmOps &&
|
|
(mail.mail_type === "DO_UPLOAD" || unit.isCurrent)
|
|
) {`,
|
|
` <CcDoUploadPanel
|
|
mode={canConfirmOps && unit.isCurrent ? "edit" : "readonly"}
|
|
value={unit.isCurrent ? doValue : doForUnit}
|
|
onChange={(p) => setDoValue((v) => ({ ...v, ...p }))}
|
|
/>
|
|
);
|
|
if (canConfirmOps && unit.isCurrent) {`,
|
|
);
|
|
|
|
fs.writeFileSync(path, src);
|
|
console.log("summary ok", {
|
|
transferCur: src.includes("canConfirmOps && unit.isCurrent"),
|
|
woMode: src.includes('mode={canConfirmOps && unit.isCurrent ? "edit"'),
|
|
});
|
|
}
|