"use strict"; const common_vendor = require("../../common/vendor.js"); const common_http = require("../../common/http.js"); function toDateString(d) { const m = (d.getMonth() + 1).toString().padStart(2, "0"); const day = d.getDate().toString().padStart(2, "0"); return `${d.getFullYear()}-${m}-${day}`; } const _sfc_main = { data() { const today = /* @__PURE__ */ new Date(); const first = new Date(today.getFullYear(), today.getMonth(), 1); return { range: "month", biz: "sale", sub: "out", kw: "", begin: toDateString(first), end: toDateString(today), list: [], loading: false }; }, computed: { totalAmount() { return this.list.reduce((s, o) => s + Number(o.amount || 0), 0); } }, onLoad() { this.reload(); }, methods: { setRange(r) { this.range = r; const now = /* @__PURE__ */ new Date(); if (r === "today") { this.begin = this.end = toDateString(now); } else if (r === "week") { const day = now.getDay() || 7; const start = new Date(now); start.setDate(now.getDate() - day + 1); this.begin = toDateString(start); this.end = toDateString(now); } else if (r === "month") { const first = new Date(now.getFullYear(), now.getMonth(), 1); this.begin = toDateString(first); this.end = toDateString(now); } else if (r === "year") { const first = new Date(now.getFullYear(), 0, 1); this.begin = toDateString(first); this.end = toDateString(now); } this.reload(); }, async reload() { this.loading = true; try { const res = await common_http.get("/api/sales/orders", { begin: this.begin, end: this.end, kw: this.kw, sub: this.sub }); this.list = Array.isArray(res == null ? void 0 : res.list) ? res.list : Array.isArray(res) ? res : []; } catch (e) { this.list = []; } finally { this.loading = false; } }, goCreate() { common_vendor.index.navigateTo({ url: "/pages/order/create" }); }, open(o) { } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $data.range === "custom" ? 1 : "", b: common_vendor.o(($event) => $options.setRange("custom")), c: $data.range === "week" ? 1 : "", d: common_vendor.o(($event) => $options.setRange("week")), e: $data.range === "today" ? 1 : "", f: common_vendor.o(($event) => $options.setRange("today")), g: $data.range === "month" ? 1 : "", h: common_vendor.o(($event) => $options.setRange("month")), i: $data.range === "year" ? 1 : "", j: common_vendor.o(($event) => $options.setRange("year")), k: $data.biz === "sale" ? 1 : "", l: common_vendor.o(($event) => $data.biz = "sale"), m: $data.biz === "purchase" ? 1 : "", n: common_vendor.o(($event) => $data.biz = "purchase"), o: $data.biz === "collection" ? 1 : "", p: common_vendor.o(($event) => $data.biz = "collection"), q: $data.biz === "capital" ? 1 : "", r: common_vendor.o(($event) => $data.biz = "capital"), s: $data.biz === "inventory" ? 1 : "", t: common_vendor.o(($event) => $data.biz = "inventory"), v: $data.sub === "out" ? 1 : "", w: common_vendor.o(($event) => $data.sub = "out"), x: $data.sub === "return" ? 1 : "", y: common_vendor.o(($event) => $data.sub = "return"), z: $data.sub === "receive" ? 1 : "", A: common_vendor.o(($event) => $data.sub = "receive"), B: common_vendor.o((...args) => $options.goCreate && $options.goCreate(...args)), C: common_vendor.o((...args) => $options.reload && $options.reload(...args)), D: $data.kw, E: common_vendor.o(($event) => $data.kw = $event.detail.value), F: $data.range === "custom" }, $data.range === "custom" ? { G: common_vendor.t($data.begin), H: $data.begin, I: common_vendor.o((e) => { $data.begin = e.detail.value; $options.reload(); }), J: common_vendor.t($data.end), K: $data.end, L: common_vendor.o((e) => { $data.end = e.detail.value; $options.reload(); }) } : {}, { M: common_vendor.t($options.totalAmount.toFixed(2)), N: common_vendor.f($data.list, (o, k0, i0) => { return { a: common_vendor.t(o.orderDate), b: common_vendor.t(o.customerName), c: common_vendor.t(o.orderNo), d: common_vendor.t(Number(o.amount).toFixed(2)), e: o.id, f: common_vendor.o(($event) => $options.open(o), o.id) }; }) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/detail/index.js.map