From 85fffd2b6a9df3b4779283aab60050918c6e4823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=87=E5=B3=B0?= Date: Thu, 12 Feb 2026 20:50:48 +0800 Subject: [PATCH] up --- backend/routers/apiPurchase.go | 6 +- frontent/ops_vue_js/src/i18n/en.json | 6 +- frontent/ops_vue_js/src/i18n/zh-CN.json | 4 +- .../src/views/purchase/purchase.vue | 258 ++++++++++++++++-- 4 files changed, 244 insertions(+), 30 deletions(-) diff --git a/backend/routers/apiPurchase.go b/backend/routers/apiPurchase.go index 369b2cc..c92d01c 100644 --- a/backend/routers/apiPurchase.go +++ b/backend/routers/apiPurchase.go @@ -50,7 +50,7 @@ func ApiPurchase(r *gin.RouterGroup) { is_data_ok := true - if jsondata.Entries <= 0 { + if jsondata.Entries <= 0 || jsondata.Entries > 300 { is_data_ok = false } if jsondata.Page <= 0 { @@ -62,11 +62,11 @@ func ApiPurchase(r *gin.RouterGroup) { //读取有多少条目 var count int64 models.DB.Model(&models.TabPurchaseOrder{}).Count(&count) - fmt.Println(count) + //fmt.Println(count) //读取条目 var getorders []models.TabPurchaseOrder - models.DB.Order("created_at DESC").Limit(jsondata.Entries).Find(&getorders) + models.DB.Order("created_at DESC").Offset(jsondata.Entries * (jsondata.Page - 1)).Limit(jsondata.Entries).Find(&getorders) ReturnJson(ctx, "apiOK", map[string]interface{}{ "all_count": count, diff --git a/frontent/ops_vue_js/src/i18n/en.json b/frontent/ops_vue_js/src/i18n/en.json index 0bd997e..3d9a9ba 100644 --- a/frontent/ops_vue_js/src/i18n/en.json +++ b/frontent/ops_vue_js/src/i18n/en.json @@ -58,7 +58,9 @@ "entries": "entries", "search": "Search", "add_part": "Add Order", - "exp_report": "Export Report" + "exp_report": "Export Report", + "There_are_a_total_of": ",There are a total of", + "items": "items." }, "purchase_addorder": { "add_order": "Add Order", @@ -93,7 +95,7 @@ "order_status": "Order Status", "modify_order_status": "Modify Order Status", "submit": "Submit", - "part_name":"Parts Name" + "part_name": "Parts Name" }, "schedule": { "my_schedule": "My Schedule", diff --git a/frontent/ops_vue_js/src/i18n/zh-CN.json b/frontent/ops_vue_js/src/i18n/zh-CN.json index 7d8a6e0..4cfbbd9 100644 --- a/frontent/ops_vue_js/src/i18n/zh-CN.json +++ b/frontent/ops_vue_js/src/i18n/zh-CN.json @@ -58,7 +58,9 @@ "entries": "个物件", "search": "搜索", "add_part": "添加订单", - "exp_report": "生成报告" + "exp_report": "生成报告", + "There_are_a_total_of":",一共", + "items":"个物件" }, "purchase_addorder": { "add_order": "添加订单", diff --git a/frontent/ops_vue_js/src/views/purchase/purchase.vue b/frontent/ops_vue_js/src/views/purchase/purchase.vue index 7f72bc7..df9d9af 100644 --- a/frontent/ops_vue_js/src/views/purchase/purchase.vue +++ b/frontent/ops_vue_js/src/views/purchase/purchase.vue @@ -8,24 +8,58 @@ import { myfuncs } from "@/myfunc"; const { t, locale } = useI18n(); +const all_items = ref(0); +const all_pages = ref(0); +const page_items = ref(10); +const now_page = ref(1); + const all_orders = ref({}); +const page_start = ref(0); +const page_end = ref(0); + +const page_input = ref(); +const page_items_items = ref("10"); + //获取订单列表 function get_orders() { my_network_func.postJson( "/purchase/getorders", { search: "", - entries: 10, - page: 1, + entries: page_items.value, + page: now_page.value, }, (r) => { - console.log(r); + //console.log(r); switch (r.statusCode) { case 200: switch (r.data.err_code) { case 0: all_orders.value = r.data.return.all_orders; + all_items.value = r.data.return.all_count; + all_pages.value = Math.ceil(all_items.value / page_items.value); + if (now_page.value < 3) { + page_start.value = 1; + } else { + if (now_page.value > all_pages.value - 3) { + page_start.value = all_pages.value - 4; + if (page_start.value <= 0) { + page_start.value = 1; + } + } else { + page_start.value = now_page.value - 2; + } + } + if (now_page.value > all_pages.value - 3) { + page_end.value = all_pages.value; + } else { + if (now_page.value < 3) { + page_end.value = 5; + } else { + page_end.value = now_page.value + 2; + } + } break; default: mos.value?.showAlert("danger", t("message.server_error"), 5000); @@ -40,9 +74,56 @@ function get_orders() { ); } +function change_page(page) { + now_page.value = page; + get_orders(); +} + function functionupdataTitle() { document.title = "Operations." + t("appname.purchase"); } + +function range(start, end) { + return Array.from({ length: end - start + 1 }, (_, i) => start + i); +} + +function page_input_change(c) { + //console.log(page_input.value); + + var t = parseInt(page_input.value); + if (t > 0) { + if (t <= all_pages.value) { + page_input.value = ""; + change_page(t); + } + } +} + +function page_input_input(c) { + page_input.value = page_input.value.replace(/[^\d]/g, ""); + + //console.log(c) +} + +function page_items_input_change(c) { + var t = parseInt(page_items_items.value); + page_items.value = t; + now_page.value = 1; + get_orders(); + //console.log(t) +} + +function page_items_input_input(c) { + page_items_items.value = page_items_items.value.replace(/[^\d]/g, ""); + + var t = parseInt(page_items_items.value); + if (t > 300) { + page_items_items.value = "300"; + } + + //console.log(c) +} + onMounted(() => { functionupdataTitle(); @@ -159,8 +240,41 @@ watch(locale, () => { {{ value.Title }} {{ value.Remark }} - - {{myfuncs.formatLocalizedDate(value.CreatedAt,locale) }} + + + + + {{ myfuncs.formatLocalizedDate(value.CreatedAt, locale) }} + {{ myfuncs.formatLocalizedDate(value.UpdatedAt) }} @@ -189,16 +303,59 @@ watch(locale, () => {