@skillre/dsh-plugin-work-dashboard 0.11.1 → 0.13.0
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 +3 -3
- package/README.md +8 -15
- package/compatibility.json +2 -2
- package/docs/POC-3.2-/350/277/233/345/261/225/345/245/221/347/272/246.md +21 -0
- package/docs/Super-Agent-3.2-/350/201/224/350/260/203/346/211/213/345/206/214.md +38 -0
- package/lib/client/css/detail.d.ts +1 -1
- package/lib/client/css/detail.js +4 -0
- package/lib/client/text.js +8 -12
- package/lib/client.js +74 -38
- package/lib/form.d.ts +144 -5
- package/lib/form.js +1439 -231
- package/lib/gap.d.ts +2 -2
- package/lib/gap.js +21 -14
- package/lib/index.js +12 -13
- package/lib/progress.d.ts +8 -0
- package/lib/progress.js +20 -0
- package/lib/report-contract.d.ts +315 -0
- package/lib/report-contract.js +119 -0
- package/lib/report-form.d.ts +3 -0
- package/lib/report-form.js +41 -0
- package/lib/report-import.d.ts +9 -0
- package/lib/report-import.js +118 -0
- package/lib/report-page.d.ts +60 -0
- package/lib/report-page.js +3424 -0
- package/lib/report-style.d.ts +17 -0
- package/lib/report-style.js +459 -0
- package/lib/store.js +8 -4
- package/lib/timeline.js +7 -6
- package/lib/types.d.ts +38 -2
- package/package.json +1 -1
- package/skills/poc-export/SKILL.md +10 -82
- package/skills/poc-export/scripts/export-form.mjs +69 -624
- package/skills/poc-ledger/SKILL.md +14 -25
- package/skills/poc-submit/SKILL.md +13 -224
- package/skills/poc-submit/prepare-return.mjs +48 -0
package/lib/form.js
CHANGED
|
@@ -195,6 +195,7 @@ export function projectForForm(record) {
|
|
|
195
195
|
},
|
|
196
196
|
progress: blankProgress(progress.length),
|
|
197
197
|
existingProgressCount: progress.length,
|
|
198
|
+
history: progressHistory(progress),
|
|
198
199
|
// G4 only. Read here so a G4 form opens with the current conclusion in
|
|
199
200
|
// place rather than blank, which would invite overwriting it by omission.
|
|
200
201
|
outcome: {
|
|
@@ -219,6 +220,43 @@ function numberText(value) {
|
|
|
219
220
|
const raw = text(value);
|
|
220
221
|
return raw === '' ? '' : raw;
|
|
221
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
|
+
}
|
|
222
260
|
/** One empty progress entry, with `seq` continuing the existing count. */
|
|
223
261
|
export function blankProgress(existingCount) {
|
|
224
262
|
return {
|
|
@@ -231,7 +269,11 @@ export function blankProgress(existingCount) {
|
|
|
231
269
|
criteriaIds: [],
|
|
232
270
|
actual: '',
|
|
233
271
|
completion: '',
|
|
234
|
-
evidence
|
|
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: '' }],
|
|
235
277
|
customer: { synced_with: '', feedback: '', recognition: '' },
|
|
236
278
|
gate3_1: '',
|
|
237
279
|
gate3_2: '',
|
|
@@ -279,6 +321,7 @@ export function blankProject() {
|
|
|
279
321
|
},
|
|
280
322
|
progress: blankProgress(0),
|
|
281
323
|
existingProgressCount: 0,
|
|
324
|
+
history: [],
|
|
282
325
|
outcome: {
|
|
283
326
|
achievement: '',
|
|
284
327
|
customer_recognition: '',
|
|
@@ -411,81 +454,250 @@ export function projectToYaml(project) {
|
|
|
411
454
|
function orNull(value) {
|
|
412
455
|
return value === '' ? null : value;
|
|
413
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
|
+
};
|
|
414
487
|
/**
|
|
415
488
|
* Build one project's change set from the form state.
|
|
416
489
|
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
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".
|
|
420
499
|
*/
|
|
421
|
-
export function projectToChangeSet(project) {
|
|
422
|
-
|
|
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 = {
|
|
423
546
|
schema_version: FORM_SCHEMA_VERSION,
|
|
424
547
|
poc_id: project.pocId.trim(),
|
|
425
|
-
name:
|
|
426
|
-
org: {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
tech_owner: orNull(project.techOwner.trim()),
|
|
436
|
-
exec_sponsor: orNull(project.execSponsor.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.
|
|
437
558
|
stage: project.stage,
|
|
438
559
|
status: project.status,
|
|
439
|
-
stage_since:
|
|
560
|
+
stage_since: null,
|
|
440
561
|
gate0: {
|
|
441
|
-
why_customer:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
post_poc_decision: orNull(project.gate0.post_poc_decision.trim()),
|
|
445
|
-
competitor: orNull(project.gate0.competitor.trim()),
|
|
446
|
-
review: {
|
|
447
|
-
conclusion: orNull(project.gate0.conclusion.trim()),
|
|
448
|
-
reviewer: orNull(project.gate0.reviewer.trim()),
|
|
449
|
-
reviewed_at: orNull(project.gate0.reviewed_at.trim()),
|
|
450
|
-
},
|
|
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 },
|
|
451
565
|
},
|
|
452
566
|
plan: {
|
|
453
|
-
customer_pain:
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
.filter((item) => (item.name ?? '').trim() !== '')
|
|
458
|
-
.map((item) => ({
|
|
459
|
-
id: orNull((item.id ?? '').trim()),
|
|
460
|
-
name: item.name.trim(),
|
|
461
|
-
metric: orNull((item.metric ?? '').trim()),
|
|
462
|
-
baseline: orNull((item.baseline ?? '').trim()),
|
|
463
|
-
target: orNull((item.target ?? '').trim()),
|
|
464
|
-
})),
|
|
465
|
-
scenarios: project.plan.scenarios
|
|
466
|
-
.filter((item) => (item.name ?? '').trim() !== '')
|
|
467
|
-
.map((item) => ({
|
|
468
|
-
id: orNull((item.id ?? '').trim()),
|
|
469
|
-
name: item.name.trim(),
|
|
470
|
-
goal: orNull((item.goal ?? '').trim()),
|
|
471
|
-
})),
|
|
472
|
-
risks: project.plan.risks
|
|
473
|
-
.filter((item) => item.name.trim() !== '')
|
|
474
|
-
.map((item) => ({
|
|
475
|
-
name: item.name.trim(),
|
|
476
|
-
level: orNull(item.level.trim()),
|
|
477
|
-
mitigation: orNull(item.mitigation.trim()),
|
|
478
|
-
})),
|
|
479
|
-
timeline: {
|
|
480
|
-
start: orNull(project.plan.timeline_start.trim()),
|
|
481
|
-
end: orNull(project.plan.timeline_end.trim()),
|
|
482
|
-
},
|
|
483
|
-
gate1: { conclusion: orNull(project.plan.gate1_conclusion.trim()) },
|
|
484
|
-
gate2: { ready: orNull(project.plan.gate2_ready.trim()) },
|
|
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 },
|
|
485
571
|
},
|
|
486
|
-
|
|
487
|
-
|
|
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)) },
|
|
488
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;
|
|
489
701
|
}
|
|
490
702
|
/** Build the document a colleague sends back. */
|
|
491
703
|
export function buildChangeDocument(options) {
|
|
@@ -494,7 +706,7 @@ export function buildChangeDocument(options) {
|
|
|
494
706
|
generatedAt: (options.now ?? new Date()).toISOString(),
|
|
495
707
|
generatedBy: 'POC 信息收集表单 v3.1',
|
|
496
708
|
intent: options.intent,
|
|
497
|
-
changes: options.projects.map((project) => projectToChangeSet(project)),
|
|
709
|
+
changes: options.projects.map((project, index) => projectToChangeSet(project, options.intent, options.baseline?.[index])),
|
|
498
710
|
};
|
|
499
711
|
}
|
|
500
712
|
/** `true` when the form's progress entry carries no user content. */
|
|
@@ -624,12 +836,18 @@ export function buildFormHtml(options) {
|
|
|
624
836
|
generatedAt: now.toISOString(),
|
|
625
837
|
today: now.toISOString().slice(0, 10),
|
|
626
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))),
|
|
627
844
|
// Each project's stage decides which sections are the subject, so the
|
|
628
845
|
// resolution is per project rather than per document.
|
|
629
846
|
sections: projects.map((project) => resolveSections(intent, project.stage)),
|
|
630
847
|
draftKey: draftKeyFor(options.mode, projects.map((project) => project.pocId).filter((id) => id !== '')),
|
|
631
848
|
enums: ENUMS,
|
|
632
849
|
g0Fields: G0_PROMPTS,
|
|
850
|
+
returnCss: RETURN_CSS,
|
|
633
851
|
};
|
|
634
852
|
const data = scriptSafe(JSON.stringify(payload));
|
|
635
853
|
const title = intent === 'new'
|
|
@@ -656,7 +874,8 @@ export function buildFormHtml(options) {
|
|
|
656
874
|
<div class="footer-info" id="footerInfo">正在初始化…</div>
|
|
657
875
|
<div class="footer-actions">
|
|
658
876
|
<button type="button" class="btn" id="previewBtn">预览变更集</button>
|
|
659
|
-
<button type="button" class="btn
|
|
877
|
+
<button type="button" class="btn" id="downloadBtn">下载变更集 (.json)</button>
|
|
878
|
+
<button type="button" class="btn btn-primary" id="returnBtn">生成回传文件 (.html)</button>
|
|
660
879
|
</div>
|
|
661
880
|
</footer>
|
|
662
881
|
</div>
|
|
@@ -725,6 +944,113 @@ export function checkFormCompatibility(payload) {
|
|
|
725
944
|
reason: `这个表单声明的版本是 v${declared},当前台账读取的是 v${FORM_SCHEMA_VERSION},无法确认字段含义一致,已拒绝导入。`,
|
|
726
945
|
};
|
|
727
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
|
+
}
|
|
728
1054
|
/** Styles: one inline sheet, the console's own design tokens. */
|
|
729
1055
|
const FORM_CSS = `
|
|
730
1056
|
/* ===========================================================================
|
|
@@ -780,6 +1106,15 @@ body{
|
|
|
780
1106
|
padding-top:10px;border-top:1px solid var(--border);
|
|
781
1107
|
}
|
|
782
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
|
+
}
|
|
783
1118
|
|
|
784
1119
|
/* ---------- the fixed two-column contract, same ratio as the detail page --- */
|
|
785
1120
|
.columns{display:grid;grid-template-columns:minmax(0,1.72fr) minmax(0,1fr);gap:18px;align-items:start}
|
|
@@ -819,6 +1154,15 @@ body{
|
|
|
819
1154
|
border-radius:8px;background:var(--surface);border:1px solid var(--border);
|
|
820
1155
|
}
|
|
821
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
|
+
}
|
|
822
1166
|
.row-card-id{
|
|
823
1167
|
flex:none;font-family:var(--mono);font-size:9px;line-height:13px;
|
|
824
1168
|
color:var(--text-3);background:var(--inset);border:1px solid var(--border);
|
|
@@ -846,10 +1190,31 @@ body{
|
|
|
846
1190
|
.textarea{min-height:60px;resize:vertical}
|
|
847
1191
|
.grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}
|
|
848
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}
|
|
849
1205
|
.field.has-error .input,.field.has-error .textarea,.field.has-error .select{border-color:var(--red)}
|
|
850
1206
|
.field-error{color:var(--red);font-size:10px;display:none}
|
|
851
1207
|
.field.has-error .field-error{display:block}
|
|
852
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
|
+
|
|
853
1218
|
/* ---------- id pickers: which scenario / criterion this round touched ------ */
|
|
854
1219
|
.pick-list{display:flex;flex-wrap:wrap;gap:6px}
|
|
855
1220
|
.pick{
|
|
@@ -860,8 +1225,93 @@ body{
|
|
|
860
1225
|
.pick:has(input:checked){background:var(--primary-soft);border-color:var(--primary)}
|
|
861
1226
|
.pick input{accent-color:var(--primary);margin:0}
|
|
862
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
|
+
}
|
|
863
1232
|
.pick-name{overflow-wrap:anywhere}
|
|
864
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
|
+
|
|
865
1315
|
/* ---------- atoms ---------- */
|
|
866
1316
|
.btn{
|
|
867
1317
|
padding:6px 12px;border-radius:6px;border:1px solid var(--border);background:var(--surface);
|
|
@@ -885,19 +1335,18 @@ body{
|
|
|
885
1335
|
.pill-green{background:var(--green-soft);color:var(--green)}
|
|
886
1336
|
.pill-red{background:var(--red-soft);color:var(--red)}
|
|
887
1337
|
|
|
888
|
-
/* ----------
|
|
889
|
-
.
|
|
890
|
-
display:
|
|
891
|
-
|
|
892
|
-
border:
|
|
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;
|
|
893
1343
|
}
|
|
894
|
-
.
|
|
895
|
-
.
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
.
|
|
899
|
-
.
|
|
900
|
-
.ready-value{font-size:11px;line-height:17px;color:var(--text-2);overflow-wrap:anywhere}
|
|
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}
|
|
901
1350
|
|
|
902
1351
|
/* ---------- notices / footer ---------- */
|
|
903
1352
|
.notice{
|
|
@@ -927,6 +1376,80 @@ body{
|
|
|
927
1376
|
body{padding:0}
|
|
928
1377
|
}
|
|
929
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
|
+
`;
|
|
930
1453
|
/**
|
|
931
1454
|
* The generated page script.
|
|
932
1455
|
*
|
|
@@ -1061,22 +1584,46 @@ const FORM_SCRIPT = `
|
|
|
1061
1584
|
var opts = options || {};
|
|
1062
1585
|
var help = opts.help ? '<p class="field-help">' + escapeHtml(opts.help) + '</p>' : '';
|
|
1063
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) + '"';
|
|
1064
1593
|
var input;
|
|
1065
1594
|
if (opts.multiline) {
|
|
1066
|
-
input = '<textarea class="textarea
|
|
1595
|
+
input = '<textarea class="textarea' + (locked ? ' is-locked' : '') + '"' + pathAttr + lockAttr + '>' + escapeHtml(value) + '</textarea>';
|
|
1067
1596
|
} else if (opts.enum) {
|
|
1068
|
-
input = '<select class="select
|
|
1069
|
-
|
|
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>';
|
|
1070
1609
|
for (var i = 0; i < opts.enum.length; i += 1) {
|
|
1071
1610
|
var option = opts.enum[i];
|
|
1072
1611
|
input += '<option value="' + escapeHtml(option) + '"' + (option === value ? ' selected' : '') + '>' + escapeHtml(option) + '</option>';
|
|
1073
1612
|
}
|
|
1074
1613
|
input += '</select>';
|
|
1075
1614
|
} else {
|
|
1076
|
-
|
|
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 + '>';
|
|
1077
1621
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
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>';
|
|
1080
1627
|
}
|
|
1081
1628
|
|
|
1082
1629
|
/**
|
|
@@ -1101,28 +1648,33 @@ const FORM_SCRIPT = `
|
|
|
1101
1648
|
escapeHtml(def.hint) + '">' + escapeHtml(project.gate0[def.key]) + '</textarea>' +
|
|
1102
1649
|
'</div>';
|
|
1103
1650
|
}
|
|
1104
|
-
// The fifth prerequisite lives in the identity block,
|
|
1105
|
-
//
|
|
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.
|
|
1106
1656
|
var techFilled = text(project.techOwner).trim() !== '';
|
|
1107
1657
|
if (techFilled) present += 1;
|
|
1108
1658
|
cards += '<div class="g0-card" data-present="' + (techFilled ? 'true' : 'false') + '">' +
|
|
1109
1659
|
'<div class="g0-card-head"><span class="g0-card-label">客户技术责任人' +
|
|
1110
1660
|
'<span class="req">*</span></span>' +
|
|
1111
1661
|
(techFilled ? '' : '<span class="g0-card-missing">缺失</span>') + '</div>' +
|
|
1112
|
-
'<input class="input" data-path="techOwner" value="' + escapeHtml(project.techOwner) + '" placeholder="
|
|
1662
|
+
'<input class="input" data-path="techOwner" value="' + escapeHtml(project.techOwner) + '" placeholder="谁在客户侧配合验证">' +
|
|
1113
1663
|
'</div>';
|
|
1114
1664
|
|
|
1115
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.
|
|
1116
1671
|
return '<section class="sec">' +
|
|
1117
1672
|
'<header class="sec-head"><h2 class="sec-title">Gate 0 · 值不值得做</h2>' +
|
|
1118
1673
|
'<span class="sec-kicker">五必填 <span class="badge ' + tone + '">' + present + ' / 5</span></span></header>' +
|
|
1119
|
-
'<p class="sec-hint">这五项齐了,G0
|
|
1674
|
+
'<p class="sec-hint">这五项齐了,G0 评审才有意义。评审结论不在这里填。</p>' +
|
|
1120
1675
|
'<div class="g0-grid">' + cards + '</div>' +
|
|
1121
1676
|
'<div class="grid-2">' +
|
|
1122
1677
|
field('主要竞争对手', 'gate0.competitor', project.gate0.competitor, {}) +
|
|
1123
|
-
field('G0 评审结论', 'gate0.conclusion', project.gate0.conclusion, { enum: DATA.enums.g0Conclusion }) +
|
|
1124
|
-
field('G0 评审人', 'gate0.reviewer', project.gate0.reviewer, {}) +
|
|
1125
|
-
field('评审日期', 'gate0.reviewed_at', project.gate0.reviewed_at, { date: true }) +
|
|
1126
1678
|
'</div></section>';
|
|
1127
1679
|
}
|
|
1128
1680
|
|
|
@@ -1268,9 +1820,11 @@ const FORM_SCRIPT = `
|
|
|
1268
1820
|
*/
|
|
1269
1821
|
function idPicker(label, path, unused, options, selected, hint) {
|
|
1270
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.
|
|
1271
1825
|
return '<div class="field"><label class="field-label">' + escapeHtml(label) + '</label>' +
|
|
1272
1826
|
'<p class="field-help">' + escapeHtml(hint) + '</p>' +
|
|
1273
|
-
'<p class="
|
|
1827
|
+
'<p class="pick-empty">这个项目还没有可选的内容(方案里还没填),先跳过这一项。</p></div>';
|
|
1274
1828
|
}
|
|
1275
1829
|
var chosen = {};
|
|
1276
1830
|
for (var i = 0; i < selected.length; i += 1) chosen[text(selected[i])] = true;
|
|
@@ -1289,6 +1843,27 @@ const FORM_SCRIPT = `
|
|
|
1289
1843
|
'<div class="pick-list">' + boxes + '</div></div>';
|
|
1290
1844
|
}
|
|
1291
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
|
+
*/
|
|
1292
1867
|
function progressCard(project) {
|
|
1293
1868
|
var entry = project.progress;
|
|
1294
1869
|
var evidenceRows = '';
|
|
@@ -1300,34 +1875,41 @@ const FORM_SCRIPT = `
|
|
|
1300
1875
|
'</div></div>';
|
|
1301
1876
|
}
|
|
1302
1877
|
var countBadge = project.existingProgressCount > 0
|
|
1303
|
-
? '<span class="badge badge-info"
|
|
1304
|
-
: '<span class="badge badge-warn"
|
|
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
|
+
|
|
1305
1895
|
return '<section class="sec">' +
|
|
1306
1896
|
'<header class="sec-head"><h2 class="sec-title">这一轮进展</h2>' +
|
|
1307
1897
|
'<span class="sec-kicker">' + countBadge + '</span></header>' +
|
|
1308
|
-
'<p class="sec-hint"
|
|
1309
|
-
'<div class="grid-
|
|
1898
|
+
'<p class="sec-hint">只填这次真正发生的事。追加式,不会覆盖历史。</p>' +
|
|
1899
|
+
'<div class="grid-3">' +
|
|
1310
1900
|
field('日期', 'progress.date', entry.date, { date: true, required: true }) +
|
|
1311
1901
|
field('类型', 'progress.type', entry.type, { enum: DATA.enums.progressType, required: true }) +
|
|
1312
|
-
field('这一次什么变了', 'progress.change', entry.change, { enum: DATA.enums.progressChange, required: true, help: '
|
|
1313
|
-
field('完成度', 'progress.completion', entry.completion, { enum: DATA.enums.completion }) +
|
|
1902
|
+
field('这一次什么变了', 'progress.change', entry.change, { enum: DATA.enums.progressChange, required: true, help: '「无实质进展」也是正当答案。' }) +
|
|
1314
1903
|
'</div>' +
|
|
1315
|
-
field('
|
|
1316
|
-
field('实际结果', 'progress.actual', entry.actual, { multiline: true, required: true, help: '做了什么、结果如何。没有证据的结果会被缺口规则点名。' }) +
|
|
1317
|
-
idPicker('这一轮推进了哪些场景', 'progress.scenarioIds', null, project.plan.scenarios, entry.scenarioIds,
|
|
1318
|
-
'勾选这一轮实际验证过的场景。场景状态(已证明 / 待客户确认 / 无证据)由这里的勾选加上证据推导出来。') +
|
|
1319
|
-
idPicker('这一轮验证了哪些指标', 'progress.criteriaIds', null, project.plan.criteria, entry.criteriaIds,
|
|
1320
|
-
'与场景相互独立:一条指标可以被验证而没有推进任何场景。') +
|
|
1904
|
+
field('实际结果', 'progress.actual', entry.actual, { multiline: true, required: true, help: '做了什么、结果如何。' }) +
|
|
1321
1905
|
'<div class="field"><label class="field-label">证据<span class="req">*</span></label>' +
|
|
1322
|
-
'<p class="field-help"
|
|
1906
|
+
'<p class="field-help">没有证据的结果会被缺口规则点名。</p>' + evidenceRows +
|
|
1323
1907
|
'<button type="button" class="btn btn-sm" data-add="evidence">+ 加一条证据</button></div>' +
|
|
1324
1908
|
'<div class="grid-2">' +
|
|
1325
1909
|
field('同步对象', 'progress.customer.synced_with', entry.customer.synced_with, {}) +
|
|
1326
|
-
field('
|
|
1327
|
-
field('G3-1', 'progress.gate3_1', entry.gate3_1, { enum: DATA.enums.gate3_1 }) +
|
|
1328
|
-
field('G3-2', 'progress.gate3_2', entry.gate3_2, { enum: DATA.enums.gate3_2 }) +
|
|
1910
|
+
field('客户原话 / 反馈', 'progress.customer.feedback', entry.customer.feedback, { multiline: true, help: '照原样记,不要替他判断认可不认可。' }) +
|
|
1329
1911
|
'</div>' +
|
|
1330
|
-
|
|
1912
|
+
extras +
|
|
1331
1913
|
'</section>';
|
|
1332
1914
|
}
|
|
1333
1915
|
|
|
@@ -1336,7 +1918,7 @@ const FORM_SCRIPT = `
|
|
|
1336
1918
|
var next = project.progress.next;
|
|
1337
1919
|
return '<section class="sec">' +
|
|
1338
1920
|
'<header class="sec-head"><h2 class="sec-title">下一步工作目标及计划</h2>' +
|
|
1339
|
-
'
|
|
1921
|
+
'</header>' +
|
|
1340
1922
|
'<div class="grid-2">' +
|
|
1341
1923
|
field('下一步目标', 'progress.next.goal', next.goal, { multiline: true, required: true }) +
|
|
1342
1924
|
field('负责人', 'progress.next.owner', next.owner, {}) +
|
|
@@ -1348,87 +1930,130 @@ const FORM_SCRIPT = `
|
|
|
1348
1930
|
function identityCard(project) {
|
|
1349
1931
|
return '<section class="sec">' +
|
|
1350
1932
|
'<header class="sec-head"><h2 class="sec-title">基本信息</h2></header>' +
|
|
1933
|
+
'<p class="sec-hint">编号、阶段、状态由台账维护,这里只读。</p>' +
|
|
1351
1934
|
'<div class="grid-2">' +
|
|
1352
|
-
field('项目编号', 'pocId', project.pocId, { required: DATA.mode === 'blank', help: DATA.mode === 'blank' ? '新建时必填,格式 POC-XXX。' : '' }) +
|
|
1935
|
+
field('项目编号', 'pocId', project.pocId, { required: DATA.mode === 'blank', readonly: DATA.mode !== 'blank', help: DATA.mode === 'blank' ? '新建时必填,格式 POC-XXX。' : '台账主键,不可改。' }) +
|
|
1353
1936
|
field('项目名称', 'name', project.name, { required: true }) +
|
|
1354
1937
|
field('体系', 'system', project.system, { enum: DATA.enums.system }) +
|
|
1355
1938
|
field('客户公司', 'company', project.company, {}) +
|
|
1356
1939
|
field('部门', 'department', project.department, {}) +
|
|
1357
1940
|
field('预计金额(万元)', 'amountWan', project.amountWan, { number: true }) +
|
|
1358
1941
|
field('项目类型', 'pocType', project.pocType, { enum: DATA.enums.pocType }) +
|
|
1359
|
-
field('阶段', 'stage', project.stage, { enum: DATA.enums.stage }) +
|
|
1360
|
-
field('状态', 'status', project.status, { enum: DATA.enums.status }) +
|
|
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: '暂停/关闭请走评审流程。' }) +
|
|
1361
1944
|
field('进入阶段日期', 'stageSince', project.stageSince, { date: true, help: '不填就算不出停滞天数。' }) +
|
|
1362
1945
|
field('负责人(我方)', 'owner', project.owner, { required: true }) +
|
|
1363
1946
|
field('销售', 'sales', project.sales, {}) +
|
|
1364
|
-
field('客户技术责任人', 'techOwner', project.techOwner, { required: true, help: 'G0 五必填之一。' }) +
|
|
1365
1947
|
field('客户业务决策人', 'execSponsor', project.execSponsor, {}) +
|
|
1366
1948
|
'</div></section>';
|
|
1367
1949
|
}
|
|
1368
1950
|
|
|
1369
1951
|
/**
|
|
1370
|
-
* The
|
|
1952
|
+
* The project snapshot: where this project actually stands, at a glance.
|
|
1371
1953
|
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
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.
|
|
1376
1964
|
*/
|
|
1377
|
-
function
|
|
1378
|
-
var
|
|
1379
|
-
var gate0Filled = 0;
|
|
1965
|
+
function snapshotCard(project) {
|
|
1966
|
+
var g0Filled = 0;
|
|
1380
1967
|
for (var i = 0; i < DATA.g0Fields.length; i += 1) {
|
|
1381
|
-
if (text(project.gate0[DATA.g0Fields[i].key]).trim() !== '')
|
|
1968
|
+
if (text(project.gate0[DATA.g0Fields[i].key]).trim() !== '') g0Filled += 1;
|
|
1382
1969
|
}
|
|
1383
|
-
if (text(project.techOwner).trim() !== '')
|
|
1970
|
+
if (text(project.techOwner).trim() !== '') g0Filled += 1;
|
|
1971
|
+
var g0Tone = g0Filled === 5 ? 'ok' : g0Filled === 0 ? 'warn' : 'info';
|
|
1384
1972
|
|
|
1385
|
-
var
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
var
|
|
1390
|
-
? '
|
|
1391
|
-
: '
|
|
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 : '无日期');
|
|
1392
1985
|
|
|
1393
1986
|
var conclusion = text(project.gate0.conclusion).trim();
|
|
1394
|
-
var
|
|
1395
|
-
var
|
|
1396
|
-
if (conclusion === '通过' && gate0Filled === 5) {
|
|
1397
|
-
gateTone = 'amber';
|
|
1398
|
-
gateValue = '五必填已齐且评审通过 —— 可以申请升 G1';
|
|
1399
|
-
} else if (conclusion === '未通过-退出' || conclusion === '未通过-降级') {
|
|
1400
|
-
gateTone = 'red';
|
|
1401
|
-
gateValue = 'G0 结论「' + conclusion + '」,不再提示升级';
|
|
1402
|
-
} else if (gate0Filled === 5) {
|
|
1403
|
-
gateTone = 'green';
|
|
1404
|
-
gateValue = '五必填已齐,可以安排 G0 评审';
|
|
1405
|
-
} else {
|
|
1406
|
-
gateValue = '还缺 ' + (5 - gate0Filled) + ' 项,评审前要补齐';
|
|
1407
|
-
}
|
|
1987
|
+
var gateValue = conclusion === '' ? '待评审' : conclusion;
|
|
1988
|
+
var gateTone = conclusion === '通过' ? 'ok' : conclusion === '' ? 'muted' : 'warn';
|
|
1408
1989
|
|
|
1409
|
-
var
|
|
1410
|
-
var
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
'
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
(DATA.intent === 'new' ? '' :
|
|
1424
|
-
'<div class="ready-cell"><span class="ready-label">计划聚焦</span>' +
|
|
1425
|
-
'<span class="ready-value">' + escapeHtml(focusValue) +
|
|
1426
|
-
(focusTone === 'green' ? '' : ' · 要求指标 2–3、场景 3–5') + '</span></div>') +
|
|
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') +
|
|
1427
2004
|
'</section>';
|
|
1428
2005
|
}
|
|
1429
2006
|
|
|
2007
|
+
|
|
1430
2008
|
/**
|
|
1431
|
-
*
|
|
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.
|
|
1432
2057
|
*
|
|
1433
2058
|
* Commitments left (Gate 0, criteria, scenarios), the record right (identity,
|
|
1434
2059
|
* plan narrative, risks, gates), next actions closing across both. That is the
|
|
@@ -1483,34 +2108,61 @@ const FORM_SCRIPT = `
|
|
|
1483
2108
|
var canEdit = {};
|
|
1484
2109
|
for (var e = 0; e < plan_.editable.length; e += 1) canEdit[plan_.editable[e]] = true;
|
|
1485
2110
|
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
//
|
|
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.
|
|
1489
2116
|
if (DATA.intent === 'progress') {
|
|
1490
|
-
|
|
1491
|
-
byId('formBody').innerHTML = body;
|
|
2117
|
+
byId('formBody').innerHTML = banner + historyCard(project) + progressCard(project) + nextCard(project);
|
|
1492
2118
|
bindSwitch();
|
|
1493
2119
|
markFooter();
|
|
1494
2120
|
return;
|
|
1495
2121
|
}
|
|
1496
2122
|
|
|
2123
|
+
var body = banner + snapshotCard(project) + missingCard(project, canEdit);
|
|
2124
|
+
|
|
1497
2125
|
var left = '';
|
|
1498
2126
|
if (canEdit.gate0) left += g0Card(project); else left += contextGate0(project);
|
|
1499
|
-
|
|
1500
|
-
//
|
|
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
|
+
|
|
1501
2136
|
if (canEdit.plan) left += planCard(project);
|
|
1502
|
-
else if (
|
|
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);
|
|
1503
2143
|
|
|
1504
2144
|
var right = '';
|
|
1505
2145
|
if (canEdit.identity) right += identityCard(project); else right += contextIdentity(project);
|
|
1506
2146
|
if (canEdit.plan) right += planNarrative(project) + riskCard(project);
|
|
1507
2147
|
if (canEdit.gate12) right += gateCard(project);
|
|
1508
|
-
if (canEdit.outcome) right += outcomeCard(project);
|
|
1509
2148
|
|
|
1510
2149
|
if (left !== '') body += '<div class="columns"><div class="col">' + left + '</div><div class="col">' + right + '</div></div>';
|
|
1511
2150
|
else if (right !== '') body += '<div class="columns"><div class="col"></div><div class="col">' + right + '</div></div>';
|
|
1512
2151
|
|
|
1513
|
-
|
|
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
|
+
}
|
|
1514
2166
|
|
|
1515
2167
|
byId('formBody').innerHTML = body;
|
|
1516
2168
|
bindSwitch();
|
|
@@ -1538,7 +2190,16 @@ const FORM_SCRIPT = `
|
|
|
1538
2190
|
info.textContent = intentLabel() + ' · 共 ' + DATA.projects.length + ' 个项目 · 草稿自动保存在本机浏览器';
|
|
1539
2191
|
}
|
|
1540
2192
|
|
|
1541
|
-
/**
|
|
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
|
+
*/
|
|
1542
2203
|
function contextGate0(project) {
|
|
1543
2204
|
var present = 0;
|
|
1544
2205
|
for (var i = 0; i < DATA.g0Fields.length; i += 1) {
|
|
@@ -1546,21 +2207,143 @@ const FORM_SCRIPT = `
|
|
|
1546
2207
|
}
|
|
1547
2208
|
if (text(project.techOwner).trim() !== '') present += 1;
|
|
1548
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
|
+
|
|
1549
2221
|
return '<section class="sec">' +
|
|
1550
|
-
'<header class="sec-head"><h2 class="sec-title">Gate 0 ·
|
|
2222
|
+
'<header class="sec-head"><h2 class="sec-title">Gate 0 · 值不值得做</h2>' +
|
|
1551
2223
|
'<span class="sec-kicker"><span class="badge ' + tone + '">五必填 ' + present + ' / 5</span></span></header>' +
|
|
1552
|
-
'<
|
|
2224
|
+
'<details class="read-context"><summary>已完成的立项内容(只读,点开查看)</summary>' +
|
|
2225
|
+
'<dl class="read-grid">' + rows + '</dl></details>' +
|
|
2226
|
+
'<p class="sec-hint">要改 Gate 0,请单独导出「补充信息」表单并选择 G0 阶段。</p>' +
|
|
1553
2227
|
'</section>';
|
|
1554
2228
|
}
|
|
1555
2229
|
|
|
1556
|
-
/**
|
|
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
|
+
*/
|
|
1557
2245
|
function contextPlan(project) {
|
|
1558
2246
|
var crit = project.plan.criteria.length;
|
|
1559
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
|
+
}
|
|
1560
2298
|
return '<section class="sec">' +
|
|
1561
|
-
'<header class="sec-head"><h2 class="sec-title">方案 ·
|
|
2299
|
+
'<header class="sec-head"><h2 class="sec-title">方案 · 已确认内容</h2>' +
|
|
1562
2300
|
'<span class="sec-kicker">指标 ' + crit + ' · 场景 ' + scn + '</span></header>' +
|
|
1563
|
-
'<
|
|
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 +
|
|
1564
2347
|
'</section>';
|
|
1565
2348
|
}
|
|
1566
2349
|
|
|
@@ -1820,60 +2603,151 @@ const FORM_SCRIPT = `
|
|
|
1820
2603
|
var raw = text(value).trim();
|
|
1821
2604
|
return raw === '' ? null : raw;
|
|
1822
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
|
+
|
|
1823
2653
|
var criteria = [];
|
|
1824
|
-
for (var i = 0; i < project.plan.criteria.length; i += 1) {
|
|
2654
|
+
if (inScope('plan')) for (var i = 0; i < project.plan.criteria.length; i += 1) {
|
|
1825
2655
|
var c = project.plan.criteria[i];
|
|
1826
2656
|
if (text(c.name).trim() === '') continue;
|
|
1827
2657
|
criteria.push({ id: orNull(c.id), name: text(c.name).trim(), metric: orNull(c.metric), baseline: orNull(c.baseline), target: orNull(c.target) });
|
|
1828
2658
|
}
|
|
1829
2659
|
var scenarios = [];
|
|
1830
|
-
for (var j = 0; j < project.plan.scenarios.length; j += 1) {
|
|
2660
|
+
if (inScope('plan')) for (var j = 0; j < project.plan.scenarios.length; j += 1) {
|
|
1831
2661
|
var sc = project.plan.scenarios[j];
|
|
1832
2662
|
if (text(sc.name).trim() === '') continue;
|
|
1833
2663
|
scenarios.push({ id: orNull(sc.id), name: text(sc.name).trim(), goal: orNull(sc.goal) });
|
|
1834
2664
|
}
|
|
1835
2665
|
var risks = [];
|
|
1836
|
-
for (var k = 0; k < project.plan.risks.length; k += 1) {
|
|
2666
|
+
if (inScope('plan')) for (var k = 0; k < project.plan.risks.length; k += 1) {
|
|
1837
2667
|
var r = project.plan.risks[k];
|
|
1838
2668
|
if (text(r.name).trim() === '') continue;
|
|
1839
2669
|
risks.push({ name: text(r.name).trim(), level: orNull(r.level), mitigation: orNull(r.mitigation) });
|
|
1840
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
|
+
|
|
1841
2682
|
var rounds = [];
|
|
1842
2683
|
var entry = project.progress;
|
|
1843
2684
|
var touched = text(entry.date).trim() !== '' || text(entry.actual).trim() !== '' || text(entry.goal).trim() !== '';
|
|
1844
|
-
if (touched) rounds.push(progressEntryOf(entry));
|
|
2685
|
+
if (inScope('progress') && touched) rounds.push(progressEntryOf(entry));
|
|
2686
|
+
var outcome = project.outcome || {};
|
|
2687
|
+
var amount = text(project.amountWan).trim();
|
|
1845
2688
|
return {
|
|
1846
2689
|
schema_version: DATA.schemaVersion,
|
|
1847
2690
|
poc_id: text(project.pocId).trim(),
|
|
1848
|
-
name:
|
|
1849
|
-
org: {
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
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),
|
|
1856
2703
|
stage: project.stage,
|
|
1857
2704
|
status: project.status,
|
|
1858
|
-
stage_since:
|
|
2705
|
+
stage_since: changed('identity', 'stageSince', project.stageSince),
|
|
1859
2706
|
gate0: {
|
|
1860
|
-
why_customer:
|
|
1861
|
-
why_us:
|
|
1862
|
-
decision_chain:
|
|
1863
|
-
post_poc_decision:
|
|
1864
|
-
competitor:
|
|
1865
|
-
review: {
|
|
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
|
+
}
|
|
1866
2717
|
},
|
|
1867
2718
|
plan: {
|
|
1868
|
-
customer_pain:
|
|
1869
|
-
expected_recognition:
|
|
1870
|
-
our_edge:
|
|
1871
|
-
criteria: criteria,
|
|
1872
|
-
scenarios: scenarios,
|
|
1873
|
-
risks: risks,
|
|
1874
|
-
timeline: {
|
|
1875
|
-
|
|
1876
|
-
|
|
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)
|
|
1877
2751
|
},
|
|
1878
2752
|
progress: rounds
|
|
1879
2753
|
};
|
|
@@ -1923,9 +2797,78 @@ const FORM_SCRIPT = `
|
|
|
1923
2797
|
if (node.scrollIntoView) node.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
1924
2798
|
}
|
|
1925
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
|
+
|
|
1926
2864
|
function downloadYaml() {
|
|
1927
2865
|
if (!validateRequired()) {
|
|
1928
|
-
|
|
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' });
|
|
1929
2872
|
return;
|
|
1930
2873
|
}
|
|
1931
2874
|
var stamp = DATA.today.replace(/-/g, '');
|
|
@@ -1945,32 +2888,296 @@ const FORM_SCRIPT = `
|
|
|
1945
2888
|
save(true);
|
|
1946
2889
|
}
|
|
1947
2890
|
|
|
1948
|
-
/**
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
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;
|
|
1970
2917
|
}
|
|
1971
|
-
|
|
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);
|
|
1972
2940
|
}
|
|
1973
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
|
+
|
|
1974
3181
|
function initState() {
|
|
1975
3182
|
storageAvailable = probeStorage();
|
|
1976
3183
|
if (!storageAvailable) {
|
|
@@ -1994,6 +3201,7 @@ const FORM_SCRIPT = `
|
|
|
1994
3201
|
if (byId('clearBtn')) byId('clearBtn').addEventListener('click', clearDraft);
|
|
1995
3202
|
if (byId('previewBtn')) byId('previewBtn').addEventListener('click', previewYaml);
|
|
1996
3203
|
if (byId('downloadBtn')) byId('downloadBtn').addEventListener('click', downloadYaml);
|
|
3204
|
+
if (byId('returnBtn')) byId('returnBtn').addEventListener('click', downloadReturnFile);
|
|
1997
3205
|
setInterval(function () { save(true); }, 30000);
|
|
1998
3206
|
window.addEventListener('beforeunload', function () { save(true); });
|
|
1999
3207
|
`;
|