<template>
|
<view class="sales-account">
|
<PageHeader title="采购退货单" @back="goBack">
|
<template #right>
|
<up-button
|
type="primary"
|
size="small"
|
text="新增"
|
:customStyle="{ marginRight: '12px' }"
|
@click="goAdd"
|
/>
|
</template>
|
</PageHeader>
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input
|
class="search-text"
|
placeholder="请输入退料单号"
|
v-model="searchNo"
|
@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="list.length > 0">
|
<view v-for="item in list" :key="item.id">
|
<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.no || "-" }}</text>
|
</view>
|
</view>
|
<up-divider></up-divider>
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">退货方式</text>
|
<text class="detail-value">{{ getReturnTypeLabel(item.returnType) }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">供应商名称</text>
|
<text class="detail-value">{{ item.supplierName || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">项目阶段</text>
|
<text class="detail-value">{{ getProjectPhaseLabel(item.projectPhase) }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">制作日期</text>
|
<text class="detail-value">{{ item.preparedAt || "-" }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">成交金额(元)</text>
|
<text class="detail-value highlight">{{ formatAmount(item.totalAmount) }}</text>
|
</view>
|
</view>
|
<view class="action-buttons">
|
<u-button size="small" class="action-btn" @click="goView(item)">详情</u-button>
|
<u-button
|
type="error"
|
size="small"
|
class="action-btn"
|
@click="handleDelete(item)"
|
>
|
删除
|
</u-button>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view v-else class="no-data">
|
<text>暂无采购退货单数据</text>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref } from "vue";
|
import { onShow } from "@dcloudio/uni-app";
|
import { findPurchaseReturnOrderListPage, deletePurchaseReturnOrder } from "@/api/procurementManagement/purchaseReturnOrder";
|
|
const searchNo = ref("");
|
const list = ref([]);
|
|
const page = {
|
current: -1,
|
size: -1,
|
};
|
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
const goAdd = () => {
|
uni.navigateTo({
|
url: "/pages/procurementManagement/purchaseReturnOrder/add",
|
});
|
};
|
|
const goView = item => {
|
uni.navigateTo({
|
url: `/pages/procurementManagement/purchaseReturnOrder/view?id=${item.id}`,
|
});
|
};
|
|
const getReturnTypeLabel = value => {
|
if (String(value) === "0") return "退货退款";
|
if (String(value) === "1") return "拒收";
|
return "-";
|
};
|
|
const getProjectPhaseLabel = value => {
|
const map = {
|
0: "立项",
|
1: "设计",
|
2: "采购",
|
3: "生产",
|
4: "出货",
|
};
|
const key = String(value);
|
return map[key] || "-";
|
};
|
|
const formatAmount = value => {
|
if (value === null || value === undefined || value === "") return "-";
|
const num = Number(value);
|
if (Number.isNaN(num)) return "-";
|
return num.toFixed(2);
|
};
|
|
const getList = () => {
|
uni.showLoading({ title: "加载中...", mask: true });
|
findPurchaseReturnOrderListPage({
|
...page,
|
no: searchNo.value,
|
})
|
.then(res => {
|
list.value = res?.data?.records || [];
|
})
|
.catch(() => {
|
uni.showToast({ title: "查询失败", icon: "error" });
|
})
|
.finally(() => {
|
uni.hideLoading();
|
});
|
};
|
|
const handleDelete = item => {
|
if (!item?.id) return;
|
uni.showModal({
|
title: "删除提示",
|
content: "确定要删除吗?删除后无法恢复",
|
success: res => {
|
if (!res.confirm) return;
|
uni.showLoading({ title: "删除中...", mask: true });
|
deletePurchaseReturnOrder(item.id)
|
.then(() => {
|
uni.showToast({ title: "删除成功", icon: "success" });
|
getList();
|
})
|
.catch(() => {
|
uni.showToast({ title: "删除失败", icon: "error" });
|
})
|
.finally(() => {
|
uni.hideLoading();
|
});
|
},
|
});
|
};
|
|
onShow(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/styles/procurement-common.scss";
|
</style>
|