From 93b79b3a68e19cc36a8feb3bfea4e08ae76ec233 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 06 一月 2026 21:14:34 +0800
Subject: [PATCH] 代码调整9

---
 src/views/equipmentManagement/ledger/index.vue |  188 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 144 insertions(+), 44 deletions(-)

diff --git a/src/views/equipmentManagement/ledger/index.vue b/src/views/equipmentManagement/ledger/index.vue
index 7fa970b..6136760 100644
--- a/src/views/equipmentManagement/ledger/index.vue
+++ b/src/views/equipmentManagement/ledger/index.vue
@@ -1,45 +1,54 @@
 <template>
   <div class="app-container">
+    <!-- 椤甸潰鍔熻兘璇存槑锛屼粎浣滀负鎻忚堪锛屼笉浣滀负鍏蜂綋瀛楁 -->
     <el-form :model="filters" :inline="true">
-      <el-form-item label="璁惧鍚嶇О">
+      <!-- 鐩戞帶璁惧鍩虹淇℃伅绛涢�� -->
+      <el-form-item label="鐩戞帶璁惧鍚嶇О">
         <el-input
           v-model="filters.deviceName"
           style="width: 240px"
-          placeholder="璇疯緭鍏ヨ澶囧悕绉�"
+          placeholder="璇疯緭鍏ョ洃鎺ц澶囧悕绉�"
           clearable
           :prefix-icon="Search"
           @change="getTableData"
         />
       </el-form-item>
-      <el-form-item label="瑙勬牸鍨嬪彿">
+      <!-- 娓╁害鐩戞祴瀛楁锛堣嫳鏂囧瓧娈� deviceModel 涓嶅彉锛� -->
+      <el-form-item label="娓╁害鐩戞祴鍙傛暟">
         <el-input
             v-model="filters.deviceModel"
             style="width: 240px"
-            placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
+            placeholder="璇疯緭鍏ユ俯搴︾浉鍏崇洃娴嬪弬鏁�"
             clearable
             :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
-      <el-form-item label="渚涘簲鍟�">
+      <!-- 鍘嬪姏鐩戞祴瀛楁锛堣嫳鏂囧瓧娈� supplierName 涓嶅彉锛� -->
+      <el-form-item label="鍘嬪姏鐩戞祴鍙傛暟">
         <el-input
             v-model="filters.supplierName"
             style="width: 240px"
-            placeholder="璇疯緭鍏ヤ緵搴斿晢"
+            placeholder="璇疯緭鍏ュ帇鍔涚浉鍏崇洃娴嬪弬鏁�"
             clearable
             :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
-      <el-form-item label="鍗曚綅">
+      <!-- 鑳借�楃洃娴嬪瓧娈碉紙鑻辨枃瀛楁 unit 涓嶅彉锛� -->
+      <el-form-item label="鑳借�楃洃娴嬪弬鏁�">
         <el-input
             v-model="filters.unit"
             style="width: 240px"
-            placeholder="璇疯緭鍏ュ崟浣�"
+            placeholder="璇疯緭鍏ヨ兘鑰楃浉鍏崇洃娴嬪弬鏁�"
             clearable
             :prefix-icon="Search"
             @change="getTableData"
         />
+      </el-form-item>
+      <el-form-item label="鐩戞帶鏃ユ湡:">
+        <el-date-picker v-model="filters.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
+                        placeholder="璇烽�夋嫨" clearable @change="changeDaterange" />
       </el-form-item>
       <el-form-item>
         <el-button type="primary" @click="getTableData">鎼滅储</el-button>
@@ -51,7 +60,7 @@
         <div></div>
         <div>
           <el-button type="primary" @click="add" icon="Plus"> 鏂板 </el-button>
-          <el-button @click="handleOut" icon="download">瀵煎嚭</el-button>
+          <!-- <el-button @click="handleOut" icon="download">瀵煎嚭</el-button> -->
           <el-button
             type="danger"
             icon="Delete"
@@ -72,25 +81,22 @@
           size: pagination.pageSize,
           total: pagination.total,
         }"
+        :isShowSummary="true"
+        :summaryMethod="summaryMethod"
         @selection-change="handleSelectionChange"
         @pagination="changePage"
       >
