|
@@ -51,7 +51,7 @@
|
|
|
<button class="btn" type="default" @click='stopScan' v-if="!isShowStartBtn">
|
|
|
<uni-icons type="circle-filled"></uni-icons>
|
|
|
停止扫描</button>
|
|
|
- <button class="btn" type="default" @click="toReport">
|
|
|
+ <button class="btn" type="default" @click="toReport" :loading="reportLoad">
|
|
|
<uni-icons type="upload"></uni-icons>
|
|
|
一键生成报告</button>
|
|
|
</view>
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
watch
|
|
|
} from "vue";
|
|
|
import {onLoad, onReady, onUnload} from '@dcloudio/uni-app'
|
|
|
-import {getArrValue} from "js-fast-way";
|
|
|
+import {getArrValue,arrToId,arrToKey} from "js-fast-way";
|
|
|
import mainApi from '~api/storage.js';
|
|
|
|
|
|
|
|
@@ -83,6 +83,8 @@ onReady(() => {
|
|
|
|
|
|
onLoad((options)=>{
|
|
|
type.value=options.type
|
|
|
+ codeIds.value=''
|
|
|
+ storageIds.value=''
|
|
|
if(options.type==1){
|
|
|
title.value='样品入库'
|
|
|
}else{
|
|
@@ -133,12 +135,12 @@ const keyListener = ({keyCode}) => {
|
|
|
if (isScan.value) {
|
|
|
stopScan()
|
|
|
} else {
|
|
|
- startScan()
|
|
|
+ startScan(type.value)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//开始扫描
|
|
|
+
|
|
|
//开始扫描
|
|
|
const isShowStartBtn=ref(true)
|
|
|
const scanLoad=ref(false)
|
|
@@ -172,13 +174,22 @@ const startScanData = async (data,type) => {
|
|
|
}
|
|
|
}
|
|
|
scanDatas.value = epcs
|
|
|
- codeIds.value=epcs.join(',')
|
|
|
+ if(epcs.length===1){
|
|
|
+
|
|
|
+ codeIds.value=epcs[0]
|
|
|
+ console.log(codeIds.value,'codeIds.value');
|
|
|
+ }else{
|
|
|
+ codeIds.value=epcs.join(',')
|
|
|
+ }
|
|
|
+
|
|
|
getResult(type)
|
|
|
|
|
|
}
|
|
|
+const storageIds=ref('')
|
|
|
//获取扫描结果
|
|
|
const getResult=async(type)=>{
|
|
|
- console.log('发请求');
|
|
|
+ console.log('发请求',type);
|
|
|
+ console.log(codeIds.value,'codeIds.value');
|
|
|
const { response,error, code, data } = await mainApi.getSelectRfidListById({
|
|
|
rids:codeIds.value,
|
|
|
state:type
|
|
@@ -187,9 +198,10 @@ const getResult=async(type)=>{
|
|
|
if (!error && code === 200) {
|
|
|
console.log( listArr.value,' listArr.value');
|
|
|
listArr.value = getArrValue(data);
|
|
|
-
|
|
|
+ storageIds.value=arrToId( listArr.value)
|
|
|
} else {
|
|
|
listArr.value = [];
|
|
|
+ storageIds.value=''
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -234,12 +246,12 @@ const toStorageClick=async()=>{
|
|
|
return;
|
|
|
}
|
|
|
manualStorageLoading.value = true;
|
|
|
- console.log(codeIds.value,'codeIds.value');
|
|
|
- if(codeIds.value.length<1){
|
|
|
+ console.log(storageIds.value,'storageIds.value');
|
|
|
+ if(storageIds.value.length<1){
|
|
|
return;
|
|
|
}
|
|
|
const { error, code, msg,response } = await mainApi.update({
|
|
|
- id: codeIds.value,
|
|
|
+ id: storageIds.value,
|
|
|
sampleStatus: 2,
|
|
|
});
|
|
|
console.log(response,'response');
|
|
@@ -266,8 +278,8 @@ const clearItem=(item,index)=>{
|
|
|
|
|
|
//一键生成报告
|
|
|
|
|
|
-
|
|
|
-const toReport=()=>{
|
|
|
+const reportLoad=ref(false)
|
|
|
+const toReport=async()=>{
|
|
|
if(!isShowStartBtn.value){
|
|
|
uni.showToast({
|
|
|
title: '请先停止扫描',
|
|
@@ -276,6 +288,32 @@ const toReport=()=>{
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
+ reportLoad.value = true;
|
|
|
+ console.log(listArr.value[0].id,'listArr.value[0].id');
|
|
|
+ if(storageIds.value.length<1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const { error, code, msg,response } = await mainApi.update({
|
|
|
+ id: listArr.value[0].id,
|
|
|
+ sampleStatus: 4,
|
|
|
+ expCount:0
|
|
|
+ });
|
|
|
+ console.log(response,'response');
|
|
|
+ reportLoad.value = false;
|
|
|
+ if (!error && code === 200) {
|
|
|
+ uni.showToast({
|
|
|
+ title:'操作成功',
|
|
|
+ duration: 2000,
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ getResult().then();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title:'操作失败',
|
|
|
+ duration: 2000,
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|