pda_uniapp/pages/work/wms/skuCreatePalletByCode.vue

567 lines
13 KiB
Vue
Raw Normal View History

2025-08-07 15:33:34 +08:00
<template>
<view class="container">
2025-09-05 15:22:43 +08:00
<cu-custom :isBack="true">
<block slot="backText"></block>
2025-08-07 15:33:34 +08:00
<block slot="content">一码通组盘 AGV入库</block>
</cu-custom>
<view class="example">
<uni-forms ref="form" :model="formData" labelWidth="80px">
2025-09-05 15:22:43 +08:00
<uni-forms-item label="一码通">
<view class="fromItem">
<uni-easyinput v-model="barCode" placeholder="请扫描一码通" @blur="trimbarCode"
@confirm="handleEnter" />
<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
</view>
2025-08-07 15:33:34 +08:00
</uni-forms-item>
<uni-forms-item label="物料">
2025-09-05 15:22:43 +08:00
<view class="fromItem">
<uni-easyinput v-model="formData.palletCode" disabled />
<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
</view>
</uni-data-select>
2025-08-07 15:33:34 +08:00
</uni-forms-item>
<uni-forms-item label="托盘编号">
2025-09-05 15:22:43 +08:00
<view class="fromItem">
<uni-easyinput v-model="formData.palletCode" disabled />
<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
</view>
2025-08-07 15:33:34 +08:00
</uni-forms-item>
<uni-forms-item label="货位编号">
2025-09-05 15:22:43 +08:00
<view class="fromItem">
<uni-easyinput v-model="formData.locCode" placeholder="请扫描货位编号" @blur="trimLocInput" />
<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
</view>
2025-08-07 15:33:34 +08:00
</uni-forms-item>
<uni-forms-item label="物料数量">
2025-09-05 15:22:43 +08:00
<view class="fromItem">
<uni-easyinput v-model="formData.skuQty" type="number" disabled />
<image style="width: 28rpx;" src="/static/images/right.png" mode="widthFix"></image>
</view>
2025-08-07 15:33:34 +08:00
</uni-forms-item>
2025-09-05 15:22:43 +08:00
2025-08-07 15:33:34 +08:00
</uni-forms>
<view class="switch-item">
2025-09-05 15:22:43 +08:00
<view class="uni-list-cell-db">{{callStatus}}</view>
<switch :checked="autoCall" @change="switchChange" />
</view>
<!-- <view class="button-group">
<button type="primary" style="width: 100px;" :disabled="isButtonDisabled"
@click="submitPallet">组盘</button>
<button :disabled="isButtonDisabled" style="width: 100px;" @click="callAgv"></button>
</view> -->
2025-08-07 15:33:34 +08:00
</view>
2025-09-05 15:22:43 +08:00
<bottomBtn :isDouble="true" :isSubmit="true" :isWhite="false" position="fixed" :disable="isButtonDisabled"
:texts="['组盘', '确认入库']" @onCancel="submitPallet" @onSubmit="callAgv"></bottomBtn>
2025-08-07 15:33:34 +08:00
<view class="cu-modal" :class="msgModalName=='Modal'?'show':''">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">{{msgTitleName}}</view>
<view class="action" @tap="hideMsgModal">
<text class="cuIcon-close text-red"></text>
</view>
</view>
<view class="padding-xl">
{{msg}}
</view>
</view>
</view>
</view>
</template>
<script>
import {
2025-09-05 15:22:43 +08:00
getSkuDictionary,
getSkuTypes
2025-08-07 15:33:34 +08:00
} from "@/api/wms/sku.js"
import {
2025-09-05 15:22:43 +08:00
createPalletBySku,
callAgvIn
2025-08-07 15:33:34 +08:00
} from "@/api/wms/bill.js"
import {
getDictionary
} from "@/api/wms/dictData.js"
import {
formatDate
} from 'tough-cookie';
2025-09-05 15:22:43 +08:00
import {
debounce
} from 'lodash';
import {bottomBtn} from '@/components/bottomBtn/bottomBtn.vue'
2025-08-07 15:33:34 +08:00
export default {
data() {
return {
2025-09-05 15:22:43 +08:00
barCode: '',
isButtonDisabled: false,
autoCall: true,
callStatus: "已开启自动呼叫空容器",
2025-08-07 15:33:34 +08:00
//表单中的数据信息
formData: {
palletCode: "",
skuCode: "",
locCode: "",
skuQty: ""
},
rules: {
skuCode: {
rules: [{
required: true,
errorMessage: '请选择物料'
}]
},
palletCode: {
rules: [{
required: true,
errorMessage: '请扫码托盘号'
}]
},
locCode: {
rules: [{
required: true,
errorMessage: '请扫码货位号'
}]
},
skuQty: {
rules: [{
required: true,
errorMessage: '请输入物料数量'
}]
}
},
2025-09-05 15:22:43 +08:00
2025-08-07 15:33:34 +08:00
//查询获取的单据信息
billInfo: {
totalPlanQty: 0,
totalSurplusQty: 0,
wmsInBillSkuInfos: []
},
//table 相关
searchVal: '',
tableData: [],
// 每页数据量
pageSize: 10,
// 当前页
pageCurrent: 1,
// 数据总量
total: 0,
loading: false,
//tabe选中的数据对象
selectedIndexs: [],
// 列配置
tableClumns: [{
dataIndex: "itemCode",
key: "itemCode",
title: "明细单号"
},
{
dataIndex: "batch",
key: "batch",
title: "批次"
},
{
dataIndex: "skuCode",
key: "skuCode",
title: "物料编号"
},
{
dataIndex: "skuName",
key: "skuName",
title: "物料名称"
},
{
dataIndex: "planQty",
key: "planQty",
title: "计划数量"
},
{
dataIndex: "lockQty",
key: "lockQty",
title: "锁定数量"
},
{
dataIndex: "qty",
key: "qty",
title: "组盘数量"
},
],
2025-09-05 15:22:43 +08:00
2025-08-07 15:33:34 +08:00
warehouseList: [],
skuList: [],
2025-09-05 15:22:43 +08:00
skuType: '',
skuTypeList: [],
2025-08-07 15:33:34 +08:00
skuArray: [],
skushow: false,
invoiceCode: null,
palletCode: null,
houseCode: null,
skuCode: null,
locCode: null,
skuQty: null,
totalPlanQty: null,
totalSurplusQty: null,
msgModalName: null,
msgTitleName: null,
msg: null
};
},
onLoad() {
//加载物料下拉值列表
this.getSkuTypes()
//加载入库单据类型下拉值列表
// this.getWarehouses()
//this.getInvoicesByBusinessType()
2025-09-05 15:22:43 +08:00
2025-08-07 15:33:34 +08:00
},
onReady() {
this.$refs.form.setRules(this.rules)
},
2025-09-05 15:22:43 +08:00
component:{
bottomBtn
},
2025-08-07 15:33:34 +08:00
watch: {
2025-09-05 15:22:43 +08:00
async skuType(newVal) {
var param = {
categoryCode: this.skuType
}
2025-08-07 15:33:34 +08:00
this.skuList = await getSkuDictionary(param);
2025-09-05 15:22:43 +08:00
2025-08-07 15:33:34 +08:00
}
},
methods: {
2025-09-05 15:22:43 +08:00
handleEnter: _.debounce(function() {
console.log('回车键被按下,当前输入值:', this.barCode);
2025-08-07 15:33:34 +08:00
}, 500),
2025-09-05 15:22:43 +08:00
2025-08-07 15:33:34 +08:00
//去除空格
trimLocInput(event) {
2025-09-05 15:22:43 +08:00
this.formData.locCode = event.target.value.trim();
2025-08-07 15:33:34 +08:00
},
//去除空格
trimbarCode(event) {
2025-09-05 15:22:43 +08:00
this.barCode = event.target.value.trim();
2025-08-07 15:33:34 +08:00
},
/// 数据来源 [模拟]
async fetch(param) {
var response = await queryInBillSkuInfo(param);
return {
total: response.data.total,
data: response.data.record,
};
},
2025-09-05 15:22:43 +08:00
switchChange(e) {
2025-08-07 15:33:34 +08:00
this.autoCall = e.detail.value;
2025-09-05 15:22:43 +08:00
if (this.autoCall) {
this.callStatus = "已开启自动呼叫空容器"
} else {
this.callStatus = "已停止自动呼叫空容器"
2025-08-07 15:33:34 +08:00
}
},
//获取物料类型列表
async getSkuTypes() {
this.skuTypeList = await getSkuTypes();
2025-09-05 15:22:43 +08:00
console.log("this.skutypeList", this.skuTypeList)
2025-08-07 15:33:34 +08:00
},
//获取物料列表
// async getSkus() {
// console.log("this.skuType",this.skuType)
2025-09-05 15:22:43 +08:00
// if(this.skuType){
// this.skuList = await getSkuDictionary(this.skuType);
// }
2025-08-07 15:33:34 +08:00
// },
//获取仓库列表
async getWarehouses() {
this.warehouseList = await getDictionary('warehouseList');
2025-09-05 15:22:43 +08:00
console.log("this.warehouseList", this.warehouseList)
2025-08-07 15:33:34 +08:00
},
// 多选处理
selectedItems() {
return this.selectedIndexs.map(i => this.tableData[i])
},
// 多选
selectionChange(e) {
console.log(e.detail.index)
this.selectedIndexs = e.detail.index
//选中内容改变时获取选中数据
},
//批量删除
delTable() {
console.log(this.selectedItems())
},
// 分页触发
change(e) {
this.$refs.table.clearSelection()
this.selectedIndexs.length = 0
this.getData(e.current)
},
// 搜索
search() {
this.getData(1, this.searchVal)
},
// 获取数据
getData(pageCurrent, value = '') {
this.loading = true
this.pageCurrent = pageCurrent
this.request({
pageSize: this.pageSize,
pageCurrent: pageCurrent,
value: value,
success: res => {
// console.log('data', res);
this.tableData = res.data
this.total = res.total
this.loading = false
}
})
},
//获取选中的数据
getSelectDetail() {
if (this.selectedIndexs.length == 0) {
//提示
this.$modal.msgError("请先选择需要组盘的单据明细")
return;
}
//筛选出需要拣选的单据明细
let arr = [];
let len = this.billInfo.wmsInBillSkuInfos.length;
for (let i = 0; i < len; i++) {
if (this.selectedIndexs.indexOf(i) >= 0) {
arr.push(this.billInfo.wmsInBillSkuInfos[i]);
} else {
// console.log(this.selectArr.indexOf(i))
//this.selectArr.indexOf(i);
}
}
console.log("选中的单据明细数据为", arr.length)
return arr;
},
// 伪request请求
request(options) {
const {
pageSize,
pageCurrent,
success,
value
} = options
let total = tableData.length
let data = tableData.filter((item, index) => {
const idx = index - (pageCurrent - 1) * pageSize
return idx < pageSize && idx >= 0
})
if (value) {
data = []
tableData.forEach(item => {
if (item.name.indexOf(value) !== -1) {
data.push(item)
}
})
total = data.length
}
setTimeout(() => {
typeof success === 'function' &&
success({
data: data,
total: total
})
}, 500)
},
// submit(ref) {
// this.$refs.form.validate().then(res => {
// updateUserProfile(this.user).then(response => {
// this.$modal.msgSuccess("修改成功")
// })
// })
// }
//组盘
submitPallet: function(ref) {
2025-09-05 15:22:43 +08:00
this.isButtonDisabled = true;
2025-08-07 15:33:34 +08:00
this.$modal.loading("请等待...")
this.$refs.form.validate().then(res => {
console.log("数据校验通过", res)
createPalletBySku(this.formData).then(response => {
console.log("response", response)
this.$modal.msgSuccess("组盘成功")
}).finally(() => {
2025-09-05 15:22:43 +08:00
this.isButtonDisabled = false; // 恢复按钮可用
this.$modal.closeLoading()
2025-08-07 15:33:34 +08:00
});
2025-09-05 15:22:43 +08:00
}).catch(() => {
this.isButtonDisabled = false; // 恢复按钮可用
this.$modal.closeLoading()
2025-08-07 15:33:34 +08:00
})
},
//呼叫AGV
callAgv: function() {
2025-09-05 15:22:43 +08:00
this.isButtonDisabled = true;
this.$modal.loading("请等待...")
if (!this.formData.locCode) {
this.$modal.closeLoading()
}
if (!this.formData.palletCode) {
this.$modal.closeLoading()
}
var data = {
locCode: this.formData.locCode,
palletCode: this.formData.palletCode,
autoCall: this.autoCall
}
callAgvIn(data).then(response => {
console.log("response", response)
this.$modal.msgSuccess("呼叫入库成功")
}).finally(() => {
this.isButtonDisabled = false; // 恢复按钮可用
this.$modal.closeLoading()
});
2025-08-07 15:33:34 +08:00
},
hideMsgModal(e) {
//关闭信息模态框
this.msgModalName = null;
},
textareaAInput(e) {
this.textareaAValue = e.detail.value
},
textareaBInput(e) {
this.textareaBValue = e.detail.value
},
//根据单据号查询入库单
queryRkOrder: async function(e) {
console.log('进入查询方法', e);
console.log('this.formData', this.formData);
console.log('this.formData.invoiceCode', this.formData.invoiceCode);
var invoiceCode = this.formData.invoiceCode;
if (invoiceCode == null) {
this.$modal.msgError("单据号不能为空")
return;
}
if (invoiceCode.length < 1) {
this.$modal.msgError("单据号不能为空")
return;
}
//查询单据信息
var billInfo = await queryInBillSkuInfo({
'invoiceCode': invoiceCode
});
console.log("billInfo", billInfo)
if (billInfo) {
this.billInfo = billInfo.data;
};
}
}
}
</script>
2025-09-05 15:22:43 +08:00
<style scoped lang="scss">
.container {
background: rgb(242, 243, 245);
height: 100vh;
}
.uni-forms-item {
border-bottom: 1px solid #E5E6EB;
margin-bottom: 0;
padding: 24rpx 0;
}
::v-deep .uni-forms-item__label {
color: #1D2129;
font-size: 28rpx;
font-weight: 400;
}
::v-deep .uni-select {
border: 0px;
}
::v-deep.uni-select__input-placeholder {
font-size: 28rpx;
font-weight: 400;
color: #86909C;
}
.textarea{
background-color: #F2F3F5;
width: 100%;
}
::v-deep.full-width-textarea{
width: 100%!important;
border: unset!important;
}
::v-deep .is-input-border{
border: unset;
}
::v-deep .uni-easyinput__placeholder-class{
font-size: 28rpx;
color: #86909C;
}
::v-deep .uni-input-input{
font-size: 28rpx;
}
::v-deep .uni-select__input-placeholder{
font-size: 28rpx;
color: #86909C;
}
::v-deep .uniui-bottom{
display: none;
}
::v-deep .uniui-top{
display: none;
}
.fromItem{
display: flex;
align-items: center;
}
2025-08-07 15:33:34 +08:00
.cu-form-group .title {
min-width: calc(4em + 15px);
}
page {
background-color: #ffffff;
}
.example {
2025-09-05 15:22:43 +08:00
padding: 0 24rpx;
2025-08-07 15:33:34 +08:00
background-color: #fff;
2025-09-05 15:22:43 +08:00
width: 702rpx;
border-radius: 24rpx;
margin: 24rpx auto;
2025-08-07 15:33:34 +08:00
}
.segmented-control {
margin-bottom: 15px;
}
.button-group {
margin-top: 15px;
display: flex;
justify-content: space-around;
}
.form-item {
display: flex;
align-items: center;
flex: 1;
}
.button {
display: flex;
align-items: center;
height: 35px;
line-height: 35px;
margin-left: 10px;
}
2025-09-05 15:22:43 +08:00
.switch-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
border-bottom: 1px solid #eee;
}
2025-08-07 15:33:34 +08:00
</style>