| | |
| | | </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> |
| | |
| | | <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 || '请选择过磅日期' }} |
| | |
| | | </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="选填" /> |
| | |
| | | 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({ |
| | |
| | | productModelName: '', |
| | | unit: '', |
| | | productType: undefined, |
| | | parentName: '', |
| | | licensePlateNo: '', |
| | | grossWeight: '', |
| | | tareWeight: '', |
| | |
| | | remark: '' |
| | | }) |
| | | |
| | | const type = ref('0') // 0 合格库存,1 不合格库存 |
| | | const isQualified = computed(() => type.value === '0') |
| | | const type = ref('0') // 固定合格库存 |
| | | const isQualified = computed(() => true) |
| | | const isFinishedProduct = computed(() => form.parentName === '成品') |
| | | |
| | | const showProductPopup = ref(false) |
| | | const productQuery = reactive({ |
| | |
| | | const weighingDateValue = ref(Date.now()) |
| | | |
| | | onLoad((options) => { |
| | | if (options && options.type != null) { |
| | | type.value = options.type |
| | | } |
| | | type.value = '0' |
| | | }) |
| | | |
| | | const openProductSelector = () => { |
| | |
| | | }) |
| | | .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 |
| | |
| | | } |
| | | |
| | | 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 |
| | | 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 |
| | | } |
| | | |
| | |
| | | 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(() => { |