Commit a4618219 by 黄南光

优化前端

1 parent 98413923
...@@ -11,3 +11,12 @@ ...@@ -11,3 +11,12 @@
- 后端不动(数据已齐全:Line 带 category/so_hit/grp,page_state 传 stock_categories/so_months) - 后端不动(数据已齐全:Line 带 category/so_hit/grp,page_state 传 stock_categories/so_months)
- vue-tsc 类型检查通过(exit 0,零错误) - vue-tsc 类型检查通过(exit 0,零错误)
- 决策来源:老大拍板 ①大组+子组全选 ②空分类归未分类 ③so_months 跟配置走(补货规则页可配) - 决策来源:老大拍板 ①大组+子组全选 ②空分类归未分类 ③so_months 跟配置走(补货规则页可配)
## 子组折叠 + 级联层次感(追加)
- 需求:①大组/子组要有级联层次感 ②每个二级分类子组能独立折叠收缩
- 改动:
- mobile.css:.m-section 改成色块条(浅蓝背景+圆角);新增 .m-subgroup(左竖线+缩进包裹子组);新增 .m-sub-toggle(可点击折叠区+▸▾箭头)
- OrderPage.vue:子组从 template v-for 改成 div.m-subgroup 包裹;子组标题拆成 checkbox(全选) + .m-sub-toggle(标题+项数+箭头);卡片加 v-show="!isCollapsed(...)" 控制折叠
- script:新增 collapsed ref + toggleGroup/isCollapsed/gkey 函数
- 交互:点子组标题区折叠/展开(▸折叠 / ▾展开);checkbox 方框做子组全选;默认全部展开
- vue-tsc 类型检查通过
...@@ -26,6 +26,7 @@ const seq = ref(0) // 当前编辑基于第几轮取数( ...@@ -26,6 +26,7 @@ const seq = ref(0) // 当前编辑基于第几轮取数(
const left = ref(0) const left = ref(0)
const busy = ref(false) const busy = ref(false)
const showOthers = ref(false) const showOthers = ref(false)
const collapsed = ref<Record<string, boolean>>({})
const preview = ref({ show: false, start: 0 }) const preview = ref({ show: false, start: 0 })
let deadline = 0 let deadline = 0
let poll: any = null let poll: any = null
...@@ -207,6 +208,13 @@ function expand() { ...@@ -207,6 +208,13 @@ function expand() {
showOthers.value = !showOthers.value showOthers.value = !showOthers.value
if (showOthers.value) event('expand', { count: otherCount.value }) if (showOthers.value) event('expand', { count: otherCount.value })
} }
const gkey = (prefix: string, label: string) => prefix + ':' + label
function toggleGroup(prefix: string, label: string) {
const k = gkey(prefix, label)
collapsed.value[k] = !collapsed.value[k]
event('toggle_sub', { group: k, collapsed: collapsed.value[k] })
}
const isCollapsed = (prefix: string, label: string) => !!collapsed.value[gkey(prefix, label)]
const payload = () => ({ lines: Object.entries(edits.value).map(([part_no, e]) => ({ part_no, ...e })) }) const payload = () => ({ lines: Object.entries(edits.value).map(([part_no, e]) => ({ part_no, ...e })) })
async function refresh() { async function refresh() {
...@@ -357,19 +365,31 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli ...@@ -357,19 +365,31 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli
<!-- 定时补货:历史常备件(按零件分类二级分组) --> <!-- 定时补货:历史常备件(按零件分类二级分组) -->
<template v-else-if="!['creating', 'screenshotting', 'awaiting_submit', 'submitting', 'done'].includes(status) || !st.run.order_no"> <template v-else-if="!['creating', 'screenshotting', 'awaiting_submit', 'submitting', 'done'].includes(status) || !st.run.order_no">
<div class="m-section">建议补货 <span>历史常备件 {{ stockAllLines.length }} 项 · 期望默认取「库存 + 出库」(推荐),填过的带上次的值(上次)</span></div> <div class="m-section">
<div class="m-section-head">
<div class="m-section-title"><small>建议补货</small>历史常备件</div>
<div class="m-section-meta"><span class="m-section-count">{{ stockAllLines.length }} 项</span></div>
</div>
<div class="m-section-desc">默认勾选 · 期望取「库存 + 出库」,修改过的沿用上次值</div>
<div v-if="editing && stockAllLines.length" class="m-allbar"> <div v-if="editing && stockAllLines.length" class="m-allbar">
<van-checkbox :model-value="allChecked(stockAllLines)" :indeterminate="someChecked(stockAllLines)" icon-size="18px" <van-checkbox :model-value="allChecked(stockAllLines)" :indeterminate="someChecked(stockAllLines)" icon-size="18px"
@update:model-value="(v: boolean) => toggleAll(stockAllLines, v, 'stock')"> @update:model-value="(v: boolean) => toggleAll(stockAllLines, v, 'stock')">
全选 <span>已选 {{ checkedCount(stockAllLines) }} / {{ stockAllLines.length }}</span></van-checkbox> 全选本组 <span>已选 {{ checkedCount(stockAllLines) }} / {{ stockAllLines.length }}</span></van-checkbox>
</div> </div>
<template v-for="(g, gi) in stockGroups" :key="g.label + gi">
<div class="m-subsection">
<van-checkbox v-if="editing" :model-value="allChecked(g.lines)" :indeterminate="someChecked(g.lines)" icon-size="16px"
@update:model-value="(v: boolean) => toggleAll(g.lines, v, 'stock')">{{ g.label }}</van-checkbox>
<template v-else>{{ g.label }}</template>
<span>{{ g.lines.length }} 项</span>
</div> </div>
<div v-for="(g, gi) in stockGroups" :key="g.label + gi" class="m-subgroup"
:class="{ collapsed: isCollapsed('stock', g.label) }">
<div class="m-subsection">
<van-checkbox v-if="editing" :model-value="allChecked(g.lines)" :indeterminate="someChecked(g.lines)" icon-size="17px"
@update:model-value="(v: boolean) => toggleAll(g.lines, v, 'stock')" />
<button type="button" class="m-sub-toggle" :aria-expanded="!isCollapsed('stock', g.label)"
@click="toggleGroup('stock', g.label)">
<span class="m-sub-title">{{ g.label }}</span>
<span class="m-sub-count">{{ g.lines.length }} 项</span>
<i class="m-sub-arrow" aria-hidden="true"></i>
</button>
</div>
<div v-show="!isCollapsed('stock', g.label)" class="m-sub-body">
<div v-for="l in g.lines" :key="l.part_no" class="m-card m-line" :class="{ off: !edits[l.part_no]?.checked }"> <div v-for="l in g.lines" :key="l.part_no" class="m-card m-line" :class="{ off: !edits[l.part_no]?.checked }">
<div class="m-line-head"> <div class="m-line-head">
<van-checkbox v-if="editing" :model-value="edits[l.part_no]?.checked" icon-size="18px" @update:model-value="(v: boolean) => toggle(l, v)"> <van-checkbox v-if="editing" :model-value="edits[l.part_no]?.checked" icon-size="18px" @update:model-value="(v: boolean) => toggle(l, v)">
...@@ -377,8 +397,7 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli ...@@ -377,8 +397,7 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli
<span v-else class="m-line-name">{{ l.name || l.part_no }}</span> <span v-else class="m-line-name">{{ l.name || l.part_no }}</span>
<b class="m-qty" :class="{ off: calc(l).off }">补 {{ calc(l).qty }}<small v-if="calc(l).off"> 未勾选</small><small v-else-if="calc(l).capped"> 按上限</small></b> <b class="m-qty" :class="{ off: calc(l).off }">补 {{ calc(l).qty }}<small v-if="calc(l).off"> 未勾选</small><small v-else-if="calc(l).capped"> 按上限</small></b>
</div> </div>
<div class="m-line-pn">{{ l.part_no }}<span v-if="l.category" class="m-tag">{{ l.category }}</span> <div class="m-line-pn">{{ l.part_no }}<span v-if="l.so_hit" class="m-tag">近 {{ st.so_months }} 月补过 {{ l.so_hit.order_count }} 次</span></div>
<span v-if="l.so_hit" class="m-tag">近 {{ st.so_months }} 月补过 {{ l.so_hit.order_count }} 次</span></div>
<div v-if="l.in_drafts?.length" class="m-draft">⚠ 未提交的采购单里已有:{{ draftText(l) }}</div> <div v-if="l.in_drafts?.length" class="m-draft">⚠ 未提交的采购单里已有:{{ draftText(l) }}</div>
<div class="m-exp-edit"> <div class="m-exp-edit">
<span class="m-exp-lbl">期望</span> <span class="m-exp-lbl">期望</span>
...@@ -395,26 +414,41 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli ...@@ -395,26 +414,41 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli
</div> </div>
<div v-if="calc(l).note || l.error" class="m-note">{{ calc(l).note }} {{ l.error }}</div> <div v-if="calc(l).note || l.error" class="m-note">{{ calc(l).note }} {{ l.error }}</div>
</div> </div>
</template> </div>
</div>
<!-- 其他出库件(折叠、默认不勾;展开后按分类二级分组) --> <!-- 其他出库件(折叠、默认不勾;展开后按分类二级分组) -->
<div v-if="otherCount" class="m-section m-fold" @click="expand"> <div v-if="otherCount" class="m-section m-section-other" :class="{ open: showOthers }">
当天出库的其他零件 <span>{{ otherCount }} 项 · 默认不勾选 · 补货数已按期望算好,勾选即加入</span> <div class="m-fold" @click="expand">
<i>{{ showOthers ? '▴' : '▾' }}</i> <div class="m-section-head">
<div class="m-section-title"><small>按需补货</small>当天出库的其他零件</div>
<div class="m-section-meta">
<span class="m-section-count">{{ otherCount }} 项</span>
<i class="m-section-arrow" :class="{ open: showOthers }" aria-hidden="true"></i>
</div> </div>
<template v-if="showOthers"> </div>
<div v-if="editing && otherAllLines.length" class="m-allbar"> <div class="m-section-desc">默认不勾选 · 点击展开,按分类挑选需要补货的零件</div>
</div>
<div v-if="showOthers && editing && otherAllLines.length" class="m-allbar">
<van-checkbox :model-value="allChecked(otherAllLines)" :indeterminate="someChecked(otherAllLines)" icon-size="18px" <van-checkbox :model-value="allChecked(otherAllLines)" :indeterminate="someChecked(otherAllLines)" icon-size="18px"
@update:model-value="(v: boolean) => toggleAll(otherAllLines, v, 'other')"> @update:model-value="(v: boolean) => toggleAll(otherAllLines, v, 'other')">
全选 <span>已选 {{ checkedCount(otherAllLines) }} / {{ otherAllLines.length }}</span></van-checkbox> 全选本组 <span>已选 {{ checkedCount(otherAllLines) }} / {{ otherAllLines.length }}</span></van-checkbox>
</div> </div>
<template v-for="(g, gi) in otherGroups" :key="g.label + gi">
<div class="m-subsection">
<van-checkbox v-if="editing" :model-value="allChecked(g.lines)" :indeterminate="someChecked(g.lines)" icon-size="16px"
@update:model-value="(v: boolean) => toggleAll(g.lines, v, 'other')">{{ g.label }}</van-checkbox>
<template v-else>{{ g.label }}</template>
<span>{{ g.lines.length }} 项</span>
</div> </div>
<template v-if="showOthers">
<div v-for="(g, gi) in otherGroups" :key="g.label + gi" class="m-subgroup"
:class="{ collapsed: isCollapsed('other', g.label) }">
<div class="m-subsection">
<van-checkbox v-if="editing" :model-value="allChecked(g.lines)" :indeterminate="someChecked(g.lines)" icon-size="17px"
@update:model-value="(v: boolean) => toggleAll(g.lines, v, 'other')" />
<button type="button" class="m-sub-toggle" :aria-expanded="!isCollapsed('other', g.label)"
@click="toggleGroup('other', g.label)">
<span class="m-sub-title">{{ g.label }}</span>
<span class="m-sub-count">{{ g.lines.length }} 项</span>
<i class="m-sub-arrow" aria-hidden="true"></i>
</button>
</div>
<div v-show="!isCollapsed('other', g.label)" class="m-sub-body">
<div v-for="l in g.lines" :key="l.part_no" class="m-card m-line" :class="{ off: !edits[l.part_no]?.checked }"> <div v-for="l in g.lines" :key="l.part_no" class="m-card m-line" :class="{ off: !edits[l.part_no]?.checked }">
<div class="m-line-head"> <div class="m-line-head">
<van-checkbox v-if="editing" :model-value="edits[l.part_no]?.checked" icon-size="18px" @update:model-value="(v: boolean) => toggle(l, v)"> <van-checkbox v-if="editing" :model-value="edits[l.part_no]?.checked" icon-size="18px" @update:model-value="(v: boolean) => toggle(l, v)">
...@@ -422,7 +456,7 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli ...@@ -422,7 +456,7 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli
<span v-else class="m-line-name">{{ l.name || l.part_no }}</span> <span v-else class="m-line-name">{{ l.name || l.part_no }}</span>
<b class="m-qty" :class="{ off: calc(l).off }">补 {{ calc(l).qty }}<small v-if="calc(l).off"> 未勾选</small><small v-else-if="calc(l).capped"> 按上限</small></b> <b class="m-qty" :class="{ off: calc(l).off }">补 {{ calc(l).qty }}<small v-if="calc(l).off"> 未勾选</small><small v-else-if="calc(l).capped"> 按上限</small></b>
</div> </div>
<div class="m-line-pn">{{ l.part_no }}<span v-if="l.category" class="m-tag">{{ l.category }}</span></div> <div class="m-line-pn">{{ l.part_no }}</div>
<div v-if="l.in_drafts?.length" class="m-draft">⚠ 未提交的采购单里已有:{{ draftText(l) }}</div> <div v-if="l.in_drafts?.length" class="m-draft">⚠ 未提交的采购单里已有:{{ draftText(l) }}</div>
<div class="m-exp-edit"> <div class="m-exp-edit">
<span class="m-exp-lbl">期望</span> <span class="m-exp-lbl">期望</span>
...@@ -439,7 +473,8 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli ...@@ -439,7 +473,8 @@ const fetchedAt = computed(() => String(st.value?.run.data_fetched_at || '').sli
<div v-if="calc(l).note || l.error" class="m-note">{{ calc(l).note }} {{ l.error }}</div> <div v-if="calc(l).note || l.error" class="m-note">{{ calc(l).note }} {{ l.error }}</div>
<div v-else-if="!l.national_queried && calc(l).qty > 0" class="m-note">没查全国仓(刷新后会查)</div> <div v-else-if="!l.national_queried && calc(l).qty > 0" class="m-note">没查全国仓(刷新后会查)</div>
</div> </div>
</template> </div>
</div>
</template> </template>
</template> </template>
......
...@@ -14,12 +14,41 @@ ...@@ -14,12 +14,41 @@
.m-sum > div { background: rgba(255, 255, 255, 0.14); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; } .m-sum > div { background: rgba(255, 255, 255, 0.14); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.m-sum b { font-size: 17px; font-variant-numeric: tabular-nums; } .m-sum b { font-size: 17px; font-variant-numeric: tabular-nums; }
.m-sum span { font-size: 11.5px; opacity: 0.8; } .m-sum span { font-size: 11.5px; opacity: 0.8; }
.m-section { padding: 18px 16px 8px; font-weight: 600; font-size: 14px; color: var(--c-text); } /* 大组:标题、说明和整组全选收进同一张卡,减少零散的标题条 */
.m-section span { font-weight: 400; font-size: 12px; color: var(--c-text-3); margin-left: 6px; } .m-section { margin: 16px 12px 10px; padding: 13px 14px 12px; background: var(--c-surface);
.m-subsection { display: flex; align-items: center; gap: 6px; padding: 10px 16px 4px; font-weight: 600; font-size: 13px; color: var(--c-text-2); } border: 1px solid var(--c-border); border-radius: 14px; box-shadow: var(--shadow); }
.m-subsection span { font-weight: 400; font-size: 11.5px; color: var(--c-text-3); margin-left: 4px; } .m-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.m-allbar { margin: 0 12px 10px; padding: 0 14px; font-size: 13.5px; } .m-section-title { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--c-text);
.m-allbar span { margin-left: 6px; font-size: 12px; color: var(--c-text-3); } font-size: 15.5px; font-weight: 700; line-height: 1.4; }
.m-section-title small { flex-shrink: 0; padding: 2px 6px; border-radius: 5px; background: var(--c-primary-soft);
color: var(--c-primary); font-size: 10.5px; font-weight: 600; }
.m-section-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.m-section-count { padding: 2px 8px; border-radius: 10px; background: var(--c-bg); color: var(--c-text-2);
font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-section-desc { margin-top: 5px; color: var(--c-text-3); font-size: 12px; line-height: 1.55; }
.m-section-arrow, .m-sub-arrow { display: block; width: 7px; height: 7px; border-right: 1.5px solid var(--c-text-3);
border-bottom: 1.5px solid var(--c-text-3); transform: rotate(45deg); transition: transform 0.18s ease; }
.m-section-arrow { margin: -4px 3px 0 0; }
.m-section-arrow.open { margin-top: 4px; transform: rotate(225deg); }
.m-allbar { margin: 10px -14px -12px; padding: 9px 14px; border-top: 1px solid var(--c-border);
border-radius: 0 0 13px 13px; background: var(--c-bg); font-size: 13px; }
.m-allbar .van-checkbox { width: 100%; }
.m-allbar span { margin-left: 6px; color: var(--c-text-3); font-size: 12px; }
/* 二级分类:一整张可折叠卡片;内部零件只用细分隔线,不再叠加卡片边框和竖线 */
.m-subgroup { margin: 0 12px 10px; overflow: hidden; background: var(--c-surface);
border: 1px solid var(--c-border); border-radius: 12px; box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04); }
.m-subsection { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 10px 12px; }
.m-sub-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0;
border: 0; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.m-sub-title { min-width: 0; color: var(--c-text); font-size: 14px; font-weight: 650; }
.m-sub-count { margin-left: auto; padding: 2px 7px; border-radius: 9px; background: var(--c-primary-soft);
color: var(--c-primary); font-size: 11px; white-space: nowrap; }
.m-sub-arrow { flex-shrink: 0; margin: 3px 2px 0 3px; transform: rotate(225deg); }
.m-subgroup.collapsed .m-sub-arrow { margin-top: -3px; transform: rotate(-45deg); }
.m-sub-body { border-top: 1px solid var(--c-border); }
.m-subgroup .m-card { margin: 0; padding: 12px; border: 0; border-radius: 0; box-shadow: none; }
.m-sub-body .m-line + .m-line { border-top: 1px solid var(--c-border); }
.m-subgroup.collapsed .m-subsection { min-height: 44px; }
.m-card { margin: 0 12px 10px; background: var(--c-surface); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); border: 1px solid var(--c-border); } .m-card { margin: 0 12px 10px; background: var(--c-surface); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); border: 1px solid var(--c-border); }
.m-po { margin-top: 12px; } .m-po { margin-top: 12px; }
.m-po.ok { border-color: #bfe3cd; background: #f3fbf6; } .m-po.ok { border-color: #bfe3cd; background: #f3fbf6; }
...@@ -74,7 +103,7 @@ ...@@ -74,7 +103,7 @@
.m-qty small { font-size: 11px; font-weight: 400; color: var(--c-warn); } .m-qty small { font-size: 11px; font-weight: 400; color: var(--c-warn); }
.m-line.off { opacity: 0.6; } .m-line.off { opacity: 0.6; }
.m-qty.off, .m-qty.off small { color: var(--c-text-3); } /* 没勾选:只显示勾选后会补多少,不计入合计 */ .m-qty.off, .m-qty.off small { color: var(--c-text-3); } /* 没勾选:只显示勾选后会补多少,不计入合计 */
.m-fold { cursor: pointer; display: flex; align-items: baseline; flex-wrap: wrap; } .m-fold { cursor: pointer; }
.m-fold i { margin-left: auto; font-style: normal; color: var(--c-text-3); } .m-fold .m-section-title { flex-wrap: wrap; }
.m-count { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.22); .m-count { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.22);
font-variant-numeric: tabular-nums; font-size: 12.5px; } font-variant-numeric: tabular-nums; font-size: 12.5px; }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!