feat: 支持批量导入 PDD 商品链接 (#104)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
{{/* 文案写全「添加 PDD 商品」:这条工具条上还有「创建采集任务」,
|
||||
两个都以「创建」开头的话,第一次用的人分不清哪个是加商品、哪个是发起采集。 */}}
|
||||
<button type="button" data-modal-open="create-modal">添加 PDD 商品</button>
|
||||
<button type="button" data-modal-open="import-modal">批量导入</button>
|
||||
|
||||
{{/* 「创建采集任务」和「删除」用的是**同一个表单**,靠按钮上的
|
||||
formaction 决定提交到哪个地址。这样表格里的勾选框只需要挂一份,
|
||||
@@ -21,6 +22,7 @@
|
||||
{{/* 文案是「创建采集任务」不是「采集」:点完只是排了个队,
|
||||
真正去手机上采要等客户端来领,可能几秒也可能几分钟 */}}
|
||||
<button type="button" data-modal-open="collect-modal" data-collect-open
|
||||
data-collect-form="pdd-form"
|
||||
data-need-checked>创建采集任务</button>
|
||||
|
||||
<form class="inline grow" method="get" action="/pdd">
|
||||
@@ -44,6 +46,61 @@
|
||||
>删除</button>
|
||||
</div>
|
||||
|
||||
{{/* 导入结果紧跟工具条:采购员上传后先核对统计和错误,再决定是否发采集任务。 */}}
|
||||
{{with .ImportResult}}
|
||||
<section class="import-result" aria-labelledby="pdd-import-result-title" aria-live="polite">
|
||||
<div class="import-result-head">
|
||||
<div>
|
||||
<h2 id="pdd-import-result-title">本次导入结果</h2>
|
||||
<p>
|
||||
总行数 <strong>{{.TotalRows}}</strong> ·
|
||||
新建 <strong>{{.CreatedCount}}</strong> ·
|
||||
已存在 <strong>{{.ExistingCount}}</strong> ·
|
||||
恢复 <strong>{{.RevivedCount}}</strong> ·
|
||||
文件内重复 <strong>{{.DuplicateCount}}</strong> ·
|
||||
失败 <strong>{{len .Failures}}</strong>
|
||||
</p>
|
||||
</div>
|
||||
{{if .GoodsIDs}}
|
||||
<button type="button" class="primary" data-modal-open="import-collect-modal"
|
||||
data-collect-open data-collect-form="pdd-import-collect-form"
|
||||
data-collect-count-value="{{len .GoodsIDs}}">
|
||||
为本次导入商品创建采集任务
|
||||
</button>
|
||||
{{end}}
|
||||
</div>
|
||||
<p class="hint">
|
||||
上传只建立商品档案,不会自动采集。创建任务时,已采集或正在采集的商品仍按现有规则跳过。
|
||||
</p>
|
||||
|
||||
<form id="pdd-import-collect-form" method="post" action="/pdd/collect" hidden>
|
||||
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
||||
{{range .GoodsIDs}}<input type="hidden" name="ids" value="{{.}}">{{end}}
|
||||
</form>
|
||||
|
||||
{{if .Failures}}
|
||||
<div class="table-wrap import-failure-table" role="region" aria-label="PDD 导入失败明细" tabindex="0">
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Excel 行号</th><th>原始内容</th><th>失败原因与处理建议</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Failures}}
|
||||
<tr class="row-warn">
|
||||
<td>{{.Row}}</td>
|
||||
<td class="import-raw">{{.Raw}}</td>
|
||||
<td class="import-reason">{{.Reason}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<p class="import-success">所有非空数据行均已处理,没有失败行。</p>
|
||||
{{end}}
|
||||
</section>
|
||||
{{end}}
|
||||
|
||||
{{/* 第二段:表格。双击一行打开弹窗,见 static/js/app.js */}}
|
||||
<div class="table-wrap" id="pddProductPage">
|
||||
<table>
|
||||
@@ -92,7 +149,7 @@
|
||||
<small>换个采集状态或清空搜索词再试。<a href="/pdd">查看全部</a></small>
|
||||
{{else}}
|
||||
还没有 PDD 商品。<br>
|
||||
<small>点左上角「创建」,粘贴一个拼多多商品链接就行,其余信息采集后自动回填。</small>
|
||||
<small>点左上角「添加 PDD 商品」粘贴单条链接,或用「批量导入」上传 Excel。</small>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -139,6 +196,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{/* ── 批量导入弹窗 ─────────────────────────────── */}}
|
||||
<div class="modal-backdrop" id="import-modal" hidden>
|
||||
<div class="modal modal-narrow" role="dialog" aria-modal="true" aria-labelledby="import-modal-title">
|
||||
<div class="modal-head">
|
||||
<h2 id="import-modal-title">批量导入 PDD 链接</h2>
|
||||
<button type="button" class="modal-x" data-modal-close aria-label="关闭">×</button>
|
||||
</div>
|
||||
<form method="post" action="/pdd/import" enctype="multipart/form-data" data-upload-form>
|
||||
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
|
||||
<div class="modal-body">
|
||||
<div class="field">
|
||||
<label for="pdd-import-file">Excel 文件</label>
|
||||
<input id="pdd-import-file" type="file" name="file" accept=".xlsx" required autofocus
|
||||
aria-describedby="pdd-import-help">
|
||||
</div>
|
||||
<p class="hint" id="pdd-import-help">
|
||||
仅支持不超过 10MB 的 <code>.xlsx</code>。第一个非空工作表第一列的表头必须是
|
||||
“拼多多链接”,每行填写一个带 <code>goods_id=</code> 的完整链接,最多 5000 条;
|
||||
空工作表和空行会自动忽略。
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<button type="button" data-modal-close>取消</button>
|
||||
<button type="submit" class="primary" data-upload-submit>开始导入</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{/* ── 批量采集确认弹窗 ─────────────────────────
|
||||
客户端是可选项,默认留空。服务端仍会按当前账号重新校验候选范围。 */}}
|
||||
<div class="modal-backdrop" id="collect-modal" hidden>
|
||||
@@ -170,6 +256,39 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{/* ── 本次导入商品的采集确认弹窗 ─────────────────
|
||||
IDs 来自刚完成的服务端导入结果,不受当前页分页影响。 */}}
|
||||
{{with .ImportResult}}{{if .GoodsIDs}}
|
||||
<div class="modal-backdrop" id="import-collect-modal" hidden>
|
||||
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="import-collect-modal-title">
|
||||
<div class="modal-head">
|
||||
<h2 id="import-collect-modal-title">为本次导入商品创建采集任务</h2>
|
||||
<button type="button" class="modal-x" data-modal-close aria-label="关闭">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>将按现有状态规则处理本次导入的 <strong data-collect-count>{{len .GoodsIDs}}</strong> 个商品。</p>
|
||||
<div class="field">
|
||||
<label for="import-collect-client">执行客户端</label>
|
||||
<select id="import-collect-client" name="client_id" form="pdd-import-collect-form" autofocus>
|
||||
<option value="">不指定(任意客户端可领取)</option>
|
||||
{{range $.AssignableClients}}
|
||||
<option value="{{.ClientID}}">{{.Name}}({{.ClientID}},{{.Status}})</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<p class="hint">
|
||||
上传本身没有创建任务。确认后才会建任务;已采集、正在采集和重复项会分别统计并跳过。
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<button type="button" data-modal-close>取消</button>
|
||||
<button type="submit" form="pdd-import-collect-form" class="primary"
|
||||
data-collect-submit>确认创建</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}{{end}}
|
||||
|
||||
{{/* ── 编辑弹窗的壳子 ───────────────────────────
|
||||
里面的内容双击行时由 /pdd/detail 返回,前端只负责放进来和显示。 */}}
|
||||
<div class="modal-backdrop" id="detail-modal" data-detail-url="{{.DetailURL}}" hidden>
|
||||
|
||||
Reference in New Issue
Block a user