From b58f53769f004fb0ba6b5aedf55ef602850c7c97 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 20 九月 2026 15:46:05 +0800
Subject: [PATCH] 天津豹鸣app 1.部署修改

---
 src/pages/sales/deliveryLedger/edit.vue |  385 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 385 insertions(+), 0 deletions(-)

diff --git a/src/pages/sales/deliveryLedger/edit.vue b/src/pages/sales/deliveryLedger/edit.vue
new file mode 100644
index 0000000..ad63b0b
--- /dev/null
+++ b/src/pages/sales/deliveryLedger/edit.vue
@@ -0,0 +1,385 @@
+<template>
+  <view class="account-detail">
+    <PageHeader title="琛ュ厖鍙戣揣淇℃伅"
+                @back="goBack" />
+    <view class="form-container">
+      <up-form ref="formRef"
+               :model="form"
+               :rules="rules"
+               label-width="120"
+               input-align="right"
+               error-message-align="right">
+        <u-cell-group title="鍙戣揣淇℃伅"
+                      class="form-section">
+          <up-form-item label="鍙戣揣绫诲瀷"
+                        prop="type"
+                        required
+                        border-bottom>
+            <FormPicker v-model="form.type"
+                        type="select"
+                        title="閫夋嫨鍙戣揣绫诲瀷"
+                        :options="typeOptions"
+                        placeholder="璇烽�夋嫨鍙戣揣绫诲瀷"
+                        @change="onTypeChange" />
+          </up-form-item>
+          <up-form-item label="鍙戣揣鏃ユ湡"
+                        prop="shippingDate"
+                        required
+                        border-bottom>
+            <FormPicker v-model="form.shippingDate"
+                        type="date"
+                        placeholder="璇烽�夋嫨鍙戣揣鏃ユ湡" />
+          </up-form-item>
+          <up-form-item v-if="form.type === '璐ц溅'"
+                        label="鍙戣揣杞︾墝鍙�"
+                        prop="shippingCarNumber"
+                        required
+                        border-bottom>
+            <up-input v-model="form.shippingCarNumber"
+                      placeholder="璇疯緭鍏ュ彂璐ц溅鐗屽彿"
+                      clearable />
+          </up-form-item>
+          <up-form-item v-if="form.type === '蹇��'"
+                        label="蹇�掑叕鍙�"
+                        prop="expressCompany"
+                        required
+                        border-bottom>
+            <up-input v-model="form.expressCompany"
+                      placeholder="璇疯緭鍏ュ揩閫掑叕鍙�"
+                      clearable />
+          </up-form-item>
+          <up-form-item v-if="form.type === '蹇��'"
+                        label="蹇�掑崟鍙�"
+                        prop="expressNumber">
+            <up-input v-model="form.expressNumber"
+                      placeholder="璇疯緭鍏ュ揩閫掑崟鍙�"
+                      clearable />
+          </up-form-item>
+        </u-cell-group>
+
+        <u-cell-group title="鍗曟嵁涓庡綊妗�"
+                      class="form-section">
+          <up-form-item label="鍙戣揣鍗曟嵁"
+                        prop="shippingDocument"
+                        border-bottom>
+            <up-input v-model="form.shippingDocument"
+                      placeholder="璇疯緭鍏ュ彂璐у崟鎹�"
+                      clearable />
+          </up-form-item>
+          <up-form-item label="鏄惁瀵硅处"
+                        prop="isReconciled"
+                        border-bottom>
+            <up-switch v-model="form.isReconciled"
+                       :active-value="1"
+                       :inactive-value="0" />
+          </up-form-item>
+          <up-form-item v-if="form.isReconciled === 1"
+                        label="瀵硅处鍗曞綊妗�"
+                        prop="statementArchivingStatus"
+                        border-bottom>
+            <up-textarea v-model="form.statementArchivingStatus"
+                         placeholder="璇峰~鍐欏璐﹀崟褰掓。鎯呭喌"
+                         auto-height
+                         maxlength="200" />
+          </up-form-item>
+          <up-form-item label="鏄惁缁撶畻"
+                        prop="isSettled"
+                        border-bottom>
+            <up-switch v-model="form.isSettled"
+                       :active-value="1"
+                       :inactive-value="0" />
+          </up-form-item>
+          <up-form-item v-if="form.isSettled === 1"
+                        label="缁撶畻鍗曞綊妗�"
+                        prop="settlementArchivingStatus"
+                        border-bottom>
+            <up-textarea v-model="form.settlementArchivingStatus"
+                         placeholder="璇峰~鍐欑粨绠楀崟褰掓。鎯呭喌"
+                         auto-height
+                         maxlength="200" />
+          </up-form-item>
+          <up-form-item label="鏄惁宸插紑绁�"
+                        prop="isInvoiced">
+            <up-switch v-model="form.isInvoiced"
+                       :active-value="1"
+                       :inactive-value="0" />
+          </up-form-item>
+        </u-cell-group>
+
+        <u-cell-group title="鍙戣揣鍥剧墖"
+                      class="form-section">
+          <view class="upload-wrap">
+            <CommonUpload v-model="form.deliveryFiles"
+                          accept="image"
+                          :max-count="6" />
+          </view>
+        </u-cell-group>
+      </up-form>
+
+      <u-cell-group title="鍙戣揣浜у搧鏄庣粏"
+                    class="form-section">
+        <view v-if="products.length === 0"
+              class="empty-block">
+          <text>鏆傛棤浜у搧鏄庣粏</text>
+        </view>
+        <view v-for="(row, index) in products"
+              :key="index"
+              class="product-row">
+          <view class="detail-row">
+            <text class="detail-label">浜у搧鍚嶇О</text>
+            <text class="detail-value">{{ row.productName || "-" }}</text>
+          </view>
+          <view class="detail-row">
+            <text class="detail-label">瑙勬牸鍨嬪彿</text>
+            <text class="detail-value">{{ row.specificationModel || "-" }}</text>
+          </view>
+          <view class="detail-row">
+            <text class="detail-label">鎵规鍙�</text>
+            <text class="detail-value">{{ row.batchNo || "-" }}</text>
+          </view>
+          <view class="detail-row">
+            <text class="detail-label">鍙戣揣鏁伴噺</text>
+            <text class="detail-value">
+              {{ row.deliveryQuantity === "" ? "-" : row.deliveryQuantity }}{{ row.unit ? ` ${row.unit}` : "" }}
+            </text>
+          </view>
+        </view>
+      </u-cell-group>
+    </view>
+
+    <FooterButtons :loading="loading"
+                   confirmText="淇濆瓨"
+                   @cancel="goBack"
+                   @confirm="handleSubmit" />
+  </view>
+</template>
+
+<script setup>
+  import { ref } from "vue";
+  import { onLoad } from "@dcloudio/uni-app";
+  import PageHeader from "@/components/PageHeader.vue";
+  import FooterButtons from "@/components/FooterButtons.vue";
+  import FormPicker from "@/components/FormPicker.vue";
+  import CommonUpload from "@/components/CommonUpload.vue";
+  import { formatDateToYMD } from "@/utils/ruoyi";
+  import { loadDetailData } from "@/utils/detailCache";
+  import {
+    resolveDeliveryFiles,
+    resolveDeliveryProducts,
+  } from "@/utils/delivery";
+  import {
+    deductStock,
+    getDeliveryDetail,
+  } from "@/api/salesManagement/deliveryLedger";
+
+  const formRef = ref();
+  const loading = ref(false);
+  const deliveryId = ref("");
+  const products = ref([]);
+
+  const typeOptions = [
+    { name: "璐ц溅", value: "璐ц溅" },
+    { name: "蹇��", value: "蹇��" },
+  ];
+
+  const form = ref({
+    id: undefined,
+    type: "",
+    shippingDate: "",
+    shippingCarNumber: "",
+    expressCompany: "",
+    expressNumber: "",
+    shippingDocument: "",
+    isReconciled: 0,
+    statementArchivingStatus: "",
+    isSettled: 0,
+    settlementArchivingStatus: "",
+    isInvoiced: 0,
+    deliveryFiles: [],
+  });
+
+  // 杞︾墝涓庡揩閫掑叕鍙告寜鍙戣揣绫诲瀷浜岄�変竴蹇呭~
+  const rules = {
+    type: [{ required: true, message: "璇烽�夋嫨鍙戣揣绫诲瀷", trigger: "change" }],
+    shippingDate: [
+      { required: true, message: "璇烽�夋嫨鍙戣揣鏃ユ湡", trigger: "change" },
+    ],
+  };
+
+  const goBack = () => uni.navigateBack();
+
+  const onTypeChange = value => {
+    if (value === "璐ц溅") {
+      form.value.expressCompany = "";
+      form.value.expressNumber = "";
+    } else {
+      form.value.shippingCarNumber = "";
+    }
+  };
+
+  const loadDetail = async () => {
+    let data = null;
+    try {
+      data = await loadDetailData({
+        cacheKey: "deliveryDetail",
+        id: deliveryId.value,
+        fetcher: getDeliveryDetail,
+      });
+    } catch (error) {
+      data = null;
+    }
+    if (!data) {
+      uni.showToast({ title: "鏈壘鍒板彂璐т俊鎭�", icon: "none" });
+      return;
+    }
+
+    form.value = {
+      id: data.id,
+      type: data.type || "",
+      shippingDate: (data.shippingDate || "").slice(0, 10),
+      shippingCarNumber: data.shippingCarNumber || "",
+      expressCompany: data.expressCompany || "",
+      expressNumber: data.expressNumber || "",
+      shippingDocument: data.shippingDocument || "",
+      isReconciled: data.isReconciled ?? 0,
+      statementArchivingStatus: data.statementArchivingStatus || "",
+      isSettled: data.isSettled ?? 0,
+      settlementArchivingStatus: data.settlementArchivingStatus || "",
+      isInvoiced: data.isInvoiced ?? 0,
+      deliveryFiles: resolveDeliveryFiles(data),
+    };
+    products.value = resolveDeliveryProducts(data);
+  };
+
+  const handleSubmit = async () => {
+    const valid = await formRef.value.validate().catch(() => false);
+    if (!valid) return;
+
+    if (form.value.type === "璐ц溅" && !form.value.shippingCarNumber) {
+      uni.showToast({ title: "璇疯緭鍏ュ彂璐ц溅鐗屽彿", icon: "none" });
+      return;
+    }
+    if (form.value.type === "蹇��" && !form.value.expressCompany) {
+      uni.showToast({ title: "璇疯緭鍏ュ揩閫掑叕鍙�", icon: "none" });
+      return;
+    }
+
+    // 闇�姹傚叚锛氬彂璐у彴璐﹁姹傝ˉ鍏呭崟鎹笌瀵硅处/缁撶畻/寮�绁ㄦ儏鍐点��
+    // 鍙傝�冨疄鐜帮紙绠$悊绔級鍙彁浜ゅ墠 7 涓瓧娈碉紝杩欓噷鎸夐渶姹備竴骞舵彁浜わ紝
+    // 鍚庣鑻ユ湭鎺ユ敹杩欏嚑涓瓧娈典細琚拷鐣ワ紝涓嶅奖鍝嶅彂璐т富娴佺▼銆�
+    const payload = {
+      id: form.value.id,
+      type: form.value.type,
+      shippingDate: form.value.shippingDate,
+      shippingCarNumber:
+        form.value.type === "璐ц溅" ? form.value.shippingCarNumber : "",
+      expressCompany:
+        form.value.type === "蹇��" ? form.value.expressCompany : "",
+      expressNumber: form.value.type === "蹇��" ? form.value.expressNumber : "",
+      storageBlobDTOs: (form.value.deliveryFiles || [])
+        .filter(file => file?.url)
+        .map(file => ({ url: file.url, name: file.name || "" })),
+      shippingDocument: form.value.shippingDocument,
+      isReconciled: form.value.isReconciled,
+      statementArchivingStatus:
+        form.value.isReconciled === 1
+          ? form.value.statementArchivingStatus
+          : "",
+      isSettled: form.value.isSettled,
+      settlementArchivingStatus:
+        form.value.isSettled === 1 ? form.value.settlementArchivingStatus : "",
+      isInvoiced: form.value.isInvoiced,
+    };
+
+    loading.value = true;
+    deductStock(payload)
+      .then(() => {
+        uni.showToast({ title: "淇濆瓨鎴愬姛", icon: "success" });
+        setTimeout(() => uni.navigateBack(), 1200);
+      })
+      .catch(() => {
+        uni.showToast({ title: "淇濆瓨澶辫触", icon: "none" });
+      })
+      .finally(() => {
+        loading.value = false;
+      });
+  };
+
+  onLoad(options => {
+    if (options?.id) {
+      deliveryId.value = options.id;
+      form.value.id = options.id;
+      loadDetail();
+    } else {
+      form.value.shippingDate = formatDateToYMD(Date.now());
+    }
+  });
+</script>
+
+<style scoped lang="scss">
+  @import "@/static/scss/form-common.scss";
+
+  .account-detail {
+    min-height: 100vh;
+    background: #f8f9fa;
+    padding-bottom: 100px;
+  }
+
+  .form-container {
+    padding: 12px 12px 0;
+  }
+
+  .form-section {
+    margin-bottom: 12px;
+    border-radius: 12px;
+    overflow: hidden;
+    box-shadow: 0 2px 10px rgba(15, 35, 95, 0.05);
+  }
+
+  .upload-wrap {
+    padding: 12px;
+  }
+
+  .empty-block {
+    padding: 16px;
+    font-size: 14px;
+    color: #909399;
+  }
+
+  .product-row {
+    padding: 12px 16px;
+    border-bottom: 1px solid #f2f4f8;
+  }
+
+  .product-row:last-child {
+    border-bottom: none;
+  }
+
+  .detail-row {
+    display: flex;
+    align-items: flex-start;
+    justify-content: space-between;
+    padding: 4px 0;
+  }
+
+  .detail-label {
+    font-size: 13px;
+    color: #909399;
+  }
+
+  .detail-value {
+    font-size: 13px;
+    color: #333;
+    max-width: 70%;
+    text-align: right;
+    word-break: break-all;
+  }
+
+  :deep(.u-cell-group__title) {
+    padding: 14px 18px 10px !important;
+    font-size: 15px !important;
+    font-weight: 600 !important;
+    color: #22324d !important;
+    background: #f8fbff !important;
+  }
+</style>

--
Gitblit v1.9.3