已完成迁移验收和清理。
删除全部 Node.js 后端、.mjs 测试、辅助脚本、package*.json、node_modules 和迁移对照工具。 浏览器前端保留并迁入 [Eis.Web/wwwroot](C:/Users/BI/Documents/EIS-dotnet/src/Eis.Web/wwwroot/index.html),统一改为 .js 模块。 修复一个隐藏遗漏:.NET 仍依赖 schema.mjs,且 MySQL 结构解析可能被转义反引号截断。现已改为原生 [SQLite SQL](C:/Users/BI/Documents/EIS-dotnet/src/Eis.Infrastructure/Data/Schema.sqlite.sql) 和 [MySQL SQL](C:/Users/BI/Documents/EIS-dotnet/src/Eis.Infrastructure/Data/Schema.mysql.sql) 资源。 更新了 [DatabaseInitializer.cs](C:/Users/BI/Documents/EIS-dotnet/src/Eis.Infrastructure/Data/DatabaseInitializer.cs)、项目配置、README 和迁移文档。 data 目录和现有数据库未修改;测试仅使用系统临时 SQLite 数据库。
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
function controlState(state, key) {
|
||||
state.tableFilters ||= {};
|
||||
return state.tableFilters[key] ||= { query: '', status: 'all', filters: {} };
|
||||
}
|
||||
|
||||
function searchable(value) {
|
||||
if (value == null) return '';
|
||||
if (Array.isArray(value)) return value.map(searchable).join(' ');
|
||||
if (typeof value === 'object') return Object.values(value).map(searchable).join(' ');
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function statusTokens(item) {
|
||||
const tokens = [item?.status, item?.paymentStatus];
|
||||
if (typeof item?.active === 'boolean') tokens.push(item.active ? 'active approved' : 'inactive disabled closed');
|
||||
if (typeof item?.published === 'boolean') tokens.push(item.published ? 'published visible' : 'draft hidden');
|
||||
if (typeof item?.qualified === 'boolean') tokens.push(item.qualified ? 'qualified' : 'unqualified');
|
||||
if (typeof item?.confirmed === 'boolean') tokens.push(item.confirmed ? (item.eligible ? 'confirmed eligible' : 'confirmed ineligible') : 'unconfirmed');
|
||||
return tokens.filter(Boolean).join(' ').toLowerCase();
|
||||
}
|
||||
|
||||
export function filterTableItems(state, items, key) {
|
||||
const control = controlState(state, key);
|
||||
const query = String(control.query || '').trim().toLocaleLowerCase('zh-CN');
|
||||
const status = String(control.status || 'all').toLowerCase();
|
||||
const filters = Object.values(control.filters || {}).filter(Boolean).map(value => String(value).toLocaleLowerCase('zh-CN'));
|
||||
return (items || []).filter(item => {
|
||||
const haystack = searchable(item).toLocaleLowerCase('zh-CN');
|
||||
if (query && !query.split(/\s+/).every(word => haystack.includes(word))) return false;
|
||||
if (status !== 'all' && !statusTokens(item).split(/\s+/).includes(status)) return false;
|
||||
return filters.every(value => haystack.includes(value));
|
||||
});
|
||||
}
|
||||
|
||||
export function setTableControl(state, key, patch) {
|
||||
const current = controlState(state, key);
|
||||
Object.assign(current, patch);
|
||||
if (patch.filters) current.filters = { ...(current.filters || {}), ...patch.filters };
|
||||
if (state.tablePages?.[key]) state.tablePages[key].page = 1;
|
||||
}
|
||||
|
||||
export function getTableControl(state, key) {
|
||||
return controlState(state, key);
|
||||
}
|
||||
Reference in New Issue
Block a user