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/add.vue | 166 ++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 127 insertions(+), 39 deletions(-)
diff --git a/src/pages/inventoryManagement/stockManagement/add.vue b/src/pages/inventoryManagement/stockManagement/add.vue
index 6c69d85..ae1329c 100644
--- a/src/pages/inventoryManagement/stockManagement/add.vue
+++ b/src/pages/inventoryManagement/stockManagement/add.vue
@@ -19,44 +19,59 @@
</view>
<view class="form-row">
<text class="form-label">鍗曚綅</text>
- <up-input v-model="form.unit" disabled placeholder="璇烽�夋嫨浜у搧鍚庤嚜鍔ㄥ甫鍑�" />
+ <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 v-if="isQualified" class="form-section">
+ <!-- 鎴愬搧锛氬彧闇�瑕佹暟閲� -->
+ <view v-if="isFinishedProduct" class="form-section">
+ <view class="form-row">
+ <text class="form-label required">鏁伴噺</text>
+ <up-input v-model="form.qualitity" type="number" placeholder="璇疯緭鍏ユ暟閲�" />
+ </view>
+ </view>
+
+ <!-- 鍘熸潗鏂欙細杩囩鐩稿叧瀛楁 -->
+ <view v-else class="form-section">
<view class="section-title">杩囩淇℃伅</view>
<view class="form-row">
- <text class="form-label">杞︾墝鍙�</text>
+ <text class="form-label required">杞︾墝鍙�</text>
<up-input v-model="form.licensePlateNo" placeholder="璇疯緭鍏ヨ溅鐗屽彿" />
</view>
<view class="form-row">
- <text class="form-label">姣涢噸(鍚�)</text>
+ <text class="form-label required">姣涢噸</text>
<up-input
v-model="form.grossWeight"
- type="number"
+ type="digit"
placeholder="璇疯緭鍏ユ瘺閲�"
/>
</view>
<view class="form-row">
- <text class="form-label">鐨噸(鍚�)</text>
+ <text class="form-label required">鐨噸</text>
<up-input
v-model="form.tareWeight"
- type="number"
+ type="digit"
placeholder="璇疯緭鍏ョ毊閲�"
/>
</view>
<view class="form-row">
- <text class="form-label">鍑�閲�(鍚�)</text>
+ <text class="form-label">鍑�閲�</text>
<up-input
v-model="form.netWeight"
- type="number"
+ type="digit"
disabled
placeholder="鑷姩璁$畻"
/>
</view>
<view class="form-row">
- <text class="form-label">杩囩鏃ユ湡</text>
+ <text class="form-label required">杩囩鏃ユ湡</text>
<view class="selector-trigger" @click="openWeighingDatePicker">
<text class="selector-text" :class="{ placeholder: !form.weighingDate }">
{{ form.weighingDate || '璇烽�夋嫨杩囩鏃ユ湡' }}
@@ -65,16 +80,12 @@
</view>
</view>
<view class="form-row">
- <text class="form-label">杩囩鍛�</text>
+ <text class="form-label required">杩囩鍛�</text>
<up-input v-model="form.weighingOperator" placeholder="璇疯緭鍏ヨ繃纾呭憳" />
</view>
</view>
<view class="form-section">
- <!-- <view class="form-row">
- <text class="form-label required">鏁伴噺</text>
- <up-input v-model="form.qualitity" type="number" placeholder="璇疯緭鍏ユ暟閲�" />
- </view> -->
<view class="form-row">
<text class="form-label">澶囨敞</text>
<up-input v-model="form.remark" type="textarea" placeholder="閫夊~" />
@@ -145,7 +156,6 @@
import dayjs from 'dayjs'
import PageHeader from '@/components/PageHeader.vue'
import { createStockInventory } from '@/api/inventoryManagement/stockInventory.js'
-import { createStockUnInventory } from '@/api/inventoryManagement/stockUninventory.js'
import { productModelList } from '@/api/basicData/productModel.js'
const form = reactive({
@@ -153,20 +163,42 @@
productModelId: undefined,
productName: '',
productModelName: '',
- unit: '',
+ unit: '鍚�',
productType: undefined,
+ parentName: '',
licensePlateNo: '',
grossWeight: '',
tareWeight: '',
netWeight: '',
- weighingDate: '',
+ weighingDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
weighingOperator: '',
qualitity: '',
remark: ''
})
-const type = ref('0') // 0 鍚堟牸搴撳瓨锛�1 涓嶅悎鏍煎簱瀛�
-const isQualified = computed(() => type.value === '0')
+const unitOptions = [
+ { label: '鍚�', value: '鍚�' },
+ { label: '鍏枻', value: '鍏枻' }
+]
+
+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 type = ref('0') // 鍥哄畾鍚堟牸搴撳瓨
+const isQualified = computed(() => true)
+const isFinishedProduct = computed(() => form.parentName === '鎴愬搧')
const showProductPopup = ref(false)
const productQuery = reactive({
@@ -180,9 +212,7 @@
const weighingDateValue = ref(Date.now())
onLoad((options) => {
- if (options && options.type != null) {
- type.value = options.type
- }
+ type.value = '0'
})
const openProductSelector = () => {
@@ -202,7 +232,12 @@
})
.then(res => {
const data = res?.records || res?.data?.records || []
- productList.value = Array.isArray(data) ? data : []
+ const list = Array.isArray(data) ? data : []
+ // 杩囨护鑰楁潗锛氳�楁潗涓嶅厑璁稿湪鈥滀骇鍝佸簱瀛樷�濆叆搴�
+ productList.value = list.filter(item => {
+ const parentName = item?.parentName || item?.parent?.name || ''
+ return parentName !== '鑰楁潗'
+ })
})
.finally(() => {
productLoading.value = false
@@ -210,12 +245,31 @@
}
const selectProduct = (item) => {
+ const parentName = item?.parentName || item?.parent?.name || ''
+ if (parentName === '鑰楁潗') {
+ uni.showToast({ title: '鑰楁潗璇峰埌鑰楁潗搴撳瓨鍏ュ簱', icon: 'none' })
+ return
+ }
form.productId = item.productId || item.id
form.productModelId = item.id
form.productName = item.productName
form.productModelName = item.model
- form.unit = item.unit
+ const normalizedUnit = normalizeUnit(item.unit)
+ form.unit = normalizedUnit === '鍚�' || normalizedUnit === '鍏枻' ? normalizedUnit : '鍚�'
form.productType = item.productType
+ form.parentName = parentName
+
+ // 鍒囨崲浜у搧鍚庯紝鎸夌被鍨嬫竻鐞嗘棤鍏冲瓧娈�
+ if (parentName === '鎴愬搧') {
+ form.licensePlateNo = ''
+ form.grossWeight = ''
+ form.tareWeight = ''
+ form.netWeight = ''
+ form.weighingDate = ''
+ form.weighingOperator = ''
+ } else {
+ form.qualitity = ''
+ }
showProductPopup.value = false
}
@@ -257,27 +311,55 @@
uni.showToast({ title: '璇烽�夋嫨浜у搧', icon: 'none' })
return
}
- // if (!form.qualitity || Number(form.qualitity) <= 0) {
- // uni.showToast({ title: '璇疯緭鍏ユ暟閲�', icon: 'none' })
- // return
- // }
- const payload = {
+ if (isFinishedProduct.value) {
+ if (!form.qualitity || Number(form.qualitity) <= 0) {
+ uni.showToast({ title: '璇疯緭鍏ユ暟閲�', icon: 'none' })
+ return
+ }
+ } else {
+ if (!form.licensePlateNo) {
+ uni.showToast({ title: '璇疯緭鍏ヨ溅鐗屽彿', icon: 'none' })
+ return
+ }
+ if (!form.grossWeight || Number(form.grossWeight) <= 0) {
+ uni.showToast({ title: '璇疯緭鍏ユ瘺閲�', icon: 'none' })
+ return
+ }
+ if (!form.tareWeight || Number(form.tareWeight) <= 0) {
+ uni.showToast({ title: '璇疯緭鍏ョ毊閲�', icon: 'none' })
+ return
+ }
+ if (!form.weighingDate) {
+ uni.showToast({ title: '璇烽�夋嫨杩囩鏃ユ湡', icon: 'none' })
+ return
+ }
+ if (!form.weighingOperator) {
+ uni.showToast({ title: '璇疯緭鍏ヨ繃纾呭憳', icon: 'none' })
+ return
+ }
+ }
+
+ const base = {
productId: form.productId,
productModelId: form.productModelId,
productName: form.productName,
productModelName: form.productModelName,
unit: form.unit,
productType: form.productType,
- licensePlateNo: form.licensePlateNo,
- grossWeight: form.grossWeight,
- tareWeight: form.tareWeight,
- netWeight: form.netWeight,
- weighingDate: form.weighingDate,
- weighingOperator: form.weighingOperator,
remark: form.remark
}
- const api = isQualified.value ? createStockInventory : createStockUnInventory
- api(payload)
+ const payload = isFinishedProduct.value
+ ? { ...base, qualitity: Number(form.qualitity) }
+ : {
+ ...base,
+ licensePlateNo: form.licensePlateNo,
+ grossWeight: form.grossWeight,
+ tareWeight: form.tareWeight,
+ netWeight: form.netWeight,
+ weighingDate: form.weighingDate,
+ weighingOperator: form.weighingOperator
+ }
+ createStockInventory(payload)
.then(() => {
uni.showToast({ title: '鏂板鎴愬姛', icon: 'success' })
setTimeout(() => {
@@ -416,6 +498,12 @@
font-size: 24rpx;
color: #666;
}
+.unit-radio-group {
+ display: flex;
+ gap: 24rpx;
+ align-items: center;
+ flex-wrap: wrap;
+}
.no-data {
text-align: center;
padding: 40rpx 0;
--
Gitblit v1.9.3