Vanessa 2023-07-07 23:31:22 +08:00
parent 63a69a9eb8
commit 479d14e6a2
2 changed files with 33 additions and 15 deletions

View file

@ -564,9 +564,22 @@ export const setFilter = (options: {
const oldFilters = JSON.parse(JSON.stringify(options.data.filters)); const oldFilters = JSON.parse(JSON.stringify(options.data.filters));
options.data.filters.find((filter) => { options.data.filters.find((filter) => {
if (filter.column === options.filter.column) { if (filter.column === options.filter.column) {
filter.value[colType] = { let cellValue: IAVCellValue;
if (colType === "number") {
if (textElement.value) {
cellValue = {
content: parseFloat(textElement.value),
isNotEmpty: true
}
} else {
cellValue = {}
}
} else {
cellValue = {
content: textElement.value content: textElement.value
}; }
}
filter.value[colType] = cellValue;
filter.operator = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement).value as TAVFilterOperator; filter.operator = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement).value as TAVFilterOperator;
return true; return true;
} }
@ -663,13 +676,15 @@ const addFilter = (options: {
icon: getColIconByType(column.type), icon: getColIconByType(column.type),
click: () => { click: () => {
const oldFilters = Object.assign([], options.data.filters); const oldFilters = Object.assign([], options.data.filters);
let cellValue = {}
if (column.type !== "number") {
cellValue = {content: ""}
}
options.data.filters.push({ options.data.filters.push({
column: column.id, column: column.id,
operator: "Contains", operator: "Contains",
value: { value: {
[column.type]: { [column.type]: cellValue
content: ""
}
}, },
}); });
transaction(options.protyle, [{ transaction(options.protyle, [{

View file

@ -851,7 +851,9 @@ interface IAV {
interface IAVFilter { interface IAVFilter {
column: string, column: string,
operator: TAVFilterOperator, operator: TAVFilterOperator,
value: IAVCellValue value: {
[key in TAVCol]?: IAVCellValue
},
} }
interface IAVSort { interface IAVSort {
@ -878,15 +880,16 @@ interface IAVCell {
id: string, id: string,
color: string, color: string,
bgColor: string, bgColor: string,
value: IAVCellValue, value: {
[key in TAVCol]?: IAVCellValue
},
valueType: TAVCol, valueType: TAVCol,
} }
type IAVCellValue = { interface IAVCellValue {
[key in TAVCol]?: { content?: any
content: string
content2?: string content2?: string
color?: string color?: string
id?: string id?: string
} isNotEmpty?: boolean
} }