<template>
|
<view class="sales-account">
|
<!-- 使用通用页面头部组件 -->
|
<PageHeader title="借阅管理" @back="goBack" />
|
|
<!-- 搜索和筛选区域 -->
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input
|
class="search-text"
|
placeholder="请输入借阅人搜索"
|
v-model="searchForm.borrower"
|
@change="getList"
|
clearable
|
/>
|
</view>
|
<view class="filter-button" @click="getList">
|
<up-icon name="search" size="24" color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
|
<!-- 借阅列表 -->
|
<view class="ledger-list" v-if="borrowList.length > 0">
|
<view v-for="(item, index) in borrowList" :key="index">
|
<view class="ledger-item">
|
<view class="item-header">
|
<view class="item-left">
|
<view class="document-icon">
|
<up-icon name="file-text" size="16" color="#ffffff"></up-icon>
|
</view>
|
<text class="item-id">{{ item.docName || '-' }}</text>
|
</view>
|
<view class="item-tag" :class="getStatusClass(item.borrowStatus)">
|
<text class="tag-text">{{ item.borrowStatus }}</text>
|
</view>
|
</view>
|
<up-divider></up-divider>
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">借阅人</text>
|
<text class="detail-value">{{ item.borrower || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">借阅目的</text>
|
<text class="detail-value">{{ item.borrowPurpose || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">借阅日期</text>
|
<text class="detail-value">{{ item.borrowDate || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">应归还日期</text>
|
<text class="detail-value">{{ item.dueReturnDate || '-' }}</text>
|
</view>
|
<view class="detail-row" v-if="item.remark">
|
<text class="detail-label">备注</text>
|
<text class="detail-value">{{ item.remark }}</text>
|
</view>
|
</view>
|
<up-divider></up-divider>
|
<view class="detail-buttons">
|
<u-button
|
v-if="item.borrowStatus !== '归还'"
|
class="detail-button"
|
size="small"
|
type="primary"
|
@click.stop="goEdit(item)"
|
>
|
编辑
|
</u-button>
|
<u-button
|
v-if="item.borrowStatus !== '归还'"
|
class="detail-button"
|
size="small"
|
type="error"
|
plain
|
@click.stop="handleDelete(item)"
|
>
|
删除
|
</u-button>
|
<u-button
|
v-if="item.borrowStatus === '归还'"
|
class="detail-button"
|
size="small"
|
type="primary"
|
plain
|
@click.stop="goView(item)"
|
>
|
查看
|
</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<view v-else class="no-data">
|
<text>暂无借阅记录</text>
|
</view>
|
|
<!-- 浮动操作按钮 -->
|
<view class="fab-button" @click="goAdd">
|
<up-icon name="plus" size="24" color="#ffffff"></up-icon>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive } from "vue";
|
import { onShow } from "@dcloudio/uni-app";
|
import PageHeader from "@/components/PageHeader.vue";
|
import { getBorrowList, deleteBorrow } from "@/api/fileManagement/borrow";
|
|
// 查询表单
|
const searchForm = reactive({
|
borrower: "",
|
});
|
|
// 借阅列表数据
|
const borrowList = ref([]);
|
|
// 分页相关
|
const pagination = reactive({
|
currentPage: 1,
|
pageSize: 10,
|
total: 0,
|
});
|
|
// 返回上一页
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
// 获取状态样式类
|
const getStatusClass = (status) => {
|
if (status === "归还") return "tag-success";
|
if (status === "借阅") return "tag-warning";
|
return "tag-default";
|
};
|
|
// 加载借阅列表
|
const getList = async () => {
|
uni.showLoading({ title: "加载中...", mask: true });
|
|
const query = {
|
page: -1,
|
size: -1,
|
borrower: searchForm.borrower || undefined,
|
};
|
|
try {
|
const res = await getBorrowList(query);
|
if (res.code === 200) {
|
borrowList.value = res.data.records || [];
|
pagination.total = res.data.total || 0;
|
} else {
|
uni.showToast({ title: res.msg || "获取借阅列表失败", icon: "none" });
|
borrowList.value = [];
|
}
|
} catch (error) {
|
uni.showToast({ title: "获取借阅列表失败", icon: "none" });
|
borrowList.value = [];
|
} finally {
|
uni.hideLoading();
|
}
|
};
|
|
// 跳转到新增页面
|
const goAdd = () => {
|
uni.navigateTo({
|
url: "/pages/fileManagement/borrow/edit",
|
});
|
};
|
|
// 跳转到编辑页面
|
const goEdit = (item) => {
|
uni.setStorageSync("borrowEditData", JSON.stringify(item));
|
uni.navigateTo({
|
url: `/pages/fileManagement/borrow/edit?id=${item.id}`,
|
});
|
};
|
|
// 跳转到查看页面(已归还记录)
|
const goView = (item) => {
|
uni.setStorageSync("borrowEditData", JSON.stringify(item));
|
uni.navigateTo({
|
url: `/pages/fileManagement/borrow/edit?id=${item.id}`,
|
});
|
};
|
|
// 删除
|
const handleDelete = (row) => {
|
uni.showModal({
|
title: "删除确认",
|
content: "选中的内容将被删除,是否确认删除?",
|
confirmText: "确认",
|
cancelText: "取消",
|
success: async (res) => {
|
if (res.confirm) {
|
try {
|
uni.showLoading({ title: "删除中...", mask: true });
|
const result = await deleteBorrow([row.id]);
|
if (result.code === 200) {
|
uni.showToast({ title: "删除成功", icon: "success" });
|
getList();
|
} else {
|
uni.showToast({ title: result.msg || "删除失败", icon: "none" });
|
}
|
} catch (error) {
|
uni.showToast({ title: "删除失败", icon: "none" });
|
} finally {
|
uni.hideLoading();
|
}
|
}
|
},
|
});
|
};
|
|
onShow(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/styles/sales-common.scss";
|
|
// 标签样式
|
.item-tag {
|
border-radius: 4px;
|
padding: 2px 8px;
|
|
&.tag-success {
|
background: #4caf50;
|
}
|
|
&.tag-warning {
|
background: #ff9800;
|
}
|
|
&.tag-default {
|
background: #9e9e9e;
|
}
|
}
|
|
.tag-text {
|
font-size: 11px;
|
color: #ffffff;
|
font-weight: 500;
|
}
|
|
// 按钮样式
|
.detail-buttons {
|
padding: 12px 0;
|
display: flex;
|
gap: 12px;
|
}
|
|
.detail-button {
|
flex: 1;
|
}
|
</style>
|