@skillre/dsh-plugin-work-dashboard 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +5 -8
- package/README.md +5 -8
- package/lib/client/api.d.ts +3 -3
- package/lib/client/api.js +1 -3
- package/lib/client.js +18 -16
- package/lib/index.js +35 -1
- package/lib/report-contract.d.ts +132 -2
- package/lib/report-contract.js +126 -0
- package/lib/report-form.d.ts +10 -1
- package/lib/report-form.js +26 -2
- package/lib/report-page.js +2052 -1168
- package/lib/report-style.d.ts +24 -13
- package/lib/report-style.js +380 -398
- package/lib/transport.d.ts +5 -5
- package/lib/transport.js +4 -3
- package/lib/types.d.ts +5 -3
- package/package.json +9 -16
- package/compatibility.json +0 -240
- package/docs/DESIGN-0.3.md +0 -122
- package/docs/DESIGN-1.0-/344/274/230/345/214/226/346/226/271/346/241/210.md +0 -212
- package/docs/DESIGN-/344/274/232/350/257/235/344/272/214-SuperAgent/344/270/216/344/273/223/345/272/223/346/224/271/351/200/240.md +0 -275
- package/docs/DESIGN-/345/257/274/345/207/272/350/241/250/345/215/225/351/207/215/350/256/276/350/256/241.md +0 -330
- package/docs/DESIGN-/346/217/220/351/206/222/344/270/216Gate/350/257/204/345/256/241.md +0 -518
- package/docs/DESIGN-/346/226/207/346/234/254/346/210/252/346/226/255.md +0 -565
- package/docs/DESIGN-/350/241/250/345/215/225/345/210/206/351/230/266/346/256/265.md +0 -420
- package/docs/LEDGER-REQUIREMENTS-v3.1.md +0 -367
- package/docs/PLAN-0.7-0.9.md +0 -230
- package/docs/PLAN-v3.1-adaptation.md +0 -237
- package/docs/POC-3.2-/350/277/233/345/261/225/345/245/221/347/272/246.md +0 -21
- package/docs/Super-Agent-3.2-/350/201/224/350/260/203/346/211/213/345/206/214.md +0 -38
- package/docs/TARGET-/345/217/260/350/264/246/344/273/223/345/272/223v3.1.md +0 -500
- package/docs//350/200/201Mac-SuperAgent/346/224/271/351/200/240/350/256/260/345/275/225-/347/254/254/344/272/214/346/255/245.md +0 -233
- package/lib/form.d.ts +0 -597
- package/lib/form.js +0 -3211
package/lib/form.js
DELETED
|
@@ -1,3211 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The v3 collection form: a self-contained HTML file a colleague can fill in.
|
|
3
|
-
*
|
|
4
|
-
* ## What changed from the v1 form
|
|
5
|
-
*
|
|
6
|
-
* The v1 generator modelled `why_customer_test` / `success_criteria` /
|
|
7
|
-
* `result` / `timeline` — all removed by v3. Shipping it would have handed
|
|
8
|
-
* colleagues a file the ledger can no longer read, so it was held back while
|
|
9
|
-
* this replacement was written, and then deleted.
|
|
10
|
-
*
|
|
11
|
-
* v3 is **progress-centred**: `gate0` says whether the project is worth doing,
|
|
12
|
-
* `plan` says how to win, and `progress[]` is the append-only history. The form
|
|
13
|
-
* therefore asks for exactly those three, and nothing else:
|
|
14
|
-
*
|
|
15
|
-
* 1. **G0** — the five prerequisites (four here; `tech_owner` is identity, which
|
|
16
|
-
* the blank form asks for too), each with a "why this matters" hint.
|
|
17
|
-
* 2. **Plan** — pain, expected recognition, 2–3 criteria, 3–5 scenarios, ≤3
|
|
18
|
-
* risks, edge. The counts are validated live because the gap rules enforce
|
|
19
|
-
* them and a colleague cannot know that.
|
|
20
|
-
* 3. **Progress** — one new entry, appended. The form never rewrites history.
|
|
21
|
-
*
|
|
22
|
-
* ## What is kept from v1 because it was hard-won
|
|
23
|
-
*
|
|
24
|
-
* - **One file, no server, no CDN.** Everything inlined, works offline.
|
|
25
|
-
* - **Autosave keyed by the project set**, not by a timestamp: regenerating the
|
|
26
|
-
* form for the same projects must find the same draft.
|
|
27
|
-
* - **Real YAML out**, via `yaml`'s own stringifier, so `name: 某某:试点` stays
|
|
28
|
-
* valid.
|
|
29
|
-
* - **One file per project** on download, so two colleagues never clobber a
|
|
30
|
-
* shared file.
|
|
31
|
-
*
|
|
32
|
-
* ## What it deliberately does NOT do
|
|
33
|
-
*
|
|
34
|
-
* It does not write to the ledger. The output is a `.yaml` the owner reviews and
|
|
35
|
-
* commits; submission stays a human-merged PR, which is the ledger's design.
|
|
36
|
-
*/
|
|
37
|
-
import YAML from 'yaml';
|
|
38
|
-
/** The four G0 prerequisites that live under `gate0` (the fifth is identity). */
|
|
39
|
-
export const G0_FIELDS = Object.freeze([
|
|
40
|
-
'why_customer',
|
|
41
|
-
'why_us',
|
|
42
|
-
'decision_chain',
|
|
43
|
-
'post_poc_decision',
|
|
44
|
-
]);
|
|
45
|
-
/** The stage ids, local to keep the browser payload free of the frozen tuple. */
|
|
46
|
-
const STAGE_IDS = ['G0', 'G1', 'G2', 'G3', 'G4'];
|
|
47
|
-
/**
|
|
48
|
-
* Which sections each stage is about.
|
|
49
|
-
*
|
|
50
|
-
* Derived from the ledger's own structure rather than invented: `schemas/poc-schema.md`
|
|
51
|
-
* groups fields into ①identity ②gate0 ③plan ④progress ⑤outcome, each gate's
|
|
52
|
-
* verdict lives in its group, and the 16 gap rules judge by the same grouping
|
|
53
|
-
* (R1–R3 gate0, R4–R6 plan, R8–R10 progress, R11 outcome). So "G1 fills the plan"
|
|
54
|
-
* is the data model, not a convention this form invented.
|
|
55
|
-
*/
|
|
56
|
-
const SECTIONS_FOR_STAGE = {
|
|
57
|
-
G0: ['identity', 'gate0'],
|
|
58
|
-
G1: ['plan', 'gate12'],
|
|
59
|
-
G2: ['plan', 'gate12', 'progress'],
|
|
60
|
-
G3: ['progress'],
|
|
61
|
-
G4: ['progress', 'outcome'],
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* The sections one intent may EDIT.
|
|
65
|
-
*
|
|
66
|
-
* `new` asks only for what a project needs to exist: identity plus the five G0
|
|
67
|
-
* prerequisites. It deliberately does not ask for a plan — gap rule R3 only
|
|
68
|
-
* demands a plan *after* G0 passes, so asking earlier pushes people to write a
|
|
69
|
-
* plan before they have thought one through, which R4/R5 then reject.
|
|
70
|
-
*
|
|
71
|
-
* `progress` edits nothing but the appended round: it is the highest-frequency
|
|
72
|
-
* form and must fit one screen.
|
|
73
|
-
*/
|
|
74
|
-
const EDITABLE_FOR_INTENT = {
|
|
75
|
-
new: ['identity', 'gate0'],
|
|
76
|
-
supplement: ['identity', 'gate0', 'plan', 'gate12', 'progress', 'outcome'],
|
|
77
|
-
progress: ['progress'],
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Resolve what a form should ask, given the intent and the project's stage.
|
|
81
|
-
*
|
|
82
|
-
* Returns the editable sections (the subject) and the context sections (shown
|
|
83
|
-
* read-only so the colleague knows what they are adding to). An unknown stage
|
|
84
|
-
* falls back to G0's set: a project whose stage is unrecognised is, for form
|
|
85
|
-
* purposes, still being set up.
|
|
86
|
-
*/
|
|
87
|
-
export function resolveSections(intent, stage) {
|
|
88
|
-
const key = (STAGE_IDS.find((id) => stage === id || stage.startsWith(`${id}-`)) ?? 'G0');
|
|
89
|
-
const stageSections = SECTIONS_FOR_STAGE[key];
|
|
90
|
-
const allowed = EDITABLE_FOR_INTENT[intent];
|
|
91
|
-
if (intent === 'new' || intent === 'progress') {
|
|
92
|
-
const editable = allowed.filter((section) => section === 'identity' || section === 'gate0' || section === 'progress');
|
|
93
|
-
return { editable: [...editable], context: [] };
|
|
94
|
-
}
|
|
95
|
-
// `supplement` edits the current stage's subject, and shows only what came
|
|
96
|
-
// BEFORE it as read-only context — never a later stage, which has not
|
|
97
|
-
// happened yet. Showing a G4 project's empty conclusion block to someone
|
|
98
|
-
// filling in G1 invites them to invent a conclusion.
|
|
99
|
-
const editable = stageSections.filter((section) => allowed.includes(section));
|
|
100
|
-
const order = ['identity', 'gate0', 'plan', 'gate12', 'progress', 'outcome'];
|
|
101
|
-
const currentIndex = stageSections.length === 0 ? -1 : Math.max(...stageSections.map((section) => order.indexOf(section)));
|
|
102
|
-
const context = order.filter((section) => {
|
|
103
|
-
if (section === 'progress')
|
|
104
|
-
return false;
|
|
105
|
-
if (editable.includes(section))
|
|
106
|
-
return false;
|
|
107
|
-
// Only sections that precede the current stage's subject.
|
|
108
|
-
return order.indexOf(section) < currentIndex;
|
|
109
|
-
});
|
|
110
|
-
return { editable: [...editable], context };
|
|
111
|
-
}
|
|
112
|
-
/** Coerce a stored value to the string the form edits. */
|
|
113
|
-
function text(value) {
|
|
114
|
-
if (value === null || value === undefined)
|
|
115
|
-
return '';
|
|
116
|
-
if (typeof value === 'string')
|
|
117
|
-
return value;
|
|
118
|
-
if (typeof value === 'number' || typeof value === 'boolean')
|
|
119
|
-
return String(value);
|
|
120
|
-
return '';
|
|
121
|
-
}
|
|
122
|
-
/** A `YYYY-MM-DD` date, or `''`. */
|
|
123
|
-
function dateText(value) {
|
|
124
|
-
const raw = text(value);
|
|
125
|
-
return /^\d{4}-\d{2}-\d{2}$/.test(raw) ? raw : '';
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Convert one ledger record into the form's project shape.
|
|
129
|
-
*
|
|
130
|
-
* Every field becomes a string or a list of strings. A missing block becomes an
|
|
131
|
-
* empty one rather than `undefined`, so the generated script never has to guard.
|
|
132
|
-
*/
|
|
133
|
-
export function projectForForm(record) {
|
|
134
|
-
const gate0 = record.gate0 ?? {};
|
|
135
|
-
const plan = record.plan ?? {};
|
|
136
|
-
const outcome = record.outcome ?? {};
|
|
137
|
-
const progress = Array.isArray(record.progress) ? record.progress : [];
|
|
138
|
-
const org = record.org ?? {};
|
|
139
|
-
const review = gate0.review ?? {};
|
|
140
|
-
return {
|
|
141
|
-
pocId: text(record.poc_id),
|
|
142
|
-
name: text(record.name),
|
|
143
|
-
system: text(org.system),
|
|
144
|
-
company: text(org.company),
|
|
145
|
-
department: text(org.department),
|
|
146
|
-
amountWan: numberText(record.amount_wan),
|
|
147
|
-
pocType: text(record.poc_type),
|
|
148
|
-
owner: text(record.owner),
|
|
149
|
-
sales: text(record.sales),
|
|
150
|
-
techOwner: text(record.tech_owner),
|
|
151
|
-
execSponsor: text(record.exec_sponsor),
|
|
152
|
-
stage: text(record.stage),
|
|
153
|
-
status: text(record.status),
|
|
154
|
-
stageSince: dateText(record.stage_since),
|
|
155
|
-
gate0: {
|
|
156
|
-
why_customer: text(gate0.why_customer),
|
|
157
|
-
why_us: text(gate0.why_us),
|
|
158
|
-
decision_chain: text(gate0.decision_chain),
|
|
159
|
-
post_poc_decision: text(gate0.post_poc_decision),
|
|
160
|
-
competitor: text(gate0.competitor),
|
|
161
|
-
conclusion: text(review.conclusion),
|
|
162
|
-
reviewer: text(review.reviewer),
|
|
163
|
-
reviewed_at: dateText(review.reviewed_at),
|
|
164
|
-
},
|
|
165
|
-
plan: {
|
|
166
|
-
customer_pain: text(plan.customer_pain),
|
|
167
|
-
expected_recognition: text(plan.expected_recognition),
|
|
168
|
-
our_edge: text(plan.our_edge),
|
|
169
|
-
criteria: (Array.isArray(plan.criteria) ? plan.criteria : []).map((item, index) => ({
|
|
170
|
-
// A criterion without an id in the ledger is given one on the way out so
|
|
171
|
-
// the form can reference it; the Host is what writes it back.
|
|
172
|
-
id: text(item?.id) === '' ? `cri-${String(index + 1).padStart(2, '0')}` : text(item?.id),
|
|
173
|
-
name: text(item?.name),
|
|
174
|
-
metric: text(item?.metric),
|
|
175
|
-
baseline: text(item?.baseline),
|
|
176
|
-
target: text(item?.target),
|
|
177
|
-
})),
|
|
178
|
-
// v3.1: objects with a stable id, not bare strings.
|
|
179
|
-
scenarios: (Array.isArray(plan.scenarios) ? plan.scenarios : [])
|
|
180
|
-
.filter((item) => item !== null && item !== undefined)
|
|
181
|
-
.map((item, index) => ({
|
|
182
|
-
id: text(item?.id) === '' ? `scn-${String(index + 1).padStart(2, '0')}` : text(item?.id),
|
|
183
|
-
name: text(item?.name),
|
|
184
|
-
goal: text(item?.goal),
|
|
185
|
-
})),
|
|
186
|
-
risks: (Array.isArray(plan.risks) ? plan.risks : []).map((item) => ({
|
|
187
|
-
name: text(item?.name),
|
|
188
|
-
level: text(item?.level).toLowerCase(),
|
|
189
|
-
mitigation: text(item?.mitigation),
|
|
190
|
-
})),
|
|
191
|
-
timeline_start: dateText(plan.timeline?.start),
|
|
192
|
-
timeline_end: dateText(plan.timeline?.end),
|
|
193
|
-
gate1_conclusion: text(plan.gate1?.conclusion),
|
|
194
|
-
gate2_ready: text(plan.gate2?.ready),
|
|
195
|
-
},
|
|
196
|
-
progress: blankProgress(progress.length),
|
|
197
|
-
existingProgressCount: progress.length,
|
|
198
|
-
history: progressHistory(progress),
|
|
199
|
-
// G4 only. Read here so a G4 form opens with the current conclusion in
|
|
200
|
-
// place rather than blank, which would invite overwriting it by omission.
|
|
201
|
-
outcome: {
|
|
202
|
-
achievement: text(outcome.achievement),
|
|
203
|
-
customer_recognition: text(outcome.customer_recognition),
|
|
204
|
-
our_proof: text(outcome.our_proof),
|
|
205
|
-
proved: text((outcome.conclusion ?? {}).proved),
|
|
206
|
-
recognized: text((outcome.conclusion ?? {}).recognized),
|
|
207
|
-
next_business: text((outcome.conclusion ?? {}).next_business),
|
|
208
|
-
milestone: text((outcome.business ?? {}).milestone),
|
|
209
|
-
businessOwner: text((outcome.business ?? {}).owner),
|
|
210
|
-
businessDeadline: dateText((outcome.business ?? {}).deadline),
|
|
211
|
-
businessStatus: text((outcome.business ?? {}).status),
|
|
212
|
-
overall: text(outcome.overall),
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/** A numeric field as the form's string, keeping `0` distinct from blank. */
|
|
217
|
-
function numberText(value) {
|
|
218
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
219
|
-
return String(value);
|
|
220
|
-
const raw = text(value);
|
|
221
|
-
return raw === '' ? '' : raw;
|
|
222
|
-
}
|
|
223
|
-
/** How many recorded rounds the form lists read-only. */
|
|
224
|
-
export const HISTORY_LIMIT = 5;
|
|
225
|
-
/**
|
|
226
|
-
* Flatten the recorded rounds for the read-only history block.
|
|
227
|
-
*
|
|
228
|
-
* Newest first, because the round a colleague is about to continue is the newest
|
|
229
|
-
* one: reading it first is what makes "这次什么变了" answerable. The order is
|
|
230
|
-
* reversed rather than re-sorted by date because the ledger's own array order is
|
|
231
|
-
* the append order, and a hand-edited `date` must not reshuffle history.
|
|
232
|
-
*/
|
|
233
|
-
export function progressHistory(progress) {
|
|
234
|
-
const entries = [];
|
|
235
|
-
for (let index = progress.length - 1; index >= 0 && entries.length < HISTORY_LIMIT; index -= 1) {
|
|
236
|
-
const entry = progress[index];
|
|
237
|
-
if (entry === null || entry === undefined)
|
|
238
|
-
continue;
|
|
239
|
-
const customer = entry.customer ?? {};
|
|
240
|
-
const next = entry.next ?? {};
|
|
241
|
-
entries.push({
|
|
242
|
-
seq: typeof entry.seq === 'number' ? entry.seq : null,
|
|
243
|
-
date: dateText(entry.date),
|
|
244
|
-
type: text(entry.type),
|
|
245
|
-
change: text(entry.change),
|
|
246
|
-
actual: text(entry.actual),
|
|
247
|
-
completion: text(entry.completion),
|
|
248
|
-
evidence: (Array.isArray(entry.evidence) ? entry.evidence : [])
|
|
249
|
-
.map((item) => text(item?.title).trim())
|
|
250
|
-
.filter((title) => title !== ''),
|
|
251
|
-
syncedWith: text(customer.synced_with),
|
|
252
|
-
recognition: text(customer.recognition),
|
|
253
|
-
nextGoal: text(next.goal),
|
|
254
|
-
nextOwner: text(next.owner),
|
|
255
|
-
nextDeadline: dateText(next.deadline),
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
return entries;
|
|
259
|
-
}
|
|
260
|
-
/** One empty progress entry, with `seq` continuing the existing count. */
|
|
261
|
-
export function blankProgress(existingCount) {
|
|
262
|
-
return {
|
|
263
|
-
seq: existingCount + 1,
|
|
264
|
-
date: '',
|
|
265
|
-
type: '',
|
|
266
|
-
change: '',
|
|
267
|
-
goal: '',
|
|
268
|
-
scenarioIds: [],
|
|
269
|
-
criteriaIds: [],
|
|
270
|
-
actual: '',
|
|
271
|
-
completion: '',
|
|
272
|
-
// One empty row, so the required evidence field has an obvious place to type
|
|
273
|
-
// instead of presenting only a "+ 加一条证据" button. `progressIsEmpty` still
|
|
274
|
-
// treats an all-blank list as "the colleague recorded nothing", so this does
|
|
275
|
-
// not by itself make a round look filled in.
|
|
276
|
-
evidence: [{ title: '', link: '', type: '' }],
|
|
277
|
-
customer: { synced_with: '', feedback: '', recognition: '' },
|
|
278
|
-
gate3_1: '',
|
|
279
|
-
gate3_2: '',
|
|
280
|
-
next: { goal: '', owner: '', deadline: '' },
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
/** The blank project a `blank`-mode form edits. */
|
|
284
|
-
export function blankProject() {
|
|
285
|
-
return {
|
|
286
|
-
pocId: '',
|
|
287
|
-
name: '',
|
|
288
|
-
system: '',
|
|
289
|
-
company: '',
|
|
290
|
-
department: '',
|
|
291
|
-
amountWan: '',
|
|
292
|
-
pocType: '',
|
|
293
|
-
owner: '',
|
|
294
|
-
sales: '',
|
|
295
|
-
techOwner: '',
|
|
296
|
-
execSponsor: '',
|
|
297
|
-
stage: 'G0-立项',
|
|
298
|
-
status: '进行中',
|
|
299
|
-
stageSince: '',
|
|
300
|
-
gate0: {
|
|
301
|
-
why_customer: '',
|
|
302
|
-
why_us: '',
|
|
303
|
-
decision_chain: '',
|
|
304
|
-
post_poc_decision: '',
|
|
305
|
-
competitor: '',
|
|
306
|
-
conclusion: '',
|
|
307
|
-
reviewer: '',
|
|
308
|
-
reviewed_at: '',
|
|
309
|
-
},
|
|
310
|
-
plan: {
|
|
311
|
-
customer_pain: '',
|
|
312
|
-
expected_recognition: '',
|
|
313
|
-
our_edge: '',
|
|
314
|
-
criteria: [],
|
|
315
|
-
scenarios: [],
|
|
316
|
-
risks: [],
|
|
317
|
-
timeline_start: '',
|
|
318
|
-
timeline_end: '',
|
|
319
|
-
gate1_conclusion: '',
|
|
320
|
-
gate2_ready: '',
|
|
321
|
-
},
|
|
322
|
-
progress: blankProgress(0),
|
|
323
|
-
existingProgressCount: 0,
|
|
324
|
-
history: [],
|
|
325
|
-
outcome: {
|
|
326
|
-
achievement: '',
|
|
327
|
-
customer_recognition: '',
|
|
328
|
-
our_proof: '',
|
|
329
|
-
proved: '',
|
|
330
|
-
recognized: '',
|
|
331
|
-
next_business: '',
|
|
332
|
-
milestone: '',
|
|
333
|
-
businessOwner: '',
|
|
334
|
-
businessDeadline: '',
|
|
335
|
-
businessStatus: '',
|
|
336
|
-
overall: '',
|
|
337
|
-
},
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Build the stable draft key.
|
|
342
|
-
*
|
|
343
|
-
* Sorting the ids makes the key independent of selection order, so the same set
|
|
344
|
-
* of projects always resumes the same draft — even if the user regenerates the
|
|
345
|
-
* form later. A blank form gets a constant key so its draft survives too.
|
|
346
|
-
*/
|
|
347
|
-
export function draftKeyFor(mode, pocIds) {
|
|
348
|
-
if (mode === 'blank')
|
|
349
|
-
return 'poc-v3-form-draft-blank';
|
|
350
|
-
return `poc-v3-form-draft-${[...pocIds].sort().join('+')}`;
|
|
351
|
-
}
|
|
352
|
-
/** Drop empty strings from a list, so a stored YAML has no blank rows. */
|
|
353
|
-
function compact(values) {
|
|
354
|
-
return values.map((value) => value.trim()).filter((value) => value !== '');
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Serialize one project back to the v3 YAML shape.
|
|
358
|
-
*
|
|
359
|
-
* `yaml`'s own stringifier rather than concatenation: a value containing `: `,
|
|
360
|
-
* `#`, quotes or a newline must be quoted correctly, which hand-built strings
|
|
361
|
-
* get wrong (`name: 某某:试点` produced invalid YAML in the reference tool).
|
|
362
|
-
*
|
|
363
|
-
* Empty plan/progress blocks are emitted as empty collections, not omitted: the
|
|
364
|
-
* ledger's parser tolerates absence, but a colleague reopening the file should
|
|
365
|
-
* see the shape they are expected to fill.
|
|
366
|
-
*
|
|
367
|
-
* **This is not the download format.** The form ships a change set (see
|
|
368
|
-
* {@link projectToChangeSet}); a complete file would have to carry the ledger's
|
|
369
|
-
* derived fields (`gate0.missing`, `priority`, scenario status), and those are
|
|
370
|
-
* owned by `tools/derive.mjs` — writing them here would either be wrong or be
|
|
371
|
-
* overwritten by CI. `projectToYaml` remains for tests and for a full-file
|
|
372
|
-
* preview.
|
|
373
|
-
*/
|
|
374
|
-
export function projectToYaml(project) {
|
|
375
|
-
const document = {
|
|
376
|
-
poc_id: project.pocId,
|
|
377
|
-
name: project.name,
|
|
378
|
-
org: {
|
|
379
|
-
system: project.system === '' ? null : project.system,
|
|
380
|
-
company: project.company === '' ? null : project.company,
|
|
381
|
-
department: project.department === '' ? null : project.department,
|
|
382
|
-
},
|
|
383
|
-
amount_wan: project.amountWan === '' ? null : Number(project.amountWan),
|
|
384
|
-
poc_type: project.pocType === '' ? null : project.pocType,
|
|
385
|
-
owner: project.owner === '' ? null : project.owner,
|
|
386
|
-
sales: project.sales === '' ? null : project.sales,
|
|
387
|
-
tech_owner: project.techOwner === '' ? null : project.techOwner,
|
|
388
|
-
exec_sponsor: project.execSponsor === '' ? null : project.execSponsor,
|
|
389
|
-
stage: project.stage,
|
|
390
|
-
status: project.status,
|
|
391
|
-
stage_since: project.stageSince === '' ? null : project.stageSince,
|
|
392
|
-
gate0: {
|
|
393
|
-
why_customer: project.gate0.why_customer === '' ? null : project.gate0.why_customer,
|
|
394
|
-
why_us: project.gate0.why_us === '' ? null : project.gate0.why_us,
|
|
395
|
-
decision_chain: project.gate0.decision_chain === '' ? null : project.gate0.decision_chain,
|
|
396
|
-
post_poc_decision: project.gate0.post_poc_decision === '' ? null : project.gate0.post_poc_decision,
|
|
397
|
-
competitor: project.gate0.competitor === '' ? null : project.gate0.competitor,
|
|
398
|
-
review: {
|
|
399
|
-
conclusion: project.gate0.conclusion === '' ? null : project.gate0.conclusion,
|
|
400
|
-
reviewer: project.gate0.reviewer === '' ? null : project.gate0.reviewer,
|
|
401
|
-
reviewed_at: project.gate0.reviewed_at === '' ? null : project.gate0.reviewed_at,
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
plan: {
|
|
405
|
-
customer_pain: project.plan.customer_pain === '' ? null : project.plan.customer_pain,
|
|
406
|
-
expected_recognition: project.plan.expected_recognition === '' ? null : project.plan.expected_recognition,
|
|
407
|
-
criteria: project.plan.criteria
|
|
408
|
-
.filter((criterion) => (criterion.name ?? '').trim() !== '')
|
|
409
|
-
.map((criterion) => ({
|
|
410
|
-
// Never renumber: a returned criterion keeps the id evidence cites.
|
|
411
|
-
id: (criterion.id ?? '').trim() === '' ? null : (criterion.id ?? '').trim(),
|
|
412
|
-
name: criterion.name.trim(),
|
|
413
|
-
metric: (criterion.metric ?? '').trim() === '' ? null : criterion.metric.trim(),
|
|
414
|
-
baseline: (criterion.baseline ?? '').trim() === '' ? null : criterion.baseline.trim(),
|
|
415
|
-
target: (criterion.target ?? '').trim() === '' ? null : criterion.target.trim(),
|
|
416
|
-
})),
|
|
417
|
-
scenarios: project.plan.scenarios
|
|
418
|
-
.filter((scenario) => (scenario.name ?? '').trim() !== '')
|
|
419
|
-
.map((scenario) => ({
|
|
420
|
-
id: (scenario.id ?? '').trim() === '' ? null : (scenario.id ?? '').trim(),
|
|
421
|
-
name: scenario.name.trim(),
|
|
422
|
-
goal: (scenario.goal ?? '').trim() === '' ? null : scenario.goal.trim(),
|
|
423
|
-
})),
|
|
424
|
-
our_edge: project.plan.our_edge === '' ? null : project.plan.our_edge,
|
|
425
|
-
timeline: {
|
|
426
|
-
start: project.plan.timeline_start === '' ? null : project.plan.timeline_start,
|
|
427
|
-
end: project.plan.timeline_end === '' ? null : project.plan.timeline_end,
|
|
428
|
-
},
|
|
429
|
-
risks: project.plan.risks
|
|
430
|
-
.filter((risk) => risk.name.trim() !== '')
|
|
431
|
-
.map((risk) => ({
|
|
432
|
-
name: risk.name.trim(),
|
|
433
|
-
level: risk.level === '' ? null : risk.level,
|
|
434
|
-
mitigation: risk.mitigation.trim() === '' ? null : risk.mitigation.trim(),
|
|
435
|
-
})),
|
|
436
|
-
gate1: { conclusion: project.plan.gate1_conclusion === '' ? null : project.plan.gate1_conclusion },
|
|
437
|
-
gate2: { ready: project.plan.gate2_ready === '' ? null : project.plan.gate2_ready },
|
|
438
|
-
},
|
|
439
|
-
progress: progressIsEmpty(project.progress) ? [] : [serializeProgress(project.progress)],
|
|
440
|
-
outcome: {
|
|
441
|
-
achievement: null,
|
|
442
|
-
customer_recognition: null,
|
|
443
|
-
our_proof: null,
|
|
444
|
-
remaining_risks: null,
|
|
445
|
-
conclusion: { proved: null, recognized: null, next_business: null },
|
|
446
|
-
business: { milestone: null, owner: null, deadline: null, status: null },
|
|
447
|
-
overall: null,
|
|
448
|
-
reviewed_at: null,
|
|
449
|
-
},
|
|
450
|
-
};
|
|
451
|
-
return YAML.stringify(document, { lineWidth: 0 });
|
|
452
|
-
}
|
|
453
|
-
/** `''` becomes `null`: the ledger's "absent" is null, never the string "". */
|
|
454
|
-
function orNull(value) {
|
|
455
|
-
return value === '' ? null : value;
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Which blocks of a change set a given intent may carry.
|
|
459
|
-
*
|
|
460
|
-
* ## Why this is a correctness rule, not tidiness
|
|
461
|
-
*
|
|
462
|
-
* The form pre-fills every field from the ledger, so a change set built from the
|
|
463
|
-
* whole project always carries values the colleague never looked at. Under
|
|
464
|
-
* `poc-submit`'s "skip null, apply the rest" merge, those pre-filled values are
|
|
465
|
-
* written back. That turns a read-only snapshot into an overwrite: if the ledger
|
|
466
|
-
* changed while the form sat in someone's WeChat, submitting it silently reverts
|
|
467
|
-
* the field to the day the form was generated.
|
|
468
|
-
*
|
|
469
|
-
* So the rule is: **emit only the blocks the person could actually edit.** A
|
|
470
|
-
* `progress` form sends its round and nothing else, and cannot clobber a plan it
|
|
471
|
-
* never displayed.
|
|
472
|
-
*
|
|
473
|
-
* `stage` and `status` are the exception: they are always emitted because they are
|
|
474
|
-
* the ledger's own routing keys, and a brand-new project has no file to inherit
|
|
475
|
-
* them from.
|
|
476
|
-
*/
|
|
477
|
-
const CHANGE_SCOPE = {
|
|
478
|
-
// `progress` is listed for `new` because the new-project form offers an
|
|
479
|
-
// OPTIONAL first round. Optional means "sent only if the colleague filled it",
|
|
480
|
-
// which `progressIsEmpty` already enforces; it is not a required field.
|
|
481
|
-
new: ['identity', 'gate0', 'progress'],
|
|
482
|
-
// `supplement` resolves per project against its stage, so the union is allowed
|
|
483
|
-
// here and narrowed by `resolveSections` at emit time.
|
|
484
|
-
supplement: ['identity', 'gate0', 'plan', 'gate12', 'progress', 'outcome'],
|
|
485
|
-
progress: ['progress'],
|
|
486
|
-
};
|
|
487
|
-
/**
|
|
488
|
-
* Build one project's change set from the form state.
|
|
489
|
-
*
|
|
490
|
-
* Blocks outside the intent's scope are emitted as `null` (or an empty list), which
|
|
491
|
-
* `poc-submit` treats as "not changed" and skips. A blank field inside a block that
|
|
492
|
-
* IS in scope means the same thing: the colleague did not touch it.
|
|
493
|
-
*
|
|
494
|
-
* @param project the form's own view of the project
|
|
495
|
-
* @param intent what the colleague was asked to do; defaults to `supplement`, the
|
|
496
|
-
* widest scope, so an older caller keeps its previous behaviour
|
|
497
|
-
* @param baseline the project's values when the form was generated. When given,
|
|
498
|
-
* a field equal to its seed is emitted as `null` — "I did not touch this".
|
|
499
|
-
*/
|
|
500
|
-
export function projectToChangeSet(project, intent = 'supplement', baseline) {
|
|
501
|
-
// A supplement form is narrowed to the project's own stage, exactly as the page
|
|
502
|
-
// was: asking for a G1 plan change must not also re-emit a G0 block the page
|
|
503
|
-
// rendered read-only.
|
|
504
|
-
const scope = intent === 'supplement'
|
|
505
|
-
? new Set(resolveSections(intent, project.stage).editable)
|
|
506
|
-
: new Set(CHANGE_SCOPE[intent]);
|
|
507
|
-
const inScope = (section) => scope.has(section);
|
|
508
|
-
/**
|
|
509
|
-
* A field's value, or `null` when it is still what the form was seeded with.
|
|
510
|
-
*
|
|
511
|
-
* ## Why this is the difference between working and silently losing data
|
|
512
|
-
*
|
|
513
|
-
* The page pre-fills every field from the ledger, and `poc-submit` merges with
|
|
514
|
-
* "skip null, apply the rest". Without this comparison, a colleague who changed
|
|
515
|
-
* ONE Gate 0 field re-sent the other four exactly as they were at export time —
|
|
516
|
-
* so anything another person changed while the form sat in WeChat was reverted.
|
|
517
|
-
* That is a data-loss bug wearing the costume of a normal merge.
|
|
518
|
-
*
|
|
519
|
-
* With it, the change set means what its name says: only the fields this person
|
|
520
|
-
* actually edited.
|
|
521
|
-
*/
|
|
522
|
-
const seed = (path) => {
|
|
523
|
-
if (baseline === undefined)
|
|
524
|
-
return '';
|
|
525
|
-
const raw = path(baseline);
|
|
526
|
-
return raw === undefined || raw === null ? '' : String(raw);
|
|
527
|
-
};
|
|
528
|
-
const changed = (section, value, seeded) => {
|
|
529
|
-
if (!inScope(section))
|
|
530
|
-
return null;
|
|
531
|
-
const trimmed = value.trim();
|
|
532
|
-
if (trimmed === '')
|
|
533
|
-
return null;
|
|
534
|
-
return trimmed === seeded.trim() ? null : trimmed;
|
|
535
|
-
};
|
|
536
|
-
const changedList = (section, value, seeded) => {
|
|
537
|
-
if (!inScope(section))
|
|
538
|
-
return null;
|
|
539
|
-
if (value.length === 0)
|
|
540
|
-
return null;
|
|
541
|
-
if (baseline !== undefined && JSON.stringify(value) === JSON.stringify(seeded))
|
|
542
|
-
return null;
|
|
543
|
-
return [...value];
|
|
544
|
-
};
|
|
545
|
-
const blank = {
|
|
546
|
-
schema_version: FORM_SCHEMA_VERSION,
|
|
547
|
-
poc_id: project.pocId.trim(),
|
|
548
|
-
name: '',
|
|
549
|
-
org: { system: null, company: null, department: null },
|
|
550
|
-
amount_wan: null,
|
|
551
|
-
poc_type: null,
|
|
552
|
-
owner: null,
|
|
553
|
-
sales: null,
|
|
554
|
-
tech_owner: null,
|
|
555
|
-
exec_sponsor: null,
|
|
556
|
-
// Always emitted: the ledger routes on these, and a new project has no file to
|
|
557
|
-
// inherit them from.
|
|
558
|
-
stage: project.stage,
|
|
559
|
-
status: project.status,
|
|
560
|
-
stage_since: null,
|
|
561
|
-
gate0: {
|
|
562
|
-
why_customer: null, why_us: null, decision_chain: null,
|
|
563
|
-
post_poc_decision: null, competitor: null,
|
|
564
|
-
review: { conclusion: null, reviewer: null, reviewed_at: null },
|
|
565
|
-
},
|
|
566
|
-
plan: {
|
|
567
|
-
customer_pain: null, expected_recognition: null, our_edge: null,
|
|
568
|
-
criteria: [], scenarios: [], risks: [],
|
|
569
|
-
timeline: { start: null, end: null },
|
|
570
|
-
gate1: { conclusion: null }, gate2: { ready: null },
|
|
571
|
-
},
|
|
572
|
-
outcome: {
|
|
573
|
-
achievement: null, customer_recognition: null, our_proof: null, remaining_risks: null,
|
|
574
|
-
conclusion: { proved: null, recognized: null, next_business: null },
|
|
575
|
-
business: { milestone: null, owner: null, deadline: null, status: null },
|
|
576
|
-
overall: null,
|
|
577
|
-
},
|
|
578
|
-
progress: [],
|
|
579
|
-
};
|
|
580
|
-
// Identity. `pocId` is the ledger's primary key and is never a change; it is
|
|
581
|
-
// always carried so the merge knows which project this is.
|
|
582
|
-
blank.name = changed('identity', project.name, seed((b) => b.name)) ?? '';
|
|
583
|
-
blank.org = {
|
|
584
|
-
system: changed('identity', project.system, seed((b) => b.system)),
|
|
585
|
-
company: changed('identity', project.company, seed((b) => b.company)),
|
|
586
|
-
department: changed('identity', project.department, seed((b) => b.department)),
|
|
587
|
-
};
|
|
588
|
-
const amount = project.amountWan.trim();
|
|
589
|
-
blank.amount_wan = inScope('identity') && amount !== '' && amount !== seed((b) => b.amountWan)
|
|
590
|
-
? Number(amount)
|
|
591
|
-
: null;
|
|
592
|
-
blank.poc_type = changed('identity', project.pocType, seed((b) => b.pocType));
|
|
593
|
-
blank.owner = changed('identity', project.owner, seed((b) => b.owner));
|
|
594
|
-
blank.sales = changed('identity', project.sales, seed((b) => b.sales));
|
|
595
|
-
blank.tech_owner = changed('identity', project.techOwner, seed((b) => b.techOwner));
|
|
596
|
-
blank.exec_sponsor = changed('identity', project.execSponsor, seed((b) => b.execSponsor));
|
|
597
|
-
blank.stage_since = changed('identity', project.stageSince, seed((b) => b.stageSince));
|
|
598
|
-
// Gate 0.
|
|
599
|
-
blank.gate0 = {
|
|
600
|
-
why_customer: changed('gate0', project.gate0.why_customer, seed((b) => b.gate0.why_customer)),
|
|
601
|
-
why_us: changed('gate0', project.gate0.why_us, seed((b) => b.gate0.why_us)),
|
|
602
|
-
decision_chain: changed('gate0', project.gate0.decision_chain, seed((b) => b.gate0.decision_chain)),
|
|
603
|
-
post_poc_decision: changed('gate0', project.gate0.post_poc_decision, seed((b) => b.gate0.post_poc_decision)),
|
|
604
|
-
competitor: changed('gate0', project.gate0.competitor, seed((b) => b.gate0.competitor)),
|
|
605
|
-
review: {
|
|
606
|
-
conclusion: changed('gate0', project.gate0.conclusion, seed((b) => b.gate0.conclusion)),
|
|
607
|
-
reviewer: changed('gate0', project.gate0.reviewer, seed((b) => b.gate0.reviewer)),
|
|
608
|
-
reviewed_at: changed('gate0', project.gate0.reviewed_at, seed((b) => b.gate0.reviewed_at)),
|
|
609
|
-
},
|
|
610
|
-
};
|
|
611
|
-
// Plan. Lists are compared as a whole: a list that matches its seed exactly is
|
|
612
|
-
// "untouched", and any edit re-sends the whole list because the merge replaces it.
|
|
613
|
-
const criteria = project.plan.criteria
|
|
614
|
-
.filter((item) => (item.name ?? '').trim() !== '')
|
|
615
|
-
.map((item) => ({
|
|
616
|
-
id: orNull((item.id ?? '').trim()),
|
|
617
|
-
name: item.name.trim(),
|
|
618
|
-
metric: orNull((item.metric ?? '').trim()),
|
|
619
|
-
baseline: orNull((item.baseline ?? '').trim()),
|
|
620
|
-
target: orNull((item.target ?? '').trim()),
|
|
621
|
-
}));
|
|
622
|
-
const scenarios = project.plan.scenarios
|
|
623
|
-
.filter((item) => (item.name ?? '').trim() !== '')
|
|
624
|
-
.map((item) => ({
|
|
625
|
-
id: orNull((item.id ?? '').trim()),
|
|
626
|
-
name: item.name.trim(),
|
|
627
|
-
goal: orNull((item.goal ?? '').trim()),
|
|
628
|
-
}));
|
|
629
|
-
const risks = project.plan.risks
|
|
630
|
-
.filter((item) => item.name.trim() !== '')
|
|
631
|
-
.map((item) => ({
|
|
632
|
-
name: item.name.trim(),
|
|
633
|
-
level: orNull(item.level.trim()),
|
|
634
|
-
mitigation: orNull(item.mitigation.trim()),
|
|
635
|
-
}));
|
|
636
|
-
// The seed lists are normalized through the SAME mapping as the emitted ones.
|
|
637
|
-
// Comparing raw form rows against normalized output made every list look
|
|
638
|
-
// changed ('' vs null), so an untouched plan was re-sent and could overwrite a
|
|
639
|
-
// concurrent edit — the exact failure this diff exists to prevent.
|
|
640
|
-
const seedCriteria = (baseline?.plan.criteria ?? [])
|
|
641
|
-
.filter((item) => (item.name ?? '').trim() !== '')
|
|
642
|
-
.map((item) => ({
|
|
643
|
-
id: orNull((item.id ?? '').trim()),
|
|
644
|
-
name: item.name.trim(),
|
|
645
|
-
metric: orNull((item.metric ?? '').trim()),
|
|
646
|
-
baseline: orNull((item.baseline ?? '').trim()),
|
|
647
|
-
target: orNull((item.target ?? '').trim()),
|
|
648
|
-
}));
|
|
649
|
-
const seedScenarios = (baseline?.plan.scenarios ?? [])
|
|
650
|
-
.filter((item) => (item.name ?? '').trim() !== '')
|
|
651
|
-
.map((item) => ({
|
|
652
|
-
id: orNull((item.id ?? '').trim()),
|
|
653
|
-
name: item.name.trim(),
|
|
654
|
-
goal: orNull((item.goal ?? '').trim()),
|
|
655
|
-
}));
|
|
656
|
-
const seedRisks = (baseline?.plan.risks ?? [])
|
|
657
|
-
.filter((item) => item.name.trim() !== '')
|
|
658
|
-
.map((item) => ({
|
|
659
|
-
name: item.name.trim(),
|
|
660
|
-
level: orNull(item.level.trim()),
|
|
661
|
-
mitigation: orNull(item.mitigation.trim()),
|
|
662
|
-
}));
|
|
663
|
-
blank.plan = {
|
|
664
|
-
customer_pain: changed('plan', project.plan.customer_pain, seed((b) => b.plan.customer_pain)),
|
|
665
|
-
expected_recognition: changed('plan', project.plan.expected_recognition, seed((b) => b.plan.expected_recognition)),
|
|
666
|
-
our_edge: changed('plan', project.plan.our_edge, seed((b) => b.plan.our_edge)),
|
|
667
|
-
criteria: changedList('plan', criteria, seedCriteria) ?? [],
|
|
668
|
-
scenarios: changedList('plan', scenarios, seedScenarios) ?? [],
|
|
669
|
-
risks: changedList('plan', risks, seedRisks) ?? [],
|
|
670
|
-
timeline: {
|
|
671
|
-
start: changed('plan', project.plan.timeline_start, seed((b) => b.plan.timeline_start)),
|
|
672
|
-
end: changed('plan', project.plan.timeline_end, seed((b) => b.plan.timeline_end)),
|
|
673
|
-
},
|
|
674
|
-
gate1: { conclusion: changed('gate12', project.plan.gate1_conclusion, seed((b) => b.plan.gate1_conclusion)) },
|
|
675
|
-
gate2: { ready: changed('gate12', project.plan.gate2_ready, seed((b) => b.plan.gate2_ready)) },
|
|
676
|
-
};
|
|
677
|
-
// Outcome: the G4 block.
|
|
678
|
-
blank.outcome = {
|
|
679
|
-
achievement: changed('outcome', project.outcome.achievement, seed((b) => b.outcome.achievement)),
|
|
680
|
-
customer_recognition: changed('outcome', project.outcome.customer_recognition, seed((b) => b.outcome.customer_recognition)),
|
|
681
|
-
our_proof: changed('outcome', project.outcome.our_proof, seed((b) => b.outcome.our_proof)),
|
|
682
|
-
remaining_risks: null,
|
|
683
|
-
conclusion: {
|
|
684
|
-
proved: changed('outcome', project.outcome.proved, seed((b) => b.outcome.proved)),
|
|
685
|
-
recognized: changed('outcome', project.outcome.recognized, seed((b) => b.outcome.recognized)),
|
|
686
|
-
next_business: changed('outcome', project.outcome.next_business, seed((b) => b.outcome.next_business)),
|
|
687
|
-
},
|
|
688
|
-
business: {
|
|
689
|
-
milestone: changed('outcome', project.outcome.milestone, seed((b) => b.outcome.milestone)),
|
|
690
|
-
owner: changed('outcome', project.outcome.businessOwner, seed((b) => b.outcome.businessOwner)),
|
|
691
|
-
deadline: changed('outcome', project.outcome.businessDeadline, seed((b) => b.outcome.businessDeadline)),
|
|
692
|
-
status: changed('outcome', project.outcome.businessStatus, seed((b) => b.outcome.businessStatus)),
|
|
693
|
-
},
|
|
694
|
-
overall: changed('outcome', project.outcome.overall, seed((b) => b.outcome.overall)),
|
|
695
|
-
};
|
|
696
|
-
// Append-only: this is the list of NEW rounds, never the existing history.
|
|
697
|
-
blank.progress = inScope('progress') && !progressIsEmpty(project.progress)
|
|
698
|
-
? [serializeProgress(project.progress)]
|
|
699
|
-
: [];
|
|
700
|
-
return blank;
|
|
701
|
-
}
|
|
702
|
-
/** Build the document a colleague sends back. */
|
|
703
|
-
export function buildChangeDocument(options) {
|
|
704
|
-
return {
|
|
705
|
-
schemaVersion: FORM_SCHEMA_VERSION,
|
|
706
|
-
generatedAt: (options.now ?? new Date()).toISOString(),
|
|
707
|
-
generatedBy: 'POC 信息收集表单 v3.1',
|
|
708
|
-
intent: options.intent,
|
|
709
|
-
changes: options.projects.map((project, index) => projectToChangeSet(project, options.intent, options.baseline?.[index])),
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
/** `true` when the form's progress entry carries no user content. */
|
|
713
|
-
function progressIsEmpty(entry) {
|
|
714
|
-
return (entry.date === '' &&
|
|
715
|
-
entry.type === '' &&
|
|
716
|
-
entry.goal === '' &&
|
|
717
|
-
entry.actual === '' &&
|
|
718
|
-
compact(entry.scenarioIds).length === 0 &&
|
|
719
|
-
compact(entry.criteriaIds).length === 0 &&
|
|
720
|
-
entry.evidence.every((item) => item.title.trim() === ''));
|
|
721
|
-
}
|
|
722
|
-
/** One progress entry in the ledger's own shape. */
|
|
723
|
-
function serializeProgress(entry) {
|
|
724
|
-
return {
|
|
725
|
-
seq: entry.seq,
|
|
726
|
-
date: entry.date,
|
|
727
|
-
type: entry.type === '' ? null : entry.type,
|
|
728
|
-
// `change` is mandatory in v3.1: a round that does not say what moved is the
|
|
729
|
-
// single most common way a timeline decays into "communicated with customer".
|
|
730
|
-
change: entry.change === '' ? null : entry.change,
|
|
731
|
-
goal: entry.goal === '' ? null : entry.goal,
|
|
732
|
-
scenario_ids: compact(entry.scenarioIds),
|
|
733
|
-
criteria_ids: compact(entry.criteriaIds),
|
|
734
|
-
actual: entry.actual === '' ? null : entry.actual,
|
|
735
|
-
completion: entry.completion === '' ? null : entry.completion,
|
|
736
|
-
evidence: entry.evidence
|
|
737
|
-
.filter((item) => item.title.trim() !== '')
|
|
738
|
-
.map((item) => ({
|
|
739
|
-
title: item.title.trim(),
|
|
740
|
-
link: item.link.trim() === '' ? null : item.link.trim(),
|
|
741
|
-
type: item.type === '' ? null : item.type,
|
|
742
|
-
})),
|
|
743
|
-
customer: {
|
|
744
|
-
synced_with: entry.customer.synced_with === '' ? null : entry.customer.synced_with,
|
|
745
|
-
feedback: entry.customer.feedback === '' ? null : entry.customer.feedback,
|
|
746
|
-
recognition: entry.customer.recognition === '' ? null : entry.customer.recognition,
|
|
747
|
-
},
|
|
748
|
-
gate3_1: entry.gate3_1 === '' ? null : entry.gate3_1,
|
|
749
|
-
gate3_2: entry.gate3_2 === '' ? null : entry.gate3_2,
|
|
750
|
-
next: {
|
|
751
|
-
goal: entry.next.goal === '' ? null : entry.next.goal,
|
|
752
|
-
owner: entry.next.owner === '' ? null : entry.next.owner,
|
|
753
|
-
deadline: entry.next.deadline === '' ? null : entry.next.deadline,
|
|
754
|
-
},
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
/** Escape a value for embedding inside a `<script>` block. */
|
|
758
|
-
function scriptSafe(json) {
|
|
759
|
-
return json
|
|
760
|
-
.replace(/</g, '\\u003c')
|
|
761
|
-
.replace(/>/g, '\\u003e')
|
|
762
|
-
.replace(/\u2028/g, '\\u2028')
|
|
763
|
-
.replace(/\u2029/g, '\\u2029');
|
|
764
|
-
}
|
|
765
|
-
/** Escape text for HTML content. */
|
|
766
|
-
function escapeHtml(value) {
|
|
767
|
-
return value
|
|
768
|
-
.replace(/&/g, '&')
|
|
769
|
-
.replace(/</g, '<')
|
|
770
|
-
.replace(/>/g, '>')
|
|
771
|
-
.replace(/"/g, '"');
|
|
772
|
-
}
|
|
773
|
-
/** The enums, mirrored from `schemas/enums.yaml`. */
|
|
774
|
-
const ENUMS = {
|
|
775
|
-
pocType: ['SDL', 'ACG', 'AI安全', '保护AI', '虚拟化', '大体量项目'],
|
|
776
|
-
stage: ['G0-立项', 'G1-方案设计', 'G2-方案验证', 'G3-结果验证', 'G4-结果转化', 'closed'],
|
|
777
|
-
status: ['未开始', '进行中', '暂停', '已关闭', '已取消'],
|
|
778
|
-
g0Conclusion: ['通过', '未通过-退出', '未通过-降级', '待评审'],
|
|
779
|
-
g1Conclusion: ['通过', '补充后进入', '未通过'],
|
|
780
|
-
g2Ready: ['Ready', '有风险', '未Ready'],
|
|
781
|
-
recognition: ['认可', '部分认可', '未认可', '待确认'],
|
|
782
|
-
progressType: ['内部Review', '客户阶段同步', 'Checkpoint'],
|
|
783
|
-
// v3.1: mandatory on every progress entry. "无实质进展" is an allowed value:
|
|
784
|
-
// saying "nothing moved" beats writing a sentence that hides it.
|
|
785
|
-
progressChange: ['阶段推进', '场景新增', '目标调整', '证据补充', '风险出现', '风险解除', '无实质进展'],
|
|
786
|
-
completion: ['0%', '25%', '50%', '75%', '100%'],
|
|
787
|
-
riskLevel: ['high', 'medium', 'low'],
|
|
788
|
-
gate3_1: ['可证明', '待补证据'],
|
|
789
|
-
gate3_2: ['已确认', '待确认'],
|
|
790
|
-
evidenceType: ['文档', '截图', '数据', '邮件', '链接'],
|
|
791
|
-
system: ['人保体系', '国寿体系'],
|
|
792
|
-
// G4 only: the outcome block is the one thing no earlier stage asks for.
|
|
793
|
-
achievement: ['达成', '部分达成', '未达成'],
|
|
794
|
-
businessStatus: ['已进入下一里程碑', '待推进', '补救中', '无后续动作'],
|
|
795
|
-
};
|
|
796
|
-
/**
|
|
797
|
-
* The schema generation this form emits.
|
|
798
|
-
*
|
|
799
|
-
* Stamped into every generated page so a returned form can be checked against
|
|
800
|
-
* the schema that will read it. There is deliberately **no older-shape
|
|
801
|
-
* fallback**: the ledger declares one shape version and its validator rejects
|
|
802
|
-
* anything else outright (`E-VERSION`). A tolerant reader here would only move
|
|
803
|
-
* that failure later — to a point where the colleague already believes their
|
|
804
|
-
* work was recorded.
|
|
805
|
-
*/
|
|
806
|
-
export const FORM_SCHEMA_VERSION = '3.1';
|
|
807
|
-
/**
|
|
808
|
-
* The stamp a pre-v3.1 form carries.
|
|
809
|
-
*
|
|
810
|
-
* A named constant only so the refusal message can name it. This is not a
|
|
811
|
-
* supported shape: nothing parses it, nothing converts it, and importing one is
|
|
812
|
-
* refused rather than half-applied.
|
|
813
|
-
*/
|
|
814
|
-
export const LEGACY_FORM_SCHEMA_VERSION = '3.0';
|
|
815
|
-
/** The G0 prompts: the label and the reason each field exists. */
|
|
816
|
-
const G0_PROMPTS = [
|
|
817
|
-
{ key: 'why_customer', label: '客户为什么要测', hint: '客户自己的痛点与压力,不是我们的卖点。' },
|
|
818
|
-
{ key: 'why_us', label: '我们为什么测', hint: '对我们的价值:突破点、可复制的样板、后续生意。' },
|
|
819
|
-
{ key: 'decision_chain', label: '项目流程 / 决策链', hint: '谁提需求、谁评审、谁签字、按什么流程走。' },
|
|
820
|
-
{ key: 'post_poc_decision', label: '测完之后客户会做什么决定', hint: '采购、扩容、试点转正,还是就此结束。' },
|
|
821
|
-
];
|
|
822
|
-
/**
|
|
823
|
-
* Generate the complete HTML form.
|
|
824
|
-
*
|
|
825
|
-
* The returned string is the whole document: no external stylesheet, script,
|
|
826
|
-
* font or image reference.
|
|
827
|
-
*/
|
|
828
|
-
export function buildFormHtml(options) {
|
|
829
|
-
const now = options.now ?? new Date();
|
|
830
|
-
const projects = options.mode === 'blank' ? [blankProject()] : options.projects;
|
|
831
|
-
const intent = options.intent ?? (options.mode === 'blank' ? 'new' : 'supplement');
|
|
832
|
-
const payload = {
|
|
833
|
-
mode: options.mode,
|
|
834
|
-
intent,
|
|
835
|
-
schemaVersion: FORM_SCHEMA_VERSION,
|
|
836
|
-
generatedAt: now.toISOString(),
|
|
837
|
-
today: now.toISOString().slice(0, 10),
|
|
838
|
-
projects,
|
|
839
|
-
// The values as generated, index-aligned with `projects`. The page diffs
|
|
840
|
-
// against these so it only sends what the colleague actually changed — see
|
|
841
|
-
// projectToChangeSet. Without it, an untouched pre-filled field would be sent
|
|
842
|
-
// back and would revert any edit made while the form sat in WeChat.
|
|
843
|
-
baseline: projects.map((project) => JSON.parse(JSON.stringify(project))),
|
|
844
|
-
// Each project's stage decides which sections are the subject, so the
|
|
845
|
-
// resolution is per project rather than per document.
|
|
846
|
-
sections: projects.map((project) => resolveSections(intent, project.stage)),
|
|
847
|
-
draftKey: draftKeyFor(options.mode, projects.map((project) => project.pocId).filter((id) => id !== '')),
|
|
848
|
-
enums: ENUMS,
|
|
849
|
-
g0Fields: G0_PROMPTS,
|
|
850
|
-
returnCss: RETURN_CSS,
|
|
851
|
-
};
|
|
852
|
-
const data = scriptSafe(JSON.stringify(payload));
|
|
853
|
-
const title = intent === 'new'
|
|
854
|
-
? 'POC 新建项目表单 v3'
|
|
855
|
-
: intent === 'progress'
|
|
856
|
-
? `POC 进展记录表单 v3(${projects.length} 个项目)`
|
|
857
|
-
: `POC 信息补充表单 v3(${projects.length} 个项目)`;
|
|
858
|
-
return `<!DOCTYPE html>
|
|
859
|
-
<html lang="zh-CN">
|
|
860
|
-
<head>
|
|
861
|
-
<meta charset="UTF-8">
|
|
862
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
863
|
-
<title>${escapeHtml(title)}</title>
|
|
864
|
-
<style>${FORM_CSS}</style>
|
|
865
|
-
</head>
|
|
866
|
-
<body>
|
|
867
|
-
<div class="shell">
|
|
868
|
-
<div class="notice" id="restoreNotice" hidden>已恢复上次未提交的草稿。</div>
|
|
869
|
-
<div class="notice notice-warn" id="draftNotice" hidden></div>
|
|
870
|
-
<!-- The banner is rendered by the script from DATA, so it carries the project's
|
|
871
|
-
real identity instead of a static page title that says nothing. -->
|
|
872
|
-
<main id="formBody"></main>
|
|
873
|
-
<footer class="footer">
|
|
874
|
-
<div class="footer-info" id="footerInfo">正在初始化…</div>
|
|
875
|
-
<div class="footer-actions">
|
|
876
|
-
<button type="button" class="btn" id="previewBtn">预览变更集</button>
|
|
877
|
-
<button type="button" class="btn" id="downloadBtn">下载变更集 (.json)</button>
|
|
878
|
-
<button type="button" class="btn btn-primary" id="returnBtn">生成回传文件 (.html)</button>
|
|
879
|
-
</div>
|
|
880
|
-
</footer>
|
|
881
|
-
</div>
|
|
882
|
-
<pre class="yaml-preview" id="yamlPreview" hidden></pre>
|
|
883
|
-
<div class="toast" id="toast" hidden></div>
|
|
884
|
-
<script>
|
|
885
|
-
(function () {
|
|
886
|
-
'use strict';
|
|
887
|
-
var DATA = ${data};
|
|
888
|
-
${FORM_SCRIPT}
|
|
889
|
-
})();
|
|
890
|
-
</script>
|
|
891
|
-
</body>
|
|
892
|
-
</html>
|
|
893
|
-
`;
|
|
894
|
-
}
|
|
895
|
-
/** A file name for the generated form. */
|
|
896
|
-
export function formFileName(options) {
|
|
897
|
-
const now = options.now ?? new Date();
|
|
898
|
-
const stamp = now.toISOString().slice(0, 10).replace(/-/g, '');
|
|
899
|
-
if (options.mode === 'blank')
|
|
900
|
-
return `poc-form-v3-new-${stamp}.html`;
|
|
901
|
-
if (options.pocIds.length === 1)
|
|
902
|
-
return `poc-form-v3-${options.pocIds[0]}-${stamp}.html`;
|
|
903
|
-
return `poc-forms-v3-${options.pocIds.length}-${stamp}.html`;
|
|
904
|
-
}
|
|
905
|
-
/** The file name a colleague should save one project's YAML under. */
|
|
906
|
-
export function yamlFileName(project, now = new Date()) {
|
|
907
|
-
const id = project.pocId.trim() === '' ? 'new' : project.pocId.trim();
|
|
908
|
-
const stamp = now.toISOString().slice(0, 10).replace(/-/g, '');
|
|
909
|
-
return `${id}-${stamp}.yaml`;
|
|
910
|
-
}
|
|
911
|
-
/** Re-export the YAML library's parse for the round-trip test. */
|
|
912
|
-
export { YAML };
|
|
913
|
-
/**
|
|
914
|
-
* Check a parsed form payload against {@link FORM_SCHEMA_VERSION}.
|
|
915
|
-
*
|
|
916
|
-
* Accepts the raw parsed object rather than a typed payload, because the whole
|
|
917
|
-
* point is to inspect a document whose shape may be from an older generation.
|
|
918
|
-
*/
|
|
919
|
-
export function checkFormCompatibility(payload) {
|
|
920
|
-
if (typeof payload !== 'object' || payload === null) {
|
|
921
|
-
return {
|
|
922
|
-
compatible: false,
|
|
923
|
-
declared: '',
|
|
924
|
-
reason: '这个文件不是本表单导出的格式,无法导入。',
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
const record = payload;
|
|
928
|
-
const declared = typeof record.schemaVersion === 'string' ? record.schemaVersion.trim() : '';
|
|
929
|
-
if (declared === FORM_SCHEMA_VERSION) {
|
|
930
|
-
return { compatible: true, declared, reason: '' };
|
|
931
|
-
}
|
|
932
|
-
if (declared === LEGACY_FORM_SCHEMA_VERSION || declared === '') {
|
|
933
|
-
return {
|
|
934
|
-
compatible: false,
|
|
935
|
-
declared: declared === '' ? LEGACY_FORM_SCHEMA_VERSION : declared,
|
|
936
|
-
reason: `这个表单是 v${LEGACY_FORM_SCHEMA_VERSION} 或更早版本导出的,台账只接受 v${FORM_SCHEMA_VERSION}。` +
|
|
937
|
-
'旧表单的场景是字符串、指标没有 id,而证据按 id 挂靠,导入后会丢失全部场景与指标引用。' +
|
|
938
|
-
'台账不做旧结构兼容,请重新导出一份 v' + FORM_SCHEMA_VERSION + ' 表单再填。',
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
return {
|
|
942
|
-
compatible: false,
|
|
943
|
-
declared,
|
|
944
|
-
reason: `这个表单声明的版本是 v${declared},当前台账读取的是 v${FORM_SCHEMA_VERSION},无法确认字段含义一致,已拒绝导入。`,
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
/** The element id the returned page carries its change set in. */
|
|
948
|
-
export const RETURN_DATA_ID = 'poc-return-data';
|
|
949
|
-
/**
|
|
950
|
-
* Read a returned form — either the `.html` this generator emits or a `.json`
|
|
951
|
-
* change set — back into a change document.
|
|
952
|
-
*
|
|
953
|
-
* ## Why both formats, and why HTML is the default
|
|
954
|
-
*
|
|
955
|
-
* The documented workflow is "colleague fills it in and sends the HTML back on
|
|
956
|
-
* WeChat". That only works if the returned HTML actually carries the answers, so
|
|
957
|
-
* {@link buildFormHtml}'s page writes a `RETURN_DATA_ID` script block holding the
|
|
958
|
-
* exact change set. The same page is also readable by a human: it renders the
|
|
959
|
-
* answers as formatted HTML, so the person who receives it can see what was
|
|
960
|
-
* submitted before handing it to DSH.
|
|
961
|
-
*
|
|
962
|
-
* The `.json` path is kept because it is stricter and smaller, and because forms
|
|
963
|
-
* already in circulation emit it.
|
|
964
|
-
*
|
|
965
|
-
* ## Safety
|
|
966
|
-
*
|
|
967
|
-
* The HTML is never executed and never given to a DOM parser: the block is found
|
|
968
|
-
* with a string search and the slice is handed to `JSON.parse`. Nothing in the
|
|
969
|
-
* returned file can run.
|
|
970
|
-
*/
|
|
971
|
-
export function readReturnDocument(input) {
|
|
972
|
-
const raw = input.trim();
|
|
973
|
-
if (raw === '')
|
|
974
|
-
return { document: null, reason: '文件是空的。' };
|
|
975
|
-
// A JSON change set: the common case for a `.json` return.
|
|
976
|
-
if (raw.startsWith('{')) {
|
|
977
|
-
let parsed;
|
|
978
|
-
try {
|
|
979
|
-
parsed = JSON.parse(raw);
|
|
980
|
-
}
|
|
981
|
-
catch {
|
|
982
|
-
return { document: null, reason: '这个 .json 文件解析失败,可能传输过程中被截断或改坏了。' };
|
|
983
|
-
}
|
|
984
|
-
return acceptDocument(parsed);
|
|
985
|
-
}
|
|
986
|
-
// A returned HTML page: find the data block by its id and parse only that.
|
|
987
|
-
//
|
|
988
|
-
// The marker is searched for exhaustively rather than once, because the FORM
|
|
989
|
-
// page also contains the literal marker inside its own generator source (the
|
|
990
|
-
// code that writes the return page). A single `indexOf` finds that copy first,
|
|
991
|
-
// and a blank form then reports "the data block is corrupt" instead of the
|
|
992
|
-
// truth: this form was never filled in. So every occurrence is tried and the
|
|
993
|
-
// first one that parses as a change document wins.
|
|
994
|
-
const marker = `id="${RETURN_DATA_ID}"`;
|
|
995
|
-
let at = raw.indexOf(marker);
|
|
996
|
-
while (at >= 0) {
|
|
997
|
-
const open = raw.indexOf('>', at);
|
|
998
|
-
const close = open < 0 ? -1 : raw.indexOf('</script>', open);
|
|
999
|
-
if (open >= 0 && close >= 0) {
|
|
1000
|
-
const body = raw.slice(open + 1, close).trim();
|
|
1001
|
-
let parsed;
|
|
1002
|
-
try {
|
|
1003
|
-
parsed = JSON.parse(body);
|
|
1004
|
-
}
|
|
1005
|
-
catch {
|
|
1006
|
-
// Not the real block (a source-code copy, or a truncated file). Keep
|
|
1007
|
-
// looking: a later occurrence may still be intact.
|
|
1008
|
-
parsed = undefined;
|
|
1009
|
-
}
|
|
1010
|
-
if (parsed !== undefined) {
|
|
1011
|
-
const accepted = acceptDocument(parsed);
|
|
1012
|
-
// Only a successfully accepted document ends the search; a marker copy
|
|
1013
|
-
// that parses to some other JSON is skipped.
|
|
1014
|
-
if (accepted.document !== null)
|
|
1015
|
-
return accepted;
|
|
1016
|
-
// A real-looking block that fails the schema gate is the answer: stop and
|
|
1017
|
-
// report it rather than silently falling through to "not a return file".
|
|
1018
|
-
if (Array.isArray(parsed.changes))
|
|
1019
|
-
return accepted;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
at = raw.indexOf(marker, at + marker.length);
|
|
1023
|
-
}
|
|
1024
|
-
return {
|
|
1025
|
-
document: null,
|
|
1026
|
-
reason: '这个 HTML 里没有可读的回传数据。它可能是**原始空白表单**——组员要填完后点' +
|
|
1027
|
-
'【生成回传文件 (.html)】,发回的是新生成的那个文件,而不是最初收到的表单。',
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
/** Validate a parsed return against the schema gate, then hand it back. */
|
|
1031
|
-
function acceptDocument(parsed) {
|
|
1032
|
-
if (typeof parsed !== 'object' || parsed === null) {
|
|
1033
|
-
return { document: null, reason: '这个文件不是变更集格式。' };
|
|
1034
|
-
}
|
|
1035
|
-
const record = parsed;
|
|
1036
|
-
// A change document carries `changes`; a raw form payload carries `projects`.
|
|
1037
|
-
// The latter is the BLANK form, and reading it as a submission would silently
|
|
1038
|
-
// import an empty round.
|
|
1039
|
-
if (!Array.isArray(record.changes)) {
|
|
1040
|
-
if (Array.isArray(record.projects)) {
|
|
1041
|
-
return {
|
|
1042
|
-
document: null,
|
|
1043
|
-
reason: '这是**尚未填写/未生成回传文件**的原始表单,里面没有组员填的内容。' +
|
|
1044
|
-
'请让组员填完后点【生成回传文件 (.html)】或【下载变更集 (.json)】,把那个文件发回。',
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
return { document: null, reason: '这个文件里没有 changes 数组,不是表单变更集。' };
|
|
1048
|
-
}
|
|
1049
|
-
const gate = checkFormCompatibility(record);
|
|
1050
|
-
if (!gate.compatible)
|
|
1051
|
-
return { document: null, reason: gate.reason };
|
|
1052
|
-
return { document: parsed, reason: '' };
|
|
1053
|
-
}
|
|
1054
|
-
/** Styles: one inline sheet, the console's own design tokens. */
|
|
1055
|
-
const FORM_CSS = `
|
|
1056
|
-
/* ===========================================================================
|
|
1057
|
-
* The form mirrors the detail page, not a generic settings screen.
|
|
1058
|
-
*
|
|
1059
|
-
* A colleague filling this in is answering the same questions the detail page
|
|
1060
|
-
* asks: what does Gate 0 say, what are the criteria and scenarios, what happened
|
|
1061
|
-
* this round. So the layout follows the detail page's own contract — a banner,
|
|
1062
|
-
* then a fixed two-column body (commitments left, record right), then a
|
|
1063
|
-
* full-width closing block — instead of one long stack of generic cards.
|
|
1064
|
-
*
|
|
1065
|
-
* The tokens are the dashboard's: same palette, same 8px rhythm, same type
|
|
1066
|
-
* scale. Nothing here invents a new visual language, because the form is the
|
|
1067
|
-
* same product seen from the other side.
|
|
1068
|
-
* ======================================================================== */
|
|
1069
|
-
:root{
|
|
1070
|
-
--primary:#2864E8;--primary-soft:rgba(40,100,232,.09);
|
|
1071
|
-
--text:#192638;--text-2:#4A5A70;--text-3:#7A8AA0;
|
|
1072
|
-
--bg:#F5F7FB;--surface:#fff;--inset:#F7F9FC;
|
|
1073
|
-
--border:#E6EBF2;--green:#218568;--green-soft:rgba(33,133,104,.10);
|
|
1074
|
-
--amber:#B77919;--amber-soft:rgba(183,121,25,.11);
|
|
1075
|
-
--red:#C0392B;--red-soft:rgba(192,57,43,.10);
|
|
1076
|
-
--slate:#5A6A80;--slate-soft:rgba(90,106,128,.10);
|
|
1077
|
-
--shadow-1:0 1px 2px rgba(20,32,52,.05);
|
|
1078
|
-
--shadow-2:0 2px 6px rgba(20,32,52,.07),0 1px 2px rgba(20,32,52,.04);
|
|
1079
|
-
--mono:ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
1080
|
-
}
|
|
1081
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
1082
|
-
body{
|
|
1083
|
-
font-family:'Avenir Next','PingFang SC','Microsoft YaHei',system-ui,sans-serif;
|
|
1084
|
-
background:var(--bg);color:var(--text);font-size:13px;line-height:20px;
|
|
1085
|
-
-webkit-font-smoothing:antialiased;padding:20px 28px 96px;
|
|
1086
|
-
}
|
|
1087
|
-
.shell{max-width:1200px;margin:0 auto;display:flex;flex-direction:column;gap:16px}
|
|
1088
|
-
|
|
1089
|
-
/* ---------- banner: identity + progress, the detail page's header ---------- */
|
|
1090
|
-
.banner{
|
|
1091
|
-
display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px 18px;
|
|
1092
|
-
padding:16px 20px;background:var(--surface);border:1px solid var(--border);
|
|
1093
|
-
border-radius:10px;position:sticky;top:0;z-index:100;box-shadow:var(--shadow-1);
|
|
1094
|
-
}
|
|
1095
|
-
.banner-main{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
1096
|
-
.banner-kicker{font-size:10px;font-weight:650;letter-spacing:.05em;text-transform:uppercase;color:var(--primary)}
|
|
1097
|
-
.banner-title{margin:0;font-size:20px;line-height:28px;font-weight:700;letter-spacing:-.01em;overflow-wrap:anywhere}
|
|
1098
|
-
.banner-meta{display:flex;flex-wrap:wrap;align-items:baseline;gap:10px;font-size:10.5px;color:var(--text-3)}
|
|
1099
|
-
.banner-id{font-family:var(--mono);font-size:10px}
|
|
1100
|
-
.banner-side{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
|
|
1101
|
-
.banner-pills{display:flex;flex-wrap:wrap;gap:5px;justify-content:flex-end}
|
|
1102
|
-
.banner-actions{display:flex;align-items:center;gap:8px}
|
|
1103
|
-
.save-status{font-size:10.5px;color:var(--green);white-space:nowrap}
|
|
1104
|
-
.banner-nav{
|
|
1105
|
-
grid-column:1/-1;display:flex;align-items:center;gap:10px;
|
|
1106
|
-
padding-top:10px;border-top:1px solid var(--border);
|
|
1107
|
-
}
|
|
1108
|
-
.banner-step{margin:0 auto;font-size:10px;color:var(--text-3);font-variant-numeric:tabular-nums}
|
|
1109
|
-
/* On a phone the two-column banner squeezed the title into one word per line.
|
|
1110
|
-
* Stack it: title and pills full width, actions on their own row. */
|
|
1111
|
-
@media(max-width:720px){
|
|
1112
|
-
.banner{grid-template-columns:minmax(0,1fr);gap:10px}
|
|
1113
|
-
.banner-side{align-items:flex-start}
|
|
1114
|
-
.banner-pills{justify-content:flex-start}
|
|
1115
|
-
.banner-actions{width:100%;justify-content:space-between}
|
|
1116
|
-
.banner-title{font-size:18px;line-height:25px}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
/* ---------- the fixed two-column contract, same ratio as the detail page --- */
|
|
1120
|
-
.columns{display:grid;grid-template-columns:minmax(0,1.72fr) minmax(0,1fr);gap:18px;align-items:start}
|
|
1121
|
-
@media(max-width:1080px){.columns{grid-template-columns:minmax(0,1fr)}}
|
|
1122
|
-
.col{display:flex;flex-direction:column;gap:18px;min-width:0}
|
|
1123
|
-
|
|
1124
|
-
/* ---------- section: one block with a heading and a rule ---------- */
|
|
1125
|
-
.sec{display:flex;flex-direction:column;gap:10px;min-width:0}
|
|
1126
|
-
.sec-head{display:flex;align-items:baseline;gap:9px;padding-bottom:7px;border-bottom:1px solid var(--border)}
|
|
1127
|
-
.sec-title{margin:0;font-size:13.5px;line-height:20px;font-weight:650;letter-spacing:-.005em}
|
|
1128
|
-
.sec-kicker{margin-left:auto;font-size:10.5px;color:var(--text-3);font-variant-numeric:tabular-nums}
|
|
1129
|
-
.sec-hint{margin:0;font-size:11px;line-height:17px;color:var(--text-2)}
|
|
1130
|
-
|
|
1131
|
-
/* ---------- Gate 0 as the same 2x3 card grid the detail page uses ---------- */
|
|
1132
|
-
.g0-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
|
|
1133
|
-
@media(max-width:720px){.g0-grid{grid-template-columns:minmax(0,1fr)}}
|
|
1134
|
-
.g0-card{
|
|
1135
|
-
display:flex;flex-direction:column;gap:5px;padding:10px 12px;
|
|
1136
|
-
border-radius:8px;background:var(--surface);border:1px solid var(--border);
|
|
1137
|
-
}
|
|
1138
|
-
.g0-card[data-present="false"]{background:var(--inset);border-style:dashed}
|
|
1139
|
-
.g0-card-head{display:flex;align-items:baseline;gap:8px}
|
|
1140
|
-
.g0-card-label{font-size:11px;line-height:16px;font-weight:650}
|
|
1141
|
-
.g0-card-label .req{color:var(--red);margin-left:2px}
|
|
1142
|
-
.g0-card-missing{
|
|
1143
|
-
margin-left:auto;font-size:9px;line-height:13px;font-weight:650;white-space:nowrap;
|
|
1144
|
-
color:var(--amber);background:var(--amber-soft);padding:1px 5px;border-radius:4px;
|
|
1145
|
-
}
|
|
1146
|
-
.g0-card .textarea{min-height:54px;font-size:11px;line-height:16px;border-color:transparent;background:transparent;padding:2px 0}
|
|
1147
|
-
.g0-card .textarea:hover{border-color:var(--border);background:var(--surface);padding:6px 8px}
|
|
1148
|
-
.g0-card .textarea:focus{border-color:var(--primary);background:var(--surface);padding:6px 8px}
|
|
1149
|
-
.g0-help{font-size:10px;line-height:14px;color:var(--text-3)}
|
|
1150
|
-
|
|
1151
|
-
/* ---------- list rows: criteria and scenarios as cards, not bare inputs --- */
|
|
1152
|
-
.row-card{
|
|
1153
|
-
display:flex;flex-direction:column;gap:6px;padding:9px 11px;
|
|
1154
|
-
border-radius:8px;background:var(--surface);border:1px solid var(--border);
|
|
1155
|
-
}
|
|
1156
|
-
.row-card-head{display:flex;align-items:center;gap:8px}
|
|
1157
|
-
/* An evidence row is [title][link][delete] on one line. On a phone that leaves
|
|
1158
|
-
* the title input about 60px wide, which truncates the placeholder mid-word, so
|
|
1159
|
-
* the row stacks and the delete button moves to its own shorter line. */
|
|
1160
|
-
@media(max-width:560px){
|
|
1161
|
-
.row-card-head{flex-wrap:wrap}
|
|
1162
|
-
.row-card-head>.input:first-child{flex:1 1 100%}
|
|
1163
|
-
.row-card-head>.input{flex:1 1 calc(100% - 64px)}
|
|
1164
|
-
.row-card-head>.btn-remove{margin-left:auto}
|
|
1165
|
-
}
|
|
1166
|
-
.row-card-id{
|
|
1167
|
-
flex:none;font-family:var(--mono);font-size:9px;line-height:13px;
|
|
1168
|
-
color:var(--text-3);background:var(--inset);border:1px solid var(--border);
|
|
1169
|
-
padding:1px 5px;border-radius:4px;
|
|
1170
|
-
}
|
|
1171
|
-
.row-card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
|
|
1172
|
-
@media(max-width:720px){.row-card-grid{grid-template-columns:minmax(0,1fr)}}
|
|
1173
|
-
.mini{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
1174
|
-
.mini-wide{margin-top:2px}
|
|
1175
|
-
.mini-label{font-size:9.5px;font-weight:600;letter-spacing:.03em;color:var(--text-3)}
|
|
1176
|
-
|
|
1177
|
-
/* ---------- fields ---------- */
|
|
1178
|
-
.field{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
1179
|
-
.field-label{font-size:11px;font-weight:650;color:var(--text)}
|
|
1180
|
-
.field-label .req{color:var(--red);margin-left:2px}
|
|
1181
|
-
.field-help{font-size:10px;line-height:15px;color:var(--text-3)}
|
|
1182
|
-
.input,.textarea,.select{
|
|
1183
|
-
width:100%;padding:6px 9px;border:1px solid var(--border);border-radius:6px;
|
|
1184
|
-
font-family:inherit;font-size:12px;line-height:18px;background:var(--surface);color:var(--text);
|
|
1185
|
-
}
|
|
1186
|
-
.input-flush{border-color:transparent;background:transparent;padding:2px 0;font-size:13px;font-weight:600}
|
|
1187
|
-
.input-flush:hover{border-color:var(--border);background:var(--surface);padding:5px 8px}
|
|
1188
|
-
.input-flush:focus{border-color:var(--primary);background:var(--surface);padding:5px 8px}
|
|
1189
|
-
.input:focus,.textarea:focus,.select:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-soft)}
|
|
1190
|
-
.textarea{min-height:60px;resize:vertical}
|
|
1191
|
-
.grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}
|
|
1192
|
-
@media(max-width:720px){.grid-2{grid-template-columns:minmax(0,1fr)}}
|
|
1193
|
-
/* Three-up row for the round's three compulsory facts: date, type, what moved.
|
|
1194
|
-
* They belong on one line so the progress receipt reads as one screen. */
|
|
1195
|
-
.grid-3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px 14px}
|
|
1196
|
-
@media(max-width:900px){.grid-3{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
1197
|
-
@media(max-width:560px){.grid-3{grid-template-columns:minmax(0,1fr)}}
|
|
1198
|
-
/* An optional block: collapsed by default, visually lighter than a subject
|
|
1199
|
-
* section, so it cannot be mistaken for something that must be filled. */
|
|
1200
|
-
.optional-block{margin-top:14px}
|
|
1201
|
-
.optional-block>summary{font-weight:650;color:var(--text-2)}
|
|
1202
|
-
.extras{margin-top:12px}
|
|
1203
|
-
.extras>summary{font-size:10.5px}
|
|
1204
|
-
.extras[open]>summary{margin-bottom:8px}
|
|
1205
|
-
.field.has-error .input,.field.has-error .textarea,.field.has-error .select{border-color:var(--red)}
|
|
1206
|
-
.field-error{color:var(--red);font-size:10px;display:none}
|
|
1207
|
-
.field.has-error .field-error{display:block}
|
|
1208
|
-
|
|
1209
|
-
/* ---------- locked fields: shown so the ledger's state is visible, but not
|
|
1210
|
-
* editable. Muted rather than hidden, because "what does the ledger already
|
|
1211
|
-
* say" is exactly what a colleague needs before answering. ------------------ */
|
|
1212
|
-
.input.is-locked,.textarea.is-locked,.select.is-locked{
|
|
1213
|
-
background:var(--inset);color:var(--text-2);border-color:var(--border);
|
|
1214
|
-
cursor:not-allowed;opacity:1;
|
|
1215
|
-
}
|
|
1216
|
-
.field-locked{color:var(--text-3);font-style:italic}
|
|
1217
|
-
|
|
1218
|
-
/* ---------- id pickers: which scenario / criterion this round touched ------ */
|
|
1219
|
-
.pick-list{display:flex;flex-wrap:wrap;gap:6px}
|
|
1220
|
-
.pick{
|
|
1221
|
-
display:flex;align-items:center;gap:6px;padding:5px 9px;border-radius:7px;
|
|
1222
|
-
border:1px solid var(--border);background:var(--surface);cursor:pointer;font-size:11px;
|
|
1223
|
-
}
|
|
1224
|
-
.pick:hover{border-color:var(--primary)}
|
|
1225
|
-
.pick:has(input:checked){background:var(--primary-soft);border-color:var(--primary)}
|
|
1226
|
-
.pick input{accent-color:var(--primary);margin:0}
|
|
1227
|
-
.pick-id{font-family:var(--mono);font-size:9px;color:var(--text-3)}
|
|
1228
|
-
.pick-empty{
|
|
1229
|
-
margin-top:2px;padding:7px 11px;border:1px dashed var(--border);border-radius:7px;
|
|
1230
|
-
font-size:11px;color:var(--text-3);background:var(--inset);
|
|
1231
|
-
}
|
|
1232
|
-
.pick-name{overflow-wrap:anywhere}
|
|
1233
|
-
|
|
1234
|
-
/* ---------- project snapshot: the orientation strip under the banner ------- */
|
|
1235
|
-
.snapshot{
|
|
1236
|
-
display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;
|
|
1237
|
-
background:var(--surface);border:1px solid var(--border);border-radius:10px;
|
|
1238
|
-
overflow:hidden;box-shadow:var(--shadow-1);
|
|
1239
|
-
}
|
|
1240
|
-
@media(max-width:900px){.snapshot{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
1241
|
-
@media(max-width:520px){
|
|
1242
|
-
/* Two columns even on a phone: five stacked cells cost a full screen before
|
|
1243
|
-
* the first field. The amount cell spans the row to avoid a dangling gap. */
|
|
1244
|
-
.snapshot{grid-template-columns:repeat(2,minmax(0,1fr))}
|
|
1245
|
-
.snap-cell{padding:8px 11px}
|
|
1246
|
-
.snap-cell:last-child{grid-column:1/-1;border-top:1px solid var(--border)}
|
|
1247
|
-
.snap-value{font-size:11.5px;line-height:16px}
|
|
1248
|
-
}
|
|
1249
|
-
.snap-cell{
|
|
1250
|
-
display:flex;flex-direction:column;gap:3px;padding:10px 14px;min-width:0;
|
|
1251
|
-
border-left:1px solid var(--border);
|
|
1252
|
-
}
|
|
1253
|
-
.snap-cell:first-child{border-left:0}
|
|
1254
|
-
@media(max-width:900px){
|
|
1255
|
-
.snap-cell:nth-child(odd){border-left:0}
|
|
1256
|
-
.snap-cell:nth-child(n+3){border-top:1px solid var(--border)}
|
|
1257
|
-
}
|
|
1258
|
-
.snap-label{
|
|
1259
|
-
font-size:9.5px;font-weight:650;letter-spacing:.05em;text-transform:uppercase;color:var(--text-3);
|
|
1260
|
-
}
|
|
1261
|
-
.snap-value{
|
|
1262
|
-
font-size:12px;line-height:17px;font-weight:600;color:var(--text);
|
|
1263
|
-
font-variant-numeric:tabular-nums;overflow-wrap:anywhere;
|
|
1264
|
-
}
|
|
1265
|
-
.snap-cell[data-tone="ok"] .snap-value{color:var(--green)}
|
|
1266
|
-
.snap-cell[data-tone="warn"] .snap-value{color:var(--amber)}
|
|
1267
|
-
.snap-cell[data-tone="info"] .snap-value{color:var(--primary)}
|
|
1268
|
-
.snap-cell[data-tone="muted"] .snap-value{color:var(--text-3);font-weight:500}
|
|
1269
|
-
|
|
1270
|
-
/* ---------- read-only context: shown so the ledger is legible, collapsed so it
|
|
1271
|
-
* does not push the fields-to-fill below the fold. A <details> is used rather
|
|
1272
|
-
* than a JS toggle because it works with no script and prints expanded. ------ */
|
|
1273
|
-
.read-context{border:1px solid var(--border);border-radius:8px;background:var(--inset)}
|
|
1274
|
-
.read-context>summary{
|
|
1275
|
-
padding:8px 12px;font-size:11px;font-weight:600;color:var(--text-2);
|
|
1276
|
-
cursor:pointer;list-style:none;display:flex;align-items:center;gap:7px;
|
|
1277
|
-
}
|
|
1278
|
-
.read-context>summary::-webkit-details-marker{display:none}
|
|
1279
|
-
.read-context>summary::before{
|
|
1280
|
-
content:'';width:0;height:0;flex:none;
|
|
1281
|
-
border-left:4px solid var(--text-3);border-top:3.5px solid transparent;border-bottom:3.5px solid transparent;
|
|
1282
|
-
transition:transform .12s ease;
|
|
1283
|
-
}
|
|
1284
|
-
.read-context[open]>summary::before{transform:rotate(90deg)}
|
|
1285
|
-
.read-context>summary:hover{color:var(--text)}
|
|
1286
|
-
.read-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px;padding:2px 12px 11px}
|
|
1287
|
-
@media(max-width:720px){.read-grid{grid-template-columns:minmax(0,1fr)}}
|
|
1288
|
-
.read-pair{padding:6px 0;border-top:1px dashed var(--border);min-width:0}
|
|
1289
|
-
.read-pair dt{font-size:10px;font-weight:600;color:var(--text-3);margin-bottom:2px}
|
|
1290
|
-
.read-pair dd{font-size:11.5px;line-height:17px;color:var(--text-2);white-space:pre-wrap;overflow-wrap:anywhere}
|
|
1291
|
-
.read-pair dd.read-empty{color:var(--text-3);font-style:italic}
|
|
1292
|
-
.read-list-block{padding:0 12px 10px}
|
|
1293
|
-
.read-list-block h3{margin:6px 0 5px;font-size:10px;font-weight:650;letter-spacing:.04em;text-transform:uppercase;color:var(--text-3)}
|
|
1294
|
-
.read-list{list-style:none;display:flex;flex-direction:column;gap:4px}
|
|
1295
|
-
.read-list li{padding:5px 9px;background:var(--surface);border:1px solid var(--border);border-radius:6px;font-size:11.5px;line-height:17px;overflow-wrap:anywhere}
|
|
1296
|
-
.read-id{font-family:var(--mono);font-size:9px;color:var(--text-3);margin-right:6px}
|
|
1297
|
-
.read-dim{color:var(--text-3)}
|
|
1298
|
-
|
|
1299
|
-
/* ---------- progress history: what has already been reported --------------- */
|
|
1300
|
-
.hist-list{list-style:none;display:flex;flex-direction:column;gap:0;padding:0 12px 10px}
|
|
1301
|
-
.hist-item{
|
|
1302
|
-
display:grid;grid-template-columns:minmax(0,1fr);gap:3px;
|
|
1303
|
-
padding:8px 0;border-top:1px dashed var(--border);
|
|
1304
|
-
}
|
|
1305
|
-
.hist-item:first-child{border-top:0}
|
|
1306
|
-
.hist-head{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
|
|
1307
|
-
.hist-seq{font-family:var(--mono);font-size:9.5px;color:var(--text-3)}
|
|
1308
|
-
.hist-date{font-size:11px;font-weight:650;color:var(--text-2);font-variant-numeric:tabular-nums}
|
|
1309
|
-
.hist-type{font-size:9.5px;color:var(--primary);background:var(--primary-soft);padding:1px 6px;border-radius:4px}
|
|
1310
|
-
.hist-change{font-size:9.5px;color:var(--amber);background:var(--amber-soft);padding:1px 6px;border-radius:4px}
|
|
1311
|
-
.hist-pct{font-size:9.5px;color:var(--text-3);font-variant-numeric:tabular-nums;margin-left:auto}
|
|
1312
|
-
.hist-actual{margin:2px 0 0;font-size:11.5px;line-height:17px;color:var(--text-2);white-space:pre-wrap;overflow-wrap:anywhere}
|
|
1313
|
-
.hist-meta{margin:1px 0 0;font-size:10px;color:var(--text-3);overflow-wrap:anywhere}
|
|
1314
|
-
|
|
1315
|
-
/* ---------- atoms ---------- */
|
|
1316
|
-
.btn{
|
|
1317
|
-
padding:6px 12px;border-radius:6px;border:1px solid var(--border);background:var(--surface);
|
|
1318
|
-
cursor:pointer;font-family:inherit;font-size:12px;color:var(--text);white-space:nowrap;
|
|
1319
|
-
}
|
|
1320
|
-
.btn:hover{background:var(--inset)}
|
|
1321
|
-
.btn-primary{background:var(--primary);color:#fff;border-color:var(--primary);font-weight:600}
|
|
1322
|
-
.btn-primary:hover{background:#1E54C9}
|
|
1323
|
-
.btn-sm{padding:3px 9px;font-size:11px}
|
|
1324
|
-
.btn-remove{color:var(--red);border-color:rgba(192,57,43,.28);flex:none}
|
|
1325
|
-
.badge{display:inline-block;padding:1px 7px;border-radius:4px;font-size:10px;font-weight:600;white-space:nowrap}
|
|
1326
|
-
.badge-ok{background:var(--green-soft);color:var(--green)}
|
|
1327
|
-
.badge-warn{background:var(--amber-soft);color:var(--amber)}
|
|
1328
|
-
.badge-error{background:var(--red-soft);color:var(--red)}
|
|
1329
|
-
.badge-info{background:var(--primary-soft);color:var(--primary)}
|
|
1330
|
-
.pill{display:inline-flex;align-items:center;gap:5px;padding:2px 9px;border-radius:13px;font-size:10.5px;font-weight:600}
|
|
1331
|
-
.pill-dot{width:6px;height:6px;border-radius:50%;background:currentColor;flex:none}
|
|
1332
|
-
.pill-blue{background:var(--primary-soft);color:var(--primary)}
|
|
1333
|
-
.pill-slate{background:var(--slate-soft);color:var(--slate)}
|
|
1334
|
-
.pill-amber{background:var(--amber-soft);color:var(--amber)}
|
|
1335
|
-
.pill-green{background:var(--green-soft);color:var(--green)}
|
|
1336
|
-
.pill-red{background:var(--red-soft);color:var(--red)}
|
|
1337
|
-
|
|
1338
|
-
/* ---------- what is still missing: the one actionable strip ------------- */
|
|
1339
|
-
.missing{
|
|
1340
|
-
display:flex;align-items:flex-start;gap:12px;padding:9px 14px;
|
|
1341
|
-
background:var(--amber-soft);border:1px solid rgba(183,121,25,.24);
|
|
1342
|
-
border-left:3px solid var(--amber);border-radius:8px;
|
|
1343
|
-
}
|
|
1344
|
-
.missing-label{
|
|
1345
|
-
flex:none;font-size:9.5px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;
|
|
1346
|
-
color:var(--amber);padding-top:2px;
|
|
1347
|
-
}
|
|
1348
|
-
.missing-list{list-style:none;display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
1349
|
-
.missing-list li{font-size:11.5px;line-height:17px;color:#8A5E12;overflow-wrap:anywhere}
|
|
1350
|
-
|
|
1351
|
-
/* ---------- notices / footer ---------- */
|
|
1352
|
-
.notice{
|
|
1353
|
-
background:var(--primary-soft);border:1px solid rgba(40,100,232,.22);border-radius:8px;
|
|
1354
|
-
padding:9px 13px;font-size:11.5px;color:var(--text-2);
|
|
1355
|
-
}
|
|
1356
|
-
.notice-warn{background:var(--amber-soft);border-color:rgba(183,121,25,.24);color:#8A5E12}
|
|
1357
|
-
.footer{
|
|
1358
|
-
position:fixed;bottom:0;left:0;right:0;z-index:150;
|
|
1359
|
-
background:var(--surface);border-top:1px solid var(--border);
|
|
1360
|
-
padding:11px 28px;display:flex;justify-content:space-between;align-items:center;gap:12px;
|
|
1361
|
-
flex-wrap:wrap;box-shadow:0 -4px 12px rgba(20,32,52,.06);
|
|
1362
|
-
}
|
|
1363
|
-
.footer-info{font-size:11.5px;color:var(--text-3)}
|
|
1364
|
-
.footer-actions{display:flex;gap:8px;flex-wrap:wrap}
|
|
1365
|
-
.yaml-preview{
|
|
1366
|
-
background:var(--surface);padding:16px;border-radius:10px;border:1px solid var(--border);
|
|
1367
|
-
overflow:auto;font-size:11px;font-family:var(--mono);white-space:pre-wrap;line-height:1.55;
|
|
1368
|
-
}
|
|
1369
|
-
.toast{
|
|
1370
|
-
position:fixed;top:76px;left:50%;transform:translateX(-50%);
|
|
1371
|
-
background:var(--green);color:#fff;padding:8px 17px;border-radius:7px;
|
|
1372
|
-
font-size:12px;z-index:200;box-shadow:var(--shadow-2);
|
|
1373
|
-
}
|
|
1374
|
-
@media print{
|
|
1375
|
-
.banner,.footer{position:static;box-shadow:none}
|
|
1376
|
-
body{padding:0}
|
|
1377
|
-
}
|
|
1378
|
-
`;
|
|
1379
|
-
/**
|
|
1380
|
-
* Styles for the RETURNED page — the read-only report a colleague sends back.
|
|
1381
|
-
*
|
|
1382
|
-
* It is a separate sheet on purpose. The form's sheet is built for input
|
|
1383
|
-
* affordances (focus rings, hover borders, a sticky footer); a report has none of
|
|
1384
|
-
* those and needs a reading rhythm instead: one column, generous line height, and
|
|
1385
|
-
* a label/value grid that stays legible when someone opens it on a phone in
|
|
1386
|
-
* WeChat. Sharing the form's tokens keeps it recognisably the same product.
|
|
1387
|
-
*/
|
|
1388
|
-
const RETURN_CSS = `
|
|
1389
|
-
:root{
|
|
1390
|
-
--text:#192638;--text-2:#4A5A70;--text-3:#7A8AA0;
|
|
1391
|
-
--bg:#F5F7FB;--surface:#fff;--inset:#F7F9FC;
|
|
1392
|
-
--border:#E6EBF2;--green:#218568;--amber:#B77919;--primary:#2864E8;
|
|
1393
|
-
--mono:ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
1394
|
-
}
|
|
1395
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
1396
|
-
body{
|
|
1397
|
-
font-family:'Avenir Next','PingFang SC','Microsoft YaHei',system-ui,sans-serif;
|
|
1398
|
-
background:var(--bg);color:var(--text);font-size:13px;line-height:20px;
|
|
1399
|
-
-webkit-font-smoothing:antialiased;padding:24px 20px 60px;
|
|
1400
|
-
}
|
|
1401
|
-
.ret-shell{max-width:820px;margin:0 auto;display:flex;flex-direction:column;gap:14px}
|
|
1402
|
-
.ret-note{
|
|
1403
|
-
background:rgba(40,100,232,.07);border:1px solid rgba(40,100,232,.2);
|
|
1404
|
-
border-radius:8px;padding:10px 14px;font-size:11.5px;line-height:18px;color:var(--text-2);
|
|
1405
|
-
}
|
|
1406
|
-
.ret-bar{
|
|
1407
|
-
display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between;align-items:baseline;
|
|
1408
|
-
font-size:11.5px;font-weight:600;color:var(--text-2);
|
|
1409
|
-
}
|
|
1410
|
-
.ret-dim{font-weight:400;color:var(--text-3)}
|
|
1411
|
-
.ret-card{
|
|
1412
|
-
background:var(--surface);border:1px solid var(--border);border-radius:10px;
|
|
1413
|
-
padding:18px 20px;display:flex;flex-direction:column;gap:16px;
|
|
1414
|
-
}
|
|
1415
|
-
.ret-head{padding-bottom:12px;border-bottom:1px solid var(--border)}
|
|
1416
|
-
.ret-head h1{margin:0;font-size:19px;line-height:27px;font-weight:700;letter-spacing:-.01em;overflow-wrap:anywhere}
|
|
1417
|
-
.ret-meta{margin-top:4px;font-size:10.5px;color:var(--text-3);font-family:var(--mono)}
|
|
1418
|
-
.ret-sec h2{
|
|
1419
|
-
margin:0 0 7px;font-size:11px;font-weight:650;letter-spacing:.05em;
|
|
1420
|
-
text-transform:uppercase;color:var(--text-3);
|
|
1421
|
-
}
|
|
1422
|
-
.ret-sec dl{display:flex;flex-direction:column;gap:0}
|
|
1423
|
-
.ret-pair{
|
|
1424
|
-
display:grid;grid-template-columns:132px minmax(0,1fr);gap:12px;
|
|
1425
|
-
padding:6px 0;border-top:1px dashed var(--border);
|
|
1426
|
-
}
|
|
1427
|
-
.ret-pair:first-child{border-top:0}
|
|
1428
|
-
.ret-pair dt{font-size:11.5px;color:var(--text-3);line-height:19px}
|
|
1429
|
-
.ret-pair dd{font-size:12.5px;line-height:20px;color:var(--text);white-space:pre-wrap;overflow-wrap:anywhere}
|
|
1430
|
-
.ret-list{list-style:none;display:flex;flex-direction:column;gap:5px}
|
|
1431
|
-
.ret-list li{
|
|
1432
|
-
padding:6px 10px;background:var(--inset);border-radius:6px;
|
|
1433
|
-
font-size:12px;line-height:18px;overflow-wrap:anywhere;
|
|
1434
|
-
}
|
|
1435
|
-
.ret-list li b{font-family:var(--mono);font-size:9.5px;color:var(--text-3);margin-right:6px}
|
|
1436
|
-
.ret-new{border-left:3px solid var(--green);padding-left:13px}
|
|
1437
|
-
.ret-new h2{color:var(--green)}
|
|
1438
|
-
.ret-tag{
|
|
1439
|
-
margin-left:7px;padding:1px 6px;border-radius:4px;font-size:9px;
|
|
1440
|
-
background:rgba(33,133,104,.12);color:var(--green);text-transform:none;letter-spacing:0;
|
|
1441
|
-
}
|
|
1442
|
-
@media(max-width:560px){
|
|
1443
|
-
body{padding:14px 12px 40px}
|
|
1444
|
-
.ret-card{padding:14px 15px}
|
|
1445
|
-
.ret-pair{grid-template-columns:minmax(0,1fr);gap:2px}
|
|
1446
|
-
}
|
|
1447
|
-
@media print{
|
|
1448
|
-
body{background:#fff;padding:0}
|
|
1449
|
-
.ret-note{display:none}
|
|
1450
|
-
.ret-card{break-inside:avoid;border-color:#ccc}
|
|
1451
|
-
}
|
|
1452
|
-
`;
|
|
1453
|
-
/**
|
|
1454
|
-
* The generated page script.
|
|
1455
|
-
*
|
|
1456
|
-
* Plain ES5 (no arrow functions, no template literals, no `const`): the file has
|
|
1457
|
-
* to run from `file://` in any browser a colleague happens to have. It also
|
|
1458
|
-
* keeps the generator's own template escaping simple.
|
|
1459
|
-
*
|
|
1460
|
-
* It renders a form from `DATA`, keeps a draft in localStorage, validates the
|
|
1461
|
-
* counts the gap rules enforce, and downloads real YAML — one file per project.
|
|
1462
|
-
*/
|
|
1463
|
-
const FORM_SCRIPT = `
|
|
1464
|
-
var state = { active: 0 };
|
|
1465
|
-
var saveTimer = null;
|
|
1466
|
-
var storageAvailable = true;
|
|
1467
|
-
|
|
1468
|
-
function text(value) {
|
|
1469
|
-
if (value === null || value === undefined) return '';
|
|
1470
|
-
return String(value);
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
function byId(id) { return document.getElementById(id); }
|
|
1474
|
-
|
|
1475
|
-
function escapeHtml(value) {
|
|
1476
|
-
return text(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
function showToast(message) {
|
|
1480
|
-
var toast = byId('toast');
|
|
1481
|
-
if (!toast) return;
|
|
1482
|
-
toast.textContent = message;
|
|
1483
|
-
toast.hidden = false;
|
|
1484
|
-
clearTimeout(showToast.timer);
|
|
1485
|
-
showToast.timer = setTimeout(function () { toast.hidden = true; }, 2200);
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
function probeStorage() {
|
|
1489
|
-
try {
|
|
1490
|
-
var probe = '__poc_v3_probe__';
|
|
1491
|
-
window.localStorage.setItem(probe, '1');
|
|
1492
|
-
window.localStorage.removeItem(probe);
|
|
1493
|
-
return true;
|
|
1494
|
-
} catch (error) {
|
|
1495
|
-
return false;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
function storageKey() { return DATA.draftKey; }
|
|
1500
|
-
|
|
1501
|
-
function loadDraft() {
|
|
1502
|
-
if (!storageAvailable) return null;
|
|
1503
|
-
try {
|
|
1504
|
-
var raw = window.localStorage.getItem(storageKey());
|
|
1505
|
-
if (!raw) return null;
|
|
1506
|
-
var parsed = JSON.parse(raw);
|
|
1507
|
-
if (!parsed || !parsed.projects || !parsed.projects.length) return null;
|
|
1508
|
-
return parsed.projects;
|
|
1509
|
-
} catch (error) {
|
|
1510
|
-
return null;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
function save(quiet) {
|
|
1515
|
-
if (!storageAvailable) {
|
|
1516
|
-
markSave('草稿无法保存(浏览器禁用了本地存储)');
|
|
1517
|
-
return;
|
|
1518
|
-
}
|
|
1519
|
-
try {
|
|
1520
|
-
window.localStorage.setItem(storageKey(), JSON.stringify({ projects: DATA.projects, savedAt: new Date().toISOString() }));
|
|
1521
|
-
markSave('已自动保存');
|
|
1522
|
-
} catch (error) {
|
|
1523
|
-
markSave('草稿保存失败:可能空间不足');
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
function markSave(message) {
|
|
1528
|
-
var node = byId('saveStatus');
|
|
1529
|
-
if (node) node.textContent = message;
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
function scheduleSave() {
|
|
1533
|
-
clearTimeout(saveTimer);
|
|
1534
|
-
saveTimer = setTimeout(function () { save(false); }, 600);
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
function clearDraft() {
|
|
1538
|
-
if (storageAvailable) {
|
|
1539
|
-
try { window.localStorage.removeItem(storageKey()); } catch (error) {}
|
|
1540
|
-
}
|
|
1541
|
-
DATA.projects = DATA.mode === 'blank' ? [blankProject()] : DATA.projects;
|
|
1542
|
-
location.reload();
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
function blankProject() {
|
|
1546
|
-
return ${JSON.stringify(blankProjectPayload())};
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
function current() { return DATA.projects[state.active]; }
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
* A new list row, carrying the next free stable id.
|
|
1553
|
-
*
|
|
1554
|
-
* v3.1 requires an id on every scenario and criterion because evidence and
|
|
1555
|
-
* progress reference them. A row added without one used to crash the YAML
|
|
1556
|
-
* writer outright (it called '.trim()' on an absent id), and even when it did
|
|
1557
|
-
* not, the row could never be referenced. The id is derived from the highest
|
|
1558
|
-
* existing suffix so deleting a row never renumbers the survivors.
|
|
1559
|
-
*/
|
|
1560
|
-
function nextRow(prefix, list, fields) {
|
|
1561
|
-
var highest = 0;
|
|
1562
|
-
for (var i = 0; i < list.length; i += 1) {
|
|
1563
|
-
var match = new RegExp('^' + prefix + '-(\\\\d+)$').exec(text(list[i].id));
|
|
1564
|
-
if (match) highest = Math.max(highest, Number(match[1]));
|
|
1565
|
-
}
|
|
1566
|
-
fields.id = prefix + '-' + ('0' + (highest + 1)).slice(-2);
|
|
1567
|
-
return fields;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
function setPath(target, path, value) {
|
|
1571
|
-
var parts = path.split('.');
|
|
1572
|
-
var node = target;
|
|
1573
|
-
for (var i = 0; i < parts.length - 1; i += 1) {
|
|
1574
|
-
var key = parts[i];
|
|
1575
|
-
if (key === '') continue;
|
|
1576
|
-
if (/^\\d+$/.test(key)) key = Number(key);
|
|
1577
|
-
if (node[key] === null || node[key] === undefined) node[key] = {};
|
|
1578
|
-
node = node[key];
|
|
1579
|
-
}
|
|
1580
|
-
node[parts[parts.length - 1]] = value;
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
function field(label, path, value, options) {
|
|
1584
|
-
var opts = options || {};
|
|
1585
|
-
var help = opts.help ? '<p class="field-help">' + escapeHtml(opts.help) + '</p>' : '';
|
|
1586
|
-
var req = opts.required ? '<span class="req">*</span>' : '';
|
|
1587
|
-
// A locked field is shown, not hidden: the person needs to know what the
|
|
1588
|
-
// ledger already says. It is rendered as a disabled control (so it reads as a
|
|
1589
|
-
// field) with no 'data-path' (so no handler can write it), plus a lock note.
|
|
1590
|
-
var locked = opts.readonly === true;
|
|
1591
|
-
var lockAttr = locked ? ' disabled' : '';
|
|
1592
|
-
var pathAttr = locked ? '' : ' data-path="' + escapeHtml(path) + '"';
|
|
1593
|
-
var input;
|
|
1594
|
-
if (opts.multiline) {
|
|
1595
|
-
input = '<textarea class="textarea' + (locked ? ' is-locked' : '') + '"' + pathAttr + lockAttr + '>' + escapeHtml(value) + '</textarea>';
|
|
1596
|
-
} else if (opts.enum) {
|
|
1597
|
-
input = '<select class="select' + (locked ? ' is-locked' : '') + '"' + pathAttr + lockAttr + '>';
|
|
1598
|
-
// ALWAYS offer an explicit "not answered" choice on an EDITABLE select.
|
|
1599
|
-
//
|
|
1600
|
-
// This line once read 'if (locked && value === '')', which meant no
|
|
1601
|
-
// editable enum had an empty option. The browser then selects option[0]
|
|
1602
|
-
// by default, so a colleague who touched nothing still submitted
|
|
1603
|
-
// type=内部Review, change=阶段推进, completion=0%, recognition=认可,
|
|
1604
|
-
// gate3_1=可证明, gate3_2=已确认 — and, on the new-project form,
|
|
1605
|
-
// gate0 评审结论=通过. Those are audit verdicts; the form was signing
|
|
1606
|
-
// them for the colleague. A locked field is different: its value comes
|
|
1607
|
-
// from the ledger, so it must show that value rather than an empty one.
|
|
1608
|
-
if (!locked || value === '') input += '<option value="">— 未填 —</option>';
|
|
1609
|
-
for (var i = 0; i < opts.enum.length; i += 1) {
|
|
1610
|
-
var option = opts.enum[i];
|
|
1611
|
-
input += '<option value="' + escapeHtml(option) + '"' + (option === value ? ' selected' : '') + '>' + escapeHtml(option) + '</option>';
|
|
1612
|
-
}
|
|
1613
|
-
input += '</select>';
|
|
1614
|
-
} else {
|
|
1615
|
-
// lang="zh-CN" on a date input: the browser otherwise formats the picker as
|
|
1616
|
-
// mm/dd/yyyy in an English locale, which reads as "month 20" to a Chinese
|
|
1617
|
-
// colleague. The attribute is per-element because it must override the
|
|
1618
|
-
// browser's own locale, not the document's.
|
|
1619
|
-
var langAttr = opts.date ? ' lang="zh-CN"' : '';
|
|
1620
|
-
input = '<input class="input' + (locked ? ' is-locked' : '') + '" type="' + (opts.date ? 'date' : opts.number ? 'number' : 'text') + '"' + pathAttr + langAttr + ' value="' + escapeHtml(value) + '"' + lockAttr + '>';
|
|
1621
|
-
}
|
|
1622
|
-
// The note is redundant when 'help' already explains why the field is locked,
|
|
1623
|
-
// and printing both made a two-line field into a four-line one.
|
|
1624
|
-
var lockNote = locked && !opts.help ? '<p class="field-help field-locked">只读 · 由台账/评审流程维护</p>' : '';
|
|
1625
|
-
return '<div class="field' + (locked ? ' is-locked' : '') + '" data-field="' + escapeHtml(path) + '">' +
|
|
1626
|
-
'<label class="field-label">' + escapeHtml(label) + req + '</label>' + help + input + lockNote + '</div>';
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
/**
|
|
1630
|
-
* Gate 0 as the same 2x3 card grid the detail page uses.
|
|
1631
|
-
*
|
|
1632
|
-
* A generic stack of labelled textareas hid the thing a colleague most needs
|
|
1633
|
-
* to see: WHICH of the five prerequisites is still missing. The grid makes a
|
|
1634
|
-
* blank cell a visible gap rather than one empty box among many.
|
|
1635
|
-
*/
|
|
1636
|
-
function g0Card(project) {
|
|
1637
|
-
var cards = '';
|
|
1638
|
-
var present = 0;
|
|
1639
|
-
for (var i = 0; i < DATA.g0Fields.length; i += 1) {
|
|
1640
|
-
var def = DATA.g0Fields[i];
|
|
1641
|
-
var filled = text(project.gate0[def.key]).trim() !== '';
|
|
1642
|
-
if (filled) present += 1;
|
|
1643
|
-
cards += '<div class="g0-card" data-present="' + (filled ? 'true' : 'false') + '">' +
|
|
1644
|
-
'<div class="g0-card-head"><span class="g0-card-label">' + escapeHtml(def.label) +
|
|
1645
|
-
'<span class="req">*</span></span>' +
|
|
1646
|
-
(filled ? '' : '<span class="g0-card-missing">缺失</span>') + '</div>' +
|
|
1647
|
-
'<textarea class="textarea" data-path="gate0.' + def.key + '" placeholder="' +
|
|
1648
|
-
escapeHtml(def.hint) + '">' + escapeHtml(project.gate0[def.key]) + '</textarea>' +
|
|
1649
|
-
'</div>';
|
|
1650
|
-
}
|
|
1651
|
-
// The fifth prerequisite lives in the identity block of the ledger, but it is
|
|
1652
|
-
// a G0 requirement, so it is EDITED here — once. It used to be rendered both
|
|
1653
|
-
// here and in the identity card with the same 'data-path', so two inputs owned
|
|
1654
|
-
// one value: typing in one left the other showing stale text, and the last
|
|
1655
|
-
// render won. One field, one input.
|
|
1656
|
-
var techFilled = text(project.techOwner).trim() !== '';
|
|
1657
|
-
if (techFilled) present += 1;
|
|
1658
|
-
cards += '<div class="g0-card" data-present="' + (techFilled ? 'true' : 'false') + '">' +
|
|
1659
|
-
'<div class="g0-card-head"><span class="g0-card-label">客户技术责任人' +
|
|
1660
|
-
'<span class="req">*</span></span>' +
|
|
1661
|
-
(techFilled ? '' : '<span class="g0-card-missing">缺失</span>') + '</div>' +
|
|
1662
|
-
'<input class="input" data-path="techOwner" value="' + escapeHtml(project.techOwner) + '" placeholder="谁在客户侧配合验证">' +
|
|
1663
|
-
'</div>';
|
|
1664
|
-
|
|
1665
|
-
var tone = present === 5 ? 'badge-ok' : present === 0 ? 'badge-warn' : 'badge-info';
|
|
1666
|
-
// 评审结论 / 评审人 / 评审日期 are NOT here on purpose. They are the G0
|
|
1667
|
-
// review's output, and the form once offered them to the colleague being
|
|
1668
|
-
// asked to supply facts — so a form could arrive claiming "评审通过, 评审人 X"
|
|
1669
|
-
// written by the person under review. The review is recorded through DSH,
|
|
1670
|
-
// not through this file.
|
|
1671
|
-
return '<section class="sec">' +
|
|
1672
|
-
'<header class="sec-head"><h2 class="sec-title">Gate 0 · 值不值得做</h2>' +
|
|
1673
|
-
'<span class="sec-kicker">五必填 <span class="badge ' + tone + '">' + present + ' / 5</span></span></header>' +
|
|
1674
|
-
'<p class="sec-hint">这五项齐了,G0 评审才有意义。评审结论不在这里填。</p>' +
|
|
1675
|
-
'<div class="g0-grid">' + cards + '</div>' +
|
|
1676
|
-
'<div class="grid-2">' +
|
|
1677
|
-
field('主要竞争对手', 'gate0.competitor', project.gate0.competitor, {}) +
|
|
1678
|
-
'</div></section>';
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
function criteriaList(project) {
|
|
1682
|
-
var rows = '';
|
|
1683
|
-
for (var i = 0; i < project.plan.criteria.length; i += 1) {
|
|
1684
|
-
var criterion = project.plan.criteria[i];
|
|
1685
|
-
rows += '<div class="row-card">' +
|
|
1686
|
-
'<div class="row-card-head">' +
|
|
1687
|
-
'<span class="row-card-id mono">' + escapeHtml(criterion.id) + '</span>' +
|
|
1688
|
-
'<input class="input input-flush" data-path="plan.criteria.' + i + '.name" value="' + escapeHtml(criterion.name) + '" placeholder="指标名称,如「200 人并发稳定 7 天」">' +
|
|
1689
|
-
'<button type="button" class="btn btn-sm btn-remove" data-remove="criteria" data-index="' + i + '" title="删除这条指标">删</button>' +
|
|
1690
|
-
'</div>' +
|
|
1691
|
-
'<div class="row-card-grid">' +
|
|
1692
|
-
'<label class="mini"><span class="mini-label">度量</span>' +
|
|
1693
|
-
'<input class="input" data-path="plan.criteria.' + i + '.metric" value="' + escapeHtml(criterion.metric) + '" placeholder="如「成功率」"></label>' +
|
|
1694
|
-
'<label class="mini"><span class="mini-label">基线</span>' +
|
|
1695
|
-
'<input class="input" data-path="plan.criteria.' + i + '.baseline" value="' + escapeHtml(criterion.baseline) + '" placeholder="当前值"></label>' +
|
|
1696
|
-
'<label class="mini"><span class="mini-label">目标</span>' +
|
|
1697
|
-
'<input class="input" data-path="plan.criteria.' + i + '.target" value="' + escapeHtml(criterion.target) + '" placeholder="如 ≥99.5%"></label>' +
|
|
1698
|
-
'</div></div>';
|
|
1699
|
-
}
|
|
1700
|
-
return rows + '<button type="button" class="btn btn-sm" data-add="criteria">+ 加一条指标</button>';
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
/**
|
|
1704
|
-
* The scenario list.
|
|
1705
|
-
*
|
|
1706
|
-
* v3.1 made a scenario an object with a stable id, not a bare string. The old
|
|
1707
|
-
* renderer still printed the object, which is why every scenario row showed
|
|
1708
|
-
* "[object Object]" — the id is carried through untouched because evidence
|
|
1709
|
-
* attaches to it, and 'name' / 'goal' are the two editable parts.
|
|
1710
|
-
*/
|
|
1711
|
-
function scenarioList(project) {
|
|
1712
|
-
var rows = '';
|
|
1713
|
-
for (var i = 0; i < project.plan.scenarios.length; i += 1) {
|
|
1714
|
-
var scenario = project.plan.scenarios[i];
|
|
1715
|
-
rows += '<div class="row-card">' +
|
|
1716
|
-
'<div class="row-card-head">' +
|
|
1717
|
-
'<span class="row-card-id mono">' + escapeHtml(scenario.id) + '</span>' +
|
|
1718
|
-
'<input class="input input-flush" data-path="plan.scenarios.' + i + '.name" value="' + escapeHtml(scenario.name) + '" placeholder="场景名称,如「办公网远程接入」">' +
|
|
1719
|
-
'<button type="button" class="btn btn-sm btn-remove" data-remove="scenarios" data-index="' + i + '" title="删除这个场景">删</button>' +
|
|
1720
|
-
'</div>' +
|
|
1721
|
-
'<label class="mini mini-wide"><span class="mini-label">成功目标</span>' +
|
|
1722
|
-
'<input class="input" data-path="plan.scenarios.' + i + '.goal" value="' + escapeHtml(scenario.goal) + '" placeholder="如 5000 人并发成功率 ≥99.5%,稳定 7 天"></label>' +
|
|
1723
|
-
'</div>';
|
|
1724
|
-
}
|
|
1725
|
-
return rows + '<button type="button" class="btn btn-sm" data-add="scenarios">+ 加一个场景</button>';
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
function riskList(project) {
|
|
1729
|
-
var rows = '';
|
|
1730
|
-
for (var i = 0; i < project.plan.risks.length; i += 1) {
|
|
1731
|
-
var risk = project.plan.risks[i];
|
|
1732
|
-
var select = '<select class="select" data-path="plan.risks.' + i + '.level">';
|
|
1733
|
-
select += '<option value="">— 未评级 —</option>';
|
|
1734
|
-
for (var j = 0; j < DATA.enums.riskLevel.length; j += 1) {
|
|
1735
|
-
var level = DATA.enums.riskLevel[j];
|
|
1736
|
-
select += '<option value="' + level + '"' + (level === risk.level ? ' selected' : '') + '>' + level + '</option>';
|
|
1737
|
-
}
|
|
1738
|
-
select += '</select>';
|
|
1739
|
-
rows += '<div class="list-item">' +
|
|
1740
|
-
'<input class="input" data-path="plan.risks.' + i + '.name" value="' + escapeHtml(risk.name) + '" placeholder="风险">' +
|
|
1741
|
-
select +
|
|
1742
|
-
'<input class="input" data-path="plan.risks.' + i + '.mitigation" value="' + escapeHtml(risk.mitigation) + '" placeholder="应对">' +
|
|
1743
|
-
'<button type="button" class="btn btn-sm btn-remove" data-remove="risks" data-index="' + i + '">删</button>' +
|
|
1744
|
-
'</div>';
|
|
1745
|
-
}
|
|
1746
|
-
return rows + '<button type="button" class="btn btn-sm" data-add="risks">+ 加一条风险</button>';
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
/** The plan block: how we win, split into what we commit to and the limits. */
|
|
1750
|
-
function planCard(project) {
|
|
1751
|
-
var criteria = project.plan.criteria.length;
|
|
1752
|
-
var scenarios = project.plan.scenarios.length;
|
|
1753
|
-
var risks = project.plan.risks.length;
|
|
1754
|
-
var criteriaBadge = criteria === 0 ? '<span class="badge badge-warn">还没有指标</span>'
|
|
1755
|
-
: (criteria >= 2 && criteria <= 3 ? '<span class="badge badge-ok">' + criteria + ' 条,符合 2–3</span>'
|
|
1756
|
-
: '<span class="badge badge-error">' + criteria + ' 条,要求 2–3</span>');
|
|
1757
|
-
var scenarioBadge = scenarios === 0 ? '<span class="badge badge-warn">还没有场景</span>'
|
|
1758
|
-
: (scenarios >= 3 && scenarios <= 5 ? '<span class="badge badge-ok">' + scenarios + ' 个,符合 3–5</span>'
|
|
1759
|
-
: '<span class="badge badge-error">' + scenarios + ' 个,要求 3–5</span>');
|
|
1760
|
-
return '<section class="sec">' +
|
|
1761
|
-
'<header class="sec-head"><h2 class="sec-title">成功指标与测试场景</h2>' +
|
|
1762
|
-
'<span class="sec-kicker">G1 / G2</span></header>' +
|
|
1763
|
-
'<p class="sec-hint">指标 2–3 条、场景 3–5 个。数量不对会在缺口清单里被点名。id 由系统分配,不要改——证据靠它挂靠。</p>' +
|
|
1764
|
-
'<div class="sec"><label class="field-label">关键成功指标 ' + criteriaBadge + '</label>' + criteriaList(project) + '</div>' +
|
|
1765
|
-
'<div class="sec"><label class="field-label">关键测试场景 ' + scenarioBadge + '</label>' + scenarioList(project) + '</div>' +
|
|
1766
|
-
'</section>';
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
/** The plan's narrative + its limits, which belong on the record side. */
|
|
1770
|
-
function planNarrative(project) {
|
|
1771
|
-
return '<section class="sec">' +
|
|
1772
|
-
'<header class="sec-head"><h2 class="sec-title">方案要点</h2></header>' +
|
|
1773
|
-
field('客户核心痛点', 'plan.customer_pain', project.plan.customer_pain, { multiline: true }) +
|
|
1774
|
-
field('期望客户认可什么', 'plan.expected_recognition', project.plan.expected_recognition, { multiline: true }) +
|
|
1775
|
-
field('我方优势 / 赢点', 'plan.our_edge', project.plan.our_edge, { multiline: true }) +
|
|
1776
|
-
'</section>';
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
function riskCard(project) {
|
|
1780
|
-
var risks = project.plan.risks.length;
|
|
1781
|
-
var riskBadge = risks === 0 ? '<span class="badge badge-warn">还没有风险</span>'
|
|
1782
|
-
: (risks <= 3 ? '<span class="badge badge-ok">' + risks + ' 条,≤3</span>'
|
|
1783
|
-
: '<span class="badge badge-error">' + risks + ' 条,超过 3</span>');
|
|
1784
|
-
return '<section class="sec">' +
|
|
1785
|
-
'<header class="sec-head"><h2 class="sec-title">最大风险</h2>' +
|
|
1786
|
-
'<span class="sec-kicker">' + riskBadge + '</span></header>' +
|
|
1787
|
-
riskList(project) + '</section>';
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
function gateCard(project) {
|
|
1791
|
-
return '<section class="sec">' +
|
|
1792
|
-
'<header class="sec-head"><h2 class="sec-title">Gate 结论与时间</h2></header>' +
|
|
1793
|
-
'<div class="grid-2">' +
|
|
1794
|
-
field('计划开始', 'plan.timeline_start', project.plan.timeline_start, { date: true }) +
|
|
1795
|
-
field('计划结束', 'plan.timeline_end', project.plan.timeline_end, { date: true }) +
|
|
1796
|
-
field('G1 结论', 'plan.gate1_conclusion', project.plan.gate1_conclusion, { enum: DATA.enums.g1Conclusion }) +
|
|
1797
|
-
field('G2 Ready 状态', 'plan.gate2_ready', project.plan.gate2_ready, { enum: DATA.enums.g2Ready }) +
|
|
1798
|
-
'</div></section>';
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
/**
|
|
1802
|
-
* This round's entry — the append-only half of the ledger.
|
|
1803
|
-
*
|
|
1804
|
-
* Kept as one section rather than split across the columns: a progress entry is
|
|
1805
|
-
* read as a single unit ("what happened, what proves it, who said so, what
|
|
1806
|
-
* next"), and splitting it would let a colleague fill the top half and forget
|
|
1807
|
-
* the evidence below.
|
|
1808
|
-
*/
|
|
1809
|
-
/**
|
|
1810
|
-
* A checkbox group that picks which scenarios / criteria this round touched.
|
|
1811
|
-
*
|
|
1812
|
-
* v3.1 requires scenario_ids / criteria_ids on every progress entry, and they
|
|
1813
|
-
* are what makes a scenario's status derivable at all. The form shipped without
|
|
1814
|
-
* any way to set them, so every returned form carried an empty list and the
|
|
1815
|
-
* ledger could never work out which scenario a proof belonged to.
|
|
1816
|
-
*
|
|
1817
|
-
* The two lists are deliberately independent: a round can prove a criterion
|
|
1818
|
-
* without touching any scenario, which is why they are separate groups rather
|
|
1819
|
-
* than a nested scenario -> criteria tree.
|
|
1820
|
-
*/
|
|
1821
|
-
function idPicker(label, path, unused, options, selected, hint) {
|
|
1822
|
-
if (options.length === 0) {
|
|
1823
|
-
// Nothing to pick: say so in one muted line instead of two help paragraphs.
|
|
1824
|
-
// A G0 project has no plan yet by design, so this is normal, not a gap.
|
|
1825
|
-
return '<div class="field"><label class="field-label">' + escapeHtml(label) + '</label>' +
|
|
1826
|
-
'<p class="field-help">' + escapeHtml(hint) + '</p>' +
|
|
1827
|
-
'<p class="pick-empty">这个项目还没有可选的内容(方案里还没填),先跳过这一项。</p></div>';
|
|
1828
|
-
}
|
|
1829
|
-
var chosen = {};
|
|
1830
|
-
for (var i = 0; i < selected.length; i += 1) chosen[text(selected[i])] = true;
|
|
1831
|
-
var boxes = '';
|
|
1832
|
-
for (var j = 0; j < options.length; j += 1) {
|
|
1833
|
-
var option = options[j];
|
|
1834
|
-
boxes += '<label class="pick">' +
|
|
1835
|
-
'<input type="checkbox" data-pick="' + escapeHtml(path) + '" value="' + escapeHtml(option.id) + '"' +
|
|
1836
|
-
(chosen[option.id] ? ' checked' : '') + '>' +
|
|
1837
|
-
'<span class="pick-id">' + escapeHtml(option.id) + '</span>' +
|
|
1838
|
-
'<span class="pick-name">' + escapeHtml(option.name || '(未命名)') + '</span>' +
|
|
1839
|
-
'</label>';
|
|
1840
|
-
}
|
|
1841
|
-
return '<div class="field"><label class="field-label">' + escapeHtml(label) + '</label>' +
|
|
1842
|
-
'<p class="field-help">' + escapeHtml(hint) + '</p>' +
|
|
1843
|
-
'<div class="pick-list">' + boxes + '</div></div>';
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
/**
|
|
1847
|
-
* One round of progress — the form's primary job.
|
|
1848
|
-
*
|
|
1849
|
-
* ## Fact-only, deliberately
|
|
1850
|
-
*
|
|
1851
|
-
* A round used to also ask for 客户认可度, G3-1 and G3-2. Those are not facts a
|
|
1852
|
-
* colleague observes; they are the ledger's verdicts, and 'tools/derive.mjs'
|
|
1853
|
-
* consumes them to work out scenario and criterion status. Letting the person
|
|
1854
|
-
* filling the form set them meant self-certification: every round could arrive
|
|
1855
|
-
* already marked 可证明 + 已确认 without anyone having confirmed anything.
|
|
1856
|
-
*
|
|
1857
|
-
* They are removed from the form. DSH derives them on merge (see the
|
|
1858
|
-
* poc-submit skill) from what IS collected here: evidence, the customer's own
|
|
1859
|
-
* words, and what was actually done. Super Agent audits afterwards.
|
|
1860
|
-
*
|
|
1861
|
-
* ## Why this is short
|
|
1862
|
-
*
|
|
1863
|
-
* The intended use is "one round, one screen". So the required facts come
|
|
1864
|
-
* first, and the optional ones live in a collapsed block — a colleague filing
|
|
1865
|
-
* a weekly update should not have to scroll past fields they rarely touch.
|
|
1866
|
-
*/
|
|
1867
|
-
function progressCard(project) {
|
|
1868
|
-
var entry = project.progress;
|
|
1869
|
-
var evidenceRows = '';
|
|
1870
|
-
for (var i = 0; i < entry.evidence.length; i += 1) {
|
|
1871
|
-
evidenceRows += '<div class="row-card"><div class="row-card-head">' +
|
|
1872
|
-
'<input class="input" data-path="progress.evidence.' + i + '.title" value="' + escapeHtml(entry.evidence[i].title) + '" placeholder="证据名称,如「压测报告」">' +
|
|
1873
|
-
'<input class="input" data-path="progress.evidence.' + i + '.link" value="' + escapeHtml(entry.evidence[i].link) + '" placeholder="链接(可空)">' +
|
|
1874
|
-
'<button type="button" class="btn btn-sm btn-remove" data-remove="evidence" data-index="' + i + '">删</button>' +
|
|
1875
|
-
'</div></div>';
|
|
1876
|
-
}
|
|
1877
|
-
var countBadge = project.existingProgressCount > 0
|
|
1878
|
-
? '<span class="badge badge-info">第 ' + (project.existingProgressCount + 1) + ' 条</span>'
|
|
1879
|
-
: '<span class="badge badge-warn">第一条</span>';
|
|
1880
|
-
|
|
1881
|
-
// Optional extras are collapsed by default: they exist, but they must not
|
|
1882
|
-
// stand between the colleague and the three fields that actually matter.
|
|
1883
|
-
var extras =
|
|
1884
|
-
'<details class="read-context extras"><summary>可选:完成度 / 目标 / 关联场景与指标</summary>' +
|
|
1885
|
-
'<div class="grid-2">' +
|
|
1886
|
-
field('完成度', 'progress.completion', entry.completion, { enum: DATA.enums.completion }) +
|
|
1887
|
-
field('这一轮的目标', 'progress.goal', entry.goal, {}) +
|
|
1888
|
-
'</div>' +
|
|
1889
|
-
idPicker('推进了哪些场景', 'progress.scenarioIds', null, project.plan.scenarios, entry.scenarioIds,
|
|
1890
|
-
'勾选这一轮实际验证过的场景。') +
|
|
1891
|
-
idPicker('验证了哪些指标', 'progress.criteriaIds', null, project.plan.criteria, entry.criteriaIds,
|
|
1892
|
-
'与场景相互独立:一条指标可以被验证而没有推进任何场景。') +
|
|
1893
|
-
'</details>';
|
|
1894
|
-
|
|
1895
|
-
return '<section class="sec">' +
|
|
1896
|
-
'<header class="sec-head"><h2 class="sec-title">这一轮进展</h2>' +
|
|
1897
|
-
'<span class="sec-kicker">' + countBadge + '</span></header>' +
|
|
1898
|
-
'<p class="sec-hint">只填这次真正发生的事。追加式,不会覆盖历史。</p>' +
|
|
1899
|
-
'<div class="grid-3">' +
|
|
1900
|
-
field('日期', 'progress.date', entry.date, { date: true, required: true }) +
|
|
1901
|
-
field('类型', 'progress.type', entry.type, { enum: DATA.enums.progressType, required: true }) +
|
|
1902
|
-
field('这一次什么变了', 'progress.change', entry.change, { enum: DATA.enums.progressChange, required: true, help: '「无实质进展」也是正当答案。' }) +
|
|
1903
|
-
'</div>' +
|
|
1904
|
-
field('实际结果', 'progress.actual', entry.actual, { multiline: true, required: true, help: '做了什么、结果如何。' }) +
|
|
1905
|
-
'<div class="field"><label class="field-label">证据<span class="req">*</span></label>' +
|
|
1906
|
-
'<p class="field-help">没有证据的结果会被缺口规则点名。</p>' + evidenceRows +
|
|
1907
|
-
'<button type="button" class="btn btn-sm" data-add="evidence">+ 加一条证据</button></div>' +
|
|
1908
|
-
'<div class="grid-2">' +
|
|
1909
|
-
field('同步对象', 'progress.customer.synced_with', entry.customer.synced_with, {}) +
|
|
1910
|
-
field('客户原话 / 反馈', 'progress.customer.feedback', entry.customer.feedback, { multiline: true, help: '照原样记,不要替他判断认可不认可。' }) +
|
|
1911
|
-
'</div>' +
|
|
1912
|
-
extras +
|
|
1913
|
-
'</section>';
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
/** The closing block: next actions, spanning both columns like the detail page. */
|
|
1917
|
-
function nextCard(project) {
|
|
1918
|
-
var next = project.progress.next;
|
|
1919
|
-
return '<section class="sec">' +
|
|
1920
|
-
'<header class="sec-head"><h2 class="sec-title">下一步工作目标及计划</h2>' +
|
|
1921
|
-
'</header>' +
|
|
1922
|
-
'<div class="grid-2">' +
|
|
1923
|
-
field('下一步目标', 'progress.next.goal', next.goal, { multiline: true, required: true }) +
|
|
1924
|
-
field('负责人', 'progress.next.owner', next.owner, {}) +
|
|
1925
|
-
field('截止日期', 'progress.next.deadline', next.deadline, { date: true }) +
|
|
1926
|
-
'</div></section>';
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
/** Identity: the fields the detail page keeps in its right-hand column. */
|
|
1930
|
-
function identityCard(project) {
|
|
1931
|
-
return '<section class="sec">' +
|
|
1932
|
-
'<header class="sec-head"><h2 class="sec-title">基本信息</h2></header>' +
|
|
1933
|
-
'<p class="sec-hint">编号、阶段、状态由台账维护,这里只读。</p>' +
|
|
1934
|
-
'<div class="grid-2">' +
|
|
1935
|
-
field('项目编号', 'pocId', project.pocId, { required: DATA.mode === 'blank', readonly: DATA.mode !== 'blank', help: DATA.mode === 'blank' ? '新建时必填,格式 POC-XXX。' : '台账主键,不可改。' }) +
|
|
1936
|
-
field('项目名称', 'name', project.name, { required: true }) +
|
|
1937
|
-
field('体系', 'system', project.system, { enum: DATA.enums.system }) +
|
|
1938
|
-
field('客户公司', 'company', project.company, {}) +
|
|
1939
|
-
field('部门', 'department', project.department, {}) +
|
|
1940
|
-
field('预计金额(万元)', 'amountWan', project.amountWan, { number: true }) +
|
|
1941
|
-
field('项目类型', 'pocType', project.pocType, { enum: DATA.enums.pocType }) +
|
|
1942
|
-
field('阶段', 'stage', project.stage, { enum: DATA.enums.stage, readonly: true, help: '阶段由 Gate 评审推进,不能在这里改。' }) +
|
|
1943
|
-
field('状态', 'status', project.status, { enum: DATA.enums.status, readonly: true, help: '暂停/关闭请走评审流程。' }) +
|
|
1944
|
-
field('进入阶段日期', 'stageSince', project.stageSince, { date: true, help: '不填就算不出停滞天数。' }) +
|
|
1945
|
-
field('负责人(我方)', 'owner', project.owner, { required: true }) +
|
|
1946
|
-
field('销售', 'sales', project.sales, {}) +
|
|
1947
|
-
field('客户业务决策人', 'execSponsor', project.execSponsor, {}) +
|
|
1948
|
-
'</div></section>';
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
/**
|
|
1952
|
-
* The project snapshot: where this project actually stands, at a glance.
|
|
1953
|
-
*
|
|
1954
|
-
* The complaint that drove this block was "通过这个表单看项目的时候,情况好像也看不太
|
|
1955
|
-
* 清楚". The banner showed a title and three pills; everything else a reader needs
|
|
1956
|
-
* to orient — how far G0 has got, whether a plan exists, how many rounds have
|
|
1957
|
-
* been recorded and how stale the newest one is — was either scattered across
|
|
1958
|
-
* sections or missing entirely.
|
|
1959
|
-
*
|
|
1960
|
-
* So this is a five-cell strip of FACTS, each a number plus its meaning. It is
|
|
1961
|
-
* read-only, sits directly under the banner, and is the same information the
|
|
1962
|
-
* dashboard's own card would show. Deliberately not editable: it is orientation,
|
|
1963
|
-
* not a task.
|
|
1964
|
-
*/
|
|
1965
|
-
function snapshotCard(project) {
|
|
1966
|
-
var g0Filled = 0;
|
|
1967
|
-
for (var i = 0; i < DATA.g0Fields.length; i += 1) {
|
|
1968
|
-
if (text(project.gate0[DATA.g0Fields[i].key]).trim() !== '') g0Filled += 1;
|
|
1969
|
-
}
|
|
1970
|
-
if (text(project.techOwner).trim() !== '') g0Filled += 1;
|
|
1971
|
-
var g0Tone = g0Filled === 5 ? 'ok' : g0Filled === 0 ? 'warn' : 'info';
|
|
1972
|
-
|
|
1973
|
-
var crit = project.plan.criteria.length;
|
|
1974
|
-
var scn = project.plan.scenarios.length;
|
|
1975
|
-
var planTone = (crit >= 2 && crit <= 3 && scn >= 3 && scn <= 5) ? 'ok'
|
|
1976
|
-
: (crit === 0 && scn === 0) ? 'muted' : 'warn';
|
|
1977
|
-
var planValue = crit === 0 && scn === 0
|
|
1978
|
-
? '还没有计划'
|
|
1979
|
-
: '指标 ' + crit + ' · 场景 ' + scn;
|
|
1980
|
-
|
|
1981
|
-
var rounds = project.existingProgressCount;
|
|
1982
|
-
var newest = project.history && project.history.length > 0 ? project.history[0] : null;
|
|
1983
|
-
var roundTone = rounds === 0 ? 'warn' : 'ok';
|
|
1984
|
-
var roundValue = rounds === 0 ? '还没有进展记录' : '最近 ' + (newest && newest.date ? newest.date : '无日期');
|
|
1985
|
-
|
|
1986
|
-
var conclusion = text(project.gate0.conclusion).trim();
|
|
1987
|
-
var gateValue = conclusion === '' ? '待评审' : conclusion;
|
|
1988
|
-
var gateTone = conclusion === '通过' ? 'ok' : conclusion === '' ? 'muted' : 'warn';
|
|
1989
|
-
|
|
1990
|
-
var amount = text(project.amountWan).trim();
|
|
1991
|
-
var amountValue = amount === '' ? '未填' : amount + ' 万';
|
|
1992
|
-
|
|
1993
|
-
function cell(label, value, tone) {
|
|
1994
|
-
return '<div class="snap-cell" data-tone="' + tone + '">' +
|
|
1995
|
-
'<span class="snap-label">' + escapeHtml(label) + '</span>' +
|
|
1996
|
-
'<span class="snap-value">' + escapeHtml(value) + '</span></div>';
|
|
1997
|
-
}
|
|
1998
|
-
return '<section class="snapshot">' +
|
|
1999
|
-
cell('Gate 0 五必填', g0Filled + ' / 5', g0Tone) +
|
|
2000
|
-
cell('G0 评审结论', gateValue, gateTone) +
|
|
2001
|
-
cell('方案', planValue, planTone) +
|
|
2002
|
-
cell('进展', rounds + ' 轮 · ' + roundValue, roundTone) +
|
|
2003
|
-
cell('金额', amountValue, 'muted') +
|
|
2004
|
-
'</section>';
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
/**
|
|
2009
|
-
* "What is still missing" — and only that.
|
|
2010
|
-
*
|
|
2011
|
-
* This replaces a three-cell readiness band that restated the snapshot (G0 count,
|
|
2012
|
-
* plan counts) and added two clock hints. Restating the same numbers twice on one
|
|
2013
|
-
* screen is what makes a form feel noisy, so the snapshot owns the facts and this
|
|
2014
|
-
* strip owns the one thing facts cannot say: **what to do next.**
|
|
2015
|
-
*
|
|
2016
|
-
* Empty by design when nothing is actionable. A strip that always shows something
|
|
2017
|
-
* trains people to ignore it.
|
|
2018
|
-
*/
|
|
2019
|
-
function missingCard(project, canEdit) {
|
|
2020
|
-
var editable = canEdit || {};
|
|
2021
|
-
var notes = [];
|
|
2022
|
-
|
|
2023
|
-
if (text(project.stageSince).trim() === '' && (editable.identity || DATA.mode === 'blank')) {
|
|
2024
|
-
notes.push('「进入阶段日期」空着,台账算不出这个项目停滞了多久。');
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
var g0Filled = 0;
|
|
2028
|
-
for (var i = 0; i < DATA.g0Fields.length; i += 1) {
|
|
2029
|
-
if (text(project.gate0[DATA.g0Fields[i].key]).trim() !== '') g0Filled += 1;
|
|
2030
|
-
}
|
|
2031
|
-
if (text(project.techOwner).trim() !== '') g0Filled += 1;
|
|
2032
|
-
if (g0Filled < 5 && g0Filled > 0 && !editable.gate0) {
|
|
2033
|
-
// Not this page's job, but the person should know their round will land on a
|
|
2034
|
-
// project whose G0 is still incomplete.
|
|
2035
|
-
notes.push('Gate 0 还缺 ' + (5 - g0Filled) + ' 项,评审前要补齐。');
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
// A plan-stage form is the one place the 2–3 / 3–5 counts are actionable.
|
|
2039
|
-
if (editable.plan) {
|
|
2040
|
-
var crit = project.plan.criteria.length;
|
|
2041
|
-
var scn = project.plan.scenarios.length;
|
|
2042
|
-
if (crit < 2) notes.push('成功指标还差 ' + (2 - crit) + ' 条(要求 2–3)。');
|
|
2043
|
-
else if (crit > 3) notes.push('成功指标 ' + crit + ' 条,超过 3 条上限。');
|
|
2044
|
-
if (scn < 3) notes.push('验证场景还差 ' + (3 - scn) + ' 个(要求 3–5)。');
|
|
2045
|
-
else if (scn > 5) notes.push('验证场景 ' + scn + ' 个,超过 5 个上限。');
|
|
2046
|
-
}
|
|
2047
|
-
|
|
2048
|
-
if (notes.length === 0) return '';
|
|
2049
|
-
var items = '';
|
|
2050
|
-
for (var n = 0; n < notes.length; n += 1) items += '<li>' + escapeHtml(notes[n]) + '</li>';
|
|
2051
|
-
return '<section class="missing"><span class="missing-label">还需要补</span>' +
|
|
2052
|
-
'<ul class="missing-list">' + items + '</ul></section>';
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
/**
|
|
2056
|
-
* The page: banner, snapshot, what-is-missing, then the fixed two columns.
|
|
2057
|
-
*
|
|
2058
|
-
* Commitments left (Gate 0, criteria, scenarios), the record right (identity,
|
|
2059
|
-
* plan narrative, risks, gates), next actions closing across both. That is the
|
|
2060
|
-
* same contract the detail page holds at every gate, so the person filling the
|
|
2061
|
-
* form and the person reading the dashboard are looking at the same layout.
|
|
2062
|
-
*/
|
|
2063
|
-
function render() {
|
|
2064
|
-
var project = current();
|
|
2065
|
-
var title = project.name || project.pocId || '新建项目';
|
|
2066
|
-
var meta = [];
|
|
2067
|
-
if (project.pocId) meta.push('<span class="banner-id">' + escapeHtml(project.pocId) + '</span>');
|
|
2068
|
-
var org = [project.system, project.company, project.pocType].filter(function (item) { return text(item).trim() !== ''; });
|
|
2069
|
-
if (org.length) meta.push('<span>' + escapeHtml(org.join(' · ')) + '</span>');
|
|
2070
|
-
if (text(project.owner).trim() !== '') meta.push('<span>我方 Owner ' + escapeHtml(project.owner) + '</span>');
|
|
2071
|
-
|
|
2072
|
-
var pills = '';
|
|
2073
|
-
if (text(project.stage).trim() !== '') pills += '<span class="pill pill-blue"><span class="pill-dot"></span>' + escapeHtml(project.stage) + '</span>';
|
|
2074
|
-
if (text(project.status).trim() !== '') pills += '<span class="pill pill-slate"><span class="pill-dot"></span>' + escapeHtml(project.status) + '</span>';
|
|
2075
|
-
var amount = text(project.amountWan).trim();
|
|
2076
|
-
if (amount !== '') pills += '<span class="pill pill-amber">' + escapeHtml(amount) + ' 万元</span>';
|
|
2077
|
-
|
|
2078
|
-
var switcher = '';
|
|
2079
|
-
if (DATA.projects.length > 1) {
|
|
2080
|
-
switcher = '<div class="banner-step">第 ' + (state.active + 1) + ' / ' + DATA.projects.length + ' 个项目' +
|
|
2081
|
-
' <select class="select" id="projectSwitch" style="width:auto;display:inline-block">';
|
|
2082
|
-
for (var i = 0; i < DATA.projects.length; i += 1) {
|
|
2083
|
-
switcher += '<option value="' + i + '"' + (i === state.active ? ' selected' : '') + '>' +
|
|
2084
|
-
escapeHtml(DATA.projects[i].name || DATA.projects[i].pocId || '未命名') + '</option>';
|
|
2085
|
-
}
|
|
2086
|
-
switcher += '</select></div>';
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
var banner = '<header class="banner">' +
|
|
2090
|
-
'<div class="banner-main">' +
|
|
2091
|
-
'<span class="banner-kicker">POC 信息收集 · ' + intentLabel() + '</span>' +
|
|
2092
|
-
'<h1 class="banner-title">' + escapeHtml(title) + '</h1>' +
|
|
2093
|
-
'<div class="banner-meta">' + meta.join('') + '</div>' +
|
|
2094
|
-
'</div>' +
|
|
2095
|
-
'<div class="banner-side">' +
|
|
2096
|
-
'<div class="banner-pills">' + pills + '</div>' +
|
|
2097
|
-
'<div class="banner-actions"><span class="save-status" id="saveStatus">已就绪</span>' +
|
|
2098
|
-
'<button type="button" class="btn" id="clearBtn">清空草稿</button></div>' +
|
|
2099
|
-
'</div>' +
|
|
2100
|
-
(switcher ? '<nav class="banner-nav">' + switcher + '</nav>' : '') +
|
|
2101
|
-
'</header>';
|
|
2102
|
-
|
|
2103
|
-
// Which sections this page is about, resolved on the Host from the intent
|
|
2104
|
-
// and the project's stage. Everything outside 'editable' is shown collapsed
|
|
2105
|
-
// and read-only, so a colleague adding a progress round never scrolls past
|
|
2106
|
-
// twenty fields they are not editing.
|
|
2107
|
-
var plan_ = DATA.sections[state.active] || { editable: ['identity', 'gate0', 'plan', 'progress'], context: [] };
|
|
2108
|
-
var canEdit = {};
|
|
2109
|
-
for (var e = 0; e < plan_.editable.length; e += 1) canEdit[plan_.editable[e]] = true;
|
|
2110
|
-
|
|
2111
|
-
// 'progress' intent is the one-screen case: what has already been reported,
|
|
2112
|
-
// then this round. Deliberately NO snapshot strip and no "what is missing"
|
|
2113
|
-
// banner here — on a single-round receipt, five fact cells and a "Gate 0 还缺
|
|
2114
|
-
// 2 项" nag are noise that push the actual fields down the page. The banner
|
|
2115
|
-
// above already carries stage, status and owner.
|
|
2116
|
-
if (DATA.intent === 'progress') {
|
|
2117
|
-
byId('formBody').innerHTML = banner + historyCard(project) + progressCard(project) + nextCard(project);
|
|
2118
|
-
bindSwitch();
|
|
2119
|
-
markFooter();
|
|
2120
|
-
return;
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
var body = banner + snapshotCard(project) + missingCard(project, canEdit);
|
|
2124
|
-
|
|
2125
|
-
var left = '';
|
|
2126
|
-
if (canEdit.gate0) left += g0Card(project); else left += contextGate0(project);
|
|
2127
|
-
|
|
2128
|
-
// Read-only context is driven by the Host's resolved 'context' list, NOT by
|
|
2129
|
-
// "intent !== new". The old check was the bug behind "什么都能填、什么都能改":
|
|
2130
|
-
// a G0 supplement rendered a read-only PLAN block for a plan that does not
|
|
2131
|
-
// exist yet, which both invented a failure ("指标 0,要求 2–3") and told the
|
|
2132
|
-
// colleague they were looking at a stage the project has not reached.
|
|
2133
|
-
var showContext = {};
|
|
2134
|
-
for (var ci = 0; ci < plan_.context.length; ci += 1) showContext[plan_.context[ci]] = true;
|
|
2135
|
-
|
|
2136
|
-
if (canEdit.plan) left += planCard(project);
|
|
2137
|
-
else if (showContext.plan) left += contextPlan(project);
|
|
2138
|
-
|
|
2139
|
-
// The G4 conclusion is the SUBJECT of a G4 form, so it belongs in the wide
|
|
2140
|
-
// left column with the other commitments — not squeezed into the narrow record
|
|
2141
|
-
// column, which left most of the page empty and made the form look broken.
|
|
2142
|
-
if (canEdit.outcome) left += outcomeCard(project);
|
|
2143
|
-
|
|
2144
|
-
var right = '';
|
|
2145
|
-
if (canEdit.identity) right += identityCard(project); else right += contextIdentity(project);
|
|
2146
|
-
if (canEdit.plan) right += planNarrative(project) + riskCard(project);
|
|
2147
|
-
if (canEdit.gate12) right += gateCard(project);
|
|
2148
|
-
|
|
2149
|
-
if (left !== '') body += '<div class="columns"><div class="col">' + left + '</div><div class="col">' + right + '</div></div>';
|
|
2150
|
-
else if (right !== '') body += '<div class="columns"><div class="col"></div><div class="col">' + right + '</div></div>';
|
|
2151
|
-
|
|
2152
|
-
// History sits immediately above the new round: read what happened, then say
|
|
2153
|
-
// what changed. A new project has no history, so the block is simply absent.
|
|
2154
|
-
body += historyCard(project);
|
|
2155
|
-
// On a NEW project the round is optional. A project that has just been
|
|
2156
|
-
// registered may have nothing to report yet, and making this block required
|
|
2157
|
-
// was what pushed the new-project form to roughly 2000px. Collapsed, so it
|
|
2158
|
-
// cannot read as another mandatory section.
|
|
2159
|
-
if (canEdit.progress) {
|
|
2160
|
-
body += progressCard(project) + nextCard(project);
|
|
2161
|
-
} else if (DATA.intent === 'new') {
|
|
2162
|
-
body += '<details class="read-context optional-block">' +
|
|
2163
|
-
'<summary>可选:如果已经有客户动作,顺便登记第一条进展(不填也能提交)</summary>' +
|
|
2164
|
-
progressCard(project) + nextCard(project) + '</details>';
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
byId('formBody').innerHTML = body;
|
|
2168
|
-
bindSwitch();
|
|
2169
|
-
markFooter();
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
|
-
/** Wire the project switcher, if the batch has more than one project. */
|
|
2173
|
-
function bindSwitch() {
|
|
2174
|
-
var switchNode = byId('projectSwitch');
|
|
2175
|
-
if (!switchNode) return;
|
|
2176
|
-
switchNode.addEventListener('change', function (event) {
|
|
2177
|
-
state.active = Number(event.target.value);
|
|
2178
|
-
render();
|
|
2179
|
-
});
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
/** The intent, as a phrase for the banner and the footer. */
|
|
2183
|
-
function intentLabel() {
|
|
2184
|
-
return DATA.intent === 'new' ? '新建项目' : DATA.intent === 'progress' ? '记录进展' : '补充信息';
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
function markFooter() {
|
|
2188
|
-
var info = byId('footerInfo');
|
|
2189
|
-
if (!info) return;
|
|
2190
|
-
info.textContent = intentLabel() + ' · 共 ' + DATA.projects.length + ' 个项目 · 草稿自动保存在本机浏览器';
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
/**
|
|
2194
|
-
* Read-only Gate 0 summary: a completed stage is context, not a task.
|
|
2195
|
-
*
|
|
2196
|
-
* It used to render only "五必填 3 / 5" and a sentence — the actual answers were
|
|
2197
|
-
* never shown. That is the "看不清项目情况" complaint in its purest form: a
|
|
2198
|
-
* colleague supplementing the plan could not read what G0 had already decided,
|
|
2199
|
-
* and a reviewer opening the returned file could not check whether the new round
|
|
2200
|
-
* contradicted it. The answers are now shown in full, collapsed by default so
|
|
2201
|
-
* they inform without pushing the fields-to-fill down the page.
|
|
2202
|
-
*/
|
|
2203
|
-
function contextGate0(project) {
|
|
2204
|
-
var present = 0;
|
|
2205
|
-
for (var i = 0; i < DATA.g0Fields.length; i += 1) {
|
|
2206
|
-
if (text(project.gate0[DATA.g0Fields[i].key]).trim() !== '') present += 1;
|
|
2207
|
-
}
|
|
2208
|
-
if (text(project.techOwner).trim() !== '') present += 1;
|
|
2209
|
-
var tone = present === 5 ? 'badge-ok' : 'badge-warn';
|
|
2210
|
-
|
|
2211
|
-
var rows = '';
|
|
2212
|
-
for (var j = 0; j < DATA.g0Fields.length; j += 1) {
|
|
2213
|
-
rows += readPair(DATA.g0Fields[j].label, project.gate0[DATA.g0Fields[j].key]);
|
|
2214
|
-
}
|
|
2215
|
-
rows += readPair('客户技术责任人', project.techOwner);
|
|
2216
|
-
rows += readPair('主要竞争对手', project.gate0.competitor);
|
|
2217
|
-
rows += readPair('G0 评审结论', project.gate0.conclusion);
|
|
2218
|
-
rows += readPair('G0 评审人', project.gate0.reviewer);
|
|
2219
|
-
rows += readPair('评审日期', project.gate0.reviewed_at);
|
|
2220
|
-
|
|
2221
|
-
return '<section class="sec">' +
|
|
2222
|
-
'<header class="sec-head"><h2 class="sec-title">Gate 0 · 值不值得做</h2>' +
|
|
2223
|
-
'<span class="sec-kicker"><span class="badge ' + tone + '">五必填 ' + present + ' / 5</span></span></header>' +
|
|
2224
|
-
'<details class="read-context"><summary>已完成的立项内容(只读,点开查看)</summary>' +
|
|
2225
|
-
'<dl class="read-grid">' + rows + '</dl></details>' +
|
|
2226
|
-
'<p class="sec-hint">要改 Gate 0,请单独导出「补充信息」表单并选择 G0 阶段。</p>' +
|
|
2227
|
-
'</section>';
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
/** One label/value row in a read-only context block. */
|
|
2231
|
-
function readPair(label, value) {
|
|
2232
|
-
var raw = text(value).trim();
|
|
2233
|
-
return '<div class="read-pair"><dt>' + escapeHtml(label) + '</dt>' +
|
|
2234
|
-
'<dd' + (raw === '' ? ' class="read-empty"' : '') + '>' + (raw === '' ? '未填写' : escapeHtml(raw)) + '</dd></div>';
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
/**
|
|
2238
|
-
* Read-only plan summary.
|
|
2239
|
-
*
|
|
2240
|
-
* Same defect as the Gate 0 block: it reported counts ("指标 0 · 场景 0") but not
|
|
2241
|
-
* the plan itself. A G3 colleague recording a proof needs to know which scenarios
|
|
2242
|
-
* and criteria the proof is supposed to attach to — that is the whole point of
|
|
2243
|
-
* the pickers below it. Counts alone told them nothing.
|
|
2244
|
-
*/
|
|
2245
|
-
function contextPlan(project) {
|
|
2246
|
-
var crit = project.plan.criteria.length;
|
|
2247
|
-
var scn = project.plan.scenarios.length;
|
|
2248
|
-
var rows = '';
|
|
2249
|
-
rows += readPair('客户核心痛点', project.plan.customer_pain);
|
|
2250
|
-
rows += readPair('期望客户认可什么', project.plan.expected_recognition);
|
|
2251
|
-
rows += readPair('我方优势 / 赢点', project.plan.our_edge);
|
|
2252
|
-
rows += readPair('计划开始', project.plan.timeline_start);
|
|
2253
|
-
rows += readPair('计划结束', project.plan.timeline_end);
|
|
2254
|
-
rows += readPair('G1 结论', project.plan.gate1_conclusion);
|
|
2255
|
-
rows += readPair('G2 Ready', project.plan.gate2_ready);
|
|
2256
|
-
|
|
2257
|
-
var lists = '';
|
|
2258
|
-
if (crit > 0) {
|
|
2259
|
-
var critItems = '';
|
|
2260
|
-
for (var c = 0; c < crit; c += 1) {
|
|
2261
|
-
var criterion = project.plan.criteria[c];
|
|
2262
|
-
critItems += '<li><span class="read-id">' + escapeHtml(criterion.id) + '</span>' +
|
|
2263
|
-
escapeHtml(criterion.name) +
|
|
2264
|
-
(text(criterion.target).trim() === '' ? '' : '<span class="read-dim"> · 目标 ' + escapeHtml(criterion.target) + '</span>') +
|
|
2265
|
-
'</li>';
|
|
2266
|
-
}
|
|
2267
|
-
lists += '<div class="read-list-block"><h3>关键成功指标</h3><ul class="read-list">' + critItems + '</ul></div>';
|
|
2268
|
-
}
|
|
2269
|
-
if (scn > 0) {
|
|
2270
|
-
var scnItems = '';
|
|
2271
|
-
for (var s = 0; s < scn; s += 1) {
|
|
2272
|
-
var scenario = project.plan.scenarios[s];
|
|
2273
|
-
scnItems += '<li><span class="read-id">' + escapeHtml(scenario.id) + '</span>' + escapeHtml(scenario.name) +
|
|
2274
|
-
(text(scenario.goal).trim() === '' ? '' : '<span class="read-dim"> · ' + escapeHtml(scenario.goal) + '</span>') +
|
|
2275
|
-
'</li>';
|
|
2276
|
-
}
|
|
2277
|
-
lists += '<div class="read-list-block"><h3>验证场景</h3><ul class="read-list">' + scnItems + '</ul></div>';
|
|
2278
|
-
}
|
|
2279
|
-
if (project.plan.risks.length > 0) {
|
|
2280
|
-
var riskItems = '';
|
|
2281
|
-
for (var r = 0; r < project.plan.risks.length; r += 1) {
|
|
2282
|
-
var risk = project.plan.risks[r];
|
|
2283
|
-
riskItems += '<li>' + escapeHtml(risk.name) +
|
|
2284
|
-
(text(risk.level).trim() === '' ? '' : '<span class="read-dim"> · ' + escapeHtml(risk.level) + '</span>') +
|
|
2285
|
-
(text(risk.mitigation).trim() === '' ? '' : '<span class="read-dim"> · 应对 ' + escapeHtml(risk.mitigation) + '</span>') +
|
|
2286
|
-
'</li>';
|
|
2287
|
-
}
|
|
2288
|
-
lists += '<div class="read-list-block"><h3>风险</h3><ul class="read-list">' + riskItems + '</ul></div>';
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
var body = rows + lists;
|
|
2292
|
-
if (text(body).trim() === '') {
|
|
2293
|
-
return '<section class="sec">' +
|
|
2294
|
-
'<header class="sec-head"><h2 class="sec-title">方案 · 只读</h2>' +
|
|
2295
|
-
'<span class="sec-kicker">还没有方案</span></header>' +
|
|
2296
|
-
'<p class="sec-hint">这个项目还没有填过计划。方案在 G1 阶段补充。</p></section>';
|
|
2297
|
-
}
|
|
2298
|
-
return '<section class="sec">' +
|
|
2299
|
-
'<header class="sec-head"><h2 class="sec-title">方案 · 已确认内容</h2>' +
|
|
2300
|
-
'<span class="sec-kicker">指标 ' + crit + ' · 场景 ' + scn + '</span></header>' +
|
|
2301
|
-
'<details class="read-context"><summary>方案详情(只读,点开查看)</summary>' +
|
|
2302
|
-
'<dl class="read-grid">' + rows + '</dl>' + lists + '</details>' +
|
|
2303
|
-
'<p class="sec-hint">要改计划,请导出「补充信息」表单并选择 G1 / G2 阶段。</p>' +
|
|
2304
|
-
'</section>';
|
|
2305
|
-
}
|
|
2306
|
-
|
|
2307
|
-
/**
|
|
2308
|
-
* The recorded rounds, newest first, read-only.
|
|
2309
|
-
*
|
|
2310
|
-
* The single most useful thing the form can show: what has already been
|
|
2311
|
-
* reported. Without it a colleague writes "已完成压测" for the third week
|
|
2312
|
-
* running, and the reviewer cannot tell what is new. Shown collapsed so it
|
|
2313
|
-
* informs the new entry without pushing it off screen.
|
|
2314
|
-
*/
|
|
2315
|
-
function historyCard(project) {
|
|
2316
|
-
var history = project.history || [];
|
|
2317
|
-
if (history.length === 0) return '';
|
|
2318
|
-
var rows = '';
|
|
2319
|
-
for (var i = 0; i < history.length; i += 1) {
|
|
2320
|
-
var entry = history[i];
|
|
2321
|
-
var head = '<div class="hist-head">' +
|
|
2322
|
-
'<span class="hist-seq">#' + (entry.seq === null ? '?' : entry.seq) + '</span>' +
|
|
2323
|
-
'<span class="hist-date">' + escapeHtml(entry.date || '无日期') + '</span>' +
|
|
2324
|
-
(entry.type ? '<span class="hist-type">' + escapeHtml(entry.type) + '</span>' : '') +
|
|
2325
|
-
(entry.change ? '<span class="hist-change">' + escapeHtml(entry.change) + '</span>' : '') +
|
|
2326
|
-
(entry.completion ? '<span class="hist-pct">' + escapeHtml(entry.completion) + '</span>' : '') +
|
|
2327
|
-
'</div>';
|
|
2328
|
-
var body = '';
|
|
2329
|
-
if (entry.actual) body += '<p class="hist-actual">' + escapeHtml(entry.actual) + '</p>';
|
|
2330
|
-
var meta = [];
|
|
2331
|
-
if (entry.evidence.length) meta.push('证据 ' + entry.evidence.length + ' 条');
|
|
2332
|
-
if (entry.syncedWith) meta.push('同步 ' + entry.syncedWith);
|
|
2333
|
-
if (entry.recognition) meta.push('客户' + entry.recognition);
|
|
2334
|
-
if (entry.nextGoal) meta.push('下一步 ' + entry.nextGoal);
|
|
2335
|
-
if (entry.nextDeadline) meta.push('截止 ' + entry.nextDeadline);
|
|
2336
|
-
if (meta.length) body += '<p class="hist-meta">' + escapeHtml(meta.join(' · ')) + '</p>';
|
|
2337
|
-
rows += '<li class="hist-item">' + head + body + '</li>';
|
|
2338
|
-
}
|
|
2339
|
-
var more = project.existingProgressCount > history.length
|
|
2340
|
-
? '<p class="sec-hint">仅显示最近 ' + history.length + ' 条,共 ' + project.existingProgressCount + ' 条。</p>'
|
|
2341
|
-
: '';
|
|
2342
|
-
return '<section class="sec">' +
|
|
2343
|
-
'<header class="sec-head"><h2 class="sec-title">已有进展</h2>' +
|
|
2344
|
-
'<span class="sec-kicker">共 ' + project.existingProgressCount + ' 条 · 只读</span></header>' +
|
|
2345
|
-
'<details class="read-context" open><summary>最近 ' + history.length + ' 条(只读)</summary>' +
|
|
2346
|
-
'<ol class="hist-list">' + rows + '</ol></details>' + more +
|
|
2347
|
-
'</section>';
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
|
-
/** Read-only identity summary: the fields a colleague must not re-edit here. */
|
|
2351
|
-
function contextIdentity(project) {
|
|
2352
|
-
var bits = [];
|
|
2353
|
-
if (project.pocId) bits.push(project.pocId);
|
|
2354
|
-
if (project.system) bits.push(project.system);
|
|
2355
|
-
if (project.company) bits.push(project.company);
|
|
2356
|
-
if (project.owner) bits.push('Owner ' + project.owner);
|
|
2357
|
-
return '<section class="sec">' +
|
|
2358
|
-
'<header class="sec-head"><h2 class="sec-title">基本信息 · 只读</h2></header>' +
|
|
2359
|
-
'<p class="sec-hint">' + escapeHtml(bits.join(' · ') || '未填写') + '</p>' +
|
|
2360
|
-
'</section>';
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
/** The G4 block: conclusion and conversion, which no other stage asks for. */
|
|
2364
|
-
function outcomeCard(project) {
|
|
2365
|
-
var o = project.outcome || {};
|
|
2366
|
-
return '<section class="sec">' +
|
|
2367
|
-
'<header class="sec-head"><h2 class="sec-title">结论与转化</h2>' +
|
|
2368
|
-
'<span class="sec-kicker">G4</span></header>' +
|
|
2369
|
-
'<p class="sec-hint">这一阶段要回答:证明了什么、客户认可什么、下一步业务动作是什么。</p>' +
|
|
2370
|
-
field('我们证明了什么', 'outcome.conclusion.proved', o.proved || '', { multiline: true }) +
|
|
2371
|
-
field('客户认可了什么', 'outcome.conclusion.recognized', o.recognized || '', { multiline: true }) +
|
|
2372
|
-
field('下一步业务动作', 'outcome.conclusion.next_business', o.next_business || '', { multiline: true }) +
|
|
2373
|
-
field('我方证据', 'outcome.our_proof', o.our_proof || '', { multiline: true }) +
|
|
2374
|
-
'<div class="grid-2">' +
|
|
2375
|
-
field('目标达成', 'outcome.achievement', o.achievement || '', { enum: DATA.enums.achievement }) +
|
|
2376
|
-
field('客户认可', 'outcome.customer_recognition', o.customer_recognition || '', { enum: DATA.enums.recognition }) +
|
|
2377
|
-
field('Next Milestone', 'outcome.business.milestone', o.milestone || '') +
|
|
2378
|
-
field('业务负责人', 'outcome.business.owner', o.businessOwner || '') +
|
|
2379
|
-
field('业务截止', 'outcome.business.deadline', o.businessDeadline || '', { date: true }) +
|
|
2380
|
-
field('业务状态', 'outcome.business.status', o.businessStatus || '', { enum: DATA.enums.businessStatus }) +
|
|
2381
|
-
'</div>' +
|
|
2382
|
-
field('总体结论', 'outcome.overall', o.overall || '', { multiline: true }) +
|
|
2383
|
-
'</section>';
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
function setPathOn(project, path, value) {
|
|
2387
|
-
// "progress.*" paths address the pending entry; everything else addresses
|
|
2388
|
-
// the project itself. Keeping the two apart is what stops a progress edit
|
|
2389
|
-
// from overwriting a plan field with a same-named key.
|
|
2390
|
-
if (path.indexOf('progress.') === 0) {
|
|
2391
|
-
setPath({ progress: project.progress }, path, value);
|
|
2392
|
-
return;
|
|
2393
|
-
}
|
|
2394
|
-
setPath(project, path, value);
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
function bind() {
|
|
2398
|
-
document.addEventListener('input', function (event) {
|
|
2399
|
-
var target = event.target;
|
|
2400
|
-
if (!target || !target.getAttribute) return;
|
|
2401
|
-
var path = target.getAttribute('data-path');
|
|
2402
|
-
if (!path) return;
|
|
2403
|
-
setPathOn(current(), path, target.value);
|
|
2404
|
-
scheduleSave();
|
|
2405
|
-
});
|
|
2406
|
-
document.addEventListener('change', function (event) {
|
|
2407
|
-
var target = event.target;
|
|
2408
|
-
if (!target || !target.getAttribute) return;
|
|
2409
|
-
// A picker checkbox writes an id LIST, not a scalar, so it takes its own
|
|
2410
|
-
// branch: routing it through setPath would replace the array with "on".
|
|
2411
|
-
var pickPath = target.getAttribute('data-pick');
|
|
2412
|
-
if (pickPath) {
|
|
2413
|
-
var entry = current().progress;
|
|
2414
|
-
var list = pickPath === 'progress.scenarioIds' ? entry.scenarioIds : entry.criteriaIds;
|
|
2415
|
-
var id = target.value;
|
|
2416
|
-
var at = list.indexOf(id);
|
|
2417
|
-
if (target.checked && at < 0) list.push(id);
|
|
2418
|
-
if (!target.checked && at >= 0) list.splice(at, 1);
|
|
2419
|
-
scheduleSave();
|
|
2420
|
-
return;
|
|
2421
|
-
}
|
|
2422
|
-
var path = target.getAttribute('data-path');
|
|
2423
|
-
if (!path) return;
|
|
2424
|
-
setPathOn(current(), path, target.value);
|
|
2425
|
-
scheduleSave();
|
|
2426
|
-
if (target.tagName === 'SELECT') render();
|
|
2427
|
-
});
|
|
2428
|
-
document.addEventListener('click', function (event) {
|
|
2429
|
-
var target = event.target;
|
|
2430
|
-
if (!target || !target.getAttribute) return;
|
|
2431
|
-
var project = current();
|
|
2432
|
-
var addKey = target.getAttribute('data-add');
|
|
2433
|
-
var removeKey = target.getAttribute('data-remove');
|
|
2434
|
-
if (addKey) {
|
|
2435
|
-
if (addKey === 'criteria') project.plan.criteria.push(nextRow('cri', project.plan.criteria, { name: '', metric: '', baseline: '', target: '' }));
|
|
2436
|
-
if (addKey === 'scenarios') project.plan.scenarios.push(nextRow('scn', project.plan.scenarios, { name: '', goal: '' }));
|
|
2437
|
-
if (addKey === 'risks') project.plan.risks.push({ name: '', level: '', mitigation: '' });
|
|
2438
|
-
if (addKey === 'evidence') project.progress.evidence.push({ title: '', link: '', type: '' });
|
|
2439
|
-
scheduleSave();
|
|
2440
|
-
render();
|
|
2441
|
-
return;
|
|
2442
|
-
}
|
|
2443
|
-
if (removeKey) {
|
|
2444
|
-
var index = Number(target.getAttribute('data-index'));
|
|
2445
|
-
if (removeKey === 'criteria') project.plan.criteria.splice(index, 1);
|
|
2446
|
-
if (removeKey === 'scenarios') project.plan.scenarios.splice(index, 1);
|
|
2447
|
-
if (removeKey === 'risks') project.plan.risks.splice(index, 1);
|
|
2448
|
-
if (removeKey === 'evidence') project.progress.evidence.splice(index, 1);
|
|
2449
|
-
scheduleSave();
|
|
2450
|
-
render();
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
|
-
/**
|
|
2456
|
-
* Serialize one project to the v3 YAML shape.
|
|
2457
|
-
*
|
|
2458
|
-
* This mirrors the Host's own projectToYaml on purpose: the browser cannot call
|
|
2459
|
-
* it, and the file a colleague downloads has to be byte-compatible with what
|
|
2460
|
-
* the plugin's own generator would emit. The tests pin both sides to the same
|
|
2461
|
-
* output, so a drift shows up as a failure rather than as an unreadable file.
|
|
2462
|
-
*/
|
|
2463
|
-
function toYaml(project) {
|
|
2464
|
-
var lines = [];
|
|
2465
|
-
function scalar(value) {
|
|
2466
|
-
if (value === null || value === undefined || value === '') return 'null';
|
|
2467
|
-
var raw = String(value);
|
|
2468
|
-
if (/[:#\\n"']/.test(raw) || raw !== raw.trim()) return JSON.stringify(raw);
|
|
2469
|
-
return raw;
|
|
2470
|
-
}
|
|
2471
|
-
function push(key, value, indent) {
|
|
2472
|
-
var pad = new Array(indent + 1).join(' ');
|
|
2473
|
-
lines.push(pad + key + ': ' + scalar(value));
|
|
2474
|
-
}
|
|
2475
|
-
push('poc_id', project.pocId, 0);
|
|
2476
|
-
push('name', project.name, 0);
|
|
2477
|
-
lines.push('org:');
|
|
2478
|
-
push('system', project.system, 2);
|
|
2479
|
-
push('company', project.company, 2);
|
|
2480
|
-
push('department', project.department, 2);
|
|
2481
|
-
push('amount_wan', project.amountWan === '' ? '' : Number(project.amountWan), 0);
|
|
2482
|
-
push('poc_type', project.pocType, 0);
|
|
2483
|
-
push('owner', project.owner, 0);
|
|
2484
|
-
push('sales', project.sales, 0);
|
|
2485
|
-
push('tech_owner', project.techOwner, 0);
|
|
2486
|
-
push('exec_sponsor', project.execSponsor, 0);
|
|
2487
|
-
push('stage', project.stage, 0);
|
|
2488
|
-
push('status', project.status, 0);
|
|
2489
|
-
push('stage_since', project.stageSince, 0);
|
|
2490
|
-
lines.push('gate0:');
|
|
2491
|
-
push('why_customer', project.gate0.why_customer, 2);
|
|
2492
|
-
push('why_us', project.gate0.why_us, 2);
|
|
2493
|
-
push('decision_chain', project.gate0.decision_chain, 2);
|
|
2494
|
-
push('post_poc_decision', project.gate0.post_poc_decision, 2);
|
|
2495
|
-
push('competitor', project.gate0.competitor, 2);
|
|
2496
|
-
lines.push(' review:');
|
|
2497
|
-
push('conclusion', project.gate0.conclusion, 4);
|
|
2498
|
-
push('reviewer', project.gate0.reviewer, 4);
|
|
2499
|
-
push('reviewed_at', project.gate0.reviewed_at, 4);
|
|
2500
|
-
lines.push('plan:');
|
|
2501
|
-
push('customer_pain', project.plan.customer_pain, 2);
|
|
2502
|
-
push('expected_recognition', project.plan.expected_recognition, 2);
|
|
2503
|
-
push('our_edge', project.plan.our_edge, 2);
|
|
2504
|
-
lines.push(' timeline:');
|
|
2505
|
-
push('start', project.plan.timeline_start, 4);
|
|
2506
|
-
push('end', project.plan.timeline_end, 4);
|
|
2507
|
-
lines.push(' gate1:');
|
|
2508
|
-
push('conclusion', project.plan.gate1_conclusion, 4);
|
|
2509
|
-
lines.push(' gate2:');
|
|
2510
|
-
push('ready', project.plan.gate2_ready, 4);
|
|
2511
|
-
var i;
|
|
2512
|
-
lines.push(' criteria:');
|
|
2513
|
-
var criteria = project.plan.criteria.filter(function (item) { return text(item.name).trim() !== ''; });
|
|
2514
|
-
if (criteria.length === 0) { lines[lines.length - 1] = ' criteria: []'; }
|
|
2515
|
-
for (i = 0; i < criteria.length; i += 1) {
|
|
2516
|
-
// v3.1: the id comes first because it is the join key evidence uses.
|
|
2517
|
-
lines.push(' - id: ' + scalar(criteria[i].id));
|
|
2518
|
-
lines.push(' name: ' + scalar(criteria[i].name));
|
|
2519
|
-
lines.push(' metric: ' + scalar(criteria[i].metric));
|
|
2520
|
-
lines.push(' baseline: ' + scalar(criteria[i].baseline));
|
|
2521
|
-
lines.push(' target: ' + scalar(criteria[i].target));
|
|
2522
|
-
}
|
|
2523
|
-
var scenarios = project.plan.scenarios.filter(function (item) { return text(item.name).trim() !== ''; });
|
|
2524
|
-
lines.push(' scenarios:' + (scenarios.length === 0 ? ' []' : ''));
|
|
2525
|
-
for (i = 0; i < scenarios.length; i += 1) {
|
|
2526
|
-
lines.push(' - id: ' + scalar(scenarios[i].id));
|
|
2527
|
-
lines.push(' name: ' + scalar(scenarios[i].name));
|
|
2528
|
-
lines.push(' goal: ' + scalar(scenarios[i].goal));
|
|
2529
|
-
}
|
|
2530
|
-
var risks = project.plan.risks.filter(function (item) { return text(item.name).trim() !== ''; });
|
|
2531
|
-
lines.push(' risks:' + (risks.length === 0 ? ' []' : ''));
|
|
2532
|
-
for (i = 0; i < risks.length; i += 1) {
|
|
2533
|
-
lines.push(' - name: ' + scalar(risks[i].name));
|
|
2534
|
-
lines.push(' level: ' + scalar(risks[i].level));
|
|
2535
|
-
lines.push(' mitigation: ' + scalar(risks[i].mitigation));
|
|
2536
|
-
}
|
|
2537
|
-
var entry = project.progress;
|
|
2538
|
-
var hasEntry = text(entry.date) !== '' || text(entry.actual) !== '' || text(entry.goal) !== '';
|
|
2539
|
-
lines.push('progress:' + (hasEntry ? '' : ' []'));
|
|
2540
|
-
if (hasEntry) {
|
|
2541
|
-
lines.push(' - seq: ' + (entry.seq === null ? 'null' : entry.seq));
|
|
2542
|
-
lines.push(' date: ' + scalar(entry.date));
|
|
2543
|
-
lines.push(' type: ' + scalar(entry.type));
|
|
2544
|
-
lines.push(' change: ' + scalar(entry.change));
|
|
2545
|
-
lines.push(' goal: ' + scalar(entry.goal));
|
|
2546
|
-
var scnIds = entry.scenarioIds.filter(function (item) { return text(item).trim() !== ''; });
|
|
2547
|
-
lines.push(' scenario_ids:' + (scnIds.length === 0 ? ' []' : ''));
|
|
2548
|
-
for (i = 0; i < scnIds.length; i += 1) lines.push(' - ' + scalar(scnIds[i]));
|
|
2549
|
-
var criIds = entry.criteriaIds.filter(function (item) { return text(item).trim() !== ''; });
|
|
2550
|
-
lines.push(' criteria_ids:' + (criIds.length === 0 ? ' []' : ''));
|
|
2551
|
-
for (i = 0; i < criIds.length; i += 1) lines.push(' - ' + scalar(criIds[i]));
|
|
2552
|
-
lines.push(' actual: ' + scalar(entry.actual));
|
|
2553
|
-
lines.push(' completion: ' + scalar(entry.completion));
|
|
2554
|
-
var evidence = entry.evidence.filter(function (item) { return text(item.title).trim() !== ''; });
|
|
2555
|
-
lines.push(' evidence:' + (evidence.length === 0 ? ' []' : ''));
|
|
2556
|
-
for (i = 0; i < evidence.length; i += 1) {
|
|
2557
|
-
lines.push(' - title: ' + scalar(evidence[i].title));
|
|
2558
|
-
lines.push(' link: ' + scalar(evidence[i].link));
|
|
2559
|
-
lines.push(' type: ' + scalar(evidence[i].type));
|
|
2560
|
-
}
|
|
2561
|
-
lines.push(' customer:');
|
|
2562
|
-
lines.push(' synced_with: ' + scalar(entry.customer.synced_with));
|
|
2563
|
-
lines.push(' feedback: ' + scalar(entry.customer.feedback));
|
|
2564
|
-
lines.push(' recognition: ' + scalar(entry.customer.recognition));
|
|
2565
|
-
lines.push(' gate3_1: ' + scalar(entry.gate3_1));
|
|
2566
|
-
lines.push(' gate3_2: ' + scalar(entry.gate3_2));
|
|
2567
|
-
lines.push(' next:');
|
|
2568
|
-
lines.push(' goal: ' + scalar(entry.next.goal));
|
|
2569
|
-
lines.push(' owner: ' + scalar(entry.next.owner));
|
|
2570
|
-
lines.push(' deadline: ' + scalar(entry.next.deadline));
|
|
2571
|
-
}
|
|
2572
|
-
return lines.join('\\n') + '\\n';
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
/**
|
|
2576
|
-
* Serialize the whole page to the change document a colleague sends back.
|
|
2577
|
-
*
|
|
2578
|
-
* This is the DOWNLOAD format. It carries only the fields a human filled in,
|
|
2579
|
-
* never the ledger's derived values: 'gate0.missing', 'gate0.complete',
|
|
2580
|
-
* 'priority' and the per-scenario statuses are computed by 'tools/derive.mjs'
|
|
2581
|
-
* and asserted by CI, so a form that wrote them would be either wrong or
|
|
2582
|
-
* overwritten. 'poc-submit' merges this object into the existing project file
|
|
2583
|
-
* and leaves everything else — including 'gate_decisions', existing progress
|
|
2584
|
-
* history and gate verdicts — untouched.
|
|
2585
|
-
*/
|
|
2586
|
-
function toChangeDocument() {
|
|
2587
|
-
var changes = [];
|
|
2588
|
-
for (var i = 0; i < DATA.projects.length; i += 1) {
|
|
2589
|
-
changes.push(changeSetOf(DATA.projects[i]));
|
|
2590
|
-
}
|
|
2591
|
-
return {
|
|
2592
|
-
schemaVersion: DATA.schemaVersion,
|
|
2593
|
-
generatedAt: new Date().toISOString(),
|
|
2594
|
-
generatedBy: 'POC 信息收集表单 v3.1',
|
|
2595
|
-
intent: DATA.intent,
|
|
2596
|
-
changes: changes
|
|
2597
|
-
};
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2600
|
-
/** One project's human-authored fields, with '' collapsed to null. */
|
|
2601
|
-
function changeSetOf(project) {
|
|
2602
|
-
function orNull(value) {
|
|
2603
|
-
var raw = text(value).trim();
|
|
2604
|
-
return raw === '' ? null : raw;
|
|
2605
|
-
}
|
|
2606
|
-
// Only the blocks this page let the person edit, mirroring the Host's
|
|
2607
|
-
// projectToChangeSet. Everything else is emitted as null/empty so the merge
|
|
2608
|
-
// step skips it: the page pre-fills from the ledger, and re-sending a
|
|
2609
|
-
// pre-filled value would overwrite a field that changed after export.
|
|
2610
|
-
var plan_ = DATA.sections[state.active] || { editable: ['identity', 'gate0', 'plan', 'progress'] };
|
|
2611
|
-
var scope = {};
|
|
2612
|
-
for (var s = 0; s < plan_.editable.length; s += 1) scope[plan_.editable[s]] = true;
|
|
2613
|
-
if (scope.plan) scope.gate12 = true;
|
|
2614
|
-
// The new-project form offers an OPTIONAL first round. It is not in the
|
|
2615
|
-
// Host's editable list — so it is never required — but it must still be
|
|
2616
|
-
// emitted when the colleague filled it in.
|
|
2617
|
-
if (DATA.intent === 'new') scope.progress = true;
|
|
2618
|
-
function inScope(section) { return scope[section] === true; }
|
|
2619
|
-
|
|
2620
|
-
// The seed snapshot: what these fields held when the form was generated.
|
|
2621
|
-
var base = (DATA.baseline || [])[state.active] || null;
|
|
2622
|
-
function seeded(path) {
|
|
2623
|
-
if (!base) return '';
|
|
2624
|
-
var parts = path.split('.');
|
|
2625
|
-
var node = base;
|
|
2626
|
-
for (var i = 0; i < parts.length; i += 1) {
|
|
2627
|
-
if (node === null || node === undefined) return '';
|
|
2628
|
-
node = node[parts[i]];
|
|
2629
|
-
}
|
|
2630
|
-
return text(node);
|
|
2631
|
-
}
|
|
2632
|
-
/**
|
|
2633
|
-
* A value, or null when it is unchanged or out of scope.
|
|
2634
|
-
*
|
|
2635
|
-
* This diff is the whole reason a returned form is safe to merge: it means
|
|
2636
|
-
* "only what this person edited", not "a snapshot of the project on the day
|
|
2637
|
-
* the form was exported".
|
|
2638
|
-
*/
|
|
2639
|
-
function changed(section, path, value) {
|
|
2640
|
-
if (!inScope(section)) return null;
|
|
2641
|
-
var raw = text(value).trim();
|
|
2642
|
-
if (raw === '') return null;
|
|
2643
|
-
return raw === seeded(path).trim() ? null : raw;
|
|
2644
|
-
}
|
|
2645
|
-
/** A list, or null when it is unchanged as a whole. */
|
|
2646
|
-
function changedList(section, list, baseList) {
|
|
2647
|
-
if (!inScope(section)) return null;
|
|
2648
|
-
if (list.length === 0) return null;
|
|
2649
|
-
if (baseList && JSON.stringify(list) === JSON.stringify(baseList)) return null;
|
|
2650
|
-
return list;
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
|
-
var criteria = [];
|
|
2654
|
-
if (inScope('plan')) for (var i = 0; i < project.plan.criteria.length; i += 1) {
|
|
2655
|
-
var c = project.plan.criteria[i];
|
|
2656
|
-
if (text(c.name).trim() === '') continue;
|
|
2657
|
-
criteria.push({ id: orNull(c.id), name: text(c.name).trim(), metric: orNull(c.metric), baseline: orNull(c.baseline), target: orNull(c.target) });
|
|
2658
|
-
}
|
|
2659
|
-
var scenarios = [];
|
|
2660
|
-
if (inScope('plan')) for (var j = 0; j < project.plan.scenarios.length; j += 1) {
|
|
2661
|
-
var sc = project.plan.scenarios[j];
|
|
2662
|
-
if (text(sc.name).trim() === '') continue;
|
|
2663
|
-
scenarios.push({ id: orNull(sc.id), name: text(sc.name).trim(), goal: orNull(sc.goal) });
|
|
2664
|
-
}
|
|
2665
|
-
var risks = [];
|
|
2666
|
-
if (inScope('plan')) for (var k = 0; k < project.plan.risks.length; k += 1) {
|
|
2667
|
-
var r = project.plan.risks[k];
|
|
2668
|
-
if (text(r.name).trim() === '') continue;
|
|
2669
|
-
risks.push({ name: text(r.name).trim(), level: orNull(r.level), mitigation: orNull(r.mitigation) });
|
|
2670
|
-
}
|
|
2671
|
-
var basePlan = base && base.plan ? base.plan : null;
|
|
2672
|
-
var baseCriteria = basePlan ? basePlan.criteria.filter(function (x) { return text(x.name).trim() !== ''; }).map(function (x) {
|
|
2673
|
-
return { id: orNull(x.id), name: text(x.name).trim(), metric: orNull(x.metric), baseline: orNull(x.baseline), target: orNull(x.target) };
|
|
2674
|
-
}) : null;
|
|
2675
|
-
var baseScenarios = basePlan ? basePlan.scenarios.filter(function (x) { return text(x.name).trim() !== ''; }).map(function (x) {
|
|
2676
|
-
return { id: orNull(x.id), name: text(x.name).trim(), goal: orNull(x.goal) };
|
|
2677
|
-
}) : null;
|
|
2678
|
-
var baseRisks = basePlan ? basePlan.risks.filter(function (x) { return text(x.name).trim() !== ''; }).map(function (x) {
|
|
2679
|
-
return { name: text(x.name).trim(), level: orNull(x.level), mitigation: orNull(x.mitigation) };
|
|
2680
|
-
}) : null;
|
|
2681
|
-
|
|
2682
|
-
var rounds = [];
|
|
2683
|
-
var entry = project.progress;
|
|
2684
|
-
var touched = text(entry.date).trim() !== '' || text(entry.actual).trim() !== '' || text(entry.goal).trim() !== '';
|
|
2685
|
-
if (inScope('progress') && touched) rounds.push(progressEntryOf(entry));
|
|
2686
|
-
var outcome = project.outcome || {};
|
|
2687
|
-
var amount = text(project.amountWan).trim();
|
|
2688
|
-
return {
|
|
2689
|
-
schema_version: DATA.schemaVersion,
|
|
2690
|
-
poc_id: text(project.pocId).trim(),
|
|
2691
|
-
name: changed('identity', 'name', project.name) || '',
|
|
2692
|
-
org: {
|
|
2693
|
-
system: changed('identity', 'system', project.system),
|
|
2694
|
-
company: changed('identity', 'company', project.company),
|
|
2695
|
-
department: changed('identity', 'department', project.department)
|
|
2696
|
-
},
|
|
2697
|
-
amount_wan: (inScope('identity') && amount !== '' && amount !== seeded('amountWan')) ? Number(amount) : null,
|
|
2698
|
-
poc_type: changed('identity', 'pocType', project.pocType),
|
|
2699
|
-
owner: changed('identity', 'owner', project.owner),
|
|
2700
|
-
sales: changed('identity', 'sales', project.sales),
|
|
2701
|
-
tech_owner: changed('identity', 'techOwner', project.techOwner),
|
|
2702
|
-
exec_sponsor: changed('identity', 'execSponsor', project.execSponsor),
|
|
2703
|
-
stage: project.stage,
|
|
2704
|
-
status: project.status,
|
|
2705
|
-
stage_since: changed('identity', 'stageSince', project.stageSince),
|
|
2706
|
-
gate0: {
|
|
2707
|
-
why_customer: changed('gate0', 'gate0.why_customer', project.gate0.why_customer),
|
|
2708
|
-
why_us: changed('gate0', 'gate0.why_us', project.gate0.why_us),
|
|
2709
|
-
decision_chain: changed('gate0', 'gate0.decision_chain', project.gate0.decision_chain),
|
|
2710
|
-
post_poc_decision: changed('gate0', 'gate0.post_poc_decision', project.gate0.post_poc_decision),
|
|
2711
|
-
competitor: changed('gate0', 'gate0.competitor', project.gate0.competitor),
|
|
2712
|
-
review: {
|
|
2713
|
-
conclusion: changed('gate0', 'gate0.conclusion', project.gate0.conclusion),
|
|
2714
|
-
reviewer: changed('gate0', 'gate0.reviewer', project.gate0.reviewer),
|
|
2715
|
-
reviewed_at: changed('gate0', 'gate0.reviewed_at', project.gate0.reviewed_at)
|
|
2716
|
-
}
|
|
2717
|
-
},
|
|
2718
|
-
plan: {
|
|
2719
|
-
customer_pain: changed('plan', 'plan.customer_pain', project.plan.customer_pain),
|
|
2720
|
-
expected_recognition: changed('plan', 'plan.expected_recognition', project.plan.expected_recognition),
|
|
2721
|
-
our_edge: changed('plan', 'plan.our_edge', project.plan.our_edge),
|
|
2722
|
-
criteria: changedList('plan', criteria, baseCriteria) || [],
|
|
2723
|
-
scenarios: changedList('plan', scenarios, baseScenarios) || [],
|
|
2724
|
-
risks: changedList('plan', risks, baseRisks) || [],
|
|
2725
|
-
timeline: {
|
|
2726
|
-
start: changed('plan', 'plan.timeline_start', project.plan.timeline_start),
|
|
2727
|
-
end: changed('plan', 'plan.timeline_end', project.plan.timeline_end)
|
|
2728
|
-
},
|
|
2729
|
-
gate1: { conclusion: changed('gate12', 'plan.gate1_conclusion', project.plan.gate1_conclusion) },
|
|
2730
|
-
gate2: { ready: changed('gate12', 'plan.gate2_ready', project.plan.gate2_ready) }
|
|
2731
|
-
},
|
|
2732
|
-
// The G4 conclusion block. It was absent from this serializer while the page
|
|
2733
|
-
// could edit it, so every G4 answer was dropped on download.
|
|
2734
|
-
outcome: {
|
|
2735
|
-
achievement: changed('outcome', 'outcome.achievement', outcome.achievement),
|
|
2736
|
-
customer_recognition: changed('outcome', 'outcome.customer_recognition', outcome.customer_recognition),
|
|
2737
|
-
our_proof: changed('outcome', 'outcome.our_proof', outcome.our_proof),
|
|
2738
|
-
remaining_risks: null,
|
|
2739
|
-
conclusion: {
|
|
2740
|
-
proved: changed('outcome', 'outcome.proved', outcome.proved),
|
|
2741
|
-
recognized: changed('outcome', 'outcome.recognized', outcome.recognized),
|
|
2742
|
-
next_business: changed('outcome', 'outcome.next_business', outcome.next_business)
|
|
2743
|
-
},
|
|
2744
|
-
business: {
|
|
2745
|
-
milestone: changed('outcome', 'outcome.milestone', outcome.milestone),
|
|
2746
|
-
owner: changed('outcome', 'outcome.businessOwner', outcome.businessOwner),
|
|
2747
|
-
deadline: changed('outcome', 'outcome.businessDeadline', outcome.businessDeadline),
|
|
2748
|
-
status: changed('outcome', 'outcome.businessStatus', outcome.businessStatus)
|
|
2749
|
-
},
|
|
2750
|
-
overall: changed('outcome', 'outcome.overall', outcome.overall)
|
|
2751
|
-
},
|
|
2752
|
-
progress: rounds
|
|
2753
|
-
};
|
|
2754
|
-
}
|
|
2755
|
-
|
|
2756
|
-
/** One appended round, in the ledger's v3.1 shape. */
|
|
2757
|
-
function progressEntryOf(entry) {
|
|
2758
|
-
function orNull(value) {
|
|
2759
|
-
var raw = text(value).trim();
|
|
2760
|
-
return raw === '' ? null : raw;
|
|
2761
|
-
}
|
|
2762
|
-
var evidence = [];
|
|
2763
|
-
for (var i = 0; i < entry.evidence.length; i += 1) {
|
|
2764
|
-
var item = entry.evidence[i];
|
|
2765
|
-
if (text(item.title).trim() === '') continue;
|
|
2766
|
-
evidence.push({ title: text(item.title).trim(), link: orNull(item.link), type: orNull(item.type) });
|
|
2767
|
-
}
|
|
2768
|
-
var scnIds = [];
|
|
2769
|
-
for (var j = 0; j < entry.scenarioIds.length; j += 1) if (text(entry.scenarioIds[j]).trim() !== '') scnIds.push(text(entry.scenarioIds[j]).trim());
|
|
2770
|
-
var criIds = [];
|
|
2771
|
-
for (var k = 0; k < entry.criteriaIds.length; k += 1) if (text(entry.criteriaIds[k]).trim() !== '') criIds.push(text(entry.criteriaIds[k]).trim());
|
|
2772
|
-
return {
|
|
2773
|
-
date: orNull(entry.date),
|
|
2774
|
-
type: orNull(entry.type),
|
|
2775
|
-
change: orNull(entry.change),
|
|
2776
|
-
goal: orNull(entry.goal),
|
|
2777
|
-
scenario_ids: scnIds,
|
|
2778
|
-
criteria_ids: criIds,
|
|
2779
|
-
actual: orNull(entry.actual),
|
|
2780
|
-
completion: orNull(entry.completion),
|
|
2781
|
-
evidence: evidence,
|
|
2782
|
-
customer: { synced_with: orNull(entry.customer.synced_with), feedback: orNull(entry.customer.feedback), recognition: orNull(entry.customer.recognition) },
|
|
2783
|
-
gate3_1: orNull(entry.gate3_1),
|
|
2784
|
-
gate3_2: orNull(entry.gate3_2),
|
|
2785
|
-
next: { goal: orNull(entry.next.goal), owner: orNull(entry.next.owner), deadline: orNull(entry.next.deadline) }
|
|
2786
|
-
};
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
function previewYaml() {
|
|
2790
|
-
var node = byId('yamlPreview');
|
|
2791
|
-
if (!node) return;
|
|
2792
|
-
node.textContent = JSON.stringify(toChangeDocument(), null, 2);
|
|
2793
|
-
node.hidden = false;
|
|
2794
|
-
// Guarded: scrollIntoView is absent in jsdom and in a few older embedded
|
|
2795
|
-
// webviews. Scrolling is a convenience, so a missing implementation must not
|
|
2796
|
-
// throw after the preview has already been rendered.
|
|
2797
|
-
if (node.scrollIntoView) node.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
2798
|
-
}
|
|
2799
|
-
|
|
2800
|
-
/**
|
|
2801
|
-
* The bare-minimum required fields, checked before a download.
|
|
2802
|
-
*
|
|
2803
|
-
* ## The bug this replaces
|
|
2804
|
-
*
|
|
2805
|
-
* The list was unconditional: it demanded 'progress.date', 'progress.change',
|
|
2806
|
-
* 'progress.actual' and 'progress.next.goal' on EVERY form. But a G0/G1
|
|
2807
|
-
* supplement form does not render the progress block at all, so those four
|
|
2808
|
-
* values are empty by construction and no amount of filling anything on the
|
|
2809
|
-
* page could satisfy them. Every supplement, new and batch form refused to
|
|
2810
|
-
* download, forever, with a toast that named no field — the form was a dead end.
|
|
2811
|
-
*
|
|
2812
|
-
* The rule is now: **only demand what this page actually asks for.** The scope
|
|
2813
|
-
* comes from the same 'sections' resolution the renderer used, so the validator
|
|
2814
|
-
* cannot drift from what is on screen. Returns the list of missing labels so the
|
|
2815
|
-
* toast can name them instead of saying "还有必填项没填".
|
|
2816
|
-
*/
|
|
2817
|
-
function validateRequired() {
|
|
2818
|
-
var project = current();
|
|
2819
|
-
var plan_ = DATA.sections[state.active] || { editable: ['identity', 'gate0', 'plan', 'progress'] };
|
|
2820
|
-
var scope = {};
|
|
2821
|
-
for (var s = 0; s < plan_.editable.length; s += 1) scope[plan_.editable[s]] = true;
|
|
2822
|
-
// 'gate12' is the plan's verdict block; it rides with 'plan' on the page.
|
|
2823
|
-
if (scope.plan) scope.gate12 = true;
|
|
2824
|
-
|
|
2825
|
-
var required = [];
|
|
2826
|
-
if (scope.identity) {
|
|
2827
|
-
required.push(['name', '项目名称']);
|
|
2828
|
-
required.push(['owner', '负责人(我方)']);
|
|
2829
|
-
required.push(['techOwner', '客户技术责任人']);
|
|
2830
|
-
}
|
|
2831
|
-
if (scope.progress) {
|
|
2832
|
-
required.push(['progress.date', '进展日期']);
|
|
2833
|
-
// v3.1 makes 'change' mandatory: a round that does not say what moved is
|
|
2834
|
-
// how a timeline decays into "communicated with customer".
|
|
2835
|
-
required.push(['progress.change', '这一次什么变了']);
|
|
2836
|
-
required.push(['progress.actual', '实际结果']);
|
|
2837
|
-
required.push(['progress.next.goal', '下一步目标']);
|
|
2838
|
-
}
|
|
2839
|
-
|
|
2840
|
-
var missing = [];
|
|
2841
|
-
for (var i = 0; i < required.length; i += 1) {
|
|
2842
|
-
var key = required[i][0];
|
|
2843
|
-
var label = required[i][1];
|
|
2844
|
-
var value = text(pathValue(project, key)).trim();
|
|
2845
|
-
var node = document.querySelector('[data-field="' + key + '"]');
|
|
2846
|
-
if (node) node.className = value === '' ? 'field has-error' : 'field';
|
|
2847
|
-
if (value === '') missing.push(label);
|
|
2848
|
-
}
|
|
2849
|
-
validateRequired.missing = missing;
|
|
2850
|
-
return missing.length === 0;
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
/** Read a dotted path off the project, treating 'progress.*' as the new round. */
|
|
2854
|
-
function pathValue(project, path) {
|
|
2855
|
-
var parts = path.split('.');
|
|
2856
|
-
var node = project;
|
|
2857
|
-
for (var i = 0; i < parts.length; i += 1) {
|
|
2858
|
-
if (node === null || node === undefined) return '';
|
|
2859
|
-
node = node[parts[i]];
|
|
2860
|
-
}
|
|
2861
|
-
return node;
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
function downloadYaml() {
|
|
2865
|
-
if (!validateRequired()) {
|
|
2866
|
-
// Name the fields: a toast that says only "还有必填项没填" leaves the person
|
|
2867
|
-
// hunting a long page for a red border that may be below the fold.
|
|
2868
|
-
var missing = validateRequired.missing || [];
|
|
2869
|
-
showToast('还有 ' + missing.length + ' 项必填没填:' + missing.join('、'));
|
|
2870
|
-
var first = document.querySelector('.field.has-error');
|
|
2871
|
-
if (first && first.scrollIntoView) first.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
2872
|
-
return;
|
|
2873
|
-
}
|
|
2874
|
-
var stamp = DATA.today.replace(/-/g, '');
|
|
2875
|
-
var document_ = toChangeDocument();
|
|
2876
|
-
var blob = new Blob([JSON.stringify(document_, null, 2)], { type: 'application/json;charset=utf-8' });
|
|
2877
|
-
var url = URL.createObjectURL(blob);
|
|
2878
|
-
var anchor = document.createElement('a');
|
|
2879
|
-
anchor.href = url;
|
|
2880
|
-
// One file for the whole batch: the merge step keys off 'changes[]', and a
|
|
2881
|
-
// batch is what the colleague was handed.
|
|
2882
|
-
anchor.download = 'poc-changes-' + stamp + '.json';
|
|
2883
|
-
document.body.appendChild(anchor);
|
|
2884
|
-
anchor.click();
|
|
2885
|
-
document.body.removeChild(anchor);
|
|
2886
|
-
setTimeout(function () { URL.revokeObjectURL(url); }, 4000);
|
|
2887
|
-
showToast('已下载 poc-changes-' + stamp + '.json');
|
|
2888
|
-
save(true);
|
|
2889
|
-
}
|
|
2890
|
-
|
|
2891
|
-
/**
|
|
2892
|
-
* Download the HTML itself, with the answers embedded, so it can be sent back.
|
|
2893
|
-
*
|
|
2894
|
-
* ## Why this exists
|
|
2895
|
-
*
|
|
2896
|
-
* The documented workflow is "colleague fills the HTML, sends it to me on WeChat,
|
|
2897
|
-
* I hand it to DSH". But the form's answers live only in 'localStorage' and in
|
|
2898
|
-
* the downloaded JSON — the HTML file on disk never changes, so forwarding the
|
|
2899
|
-
* file forwarded a blank form. The colleague had to find, download and attach a
|
|
2900
|
-
* second file, and the person receiving it needed a JSON viewer to read it.
|
|
2901
|
-
*
|
|
2902
|
-
* So this writes a **copy of this page** whose 'RETURN_DATA' block carries the
|
|
2903
|
-
* change set. The recipient opens it in any browser and reads the answers as
|
|
2904
|
-
* formatted HTML, while 'readReturnDocument' parses the same block
|
|
2905
|
-
* programmatically. One file, no second download, no tooling on either end.
|
|
2906
|
-
*
|
|
2907
|
-
* The embedded block is inert data, never executed: it is parsed with
|
|
2908
|
-
* 'JSON.parse' on a string, and the page renders it with 'textContent'.
|
|
2909
|
-
*/
|
|
2910
|
-
function downloadReturnFile() {
|
|
2911
|
-
if (!validateRequired()) {
|
|
2912
|
-
var missing = validateRequired.missing || [];
|
|
2913
|
-
showToast('还有 ' + missing.length + ' 项必填没填:' + missing.join('、'));
|
|
2914
|
-
var first = document.querySelector('.field.has-error');
|
|
2915
|
-
if (first && first.scrollIntoView) first.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
2916
|
-
return;
|
|
2917
|
-
}
|
|
2918
|
-
var document_ = toChangeDocument();
|
|
2919
|
-
var payload = JSON.stringify(document_);
|
|
2920
|
-
// Escape the three sequences that can break out of a script element or a
|
|
2921
|
-
// template placeholder, then embed.
|
|
2922
|
-
var safe = payload
|
|
2923
|
-
.replace(/</g, '\\\\u003c')
|
|
2924
|
-
.replace(/>/g, '\\\\u003e')
|
|
2925
|
-
.replace(/\\u2028/g, '\\\\u2028')
|
|
2926
|
-
.replace(/\\u2029/g, '\\\\u2029');
|
|
2927
|
-
var page = buildReturnPage(safe, document_);
|
|
2928
|
-
var stamp = DATA.today.replace(/-/g, '');
|
|
2929
|
-
var blob = new Blob([page], { type: 'text/html;charset=utf-8' });
|
|
2930
|
-
var url = URL.createObjectURL(blob);
|
|
2931
|
-
var anchor = document.createElement('a');
|
|
2932
|
-
anchor.href = url;
|
|
2933
|
-
anchor.download = 'poc-return-' + stamp + '.html';
|
|
2934
|
-
document.body.appendChild(anchor);
|
|
2935
|
-
anchor.click();
|
|
2936
|
-
document.body.removeChild(anchor);
|
|
2937
|
-
setTimeout(function () { URL.revokeObjectURL(url); }, 4000);
|
|
2938
|
-
showToast('已生成回传文件,请通过企业微信发给发起人');
|
|
2939
|
-
save(true);
|
|
2940
|
-
}
|
|
2941
|
-
|
|
2942
|
-
/**
|
|
2943
|
-
* The self-contained page a colleague sends back.
|
|
2944
|
-
*
|
|
2945
|
-
* Deliberately plain: it is a READ-ONLY report, not another form. It carries the
|
|
2946
|
-
* same visual tokens so it reads as the same product, and it repeats the exact
|
|
2947
|
-
* change-set JSON in a machine-readable block for the Host to parse.
|
|
2948
|
-
*/
|
|
2949
|
-
function buildReturnPage(safeJson, document_) {
|
|
2950
|
-
var rows = '';
|
|
2951
|
-
var intentText = DATA.intent === 'new' ? '新建项目' : DATA.intent === 'progress' ? '记录进展' : '补充信息';
|
|
2952
|
-
for (var i = 0; i < document_.changes.length; i += 1) {
|
|
2953
|
-
var change = document_.changes[i];
|
|
2954
|
-
// The change set only carries what the colleague could EDIT, so a
|
|
2955
|
-
// progress-intent change has no project name and no Gate 0. The reader still
|
|
2956
|
-
// needs the project's identity and context to make sense of the round, so
|
|
2957
|
-
// the source project is merged back in for DISPLAY ONLY. The embedded JSON
|
|
2958
|
-
// block stays the untouched change set — that is what the Host parses, and
|
|
2959
|
-
// re-sending a pre-filled field would overwrite a newer ledger value.
|
|
2960
|
-
var source = null;
|
|
2961
|
-
for (var si = 0; si < DATA.projects.length; si += 1) {
|
|
2962
|
-
if (DATA.projects[si].pocId === change.poc_id) { source = DATA.projects[si]; break; }
|
|
2963
|
-
}
|
|
2964
|
-
var shown = mergeForDisplay(change, source);
|
|
2965
|
-
var block = '';
|
|
2966
|
-
block += returnSection('项目身份', [
|
|
2967
|
-
['项目编号', shown.poc_id], ['项目名称', shown.name],
|
|
2968
|
-
['体系', shown.org && shown.org.system], ['客户公司', shown.org && shown.org.company],
|
|
2969
|
-
['部门', shown.org && shown.org.department],
|
|
2970
|
-
['预计金额(万元)', shown.amount_wan === null || shown.amount_wan === undefined ? '' : String(shown.amount_wan)],
|
|
2971
|
-
['项目类型', shown.poc_type], ['阶段', shown.stage], ['状态', shown.status],
|
|
2972
|
-
['负责人(我方)', shown.owner], ['销售', shown.sales],
|
|
2973
|
-
['客户技术责任人', shown.tech_owner], ['客户业务决策人', shown.exec_sponsor]
|
|
2974
|
-
]);
|
|
2975
|
-
var g0 = shown.gate0 || {};
|
|
2976
|
-
block += returnSection('Gate 0 · 值不值得做', [
|
|
2977
|
-
['客户为什么要测', g0.why_customer], ['我们为什么测', g0.why_us],
|
|
2978
|
-
['项目流程 / 决策链', g0.decision_chain], ['测完后客户会做什么决定', g0.post_poc_decision],
|
|
2979
|
-
['主要竞争对手', g0.competitor],
|
|
2980
|
-
['G0 评审结论', g0.review && g0.review.conclusion],
|
|
2981
|
-
['G0 评审人', g0.review && g0.review.reviewer],
|
|
2982
|
-
['评审日期', g0.review && g0.review.reviewed_at]
|
|
2983
|
-
]);
|
|
2984
|
-
var plan = shown.plan || {};
|
|
2985
|
-
block += returnSection('方案 · 客户痛点与赢点', [
|
|
2986
|
-
['客户核心痛点', plan.customer_pain], ['期望客户认可什么', plan.expected_recognition],
|
|
2987
|
-
['我方优势 / 赢点', plan.our_edge]
|
|
2988
|
-
]);
|
|
2989
|
-
if (plan.criteria && plan.criteria.length) {
|
|
2990
|
-
var critRows = '';
|
|
2991
|
-
for (var c = 0; c < plan.criteria.length; c += 1) {
|
|
2992
|
-
var cri = plan.criteria[c];
|
|
2993
|
-
critRows += '<li><b>' + escapeHtml(cri.id || '') + '</b> ' + escapeHtml(cri.name || '') +
|
|
2994
|
-
(cri.target ? '<span class="ret-dim"> · 目标 ' + escapeHtml(cri.target) + '</span>' : '') + '</li>';
|
|
2995
|
-
}
|
|
2996
|
-
block += '<div class="ret-sec"><h2>关键成功指标</h2><ul class="ret-list">' + critRows + '</ul></div>';
|
|
2997
|
-
}
|
|
2998
|
-
if (plan.scenarios && plan.scenarios.length) {
|
|
2999
|
-
var scnRows = '';
|
|
3000
|
-
for (var sc = 0; sc < plan.scenarios.length; sc += 1) {
|
|
3001
|
-
var scn = plan.scenarios[sc];
|
|
3002
|
-
scnRows += '<li><b>' + escapeHtml(scn.id || '') + '</b> ' + escapeHtml(scn.name || '') +
|
|
3003
|
-
(scn.goal ? '<span class="ret-dim"> · ' + escapeHtml(scn.goal) + '</span>' : '') + '</li>';
|
|
3004
|
-
}
|
|
3005
|
-
block += '<div class="ret-sec"><h2>验证场景</h2><ul class="ret-list">' + scnRows + '</ul></div>';
|
|
3006
|
-
}
|
|
3007
|
-
if (plan.risks && plan.risks.length) {
|
|
3008
|
-
var riskRows = '';
|
|
3009
|
-
for (var r = 0; r < plan.risks.length; r += 1) {
|
|
3010
|
-
riskRows += '<li>' + escapeHtml(plan.risks[r].name || '') +
|
|
3011
|
-
(plan.risks[r].mitigation ? '<span class="ret-dim"> · 应对 ' + escapeHtml(plan.risks[r].mitigation) + '</span>' : '') + '</li>';
|
|
3012
|
-
}
|
|
3013
|
-
block += '<div class="ret-sec"><h2>风险</h2><ul class="ret-list">' + riskRows + '</ul></div>';
|
|
3014
|
-
}
|
|
3015
|
-
block += returnSection('Gate 结论与时间', [
|
|
3016
|
-
['计划开始', plan.timeline && plan.timeline.start], ['计划结束', plan.timeline && plan.timeline.end],
|
|
3017
|
-
['G1 结论', plan.gate1 && plan.gate1.conclusion], ['G2 Ready', plan.gate2 && plan.gate2.ready]
|
|
3018
|
-
]);
|
|
3019
|
-
for (var p = 0; p < change.progress.length; p += 1) {
|
|
3020
|
-
var entry = change.progress[p];
|
|
3021
|
-
var cust = entry.customer || {};
|
|
3022
|
-
var nxt = entry.next || {};
|
|
3023
|
-
var ev = '';
|
|
3024
|
-
if (entry.evidence && entry.evidence.length) {
|
|
3025
|
-
for (var e = 0; e < entry.evidence.length; e += 1) {
|
|
3026
|
-
ev += (ev ? '、' : '') + escapeHtml(entry.evidence[e].title || '');
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
block += '<div class="ret-sec ret-new"><h2>本次新增进展<span class="ret-tag">新</span></h2><dl>' +
|
|
3030
|
-
returnPair('日期', entry.date) + returnPair('类型', entry.type) +
|
|
3031
|
-
returnPair('这一次什么变了', entry.change) + returnPair('目标', entry.goal) +
|
|
3032
|
-
returnPair('实际结果', entry.actual) + returnPair('完成度', entry.completion) +
|
|
3033
|
-
returnPair('证据', ev) + returnPair('同步对象', cust.synced_with) +
|
|
3034
|
-
returnPair('客户反馈', cust.feedback) + returnPair('客户认可度', cust.recognition) +
|
|
3035
|
-
returnPair('G3-1', entry.gate3_1) + returnPair('G3-2', entry.gate3_2) +
|
|
3036
|
-
returnPair('下一步目标', nxt.goal) + returnPair('下一步负责人', nxt.owner) +
|
|
3037
|
-
returnPair('下一步截止', nxt.deadline) + '</dl></div>';
|
|
3038
|
-
}
|
|
3039
|
-
var o = shown.outcome || {};
|
|
3040
|
-
var oc = o.conclusion || {};
|
|
3041
|
-
var ob = o.business || {};
|
|
3042
|
-
block += returnSection('结论与转化', [
|
|
3043
|
-
['目标达成', o.achievement], ['客户认可', o.customer_recognition],
|
|
3044
|
-
['我方证据', o.our_proof], ['我们证明了什么', oc.proved],
|
|
3045
|
-
['客户认可了什么', oc.recognized], ['下一步业务动作', oc.next_business],
|
|
3046
|
-
['Next Milestone', ob.milestone], ['里程碑负责人', ob.owner],
|
|
3047
|
-
['里程碑截止', ob.deadline], ['里程碑状态', ob.status],
|
|
3048
|
-
['POC 总体结论', o.overall]
|
|
3049
|
-
]);
|
|
3050
|
-
rows += '<article class="ret-card">' +
|
|
3051
|
-
'<header class="ret-head"><h1>' + escapeHtml(shown.name || shown.poc_id || '未命名项目') + '</h1>' +
|
|
3052
|
-
'<div class="ret-meta">' + escapeHtml(shown.poc_id || '') +
|
|
3053
|
-
(shown.org && shown.org.company ? ' · ' + escapeHtml(shown.org.company) : '') +
|
|
3054
|
-
(shown.stage ? ' · ' + escapeHtml(shown.stage) : '') +
|
|
3055
|
-
(shown.poc_type ? ' · ' + escapeHtml(shown.poc_type) : '') + '</div></header>' +
|
|
3056
|
-
block + '</article>';
|
|
3057
|
-
}
|
|
3058
|
-
return '<!DOCTYPE html>\\n<html lang="zh-CN">\\n<head>\\n<meta charset="UTF-8">\\n' +
|
|
3059
|
-
'<meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
|
|
3060
|
-
'<title>POC 回传 · ' + escapeHtml(intentText) + '</title>\\n<style>' + DATA.returnCss + '</style>\\n</head>\\n<body>\\n' +
|
|
3061
|
-
'<div class="ret-shell">' +
|
|
3062
|
-
'<div class="ret-note">这是组员填写的 POC 回传文件,内容只读。' +
|
|
3063
|
-
'把整个文件(或下载的 .json)通过企业微信发给发起人,由他交给 DSH 合并进台账。</div>' +
|
|
3064
|
-
'<div class="ret-bar"><span>' + escapeHtml(intentText) + ' · ' + document_.changes.length + ' 个项目</span>' +
|
|
3065
|
-
'<span class="ret-dim">生成于 ' + escapeHtml(readableTime(document_.generatedAt)) + '</span></div>' +
|
|
3066
|
-
rows + '</div>\\n' +
|
|
3067
|
-
// The closing tag is written as '<\\/script>': this string is itself embedded
|
|
3068
|
-
// inside a <script> element, so a literal closing tag here would terminate
|
|
3069
|
-
// the generated page's script and dump the rest of the code as text.
|
|
3070
|
-
'<script type="application/json" id="poc-return-data">' + safeJson + '<\\/script>\\n' +
|
|
3071
|
-
'</body>\\n</html>\\n';
|
|
3072
|
-
}
|
|
3073
|
-
|
|
3074
|
-
/**
|
|
3075
|
-
* Merge a change set over its source project, for DISPLAY in the return page.
|
|
3076
|
-
*
|
|
3077
|
-
* The change set is deliberately narrow (only what the colleague could edit), so
|
|
3078
|
-
* a progress-only return carries no project name, no Gate 0 and no plan. Showing
|
|
3079
|
-
* that file as-is produced a report titled "POC-001" with an almost empty body —
|
|
3080
|
-
* the reader could not tell which project it was about.
|
|
3081
|
-
*
|
|
3082
|
-
* So the untouched project is merged underneath for display. The embedded JSON
|
|
3083
|
-
* block is NOT merged: it stays the exact change set, because that is what the
|
|
3084
|
-
* Host applies and a re-sent pre-filled field would revert a newer ledger value.
|
|
3085
|
-
*/
|
|
3086
|
-
function mergeForDisplay(change, source) {
|
|
3087
|
-
if (!source) return change;
|
|
3088
|
-
function pick(changeValue, sourceValue) {
|
|
3089
|
-
return changeValue === null || changeValue === undefined || changeValue === '' ? sourceValue : changeValue;
|
|
3090
|
-
}
|
|
3091
|
-
var plan = change.plan || {};
|
|
3092
|
-
var srcPlan = source.plan || {};
|
|
3093
|
-
var outcome = change.outcome || {};
|
|
3094
|
-
var srcOutcome = source.outcome || {};
|
|
3095
|
-
return {
|
|
3096
|
-
poc_id: change.poc_id,
|
|
3097
|
-
name: pick(change.name, source.name),
|
|
3098
|
-
org: {
|
|
3099
|
-
system: pick(change.org && change.org.system, source.system),
|
|
3100
|
-
company: pick(change.org && change.org.company, source.company),
|
|
3101
|
-
department: pick(change.org && change.org.department, source.department)
|
|
3102
|
-
},
|
|
3103
|
-
amount_wan: pick(change.amount_wan, source.amountWan === '' ? null : source.amountWan),
|
|
3104
|
-
poc_type: pick(change.poc_type, source.pocType),
|
|
3105
|
-
owner: pick(change.owner, source.owner),
|
|
3106
|
-
sales: pick(change.sales, source.sales),
|
|
3107
|
-
tech_owner: pick(change.tech_owner, source.techOwner),
|
|
3108
|
-
exec_sponsor: pick(change.exec_sponsor, source.execSponsor),
|
|
3109
|
-
stage: pick(change.stage, source.stage),
|
|
3110
|
-
status: pick(change.status, source.status),
|
|
3111
|
-
gate0: {
|
|
3112
|
-
why_customer: pick(change.gate0 && change.gate0.why_customer, source.gate0.why_customer),
|
|
3113
|
-
why_us: pick(change.gate0 && change.gate0.why_us, source.gate0.why_us),
|
|
3114
|
-
decision_chain: pick(change.gate0 && change.gate0.decision_chain, source.gate0.decision_chain),
|
|
3115
|
-
post_poc_decision: pick(change.gate0 && change.gate0.post_poc_decision, source.gate0.post_poc_decision),
|
|
3116
|
-
competitor: pick(change.gate0 && change.gate0.competitor, source.gate0.competitor),
|
|
3117
|
-
review: {
|
|
3118
|
-
conclusion: pick(change.gate0 && change.gate0.review && change.gate0.review.conclusion, source.gate0.conclusion),
|
|
3119
|
-
reviewer: pick(change.gate0 && change.gate0.review && change.gate0.review.reviewer, source.gate0.reviewer),
|
|
3120
|
-
reviewed_at: pick(change.gate0 && change.gate0.review && change.gate0.review.reviewed_at, source.gate0.reviewed_at)
|
|
3121
|
-
}
|
|
3122
|
-
},
|
|
3123
|
-
plan: {
|
|
3124
|
-
customer_pain: pick(plan.customer_pain, srcPlan.customer_pain),
|
|
3125
|
-
expected_recognition: pick(plan.expected_recognition, srcPlan.expected_recognition),
|
|
3126
|
-
our_edge: pick(plan.our_edge, srcPlan.our_edge),
|
|
3127
|
-
criteria: (plan.criteria && plan.criteria.length) ? plan.criteria : srcPlan.criteria,
|
|
3128
|
-
scenarios: (plan.scenarios && plan.scenarios.length) ? plan.scenarios : srcPlan.scenarios,
|
|
3129
|
-
risks: (plan.risks && plan.risks.length) ? plan.risks : srcPlan.risks,
|
|
3130
|
-
timeline: {
|
|
3131
|
-
start: pick(plan.timeline && plan.timeline.start, srcPlan.timeline_start),
|
|
3132
|
-
end: pick(plan.timeline && plan.timeline.end, srcPlan.timeline_end)
|
|
3133
|
-
},
|
|
3134
|
-
gate1: { conclusion: pick(plan.gate1 && plan.gate1.conclusion, srcPlan.gate1_conclusion) },
|
|
3135
|
-
gate2: { ready: pick(plan.gate2 && plan.gate2.ready, srcPlan.gate2_ready) }
|
|
3136
|
-
},
|
|
3137
|
-
outcome: {
|
|
3138
|
-
achievement: pick(outcome.achievement, srcOutcome.achievement),
|
|
3139
|
-
customer_recognition: pick(outcome.customer_recognition, srcOutcome.customer_recognition),
|
|
3140
|
-
our_proof: pick(outcome.our_proof, srcOutcome.our_proof),
|
|
3141
|
-
remaining_risks: pick(outcome.remaining_risks, srcOutcome.remaining_risks),
|
|
3142
|
-
conclusion: {
|
|
3143
|
-
proved: pick(outcome.conclusion && outcome.conclusion.proved, srcOutcome.proved),
|
|
3144
|
-
recognized: pick(outcome.conclusion && outcome.conclusion.recognized, srcOutcome.recognized),
|
|
3145
|
-
next_business: pick(outcome.conclusion && outcome.conclusion.next_business, srcOutcome.next_business)
|
|
3146
|
-
},
|
|
3147
|
-
business: {
|
|
3148
|
-
milestone: pick(outcome.business && outcome.business.milestone, srcOutcome.milestone),
|
|
3149
|
-
owner: pick(outcome.business && outcome.business.owner, srcOutcome.businessOwner),
|
|
3150
|
-
deadline: pick(outcome.business && outcome.business.deadline, srcOutcome.businessDeadline),
|
|
3151
|
-
status: pick(outcome.business && outcome.business.status, srcOutcome.businessStatus)
|
|
3152
|
-
},
|
|
3153
|
-
overall: pick(outcome.overall, srcOutcome.overall)
|
|
3154
|
-
},
|
|
3155
|
-
progress: change.progress
|
|
3156
|
-
};
|
|
3157
|
-
}
|
|
3158
|
-
|
|
3159
|
-
/** An ISO stamp as a local, readable time: "2026-11-20 18:08". */
|
|
3160
|
-
function readableTime(iso) {
|
|
3161
|
-
var raw = text(iso);
|
|
3162
|
-
var at = raw.indexOf('T');
|
|
3163
|
-
if (at < 0) return raw;
|
|
3164
|
-
return raw.slice(0, at) + ' ' + raw.slice(at + 1, at + 6);
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3167
|
-
function returnPair(label, value) {
|
|
3168
|
-
var raw = text(value).trim();
|
|
3169
|
-
if (raw === '') return '';
|
|
3170
|
-
return '<div class="ret-pair"><dt>' + escapeHtml(label) + '</dt><dd>' + escapeHtml(raw) + '</dd></div>';
|
|
3171
|
-
}
|
|
3172
|
-
|
|
3173
|
-
function returnSection(title, pairs) {
|
|
3174
|
-
var body = '';
|
|
3175
|
-
for (var i = 0; i < pairs.length; i += 1) body += returnPair(pairs[i][0], pairs[i][1]);
|
|
3176
|
-
if (body === '') return '';
|
|
3177
|
-
return '<div class="ret-sec"><h2>' + escapeHtml(title) + '</h2><dl>' + body + '</dl></div>';
|
|
3178
|
-
}
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
function initState() {
|
|
3182
|
-
storageAvailable = probeStorage();
|
|
3183
|
-
if (!storageAvailable) {
|
|
3184
|
-
var notice = byId('draftNotice');
|
|
3185
|
-
if (notice) {
|
|
3186
|
-
notice.textContent = '这个浏览器禁用了本地存储,草稿不会自动保存,请填完立即下载。';
|
|
3187
|
-
notice.hidden = false;
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
var draft = loadDraft();
|
|
3191
|
-
if (draft) {
|
|
3192
|
-
DATA.projects = draft;
|
|
3193
|
-
var restore = byId('restoreNotice');
|
|
3194
|
-
if (restore) restore.hidden = false;
|
|
3195
|
-
}
|
|
3196
|
-
}
|
|
3197
|
-
|
|
3198
|
-
initState();
|
|
3199
|
-
bind();
|
|
3200
|
-
render();
|
|
3201
|
-
if (byId('clearBtn')) byId('clearBtn').addEventListener('click', clearDraft);
|
|
3202
|
-
if (byId('previewBtn')) byId('previewBtn').addEventListener('click', previewYaml);
|
|
3203
|
-
if (byId('downloadBtn')) byId('downloadBtn').addEventListener('click', downloadYaml);
|
|
3204
|
-
if (byId('returnBtn')) byId('returnBtn').addEventListener('click', downloadReturnFile);
|
|
3205
|
-
setInterval(function () { save(true); }, 30000);
|
|
3206
|
-
window.addEventListener('beforeunload', function () { save(true); });
|
|
3207
|
-
`;
|
|
3208
|
-
/** The blank project, as the generated script builds it. */
|
|
3209
|
-
function blankProjectPayload() {
|
|
3210
|
-
return blankProject();
|
|
3211
|
-
}
|