From 2291b7406cdc184abfa1b1986baeb55499771343 Mon Sep 17 00:00:00 2001
From: ZN <zhang_12370@163.com>
Date: 星期一, 16 三月 2026 17:07:15 +0800
Subject: [PATCH] fix(设备管理): 修正添加维护接口的URL路径

---
 src/pages/consumablesLogistics/stockManagement/subtract.vue |  209 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 209 insertions(+), 0 deletions(-)

diff --git a/src/pages/consumablesLogistics/stockManagement/subtract.vue b/src/pages/consumablesLogistics/stockManagement/subtract.vue
new file mode 100644
index 0000000..5e688bf
--- /dev/null
+++ b/src/pages/consumablesLogistics/stockManagement/subtract.vue
@@ -0,0 +1,209 @@
+<template>
+  <view class="subtract-stock-page">
+    <PageHeader title="鍑哄簱" @back="goBack" />
+
+    <scroll-view scroll-y class="content-scroll">
+      <view class="form-section">
+        <view class="section-title">搴撳瓨淇℃伅</view>
+        <view class="info-row">
+          <text class="label">浜у搧澶х被</text>
+          <text class="value">{{ stockRecord.productName }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">瑙勬牸鍨嬪彿</text>
+          <text class="value">{{ stockRecord.model }}</text>
+        </view>
+        <view class="info-row">
+          <text class="label">鍙敤搴撳瓨</text>
+          <text class="value highlight">{{ stockRecord.unLockedQuantity }}</text>
+        </view>
+      </view>
+
+      <view class="form-section">
+        <view class="section-title">鍑哄簱淇℃伅</view>
+        <view class="form-row">
+          <text class="form-label required">鍑哄簱鏁伴噺</text>
+          <up-input v-model="form.stockOutNum" type="number" :placeholder="'鏈�澶�' + stockRecord.unLockedQuantity" />
+        </view>
+        <view class="form-row" v-if="isQualified">
+          <text class="form-label">杞︾墝鍙�</text>
+          <up-input v-model="form.licensePlateNo" placeholder="璇疯緭鍏ヨ溅鐗屽彿" />
+        </view>
+        <view class="form-row" v-if="isQualified">
+          <text class="form-label">姣涢噸(鍚�)</text>
+          <up-input v-model="form.grossWeight" type="number" placeholder="璇疯緭鍏ユ瘺閲�" />
+        </view>
+        <view class="form-row" v-if="isQualified">
+          <text class="form-label">鐨噸(鍚�)</text>
+          <up-input v-model="form.tareWeight" type="number" placeholder="璇疯緭鍏ョ毊閲�" />
+        </view>
+        <view class="form-row" v-if="isQualified">
+          <text class="form-label">鍑�閲�(鍚�)</text>
+          <up-input v-model="form.netWeight" type="number" disabled placeholder="鑷姩璁$畻" />
+        </view>
+        <view class="form-row" v-if="isQualified">
+          <text class="form-label">杩囩鏃ユ湡</text>
+          <view class="selector-trigger" @click="openWeighingDatePicker">
+            <text class="selector-text" :class="{ placeholder: !form.weighingDate }">
+              {{ form.weighingDate || "璇烽�夋嫨杩囩鏃ユ湡" }}
+            </text>
+            <up-icon name="calendar" size="16" color="#999"></up-icon>
+          </view>
+        </view>
+        <view class="form-row" v-if="isQualified">
+          <text class="form-label">杩囩鍛�</text>
+          <up-input v-model="form.weighingOperator" placeholder="璇疯緭鍏ヨ繃纾呭憳" />
+        </view>
+        <view class="form-row">
+          <text class="form-label">澶囨敞</text>
+          <up-input v-model="form.remark" type="textarea" placeholder="閫夊~" />
+        </view>
+      </view>
+    </scroll-view>
+
+    <view class="bottom-bar">
+      <view class="btn-submit" @click="handleSubmit">鎻愪氦</view>
+    </view>
+
+    <up-popup :show="showWeighingDatePicker" mode="bottom" @close="showWeighingDatePicker = false">
+      <up-datetime-picker
+        :show="true"
+        v-model="weighingDateValue"
+        mode="datetime"
+        @confirm="onWeighingDateConfirm"
+        @cancel="showWeighingDatePicker = false"
+      />
+    </up-popup>
+  </view>
+</template>
+
+<script setup>
+import { computed, reactive, ref, watch } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+import dayjs from "dayjs";
+import PageHeader from "@/components/PageHeader.vue";
+import { subtractConsumablesIn } from "@/api/consumablesLogistics/consumablesIn.js";
+import { subtractConsumablesUnInventory } from "@/api/consumablesLogistics/consumablesUninventory.js";
+
+const type = ref("0");
+const isQualified = computed(() => type.value === "0");
+
+const stockRecord = reactive({
+  id: "",
+  productName: "",
+  model: "",
+  unLockedQuantity: 0,
+});
+
+const form = reactive({
+  stockOutNum: "",
+  licensePlateNo: "",
+  grossWeight: "",
+  tareWeight: "",
+  netWeight: "",
+  weighingDate: "",
+  weighingOperator: "",
+  remark: "",
+});
+
+const showWeighingDatePicker = ref(false);
+const weighingDateValue = ref(Date.now());
+
+onLoad((options) => {
+  if (options && options.type != null) {
+    type.value = options.type;
+  }
+  const cached = uni.getStorageSync("stockSubtractRecord");
+  if (cached) {
+    try {
+      const payload = typeof cached === "string" ? JSON.parse(cached) : cached;
+      const item = payload && payload.item != null ? payload.item : payload;
+      stockRecord.id = item.id;
+      stockRecord.productName = item.productName;
+      stockRecord.model = item.model;
+      stockRecord.unLockedQuantity = item.unLockedQuantity || 0;
+      uni.removeStorageSync("stockSubtractRecord");
+    } catch (e) {
+      uni.removeStorageSync("stockSubtractRecord");
+    }
+  }
+});
+
+const computeNetWeight = () => {
+  const gross = Number(form.grossWeight);
+  const tare = Number(form.tareWeight);
+  if (!isNaN(gross) && !isNaN(tare)) {
+    const net = Number((gross - tare).toFixed(2));
+    form.netWeight = net > 0 ? net : 0;
+  } else {
+    form.netWeight = "";
+  }
+};
+
+watch(
+  () => [form.grossWeight, form.tareWeight],
+  () => computeNetWeight()
+);
+
+const openWeighingDatePicker = () => {
+  weighingDateValue.value = form.weighingDate
+    ? dayjs(form.weighingDate, "YYYY-MM-DD HH:mm:ss").valueOf()
+    : Date.now();
+  showWeighingDatePicker.value = true;
+};
+
+const onWeighingDateConfirm = (e) => {
+  const ts = e?.value ?? weighingDateValue.value;
+  form.weighingDate = dayjs(ts).format("YYYY-MM-DD HH:mm:ss");
+  showWeighingDatePicker.value = false;
+};
+
+const handleSubmit = () => {
+  const outNum = Number(form.stockOutNum);
+  if (!outNum || outNum <= 0 || outNum > Number(stockRecord.unLockedQuantity)) {
+    uni.showToast({ title: `璇疯緭鍏� 1~${stockRecord.unLockedQuantity} 涔嬮棿鐨勬暟閲廯, icon: "none" });
+    return;
+  }
+  const api = isQualified.value ? subtractConsumablesIn : subtractConsumablesUnInventory;
+  api({
+    id: stockRecord.id,
+    stockOutNum: outNum,
+    licensePlateNo: form.licensePlateNo,
+    grossWeight: form.grossWeight,
+    tareWeight: form.tareWeight,
+    netWeight: form.netWeight,
+    weighingDate: form.weighingDate,
+    weighingOperator: form.weighingOperator,
+    remark: form.remark,
+  })
+    .then(() => {
+      uni.showToast({ title: "鍑哄簱鎴愬姛", icon: "success" });
+      setTimeout(() => uni.navigateBack(), 400);
+    })
+    .catch(() => {
+      uni.showToast({ title: "鍑哄簱澶辫触", icon: "none" });
+    });
+};
+
+const goBack = () => uni.navigateBack();
+</script>
+
+<style lang="scss" scoped>
+.subtract-stock-page { min-height: 100vh; background: #f5f5f5; padding-bottom: 100rpx; }
+.content-scroll { height: calc(100vh - 100rpx); }
+.form-section { background: #fff; margin: 24rpx; padding: 24rpx; border-radius: 16rpx; }
+.section-title { font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; }
+.info-row { display: flex; justify-content: space-between; padding: 12rpx 0; font-size: 26rpx; }
+.info-row .label { color: #666; }
+.info-row .value { color: #333; }
+.info-row .value.highlight { color: #2979ff; font-weight: 500; }
+.form-row { margin-bottom: 24rpx; }
+.form-label { display: block; font-size: 26rpx; color: #666; margin-bottom: 12rpx; }
+.form-label.required:before { content: "*"; color: #f56c6c; margin-right: 6rpx; }
+.selector-trigger { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #f5f5f5; border-radius: 12rpx; }
+.selector-text { font-size: 28rpx; color: #333; }
+.selector-text.placeholder { color: #999; }
+.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04); }
+.btn-submit { height: 88rpx; border-radius: 999rpx; background: #2979ff; color: #fff; font-size: 30rpx; display: flex; align-items: center; justify-content: center; }
+</style>
+

--
Gitblit v1.9.3