From c68691983aa1621266bcb17a63a883dedf84e5d5 Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Fri, 21 Apr 2023 17:33:40 +0800 Subject: [PATCH] 2023-4-21 --- common/config.js | 66 ++++++++++---- pages/assets/index.vue | 31 ++++++- pages/scan/index.vue | 89 +++++++++++-------- pages/upload/index.vue | 195 ++++++++++++++++++++++++----------------- 4 files changed, 244 insertions(+), 137 deletions(-) diff --git a/common/config.js b/common/config.js index 087438b..51b1483 100644 --- a/common/config.js +++ b/common/config.js @@ -1,19 +1,49 @@ -const mode = 'devOnline'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 -let ROOTPATH = ''; //域名 -let DBNAME = 'gongguan';//sqlite数据库名称 -let DBPATH = '_doc/gongguan.db';//sqlite路径 -switch (mode) { - case 'devLocal': - ROOTPATH = "http://assets.langye.net" - break; - case 'devOnline': - ROOTPATH = "http://assets.langye.net" - break; - case 'production': - ROOTPATH = "https://xxxxx.cn" - break; - default: - throw new Error('未配置环境'); - console.log(`未配置环境`); +//const mode = 'devOnline'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 +import Vue from 'vue' +let ROOTPATH = 'http://assets.langye.net'; //域名 +let DBNAME = 'gongguan'; //sqlite数据库名称 +let DBPATH = '_doc/gongguan.db'; //sqlite路径 +function setRootpath(value) { + ROOTPATH = value ?? 'http://assets.langye.net' + uni.setStorageSync('ROOTPATH', ROOTPATH) + setTimeout(() => { + Vue.prototype.$u.http.setConfig({ + baseUrl: ROOTPATH, + showLoading: true, // 是否显示请求中的loading + loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透 + loadingText: '加载中', // 请求loading中的文字提示 + loadingTime: 5000, + originalData: true, // 是否在拦截器中返回服务端的原始数据 + // 设置自定义头部content-type + header: { + 'content-type': 'application/json;charset=UTF-8' + } + }) + },50) +} + +function getRootpath() { + return uni.getStorageSync('ROOTPATH') +} +setRootpath(getRootpath()) +// switch (mode) { +// case 'devLocal': +// ROOTPATH = "http://assets.langye.net" +// break; +// case 'devOnline': +// ROOTPATH = "http://assets.langye.net" +// break; +// case 'production': +// ROOTPATH = "https://xxxxx.cn" +// break; +// default: +// throw new Error('未配置环境'); +// console.log(`未配置环境`); +// } +export { + ROOTPATH, + DBNAME, + DBPATH, + setRootpath, + getRootpath } -export { ROOTPATH,DBNAME,DBPATH } \ No newline at end of file diff --git a/pages/assets/index.vue b/pages/assets/index.vue index e223785..33fc0cd 100644 --- a/pages/assets/index.vue +++ b/pages/assets/index.vue @@ -8,7 +8,14 @@ - + + + + 当前连接地址: + + + 确认 + 服务器连接状态: { + this.testConnect() + },100) + }, async getInitInfo(){ let time; @@ -86,9 +102,17 @@ this.isConnect = true }else{ this.isConnect = false + uni.showToast({ + icon:'none', + title:'连接失败' + }) } }).catch(err => { this.isConnect = false + uni.showToast({ + icon:'none', + title:'连接失败' + }) }) }, @@ -119,6 +143,7 @@ // #endif this.isSync = true let res = await this.$u.api.getAll() + console.log('assetapi',res.data); //先清空表 await executeSql(` DELETE from property; @@ -163,6 +188,8 @@ uni.$emit('assetsSync',{msg:'success'}) }catch(err){ console.warn('sqlite-err',err) + androidModule.showToast(err) + this.isSync = false } } }, diff --git a/pages/scan/index.vue b/pages/scan/index.vue index b6fb443..f32b40c 100644 --- a/pages/scan/index.vue +++ b/pages/scan/index.vue @@ -47,7 +47,7 @@ - 盘点 + 盘 点 @@ -79,8 +79,16 @@ + + + + + + + + - + @@ -173,6 +181,17 @@ assets_status: '', photo: '', content: '' + }, + rules: { + position: [ + { required:true,message:"请输入存放位置" } + ], + worker_name: [ + { required:true,message:"请输入保管人" } + ], + assets_status: [ + { required:true,message:"请选择资产状态" } + ], }, qrIdList: [], @@ -201,40 +220,35 @@ `) }, - async confirm() { - - if (!this.fund.assets_status) { - uni.showToast({ - icon: "none", - title: "请选择资产状态" - }) - return + async confirm() { + if(!this.fund.position || !this.fund.worker_name || !this.fund.assets_status) { + androidModule.showToast("请填写完整信息") } - try { - if (this.$refs.uUpload.lists[0]?.url) { - const filePath = await uni.saveFile({ - tempFilePath: this.$refs.uUpload.lists[0]?.url - }) - console.log(filePath); - this.fund.photo = filePath[1]?.savedFilePath - } - await executeSql(` - update property set assets_status = "${this.fund.assets_status}",content = "${this.fund.content}",is_check = 1${this.fund.photo ? ',photo = "' + this.fund.photo + '"' : '' } where assets_id = ${this.fund.assets_id}; - `) - uni.showToast({ - icon: 'success', - title: '本地保存成功' - }) - this.isShowPop = false - - await executeSql(` - INSERT INTO log (remark,type) VALUES ('本地盘点:${this.fund.name}',1); - `) - - await this.getLogs() - } catch (err) { - console.warn('sqlite-err', err) - androidModule.showToast(err) + try { + if (this.$refs.uUpload.lists[0]?.url) { + const filePath = await uni.saveFile({ + tempFilePath: this.$refs.uUpload.lists[0]?.url + }) + console.log(filePath); + this.fund.photo = filePath[1]?.savedFilePath + } + await executeSql(` + update property set position = "${this.fund.position}",worker_name = "${this.fund.worker_name}",assets_status = "${this.fund.assets_status}",content = "${this.fund.content}",is_check = 1${this.fund.photo ? ',photo = "' + this.fund.photo + '"' : '' } where assets_id = ${this.fund.assets_id}; + `) + uni.showToast({ + icon: 'success', + title: '本地保存成功' + }) + this.isShowPop = false + + await executeSql(` + INSERT INTO log (remark,type) VALUES ('本地盘点:${this.fund.name}',1); + `) + + await this.getLogs() + } catch (err) { + console.warn('sqlite-err', err) + androidModule.showToast(err) } }, @@ -309,7 +323,8 @@ androidModule.asyncStopReading() androidModule.tagInventoryRealTime(async res => { - let dataList = JSON.parse(res) + let dataList = JSON.parse(res) + const getSqlIn = () => { return Array.from(new Set([...dataList, ...this.qrIdList])).map(item => { return `"${item.replace(/^1(0+)/g,"")}"` @@ -319,7 +334,7 @@ let propertys = await selectFromTable(` select * from property where assets_id in (${getSqlIn()}); `) - androidModule.showToast(`扫描到:${propertys.length}件资产`) + androidModule.showToast(`扫描到:${propertys.length}件资产,扫描到编号:${Array.from(new Set([...dataList, ...this.qrIdList])).toString()}`) this.info = propertys this.fund = propertys[0] } catch (e) { diff --git a/pages/upload/index.vue b/pages/upload/index.vue index b9bfa0f..5c7f43d 100644 --- a/pages/upload/index.vue +++ b/pages/upload/index.vue @@ -9,6 +9,11 @@ + + 当前连接地址: + + + 确认 服务器连接状态: - {{ isUpload ? "上传中" : "点击开始上传" }} + + {{ isUpload ? "上传中" : "点击开始上传" }} @@ -37,124 +43,153 @@ -