SmartStorage/pages/rfidOutStore/rfidOutStore.vue

508 lines
12 KiB
Vue
Raw Normal View History

2024-03-13 17:55:34 +08:00
<template>
<view>
2024-11-01 15:08:36 +08:00
<!-- <div v-if="showPrompt" class="prompt">{{ promptMessage }}</div> -->
<!-- 添加新的加载效果 -->
<div v-if="showPrompt" class="custom-loading-overlay">
<div class="custom-loading-content">
<div class="custom-spinner"></div>
<p>{{ promptMessage }}</p>
</div>
</div>
2024-03-13 17:55:34 +08:00
<view class="btn-area">
<view @click="startVeri">开始识别</view>
<view @click="stopVeri">停止识别</view>
<view @click="openPop">出库</view>
</view>
<view class="number">
<h4>
待出库数{{ waitOutNum }}
</h4>
2024-11-01 15:08:36 +08:00
<h4 style="margin-left: 15rpx;">
2024-03-13 17:55:34 +08:00
识别设备数{{ veriDeviceNum }}
</h4>
</view>
<view class="table-container" v-show="tableData.length != 0">
2024-11-01 15:08:36 +08:00
<uni-table ref="table" :loading="loading" border stripe type="selection" emptyText="暂无更多数据"
@selection-change="selectionChange">
2024-03-13 17:55:34 +08:00
<uni-tr>
<uni-th align="center">类型</uni-th>
<uni-th align="center">规格</uni-th>
<uni-th align="center">编码</uni-th>
</uni-tr>
<uni-tr v-for="(item, index) in tableData" :key="index">
<uni-td align="center">{{ item.typeName }}</uni-td>
<uni-td align="center">
<view class="name">{{ item.typeCode }}</view>
</uni-td>
<uni-td align="center">{{ item.maCode }}</uni-td>
</uni-tr>
</uni-table>
</view>
<uni-popup ref="popup1" type="center" :mask-click="false">
<view class="popup1">
<view class="pop-top">
<h4>接收类型</h4>
<uni-icons style="color: #AAAAAA; font-weight: bold;" type="closeempty" size="20"
@click="closePopup1">
</uni-icons>
</view>
<h5 style="width: 85%; margin: 2vh auto; font-weight: normal; text-align: center;">请选择接收方式</h5>
<view class="select-area">
<!-- <view @click="scanCode">二维码</view>
<view @click="codeOut">编码接收</view>
<view @click="rfidOut">RFID接收</view> -->
<uni-data-checkbox v-model="fixVal" :localdata="fixRange" @change="fixChange"></uni-data-checkbox>
</view>
<!-- <view class="ipt-area">
<uni-easyinput v-model="codeVal" placeholder="请输入编码"></uni-easyinput>
</view> -->
<view class="btn" @click="confirmDevice">确定</view>
</view>
</uni-popup>
<u-loading-page :loading="showLoading" color="#000" loading-text="获取设备中,请稍后..."></u-loading-page>
</view>
</template>
<script>
2024-11-09 21:08:18 +08:00
// const rfidMod = uni.requireNativePlugin('BNS-RfidRed');
var rfidModule = uni.requireNativePlugin("DeviceModule_RFID");
2024-03-13 17:55:34 +08:00
export default {
data() {
return {
waitOutNum: '',
veriDeviceNum: 0,
searchVal: '',
tableData: [
/* {
type: '牵引机',
model: '90KN',
code: 'NSJJ432003524010010'
},
{
type: '牵引机',
model: '120KN',
code: 'NSXX226003524010010'
},
{
type: '牵引机',
model: '150KN',
code: 'NSRR432003524010010'
} */
],
// 每页数据量
pageSize: 10,
// 当前页
pageCurrent: 1,
// 数据总量
total: 0,
loading: false,
subList: [],
sendTypeId: '',
parentId: '',
taskId: '',
fixVal: '',
fixRange: [{
text: '合格',
value: '1'
},
{
text: '待修',
value: '2'
},
{
text: '待报废',
value: '3'
}
],
2024-11-01 15:08:36 +08:00
showLoading: false,
showPrompt: false, // 控制提示框的显示状态
promptMessage: '' // 存储提示信息
2024-03-13 17:55:34 +08:00
}
},
methods: {
selectedItems() {
return this.selectedIndexs.map(i => this.tableData[i])
},
selectionChange(e) {
let that = this
that.selectedIndexs = e.detail.index.sort((a, b) => {
return a - b
})
console.log(that.selectedIndexs);
},
2024-11-01 15:08:36 +08:00
openPop() {
2024-03-13 17:55:34 +08:00
let that = this
if (this.selectedIndexs.length == 0) {
uni.showToast({
icon: 'none',
title: '未选中设备!'
})
} else {
that.subList = []
for (let i = 0; i < that.selectedIndexs.length; i++) {
that.subList.push(that.tableData[that.selectedIndexs[i]])
}
// this.$refs.popup1.open()
console.log(that.subList, that.sendTypeId);
let ifAllRight = that.subList.some(item => {
return item.typeId != that.sendTypeId
})
console.log(ifAllRight);
if (ifAllRight == true) {
uni.showToast({
icon: 'none',
title: '设备类型不完全匹配,请重新扫描!'
})
} else if (that.subList.length > that.waitOutNum) {
uni.showToast({
icon: 'none',
title: '出库数量大于待出库数量!'
})
} else {
that.subList = that.subList.map(item => {
return {
parentId: that.parentId,
typeId: that.sendTypeId,
outNum: '1',
companyId: uni.getStorageSync('userInfo').sysUser.companyId,
// backStatus: that.fixVal,
// manageType: item['manageType'],
// createBy: uni.getStorageSync('userInfo').userid,
2024-11-01 15:08:36 +08:00
maId: item['maId'],
manageType:0
2024-03-13 17:55:34 +08:00
}
})
console.log(that.subList);
// 提交编码出库申请
that.$api.fetchMaterialOutStore.subOutStoreArr(that.subList).then(res => {
console.log(res);
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: res.data.msg,
success: () => {
uni.navigateBack()
}
})
} else {
uni.showToast({
icon: 'none',
title: res.data.msg
})
}
}).catch(err => {
console.log(err);
})
}
}
},
2024-11-01 15:08:36 +08:00
confirmDevice() {
2024-03-13 17:55:34 +08:00
let that = this
if (that.fixVal == '') {
uni.showToast({
icon: 'none',
title: '请选择一种维修方式!'
})
} else {
that.subList = that.subList.map(item => {
return {
parentId: that.parentId,
typeId: that.sendTypeId,
backNum: '1',
backStatus: that.fixVal,
manageType: item['manageType'],
createBy: uni.getStorageSync('userInfo').userid,
maId: item['maId']
}
})
let param = {
taskId: that.taskId,
arr: that.subList
}
console.log(param);
// 提交设备信息
2024-11-01 15:08:36 +08:00
2024-03-13 17:55:34 +08:00
}
},
2024-11-01 15:08:36 +08:00
fixChange(e) {
2024-03-13 17:55:34 +08:00
let that = this
that.subList = []
for (let i = 0; i < that.selectedIndexs.length; i++) {
that.subList.push(that.tableData[that.selectedIndexs[i]])
}
},
/* outStore () {
let that = this
that.subList = []
for (let i = 0; i < that.selectedIndexs.length; i++) {
that.subList.push(that.tableData[that.selectedIndexs[i]])
}
that.subList = that.tableData.filter((item) => {
return item.checked == true
})
that.tableData = that.tableData.filter((item) => {
return item.checked != true
})
if (that.subList.length == 0) {
uni.showToast({
icon: 'none',
title: '请选择至少一台设备!'
})
} else {
that.subList = that.subList.map(item => {
return {
parentId: that.parentId,
typeId: that.sendTypeId,
backNum: '1',
}
})
console.log(that.subList);
}
}, */
2024-11-01 15:08:36 +08:00
startVeri() {
2024-03-13 17:55:34 +08:00
let that = this
2024-11-01 15:08:36 +08:00
that.showPrompt = true;
that.promptMessage = '识别中,请稍候...';
// 延迟关闭提示显示Toast
setTimeout(() => {
2024-11-09 21:08:18 +08:00
// let b = rfidMod.initUHF()
let b = rfidModule.init();
2024-11-01 15:08:36 +08:00
console.log(b);
2024-11-09 21:08:18 +08:00
// let goVeri = rfidMod.redTag()
let jsonData = {
"bank": 1,
"ptr": 2,
"cnt": 6,
"accessPwd": "00000000"
}
let goVeri = rfidModule.readData(jsonData)
2024-11-01 15:08:36 +08:00
console.log(goVeri);
2024-11-09 21:08:18 +08:00
if (goVeri.code == 0) {
2024-11-01 15:08:36 +08:00
that.showLoading = true
that.showPrompt = false; // 关闭提示
uni.showToast({
icon: 'none',
title: '识别成功',
success: () => {
// 调用编码获取设备信息
that.$api.fetchMaterialOutStore.searchRfid({
2024-11-09 21:08:18 +08:00
rfidCode: goVeri.data
2024-11-01 15:08:36 +08:00
}).then(res => {
console.log(res);
if (res.data.code == 200) {
that.showLoading = false
that.veriDeviceNum = that.veriDeviceNum + res.data
.data
.length
if (res.data.data.length > 0) {
for (let i = 0; i < res.data.data.length; i++) {
that.tableData.push(res.data.data[i])
}
} else {
uni.showToast({
icon: 'none',
title: "未找到相关信息"
})
}
2024-03-13 17:55:34 +08:00
}
2024-11-01 15:08:36 +08:00
}).catch(err => {
console.log(err);
})
}
})
} else if (goVeri.code == 1000) {
that.showPrompt = false; // 关闭提示
that.showLoading = false
uni.showToast({
icon: 'none',
title: '获取设备信息失败,请重新扫描!'
})
}
}, 1000)
2024-03-13 17:55:34 +08:00
},
2024-11-01 15:08:36 +08:00
stopVeri() {
2024-11-09 21:08:18 +08:00
// let endVeri = rfidMod.closeRfid()
let endVeri = rfidModule.free();
2024-03-13 17:55:34 +08:00
console.log(endVeri);
2024-11-09 21:08:18 +08:00
if (endVeri.code == 0) {
2024-03-13 17:55:34 +08:00
uni.showToast({
icon: 'none',
2024-11-09 21:08:18 +08:00
title: "停止成功"
2024-03-13 17:55:34 +08:00
})
2024-11-01 15:08:36 +08:00
} else {
uni.showToast({
icon: 'none',
2024-11-09 21:08:18 +08:00
title: "停止失败"
2024-11-01 15:08:36 +08:00
})
2024-03-13 17:55:34 +08:00
}
},
2024-11-01 15:08:36 +08:00
closePopup1() {
2024-03-13 17:55:34 +08:00
this.fixVal = ''
this.$refs.popup1.close()
}
},
onLoad(params) {
console.log(params);
this.selectedIndexs = []
this.waitOutNum = params.waitOut
this.sendTypeId = params.typeId
this.parentId = params.parentId
this.taskId = params.taskId
// 初始化rfid识别
2024-11-09 21:08:18 +08:00
// const obj = rfidMod.initUHF()
// console.log(obj);
// 使用模块前必须先初始化RDIF模块
let res = rfidModule.init();
console.log(res)
// log(JSON.stringify(res));
if (res.code == 0) {
} else if (res.code == -1) {
uni.showToast({
title: 'RFID模块加载失败'
})
}
2024-03-13 17:55:34 +08:00
}
}
</script>
<style lang="scss">
2024-11-01 15:08:36 +08:00
.btn-area {
2024-03-13 17:55:34 +08:00
width: 90%;
margin: 20rpx auto;
display: flex;
justify-content: space-between;
align-items: center;
2024-11-01 15:08:36 +08:00
view {
2024-03-13 17:55:34 +08:00
width: 30%;
box-sizing: border-box;
padding: 15rpx;
border-radius: 20rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: #169BD5;
color: #fff;
font-size: 14px;
}
2024-11-01 15:08:36 +08:00
view:last-child {
2024-03-13 17:55:34 +08:00
background-color: #70B603;
}
}
2024-11-01 15:08:36 +08:00
.number {
2024-03-13 17:55:34 +08:00
width: 90%;
margin: 20rpx auto;
display: flex;
align-items: center;
2024-11-01 15:08:36 +08:00
h4 {
2024-03-13 17:55:34 +08:00
font-weight: normal;
font-size: 12px;
display: flex;
align-items: center;
}
}
2024-11-01 15:08:36 +08:00
.table-container {
2024-03-13 17:55:34 +08:00
width: 90%;
margin: 20rpx auto;
}
2024-11-01 15:08:36 +08:00
2024-03-13 17:55:34 +08:00
.popup1 {
width: 80vw;
height: 40vh;
background-color: #fff;
border-radius: 15rpx;
overflow: hidden;
background: linear-gradient(#D9E7FE, #fff, #fff, #fff);
2024-11-01 15:08:36 +08:00
2024-03-13 17:55:34 +08:00
.pop-top {
width: 100%;
height: 5vh;
box-sizing: border-box;
padding: 0 25rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
2024-11-01 15:08:36 +08:00
2024-03-13 17:55:34 +08:00
.select-area {
width: 85%;
margin: 40rpx auto;
display: flex;
justify-content: space-around;
align-items: center;
2024-11-01 15:08:36 +08:00
2024-03-13 17:55:34 +08:00
/* view {
box-sizing: border-box;
font-size: 14px;
padding: 10rpx 20rpx;
border: 1px solid #D5D5D4;
border-radius: 20rpx;
} */
}
2024-11-01 15:08:36 +08:00
2024-03-13 17:55:34 +08:00
.ipt-area {
width: 85%;
margin: 40rpx auto;
}
2024-11-01 15:08:36 +08:00
.btn {
2024-03-13 17:55:34 +08:00
width: 60%;
margin: 2vh auto;
box-sizing: border-box;
padding: 15rpx 0;
display: flex;
justify-content: center;
align-items: center;
border-radius: 15rpx;
color: #fff;
background-color: #169BD5;
}
}
2024-11-01 15:08:36 +08:00
// 添加新的加载效果样式
.custom-loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.custom-loading-content {
background-color: white;
padding: 20px;
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
}
.custom-spinner {
width: 40px;
height: 40px;
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 10px;
}
</style>