-        <template #operation="{ row }">
-          <el-button type="primary" text @click="edit(row.id)" icon="editPen">
-            缂栬緫
-          </el-button>
-          <el-button
-            type="danger"
-            text
-            icon="delete"
-            @click="deleteRow(row.id)"
-          >
-            鍒犻櫎
-          </el-button>
-        </template>
       </PIMTable>
     </div>
     <Modal ref="modalRef" @success="getTableData"></Modal>
+    <el-dialog v-model="qrDialogVisible" title="浜岀淮鐮�" width="300px">
+      <div style="text-align:center;">
+        <img :src="qrCodeUrl" alt="浜岀淮鐮�" style="width:200px;height:200px;" />
+        <div style="margin:10px 0;">
+          <el-button type="primary" @click="downloadQRCode">涓嬭浇浜岀淮鐮佸浘鐗�</el-button>
+        </div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -101,15 +107,25 @@
 import { onMounted, getCurrentInstance } from "vue";
 import Modal from "./Modal.vue";
 import { ElMessageBox, ElMessage } from "element-plus";
+import dayjs from "dayjs";
+import QRCode from "qrcode";
+import { ref } from "vue";
+import { summarizeTable } from "@/utils/summarizeTable";
+import {Search} from "@element-plus/icons-vue";
 
 defineOptions({
-  name: "璁惧鍙拌处",
+  // 椤甸潰鍔熻兘锛氳澶囪繙绋嬬洃鎺�
+  name: "璁惧杩滅▼鐩戞帶",
 });
 
 // 琛ㄦ牸澶氶�夋閫変腑椤�
 const multipleList = ref([]);
 const { proxy } = getCurrentInstance();
 const modalRef = ref();
+const qrDialogVisible = ref(false);
+const qrCodeUrl = ref("");
+const qrRowData = ref(null);
+
 const {
   filters,
   columns,
@@ -121,26 +137,34 @@
 } = usePaginationApi(
   getLedgerPage,
   {
-    searchText: undefined,
+    deviceName: undefined,
+    deviceModel: undefined,
+    supplierName: undefined,
+    unit: undefined,
+    entryDateStart: undefined,
+    entryDateEnd: undefined,
   },
   [
     {
-      label: "璁惧鍚嶇О",
+      label: "鐩戞帶璁惧鍚嶇О",
       align: "center",
       prop: "deviceName",
     },
     {
-      label: "瑙勬牸鍨嬪彿",
+      // 浣跨敤 deviceModel 瀛楁鎵胯浇娓╁害鐩戞祴鐩稿叧鍙傛暟
+      label: "娓╁害鐩戞祴鍙傛暟",
       align: "center",
       prop: "deviceModel",
     },
     {
-      label: "渚涘簲鍟�",
+      // 浣跨敤 supplierName 瀛楁鎵胯浇鍘嬪姏鐩戞祴鐩稿叧鍙傛暟
+      label: "鍘嬪姏鐩戞祴鍙傛暟",
       align: "center",
       prop: "supplierName",
     },
     {
-      label: "鍗曚綅",
+      // 浣跨敤 unit 瀛楁鎵胯浇鑳借�楃洃娴嬬浉鍏冲弬鏁�
+      label: "鑳借�楃洃娴嬪弬鏁�",
       align: "center",
       prop: "unit",
     },
@@ -150,43 +174,62 @@
       prop: "number",
     },
     {
-      label: "鍚◣鍗曚环",
+      // 浣跨敤 taxIncludingPriceUnit 瀛楁鎵胯浇鐩戞帶闃堝�间笂闄�
+      label: "鐩戞帶闃堝�间笂闄�",
       align: "center",
       prop: "taxIncludingPriceUnit",
     },
     {
-      label: "鍚◣鎬讳环",
+      // 浣跨敤 taxIncludingPriceTotal 瀛楁鎵胯浇鐩戞帶闃堝�间笅闄�
+      label: "鐩戞帶闃堝�间笅闄�",
       align: "center",
       prop: "taxIncludingPriceTotal",
     },
     {
-      label: "绋庣巼",
+      // 浣跨敤 taxRate 瀛楁鍛堢幇瀹炴椂鐩戞祴鍊�/褰撳墠璇绘暟
+      label: "瀹炴椂鐩戞祴鍊�",
       align: "center",
       prop: "taxRate",
     },
     {
-      label: "涓嶅惈绋庢�讳环",
+      // 浣跨敤 unTaxIncludingPriceTotal 瀛楁鎵胯浇绱鑳借��/鐩戞帶缁熻鍊�
+      label: "绱鑳借��",
       align: "center",
       prop: "unTaxIncludingPriceTotal",
     },
     {
-      label: "褰曞叆浜�",
+      label: "鐩戞帶浜�",
       align: "center",
       prop: "createUser",
     },
     {
-      label: "褰曞叆鏃ユ湡",
+      label: "鐩戞帶鏃ユ湡",
       align: "center",
       prop: "createTime",
     },
-    {
-      fixed: "right",
-      label: "鎿嶄綔",
-      dataType: "slot",
-      slot: "operation",
-      align: "center",
-      width: "200px",
-    },
+		{
+			dataType: "action",
+			label: "鎿嶄綔",
+			align: "center",
+			fixed: 'right',
+			width: 140,
+			operation: [
+				{
+					name: "缂栬緫",
+					type: "text",
+					clickFun: (row) => {
+						edit(row.id)
+					},
+				},
+				// {
+				// 	name: "鐢熸垚浜岀淮鐮�",
+				// 	type: "text",
+				// 	clickFun: (row) => {
+				// 		showQRCode(row)
+				// 	},
+				// },
+			],
+		},
   ]
 );
 
