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 { Customer } from "@/types/Customer";
|
||||||
import type { Tag } from "@/types/Tag";
|
import type { Tag } from "@/types/Tag";
|
||||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
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 { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
import { useSettingStore } from "@/store/settingStore";
|
import { useSettingStore } from "@/store/settingStore";
|
||||||
@@ -188,8 +189,6 @@ defineOptions({
|
|||||||
name: "CustomerList"
|
name: "CustomerList"
|
||||||
});
|
});
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
@@ -209,15 +208,6 @@ const canShowActionMenu = computed(() => canCreateCustomer.value || canExportCus
|
|||||||
const scannerVisible = ref(false);
|
const scannerVisible = ref(false);
|
||||||
const scanStatus = ref("点击扫码开始识别");
|
const scanStatus = ref("点击扫码开始识别");
|
||||||
let latestDecodedText = "";
|
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 dateFilterType = ref<DateFilterType>("all");
|
||||||
const dateRange = ref<[string, string]>(buildPresetDateRange("all"));
|
const dateRange = ref<[string, string]>(buildPresetDateRange("all"));
|
||||||
const startDraft = ref("");
|
const startDraft = ref("");
|
||||||
|
|||||||
@@ -170,12 +170,12 @@ import type { EventOptionStat, EventRecordPage, EventRecordPageResult, Verificat
|
|||||||
import { isRetiredEvent } from "@/utils/event";
|
import { isRetiredEvent } from "@/utils/event";
|
||||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message.ts";
|
import { Message } from "@/utils/message.ts";
|
||||||
|
|
||||||
import type { EventItem, EventStatus } from "@/types/EventItem";
|
import type { EventItem, EventStatus } from "@/types/EventItem";
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
|
||||||
type VerificationFilter = "ALL" | VerificationStatus;
|
type VerificationFilter = "ALL" | VerificationStatus;
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -186,16 +186,6 @@ const pageSize = 20;
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
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());
|
const keyword = ref(getInitialKeyword());
|
||||||
|
|||||||
@@ -142,13 +142,12 @@ import EventRecordAPI from "@/api/EventRecordAPI";
|
|||||||
import type { CustomerEventRankView, EventRecordRankPage, EventRecordRankType } from "@/types/EventRecord";
|
import type { CustomerEventRankView, EventRecordRankPage, EventRecordRankType } from "@/types/EventRecord";
|
||||||
import type { EventItem } from "@/types/EventItem";
|
import type { EventItem } from "@/types/EventItem";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
import { Message } from "@/utils/message.ts";
|
import { Message } from "@/utils/message.ts";
|
||||||
|
|
||||||
type DateFilterType = "all" | "today" | "yesterday" | "thisWeek" | "thisMonth" | "custom";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "EventRecordRank"
|
name: "EventRecordRank"
|
||||||
});
|
});
|
||||||
@@ -162,15 +161,6 @@ const rankTypeOptions: Array<{ label: string; value: EventRecordRankType }> = [
|
|||||||
{ label: "按连续天数", value: "CONTINUOUS_DAYS" },
|
{ label: "按连续天数", value: "CONTINUOUS_DAYS" },
|
||||||
{ label: "按登记数值", value: "TOTAL_NUMBER_VALUE" }
|
{ 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));
|
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 { Customer } from "@/types/Customer";
|
||||||
import type { SalesOrder } from "@/types/SalesOrder";
|
import type { SalesOrder } from "@/types/SalesOrder";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { permissionCodes } from "@/utils/permission";
|
import { permissionCodes } from "@/utils/permission";
|
||||||
@@ -220,17 +221,7 @@ const actions = computed<NavbarAction[]>(() => [
|
|||||||
action: toPackageOrderList
|
action: toPackageOrderList
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
|
||||||
type SkuFilterOption = { skuId: string; productName: string; skuName: string };
|
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 customerId = ref(getQueryText(route.query.customerId));
|
||||||
const selectedSkuIdList = ref(getSkuIdList(route.query.skuIds));
|
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 type { PointLedger, PointLedgerChangeType, PointLedgerPage } from "@/types/Point";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateFilterOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { formatWanInteger } from "@/utils/money";
|
import { formatWanInteger } from "@/utils/money";
|
||||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||||
|
|
||||||
type DateFilter = "all" | "today" | "last7" | "last30" | "custom";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "PointLedgerList"
|
name: "PointLedgerList"
|
||||||
});
|
});
|
||||||
@@ -186,8 +185,8 @@ const customer = ref<Customer>();
|
|||||||
const customerKeyword = ref("");
|
const customerKeyword = ref("");
|
||||||
const selectorVisible = ref(false);
|
const selectorVisible = ref(false);
|
||||||
const changeTypeFilter = ref("ALL");
|
const changeTypeFilter = ref("ALL");
|
||||||
const dateFilter = ref<DateFilter>("last30");
|
const dateFilter = ref<DateFilterType>("thisMonth");
|
||||||
const dateRange = ref<[string, string]>(buildPresetDateRange("last30"));
|
const dateRange = ref<[string, string]>(buildPresetDateRange("thisMonth"));
|
||||||
const startDraft = ref("");
|
const startDraft = ref("");
|
||||||
const endDraft = ref("");
|
const endDraft = ref("");
|
||||||
const startDateVisible = ref(false);
|
const startDateVisible = ref(false);
|
||||||
@@ -199,13 +198,6 @@ const changeTypeOptions = [
|
|||||||
{ label: "撤销", value: "REVOKE" },
|
{ label: "撤销", value: "REVOKE" },
|
||||||
{ label: "调整", value: "ADJUST" }
|
{ 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 || "时间范围");
|
const dateFilterLabel = computed(() => dateFilterOptions.find(item => item.value === dateFilter.value)?.label || "时间范围");
|
||||||
|
|
||||||
async function handleCustomerChange(value: string | string[]): Promise<void> {
|
async function handleCustomerChange(value: string | string[]): Promise<void> {
|
||||||
@@ -263,7 +255,7 @@ async function selectDateFilter(value: DropdownValue): Promise<void> {
|
|||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dateFilter.value = String(value) as DateFilter;
|
dateFilter.value = String(value) as DateFilterType;
|
||||||
if (dateFilter.value !== "custom") {
|
if (dateFilter.value !== "custom") {
|
||||||
dateRange.value = buildPresetDateRange(dateFilter.value);
|
dateRange.value = buildPresetDateRange(dateFilter.value);
|
||||||
await reload();
|
await reload();
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ import PointAPI from "@/api/PointAPI";
|
|||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import type { PointRedemption, PointRedemptionStatus } from "@/types/Point";
|
import type { PointRedemption, PointRedemptionStatus } from "@/types/Point";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
import { formatWanInteger } from "@/utils/money";
|
import { formatWanInteger } from "@/utils/money";
|
||||||
import { getPackageQuantityText } from "@/utils/package";
|
import { getPackageQuantityText } from "@/utils/package";
|
||||||
@@ -188,16 +189,6 @@ defineOptions({ name: "PointRedemptionList" });
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const result = reactive({ total: 0, list: [] as PointRedemption[] });
|
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 keyword = ref(getQueryText(route.query.keyword));
|
||||||
const customerId = ref(getQueryText(route.query.customerId));
|
const customerId = ref(getQueryText(route.query.customerId));
|
||||||
const selectedCustomer = ref<Customer>();
|
const selectedCustomer = ref<Customer>();
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ import ProductAPI from "@/api/ProductAPI";
|
|||||||
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
|
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
|
||||||
import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
|
import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { getProductBaseUnitName, getProductPhotoURL, getProductQuantityText, getProductTypeText, getStockOperationText } from "@/utils/product";
|
import { getProductBaseUnitName, getProductPhotoURL, getProductQuantityText, getProductTypeText, getStockOperationText } from "@/utils/product";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
@@ -209,7 +210,6 @@ import type { Product, ProductSelection, ProductSku, StockOperationType, StockRe
|
|||||||
|
|
||||||
defineOptions({ name: "ProductStockRecordList" });
|
defineOptions({ name: "ProductStockRecordList" });
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
|
||||||
type OperationFilter = "ALL" | StockOperationType;
|
type OperationFilter = "ALL" | StockOperationType;
|
||||||
type DirectionFilter = "ALL" | StockRecordDirection;
|
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 operationType = ref<OperationFilter>(getQueryText("operationType") as OperationFilter || (activeReservationRequested ? "ORDER_RESERVE" : "ALL"));
|
||||||
const direction = ref<DirectionFilter>(getQueryText("direction") as DirectionFilter || "ALL");
|
const direction = ref<DirectionFilter>(getQueryText("direction") as DirectionFilter || "ALL");
|
||||||
const keyword = ref(getQueryText("keyword"));
|
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 dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText("dateType"), dateOptions, "all"));
|
||||||
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
||||||
const startDraft = ref("");
|
const startDraft = ref("");
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ import type {
|
|||||||
ConsumptionRecordStatus
|
ConsumptionRecordStatus
|
||||||
} from "@/types/ConsumptionRecord";
|
} from "@/types/ConsumptionRecord";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||||
import { Message } from "@/utils/message";
|
import { Message } from "@/utils/message";
|
||||||
@@ -206,21 +207,10 @@ import type { Customer } from "@/types/Customer";
|
|||||||
|
|
||||||
defineOptions({ name: "ConsumptionRecordList" });
|
defineOptions({ name: "ConsumptionRecordList" });
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
|
||||||
|
|
||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
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 sourceType = ref<ConsumptionRecordSourceType | "ALL">("ALL");
|
||||||
const status = ref<ConsumptionRecordStatus | "ALL">("ALL");
|
const status = ref<ConsumptionRecordStatus | "ALL">("ALL");
|
||||||
const customerId = ref("");
|
const customerId = ref("");
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
|||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
import type { FundOperationType, FundRecord, FundRecordStatus } from "@/types/SalesOrder";
|
import type { FundOperationType, FundRecord, FundRecordStatus } from "@/types/SalesOrder";
|
||||||
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions, type DateFilterType } from "@/utils/dateFilter";
|
||||||
import { getErrorMessage } from "@/utils/error";
|
import { getErrorMessage } from "@/utils/error";
|
||||||
import { formatPackageAmount } from "@/utils/package";
|
import { formatPackageAmount } from "@/utils/package";
|
||||||
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
||||||
@@ -203,8 +204,6 @@ import type { Customer } from "@/types/Customer";
|
|||||||
|
|
||||||
defineOptions({ name: "FundRecordList" });
|
defineOptions({ name: "FundRecordList" });
|
||||||
|
|
||||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -220,15 +219,6 @@ const customerId = ref(getQueryText(route.query.customerId));
|
|||||||
const selectedCustomer = ref<Customer>();
|
const selectedCustomer = ref<Customer>();
|
||||||
const customerSelectorVisible = ref(false);
|
const customerSelectorVisible = ref(false);
|
||||||
const customerSearchKeyword = ref("");
|
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 dateFilterType = ref<DateFilterType>(parseDateFilterType(getQueryText(route.query.dateType), dateOptions, "all"));
|
||||||
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
const dateRange = ref<[string, string]>(parseDateRange(dateFilterType.value));
|
||||||
const startDraft = ref("");
|
const startDraft = ref("");
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import { Time } from "timi-web";
|
|||||||
import FilterPopup from "@/components/filter-popup/FilterPopup.vue";
|
import FilterPopup from "@/components/filter-popup/FilterPopup.vue";
|
||||||
import type { FilterGroup, FilterModel, FilterValueList } from "@/components/filter-popup/FilterPopup";
|
import type { FilterGroup, FilterModel, FilterValueList } from "@/components/filter-popup/FilterPopup";
|
||||||
import { buildPresetDateRange } from "@/utils/date";
|
import { buildPresetDateRange } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS as dateOptions } from "@/utils/dateFilter";
|
||||||
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
|
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
|
||||||
import {
|
import {
|
||||||
cloneSalesOrderFilter,
|
cloneSalesOrderFilter,
|
||||||
@@ -96,15 +97,6 @@ const endVisible = ref(false);
|
|||||||
const startDraft = ref("");
|
const startDraft = ref("");
|
||||||
const endDraft = ref("");
|
const endDraft = ref("");
|
||||||
let resetRequested = false;
|
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 }> = [
|
const orderTypeOptions: Array<{ label: string; value: GaoSalesOrderType }> = [
|
||||||
{ label: "套餐订单", value: "PACKAGE" },
|
{ label: "套餐订单", value: "PACKAGE" },
|
||||||
{ label: "产品订单", value: "DIRECT_PRODUCT" }
|
{ label: "产品订单", value: "DIRECT_PRODUCT" }
|
||||||
|
|||||||
@@ -73,8 +73,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
|
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
|
||||||
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
|
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
|
||||||
|
import { DATE_FILTER_OPTIONS } from "@/utils/dateFilter";
|
||||||
import {
|
import {
|
||||||
type SalesOrderDateFilterType,
|
|
||||||
type SalesOrderFilterGroupKey,
|
type SalesOrderFilterGroupKey,
|
||||||
type SalesOrderListFilter,
|
type SalesOrderListFilter,
|
||||||
type SalesOrderPaymentFilter
|
type SalesOrderPaymentFilter
|
||||||
@@ -112,17 +112,8 @@ const refundOptions: Array<{ label: string; value: GaoSalesRefundStatus }> = [
|
|||||||
{ label: "待退款", value: "PENDING" },
|
{ label: "待退款", value: "PENDING" },
|
||||||
{ label: "已退款", value: "REFUNDED" }
|
{ label: "已退款", value: "REFUNDED" }
|
||||||
];
|
];
|
||||||
const dateFilterLabels: Record<SalesOrderDateFilterType, string> = {
|
|
||||||
all: "全部",
|
|
||||||
today: "今天",
|
|
||||||
yesterday: "昨天",
|
|
||||||
thisWeek: "本周",
|
|
||||||
thisMonth: "本月",
|
|
||||||
last30: "最近 30 天",
|
|
||||||
custom: "自定义"
|
|
||||||
};
|
|
||||||
const filterDateText = computed(() => {
|
const filterDateText = computed(() => {
|
||||||
return dateFilterLabels[props.filter.dateFilterType];
|
return DATE_FILTER_OPTIONS.find(option => option.value === props.filter.dateFilterType)?.label || "全部";
|
||||||
});
|
});
|
||||||
const filterDateRangeText = computed(() => {
|
const filterDateRangeText = computed(() => {
|
||||||
const [start, end] = props.filter.dateRange;
|
const [start, end] = props.filter.dateRange;
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import type {
|
|||||||
GaoSalesRefundStatus
|
GaoSalesRefundStatus
|
||||||
} from "@/types/SalesOrder";
|
} from "@/types/SalesOrder";
|
||||||
import type { DateTimeRange } from "@/utils/date";
|
import type { DateTimeRange } from "@/utils/date";
|
||||||
|
import { DATE_FILTER_OPTIONS, type DateFilterType } from "@/utils/dateFilter";
|
||||||
|
|
||||||
/** 销售订单时间筛选类型。 */
|
/** 销售订单筛选类型别名,保持现有导入路径兼容。 */
|
||||||
export type SalesOrderDateFilterType = "all" | "today" | "yesterday" | "thisWeek" | "thisMonth" | "last30" | "custom";
|
export type SalesOrderDateFilterType = DateFilterType;
|
||||||
|
|
||||||
/** 销售订单资金筛选类型,未收清为未收款和部分收款的组合条件。 */
|
/** 销售订单资金筛选类型,未收清为未收款和部分收款的组合条件。 */
|
||||||
export type SalesOrderPaymentFilter = GaoSalesPaymentStatus | "PENDING_RECEIVE";
|
export type SalesOrderPaymentFilter = GaoSalesPaymentStatus | "PENDING_RECEIVE";
|
||||||
@@ -57,8 +58,10 @@ export function normalizeSalesOrderFilter(value: unknown): SalesOrderListFilter
|
|||||||
}
|
}
|
||||||
|
|
||||||
const source = value as Partial<SalesOrderListFilter>;
|
const source = value as Partial<SalesOrderListFilter>;
|
||||||
const dateFilterType = ["all", "today", "yesterday", "thisWeek", "thisMonth", "last30", "custom"].includes(source.dateFilterType || "")
|
const storedDateFilterType = (value as { dateFilterType?: unknown }).dateFilterType;
|
||||||
? source.dateFilterType!
|
const normalizedDateFilterType = storedDateFilterType === "last30" ? "lastMonth" : storedDateFilterType;
|
||||||
|
const dateFilterType = DATE_FILTER_OPTIONS.some(option => option.value === normalizedDateFilterType)
|
||||||
|
? normalizedDateFilterType as DateFilterType
|
||||||
: defaultFilter.dateFilterType;
|
: defaultFilter.dateFilterType;
|
||||||
const dateRange = Array.isArray(source.dateRange) && 2 <= source.dateRange.length
|
const dateRange = Array.isArray(source.dateRange) && 2 <= source.dateRange.length
|
||||||
? [String(source.dateRange[0] || ""), String(source.dateRange[1] || "")] as DateTimeRange
|
? [String(source.dateRange[0] || ""), String(source.dateRange[1] || "")] as DateTimeRange
|
||||||
|
|||||||
+5
-11
@@ -1,16 +1,10 @@
|
|||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
|
|
||||||
/** 日期筛选器支持的预设范围。 */
|
/** 常规列表日期筛选类型。 */
|
||||||
export type DateFilterPreset =
|
export type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||||
| "all"
|
|
||||||
| "today"
|
/** 日期范围计算支持的预设类型。 */
|
||||||
| "yesterday"
|
export type DateFilterPreset = Exclude<DateFilterType, "custom"> | "lastWeek" | "last7" | "last30";
|
||||||
| "thisWeek"
|
|
||||||
| "lastWeek"
|
|
||||||
| "thisMonth"
|
|
||||||
| "lastMonth"
|
|
||||||
| "last7"
|
|
||||||
| "last30";
|
|
||||||
|
|
||||||
/** 日期时间范围,文本格式为 YYYY-MM-DD HH:mm。 */
|
/** 日期时间范围,文本格式为 YYYY-MM-DD HH:mm。 */
|
||||||
export type DateTimeRange = [string, string];
|
export type DateTimeRange = [string, string];
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import type { DateFilterType } from "@/utils/date";
|
||||||
|
|
||||||
|
export type { DateFilterType } from "@/utils/date";
|
||||||
|
|
||||||
|
/** 日期筛选选项。 */
|
||||||
|
export type DateFilterOption<T extends string> = {
|
||||||
|
label: string;
|
||||||
|
value: T;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 常规列表日期筛选选项。 */
|
||||||
|
export const DATE_FILTER_OPTIONS: DateFilterOption<DateFilterType>[] = [
|
||||||
|
{ label: "今天", value: "today" },
|
||||||
|
{ label: "昨天", value: "yesterday" },
|
||||||
|
{ label: "本周", value: "thisWeek" },
|
||||||
|
{ label: "本月", value: "thisMonth" },
|
||||||
|
{ label: "上个月", value: "lastMonth" },
|
||||||
|
{ label: "全部", value: "all" },
|
||||||
|
{ label: "自定义", value: "custom" }
|
||||||
|
];
|
||||||
|
|
||||||
Reference in New Issue
Block a user