127 lines
6.0 KiB
Go Template
127 lines
6.0 KiB
Go Template
{{define "task-new"}}
|
|
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<title>{{.Page.Title}} - 采购任务管理</title>
|
|
{{template "document-head" .}}
|
|
</head>
|
|
<body>
|
|
{{template "site-header" .}}
|
|
<main id="main-content" class="page form-page">
|
|
<div class="title-row">
|
|
<div>
|
|
<h1>新建采购任务</h1>
|
|
<p class="subtitle">填写商品要求和不可覆盖的采购约束</p>
|
|
</div>
|
|
</div>
|
|
|
|
{{if or .Notice .Errors.Form}}
|
|
<div class="notice notice-error" role="alert" tabindex="-1" data-error-summary>
|
|
{{if .Notice}}<p>{{.Notice}}</p>{{end}}
|
|
{{if .Errors.Form}}<p>{{.Errors.Form}}</p>{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
<form class="task-form" method="post" action="/tasks" enctype="multipart/form-data"
|
|
novalidate data-dirty-form data-submit-form>
|
|
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">
|
|
<input type="hidden" name="upload_key" value="{{.UploadKey}}">
|
|
<input type="hidden" name="create_key" value="{{.CreateKey}}">
|
|
<input type="hidden" name="image_asset_id" value="{{.UploadedAsset.ID}}">
|
|
|
|
<section class="form-section" aria-labelledby="requirement-heading">
|
|
<h2 id="requirement-heading">商品要求</h2>
|
|
<div class="form-grid">
|
|
<div class="field span-2">
|
|
<label for="title">商品标题 <span class="required-text">必填</span></label>
|
|
<input id="title" name="title" value="{{.Form.Title}}" maxlength="120" required
|
|
autocomplete="off" aria-describedby="title-error"
|
|
{{if .Errors.Title}}aria-invalid="true" data-error-field{{end}}>
|
|
<p id="title-error" class="field-error">{{.Errors.Title}}</p>
|
|
</div>
|
|
|
|
<div class="field span-2">
|
|
<label for="sku">SKU <span class="required-text">必填</span></label>
|
|
<input id="sku" name="sku" value="{{.Form.SKU}}" maxlength="512" required
|
|
autocomplete="off" aria-describedby="sku-help sku-error"
|
|
{{if .Errors.SKU}}aria-invalid="true" data-error-field{{end}}>
|
|
<p id="sku-help" class="field-help">填写采购时用于核对的商品规格编号。</p>
|
|
<p id="sku-error" class="field-error">{{.Errors.SKU}}</p>
|
|
</div>
|
|
|
|
<div class="field span-2">
|
|
<label for="description">商品描述</label>
|
|
<textarea id="description" name="description" maxlength="8192"
|
|
aria-describedby="description-help description-error"
|
|
{{if .Errors.Description}}aria-invalid="true" data-error-field{{end}}>{{.Form.Description}}</textarea>
|
|
<p id="description-help" class="field-help">只填写采购判断所需信息,不填写订单、地址或个人信息。</p>
|
|
<p id="description-error" class="field-error">{{.Errors.Description}}</p>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="quantity">数量 <span class="required-text">必填</span></label>
|
|
<input id="quantity" name="quantity" type="number" value="{{.Form.Quantity}}"
|
|
min="1" step="1" inputmode="numeric" required aria-describedby="quantity-error"
|
|
{{if .Errors.Quantity}}aria-invalid="true" data-error-field{{end}}>
|
|
<p id="quantity-error" class="field-error">{{.Errors.Quantity}}</p>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="max-budget">最高总预算(元)</label>
|
|
<input id="max-budget" name="max_budget" type="text" value="{{.Form.MaxBudget}}"
|
|
inputmode="decimal" placeholder="不填写则不设上限"
|
|
aria-describedby="budget-help budget-error"
|
|
{{if .Errors.MaxBudget}}aria-invalid="true" data-error-field{{end}}>
|
|
<p id="budget-help" class="field-help">数量合计的最高预算,不是单件价格。</p>
|
|
<p id="budget-error" class="field-error">{{.Errors.MaxBudget}}</p>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="form-section" aria-labelledby="image-heading">
|
|
<h2 id="image-heading">参考图片</h2>
|
|
<div class="upload-layout">
|
|
<div class="field">
|
|
<label for="image">商品参考图 <span class="required-text">必填</span></label>
|
|
{{if .UploadedAsset.ID}}
|
|
<p class="retained-file">已保留上传成功的参考图片</p>
|
|
<p class="field-help">再次提交会复用该图片,不会重复上传。</p>
|
|
{{else}}
|
|
<input id="image" name="image" type="file"
|
|
accept="image/png,image/jpeg,image/webp" required
|
|
aria-describedby="image-help image-error"
|
|
{{if .Errors.Image}}aria-invalid="true" data-error-field{{end}}>
|
|
<p id="image-help" class="field-help">支持 JPG、PNG、WebP;服务端会校验实际内容。</p>
|
|
{{end}}
|
|
<p id="image-error" class="field-error">{{.Errors.Image}}</p>
|
|
</div>
|
|
<figure class="image-preview">
|
|
<div class="image-placeholder" data-image-placeholder>尚未选择图片</div>
|
|
<img alt="待上传的商品参考图预览" data-image-preview hidden>
|
|
<figcaption data-image-name>
|
|
{{if .UploadedAsset.ID}}参考图片已保留{{else}}选择后仅在本地预览{{end}}
|
|
</figcaption>
|
|
</figure>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="form-actions">
|
|
<a class="button" href="/tasks">取消</a>
|
|
<button class="button primary" type="submit" data-submit-button
|
|
data-loading-label="正在创建…">创建任务</button>
|
|
</div>
|
|
</form>
|
|
</main>
|
|
|
|
<dialog class="confirm-dialog" data-leave-dialog aria-labelledby="leave-title">
|
|
<h2 id="leave-title">放弃未提交内容?</h2>
|
|
<p>已填写的商品要求不会保存。</p>
|
|
<div class="dialog-actions">
|
|
<button class="button" type="button" data-stay>继续填写</button>
|
|
<a class="button danger" href="/tasks" data-discard>放弃并离开</a>
|
|
</div>
|
|
</dialog>
|
|
</body>
|
|
</html>
|
|
{{end}}
|