Files
hht-xzhy-uni/pages/General/warehouse-box.vue

560 lines
16 KiB
Vue
Raw Normal View History

2025-09-03 09:57:06 +08:00
<template>
<view class="zd_container">
<!-- 入库组箱 -->
<nav-bar :title="title"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper">
<view class="zd-row border-bottom">
2025-09-03 17:08:48 +08:00
<view class="zd-col-6">
<span class="filter_label">载具编码</span>
2025-09-03 09:57:06 +08:00
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-col-18">
2025-10-22 10:24:50 +08:00
<search-box v-model="vehicleCode" @handleChange="handleChange" @handleDel="handleDel"/>
2025-09-03 09:57:06 +08:00
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label">物料编码</span>
2025-09-03 09:57:06 +08:00
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-col-13">
2025-09-08 15:41:33 +08:00
<search-box v-model="materialData.material_code"/>
2025-09-03 09:57:06 +08:00
</view>
2025-12-04 13:59:33 +08:00
<button class="mini-btn" type="primary" @tap="toJump('material?title=物料维护')">查询</button>
2025-09-03 09:57:06 +08:00
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
<span class="filter_label filter_input_disabled">物料名称</span>
</view>
<view class="zd-col-18">
2025-09-08 15:41:33 +08:00
<input type="text" class="filter_input filter_input_disabled" v-model="materialData.material_name" disabled>
2025-09-03 09:57:06 +08:00
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label">供应商编码</span>
2025-09-03 09:57:06 +08:00
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-col-13">
2025-09-08 15:41:33 +08:00
<search-box v-model="suppData.supp_code"/>
2025-09-03 09:57:06 +08:00
</view>
2025-12-04 13:59:33 +08:00
<button class="mini-btn" type="primary" @tap="toJump('supplier?title=供应商维护')">查询</button>
2025-09-03 09:57:06 +08:00
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label filter_input_disabled">供应商名称</span>
2025-09-03 09:57:06 +08:00
</view>
<view class="zd-col-18">
2025-09-08 15:41:33 +08:00
<input type="text" v-model="suppData.supp_name" class="filter_input filter_input_disabled" disabled>
2025-09-03 09:57:06 +08:00
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label">批次</span>
2025-09-03 09:57:06 +08:00
</view>
2025-12-11 17:10:40 +08:00
<view class="zd-col-18 filter_select">
<!-- <zxz-uni-data-select v-model="index1" filterable :localdata="options1"></zxz-uni-data-select> -->
<view class="input-wrapper">
<input
class="input-field"
v-model="pcsn"
placeholder="请输入或选择"
placeholder-class="placeholder"
@input="onInput"
/>
<picker
class="picker"
mode="selector"
:range="pcOptions"
:value="selectedIndex"
@change="onPickerChange"
>
<view class="picker-trigger">
<!-- <text class="picker-text">></text> -->
<text class="uni-icons zd_icon_wraper uniui-bottom" style="color: rgb(153, 153, 153); font-size: 14px;"></text>
</view>
</picker>
</view>
2025-09-03 09:57:06 +08:00
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label">生产日期</span>
2025-09-03 09:57:06 +08:00
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-col-18 filter_picker">
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="uni-input">{{date}}</view>
</picker>
2025-09-03 09:57:06 +08:00
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label">重量</span>
2025-09-03 09:57:06 +08:00
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-col-16">
2025-09-16 14:48:07 +08:00
<NumberInput v-model="qty" />
2025-09-03 09:57:06 +08:00
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-col-2"><span class="filter_unit">KG</span></view>
2025-09-03 09:57:06 +08:00
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-09-03 17:08:48 +08:00
<span class="filter_label">品质类型</span>
2025-09-03 09:57:06 +08:00
</view>
<view class="zd-col-18 filter_select">
2025-09-08 15:41:33 +08:00
<uni-data-select v-model="index1" :localdata="options1"></uni-data-select>
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
2025-10-22 10:24:50 +08:00
<span class="filter_label filter_input_disabled">料箱类型</span>
2025-09-08 15:41:33 +08:00
</view>
2025-10-22 10:24:50 +08:00
<view class="zd-col-18">
2025-10-24 13:41:19 +08:00
<input type="text" class="filter_input filter_input_disabled" v-model="['小料箱', '大料箱', '焊条筒'][Number(boxType) - 1]" disabled>
2025-09-03 09:57:06 +08:00
</view>
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-row border-bottom">
<view class="zd-col-6">
<span class="filter_label">烘干次数</span>
</view>
<view class="zd-col-18">
2025-09-08 15:41:33 +08:00
<input type="number" v-model="num" class="filter_input">
2025-09-03 09:57:06 +08:00
</view>
</view>
2025-12-12 15:49:29 +08:00
<view class="zd-row border-bottom">
<view class="zd-col-6">
<span class="filter_label">机台编码</span>
</view>
<view class="zd-col-18 filter_select">
<uni-data-select v-model="index2" :localdata="options2"></uni-data-select>
</view>
</view>
2026-03-13 13:29:06 +08:00
<view class="zd-row border-bottom">
<view class="zd-col-6">
<span class="filter_label">执行标准</span>
</view>
<view class="zd-col-18 filter_select">
<uni-data-select v-model="index3" :localdata="options3"></uni-data-select>
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
<span class="filter_label">是否压容</span>
</view>
<view class="zd-col-18 filter_select">
<uni-data-select v-model="index4" :localdata="options4"></uni-data-select>
</view>
</view>
2025-09-03 09:57:06 +08:00
</view>
</view>
2025-09-03 17:08:48 +08:00
<view class="zd-row submit-bar">
<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
2025-09-08 15:41:33 +08:00
<button class="zd-col-9 button-primary" :class="{'button-info': !vehicleCode || JSON.stringify(materialData) === '{}' || JSON.stringify(suppData) === '{}'}" :disabled="disabled" @tap="_confirmBox">确认组箱</button>
<button class="zd-col-9 button-primary" :class="{'button-info': !vehicleCode || JSON.stringify(materialData) === '{}' || JSON.stringify(suppData) === '{}'}" :disabled="disabled1" @tap="labelPrint">标签打印</button>
2025-09-03 17:08:48 +08:00
</view>
2025-12-12 15:49:29 +08:00
<!-- 自定义弹窗遮罩 -->
<view v-if="showCustomDialog" class="custom-dialog-mask" @click="showCustomDialog = false">
<view class="custom-dialog" @click.stop>
<view class="dialog-title">打印次数</view>
<view class="dialog-body">
<input
type="number"
v-model="printCount"
class="dialog-input"
focus
/>
</view>
<view class="dialog-footer">
<button @click="showCustomDialog = false">取消</button>
<button @click="handlePrintConfirm" type="primary">确定</button>
</view>
</view>
</view>
2025-09-03 09:57:06 +08:00
</view>
</template>
<script>
2025-09-08 15:41:33 +08:00
import {getCLodop} from '@/utils/CLodopfuncs.js'
2025-09-03 09:57:06 +08:00
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
2025-09-16 14:48:07 +08:00
import NumberInput from '@/components/NumberInput.vue'
2025-09-03 17:08:48 +08:00
import {getDate} from '@/utils/utils.js'
2025-09-08 15:41:33 +08:00
const currentDate = getDate({format: true})
2025-10-22 10:24:50 +08:00
// import {queryGroupQuality, queryNowVehicle} from '@/utils/mork2.js'
2026-03-13 13:29:06 +08:00
import {queryGroupQuality, queryNowVehicle, confirmBox, printDelete, queryPcsn, queryDevice, queryExecution} from '@/utils/getData2.js'
2025-09-03 09:57:06 +08:00
export default {
components: {
NavBar,
2025-09-16 14:48:07 +08:00
SearchBox,
NumberInput
2025-09-03 09:57:06 +08:00
},
data() {
return {
2025-12-12 15:49:29 +08:00
showCustomDialog: false,
printCount: 1,
2025-09-03 09:57:06 +08:00
title: '',
2025-09-08 15:41:33 +08:00
vehicleCode: '',
2025-09-03 17:08:48 +08:00
date: currentDate,
2025-09-08 15:41:33 +08:00
options1: [],
index1: '',
2025-12-12 15:49:29 +08:00
options2: [],
index2: '',
2026-03-13 13:29:06 +08:00
options3: [],
index3: '',
options4: [{text:'压容', value: '0'}, {text:'非压容', value: '1'}],
index4: '',
2025-10-22 10:24:50 +08:00
boxType: null,
2025-09-08 15:41:33 +08:00
materialData: {},
suppData: {},
qty: null,
num: 0,
disabled: false,
2025-12-11 17:10:40 +08:00
disabled1: false,
pcsn: '',
selectedIndex: 0,
pcOptions: []
// pcOptions: [
// 'TB-001',
// 'TB-002',
// 'TB-003'
// ],
2025-09-03 09:57:06 +08:00
};
},
2025-09-03 17:08:48 +08:00
computed: {
startDate() {
return getDate('start');
},
endDate() {
return getDate('end');
}
},
2025-09-03 09:57:06 +08:00
onLoad (options) {
this.title = options.title
2025-09-08 15:41:33 +08:00
this._queryGroupQuality()
2025-12-11 17:10:40 +08:00
this._queryPcsn()
2025-12-12 15:49:29 +08:00
this._queryDevice()
2026-03-13 13:29:06 +08:00
this._queryExecution()
2025-09-08 15:41:33 +08:00
},
onShow () {
if (this.$store.getters.publicObj !== '') {
this.materialData = this.$store.getters.publicObj
this.$store.dispatch('setPublicObj', '')
}
if (this.$store.getters.formData !== '') {
this.suppData = this.$store.getters.formData
this.$store.dispatch('setFormData', '')
}
2025-09-03 09:57:06 +08:00
},
methods: {
2025-12-12 15:49:29 +08:00
handlePrintConfirm() {
// 处理打印逻辑
let data = Object.assign({}, this.materialData, this.suppData, {pcsn: this.pcsn, produce_time: this.date, bake_num: this.num})
this.showCustomDialog = false
this.toPrint(data)
},
2025-12-11 17:10:40 +08:00
onInput(e) {
// console.log('输入内容:', e.detail.value)
},
onPickerChange(e) {
const index = e.detail.value
this.selectedIndex = index
this.pcsn = this.pcOptions[index]
},
2025-10-22 10:24:50 +08:00
handleChange (e) {
if (e) {
this._queryNowVehicle(e)
}
},
handleDel () {
this.boxType = ''
},
2025-12-11 17:10:40 +08:00
/** 批次下拉框*/
async _queryPcsn () {
try {
let res = await queryPcsn()
if (res) {
this.pcOptions = res.data.map(item => item.value);
} else {
this.pcOptions = []
}
} catch (e) {
this.pcOptions = []
}
},
2025-10-22 10:24:50 +08:00
async _queryNowVehicle (e) {
try {
let res = await queryNowVehicle(e)
if (res) {
this.boxType = res.data.box_type
} else {
this.boxType = ''
}
} catch (e) {
this.boxType = ''
}
},
2025-09-03 17:08:48 +08:00
toJump (name) {
uni.navigateTo({
url: `/pages/General/${name}`
})
},
bindDateChange: function(e) {
this.date = e.detail.value
},
2025-09-03 09:57:06 +08:00
/** 下拉框*/
2025-09-08 15:41:33 +08:00
async _queryGroupQuality () {
try {
let res = await queryGroupQuality()
if (res && res.data) {
this.options1 = [...res.data]
} else {
this.options1 = []
}
} catch (e) {
this.options1 = []
}
2025-09-03 09:57:06 +08:00
},
2025-12-12 15:49:29 +08:00
/** 机台编码下拉框*/
async _queryDevice () {
try {
let res = await queryDevice()
if (res && res.data) {
this.options2 = [...res.data]
} else {
this.options2 = []
}
} catch (e) {
this.options2 = []
}
},
2026-03-13 13:29:06 +08:00
/** 执行标准下拉框*/
async _queryExecution () {
try {
let res = await queryExecution()
if (res && res.data) {
this.options3 = [...res.data]
} else {
this.options3 = []
}
} catch (e) {
this.options3 = []
}
},
2025-09-03 09:57:06 +08:00
toEmpty () {
2025-09-08 15:41:33 +08:00
this.vehicleCode = ''
this.date = currentDate
this.index1 = ''
2025-10-22 10:24:50 +08:00
this.boxType = null
2025-09-08 15:41:33 +08:00
this.materialData = {}
this.suppData = {}
this.pcsn = null
this.qty = null
this.num = 0
2025-09-03 09:57:06 +08:00
},
2025-09-08 15:41:33 +08:00
async _confirmBox () {
2025-09-03 09:57:06 +08:00
this.disabled = true
2025-09-08 15:41:33 +08:00
if (!this.vehicleCode || JSON.stringify(this.materialData) === '{}' || JSON.stringify(this.suppData) === '{}') {
2025-09-03 09:57:06 +08:00
this.disabled = false
return
}
try {
2026-03-13 13:29:06 +08:00
let res = await confirmBox(this.vehicleCode, this.materialData.material_id, this.materialData.material_code, this.materialData.material_name, this.suppData.supp_code, this.suppData.supp_name, this.pcsn, this.date, this.qty, this.index1, this.boxType, this.num, this.index2, this.index3, this.index4)
2025-09-08 15:41:33 +08:00
if (res) {
uni.showToast({
title: res.message,
icon: 'none'
})
2025-09-03 09:57:06 +08:00
}
2025-12-11 17:10:40 +08:00
this.vehicleCode = ''
this.qty = ''
this._queryPcsn()
2025-09-03 09:57:06 +08:00
this.disabled = false
} catch (e) {
this.disabled = false
}
2025-09-08 15:41:33 +08:00
},
2025-12-08 15:37:38 +08:00
async _printDelete (data) {
try {
let res = await printDelete(data)
if (res) {
// console.log('success')
}
} catch (e) {
// console.log('error')
}
},
2025-09-08 15:41:33 +08:00
labelPrint () {
2025-09-08 16:45:57 +08:00
this.disabled1 = true
2025-12-04 13:59:33 +08:00
if (!this.vehicleCode || JSON.stringify(this.materialData) === '{}' || JSON.stringify(this.suppData) === '{}') {
this.disabled1 = false
return
}
2025-12-12 15:49:29 +08:00
this.showCustomDialog = true
// let data = Object.assign({}, this.materialData, this.suppData, {pcsn: this.pcsn, produce_time: this.date, bake_num: this.num})
// this.toPrint(data)
2025-09-08 15:41:33 +08:00
},
toPrint (data) {
let iparr = this.$store.getters.printUrl.split(":")
let printUrl = iparr[1].slice(2)
let LODOP = getCLodop();
if (!(LODOP.webskt && LODOP.webskt.readyState === 1)) {
uni.showToast({
title: '当前配置ip' + printUrl + '网络不通,请检查',
icon: 'none',
duration: 5000
})
2025-09-08 16:45:57 +08:00
this.disabled1 = false
2025-09-08 15:41:33 +08:00
return
}
2025-12-12 15:49:29 +08:00
// 按次打印
for (let i = 0; i < this.printCount; i++) {
LODOP.SET_SHOW_MODE('HIDE_DISBUTTIN_SETUP', 1)// 隐藏那些无效按钮
LODOP.SET_LICENSES('浙江省烟草专卖局(公司)', 'C0C4A46A3A0D1F526D426018D9F11921', '', '')
// 更换为打印服务器ip 不需要加前缀
LODOP.PRINT_INIT(null, printUrl);
// 打印机序号 规则为打印服务器打印机列表倒数从0开始 -1为默认打印机
LODOP.SET_PRINTER_INDEX(-1);
// 设置打印纸大小
LODOP.SET_PRINT_PAGESIZE(1, '80mm', '60mm', '')
LODOP.ADD_PRINT_RECT('1mm', '3mm', '74mm', '54mm', 0, 1)
LODOP.SET_PRINT_STYLE('FontSize', 8)
LODOP.SET_PRINT_STYLE('Bold', 1)
LODOP.ADD_PRINT_BARCODE('5mm', '7mm', '30mm', '30mm', 'QRCode', data.material_code + '##' + data.material_name + '##' +
data.material_spec + '##' + data.material_model + '##' + data.quality_time + '##' + data.produce_time + '##' +
data.supp_name + '##' + data.bake_num + '##' + data.supp_code + '##' + data.pcsn + '##' + data.execution_stand
)
LODOP.ADD_PRINT_TEXT('5mm', '38mm', '60mm', '10mm', '物料编码:' + data.material_code)
LODOP.ADD_PRINT_TEXT('12mm', '38mm', '60mm', '10mm', '物料名称:' + data.material_name)
LODOP.ADD_PRINT_TEXT('19mm', '38mm', '60mm', '10mm', '规格:' + data.material_spec)
LODOP.ADD_PRINT_TEXT('26mm', '38mm', '60mm', '10mm', '型号:' + data.material_model)
LODOP.ADD_PRINT_TEXT('33mm', '38mm', '60mm', '10mm', '有效期(天)' + data.quality_time)
LODOP.ADD_PRINT_TEXT('40mm', '38mm', '60mm', '10mm', '生产日期:' + data.produce_time)
LODOP.ADD_PRINT_TEXT('47mm', '38mm', '60mm', '10mm', '供应商:' + data.supp_name)
2025-12-08 10:46:38 +08:00
2025-12-12 15:49:29 +08:00
LODOP.ADD_PRINT_TEXT('33mm', '7mm', '60mm', '10mm', '烘干次数:' + data.bake_num)
LODOP.ADD_PRINT_TEXT('40mm', '7mm', '60mm', '10mm', '批号:' + data.pcsn)
LODOP.ADD_PRINT_TEXT('47mm', '7mm', '60mm', '10mm', '执行标准:' + data.execution_stand)
LODOP.PRINT();
// LODOP.PREVIEW()
}
// 烘干出库且需要删除的 调用删除接口
2025-12-08 15:37:38 +08:00
if (data.out_type === '1004' && data.is_need_delete === '1') {
this.printDelete(data)
}
2025-09-08 15:41:33 +08:00
uni.showToast({
2025-12-08 15:37:38 +08:00
title: '操作成功',
2025-09-08 15:41:33 +08:00
icon: 'none'
})
2025-09-08 16:45:57 +08:00
this.disabled1 = false
2025-09-03 09:57:06 +08:00
}
}
}
2025-12-11 17:10:40 +08:00
</script>
<style lang="stylus">
.input-container {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
margin-bottom: 40rpx;
}
.input-wrapper {
position: relative;
display: flex;
align-items: center;
// border: 2rpx solid #e0e0e0;
border-radius: 12rpx;
overflow: hidden;
transition: border-color 0.3s;
}
.input-wrapper:focus-within {
border-color: #007AFF;
}
.input-field {
flex: 1;
height: 80rpx;
// padding: 0 24rpx;
font-size: 28rpx;
color: #333;
}
.placeholder {
color: #999;
font-size: 28rpx;
}
.picker {
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #f8f8f8;
border-left: 2rpx solid #e0e0e0;
}
.picker-trigger {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.picker-text {
font-size: 24rpx;
color: #666;
}
2025-12-12 15:49:29 +08:00
.custom-dialog-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
}
.custom-dialog {
width: 600rpx;
background: #fff;
border-radius: 16rpx;
overflow: hidden;
}
.dialog-title {
padding: 30rpx;
font-size: 32rpx;
text-align: center;
border-bottom: 1rpx solid #eee;
}
.dialog-body {
padding: 40rpx;
}
.dialog-input {
width: 100%;
height: 80rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
padding: 0 20rpx;
text-align: center;
}
.dialog-footer {
display: flex;
border-top: 1rpx solid #eee;
}
.dialog-footer button {
flex: 1;
border-radius: 0;
margin: 0;
}
2025-12-11 17:10:40 +08:00
</style>