浏览代码

:art: 数据库相对日期

Vanessa 1 年之前
父节点
当前提交
6c35f9f07b
共有 1 个文件被更改,包括 12 次插入12 次删除
  1. 12 12
      app/src/protyle/render/av/filter.ts

+ 12 - 12
app/src/protyle/render/av/filter.ts

@@ -87,13 +87,13 @@ export const setFilter = async (options: {
                         unit: parseInt((directElements[0].parentElement.lastElementChild as HTMLSelectElement).value),
                         unit: parseInt((directElements[0].parentElement.lastElementChild as HTMLSelectElement).value),
                         direction: parseInt(directElements[0].value)
                         direction: parseInt(directElements[0].value)
                     };
                     };
-                }
-                if (typeElements[1].value === "custom") {
-                    newFilter.relativeDate2 = {
-                        count: parseInt((directElements[1].parentElement.querySelector(".b3-text-field") as HTMLInputElement).value || "1"),
-                        unit: parseInt((directElements[1].parentElement.lastElementChild as HTMLSelectElement).value),
-                        direction: parseInt(directElements[1].value)
-                    };
+                    if (typeElements[1].value === "custom") {
+                        newFilter.relativeDate2 = {
+                            count: parseInt((directElements[1].parentElement.querySelector(".b3-text-field") as HTMLInputElement).value || "1"),
+                            unit: parseInt((directElements[1].parentElement.lastElementChild as HTMLSelectElement).value),
+                            direction: parseInt(directElements[1].value)
+                        };
+                    }
                 } else {
                 } else {
                     newFilter.value = genCellValue(filterType, {
                     newFilter.value = genCellValue(filterType, {
                         isNotEmpty2: textElements[1].value !== "",
                         isNotEmpty2: textElements[1].value !== "",
@@ -568,15 +568,15 @@ export const getFiltersHTML = (data: IAVTable) => {
                         dateValue = `${window.siyuan.languages[["pastDate", "current", "nextDate"][filter.relativeDate.direction + 1]]}
                         dateValue = `${window.siyuan.languages[["pastDate", "current", "nextDate"][filter.relativeDate.direction + 1]]}
  ${filter.relativeDate.direction ? filter.relativeDate.count : ""}
  ${filter.relativeDate.direction ? filter.relativeDate.count : ""}
  ${window.siyuan.languages[["day", "week", "month", "year"][filter.relativeDate.unit]]}`;
  ${window.siyuan.languages[["day", "week", "month", "year"][filter.relativeDate.unit]]}`;
+                        if (filter.relativeDate2) {
+                            dateValue2 = `${window.siyuan.languages[["pastDate", "current", "nextDate"][filter.relativeDate2.direction + 1]]}
+ ${filter.relativeDate2.direction ? filter.relativeDate2.count : ""}
+ ${window.siyuan.languages[["day", "week", "month", "year"][filter.relativeDate2.unit]]}`;
+                        }
                     } else if (filter.value?.date?.content) {
                     } else if (filter.value?.date?.content) {
                         dateValue = dayjs(filter.value.date.content).format("YYYY-MM-DD");
                         dateValue = dayjs(filter.value.date.content).format("YYYY-MM-DD");
                         dateValue2 = dayjs(filter.value.date.content2).format("YYYY-MM-DD");
                         dateValue2 = dayjs(filter.value.date.content2).format("YYYY-MM-DD");
                     }
                     }
-                    if (filter.relativeDate2) {
-                        dateValue2 = `${window.siyuan.languages[["pastDate", "current", "nextDate"][filter.relativeDate2.direction + 1]]}
- ${filter.relativeDate2.direction ? filter.relativeDate2.count : ""}
- ${window.siyuan.languages[["day", "week", "month", "year"][filter.relativeDate2.unit]]}`;
-                    }
 
 
                     if (filter.operator === "Is between") {
                     if (filter.operator === "Is between") {
                         filterValue = ` ${window.siyuan.languages.filterOperatorIsBetween} ${dateValue} ${dateValue2}`;
                         filterValue = ` ${window.siyuan.languages.filterOperatorIsBetween} ${dateValue} ${dateValue2}`;