src/pages/sales/salesAccount/index.vue
@@ -27,7 +27,7 @@
      <view v-for="(item, index) in ledgerList"
            :key="index">
        <view class="ledger-item"
              @click="handleInfo('edit', item)">
              @click="openOut(item)">
          <view class="item-header">
            <view class="item-left">
              <view class="document-icon">
@@ -67,6 +67,13 @@
              <text class="detail-label">签订日期</text>
              <text class="detail-value">{{ item.executionDate }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">发货状态</text>
              <u-tag size="mini"
                     :type="getLedgerShippingTagType(item)">{{
                getLedgerShippingLabel(item)
              }}</u-tag>
            </view>
            <up-divider></up-divider>
            <view class="detail-info">
              <view class="detail-row">
@@ -81,18 +88,33 @@
            <up-divider></up-divider>
            <view class="detail-buttons">
              <u-button class="detail-button"
                      size="small"
                      type="primary"
                      @click="openOut(item)">
              发货状态
            </u-button>
            <u-button class="detail-button"
                      size="small"
                      type="error"
                      plain
                      @click.stop="handleDelete(item)">
              删除
            </u-button>
                        size="small"
                        type="primary"
                        plain
                        :disabled="!canLedgerShip(item)"
                        @click.stop="handleShip(item)">
                发货
              </u-button>
              <!-- <u-button class="detail-button"
                        size="small"
                        type="primary"
                        @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>
@@ -103,23 +125,26 @@
      <text>暂无销售台账数据</text>
    </view>
    <!-- 浮动操作按钮 -->
    <view class="fab-button"
    <!-- <view class="fab-button"
          @click="handleInfo('add')">
      <up-icon name="plus"
               size="24"
               color="#ffffff"></up-icon>
    </view>
    </view> -->
  </view>
</template>
<script setup>
  import { ref } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import { ledgerListPage, delLedger, productList } from "@/api/salesManagement/salesLedger";
  import {
    ledgerListPage,
    delLedger,
    productList,
  } from "@/api/salesManagement/salesLedger";
    hasShippedProducts,
    getLedgerShippingLabel,
    getLedgerShippingTagType,
    canLedgerShip,
    executeSalesLedgerShip,
  } from "@/utils/salesLedgerShip";
  import useUserStore from "@/store/modules/user";
  import PageHeader from "@/components/PageHeader.vue";
  const userStore = useUserStore();
@@ -139,19 +164,7 @@
  // 销售台账数据
  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 handleShip = item => executeSalesLedgerShip(item);
  // 返回上一页
  const goBack = () => {
@@ -198,7 +211,7 @@
    if (hasShippedProducts(products)) {
      uni.showToast({
        title: "已发货/发货完成的销售订单不能删除",
        title: "已发货、部分发货或已有发货记录的销售订单不能删除",
        icon: "none",
      });
      return;
@@ -234,6 +247,7 @@
    try {
      // 设置操作类型
      uni.setStorageSync("operationType", type);
      uni.removeStorageSync("editData");
      // 如果是查看或编辑操作
      if (type !== "add") {