Files
rd_mes_uniapp/pages/les/bindMaterial.vue

155 lines
3.5 KiB
Vue
Raw Permalink Normal View History

2025-12-19 16:40:25 +08:00
<template>
2026-01-04 11:51:05 +08:00
<view class="page-wrap">
2025-12-19 16:40:25 +08:00
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-forms-item label="货位号:" name="locationCode">
2026-01-04 11:51:05 +08:00
<uni-easyinput suffixIcon="scan" @iconClick="scanLocationCodeUuid" v-model="formData.locationCode" />
2025-12-19 16:40:25 +08:00
</uni-forms-item>
<uni-forms-item label="批次号:" name="batchNo">
2026-01-04 11:51:05 +08:00
<uni-easyinput suffixIcon="scan" @iconClick="scanBatchNoUuid" v-model="formData.batchNo" />
2025-12-19 16:40:25 +08:00
</uni-forms-item>
</uni-forms>
2026-01-04 11:51:05 +08:00
<view class="btns">
<u-button type="primary" @click="handleBind" class="sub-btn">绑定</u-button>
<u-button type="warning" @click="handleUnBind" class="pri-btn">解绑</u-button>
</view>
2025-12-19 16:40:25 +08:00
</view>
</template>
<script>
import { bind, unBind } from "@/api/les/lesMaterialBind.js";
export default {
data() {
return {
2025-12-22 09:48:01 +08:00
formData: {
locationCode: null,
batchNo: null,
},
2025-12-19 16:40:25 +08:00
/** 校验规则 */
rules: {
locationCode: {
rules: [{
required: true,
errorMessage: '请输入货位号',
}, ]
},
batchNo: {
rules: [{
required: true,
errorMessage: '请选择批次号',
}, ]
},
},
}
},
methods: {
scanLocationCodeUuid() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.locationCode = res.result;
}
});
},
scanBatchNoUuid() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.batchNo = res.result;
}
});
},
handleBind() {
const _this = this;
this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定绑定该数据吗?',
success: function(res) {
if (res.confirm) {
if (_this.formData.locationCode && _this.formData.batchNo) {
_this.$modal.loading('绑定中')
bind(_this.formData).then(res => {
_this.$modal.closeLoading();
_this.$modal.msgSuccess("绑定成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
_this.$modal.msg("请将信息补充完整")
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
})
},
handleUnBind() {
const _this = this;
this.$refs.form.validate().then(res => {
uni.showModal({
title: '提示',
content: '您确定解绑该数据吗?',
success: function(res) {
if (res.confirm) {
if (_this.formData.locationCode) {
_this.$modal.loading('解绑中')
unBind(_this.formData.locationCode).then(res => {
_this.$modal.closeLoading();
2025-12-22 09:48:01 +08:00
_this.$modal.msgSuccess("解绑成功!");
2025-12-19 16:40:25 +08:00
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
_this.$modal.msg("请将信息补充完整")
}
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
})
},
}
}
2026-01-04 11:51:05 +08:00
</script>
<style scoped lang="scss">
.page-container {
width: 100%;
height: 100vh;
overflow: hidden;
padding-bottom: 60px;
/* 给按钮留位置 */
box-sizing: border-box;
}
.btns {
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-evenly;
background: #fff;
padding: 8px 0;
}
::v-deep .uni-easyinput__content-input {
height: 80rpx;
line-height: 60rpx;
display: flex;
align-items: center;
}
.btns .sub-btn,
.btns .pri-btn {
width: 47%;
height: 60rpx;
}
</style>