From a4fcad66822cfc97858a1e460c5585e577ec2551 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 24 三月 2026 12:21:07 +0800
Subject: [PATCH] fix: 质量管理可编辑
---
src/pages/inventoryManagement/stockManagement/subtract.vue | 123 ++++++----------------------------------
1 files changed, 20 insertions(+), 103 deletions(-)
diff --git a/src/pages/inventoryManagement/stockManagement/subtract.vue b/src/pages/inventoryManagement/stockManagement/subtract.vue
index 4970275..7fb85e1 100644
--- a/src/pages/inventoryManagement/stockManagement/subtract.vue
+++ b/src/pages/inventoryManagement/stockManagement/subtract.vue
@@ -19,48 +19,10 @@
</view>
<view class="form-section">
- <view class="section-title">鍑哄簱/杩囩淇℃伅</view>
+ <view class="section-title">鍑哄簱淇℃伅</view>
<view class="form-row">
- <text class="form-label">杞︾墝鍙�</text>
- <up-input v-model="form.licensePlateNo" placeholder="璇疯緭鍏ヨ溅鐗屽彿" />
- </view>
- <view class="form-row">
- <text class="form-label">姣涢噸(鍚�)</text>
- <up-input
- v-model="form.grossWeight"
- type="number"
- placeholder="璇疯緭鍏ユ瘺閲�"
- />
- </view>
- <view class="form-row">
- <text class="form-label">鐨噸(鍚�)</text>
- <up-input
- v-model="form.tareWeight"
- type="number"
- placeholder="璇疯緭鍏ョ毊閲�"
- />
- </view>
- <view class="form-row">
- <text class="form-label">鍑�閲�(鍚�)</text>
- <up-input
- v-model="form.netWeight"
- type="number"
- disabled
- placeholder="鑷姩璁$畻"
- />
- </view>
- <view class="form-row">
- <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">
- <text class="form-label">杩囩鍛�</text>
- <up-input v-model="form.weighingOperator" placeholder="璇疯緭鍏ヨ繃纾呭憳" />
+ <text class="form-label">鍑哄簱鏁伴噺</text>
+ <up-input v-model="form.stockOutNum" type="number" :placeholder="'鏈�澶�' + (form.unLockedQuantity ?? 0)" />
</view>
<view class="form-row">
<text class="form-label">澶囨敞</text>
@@ -72,27 +34,14 @@
<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 { ref, reactive, watch } from 'vue'
+import { ref, reactive, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
-import dayjs from 'dayjs'
import PageHeader from '@/components/PageHeader.vue'
import { subtractStockInventory } from '@/api/inventoryManagement/stockInventory.js'
-import { subtractStockUnInventory } from '@/api/inventoryManagement/stockUninventory.js'
const form = reactive({
id: undefined,
@@ -114,24 +63,15 @@
createTime: '',
updateTime: '',
version: undefined,
- // 鍑哄簱/杩囩淇℃伅
- licensePlateNo: '',
- grossWeight: '',
- tareWeight: '',
- netWeight: '',
- weighingDate: '',
- weighingOperator: '',
+ // 鍑哄簱淇℃伅
+ stockOutNum: '',
remark: ''
})
-const type = ref('0') // 0 鍚堟牸搴撳瓨锛�1 涓嶅悎鏍煎簱瀛�
-const showWeighingDatePicker = ref(false)
-const weighingDateValue = ref(Date.now())
+const type = ref('0') // 鍥哄畾鍚堟牸搴撳瓨
onLoad((options) => {
- if (options && options.type != null) {
- type.value = options.type
- }
+ type.value = '0'
const cached = uni.getStorageSync('stockSubtractRecord')
if (cached) {
try {
@@ -146,46 +86,23 @@
}
})
-// 鍑�閲� = 姣涢噸 - 鐨噸
-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 = () => {
if (!form.id) {
uni.showToast({ title: '璁板綍淇℃伅缂哄け锛屾棤娉曞嚭搴�', icon: 'none' })
return
}
- const payload = { ...form }
- const api = type.value === '0' ? subtractStockInventory : subtractStockUnInventory
- api(payload)
+ const outNum = Number(form.stockOutNum)
+ const max = Number(form.unLockedQuantity ?? 0)
+ if (!outNum || outNum <= 0 || outNum > max) {
+ uni.showToast({ title: `璇疯緭鍏� 1~${max} 涔嬮棿鐨勬暟閲廯, icon: 'none' })
+ return
+ }
+ const payload = {
+ id: form.id,
+ stockOutNum: outNum,
+ remark: form.remark
+ }
+ subtractStockInventory(payload)
.then(() => {
uni.showToast({ title: '鍑哄簱鎴愬姛', icon: 'success' })
setTimeout(() => {
--
Gitblit v1.9.3