HistorySearchCard.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const _sfc_main = {
  4. __name: "HistorySearchCard",
  5. props: {
  6. defaultStartMonth: { type: String, default: "2025-01" },
  7. defaultEndMonth: { type: String, default: "2025-11" }
  8. },
  9. emits: ["search"],
  10. setup(__props, { emit }) {
  11. const props = __props;
  12. const startMonth = common_vendor.ref(props.defaultStartMonth);
  13. const endMonth = common_vendor.ref(props.defaultEndMonth);
  14. const formatMonth = (monthStr) => {
  15. if (!monthStr)
  16. return "请选择";
  17. const [year, month] = monthStr.split("-");
  18. return `${year}年${month}月`;
  19. };
  20. const onStartMonthChange = (e) => {
  21. startMonth.value = e.detail.value;
  22. };
  23. const onEndMonthChange = (e) => {
  24. endMonth.value = e.detail.value;
  25. };
  26. const onSearch = () => {
  27. if (!startMonth.value || !endMonth.value) {
  28. common_vendor.index.showToast({ title: "请选择开始和结束月份", icon: "none" });
  29. return;
  30. }
  31. if (startMonth.value > endMonth.value) {
  32. common_vendor.index.showToast({ title: "开始月份不能晚于结束月份", icon: "none" });
  33. return;
  34. }
  35. emit("search", { startMonth: startMonth.value, endMonth: endMonth.value });
  36. };
  37. return (_ctx, _cache) => {
  38. return {
  39. a: common_vendor.t(formatMonth(startMonth.value)),
  40. b: startMonth.value,
  41. c: common_vendor.o(onStartMonthChange),
  42. d: common_vendor.t(formatMonth(endMonth.value)),
  43. e: endMonth.value,
  44. f: common_vendor.o(onEndMonthChange),
  45. g: common_vendor.o(onSearch)
  46. };
  47. };
  48. }
  49. };
  50. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-df43cc4c"], ["__file", "D:/program/gupiao-wx/src/components/HistorySearchCard.vue"]]);
  51. wx.createComponent(Component);