From 045da5de062c1b43f53bc7b6a4cf125fbd97a3e5 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 09 四月 2026 15:37:14 +0800
Subject: [PATCH] 1.产品维护产品大类新增时层级不做限制 2.角色管理数据权限范围枚举值修改

---
 src/views/equipmentManagement/ledger/index.vue |  214 ++++++++++++++++++++++++++--------------------------
 1 files changed, 107 insertions(+), 107 deletions(-)

diff --git a/src/views/equipmentManagement/ledger/index.vue b/src/views/equipmentManagement/ledger/index.vue
index 6af5543..7ba9401 100644
--- a/src/views/equipmentManagement/ledger/index.vue
+++ b/src/views/equipmentManagement/ledger/index.vue
@@ -4,40 +4,27 @@
       <el-form-item label="璁惧鍚嶇О">
         <el-input
           v-model="filters.deviceName"
-          style="width: 240px"
+          style="width: 200px"
           placeholder="璇疯緭鍏ヨ澶囧悕绉�"
           clearable
-          :prefix-icon="Search"
           @change="getTableData"
         />
       </el-form-item>
       <el-form-item label="瑙勬牸鍨嬪彿">
         <el-input
             v-model="filters.deviceModel"
-            style="width: 240px"
+            style="width: 200px"
             placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
             clearable
-            :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
       <el-form-item label="渚涘簲鍟�">
         <el-input
             v-model="filters.supplierName"
-            style="width: 240px"
+            style="width: 200px"
             placeholder="璇疯緭鍏ヤ緵搴斿晢"
             clearable
-            :prefix-icon="Search"
-            @change="getTableData"
-        />
-      </el-form-item>
-      <el-form-item label="鍗曚綅">
-        <el-input
-            v-model="filters.unit"
-            style="width: 240px"
-            placeholder="璇疯緭鍏ュ崟浣�"
-            clearable
-            :prefix-icon="Search"
             @change="getTableData"
         />
       </el-form-item>
@@ -55,6 +42,7 @@
         <div></div>
         <div>
           <el-button type="primary" @click="add" icon="Plus"> 鏂板 </el-button>
+          <el-button type="info" @click="handleImport" icon="Upload">瀵煎叆</el-button>
           <el-button @click="handleOut" icon="download">瀵煎嚭</el-button>
           <el-button
             type="danger"
@@ -82,15 +70,45 @@
       </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-top:6px;font-size:14px;color:#333;">{{ qrRowData?.deviceName }}</div>
-				<div style="margin:10px 0;">
-					<el-button type="primary" @click="downloadQRCode">涓嬭浇浜岀淮鐮佸浘鐗�</el-button>
-				</div>
-			</div>
-		</el-dialog>
+    <el-dialog v-model="qrDialogVisible" title="浜岀淮鐮�" width="300px" draggable>
+      <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>
+    
+    <!-- 瀵煎叆瀵硅瘽妗� -->
+    <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
+      <el-upload
+        ref="uploadRef"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <el-icon class="el-icon--upload"><upload-filled /></el-icon>
+        <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+        <template #tip>
+          <div class="el-upload__tip text-center">
+            <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
+            <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline; margin-left: 5px;" @click="importTemplate">涓嬭浇妯℃澘</el-link>
+          </div>
+        </template>
+      </el-upload>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+          <el-button @click="upload.open = false">鍙� 娑�</el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -98,12 +116,13 @@
 import { usePaginationApi } from "@/hooks/usePaginationApi";
 // import { Search } from "@element-plus/icons-vue";
 import { getLedgerPage, delLedger } from "@/api/equipmentManagement/ledger";
-import { onMounted, getCurrentInstance } from "vue";
+import { onMounted, getCurrentInstance, ref, reactive } from "vue";
 import Modal from "./Modal.vue";
 import { ElMessageBox, ElMessage } from "element-plus";
+import { UploadFilled } from "@element-plus/icons-vue";
+import { getToken } from "@/utils/auth";
 import dayjs from "dayjs";
 import QRCode from "qrcode";
