| | |
| | | v-if="ledgerList.length > 0"> |
| | | <view v-for="(item, index) in ledgerList" |
| | | :key="index"> |
| | | <view class="ledger-item" |
| | | @click="handleInfo('edit', item)"> |
| | | <view class="ledger-item"> |
| | | <view class="item-header"> |
| | | <view class="item-left"> |
| | | <view class="document-icon"> |
| | |
| | | </view> |
| | | </view> |
| | | <up-divider></up-divider> |
| | | <u-button class="detail-button" |
| | | <view class="detail-buttons"> |
| | | <u-button class="detail-button" |
| | | size="small" |
| | | type="primary" |
| | | @click="openOut(item)"> |
| | | @click.stop="handleInfo('edit', item)"> |
| | | 编辑 |
| | | </u-button> |
| | | <u-button class="detail-button" |
| | | size="small" |
| | | type="primary" |
| | | plain |
| | | @click.stop="openOut(item)"> |
| | | 发货状态 |
| | | </u-button> |
| | | <u-button class="detail-button" |
| | | size="small" |
| | | type="error" |
| | | plain |
| | | @click.stop="handleDelete(item)"> |
| | | 删除 |
| | | </u-button> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | <script setup> |
| | | import { ref } from "vue"; |
| | | import { onShow } from "@dcloudio/uni-app"; |
| | | import { ledgerListPage } from "@/api/salesManagement/salesLedger"; |
| | | import { |
| | | ledgerListPage, |
| | | delLedger, |
| | | productList, |
| | | } from "@/api/salesManagement/salesLedger"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | const userStore = useUserStore(); |
| | |
| | | |
| | | // 销售台账数据 |
| | | const ledgerList = ref([]); |
| | | |
| | | // 判断是否存在已发货/发货完成的产品 |
| | | const hasShippedProducts = products => { |
| | | if (!products || products.length === 0) return false; |
| | | return products.some(p => { |
| | | const statusStr = (p.shippingStatus ?? "").toString(); |
| | | // 包含“发货”或有发货日期/车牌号视为已发货 |
| | | return ( |
| | | statusStr.includes("发货") || |
| | | !!p.shippingDate || |
| | | !!p.shippingCarNumber |
| | | ); |
| | | }); |
| | | }; |
| | | |
| | | // 返回上一页 |
| | | const goBack = () => { |
| | |
| | | uni.setStorageSync("outData", JSON.stringify(item)); |
| | | uni.navigateTo({ |
| | | url: "/pages/sales/salesAccount/out", |
| | | }); |
| | | }; |
| | | |
| | | // 删除单条销售台账 |
| | | const handleDelete = async row => { |
| | | if (!row || !row.id) return; |
| | | |
| | | // 获取产品列表,用于判断是否已发货 |
| | | let products = row.children && row.children.length > 0 ? row.children : null; |
| | | if (!products) { |
| | | try { |
| | | const res = await productList({ salesLedgerId: row.id, type: 1 }); |
| | | products = res.data || res.records || []; |
| | | } catch (e) { |
| | | products = []; |
| | | } |
| | | } |
| | | |
| | | if (hasShippedProducts(products)) { |
| | | uni.showToast({ |
| | | title: "已发货/发货完成的销售订单不能删除", |
| | | icon: "none", |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | uni.showModal({ |
| | | title: "删除确认", |
| | | content: "选中的内容将被删除,是否确认删除?", |
| | | success: async res => { |
| | | if (res.confirm) { |
| | | try { |
| | | showLoadingToast("处理中..."); |
| | | await delLedger([row.id]); |
| | | closeToast(); |
| | | uni.showToast({ |
| | | title: "删除成功", |
| | | icon: "success", |
| | | }); |
| | | getList(); |
| | | } catch (e) { |
| | | closeToast(); |
| | | uni.showToast({ |
| | | title: "删除失败,请重试", |
| | | icon: "none", |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | }); |
| | | }; |
| | | // 处理台账信息操作(查看/编辑/新增) |
| | |
| | | |
| | | <style scoped lang="scss"> |
| | | @import "@/styles/sales-common.scss"; |
| | | .detail-buttons { |
| | | display: flex; |
| | | gap: 10px; |
| | | justify-content: space-between; |
| | | } |
| | | </style> |