diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index 8cad4d4f7..07a93fc01 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -564,9 +564,22 @@ export const setFilter = (options: { const oldFilters = JSON.parse(JSON.stringify(options.data.filters)); options.data.filters.find((filter) => { if (filter.column === options.filter.column) { - filter.value[colType] = { - content: textElement.value - }; + let cellValue: IAVCellValue; + if (colType === "number") { + if (textElement.value) { + cellValue = { + content: parseFloat(textElement.value), + isNotEmpty: true + } + } else { + cellValue = {} + } + } else { + cellValue = { + content: textElement.value + } + } + filter.value[colType] = cellValue; filter.operator = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement).value as TAVFilterOperator; return true; } @@ -663,13 +676,15 @@ const addFilter = (options: { icon: getColIconByType(column.type), click: () => { const oldFilters = Object.assign([], options.data.filters); + let cellValue = {} + if (column.type !== "number") { + cellValue = {content: ""} + } options.data.filters.push({ column: column.id, operator: "Contains", value: { - [column.type]: { - content: "" - } + [column.type]: cellValue }, }); transaction(options.protyle, [{ diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 287879484..4951f5ea5 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -851,7 +851,9 @@ interface IAV { interface IAVFilter { column: string, operator: TAVFilterOperator, - value: IAVCellValue + value: { + [key in TAVCol]?: IAVCellValue + }, } interface IAVSort { @@ -878,15 +880,16 @@ interface IAVCell { id: string, color: string, bgColor: string, - value: IAVCellValue, + value: { + [key in TAVCol]?: IAVCellValue + }, valueType: TAVCol, } -type IAVCellValue = { - [key in TAVCol]?: { - content: string - content2?: string - color?: string - id?: string - } +interface IAVCellValue { + content?: any + content2?: string + color?: string + id?: string + isNotEmpty?: boolean }