-import { ref } from "vue";
 
 defineOptions({
   name: "璁惧鍙拌处",
@@ -116,6 +135,21 @@
 const qrDialogVisible = ref(false);
 const qrCodeUrl = ref("");
 const qrRowData = ref(null);
+
+// 瀵煎叆鐩稿叧
+const uploadRef = ref(null)
+const upload = reactive({
+  // 鏄惁鏄剧ず寮瑰嚭灞�
+  open: false,
+  // 寮瑰嚭灞傛爣棰�
+  title: "",
+  // 鏄惁绂佺敤涓婁紶
+  isUploading: false,
+  // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+  headers: { Authorization: "Bearer " + getToken() },
+  // 涓婁紶鐨勫湴鍧�
+  url: import.meta.env.VITE_APP_BASE_API + "/device/ledger/import"
+})
 
 const {
   filters,
@@ -131,81 +165,53 @@
     deviceName: undefined,
     deviceModel: undefined,
     supplierName: undefined,
-    unit: undefined,
     entryDateStart: undefined,
     entryDateEnd: undefined,
   },
   [
     {
       label: "璁惧鍚嶇О",
-      align: "center",
       prop: "deviceName",
     },
     {
       label: "瑙勬牸鍨嬪彿",
-      align: "center",
       prop: "deviceModel",
     },
     {
       label: "璁惧鍝佺墝",
-      align: "center",
       prop: "deviceBrand",
     },
     {
+      label: "璁惧绫诲瀷",
+      prop: "type",
+    },
+    {
       label: "渚涘簲鍟�",
-      align: "center",
       prop: "supplierName",
     },
     {
-      label: "鍗曚綅",
-      align: "center",
-      prop: "unit",
-    },
-    {
       label: "瀛樻斁浣嶇疆",
-      align: "center",
       prop: "storageLocation",
     },
     {
       label: "鏁伴噺",
-      align: "center",
       prop: "number",
     },
     {
-      label: "鍚◣鍗曚环",
-      align: "center",
-      prop: "taxIncludingPriceUnit",
-    },
-    {
-      label: "鍚◣鎬讳环",
-      align: "center",
-      prop: "taxIncludingPriceTotal",
-    },
-    {
-      label: "绋庣巼",
-      align: "center",
-      prop: "taxRate",
-    },
-    {
-      label: "涓嶅惈绋庢�讳环",
-      align: "center",
-      prop: "unTaxIncludingPriceTotal",
-    },
-    {
-      label: "鍚敤鎶樻棫",
-      align: "center",
-      prop: "enableDepreciation",
-      formatData: (v) => (v ? "鏄�" : "鍚�"),
-    },
-    {
       label: "褰曞叆浜�",
-      align: "center",
       prop: "createUser",
     },
     {
       label: "褰曞叆鏃ユ湡",
-      align: "center",
       prop: "createTime",
+      formatData: (v) => {
+        if (!v) return '';
+        // 濡傛灉鍖呭惈鏃跺垎绉掞紝鍙彇鏃ユ湡閮ㄥ垎
+        if (v.includes(' ')) {
+          return v.split(' ')[0];
+        }
+        return v;
+      },
     },
 		{
 			dataType: "action",
@@ -216,14 +222,12 @@
 			operation: [
 				{
 					name: "缂栬緫",
-					type: "text",
 					clickFun: (row) => {
 						edit(row.id)
 					},
 				},
 				{
 					name: "鐢熸垚浜岀淮鐮�",
-					type: "text",
 					clickFun: (row) => {
 						showQRCode(row)
 					},
@@ -300,46 +304,42 @@
 };
 
 const downloadQRCode = () => {
-	const name = qrRowData.value?.deviceName || "浜岀淮鐮�";
-	const img = new Image();
-	img.src = qrCodeUrl.value;
-	img.onload = () => {
-		const padding = 10;
-		const qrSize = 200;
-		const textHeight = 24; // space for text
-		const width = qrSize + padding * 2;
-		const height = qrSize + padding * 2 + textHeight;
-		const canvas = document.createElement("canvas");
-		canvas.width = width;
-		canvas.height = height;
-		const ctx = canvas.getContext("2d");
-		// background
-		ctx.fillStyle = "#ffffff";
-		ctx.fillRect(0, 0, width, height);
-		// draw QR centered
-		ctx.drawImage(img, padding, padding, qrSize, qrSize);
-		// draw name centered below
-		ctx.fillStyle = "#333";
-		ctx.font = "14px Arial";
-		ctx.textAlign = "center";
-		ctx.textBaseline = "middle";
-		const maxTextWidth = width - padding * 2;
-		let displayName = name;
-		// ellipsis if too long
-		while (ctx.measureText(displayName).width > maxTextWidth && displayName.length > 0) {
-			displayName = displayName.slice(0, -1);
-		}
-		if (displayName !== name) displayName = displayName + "鈥�";
-		ctx.fillText(displayName, width / 2, qrSize + padding + textHeight / 2);
-		
-		const dataUrl = canvas.toDataURL("image/png");
-		const a = document.createElement("a");
-		a.href = dataUrl;
-		a.download = `${name}.png`;
-		a.click();
-	};
+  const a = document.createElement("a");
+  a.href = qrCodeUrl.value;
+  a.download = `${qrRowData.value.deviceName || "浜岀淮鐮�"}.png`;
+  a.click();
 };
 
+// 瀵煎叆鎸夐挳鎿嶄綔
+const handleImport = () => {
+  upload.title = "璁惧鍙拌处瀵煎叆"
+  upload.open = true
+}
+
+// 涓嬭浇妯℃澘鎿嶄綔
+const importTemplate = () => {
+  proxy.download("/device/ledger/downloadTemplate", {}, `璁惧鍙拌处瀵煎叆妯℃澘_${new Date().getTime()}.xlsx`)
+}
+
+// 鏂囦欢涓婁紶涓鐞�
+const handleFileUploadProgress = (event, file, fileList) => {
+  upload.isUploading = true
+}
+
+// 鏂囦欢涓婁紶鎴愬姛澶勭悊
+const handleFileSuccess = (response, file, fileList) => {
+  upload.open = false
+  upload.isUploading = false
+  proxy.$refs["uploadRef"].handleRemove(file)
+  proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "瀵煎叆缁撴灉", { dangerouslyUseHTMLString: true })
+  getTableData()
+}
+
+// 鎻愪氦涓婁紶鏂囦欢
+const submitFileForm = () => {
+  proxy.$refs["uploadRef"].submit()
+}
+
 onMounted(() => {
   getTableData();
 });

--
Gitblit v1.9.3