From 76a985e3d790e506eef36c4df7442a95db0b29a3 Mon Sep 17 00:00:00 2001
From: 曹睿 <360930172@qq.com>
Date: 星期一, 23 六月 2025 16:48:00 +0800
Subject: [PATCH] feat: 完成设备台账

---
 src/views/equipmentManagement/ledger/index.vue |  129 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 111 insertions(+), 18 deletions(-)

diff --git a/src/views/equipmentManagement/ledger/index.vue b/src/views/equipmentManagement/ledger/index.vue
index 4327e98..590bc01 100644
--- a/src/views/equipmentManagement/ledger/index.vue
+++ b/src/views/equipmentManagement/ledger/index.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="filters" :inline="true">
+    <!-- <el-form :model="filters" :inline="true">
       <el-form-item label="鎼滅储">
         <el-input
           v-model="filters.searchText"
@@ -15,35 +15,59 @@
         <el-button type="primary" @click="getTableData">鎼滅储</el-button>
         <el-button @click="resetFilters">閲嶇疆</el-button>
       </el-form-item>
-    </el-form>
-    <PIMTable
-      :column="columns"
-      :tableData="dataList"
-      :page="{
-        current: pagination.currentPage,
-        size: pagination.pageSize,
-        total: pagination.total,
-      }"
-    >
-      <template #operation>
-        <el-button type="primary" text>缂栬緫</el-button>
-        <el-button type="danger" text>鍒犻櫎</el-button>
-      </template>
-    </PIMTable>
+    </el-form> -->
+    <div class="table_list">
+      <div class="actions">
+        <div></div>
+        <div>
+          <el-button type="primary" @click="add" icon="Plus"> 鏂板 </el-button>
+          <el-button @click="handleOut" icon="download">瀵煎嚭</el-button>
+        </div>
+      </div>
+      <PIMTable
+        :column="columns"
+        :tableData="dataList"
+        :page="{
+          current: pagination.currentPage,
+          size: pagination.pageSize,
+          total: pagination.total,
+        }"
+      >
+        <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>
   </div>
 </template>
 
 <script setup>
 import { usePaginationApi } from "@/hooks/usePaginationApi";
 import { Search } from "@element-plus/icons-vue";
+import { getLedgerPage, delLedger } from "@/api/equipmentManagement/ledger";
+import { onMounted } from "vue";
+import Modal from "./Modal.vue";
+import { ElMessageBox } from "element-plus";
 
 defineOptions({
   name: "璁惧鍙拌处",
 });
 
+const modalRef = ref();
 const { filters, columns, dataList, pagination, getTableData, resetFilters } =
   usePaginationApi(
-    () => {},
+    getLedgerPage,
     {
       searchText: undefined,
     },
@@ -51,54 +75,123 @@
       {
         label: "璁惧鍚嶇О",
         align: "center",
+        prop: "deviceName",
       },
       {
         label: "瑙勬牸鍨嬪彿",
         align: "center",
+        prop: "deviceModel",
       },
       {
         label: "渚涘簲鍟�",
         align: "center",
+        prop: "supplierName",
       },
       {
         label: "鍗曚綅",
         align: "center",
+        prop: "unit",
       },
       {
         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: "createUser",
       },
       {
         label: "褰曞叆鏃ユ湡",
         align: "center",
+        prop: "createTime",
       },
       {
+        fixed: "right",
         label: "鎿嶄綔",
         dataType: "slot",
         slot: "operation",
         align: "center",
-        width: "150px",
+        width: "200px",
       },
     ]
   );
+
+const add = () => {
+  modalRef.value.openModal();
+};
+const edit = (id) => {
+  modalRef.value.loadForm(id);
+};
+
+const deleteRow = (id) => {
+  ElMessageBox.confirm("姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?", "鎻愮ず", {
+    confirmButtonText: "纭畾",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  }).then(async () => {
+    const { code } = await delLedger(id);
+    if (code == 200) {
+      ElMessage({
+        type: "success",
+        message: "鍒犻櫎鎴愬姛",
+      });
+      getTableData();
+    }
+  });
+};
+
+const handleOut = () => {
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+    .then(() => {
+      proxy.download(
+        `/device/ledger/export?ids=${ids}`,
+        {},
+        "璁惧鍙拌处妗f.xlsx"
+      );
+    })
+    .catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
+    });
+};
+
+onMounted(() => {
+  getTableData();
+});
 </script>
+
+<style lang="scss" scoped>
+.table_list {
+  margin-top: unset;
+}
+.actions {
+  display: flex;
+  justify-content: space-between;
+  margin-bottom: 10px;
+}
+</style>

--
Gitblit v1.9.3