2024-03-13 17:55:34 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<uni-forms ref="qrForm" :modelValue="qrFormData" label-position="top" :rules="rules" class="qr-stats">
|
|
|
|
|
|
<uni-forms-item name="typeVal" required label="设备类型">
|
|
|
|
|
|
<zxz-uni-data-select
|
|
|
|
|
|
v-model="qrFormData.typeVal"
|
|
|
|
|
|
:localdata="typeRange"
|
|
|
|
|
|
@change="typeChange"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
>
|
|
|
|
|
|
</zxz-uni-data-select>
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
<uni-forms-item name="specVal" required label="规格型号">
|
|
|
|
|
|
<uni-data-select
|
|
|
|
|
|
v-model="qrFormData.specVal"
|
|
|
|
|
|
:localdata="specRange"
|
|
|
|
|
|
@change="specChange"
|
|
|
|
|
|
></uni-data-select>
|
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
<view class="middle">
|
|
|
|
|
|
<h4 style="font-weight: normal; margin-bottom: 15rpx;">标签编号:</h4>
|
|
|
|
|
|
<span >{{ qrcode }}</span>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<uni-forms-item name="deviceCode" required label="设备编号">
|
2024-06-14 10:22:42 +08:00
|
|
|
|
<uni-easyinput
|
|
|
|
|
|
v-model="qrFormData.deviceCode"
|
|
|
|
|
|
maxlength="20"
|
|
|
|
|
|
>
|
|
|
|
|
|
</uni-easyinput>
|
2024-03-13 17:55:34 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
|
<view class="bind" @click="toggleBind">绑定</view>
|
|
|
|
|
|
</uni-forms>
|
2024-04-20 14:35:37 +08:00
|
|
|
|
<u-loading-page :loading="showLoading" color="#000" loading-text="加载中,请稍后..."></u-loading-page>
|
2024-03-13 17:55:34 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2024-04-20 14:35:37 +08:00
|
|
|
|
showLoading: false,
|
2024-03-13 17:55:34 +08:00
|
|
|
|
qrFormData: {
|
|
|
|
|
|
typeVal: '',
|
|
|
|
|
|
specVal: '',
|
|
|
|
|
|
deviceCode: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
typeVal: {
|
|
|
|
|
|
rules: [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
errorMessage: '请输设备类型!'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
specVal: {
|
|
|
|
|
|
rules: [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
errorMessage: '请输规格型号!'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
deviceCode: {
|
|
|
|
|
|
rules: [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
errorMessage: '请输设备编号!'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
qrcode: '',
|
|
|
|
|
|
typeRange: [],
|
|
|
|
|
|
specRange: [],
|
|
|
|
|
|
deviceStats: {},
|
|
|
|
|
|
showBindBtn: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
typeChange (e) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
// 根据设备类型获取规格类型
|
|
|
|
|
|
that.$api.qrcodeBinding.fetchDeviceSpec({
|
|
|
|
|
|
level: '4',
|
|
|
|
|
|
parentId: String(e.value)
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
|
that.specRange = res.data.data.map(item => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
text: item['typeName'],
|
|
|
|
|
|
value: item['typeId'],
|
|
|
|
|
|
code: item['code'],
|
|
|
|
|
|
modelCode: item['modelCode']
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
specChange (e) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
console.log(e, that.specRange);
|
|
|
|
|
|
const confirmedRange = that.specRange.filter(item => {
|
|
|
|
|
|
return item.value == e
|
|
|
|
|
|
})
|
|
|
|
|
|
console.log(confirmedRange);
|
2024-04-20 14:35:37 +08:00
|
|
|
|
that.qrFormData.deviceCode = `NS${confirmedRange[0].code}${confirmedRange[0].modelCode}`
|
2024-03-13 17:55:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
toggleBind () {
|
|
|
|
|
|
let that = this
|
2024-06-14 10:22:42 +08:00
|
|
|
|
console.log(that.qrcode, uni.getStorageSync('userInfo').sysUser.userId);
|
2024-03-13 17:55:34 +08:00
|
|
|
|
that.$refs.qrForm.validate().then(formData => {
|
2024-04-28 16:54:53 +08:00
|
|
|
|
that.showLoading = true
|
2024-06-14 10:22:42 +08:00
|
|
|
|
console.log(formData, that.qrcode);
|
2024-03-13 17:55:34 +08:00
|
|
|
|
that.$api.qrcodeBinding.bindQrcode({
|
2024-06-14 10:22:42 +08:00
|
|
|
|
binder: uni.getStorageSync('userInfo').sysUser.userId,
|
2024-03-13 17:55:34 +08:00
|
|
|
|
typeId: formData.specVal,
|
|
|
|
|
|
maCode: formData.deviceCode,
|
2024-04-20 14:35:37 +08:00
|
|
|
|
qrCode: that.qrcode,
|
|
|
|
|
|
maStatus: 15
|
2024-03-13 17:55:34 +08:00
|
|
|
|
}).then(res => {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
if (res.data.code == 200) {
|
2024-04-20 14:35:37 +08:00
|
|
|
|
that.showLoading = false
|
2024-03-13 17:55:34 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
title: res.data.msg,
|
|
|
|
|
|
success: () => {
|
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2024-04-20 14:35:37 +08:00
|
|
|
|
that.showLoading = false
|
2024-03-13 17:55:34 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
title: res.data.msg
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad(params) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
const { code } = params
|
|
|
|
|
|
console.log(code);
|
2024-04-28 16:54:53 +08:00
|
|
|
|
that.qrcode = code
|
|
|
|
|
|
// 根据扫出的编码查询设备
|
|
|
|
|
|
/* that.$api.fetchMaterialOutStore.fetchInfoByQrCode({
|
|
|
|
|
|
qrCode: code
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
console.log('fetchInfoByQrCode =================================',res);
|
|
|
|
|
|
// if (res.data.code == 200) that.deviceStats = res.data.rows[0]
|
|
|
|
|
|
if (res.data.rows.length == 0) {
|
|
|
|
|
|
that.showBindBtn = false
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
title: '未查询到设备数据!'
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
that.showBindBtn = true
|
|
|
|
|
|
that.deviceStats = res.data.rows[0]
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
}) */
|
|
|
|
|
|
// 获取机具设备类型
|
|
|
|
|
|
that.$api.qrcodeBinding.fetchDeviceType({
|
|
|
|
|
|
level: '3'
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
|
that.typeRange = res.data.data.map(item => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
text: item['typeName'],
|
|
|
|
|
|
value: item['typeId']
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2024-03-13 17:55:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
.qr-stats{
|
|
|
|
|
|
width: 90%;
|
|
|
|
|
|
margin: 30rpx auto;
|
|
|
|
|
|
.middle{
|
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
margin-bottom: 15rpx;
|
|
|
|
|
|
margin-top: 15rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.bind{
|
|
|
|
|
|
width: 60%;
|
|
|
|
|
|
margin: 5vh auto;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
padding: 15rpx 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
|
background-color: #3888FF;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|