| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- import { a as axios } from "./utils-dev.be08a1a2.js";
- import { a as ElMessage } from "./element-dev.26a170ea.js";
- import { v as defineComponent, r as ref, c as computed, l as onMounted, B as createElementBlock, E as createBaseVNode, C as createVNode, D as withCtx, ak as resolveComponent, aq as resolveDirective, y as openBlock, M as createTextVNode, J as withDirectives, O as toDisplayString, z as createBlock, L as createCommentVNode } from "./vue-dev.7a51ac2d.js";
- import { _ as _export_sfc } from "./_plugin-vue_export-helper-dev.cc2b3d55.js";
- const _hoisted_1 = { class: "orders-page" };
- const _hoisted_2 = { class: "card-header" };
- const _hoisted_3 = {
- key: 0,
- class: "empty-state"
- };
- const _hoisted_4 = { class: "stats-grid" };
- const _hoisted_5 = { class: "stats-content" };
- const _hoisted_6 = { class: "stats-number" };
- const _hoisted_7 = { class: "stats-content" };
- const _hoisted_8 = { class: "stats-number" };
- const _hoisted_9 = { class: "stats-content" };
- const _hoisted_10 = { class: "stats-number" };
- const _hoisted_11 = { class: "stats-content" };
- const _hoisted_12 = { class: "stats-number" };
- const _sfc_main = /* @__PURE__ */ defineComponent({
- __name: "Orders",
- setup(__props) {
- const loading = ref(false);
- const orders = ref([]);
- const completedOrders = computed(
- () => orders.value.filter((order) => order.status === "已完成").length
- );
- const processingOrders = computed(
- () => orders.value.filter((order) => order.status === "处理中").length
- );
- const totalAmount = computed(
- () => orders.value.reduce((sum, order) => sum + order.total_price, 0)
- );
- const loadOrders = async () => {
- loading.value = true;
- try {
- const response = await axios.get("/api/orders");
- if (response.data.code === 0) {
- orders.value = response.data.data.orders;
- ElMessage.success("订单列表加载成功");
- } else {
- ElMessage.error(response.data.message || "加载失败");
- }
- } catch (error) {
- console.error("加载订单列表失败:", error);
- ElMessage.error("加载订单列表失败");
- } finally {
- loading.value = false;
- }
- };
- const getStatusType = (status) => {
- switch (status) {
- case "已完成":
- return "success";
- case "处理中":
- return "warning";
- case "已取消":
- return "danger";
- default:
- return "info";
- }
- };
- const viewOrder = (order) => {
- ElMessage.info(`查看订单详情: ${order.id}`);
- };
- const cancelOrder = (order) => {
- ElMessage.info(`取消订单: ${order.id}`);
- };
- onMounted(() => {
- loadOrders();
- });
- return (_ctx, _cache) => {
- const _component_Refresh = resolveComponent("Refresh");
- const _component_el_icon = resolveComponent("el-icon");
- const _component_el_button = resolveComponent("el-button");
- const _component_el_table_column = resolveComponent("el-table-column");
- const _component_el_tag = resolveComponent("el-tag");
- const _component_el_table = resolveComponent("el-table");
- const _component_el_empty = resolveComponent("el-empty");
- const _component_el_card = resolveComponent("el-card");
- const _directive_loading = resolveDirective("loading");
- return openBlock(), createElementBlock("div", _hoisted_1, [
- _cache[8] || (_cache[8] = createBaseVNode("div", { class: "page-header" }, [
- createBaseVNode("h2", null, "订单管理"),
- createBaseVNode("p", null, "查看和管理用户订单信息")
- ], -1)),
- createVNode(_component_el_card, null, {
- header: withCtx(() => [
- createBaseVNode("div", _hoisted_2, [
- _cache[1] || (_cache[1] = createBaseVNode("span", null, "订单列表", -1)),
- createVNode(_component_el_button, {
- type: "primary",
- onClick: loadOrders
- }, {
- default: withCtx(() => [
- createVNode(_component_el_icon, null, {
- default: withCtx(() => [
- createVNode(_component_Refresh)
- ]),
- _: 1
- }),
- _cache[0] || (_cache[0] = createTextVNode(" 刷新 ", -1))
- ]),
- _: 1
- })
- ])
- ]),
- default: withCtx(() => [
- withDirectives((openBlock(), createElementBlock("div", null, [
- createVNode(_component_el_table, {
- data: orders.value,
- style: { "width": "100%" }
- }, {
- default: withCtx(() => [
- createVNode(_component_el_table_column, {
- prop: "id",
- label: "订单ID",
- width: "100"
- }),
- createVNode(_component_el_table_column, {
- prop: "product_name",
- label: "产品名称"
- }),
- createVNode(_component_el_table_column, {
- prop: "quantity",
- label: "数量",
- width: "100"
- }),
- createVNode(_component_el_table_column, {
- prop: "total_price",
- label: "总价",
- width: "120"
- }, {
- default: withCtx(({ row }) => [
- createTextVNode(" ¥" + toDisplayString(row.total_price.toFixed(2)), 1)
- ]),
- _: 1
- }),
- createVNode(_component_el_table_column, {
- prop: "status",
- label: "状态",
- width: "100"
- }, {
- default: withCtx(({ row }) => [
- createVNode(_component_el_tag, {
- type: getStatusType(row.status)
- }, {
- default: withCtx(() => [
- createTextVNode(toDisplayString(row.status), 1)
- ]),
- _: 2
- }, 1032, ["type"])
- ]),
- _: 1
- }),
- createVNode(_component_el_table_column, {
- prop: "created_at",
- label: "创建时间",
- width: "180"
- }),
- createVNode(_component_el_table_column, {
- label: "操作",
- width: "200"
- }, {
- default: withCtx(({ row }) => [
- createVNode(_component_el_button, {
- size: "small",
- onClick: ($event) => viewOrder(row)
- }, {
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
- createTextVNode(" 查看详情 ", -1)
- ])]),
- _: 1
- }, 8, ["onClick"]),
- row.status === "处理中" ? (openBlock(), createBlock(_component_el_button, {
- key: 0,
- size: "small",
- type: "warning",
- onClick: ($event) => cancelOrder(row)
- }, {
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
- createTextVNode(" 取消 ", -1)
- ])]),
- _: 1
- }, 8, ["onClick"])) : createCommentVNode("", true)
- ]),
- _: 1
- })
- ]),
- _: 1
- }, 8, ["data"]),
- !loading.value && orders.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_3, [
- createVNode(_component_el_empty, { description: "暂无订单数据" })
- ])) : createCommentVNode("", true)
- ])), [
- [_directive_loading, loading.value]
- ])
- ]),
- _: 1
- }),
- createBaseVNode("div", _hoisted_4, [
- createVNode(_component_el_card, { class: "stats-card" }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_5, [
- createBaseVNode("div", _hoisted_6, toDisplayString(orders.value.length), 1),
- _cache[4] || (_cache[4] = createBaseVNode("div", { class: "stats-label" }, "总订单数", -1))
- ])
- ]),
- _: 1
- }),
- createVNode(_component_el_card, { class: "stats-card" }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_7, [
- createBaseVNode("div", _hoisted_8, toDisplayString(completedOrders.value), 1),
- _cache[5] || (_cache[5] = createBaseVNode("div", { class: "stats-label" }, "已完成", -1))
- ])
- ]),
- _: 1
- }),
- createVNode(_component_el_card, { class: "stats-card" }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_9, [
- createBaseVNode("div", _hoisted_10, toDisplayString(processingOrders.value), 1),
- _cache[6] || (_cache[6] = createBaseVNode("div", { class: "stats-label" }, "处理中", -1))
- ])
- ]),
- _: 1
- }),
- createVNode(_component_el_card, { class: "stats-card" }, {
- default: withCtx(() => [
- createBaseVNode("div", _hoisted_11, [
- createBaseVNode("div", _hoisted_12, "¥" + toDisplayString(totalAmount.value.toFixed(2)), 1),
- _cache[7] || (_cache[7] = createBaseVNode("div", { class: "stats-label" }, "总金额", -1))
- ])
- ]),
- _: 1
- })
- ])
- ]);
- };
- }
- });
- const Orders_vue_vue_type_style_index_0_scoped_2b83f005_lang = "";
- const Orders = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2b83f005"]]);
- export {
- Orders as default
- };
- //# sourceMappingURL=Orders-dev.5c571709.js.map
|