| | |
| | | </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="请输入车牌号" /> |
| | | <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.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 required">采购员</text> |
| | | <up-input v-model="form.purchaser" placeholder="请输入采购员" /> |
| | | </view> |
| | | </view> |
| | | |
| | |
| | | </view> |
| | | </up-popup> |
| | | |
| | | <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 { computed, reactive, ref } from "vue"; |
| | | import { onLoad } from "@dcloudio/uni-app"; |
| | | import dayjs from "dayjs"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import { createConsumablesIn } from "@/api/consumablesLogistics/consumablesIn.js"; |
| | | import { productModelList } from "@/api/basicData/productModel.js"; |
| | |
| | | productModelName: "", |
| | | unit: "", |
| | | productType: undefined, |
| | | licensePlateNo: "", |
| | | grossWeight: "", |
| | | tareWeight: "", |
| | | netWeight: "", |
| | | weighingDate: "", |
| | | weighingOperator: "", |
| | | qualitity: "", |
| | | purchaser: "", |
| | | remark: "", |
| | | }); |
| | | |
| | |
| | | }); |
| | | const productList = ref([]); |
| | | const productLoading = ref(false); |
| | | |
| | | const showWeighingDatePicker = ref(false); |
| | | const weighingDateValue = ref(Date.now()); |
| | | |
| | | onLoad((options) => { |
| | | type.value = "0"; |
| | |
| | | showProductPopup.value = false; |
| | | }; |
| | | |
| | | 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.productName || !form.productModelId) { |
| | | uni.showToast({ title: "请选择产品", icon: "none" }); |
| | | return; |
| | | } |
| | | if (!form.qualitity || Number(form.qualitity) <= 0) { |
| | | uni.showToast({ title: "请输入数量", icon: "none" }); |
| | | return; |
| | | } |
| | | if (!form.purchaser) { |
| | | uni.showToast({ title: "请输入采购员", icon: "none" }); |
| | | return; |
| | | } |
| | | const payload = { |
| | |
| | | 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, |
| | | qualitity: Number(form.qualitity), |
| | | purchaser: form.purchaser, |
| | | remark: form.remark, |
| | | }; |
| | | createConsumablesIn(payload) |