add dateFilter.ts
This commit is contained in:
@@ -180,6 +180,7 @@ import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { Tag } from "@/types/Tag";
|
||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
import { useSettingStore } from "@/store/settingStore";
|
||||
@@ -188,8 +189,6 @@ defineOptions({
|
||||
name: "CustomerList"
|
||||
});
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
@@ -209,15 +208,6 @@ const canShowActionMenu = computed(() => canCreateCustomer.value || canExportCus
|
||||
const scannerVisible = ref(false);
|
||||
const scanStatus = ref("点击扫码开始识别");
|
||||
let latestDecodedText = "";
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
const dateFilterType = ref<DateFilterType>("all");
|
||||
const dateRange = ref<[string, string]>(buildPresetDateRange("all"));
|
||||
const startDraft = ref("");
|
||||
|
||||
@@ -170,12 +170,12 @@ import type { EventOptionStat, EventRecordPage, EventRecordPageResult, Verificat
|
||||
import { isRetiredEvent } from "@/utils/event";
|
||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { Message } from "@/utils/message.ts";
|
||||
|
||||
import type { EventItem, EventStatus } from "@/types/EventItem";
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type VerificationFilter = "ALL" | VerificationStatus;
|
||||
|
||||
defineOptions({
|
||||
@@ -186,16 +186,6 @@ const pageSize = 20;
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
|
||||
// ---------- 筛选 ----------
|
||||
|
||||
const keyword = ref(getInitialKeyword());
|
||||
|
||||
@@ -142,13 +142,12 @@ import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
import type { CustomerEventRankView, EventRecordRankPage, EventRecordRankType } from "@/types/EventRecord";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { Message } from "@/utils/message.ts";
|
||||
|
||||
type DateFilterType = "all" | "today" | "yesterday" | "thisWeek" | "thisMonth" | "custom";
|
||||
|
||||
defineOptions({
|
||||
name: "EventRecordRank"
|
||||
});
|
||||
@@ -162,15 +161,6 @@ const rankTypeOptions: Array<{ label: string; value: EventRecordRankType }> = [
|
||||
{ label: "按连续天数", value: "CONTINUOUS_DAYS" },
|
||||
{ label: "按登记数值", value: "TOTAL_NUMBER_VALUE" }
|
||||
];
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "全部时间", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
|
||||
// ---------- 筛选 ----------
|
||||
|
||||
const rankType = ref<EventRecordRankType>(parseRankType(route.query.rankType));
|
||||
|
||||
@@ -182,6 +182,7 @@ import SkuFilterPopup from "@/pages/fulfillment/components/SkuFilterPopup.vue";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { SalesOrder } from "@/types/SalesOrder";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
@@ -220,17 +221,7 @@ const actions = computed<NavbarAction[]>(() => [
|
||||
action: toPackageOrderList
|
||||
}
|
||||
]);
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type SkuFilterOption = { skuId: string; productName: string; skuName: string };
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
|
||||
const customerId = ref(getQueryText(route.query.customerId));
|
||||
const selectedSkuIdList = ref(getSkuIdList(route.query.skuIds));
|
||||
|
||||
@@ -162,12 +162,11 @@ import type { Customer } from "@/types/Customer";
|
||||
import type { PointLedger, PointLedgerChangeType, PointLedgerPage } from "@/types/Point";
|
||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateFilterOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { Message } from "@/utils/message";
|
||||
import { formatWanInteger } from "@/utils/money";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
type DateFilter = "all" | "today" | "last7" | "last30" | "custom";
|
||||
|
||||
defineOptions({
|
||||
name: "PointLedgerList"
|
||||
});
|
||||
@@ -186,8 +185,8 @@ const customer = ref<Customer>();
|
||||
const customerKeyword = ref("");
|
||||
const selectorVisible = ref(false);
|
||||
const changeTypeFilter = ref("ALL");
|
||||
const dateFilter = ref<DateFilter>("last30");
|
||||
const dateRange = ref<[string, string]>(buildPresetDateRange("last30"));
|
||||
const dateFilter = ref<DateFilterType>("thisMonth");
|
||||
const dateRange = ref<[string, string]>(buildPresetDateRange("thisMonth"));
|
||||
const startDraft = ref("");
|
||||
const endDraft = ref("");
|
||||
const startDateVisible = ref(false);
|
||||
@@ -199,13 +198,6 @@ const changeTypeOptions = [
|
||||
{ label: "撤销", value: "REVOKE" },
|
||||
{ label: "调整", value: "ADJUST" }
|
||||
];
|
||||
const dateFilterOptions = [
|
||||
{ label: "全部时间", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "近 7 天", value: "last7" },
|
||||
{ label: "近 30 天", value: "last30" },
|
||||
{ label: "自定义", value: "custom" }
|
||||
];
|
||||
const dateFilterLabel = computed(() => dateFilterOptions.find(item => item.value === dateFilter.value)?.label || "时间范围");
|
||||
|
||||
async function handleCustomerChange(value: string | string[]): Promise<void> {
|
||||
@@ -263,7 +255,7 @@ async function selectDateFilter(value: DropdownValue): Promise<void> {
|
||||
if (Array.isArray(value)) {
|
||||
return;
|
||||
}
|
||||
dateFilter.value = String(value) as DateFilter;
|
||||
dateFilter.value = String(value) as DateFilterType;
|
||||
if (dateFilter.value !== "custom") {
|
||||
dateRange.value = buildPresetDateRange(dateFilter.value);
|
||||
await reload();
|
||||
|
||||
@@ -175,6 +175,7 @@ import PointAPI from "@/api/PointAPI";
|
||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||
import type { PointRedemption, PointRedemptionStatus } from "@/types/Point";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { Message } from "@/utils/message";
|
||||
import { formatWanInteger } from "@/utils/money";
|
||||
import { getPackageQuantityText } from "@/utils/package";
|
||||
@@ -188,16 +189,6 @@ defineOptions({ name: "PointRedemptionList" });
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const result = reactive({ total: 0, list: [] as PointRedemption[] });
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
const keyword = ref(getQueryText(route.query.keyword));
|
||||
const customerId = ref(getQueryText(route.query.customerId));
|
||||
const selectedCustomer = ref<Customer>();
|
||||
|
||||
@@ -198,6 +198,7 @@ import ProductAPI from "@/api/ProductAPI";
|
||||
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
|
||||
import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { getProductBaseUnitName, getProductPhotoURL, getProductQuantityText, getProductTypeText, getStockOperationText } from "@/utils/product";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -209,7 +210,6 @@ import type { Product, ProductSelection, ProductSku, StockOperationType, StockRe
|
||||
|
||||
defineOptions({ name: "ProductStockRecordList" });
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type OperationFilter = "ALL" | StockOperationType;
|
||||
type DirectionFilter = "ALL" | StockRecordDirection;
|
||||
|
||||
@@ -239,15 +239,6 @@ const activeReservationRequested = getQueryText("activeReservationOnly") === "tr
|
||||
const operationType = ref<OperationFilter>(getQueryText("operationType") as OperationFilter || (activeReservationRequested ? "ORDER_RESERVE" : "ALL"));
|
||||
const direction = ref<DirectionFilter>(getQueryText("direction") as DirectionFilter || "ALL");
|
||||
const keyword = ref(getQueryText("keyword"));
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
const dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText("dateType"), dateOptions, "all"));
|
||||
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
||||
const startDraft = ref("");
|
||||
|
||||
@@ -196,6 +196,7 @@ import type {
|
||||
ConsumptionRecordStatus
|
||||
} from "@/types/ConsumptionRecord";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -206,21 +207,10 @@ import type { Customer } from "@/types/Customer";
|
||||
|
||||
defineOptions({ name: "ConsumptionRecordList" });
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
|
||||
const pageSize = 20;
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "全部时间", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
const sourceType = ref<ConsumptionRecordSourceType | "ALL">("ALL");
|
||||
const status = ref<ConsumptionRecordStatus | "ALL">("ALL");
|
||||
const customerId = ref("");
|
||||
|
||||
@@ -192,6 +192,7 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||
import type { FundOperationType, FundRecord, FundRecordStatus } from "@/types/SalesOrder";
|
||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { formatPackageAmount } from "@/utils/package";
|
||||
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
||||
@@ -203,8 +204,6 @@ import type { Customer } from "@/types/Customer";
|
||||
|
||||
defineOptions({ name: "FundRecordList" });
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
@@ -220,15 +219,6 @@ const customerId = ref(getQueryText(route.query.customerId));
|
||||
const selectedCustomer = ref<Customer>();
|
||||
const customerSelectorVisible = ref(false);
|
||||
const customerSearchKeyword = ref("");
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
const dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText(route.query.dateType), dateOptions, "all"));
|
||||
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
||||
const startDraft = ref("");
|
||||
|
||||
@@ -62,6 +62,7 @@ import { Time } from "timi-web";
|
||||
import FilterPopup from "@/components/filter-popup/FilterPopup.vue";
|
||||
import type { FilterGroup, FilterModel, FilterValueList } from "@/components/filter-popup/FilterPopup";
|
||||
import { buildPresetDateRange } from "@/utils/date";
|
||||
import { DATE_FILTER_OPTIONS as dateOptions } from "@/utils/dateFilter";
|
||||
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
|
||||
import {
|
||||
cloneSalesOrderFilter,
|
||||
@@ -96,15 +97,6 @@ const endVisible = ref(false);
|
||||
const startDraft = ref("");
|
||||
const endDraft = ref("");
|
||||
let resetRequested = false;
|
||||
const dateOptions: Array<{ label: string; value: SalesOrderDateFilterType }> = [
|
||||
{ label: "全部时间", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "最近 30 天", value: "last30" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
const orderTypeOptions: Array<{ label: string; value: GaoSalesOrderType }> = [
|
||||
{ label: "套餐订单", value: "PACKAGE" },
|
||||
{ label: "产品订单", value: "DIRECT_PRODUCT" }
|
||||
|
||||
@@ -73,8 +73,8 @@
|
||||
<script setup lang="ts">
|
||||
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
|
||||
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
|
||||
import { DATE_FILTER_OPTIONS } from "@/utils/dateFilter";
|
||||
import {
|
||||
type SalesOrderDateFilterType,
|
||||
type SalesOrderFilterGroupKey,
|
||||
type SalesOrderListFilter,
|
||||
type SalesOrderPaymentFilter
|
||||
@@ -112,17 +112,8 @@ const refundOptions: Array<{ label: string; value: GaoSalesRefundStatus }> = [
|
||||
{ label: "待退款", value: "PENDING" },
|
||||
{ label: "已退款", value: "REFUNDED" }
|
||||
];
|
||||
const dateFilterLabels: Record<SalesOrderDateFilterType, string> = {
|
||||
all: "全部",
|
||||
today: "今天",
|
||||
yesterday: "昨天",
|
||||
thisWeek: "本周",
|
||||
thisMonth: "本月",
|
||||
last30: "最近 30 天",
|
||||
custom: "自定义"
|
||||
};
|
||||
const filterDateText = computed(() => {
|
||||
return dateFilterLabels[props.filter.dateFilterType];
|
||||
return DATE_FILTER_OPTIONS.find(option => option.value === props.filter.dateFilterType)?.label || "全部";
|
||||
});
|
||||
const filterDateRangeText = computed(() => {
|
||||
const [start, end] = props.filter.dateRange;
|
||||
|
||||
Reference in New Issue
Block a user