bonus-material-app/src/pages/standardBox/codeView.vue

290 lines
9.1 KiB
Vue

<template>
<view class="accept page-common">
<uni-row :gutter="24" class="search-form">
<uni-col :span="16">
<view><uni-easyinput placeholder="请输入内容" v-model="searchValue"/></view>
</uni-col>
<uni-col :span="4">
<view class="search" @click="getCodeList()">查询</view>
</uni-col>
<!-- <uni-col :span="4">
<view class="addBtn" @click="scanStart">扫码</view>
</uni-col> -->
</uni-row>
<div class="card" style="margin-top: 10px;">
<uni-forms :model="boxInfo" label-width="200rpx" :border="true">
<uni-forms-item label="标准箱名称:" name="boxName">
<span style="height: 100%;display: flex;align-items: center;">{{ boxInfo.boxName }}</span>
</uni-forms-item>
<uni-forms-item label="标准箱编码:" name="boxCode">
<span style="height: 100%;display: flex;align-items: center;">{{ boxInfo.boxCode }}</span>
</uni-forms-item>
<uni-forms-item label="物资类型:" name="typeName">
<span style="height: 100%;display: flex;align-items: center;">{{ boxInfo.typeName }}</span>
</uni-forms-item>
<uni-forms-item label="规格型号:" name="typeModelName">
<span style="height: 100%;display: flex;align-items: center;">{{ boxInfo.typeModelName }}</span>
</uni-forms-item>
<uni-forms-item label="已录入数量:" name="devNum">
<span style="height: 100%;display: flex;align-items: center;">{{ boxInfo.devNum }}</span>
</uni-forms-item>
</uni-forms>
<div style="width: 98%;height: auto;">
<div style="margin-bottom: 10px;">绑定清单</div>
<uni-table border stripe emptyText="暂无更多数据" >
<!-- 表头行 -->
<uni-tr>
<uni-th width="70px" align="center" style="font-size: 24rpx;">编码</uni-th>
<uni-th width="60px" align="center" style="font-size: 24rpx;">状态</uni-th>
<uni-th width="60px" align="center" style="font-size: 24rpx;">录入人</uni-th>
<!-- <uni-th width="75px" align="center" style="font-size: 24rpx;">录入时间</uni-th> -->
<!-- <uni-th width="60px" align="center" style="font-size: 24rpx;">操作</uni-th> -->
</uni-tr>
<!-- 表格数据行 -->
<uni-tr v-for="item in codeList" :key="item.id">
<uni-td style="font-size: 22rpx;" align="center">{{item.maCode}}</uni-td>
<uni-td style="font-size: 22rpx;" align="center">{{item.maStatus}}</uni-td>
<uni-td style="font-size: 22rpx;" align="center">{{item.createBy}}</uni-td>
<!-- <uni-td style="font-size: 22rpx;">{{item.createTime}}</uni-td> -->
<!-- <uni-td>
<view class="uni-group">
<span style="color: red;margin-left:10px;font-size: 20rpx;" @click="delRow(item)">删除</span>
</view>
</uni-td> -->
</uni-tr>
</uni-table>
</div>
</div>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { onLoad,onShow } from '@dcloudio/uni-app'
import { getAppBoxDetailListApi,appBindMaCodeApi,appUnbindMaCodeApi } from '../../services/standard.js';
import { getMaCodeByQrCodeApi } from '../../services/index.js';
import { baseURL } from '@/utils/http'
const searchValue = ref('')
const boxInfo = ref({})
const codeList = ref([])
const imgBeseUrl = ref("")
const bmFileInfos = ref([])//请求图片参数
const getCodeList = () => {
console.log(boxInfo.value)
let param = {
"boxId":boxInfo.value.boxId,
"keyWord":searchValue.value
}
getAppBoxDetailListApi(param).then(res => {
console.log(res)
if(res.code=200){
codeList.value = res.data.rows;
if(codeList.value.length>0){
boxInfo.value.typeName=codeList.value[0].typeName;
boxInfo.value.typeModelName=codeList.value[0].typeModelName;
}
}
}).catch(error => {
console.log(error)
})
}
// 扫码识别按钮
const scanStart = () => {
console.log('编码识别--')
// 只允许通过相机扫码
// uni.scanCode({
// onlyFromCamera: true,
// scanType: ['qrCode', 'pdf417'],
// success: (res) => {
// console.log('扫码结果:' + res.result);
// let qrCode = res.result.split("qrcode=")[1]
// getMaCodeByQrCodeApi({"qrCode":qrCode}).then(res => {
// console.log(res)
// if(res.code==200){
// uni.showToast({ title: '成功', icon: 'none' })
// }else{
// uni.showToast({ title: '失败', icon: 'none' })
// }
// }).catch(error => {
// console.log(error)
// })
// console.log(qrCode)
// // bindMa(res.result)
// },
// fail: (err) => {
// // uni.showToast({
// // title: '取消',
// // icon: 'none'
// // });
// }
// });
}
//绑定接口
const bindMa = (maCode) => {
console.log(maCode)
let param = {
"maCode":maCode,
"boxId":boxInfo.value.boxId,
}
console.log(param)
appBindMaCodeApi(param).then(res => {
console.log(res)
if(res.code==200){
uni.showToast({ title: '绑定成功', icon: 'none' })
getCodeList()
}else{
uni.showToast({ title: '绑定失败', icon: 'none' })
}
}).catch(error => {
console.log(error)
})
}
//解绑
const delRow = (item) => {
console.log(item)
let param = {
"id":item.id
}
console.log(param)
appUnbindMaCodeApi(param).then(res => {
console.log(res)
if(res.code==200){
uni.showToast({ title: '解绑成功', icon: 'none' })
getCodeList()
}else{
uni.showToast({ title: '解绑失败', icon: 'none' })
}
}).catch(error => {
console.log(error)
})
}
onLoad((options)=>{
console.log(options)
boxInfo.value = JSON.parse(options.boxInfo)
boxInfo.value.typeName="";
boxInfo.value.typeModelName="";
console.log(boxInfo.value)
// getCodeList()
})
onShow(()=>{
getCodeList()
})
</script>
<style lang="scss">
.accept {
padding: 10px;
height: 95vh;
word-break: break-all;
}
.card {
padding: 10px;
background-color: #fff;
border-radius: 6px;
box-shadow: 0 2upx 4upx 0 rgba(0, 0, 0, 0.1);
:deep(.uni-forms-item--border) {
padding: 5px 0;
}
}
.coding-btn {
padding: 5rpx 0;
background-color: #409eff;
border-radius: 6rpx;
text-align: center;
color: #fff;
font-size: 14px;
}
.upload {
width: 80px;
height: 80px;
background-color: #f5f5f5;
border-radius: 6px;
display: flex;
justify-content: center;
align-items: center;
font-size: 20px;
color: #ccc;
margin-top: 10px;
}
.search-form {
display: flex;
align-items: center;
background: #fff;
padding: 20rpx;
border-radius: 20rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
:deep(.uni-easyinput__content) {
background-color: #f7f8fa;
border: 2rpx solid #e8e8e8;
border-radius: 12rpx;
height: 75rpx;
transition: all 0.3s ease;
&:focus-within {
border-color: #3784fb;
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
}
}
}
.search {
height: 60rpx;
background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
text-align: center;
line-height: 60rpx;
color: #fff;
border-radius: 12rpx;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
transition: all 0.3s ease;
&:active {
transform: translateY(2rpx);
opacity: 0.9;
}
}
.addBtn {
height: 80rpx;
background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
text-align: center;
line-height: 80rpx;
color: #fff;
border-radius: 12rpx;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
transition: all 0.3s ease;
&:active {
transform: translateY(2rpx);
opacity: 0.9;
}
}
.btn {
display: flex;
justify-content: space-around;
margin-top: 30px;
.btn-cont {
width: 40%;
height: 40px;
line-height: 40px;
text-align: center;
background-color: #3784fb;
color: #fff;
border-radius: 20px;
// 取消按钮淡蓝色
// &:first-child {
// background-color: #aacefb;
// }
}
}
</style>