diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json
index 0b0655a..fc87c6d 100644
--- a/.hbuilderx/launch.json
+++ b/.hbuilderx/launch.json
@@ -6,11 +6,15 @@
"type" : "uni-app:app-android"
},
{
- "app-plus" :
- {
- "launchtype" : "local"
- },
- "type" : "uniCloud"
- }
+ "app-plus" :
+ {
+ "launchtype" : "local"
+ },
+ "mp-weixin" :
+ {
+ "launchtype" : "local"
+ },
+ "type" : "uniCloud"
+ }
]
}
diff --git a/pages/assets/index.vue b/pages/assets/index.vue
index 9b26fe7..2db8f10 100644
--- a/pages/assets/index.vue
+++ b/pages/assets/index.vue
@@ -29,7 +29,7 @@
- 点击开始同步
+ {{ isSync ? "同步中..." : "点击开始同步" }}
@@ -53,7 +53,8 @@
btnStyle: {
"color": "#fff",
'background': "#107fc9"
- },
+ },
+ isSync:false,
}
},
methods: {
@@ -102,13 +103,14 @@
const getSql = () => {
let sql = ""
res.data?.forEach(item => {
- sql += `INSERT INTO property (id,serial,name,position,worker_name)
+ sql += `INSERT INTO property (id,serial,name,position,worker_name,remark)
VALUES (
${item.id},
${item.serial},
${item.name},
${item.position},
- ${item.worker_name}); `
+ ${item.worker_name}),
+ ${item.remark}; `
})
return sql;
}
@@ -116,7 +118,7 @@
// #ifdef APP-PLUS
androidModule.showToast("开始同步资产...")
// #endif
-
+ this.isSync = true
let res = await this.$u.api.getAll()
//先清空表
await executeSql(`
@@ -155,9 +157,12 @@
// #ifdef APP-PLUS
androidModule.showToast(`获取到${this.baseInfo.num}条资产`)
-
+ this.isSync = false
+ uni.hideLoading()
console.log(await selectFromTable(`select * from property;`));
// #endif
+
+ uni.$emit('assetsSync',{msg:'success'})
}catch(err){
console.warn('sqlite-err',err)
}
diff --git a/pages/scan/index.vue b/pages/scan/index.vue
index 2174c3d..5ed4983 100644
--- a/pages/scan/index.vue
+++ b/pages/scan/index.vue
@@ -9,6 +9,10 @@
@click="scanClick">{{ flag ? "停止扫描" : "开始扫描" }}
+
+ 资产列表
+ 清空
+
@@ -108,7 +112,7 @@
// #ifdef APP-PLUS
let androidModule = uni.requireNativePlugin('uhfr')
let receiver;
- let receiverQR;
+ let receiverQR;
let timerQR;
let main = plus.android.runtimeMainActivity();
let intent = plus.android.importClass('android.content.Intent');
@@ -172,14 +176,28 @@
active_status: '',
files: '',
remark: ''
- },
-
- qrIdList:[],
+ },
+
+ qrIdList: [],
info: [],
logs: []
}
},
methods: {
+ clear() {
+ this.info = []
+ this.fund = {
+ id: 0,
+ name: '',
+ serial: '',
+ position: '',
+ worker_name: '',
+ active_status: '',
+ files: '',
+ remark: ''
+ }
+ },
+
async getLogs() {
this.logs = await selectFromTable(`
select * from log where type = 1;
@@ -204,7 +222,7 @@
this.fund.files = filePath[1]?.savedFilePath
}
await executeSql(`
- update property set active_status = "${this.fund.active_status}",remark = "${this.fund.remark}",is_check = 1,${this.fund.files ? 'files = "' + this.fund.files + '"' : '' } where id = ${this.fund.id};
+ update property set active_status = "${this.fund.active_status}",remark = "${this.fund.remark}",is_check = 1${this.fund.files ? ',files = "' + this.fund.files + '"' : '' } where id = ${this.fund.id};
`)
uni.showToast({
icon: 'success',
@@ -227,38 +245,38 @@
receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: (context, intent) => {
plus.android.importClass(intent)
- let action = intent.getAction()
- switch (action){
- case "com.rfid.SCAN":
- let id = byteToString(intent.getExtra("data"))
- this.qrIdList.push(id)
- break;
- case "android.rfid.FUN_KEY":
- let keydown = intent.getBooleanExtra("keydown", false);
- if (!keydown) {
- this.scanClick()
- }
- break;
- }
+ let action = intent.getAction()
+ switch (action) {
+ case "com.rfid.SCAN":
+ let id = byteToString(intent.getExtra("data"))
+ this.qrIdList.push(id)
+ break;
+ case "android.rfid.FUN_KEY":
+ let keydown = intent.getBooleanExtra("keydown", false);
+ if (!keydown) {
+ this.scanClick()
+ }
+ break;
+ }
}
})
let intentFilter = plus.android.importClass('android.content.IntentFilter')
let filter = new intentFilter()
- filter.addAction("android.rfid.FUN_KEY")
+ filter.addAction("android.rfid.FUN_KEY")
filter.addAction("com.rfid.SCAN")
main.registerReceiver(receiver, filter)
},
init() {
- androidModule.initUhfrManage()
-
- //二维码扫描初始化
- let intentStart = new intent("com.rfid.SCAN_INIT")
- main.sendBroadcast(intentStart)
- let intentTime = new intent("com.rfid.SCAN_TIME")
- intentTime.putExtra("time",1000)
- let intentBroad = new intent("com.rfid.SET_SCAN_MODE")
- intentBroad.putExtra("mode",0)
+ androidModule.initUhfrManage()
+
+ //二维码扫描初始化
+ let intentStart = new intent("com.rfid.SCAN_INIT")
+ main.sendBroadcast(intentStart)
+ let intentTime = new intent("com.rfid.SCAN_TIME")
+ intentTime.putExtra("time", 1000)
+ let intentBroad = new intent("com.rfid.SET_SCAN_MODE")
+ intentBroad.putExtra("mode", 0)
main.sendBroadcast(intentBroad)
},
@@ -266,13 +284,13 @@
if (!this.flag) {
this.flag = 1
- //二维码扫描
- this.qrIdList = []
- let intentScan = new intent("com.rfid.SCAN_CMD")
- timerQR = setInterval(() => {
- main.sendBroadcast(intentScan)
- },500)
-
+ //二维码扫描
+ this.qrIdList = []
+ let intentScan = new intent("com.rfid.SCAN_CMD")
+ timerQR = setInterval(() => {
+ main.sendBroadcast(intentScan)
+ }, 500)
+
//rfid扫描
androidModule.asyncStartReading()
@@ -286,17 +304,17 @@
}
} else {
- this.flag = 0
-
- clearInterval(timerQR)
-
+ this.flag = 0
+
+ clearInterval(timerQR)
+
//rfid标签盘点
androidModule.asyncStopReading()
androidModule.tagInventoryRealTime(async res => {
let dataList = JSON.parse(res)
const getSqlIn = () => {
- return Array.from(new Set([...dataList,...this.qrIdList])).map(item => {
+ return Array.from(new Set([...dataList, ...this.qrIdList])).map(item => {
return `"${item.replace(/^1(0+)/g,"")}"`
}).toString()
}
@@ -306,7 +324,7 @@
`)
androidModule.showToast(`扫描到:${propertys.length}件资产`)
this.info = propertys
- if(this.info.length > 0)this.fund = this.info[0]
+ this.fund = propertys[0]
} catch (e) {
console.warn('sqlite-err', e);
androidModule.showToast(err)
@@ -335,11 +353,11 @@
// #endif
},
onUnload() {
- // #ifdef APP-PLUS
- //关闭二维码扫描
- let intentClose = new intent("com.rfid.CLOSE_SCAN")
- main.sendBroadcast(intentClose)
-
+ // #ifdef APP-PLUS
+ //关闭二维码扫描
+ let intentClose = new intent("com.rfid.CLOSE_SCAN")
+ main.sendBroadcast(intentClose)
+
androidModule.stopTagInventory()
androidModule.close()
main.unregisterReceiver(receiver)
@@ -353,7 +371,26 @@
console.warn('sqlite-err', e);
androidModule.showToast(err)
}
- // #endif
+ // #endif
+
+ uni.$on('uploadSuccess',() => {
+ this.clear()
+ })
+ uni.$on('assetsSync',async () => {
+ try{
+ await executeSql(`
+ DELETE from log;
+ `)
+ await executeSql(`
+ UPDATE sqlite_sequence SET seq = 0 where name = 'log';
+ `)
+ }catch(err){
+
+ }
+ })
+ },
+ destroyed() {
+ uni.$off()
}
}
diff --git a/pages/upload/index.vue b/pages/upload/index.vue
index 4fc4f4e..7168153 100644
--- a/pages/upload/index.vue
+++ b/pages/upload/index.vue
@@ -29,7 +29,7 @@
- 点击开始上传
+ {{ isUpload ? "上传中" : "点击开始上传" }}
@@ -56,7 +56,8 @@
syncTime: "",
num: 0
},
- isConnect: false,
+ isConnect: false,
+ isUpload:false,
btnStyle: {
"color": "#fff",
'background': "#107fc9"
@@ -86,14 +87,17 @@
}
androidModule.showToast("开始上传...")
+ this.isUpload = true
for(let i = 0;i < res.length;i++){
- let picRes = await uni.uploadFile({
- url:`${ROOTPATH}/index.php?s=/Home/Worker/upload.html`,
- filePath:res[i].files,
- name:"file"
- })
- res[i].files = JSON.parse(picRes[1]?.data).data?.id
+ if(res[i].files){
+ let picRes = await uni.uploadFile({
+ url:`${ROOTPATH}/index.php?s=/Home/Worker/upload.html`,
+ filePath:res[i].files,
+ name:"file"
+ })
+ res[i].files = JSON.parse(picRes[1]?.data).data?.id
+ }
}
let promiseAll = res.map(item => {
@@ -104,18 +108,20 @@
console.log(result);
androidModule.showToast(`上传成功`)
+ this.isUpload = false
//先清空表
await executeSql(`
- DELETE from property;
- `)
- await executeSql(`
- UPDATE sqlite_sequence SET seq = 0 where name = 'property';
+ delete from property where is_check = 1;
`)
+
+ //插入日志
await executeSql(`
INSERT INTO log (remark) VALUES ("数据上传");
`)
await this.getInitInfo()
+
+ uni.$emit('uploadSuccess',{msg:'success'})
}catch(err){
console.warn('sqlite-err',err)
androidModule.showToast(err)