@@ -201,10 +244,25 @@
 const edit = (id) => {
   modalRef.value.loadForm(id);
 };
-const changePage = ({ page }) => {
+const changePage = ({ page, limit }) => {
   pagination.currentPage = page;
+	pagination.pageSize = limit;
   onCurrentChange(page);
 };
+
+// 鍚堣鏂规硶
+const summaryMethod = (param) => {
+  return summarizeTable(
+    param,
+    ['number', 'taxIncludingPriceTotal', 'unTaxIncludingPriceTotal', 'taxIncludingPriceUnit'],
+    {
+      number: { noDecimal: true },
+      taxIncludingPriceTotal: { decimalPlaces: 2 },
+      unTaxIncludingPriceTotal: { decimalPlaces: 2 }
+    }
+  );
+};
+
 const deleteRow = (id) => {
   ElMessageBox.confirm("姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?", "鎻愮ず", {
     confirmButtonText: "纭畾",
@@ -222,6 +280,17 @@
   });
 };
 
+const changeDaterange = (value) => {
+  if (value) {
+    filters.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
+    filters.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
+  } else {
+    filters.entryDateStart = undefined;
+    filters.entryDateEnd = undefined;
+  }
+  getTableData();
+};
+
 const handleOut = () => {
   ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
     confirmButtonText: "纭",
@@ -229,14 +298,36 @@
     type: "warning",
   })
     .then(() => {
-      proxy.download(`/device/ledger/export`, {}, "璁惧鍙拌处妗f.xlsx");
+      // 瀵煎嚭鏂囦欢鍚嶆敼涓鸿澶囪繙绋嬬洃鎺�
+      proxy.download(`/device/ledger/export`, {}, "璁惧杩滅▼鐩戞帶.xlsx");
     })
     .catch(() => {
       proxy.$modal.msg("宸插彇娑�");
     });
 };
 
+const showQRCode = async (row) => {
+  // 浣犲彲浠ヨ嚜瀹氫箟浜岀淮鐮佸唴瀹癸紝姣斿 row.id 鎴� row.deviceName
+  const qrContent = JSON.stringify(row); // 鎴� `${row.id}`
+  qrCodeUrl.value = await QRCode.toDataURL(qrContent);
+  qrRowData.value = row;
+  qrDialogVisible.value = true;
+};
+
+const downloadQRCode = () => {
+  const a = document.createElement("a");
+  a.href = qrCodeUrl.value;
+  a.download = `${qrRowData.value.deviceName || "浜岀淮鐮�"}.png`;
+  a.click();
+};
+
 onMounted(() => {
+  // filters.entryDate = [
+  //   dayjs().format("YYYY-MM-DD"),
+  //   dayjs().add(1, "day").format("YYYY-MM-DD"),
+  // ]
+  // filters.entryDateStart = dayjs().format("YYYY-MM-DD")
+  // filters.entryDateEnd = dayjs().add(1, "day").format("YYYY-MM-DD")
   getTableData();
 });
 </script>
@@ -250,4 +341,13 @@
   justify-content: space-between;
   margin-bottom: 10px;
 }
+
+.feature-desc {
+  margin-bottom: 16px;
+  padding: 10px 12px;
+  background: #f5f7fa;
+  border-radius: 4px;
+  color: #606266;
+  font-size: 13px;
+}
 </style>

--
Gitblit v1.9.3