From 7c8f7be6ee7244381eb0f842021f872bb0d8ffe5 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期六, 28 三月 2026 13:37:46 +0800
Subject: [PATCH] 固定资产
---
src/api/financialManagement/fixedAssets.js | 43 +++++++
src/views/financialManagement/fixedAssets/index.vue | 313 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 356 insertions(+), 0 deletions(-)
diff --git a/src/api/financialManagement/fixedAssets.js b/src/api/financialManagement/fixedAssets.js
new file mode 100644
index 0000000..309b183
--- /dev/null
+++ b/src/api/financialManagement/fixedAssets.js
@@ -0,0 +1,43 @@
+import request from "@/utils/request";
+// 鍒嗛〉鏌ヨ鍥哄畾璧勪骇鍒楄〃
+export const listPage = (params) => {
+ return request({
+ url: "/enterpriseFixedAssets/listPage",
+ method: "get",
+ params,
+ });
+};
+// 鏂板鍥哄畾璧勪骇
+export function add(data) {
+ return request({
+ url: "/enterpriseFixedAssets/add",
+ method: "post",
+ data: data,
+ });
+}
+// 鏇存柊鍥哄畾璧勪骇
+export function update(data) {
+ return request({
+ url: "/enterpriseFixedAssets/update",
+ method: "post",
+ data: data,
+ });
+}
+// 鍒犻櫎鍥哄畾璧勪骇
+export const delFixedAssets = (query) => {
+ return request({
+ url: `/enterpriseFixedAssets/delete`,
+ method: "delete",
+ data: query,
+ });
+};
+
+// 瀵煎嚭鍥哄畾璧勪骇
+export const exportFixedAssets = (query) => {
+ return request({
+ url: "/financial/fixedAssets/export",
+ method: "post",
+ data: query,
+ responseType: "blob",
+ });
+};
diff --git a/src/views/financialManagement/fixedAssets/index.vue b/src/views/financialManagement/fixedAssets/index.vue
new file mode 100644
index 0000000..6cf8824
--- /dev/null
+++ b/src/views/financialManagement/fixedAssets/index.vue
@@ -0,0 +1,313 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title">璧勪骇鍚嶇О锛�</span>
+ <el-input v-model="searchForm.name"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ @change="handleQuery"
+ clearable
+ prefix-icon="Search" />
+ <el-button type="primary"
+ @click="handleQuery"
+ style="margin-left: 10px">鎼滅储</el-button>
+ </div>
+ <div>
+ <el-button type="primary"
+ @click="openForm('add')">鏂板璧勪骇</el-button>
+ <el-button type="danger"
+ plain
+ @click="handleDelete">鍒犻櫎</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <el-table :data="tableData"
+ border
+ v-loading="tableLoading"
+ @selection-change="handleSelectionChange"
+ style="width: 100%"
+ height="calc(100vh - 18.5em)">
+ <el-table-column align="center"
+ type="selection"
+ width="55" />
+ <el-table-column align="center"
+ label="搴忓彿"
+ type="index"
+ width="60" />
+ <el-table-column label="璧勪骇鍚嶇О"
+ prop="name"
+ show-overflow-tooltip />
+ <el-table-column label="鍨嬪彿"
+ prop="model"
+ show-overflow-tooltip />
+ <el-table-column label="浠锋牸"
+ prop="price"
+ show-overflow-tooltip>
+ <template #default="{ row }">
+ 楼{{ row.price ? row.price.toFixed(2) : '0.00' }}
+ </template>
+ </el-table-column>
+ <el-table-column label="浣嶇疆"
+ prop="address"
+ show-overflow-tooltip />
+ <el-table-column label="鍒涘缓鏃堕棿"
+ prop="createTime"
+ show-overflow-tooltip>
+ <template #default="{ row }">
+ {{ row.createTime ? dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') : '-' }}
+ </template>
+ </el-table-column>
+ <el-table-column fixed="right"
+ label="鎿嶄綔"
+ min-width="100"
+ align="center">
+ <template #default="scope">
+ <el-button link
+ type="primary"
+ size="small"
+ @click="openForm('edit', scope.row);">缂栬緫</el-button>
+ <el-button link
+ type="danger"
+ size="small"
+ @click="handleDeleteSolo(scope.row)">鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <pagination v-show="total > 0"
+ :total="total"
+ layout="total, sizes, prev, pager, next, jumper"
+ :page="page.current"
+ :limit="page.size"
+ @pagination="paginationChange" />
+ </div>
+ <el-dialog v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板鍥哄畾璧勪骇' : '缂栬緫鍥哄畾璧勪骇'"
+ width="600px"
+ @close="closeDia">
+ <el-form :model="form"
+ label-width="100px"
+ :rules="rules"
+ ref="formRef">
+ <el-form-item label="璧勪骇鍚嶇О"
+ prop="name">
+ <el-input v-model="form.name"
+ placeholder="璇疯緭鍏ヨ祫浜у悕绉�"
+ clearable />
+ </el-form-item>
+ <el-form-item label="鍨嬪彿"
+ prop="model">
+ <el-input v-model="form.model"
+ placeholder="璇疯緭鍏ュ瀷鍙�"
+ clearable />
+ </el-form-item>
+ <el-form-item label="浠锋牸"
+ prop="price">
+ <el-input-number v-model="form.price"
+ :min="0"
+ :precision="2"
+ :step="0.01"
+ style="width: 100%"
+ placeholder="璇疯緭鍏ヤ环鏍�" />
+ </el-form-item>
+ <el-form-item label="浣嶇疆"
+ prop="address">
+ <el-input v-model="form.address"
+ type="textarea"
+ :rows="3"
+ placeholder="璇疯緭鍏ヤ綅缃�" />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary"
+ @click="submitForm">纭</el-button>
+ <el-button @click="closeDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+ import pagination from "@/components/PIMTable/Pagination.vue";
+ import { ref, reactive, toRefs, onMounted, getCurrentInstance } from "vue";
+ import { ElMessageBox } from "element-plus";
+ import useUserStore from "@/store/modules/user";
+ import {
+ listPage,
+ add,
+ update,
+ delFixedAssets,
+ } from "@/api/financialManagement/fixedAssets.js";
+ import dayjs from "dayjs";
+
+ const userStore = useUserStore();
+ const { proxy } = getCurrentInstance();
+
+ const tableData = ref([]);
+ const selectedRows = ref([]);
+ const tableLoading = ref(false);
+ const loading = ref(false);
+
+ const page = reactive({
+ current: 1,
+ size: 100,
+ });
+ const total = ref(0);
+
+ const operationType = ref("");
+ const dialogFormVisible = ref(false);
+ const data = reactive({
+ searchForm: {
+ name: "",
+ },
+ form: {
+ id: null,
+ name: "",
+ model: "",
+ price: 0,
+ address: "",
+ },
+ rules: {
+ name: [{ required: true, message: "璇疯緭鍏ヨ祫浜у悕绉�", trigger: "blur" }],
+ model: [{ required: true, message: "璇疯緭鍏ュ瀷鍙�", trigger: "blur" }],
+ price: [{ required: true, message: "璇疯緭鍏ヤ环鏍�", trigger: "blur" }],
+ address: [{ required: true, message: "璇疯緭鍏ヤ綅缃�", trigger: "blur" }],
+ },
+ });
+ const { searchForm, form, rules } = toRefs(data);
+
+ const handleQuery = () => {
+ page.current = 1;
+ getList();
+ };
+
+ const paginationChange = obj => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+ };
+
+ const getList = () => {
+ tableLoading.value = true;
+ listPage({ ...searchForm.value, ...page })
+ .then(res => {
+ tableLoading.value = false;
+ tableData.value = res.data.records;
+ total.value = res.data.total;
+ })
+ .catch(() => {
+ tableLoading.value = false;
+ });
+ };
+
+ const handleSelectionChange = selection => {
+ selectedRows.value = selection;
+ };
+
+ const openForm = async (type, row) => {
+ operationType.value = type;
+ dialogFormVisible.value = true;
+
+ if (type === "add") {
+ form.value = {
+ id: null,
+ name: "",
+ model: "",
+ price: 0,
+ address: "",
+ };
+ } else {
+ form.value = {
+ id: row.id,
+ name: row.name,
+ model: row.model,
+ price: row.price,
+ address: row.address,
+ };
+ }
+ };
+
+ const submitForm = async () => {
+ try {
+ await proxy.$refs.formRef.validate();
+ loading.value = true;
+
+ if (operationType.value === "add") {
+ await add(form.value);
+ proxy.$modal.msgSuccess("鏂板璧勪骇鎴愬姛");
+ } else {
+ await update(form.value);
+ proxy.$modal.msgSuccess("淇敼璧勪骇鎴愬姛");
+ }
+ closeDia();
+ getList();
+ } catch (error) {
+ console.error("鎻愪氦澶辫触:", error);
+ if (!error.errors) {
+ proxy.$modal.msgError("鎿嶄綔澶辫触锛岃閲嶈瘯");
+ }
+ } finally {
+ loading.value = false;
+ }
+ };
+
+ const closeDia = () => {
+ proxy.$refs.formRef.resetFields();
+ dialogFormVisible.value = false;
+ };
+ const handleDeleteSolo = row => {
+ ElMessageBox.confirm("璇ヨ祫浜у皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ const ids = [row.id];
+ delFixedAssets(ids)
+ .then(res => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("鍒犻櫎澶辫触");
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+ };
+
+ const handleDelete = () => {
+ if (selectedRows.value.length === 0) {
+ proxy.$modal.msgWarning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ const ids = selectedRows.value.map(item => item.id);
+ delFixedAssets(ids)
+ .then(res => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("鍒犻櫎澶辫触");
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+ };
+
+ onMounted(() => {
+ getList();
+ });
+</script>
+
+<style scoped lang="scss"></style>
--
Gitblit v1.9.3