feat: 统一蝦皮与顺运宝 PDD 关联入口 (#68)

This commit is contained in:
chengma
2026-08-09 22:40:58 +08:00
parent eb0e296b7c
commit 518e6df349
14 changed files with 429 additions and 98 deletions
+42 -40
View File
@@ -1,61 +1,65 @@
{{define "shopee/detail_modal"}}
{{/* 双击一行时弹出的内容。
这是一个**片段**,不是整页——外面的弹窗壳子在 shopee/list.html 里。
`[必须]` 这个弹窗只读,没有保存表单——ShopeeSave 仍是 501,
不要放一个点了没反应的保存按钮,见工单 #41。 */}}
{{with .D}}
<div class="modal-head">
<h2>商品 {{.GoodsID}}</h2>
<button type="button" class="modal-x" data-modal-close aria-label="关闭">×</button>
</div>
<div class="modal-body">
<div class="modal-body form-stack">
<dl class="detail">
<dt>商品名称</dt><dd>{{.Title}}</dd>
<dt>蝦皮状态</dt><dd>{{.ShopeeStatus}}</dd>
<dt>主商品货号</dt><dd>{{.MainSKUCode}}</dd>
{{/* PDD 链接本工单只读展示,不做保存,见 #41「不做」清单 */}}
<dt>PDD 链接</dt>
<dd{{if .PddMissing}} class="missing"{{end}}>{{.PddURL}}</dd>
<dt>采集状态</dt><dd>{{.StatusText}}</dd>
<dt>PDD 商品 ID</dt><dd{{if .PddMissing}} class="missing"{{end}}>{{if .PddGoodsID}}{{.PddGoodsID}}{{else}}未关联{{end}}</dd>
<dt>采集状态</dt><dd>{{.StatusText}}{{if .CollectMsg}}:{{.CollectMsg}}{{end}}</dd>
</dl>
<h3>
规格({{len .SKUs}} 个{{if gt .PendingCount 0}},{{.PendingCount}} 个待人工补{{end}})
</h3>
<form method="post" action="/shopee/save" class="form-stack">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<input type="hidden" name="shopee_goods_id" value="{{.GoodsID}}">
<input type="hidden" name="list_goods_id" value="{{$.Keyword}}">
<input type="hidden" name="status" value="{{$.StatusFilter}}">
<input type="hidden" name="page" value="{{$.CurrentPage}}">
<div class="field">
<label for="shopee-pdd-url">PDD 商品链接</label>
<input id="shopee-pdd-url" type="url" name="pdd_url" value="{{.PddURL}}" required placeholder="https://mobile.yangkeduo.com/goods.html?goods_id=...">
<small>保存后会按链接中的 goods_id 建立或复用 PDD 商品档案。</small>
</div>
{{if .PddGoodsID}}
<label class="check-line">
<input type="checkbox" name="confirm_replace" value="1">
如果新链接是其他商品,我确认更换当前关联(现有规格映射不会删除)
</label>
{{end}}
<div><button type="submit" class="primary">保存 PDD 关联</button></div>
</form>
{{if .PddGoodsID}}
<form method="post" action="/shopee/collect" class="inline">
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
<input type="hidden" name="shopee_goods_id" value="{{.GoodsID}}">
<input type="hidden" name="list_goods_id" value="{{$.Keyword}}">
<input type="hidden" name="status" value="{{$.StatusFilter}}">
<input type="hidden" name="page" value="{{$.CurrentPage}}">
{{if .CanCollect}}
<button type="submit">{{if eq .CollectStatus "failed"}}重新创建采集任务{{else}}创建采集任务{{end}}</button>
{{else}}
<span class="hint">{{if eq .CollectStatus "collecting"}}采集任务正在执行,请稍后刷新。{{else}}PDD 数据已采集,可继续处理顺运宝规格映射。{{end}}</span>
{{end}}
</form>
{{end}}
<h3>规格({{len .SKUs}} 个{{if gt .PendingCount 0}},{{.PendingCount}} 个待人工补{{end}})</h3>
{{if not .SKUs}}
<p class="missing">这个商品在报表里没有任何 SKU。</p>
{{else}}
<div class="table-wrap">
<table>
<thead>
<tr>
<th>规格ID</th>
<th>颜色</th>
<th>尺码</th>
<th>建議</th>
{{/* 状态列要有文字(✓ / 待补),不能只靠颜色区分,见 #41 */}}
<th>状态</th>
</tr>
</thead>
<thead><tr><th>规格ID</th><th>颜色</th><th>尺码</th><th>建議</th><th>状态</th></tr></thead>
<tbody>
{{range .SKUs}}
<tr{{if .Pending}} class="row-warn"{{end}}>
<td>{{.SKUID}}</td>
<td>{{.Color}}</td>
<td>{{.Size}}</td>
<td>{{.Advice}}</td>
<td>{{.StatusText}}</td>
</tr>
{{if .Pending}}
{{/* `[必须]` 待补的行要显示 spec_raw 原文——不显示的话人工不知道
该填什么,这正是保留原文这个设计的全部意义,见 #41。 */}}
<tr class="row-warn">
<td colspan="5"><small>原文:{{.SpecRaw}}</small></td>
</tr>
{{end}}
<tr{{if .Pending}} class="row-warn"{{end}}><td>{{.SKUID}}</td><td>{{.Color}}</td><td>{{.Size}}</td><td>{{.Advice}}</td><td>{{.StatusText}}</td></tr>
{{if .Pending}}<tr class="row-warn"><td colspan="5"><small>原文:{{.SpecRaw}}</small></td></tr>{{end}}
{{end}}
</tbody>
</table>
@@ -63,8 +67,6 @@
{{end}}
</div>
<div class="modal-foot">
<button type="button" data-modal-close>关闭</button>
</div>
<div class="modal-foot"><button type="button" data-modal-close>关闭</button></div>
{{end}}
{{end}}