From 4e950b3724519ddf165f33be9988098daf979d33 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 27 三月 2026 09:58:26 +0800
Subject: [PATCH] fix: 检测化验样式调整
---
src/pages/inventoryManagement/stockManagement/subtract.vue | 177 +++++++++++++++++++++++++----------------------------------
1 files changed, 75 insertions(+), 102 deletions(-)
diff --git a/src/pages/inventoryManagement/stockManagement/subtract.vue b/src/pages/inventoryManagement/stockManagement/subtract.vue
index 2452e04..6da92d4 100644
--- a/src/pages/inventoryManagement/stockManagement/subtract.vue
+++ b/src/pages/inventoryManagement/stockManagement/subtract.vue
@@ -14,53 +14,26 @@
</view>
<view class="form-row">
<text class="form-label">鍗曚綅</text>
- <up-input v-model="form.unit" disabled />
+ <up-radio-group v-model="form.unit" class="unit-radio-group">
+ <up-radio
+ v-for="opt in unitOptions"
+ :key="opt.value"
+ :label="opt.label"
+ :name="opt.value"
+ ></up-radio>
+ </up-radio-group>
</view>
</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>
+ <text class="form-label">鍑哄簱鏁伴噺</text>
<up-input
- v-model="form.grossWeight"
+ v-model="form.stockOutNum"
type="number"
- placeholder="璇疯緭鍏ユ瘺閲�"
+ :placeholder="'鏈�澶�' + maxOutQuantity"
/>
- </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="璇疯緭鍏ヨ繃纾呭憳" />
</view>
<view class="form-row">
<text class="form-label">澶囨敞</text>
@@ -72,24 +45,12 @@
<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, computed } 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'
@@ -102,7 +63,7 @@
parentName: '',
productName: '',
model: '',
- unit: '',
+ unit: '鍚�',
qualitity: undefined,
lockedQuantity: undefined,
unLockedQuantity: undefined,
@@ -113,24 +74,50 @@
createTime: '',
updateTime: '',
version: undefined,
- // 鍑哄簱/杩囩淇℃伅
- licensePlateNo: '',
- grossWeight: '',
- tareWeight: '',
- netWeight: '',
- weighingDate: '',
- weighingOperator: '',
+ // 鍑哄簱淇℃伅
+ stockOutNum: '',
remark: ''
})
const type = ref('0') // 鍥哄畾鍚堟牸搴撳瓨
-const showWeighingDatePicker = ref(false)
-const weighingDateValue = ref(Date.now())
+const unitOptions = [
+ { label: '鍚�', value: '鍚�' },
+ { label: '鍏枻', value: '鍏枻' }
+]
-const maxAllowedNetWeight = computed(() => {
- const v = form.unLockedQuantity ?? form.qualitity
- const n = Number(v)
- return !isNaN(n) ? n : 0
+// 璁板綍鐨勫師濮嬪崟浣嶏紝鐢ㄤ簬鍚�/鍏枻鎹㈢畻鏍¢獙鈥滄渶澶у彲鍑哄簱鏁伴噺鈥�
+const recordUnit = ref('')
+
+const normalizeUnit = (u) => {
+ if (!u) return ''
+ const s = String(u).trim()
+ if (s === '鍚�' || s === 't' || s === 'ton' || s === 'tonne') return '鍚�'
+ if (
+ s === '鍏枻' ||
+ s === 'kg' ||
+ s === 'kilogram' ||
+ s === '鍗冨厠' ||
+ s === 'kilograms'
+ )
+ return '鍏枻'
+ return s
+}
+
+const convertByUnit = (value, fromUnit, toUnit) => {
+ if (value === '' || value === undefined || value === null) return 0
+ const num = Number(value)
+ if (Number.isNaN(num)) return 0
+ if (fromUnit === toUnit) return num
+ // 榛樿鍙鐞嗗惃<->鍏枻锛涘叾浠栧崟浣嶇洿鎺ュ師鏍疯繑鍥�
+ if (fromUnit === '鍚�' && toUnit === '鍏枻') return num * 1000
+ if (fromUnit === '鍏枻' && toUnit === '鍚�') return num / 1000
+ return num
+}
+
+const maxOutQuantity = computed(() => {
+ const baseMax = Number(form.unLockedQuantity ?? 0)
+ if (!recordUnit.value || !form.unit) return baseMax
+ return convertByUnit(baseMax, recordUnit.value, form.unit)
})
onLoad((options) => {
@@ -142,6 +129,9 @@
const item = payload && payload.item ? payload.item : payload
// 灏嗗垪琛ㄨ褰曠殑瀹屾暣瀛楁鎷疯礉鍒拌〃鍗曚腑锛屼繚鎸佷笌 PC 绔� Subtract.vue 涓�鑷�
Object.assign(form, item)
+ const normalizedUnit = normalizeUnit(form.unit)
+ form.unit = normalizedUnit === '鍚�' || normalizedUnit === '鍏枻' ? normalizedUnit : '鍚�'
+ recordUnit.value = form.unit
uni.removeStorageSync('stockSubtractRecord')
} catch (e) {
uni.removeStorageSync('stockSubtractRecord')
@@ -149,49 +139,26 @@
}
})
-// 鍑�閲� = 姣涢噸 - 鐨噸
-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 net = Number(form.netWeight)
- if (!isNaN(net) && net > 0 && maxAllowedNetWeight.value > 0 && net > maxAllowedNetWeight.value) {
- uni.showToast({ title: `鍑�閲嶄笉鑳藉ぇ浜庡彲鐢ㄥ簱瀛� ${maxAllowedNetWeight.value}`, icon: 'none' })
+ const normalizedUnit = normalizeUnit(form.unit)
+ form.unit = normalizedUnit === '鍚�' || normalizedUnit === '鍏枻' ? normalizedUnit : '鍚�'
+
+ const outNum = Number(form.stockOutNum)
+ const max = Number(maxOutQuantity.value ?? 0)
+ if (!outNum || outNum <= 0 || outNum > max) {
+ uni.showToast({ title: `璇疯緭鍏� 1~${max} 涔嬮棿鐨勬暟閲廯, icon: 'none' })
return
}
- const payload = { ...form }
+ const payload = {
+ id: form.id,
+ stockOutNum: outNum,
+ remark: form.remark,
+ unit: form.unit
+ }
subtractStockInventory(payload)
.then(() => {
uni.showToast({ title: '鍑哄簱鎴愬姛', icon: 'success' })
@@ -271,5 +238,11 @@
align-items: center;
justify-content: center;
}
+.unit-radio-group {
+ display: flex;
+ gap: 24rpx;
+ align-items: center;
+ flex-wrap: wrap;
+}
</style>
--
Gitblit v1.9.3