diff --git a/static/modules/drawer.js b/static/modules/drawer.js index d0a5469..8defd61 100644 --- a/static/modules/drawer.js +++ b/static/modules/drawer.js @@ -58,7 +58,7 @@ function openDrawer(resource, id) { ${resource === "operations" ? drawerField("map-pin", "当前阶段", "current_stage", "", false, ``) : ""} ${fields.map(([key,label]) => { if (resource === "products" && key === "priority") { - return `
优先级
状态
`; + return `
优先级 / 状态
`; } if (resource === "products" && (key === "start_date" || key === "plan_date" || key === "dev_done_date" || key === "test_date" || key === "launch_date")) { return drawerField("calendar", label, key, item[key], false, ``); diff --git a/static/modules/products.js b/static/modules/products.js index fa0852f..6e2cc82 100644 --- a/static/modules/products.js +++ b/static/modules/products.js @@ -151,9 +151,42 @@ window.addFeature = () => {}; window.removeFeature = () => {}; window.saveFeatureList = () => {}; +// 排序状态 +let productSort = { field: null, dir: 1 }; + +window.sortProducts = (field) => { + if (productSort.field === field) { + productSort.dir = -productSort.dir; + } else { + productSort.field = field; + productSort.dir = 1; + } + renderProducts(); +}; + +function sortItems(items) { + if (!productSort.field) return items; + const f = productSort.field; + const d = productSort.dir; + const priorityOrder = { P0: 0, P1: 1, P2: 2, P3: 3 }; + return [...items].sort((a, b) => { + let va = a[f] || '', vb = b[f] || ''; + if (f === 'priority') { va = priorityOrder[va] ?? 9; vb = priorityOrder[vb] ?? 9; } + if (va < vb) return -1 * d; + if (va > vb) return 1 * d; + return 0; + }); +} + function renderProducts() { - const items = state.data.products || []; + const rawItems = state.data.products || []; + const items = sortItems(rawItems); const priorityColor = { P0: "bg-red-100 text-red-700", P1: "bg-orange-100 text-orange-700", P2: "bg-blue-100 text-blue-700", P3: "bg-slate-100 text-slate-600" }; + const sortIcon = (f) => { + if (productSort.field !== f) return ''; + return productSort.dir > 0 ? '' : ''; + }; + const sortTh = (f, label, extra='') => `${label}${sortIcon(f)}${extra}`; document.querySelector("#products").innerHTML = `
@@ -163,15 +196,15 @@ function renderProducts() { - - - - - - - - - + ${sortTh('version','版本号')} + ${sortTh('priority','优先级')} + ${sortTh('product_name','版本名称')} + ${sortTh('status','状态')} + ${sortTh('start_date','启动时间')} + ${sortTh('plan_date','产品方案')} + ${sortTh('dev_done_date','研发完成')} + ${sortTh('test_date','测试完成')} + ${sortTh('launch_date','上线时间')}
版本号优先级版本名称状态启动时间产品方案研发完成测试完成上线时间总耗时