Explorar el Código

修复套餐月成本项布局和操作列边框

sy hace 17 horas
padre
commit
9d69be0929

+ 22 - 16
web-scaffold/src/components/PackagePlanEditor.tsx

@@ -332,22 +332,28 @@ export function PackagePlanEditor({ state, tiers, onClose, onSaved }: {
         {costs.length > 0 && <div className="catalog-cost-editor-head" aria-hidden="true"><span>成本项</span><span>金额(元)</span><span>计价口径</span><span>类别</span><span /></div>}
         {costItemCatalog.error && <FetchError message={costItemCatalog.error.message} onRetry={costItemCatalog.reload} className="catalog-editor-error" />}
         {costs.map((cost, index) => <div className="catalog-cost-editor-row" key={index}>
-          <select aria-label={`成本项 ${index + 1}`} value={cost.cost_item_id} onChange={(event) => pickGlobalCostItem(index, event.target.value)} disabled={costItemCatalog.loading && globalCostItems.length === 0} title="从全局成本项清单按 id 选择(D-1:⛔ 自由录名)">
-            <option value="">{costItemCatalog.loading ? "载入中…" : costItemCatalog.error ? WORD_FETCH_FAILED : "选择成本项"}</option>
-            {globalCostItems.map((it) => <option key={it.id} value={it.id}>{it.name}</option>)}
-            {cost.cost_item_id && !globalCostItems.some((it) => it.id === cost.cost_item_id) && (
-              <option value={cost.cost_item_id}>{cost.item_name || cost.cost_item_id}(全局已删除)</option>
-            )}
-          </select>
-          <span className="catalog-price-input"><input aria-label={`成本项 ${index + 1} 金额`} inputMode="decimal" maxLength={14} value={cost.amount} onChange={(event) => { setCostsDirty(true); setCosts((current) => current.map((item, i) => i === index ? { ...item, amount: event.target.value } : item)); }} placeholder="金额" /></span>
-          <select disabled aria-label={`成本项 ${index + 1} 计价口径`} value={cost.billing_unit} title="随选中的全局成本项带入,只读跟随">
-            <option value="">未配置</option>
-            {BILLING_OPTIONS.map(([value, text]) => <option key={value} value={value}>{text}</option>)}
-          </select>
-          <select disabled aria-label={`成本项 ${index + 1} 类别`} value={cost.category} title="随选中的全局成本项带入,只读跟随">
-            <option value="">未配置</option>
-            {CATEGORY_OPTIONS.map(([value, text]) => <option key={value} value={value}>{text}</option>)}
-          </select>
+          <div className="catalog-cost-field">
+            <span className="catalog-cost-field-label" aria-hidden="true">成本项</span>
+            <select aria-label={`成本项 ${index + 1}`} value={cost.cost_item_id} onChange={(event) => pickGlobalCostItem(index, event.target.value)} disabled={costItemCatalog.loading && globalCostItems.length === 0} title="从全局成本项清单选择">
+              <option value="">{costItemCatalog.loading ? "载入中…" : costItemCatalog.error ? WORD_FETCH_FAILED : "选择成本项"}</option>
+              {globalCostItems.map((it) => <option key={it.id} value={it.id}>{it.name}</option>)}
+              {cost.cost_item_id && !globalCostItems.some((it) => it.id === cost.cost_item_id) && (
+                <option value={cost.cost_item_id}>{cost.item_name || cost.cost_item_id}(全局已删除)</option>
+              )}
+            </select>
+          </div>
+          <div className="catalog-cost-field">
+            <span className="catalog-cost-field-label" aria-hidden="true">金额(元)</span>
+            <input aria-label={`成本项 ${index + 1} 金额`} inputMode="decimal" maxLength={14} value={cost.amount} onChange={(event) => { setCostsDirty(true); setCosts((current) => current.map((item, i) => i === index ? { ...item, amount: event.target.value } : item)); }} placeholder="金额" />
+          </div>
+          <div className="catalog-cost-field">
+            <span className="catalog-cost-field-label" aria-hidden="true">计价口径</span>
+            <input readOnly aria-label={`成本项 ${index + 1} 计价口径`} value={BILLING_OPTIONS.find(([value]) => value === cost.billing_unit)?.[1] ?? "未配置"} title="随选中的全局成本项带入" />
+          </div>
+          <div className="catalog-cost-field">
+            <span className="catalog-cost-field-label" aria-hidden="true">类别</span>
+            <input readOnly aria-label={`成本项 ${index + 1} 类别`} value={CATEGORY_OPTIONS.find(([value]) => value === cost.category)?.[1] ?? "未配置"} title="随选中的全局成本项带入" />
+          </div>
           <button aria-label={`移除成本项 ${index + 1}`} onClick={() => { setCostsDirty(true); setCosts((current) => current.filter((_, i) => i !== index)); }} type="button"><X size={16} /></button>
         </div>)}
         <button

+ 24 - 8
web-scaffold/src/styles/packages.css

@@ -101,7 +101,6 @@
   position: sticky;
   inset-inline-end: 0;
   padding-inline: 8px;
-  border-inline-start: 1px solid var(--border-subtle);
   text-align: center;
 }
 .catalog-ledger th:last-child { z-index: 3; }
@@ -133,6 +132,7 @@
 .catalog-group-label strong { color: var(--primary-soft-foreground); font-size: var(--type-support); }
 .catalog-group-label > span { color: var(--text-secondary); font-size: var(--type-meta); }
 .catalog-actions-cell .catalog-row-actions { display: flex; flex-wrap: wrap; justify-content: center; }
+.catalog-actions-cell .catalog-row-actions button { padding-inline: 5px; }
 .catalog-ledger td .catalog-plan-owner { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
 .catalog-readonly-note { color: var(--muted-foreground); font-size: var(--type-support); }
 .catalog-empty { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 12px; }
@@ -175,7 +175,7 @@
   .catalog-ledger .catalog-plan-row:hover .catalog-actions-cell { background: transparent; }
   .catalog-ledger .catalog-sequence::before { content: "序号"; margin-inline-end: 6px; font-size: var(--type-meta); }
   .catalog-actions-cell .catalog-row-actions { justify-content: end; }
-  .catalog-actions-cell .catalog-row-actions button { min-height: 36px; padding-inline: 5px; }
+  .catalog-actions-cell .catalog-row-actions button { min-height: 36px; }
   .catalog-ledger .ops-table-empty-cell { display: block; }
 }
 @container package-catalog (max-width: 780px) {
@@ -211,13 +211,31 @@
 .catalog-heading-with-info{position:relative;display:flex;align-items:center;gap:5px}
 .catalog-heading-with-info>:is(label,h3){margin:0}
 .catalog-cost-editor>.catalog-heading-with-info{margin-bottom:12px}
-@media (width > 760px){
-  .catalog-cost-editor>.catalog-heading-with-info:has(+.catalog-cost-editor-row){margin-bottom:calc(12px + var(--catalog-field-label-height) + var(--catalog-field-gap))}
+.catalog-editor-body > .catalog-cost-editor {
+  grid-column: 1 / -1;
+  container: catalog-costs / inline-size;
 }
 .catalog-editor-body section>p{margin:-3px 0 15px;color:var(--muted-foreground);font-size:13px;line-height:1.6}
-.catalog-cost-editor-head,.catalog-cost-editor-row{display:grid;grid-template-columns:minmax(0,1.4fr) 88px minmax(0,1fr) minmax(0,1fr) 34px;align-items:center;gap:8px;margin-bottom:8px}
+.catalog-cost-editor-head,.catalog-cost-editor-row{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr) repeat(2,minmax(0,1.15fr)) 40px;align-items:center;gap:8px;margin-bottom:8px}
 .catalog-cost-editor-head{margin-bottom:6px;color:var(--field-label);font-size:var(--type-support);font-weight:500}
-.catalog-bandwidth-field>select,.catalog-cost-editor-row>:is(input,select){min-width:0;height:40px}
+.catalog-bandwidth-field>select,.catalog-cost-field>:is(input,select){min-width:0;height:40px}
+.catalog-cost-field{min-width:0}
+.catalog-cost-field-label{display:none}
+.catalog-cost-field>:is(input,select){margin-top:0}
+.catalog-cost-field>select{padding-inline-end:30px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.catalog-cost-field>input:read-only{background:var(--surface-subtle);color:var(--muted-foreground);text-overflow:ellipsis}
+@container catalog-costs (max-width: 540px) {
+  .catalog-cost-editor-head{display:none}
+  .catalog-cost-editor-row{
+    grid-template-columns:repeat(2,minmax(0,1fr)) 36px;
+    align-items:end;
+    padding:10px;
+    border:1px solid var(--border-subtle);
+    border-radius:7px;
+  }
+  .catalog-cost-field-label{display:block;margin-bottom:4px;color:var(--field-label);font-size:var(--type-meta)}
+  .catalog-cost-editor-row>button{grid-column:3;grid-row:1}
+}
 .catalog-cost-add:disabled,.catalog-cost-add[aria-disabled="true"]{opacity:.55;cursor:not-allowed}
 .catalog-cost-limit-note{margin:8px 0 0;color:var(--muted-foreground);font-size:var(--type-support);line-height:1.5}
 /* 带宽档位快捷(2026-11-17):档位目录同时是套餐带宽权益的预设,点一条即填上/下行。 */
@@ -229,8 +247,6 @@
 .catalog-bandwidth-preset:hover{border-color:var(--primary);color:var(--primary)}
 .catalog-bandwidth-preset.is-on{border-color:var(--primary);background:var(--primary-soft);color:var(--primary);font-weight:650}
 .catalog-bandwidth-preset:focus-visible{outline:2px solid var(--info);outline-offset:1px}
-.catalog-cost-editor-row>:is(input,select){margin-top:0}
-.catalog-cost-unit{color:var(--text-secondary);font-size:var(--type-support);text-align:center}
 .catalog-cost-editor-row button,.catalog-cost-add{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-height:40px;border:1px solid var(--border);border-radius:6px;background:var(--card);color:var(--text-secondary);cursor:pointer}
 .catalog-cost-editor-row button:hover,.catalog-cost-add:hover{border-color:var(--primary);color:var(--primary)}
 .catalog-cost-add{padding:0 12px;font-size:var(--type-support)}