标签打印弹框

This commit is contained in:
2026-04-02 13:46:44 +08:00
parent dc16ec0198
commit 8e1c9979a7
2 changed files with 512 additions and 162 deletions

View File

@@ -104,7 +104,49 @@
<!-- <button class="zd-col-5 button-default" @tap="toEmpty">清空</button> -->
<button class="zd-col-7 button-primary" :class="{'button-info': flag || !val1 || !pcsn || !num || JSON.stringify(materialData) === '{}'}" :disabled="disabled" @tap="toZdPrint">组袋并打印</button>
<button class="zd-col-7 button-primary" :class="{'button-info': flag || !val1 || !pcsn || !num || JSON.stringify(materialData) === '{}'}" :disabled="disabled" @tap="_confirmBagAssembly">确认组袋</button>
<button class="zd-col-7 button-primary" :class="{'button-info': !val1 || !pcsn || !num || JSON.stringify(materialData) === '{}'}" :disabled="disabled1" @tap="labelPrint">标签打印</button>
<button class="zd-col-7 button-primary" :class="{'button-info': !val1 || !pcsn || !num || JSON.stringify(materialData) === '{}'}" :disabled="disabled1" @tap="tolPrint">标签打印</button>
</view>
<!-- 自定义弹窗 -->
<view v-if="dialogVisible" class="dialog-mask" @click="closeDialog" @touchmove.stop.prevent>
<view class="dialog-container" @click.stop>
<view class="dialog-title">是否确认补打印标签</view>
<view class="dialog-content">
<!-- 物料卡标签填满更换 -->
<view class="checkbox-item">
<checkbox :checked="reasons.full" @click="toggleFull" />
<text class="checkbox-label">物料卡标签填满更换</text>
</view>
<!-- 标签破损更换 -->
<view class="checkbox-item">
<checkbox :checked="reasons.broken" @click="toggleBroken" />
<text class="checkbox-label">标签破损更换</text>
</view>
<!-- 其他选项 + 说明输入框 -->
<view class="other-section">
<view class="checkbox-item">
<checkbox :checked="reasons.other" @click="toggleOther" />
<text class="checkbox-label">其他说明</text>
</view>
<!-- 当选中其他显示说明输入框 -->
<input
v-if="reasons.other"
class="filter_input"
style="border:1px solid #ccc; text-indent: 6px; border-radius: 5px;"
type="text"
v-model="otherRemark"
maxlength="100"
/>
</view>
</view>
<view class="dialog-buttons">
<button class="cancel-btn" @click="closeDialog">取消</button>
<button class="confirm-btn" type="primary" @click="submitReasons">确认打印</button>
</view>
</view>
</view>
</view>
</template>
@@ -136,7 +178,14 @@
disabled: false,
disabled1: false,
pcsn: '',
flag: false
flag: false,
dialogVisible: false, // 控制弹窗显示/隐藏
reasons: {
full: false, // 物料卡标签填满更换
broken: false, // 标签破损更换
other: false // 其他
},
otherRemark: '' // 其他说明文字
};
},
computed: {
@@ -159,6 +208,44 @@
}
},
methods: {
// 显示弹窗(重置表单)
showDialog() {
this.resetForm();
this.dialogVisible = true;
},
// 关闭弹窗并重置表单
closeDialog() {
this.dialogVisible = false;
this.resetForm();
},
// 重置所有选项和输入内容
resetForm() {
this.reasons = {
full: false,
broken: false,
other: false
};
this.otherRemark = '';
},
// 切换复选框状态(手动控制,避免使用 v-model 复杂对象)
toggleFull() {
this.reasons.full = !this.reasons.full;
},
toggleBroken() {
this.reasons.broken = !this.reasons.broken;
},
toggleOther() {
this.reasons.other = !this.reasons.other;
// 如果取消“其他”,清空说明内容(可选,提升体验)
if (!this.reasons.other) {
this.otherRemark = '';
}
},
submitReasons () {
this.labelPrint()
console.log(1)
this.closeDialog();
},
bindDateChange: function(e) {
this.date = e.detail.value
},
@@ -171,6 +258,7 @@
}
},
async _queryBagInfo (e) {
// this.dialogVisible = true
try {
let res = await queryBagInfo(e)
if (res) {
@@ -259,8 +347,17 @@
// // console.log('error')
// }
// },
tolPrint() {
if (this.flag) {
this.dialogVisible = true
return
} else {
this.labelPrint()
}
},
async labelPrint () {
this.disabled1 = true
this.dialogVisible = false
this.flag = false
if (!this.val1 || JSON.stringify(this.materialData) === '{}') {
this.disabled1 = false
@@ -462,112 +559,245 @@
}
</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-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 {
// 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-wrapper:focus-within {
// border-color: #007AFF;
// }
.input-field {
flex: 1;
height: 80rpx;
// padding: 0 24rpx;
font-size: 28rpx;
color: #333;
}
// .input-field {
// flex: 1;
// height: 80rpx;
// // padding: 0 24rpx;
// font-size: 28rpx;
// color: #333;
// }
.placeholder {
color: #999;
font-size: 28rpx;
}
// .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 {
// 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-trigger {
// width: 100%;
// height: 100%;
// display: flex;
// align-items: center;
// justify-content: center;
// }
.picker-text {
font-size: 24rpx;
color: #666;
}
// .picker-text {
// font-size: 24rpx;
// color: #666;
// }
.custom-dialog-mask {
// .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;
// }
/* 遮罩层 */
.dialog-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
align-items: center;
z-index: 1000;
}
.custom-dialog {
width: 600rpx;
background: #fff;
border-radius: 16rpx;
/* 弹窗容器 */
.dialog-container {
width: 80%;
max-width: 300px;
background-color: #fff;
border-radius: 16px;
overflow: hidden;
animation: fadeInScale 0.2s ease-out;
}
@keyframes fadeInScale {
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
}
.dialog-title {
padding: 30rpx;
font-size: 32rpx;
font-size: 18px;
font-weight: bold;
text-align: center;
border-bottom: 1rpx solid #eee;
padding: 20px 16px 12px;
border-bottom: 1px solid #f0f0f0;
color: #333;
}
.dialog-body {
padding: 40rpx;
.dialog-content {
padding: 20px 16px;
}
.dialog-input {
width: 100%;
height: 80rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
padding: 0 20rpx;
text-align: center;
}
.dialog-footer {
.checkbox-item {
display: flex;
border-top: 1rpx solid #eee;
align-items: center;
margin-bottom: 16px;
cursor: pointer;
}
.dialog-footer button {
.checkbox-label {
font-size: 15px;
margin-left: 8px;
color: #333;
flex: 1;
}
/* 其他选项区域 */
.other-section {
margin-top: 4px;
}
.other-input {
margin-top: 12px;
margin-left: 28px; /* 与复选框文本对齐缩进 */
padding: 8px 12px;
border: 1px solid #e5e5e5;
border-radius: 8px;
font-size: 14px;
width: calc(100% - 40px);
background-color: #fafafa;
transition: all 0.2s;
}
.other-input:focus {
border-color: #007aff;
background-color: #fff;
}
/* 按钮区域 */
.dialog-buttons {
display: flex;
border-top: 1px solid #f0f0f0;
}
.dialog-buttons button {
flex: 1;
border-radius: 0;
height: 48px;
line-height: 48px;
font-size: 16px;
background: transparent;
border: none;
margin: 0;
}
.cancel-btn {
color: #666;
border-right: 1px solid #f0f0f0;
}
.cancel-btn::after {
border: none;
}
.confirm-btn {
color: #007aff;
font-weight: 500;
}
.confirm-btn::after {
border: none;
}
/* 分隔线样式 */
.button-divider {
width: 1px;
height: 24px;
background-color: #e5e5e5;
flex-shrink: 0;
}
/* 针对 checkbox 组件样式微调(可选,保证在不同平台显示一致) */
checkbox {
transform: scale(0.9);
}
</style>

View File

@@ -76,7 +76,49 @@
<!-- <button class="zd-col-5 button-default" @tap="toEmpty">清空</button> -->
<button class="zd-col-7 button-primary" :class="{'button-info': flag || !val1 || !weight || !pcsn || JSON.stringify(materialData) === '{}'}" :disabled="disabled" @tap="toZtPrint">组桶并打印</button>
<button class="zd-col-7 button-primary" :class="{'button-info': flag || !val1 || !weight || !pcsn || JSON.stringify(materialData) === '{}'}" :disabled="disabled" @tap="_confirmBucketAssembly">确认组桶</button>
<button class="zd-col-7 button-primary" :class="{'button-info': !val1 || !weight || !pcsn || JSON.stringify(materialData) === '{}'}" :disabled="disabled1" @tap="labelPrint">标签打印</button>
<button class="zd-col-7 button-primary" :class="{'button-info': !val1 || !weight || !pcsn || JSON.stringify(materialData) === '{}'}" :disabled="disabled1" @tap="tolPrint">标签打印</button>
</view>
<!-- 自定义弹窗 -->
<view v-if="dialogVisible" class="dialog-mask" @click="closeDialog" @touchmove.stop.prevent>
<view class="dialog-container" @click.stop>
<view class="dialog-title">是否确认补打印标签</view>
<view class="dialog-content">
<!-- 物料卡标签填满更换 -->
<view class="checkbox-item">
<checkbox :checked="reasons.full" @click="toggleFull" />
<text class="checkbox-label">物料卡标签填满更换</text>
</view>
<!-- 标签破损更换 -->
<view class="checkbox-item">
<checkbox :checked="reasons.broken" @click="toggleBroken" />
<text class="checkbox-label">标签破损更换</text>
</view>
<!-- 其他选项 + 说明输入框 -->
<view class="other-section">
<view class="checkbox-item">
<checkbox :checked="reasons.other" @click="toggleOther" />
<text class="checkbox-label">其他说明</text>
</view>
<!-- 当选中其他显示说明输入框 -->
<input
v-if="reasons.other"
class="filter_input"
style="border:1px solid #ccc; text-indent: 6px; border-radius: 5px;"
type="text"
v-model="otherRemark"
maxlength="100"
/>
</view>
</view>
<view class="dialog-buttons">
<button class="cancel-btn" @click="closeDialog">取消</button>
<button class="confirm-btn" type="primary" @click="submitReasons">确认打印</button>
</view>
</view>
</view>
</view>
</template>
@@ -106,7 +148,14 @@
disabled: false,
disabled1: false,
pcsn: '',
flag: false
flag: false,
dialogVisible: false, // 控制弹窗显示/隐藏
reasons: {
full: false, // 物料卡标签填满更换
broken: false, // 标签破损更换
other: false // 其他
},
otherRemark: '' // 其他说明文字
};
},
onLoad (options) {
@@ -120,12 +169,51 @@
}
},
methods: {
// 显示弹窗(重置表单)
showDialog() {
this.resetForm();
this.dialogVisible = true;
},
// 关闭弹窗并重置表单
closeDialog() {
this.dialogVisible = false;
this.resetForm();
},
// 重置所有选项和输入内容
resetForm() {
this.reasons = {
full: false,
broken: false,
other: false
};
this.otherRemark = '';
},
// 切换复选框状态(手动控制,避免使用 v-model 复杂对象)
toggleFull() {
this.reasons.full = !this.reasons.full;
},
toggleBroken() {
this.reasons.broken = !this.reasons.broken;
},
toggleOther() {
this.reasons.other = !this.reasons.other;
// 如果取消“其他”,清空说明内容(可选,提升体验)
if (!this.reasons.other) {
this.otherRemark = '';
}
},
submitReasons () {
this.labelPrint()
console.log(1)
this.closeDialog();
},
handleChange (e) {
if (e) {
this._queryBuckInfo(e)
}
},
async _queryBuckInfo (e) {
// this.dialogVisible = true
try {
let res = await queryBuckInfo(e)
if (res) {
@@ -204,8 +292,17 @@
// // console.log('error')
// }
// },
tolPrint() {
if (this.flag) {
this.dialogVisible = true
return
} else {
this.labelPrint()
}
},
async labelPrint () {
this.disabled1 = true
this.dialogVisible = false
this.flag = false
if (!this.val1 || JSON.stringify(this.materialData) === '{}' || JSON.stringify(this.suppData) === '{}') {
this.disabled1 = false
@@ -313,112 +410,135 @@
}
</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;
}
.custom-dialog-mask {
/* 遮罩层 */
.dialog-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
align-items: center;
z-index: 1000;
}
.custom-dialog {
width: 600rpx;
background: #fff;
border-radius: 16rpx;
/* 弹窗容器 */
.dialog-container {
width: 80%;
max-width: 300px;
background-color: #fff;
border-radius: 16px;
overflow: hidden;
animation: fadeInScale 0.2s ease-out;
}
@keyframes fadeInScale {
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
}
.dialog-title {
padding: 30rpx;
font-size: 32rpx;
font-size: 18px;
font-weight: bold;
text-align: center;
border-bottom: 1rpx solid #eee;
padding: 20px 16px 12px;
border-bottom: 1px solid #f0f0f0;
color: #333;
}
.dialog-body {
padding: 40rpx;
.dialog-content {
padding: 20px 16px;
}
.dialog-input {
width: 100%;
height: 80rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
padding: 0 20rpx;
text-align: center;
}
.dialog-footer {
.checkbox-item {
display: flex;
border-top: 1rpx solid #eee;
align-items: center;
margin-bottom: 16px;
cursor: pointer;
}
.dialog-footer button {
.checkbox-label {
font-size: 15px;
margin-left: 8px;
color: #333;
flex: 1;
}
/* 其他选项区域 */
.other-section {
margin-top: 4px;
}
.other-input {
margin-top: 12px;
margin-left: 28px; /* 与复选框文本对齐缩进 */
padding: 8px 12px;
border: 1px solid #e5e5e5;
border-radius: 8px;
font-size: 14px;
width: calc(100% - 40px);
background-color: #fafafa;
transition: all 0.2s;
}
.other-input:focus {
border-color: #007aff;
background-color: #fff;
}
/* 按钮区域 */
.dialog-buttons {
display: flex;
border-top: 1px solid #f0f0f0;
}
.dialog-buttons button {
flex: 1;
border-radius: 0;
height: 48px;
line-height: 48px;
font-size: 16px;
background: transparent;
border: none;
margin: 0;
}
.cancel-btn {
color: #666;
border-right: 1px solid #f0f0f0;
}
.cancel-btn::after {
border: none;
}
.confirm-btn {
color: #007aff;
font-weight: 500;
}
.confirm-btn::after {
border: none;
}
/* 分隔线样式 */
.button-divider {
width: 1px;
height: 24px;
background-color: #e5e5e5;
flex-shrink: 0;
}
/* 针对 checkbox 组件样式微调(可选,保证在不同平台显示一致) */
checkbox {
transform: scale(0.9);
}
</style>