381 lines
11 KiB
Vue
381 lines
11 KiB
Vue
<template>
|
|
<!-- 入库 -->
|
|
<view class="common-box">
|
|
<uni-card>
|
|
<ScanInput
|
|
@scanConfirm="scanConfirm"
|
|
placeholder="请扫标签,操作入库"
|
|
></ScanInput>
|
|
</uni-card>
|
|
|
|
<view class="form-box">
|
|
<uni-section title="填写入库单信息" type="line">
|
|
<view class="example">
|
|
<uni-forms
|
|
ref="baseForm"
|
|
:modelValue="baseFormData"
|
|
:rules="valiFormData"
|
|
label-position="top"
|
|
label-width="120"
|
|
>
|
|
<uni-forms-item label="物料编码" name="materialCode" required>
|
|
<uni-easyinput
|
|
v-model="baseFormData.materialName"
|
|
placeholder="请输入物料编码"
|
|
:disabled="true"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="物料名称" name="materialName">
|
|
<uni-easyinput
|
|
v-model="baseFormData.materialName"
|
|
placeholder="请输入物料名称"
|
|
:disabled="true"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="标号" name="type">
|
|
<uni-easyinput
|
|
v-model="baseFormData.type"
|
|
placeholder="请输入标号"
|
|
:disabled="true"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="供应商名称" name="supplierName">
|
|
<uni-easyinput
|
|
v-model="baseFormData.supplierName"
|
|
placeholder="请输入供应商名称"
|
|
:disabled="true"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="库位编码" name="locationCode" required>
|
|
<uni-combox
|
|
:candidates="locationList.map((item) => item.locationCode)"
|
|
placeholder="请选择库位编码"
|
|
v-model="baseFormData.locationCode"
|
|
@select="handleLocationSelect"
|
|
>
|
|
<template #item="{ item }">
|
|
<text>{{ item }}</text>
|
|
<text class="location-name">{{ getLocationName(item) }}</text>
|
|
</template>
|
|
</uni-combox>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="库位名称" name="locationName">
|
|
<uni-easyinput
|
|
v-model="baseFormData.locationName"
|
|
placeholder="请输入库位名称"
|
|
:disabled="true"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="仓库编码" name="warehouseCode" required>
|
|
<uni-easyinput
|
|
v-model="baseFormData.warehouseCode"
|
|
placeholder="请输入仓库编码"
|
|
:disabled="true"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="入库类型" name="transactionType" required>
|
|
<uni-combox
|
|
:candidates="transactionTypeList.map((item) => item.typeName)"
|
|
placeholder="请选择入库类型"
|
|
v-model="baseFormData.transactionType"
|
|
>
|
|
<template #item="{ item }">
|
|
<text>{{ item }}</text>
|
|
<text class="transport-type-name">{{
|
|
getTransportTypeName(item)
|
|
}}</text>
|
|
</template>
|
|
</uni-combox>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="入库数量" name="quantity" required>
|
|
<uni-easyinput
|
|
v-model="baseFormData.quantity"
|
|
placeholder="请输入入库数量"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="批次号" name="batchNo" required>
|
|
<uni-easyinput
|
|
v-model="baseFormData.batchNo"
|
|
placeholder="请输入批次号"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="炉号" name="ovenNo">
|
|
<uni-easyinput
|
|
v-model="baseFormData.ovenNo"
|
|
placeholder="请输入炉号"
|
|
/>
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="操作员" name="operator">
|
|
<uni-easyinput
|
|
v-model="baseFormData.operator"
|
|
placeholder="请输入操作员"
|
|
/>
|
|
</uni-forms-item>
|
|
</uni-forms>
|
|
<button type="primary" @click="submit('customForm')">提交</button>
|
|
</view>
|
|
</uni-section>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import * as recordInboundApi from "@/api/productionMaterial/recordInbound.js";
|
|
export default {
|
|
components: {},
|
|
data() {
|
|
return {
|
|
lastScanValue: "",
|
|
// 库位表数据
|
|
locationList: [],
|
|
// 出入库类别对照表数据
|
|
transactionTypeList: [],
|
|
// 基础表单数据
|
|
baseFormData: {
|
|
materialCode: "",
|
|
materialName: "",
|
|
type: "",
|
|
transactionType: "",
|
|
supplierName: "",
|
|
locationCode: "",
|
|
locationName: "",
|
|
warehouseCode: "",
|
|
quantity: null,
|
|
batchNo: "",
|
|
stoveCode: "",
|
|
operator: "",
|
|
},
|
|
// 校验表单数据
|
|
valiFormData: {
|
|
materialCode: "",
|
|
locationCode: "",
|
|
warehouseCode: "",
|
|
transportType: "",
|
|
quantity: "",
|
|
batchNo: "",
|
|
},
|
|
// 校验规则
|
|
rules: {
|
|
materialCode: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "物料编码不能为空",
|
|
},
|
|
],
|
|
},
|
|
locationCode: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "库位编码不能为空",
|
|
},
|
|
],
|
|
},
|
|
warehouseCode: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "仓库编码不能为空",
|
|
},
|
|
],
|
|
},
|
|
transportType: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "入库类型不能为空",
|
|
},
|
|
],
|
|
},
|
|
quantity: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "入库数量不能为空",
|
|
},
|
|
{
|
|
format: "number",
|
|
errorMessage: "入库数量只能输入数字",
|
|
},
|
|
],
|
|
},
|
|
batchNo: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "批次号不能为空",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
};
|
|
},
|
|
computed: {},
|
|
onLoad() {
|
|
// 库位表查询
|
|
recordInboundApi
|
|
.listMmLocation({ status: "启用" })
|
|
.then((res) => {
|
|
uni.hideLoading();
|
|
if (res.code === 200) {
|
|
if (!res.data) {
|
|
this.openModal();
|
|
this.clear();
|
|
return;
|
|
}
|
|
this.locationList = res.data.result;
|
|
}
|
|
})
|
|
.catch(() => {
|
|
uni.hideLoading();
|
|
});
|
|
// 出入库类别对照表查询
|
|
recordInboundApi
|
|
.listMmTransactionType({ status: "启用", transactionDirection: "入库" })
|
|
.then((res) => {
|
|
uni.hideLoading();
|
|
if (res.code === 200) {
|
|
if (!res.data) {
|
|
this.uModal.content = "出入库类别不存在!";
|
|
this.openModal();
|
|
this.clear();
|
|
return;
|
|
}
|
|
this.transactionTypeList = res.data.result;
|
|
}
|
|
})
|
|
.catch(() => {
|
|
uni.hideLoading();
|
|
});
|
|
},
|
|
onReady() {},
|
|
methods: {
|
|
// 获取库位名称
|
|
getLocationName(locationCode) {
|
|
const location = this.locationList.find(
|
|
(item) => item.locationCode === locationCode,
|
|
);
|
|
return location ? location.locationName : "";
|
|
},
|
|
// 获取入库类型名称
|
|
getTransportTypeName(transportType) {
|
|
const transactionType = this.transactionTypeList.find(
|
|
(item) => item.transactionType === transportType,
|
|
);
|
|
return transactionType ? transactionType.transactionTypeName : "";
|
|
},
|
|
// 扫物料编码结果
|
|
scanConfirm(val) {
|
|
this.lastScanValue = val;
|
|
const params = {
|
|
materialCode: val,
|
|
status: "启用",
|
|
};
|
|
uni.showLoading({
|
|
title: "加载中...",
|
|
mask: true,
|
|
});
|
|
recordInboundApi
|
|
.listMmMaterial(params)
|
|
.then((res) => {
|
|
uni.hideLoading();
|
|
if (res.code === 200) {
|
|
if (!res.data) {
|
|
this.uModal.content = "物料不存在!";
|
|
this.openModal();
|
|
this.clear();
|
|
return;
|
|
}
|
|
this.baseFormData = {
|
|
...res.data.result[0],
|
|
};
|
|
}
|
|
})
|
|
.catch(() => {
|
|
uni.hideLoading();
|
|
});
|
|
},
|
|
// 提交表单
|
|
submit(ref) {
|
|
this.$refs.baseForm
|
|
.validate()
|
|
.then((res) => {
|
|
console.log("表单数据信息:", res);
|
|
// 新增入库单
|
|
recordInboundApi
|
|
.createInboundReceipt(res)
|
|
.then((res) => {
|
|
uni.hideLoading();
|
|
if (res.code === 200) {
|
|
this.reset();
|
|
this.uModal.content = "入库单新增成功!";
|
|
this.openModal();
|
|
this.clear();
|
|
return;
|
|
}
|
|
})
|
|
.catch(() => {
|
|
uni.hideLoading();
|
|
});
|
|
})
|
|
.catch((err) => {
|
|
console.log("表单错误信息:", err);
|
|
});
|
|
},
|
|
// 库位选择事件
|
|
handleLocationSelect(locationCode) {
|
|
const location = this.locationList.find(
|
|
(item) => item.locationCode === locationCode,
|
|
);
|
|
if (location) {
|
|
this.baseFormData.locationName = location.locationName;
|
|
this.baseFormData.warehouseCode = location.warehouseCode;
|
|
}
|
|
},
|
|
// 重置表单
|
|
reset() {
|
|
this.baseFormData = {
|
|
id: null,
|
|
materialCode: null,
|
|
materialName: null,
|
|
supplierCode: null,
|
|
supplierName: null,
|
|
warehouseCode: null,
|
|
warehouseName: null,
|
|
locationCode: null,
|
|
locationName: null,
|
|
batchNo: null,
|
|
stoveCode: null,
|
|
currentQty: null,
|
|
unit: null,
|
|
productionDate: null,
|
|
expiryDate: null,
|
|
lastUpdatedTime: null,
|
|
createdTime: null,
|
|
operator: userStore.userInfo.nickName,
|
|
transactionType: null,
|
|
quantity: null,
|
|
type: null,
|
|
};
|
|
proxy.resetForm("formRef");
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
@import "./index.css";
|
|
</style>
|