From 5f4dc9cc6850b2c07265d47b7d2627a9b2d18a35 Mon Sep 17 00:00:00 2001 From: ancong <12345678> Date: Wed, 21 Jan 2026 17:48:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 106 ++--- src/components/uni-menu/uni-menu.vue | 170 +++++++- src/manifest.json | 295 ++++++------- src/pages/login/login.vue | 23 ++ src/pages/zhixing/addxianchang.vue | 298 +++++++------- src/pages/zhixing/fucha.vue | 10 + src/pages/zhixing/fuchaxwt.vue | 10 + src/pages/zhixing/xianchang.vue | 166 ++++++-- src/store/usershuju.ts | 387 +++++------------- .../csr-uni-data-select.vue | 20 + src/uni_modules/zero-loading/changelog.md | 55 +++ .../zero-loading/static/loading-annulus.vue | 45 ++ .../zero-loading/static/loading-atom.vue | 108 +++++ .../zero-loading/static/loading-book.vue | 80 ++++ .../zero-loading/static/loading-bounce.vue | 84 ++++ .../zero-loading/static/loading-circle.vue | 96 +++++ .../zero-loading/static/loading-cube.vue | 87 ++++ .../zero-loading/static/loading-equal.vue | 81 ++++ .../zero-loading/static/loading-eyes.vue | 78 ++++ .../zero-loading/static/loading-gear.vue | 118 ++++++ .../zero-loading/static/loading-locating.vue | 81 ++++ .../zero-loading/static/loading-photo.vue | 87 ++++ .../zero-loading/static/loading-pulse.vue | 67 +++ .../zero-loading/static/loading-radar.vue | 132 ++++++ .../zero-loading/static/loading-surround.vue | 91 ++++ .../zero-loading/static/loading-sword.vue | 81 ++++ .../zero-loading/static/loading-wobble.vue | 127 ++++++ .../components/zero-loading/zero-loading.vue | 186 +++++++++ src/uni_modules/zero-loading/package.json | 100 +++++ src/uni_modules/zero-loading/readme.md | 71 ++++ .../components/zjy-sqlite-manage/dbUtils.js | 26 +- src/utils/constant.ts | 6 +- src/utils/fileManager.js | 364 ++++++++++++++++ src/utils/http.ts | 14 +- src/utils/permissionManager.js | 93 +++++ src/utils/storage.ts | 6 +- src/utils/usersqlite/posteditxianchang.js | 199 ++++++--- src/utils/usersqlite/projects.js | 18 +- src/utils/usersqlite/projectxcdownload.js | 148 +++++++ src/utils/usersqlite/st1.js | 2 +- 40 files changed, 3445 insertions(+), 771 deletions(-) create mode 100644 src/uni_modules/zero-loading/changelog.md create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-annulus.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-atom.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-book.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-bounce.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-circle.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-cube.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-equal.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-eyes.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-gear.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-locating.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-photo.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-pulse.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-radar.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-surround.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-sword.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/static/loading-wobble.vue create mode 100644 src/uni_modules/zero-loading/components/zero-loading/zero-loading.vue create mode 100644 src/uni_modules/zero-loading/package.json create mode 100644 src/uni_modules/zero-loading/readme.md create mode 100644 src/utils/fileManager.js create mode 100644 src/utils/permissionManager.js create mode 100644 src/utils/usersqlite/projectxcdownload.js diff --git a/src/App.vue b/src/App.vue index e661f7a..f2688a5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,7 +5,8 @@ // import config from '@/config.js'; import { createNetworkMonitor } from '@/components/x-network-monitor/js_sdk/index.js'; import useshujuStore from '@/store/usershuju'; - + import permissionManager from '@/utils/permissionManager.js'; + import fileManager from '@/utils/fileManager.js'; // 创建网络监听器 @@ -31,7 +32,23 @@ // this.reloadData(); } }); + const initpermission = async () => { + //初始化权限 + // 初始化文件管理器(替换为你的实际包名) + // const packageName = 'com.skzh.xfgczlszhpt'; + + // 申请存储权限 + const hasPermission = await permissionManager.ensureStoragePermission(); + if (hasPermission) { + console.log('权限申请成功,应用准备就绪'); + // this.$store && this.$store.dispatch('app/initApp'); + await fileManager.init(); + + } else { + console.error('权限申请失败,部分功能可能无法使用'); + } + } const initConfig = () => { @@ -72,95 +89,20 @@ }); } - // // 参考了SQLite表创建语法和字段定义方式[1,4](@ref) - // const generateTableFields = (tableName, dataObject) => { - // const fields = ['id INTEGER PRIMARY KEY AUTOINCREMENT']; - // for (const key in dataObject) { - // if (Object.prototype.hasOwnProperty.call(dataObject, key)) { - // fields.push(`${key} TEXT DEFAULT ''`); - // } - // } - // fields.push(`padstatus TEXT DEFAULT '0'`); - - // // return `CREATE TABLE IF NOT EXISTS ${tableName} (${fields.join(', ')})`; - // return `CREATE TABLE IF NOT EXISTS ${tableName} (${fields.join(', ')})`; - // } - - // const inittable = () => { - // //初始化数据库准备 - // const shujuStore = useshujuStore(); - // let isopen = proxy.$dbUtils.isOpen('xiaofangdb'); //是否打开打开数据库 - // if (isopen) { - // //已打开数据库 - // console.log('isopen ' + isopen); - // } else { - // let opendb = proxy.$dbUtils.openDb('xiaofangdb'); //打开数据库 - // console.log('opendb ' + opendb); - // } - - // if (shujuStore.networkType != 'none') { - // //有网络时判断 更新数据库数据进行下载 - // console.log('fgdfg1' + shujuStore.networkType); - // shujuStore.projectDownload().then((res1 : any) => { - // console.log("555", res1) - // //下载执行中所有项目 - // // let biaofields = "CREATE TABLE IF NOT EXISTS kuanglaqu_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // if (res1.rows.length > 0) { - // let biaofieldssql = generateTableFields('projecttable', res1.rows[0]); - // console.log('项目表字段 ' + biaofieldssql); - - // //初始化表 - // proxy.$dbUtils.init("xiaofangdb", [{ - // tableName: 'projecttable', - // sql: biaofieldssql - // }]); //初始化表 - - // syncProjectData('projecttable', res1.rows) - - // } - - // }).catch((error : any) => { - // }); //获取个人资料 - - - - - - // } - - - // // let isopen = this.$dbUtils.isOpen('xiaofangdb'); //是否打开打开数据库 - // // if (isopen) { - // // //已打开数据库 - // // console.log('isopen ' + isopen); - // // } else { - // // let opendb = this.$dbUtils.openDb('xiaofangdb'); //打开数据库 - // // console.log('opendb ' + opendb); - // // } - // // //初始化表 - // // this.$dbUtils.init('xiaofangdb', [{ - // // tableName: 'xiaofang_table', - // // sql: "CREATE TABLE IF NOT EXISTS xiaofang_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // // }]); //初始化表 - - - - // } - - onLaunch(() => { + onLaunch(async () => { console.log('App Launch') + // #ifdef APP-PLUS + initConfig(); //初始化 + await initpermission(); setTimeout(() => { plus.screen.lockOrientation('landscape-primary'); plus.navigator.setFullscreen(true);//全屏隐藏状态栏 //初始化应用时触发 - initConfig(); //初始化 + + }, 500); diff --git a/src/components/uni-menu/uni-menu.vue b/src/components/uni-menu/uni-menu.vue index 6ca7a42..089b39f 100644 --- a/src/components/uni-menu/uni-menu.vue +++ b/src/components/uni-menu/uni-menu.vue @@ -129,7 +129,13 @@ 网络状态:{{shujuStore.networkType=='none'?'暂无网络':shujuStore.networkType}} - --> + + + @@ -201,6 +207,16 @@ getappConfigKey } from "@/apis/system/user" import logoimg from '@/static/logo-DN6OD_0Z.png' + import { + queryxianchangLocalDataByPadStatus, + exampleUsage + } from '@/utils/usersqlite/posteditxianchang.js' + import { + syncsprojectxcdownloadData + } from '@/utils/usersqlite/projectxcdownload.js' + + + import dbUtils from '@/uni_modules/zjy-sqlite-manage/components/zjy-sqlite-manage/dbUtils.js' export default { data() { return { @@ -503,12 +519,156 @@ }, - gengxinshuju() { - //更新数据 + // gengxinshuju() { + // //更新数据 + // if (this.shujuStore.networkType != 'none') { + // this.shujuStore.inittable(); //没网络时只是打开数据库 + // } else { + // this.$modal.msgError("当前无网络连接,请联网!") + // } + // }, + async jcsjshuju() { + //基础数据 if (this.shujuStore.networkType != 'none') { - this.shujuStore.inittable(); //没网络时只是打开数据库 + // this.shujuStore.inittable(); //没网络时只是打开数据库 + this.$modal.confirm('确定要更新全部的基础数据信息吗?').then(async () => { + this.shujuStore.setpageloadingtext("基础数据下载中...") + this.shujuStore.setpageloading(true) + const xmresults = await this.shujuStore.projectDownload() //获取项目信息 + this.shujuStore.setpageloading(false) + if (xmresults.success) { + //下载成功后 + uni.redirectTo({ + url: "/pages/zhixing/xianchang" + }) + uni.showToast({ + title: `下载成功!`, + icon: 'success' + }); + } else { + uni.showToast({ + title: `下载失败!`, + icon: 'none' + }); + } + }); + + + } else { - this.$modal.msgError("当前无网络请连接,请联网!") + this.$modal.msgError("当前无网络连接,请联网!") + } + }, + async xiazaixmshuju() { + //下载项目数据 + if (this.shujuStore.networkType != 'none') { + // this.shujuStore.inittable(); //没网络时只是打开数据库 + const xctableExists = await dbUtils.isTable('xiaofangdb', 'projectxianchangtable') + if (xctableExists) { + // 1. 先查询本地现场数据表中padstatus为2、3、4的数据 + const xianchanglocalData = await queryxianchangLocalDataByPadStatus([2, 3, 4], this.shujuStore + .activeprojectid); + // console.log("sdsa", xianchanglocalData) + let fcxwtdatasj = await dbUtils.getprojectcount('xiaofangdb', 'fcxwttable', this.shujuStore + .activeprojectid) + console.log('有无复查新问题', fcxwtdatasj) + let fcdatasj = await dbUtils.getprojectcount('xiaofangdb', 'fctable', this.shujuStore + .activeprojectid) + console.log('有无复查', fcdatasj) + if ((xianchanglocalData && xianchanglocalData.length > 0) || (fcxwtdatasj[0].projectcount !== 0 || + fcdatasj[ + 0].projectcount !== 0)) { + this.$modal.msgError("当前项目存在未上传数据请先上传!") + return; + } + } + + this.$modal.confirm(`确定要下载项目为'${this.shujuStore.activeprojetname}'的数据信息吗?`).then(async () => { + + this.shujuStore.setpageloadingtext("项目数据下载中...") + this.shujuStore.setpageloading(true) + const xcresults = await syncsprojectxcdownloadData(this.shujuStore.activeprojectid) + this.shujuStore.setpageloading(false); + if (xcresults.success) { + + //下载成功后 + uni.redirectTo({ + url: "/pages/zhixing/xianchang" + }) + uni.showToast({ + title: `下载成功!`, + icon: 'success' + }); + } else { + uni.showToast({ + title: `下载失败!`, + icon: 'none' + }); + } + }); + + + + } else { + this.$modal.msgError("当前无网络连接,请联网!") + } + }, + async shangchaunxmshuju() { + //上传项目数据 + if (this.shujuStore.networkType != 'none') { + // this.shujuStore.inittable(); //没网络时只是打开数据库 + const xctableExists = await dbUtils.isTable('xiaofangdb', 'projectxianchangtable') + if (!xctableExists) { + this.$modal.msgError("暂无可上传数据!") + return; + } else { + // 1. 先查询本地现场数据表中padstatus为2、3、4的数据 + const xianchanglocalData = await queryxianchangLocalDataByPadStatus([2, 3, 4], this.shujuStore + .activeprojectid); + + let fcxwtdatasj = await dbUtils.getprojectcount('xiaofangdb', 'fcxwttable', this.shujuStore + .activeprojectid) + console.log('有无复查新问题', fcxwtdatasj) + let fcdatasj = await dbUtils.getprojectcount('xiaofangdb', 'fctable', this.shujuStore + .activeprojectid) + console.log('有无复查', fcdatasj) + if ((xianchanglocalData && xianchanglocalData.length > 0) || (fcxwtdatasj[0].projectcount !== 0 || + fcdatasj[ + 0].projectcount !== 0)) { + + } else { + this.$modal.msgError("当前项目暂无可上传数据!") + return; + } + } + + this.$modal.confirm(`确定要上传项目为'${this.shujuStore.activeprojetname}'的数据信息吗?`).then(async () => { + this.shujuStore.setpageloadingtext("上传数据中...") + this.shujuStore.setpageloading(true) + const xmtjresults = await exampleUsage(this.shujuStore.activeprojectid) + this.shujuStore.setpageloading(false) + if (xmtjresults.success) { + + //提交成功后 + uni.redirectTo({ + url: "/pages/zhixing/xianchang" + }) + uni.showToast({ + title: `上传成功!`, + icon: 'success' + }); + } else { + uni.showToast({ + title: `上传失败!`, + icon: 'none' + }); + } + }); + + + + } else { + this.$modal.msgError("当前无网络连接,请联网!") } }, }, diff --git a/src/manifest.json b/src/manifest.json index f2ba30e..7fe2977 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,153 +1,156 @@ { - "name" : "消防工程质量数字化管理平台", - "appid" : "__UNI__CBEBC0C", - "package" : "com.skzh.xfgczlszhpt", - "description" : "消防工程质量app", - "versionName" : "1.0.1", - "versionCode" : 101, - "transformPx" : false, - /* 5+App特有相关 */ - "app-plus" : { - "usingComponents" : true, - "nvueStyleCompiler" : "uni-app", - "compilerVersion" : 3, - "splashscreen" : { - "alwaysShowBeforeRender" : true, - "waiting" : true, - "autoclose" : true, - "delay" : 0 + "name": "消防工程质量数字化管理平台", + "appid": "__UNI__CBEBC0C", + "package": "com.skzh.xfgczlszhpt", + "description": "消防工程质量app", + "versionName": "1.0.1", + "versionCode": 101, + "transformPx": false, + /* 5+App特有相关 */ + "app-plus": { + "usingComponents": true, + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + "permissions": { + "android.permission.WRITE_EXTERNAL_STORAGE": {}, + "FileSystemManager": { + "desc": "文件系统权限" + }, + "plus": { + "description": "访问系统文件", + "features": ["io", "sqlite"] + }, + "android": { + "CAMERA": {}, + "READ_EXTERNAL_STORAGE": {}, + "WRITE_EXTERNAL_STORAGE": {} + }, + "android.permission.READ_EXTERNAL_STORAGE": {} + }, + "compatible": { + "ignoreVersion": true + }, + /* 模块配置 */ + "modules": { + "Maps": {}, + "Camera": {}, + "Record": {}, + "SQLite": {} + }, + /* 应用发布信息 */ + "distribute": { + /* android打包配置 */ + "android": { + "manifestPlaceholders": { + "android:usesCleartextTraffic": "true" }, - "permissions" : { - "android.permission.WRITE_EXTERNAL_STORAGE" : {}, - "FileSystemManager" : { - "desc" : "文件系统权限" - }, - "plus" : { - "description" : "访问系统文件", - "features" : [ "io", "sqlite" ] - }, - "android" : { - "CAMERA" : {}, - "READ_EXTERNAL_STORAGE" : {}, - "WRITE_EXTERNAL_STORAGE" : {} - }, - "android.permission.READ_EXTERNAL_STORAGE" : {} - }, - "compatible" : { - "ignoreVersion" : true - }, - /* 模块配置 */ - "modules" : { - "Maps" : {}, - "Camera" : {}, - "Record" : {}, - "SQLite" : {} - }, - /* 应用发布信息 */ - "distribute" : { - /* android打包配置 */ - "android" : { - "requestLegacyExternalStorage" : true, - "packagename" : "com.skzh.xfgczlszhpt", - "permissions" : [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], - "minSdkVersion" : 21, - "manifest" : { - "application" : { - "attributes" : { - "android:requestLegacyExternalStorage" : "true" - } - } - } - }, - /* ios打包配置 */ - "ios" : { - "dSYMs" : false, - "idfa" : false - }, - /* SDK配置 */ - "sdkConfigs" : { - "ad" : {}, - "maps" : { - "amap" : { - "name" : "amap_15553236855AAFjBypAL", - "appkey_ios" : "692db8a4cd9ed6232d69cc04e56fe81e", - "appkey_android" : "692db8a4cd9ed6232d69cc04e56fe81e" - } - } - }, - "icons" : { - "android" : { - "hdpi" : "src/static/appicon/72x72.png", - "xhdpi" : "src/static/appicon/96x96.png", - "xxhdpi" : "src/static/appicon/144x144.png", - "xxxhdpi" : "src/static/appicon/192x192.png" - }, - "ios" : { - "appstore" : "" - } + "requestLegacyExternalStorage": true, + "packagename": "com.skzh.xfgczlszhpt", + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "abiFilters": ["armeabi-v7a", "arm64-v8a", "x86"], + "minSdkVersion": 21, + "manifest": { + "application": { + "attributes": { + "android:requestLegacyExternalStorage": "true" } + } } - }, - /* 快应用特有相关 */ - "quickapp" : {}, - /* 小程序特有相关 */ - "mp-weixin" : { - "appid" : "wxf7b12e274ddb9542", - "setting" : { - "urlCheck" : false, - "es6" : true, - "postcss" : false, - "minified" : true + }, + /* ios打包配置 */ + "ios": { + "dSYMs": false, + "idfa": false + }, + /* SDK配置 */ + "sdkConfigs": { + "ad": {}, + "maps": { + "amap": { + "name": "amap_15553236855AAFjBypAL", + "appkey_ios": "692db8a4cd9ed6232d69cc04e56fe81e", + "appkey_android": "692db8a4cd9ed6232d69cc04e56fe81e" + } + } + }, + "icons": { + "android": { + "hdpi": "src/static/appicon/72x72.png", + "xhdpi": "src/static/appicon/96x96.png", + "xxhdpi": "src/static/appicon/144x144.png", + "xxxhdpi": "src/static/appicon/192x192.png" }, - "usingComponents" : true - }, - "mp-alipay" : { - "usingComponents" : true - }, - "mp-baidu" : { - "usingComponents" : true - }, - "mp-toutiao" : { - "usingComponents" : true - }, - "uniStatistics" : { - "enable" : false - }, - "h5" : { - "devServer" : {}, - "sdkConfigs" : { - "maps" : { - "amap" : { - "key" : "6f0391b48bc4ebf8b6ddff94c9892af2", - "securityJsCode" : "59615c514d9e0b826bfe0b00082ac48e", - "serviceHost" : "" - } - } + "ios": { + "appstore": "" } + } + } + }, + /* 快应用特有相关 */ + "quickapp": {}, + /* 小程序特有相关 */ + "mp-weixin": { + "appid": "wxf7b12e274ddb9542", + "setting": { + "urlCheck": false, + "es6": true, + "postcss": false, + "minified": true }, - "vueVersion" : "3" -} + "usingComponents": true + }, + "mp-alipay": { + "usingComponents": true + }, + "mp-baidu": { + "usingComponents": true + }, + "mp-toutiao": { + "usingComponents": true + }, + "uniStatistics": { + "enable": false + }, + "h5": { + "devServer": {}, + "sdkConfigs": { + "maps": { + "amap": { + "key": "6f0391b48bc4ebf8b6ddff94c9892af2", + "securityJsCode": "59615c514d9e0b826bfe0b00082ac48e", + "serviceHost": "" + } + } + } + }, + "vueVersion": "3" +} \ No newline at end of file diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index 5d83373..13e6444 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -44,6 +44,10 @@ 忘记密码 --> + + + @@ -89,6 +93,25 @@ }, } }, + computed: { + activepageloadingtext() { + const shujuStore = useshujuStore(); + return shujuStore.pageloadingtext + }, + activepageloading() { + const shujuStore = useshujuStore(); + return shujuStore.pageloading + }, + + activeprojectid() { + // debugger + // return userStore.usernam + const shujuStore = useshujuStore(); + + return shujuStore.activeprojectid + }, + + }, mounted() { const userStore = useUserStore(); this.formData.username = userStore.username; diff --git a/src/pages/zhixing/addxianchang.vue b/src/pages/zhixing/addxianchang.vue index aad239c..8390098 100644 --- a/src/pages/zhixing/addxianchang.vue +++ b/src/pages/zhixing/addxianchang.vue @@ -68,12 +68,15 @@ - {{item.label}} + {{item.infopadobj.label}} - + + {{item.dw}} + + @@ -84,7 +87,7 @@ 现场验收: - @@ -126,7 +129,7 @@ 净高度(m): - @@ -138,7 +141,7 @@ 净宽度m: - @@ -150,7 +153,7 @@ 下沿据地高度m: - @@ -218,7 +221,7 @@ 净宽度m: - @@ -230,7 +233,7 @@ 净高度(m): - @@ -319,10 +322,12 @@ - m* - m + m X + + m + 是否为尽头式消防车道 @@ -332,14 +337,15 @@ - + 环形消防车道与其他车道的连通处情况: - + @@ -382,7 +388,7 @@ 宽度m: - @@ -571,8 +577,8 @@ 自动关闭时间(s): - S + S @@ -593,8 +599,8 @@ 尺寸/规格: - + @@ -1102,7 +1108,7 @@ 距地面高度(m): - @@ -1161,7 +1167,7 @@ 最不利处疏散宽度(m): - @@ -1191,7 +1197,7 @@ 疏散楼梯净宽(m): - @@ -1253,7 +1259,7 @@ 防火分区位置: - @@ -1284,7 +1290,7 @@ 疏散门净宽度(m): - @@ -1320,7 +1326,7 @@ 净宽度(m): - @@ -1332,7 +1338,7 @@ 净高度(m): - @@ -1344,7 +1350,7 @@ 耐火极限(h): - @@ -3034,7 +3040,7 @@ - A @@ -3048,7 +3054,7 @@ 配制数量: - @@ -3391,7 +3397,53 @@ this.formdata.voiceUrl = ''; }, + parseStr(str, resultInfo = "") { + const regex = /\{(\d+)\}/g; + const matches = []; + let match; + // 提取所有{数字}的位置和值 + while ((match = regex.exec(str)) !== null) { + matches.push({ + number: match[1], + start: match.index, + end: regex.lastIndex + }); + } + + // 无占位符的情况 + if (matches.length === 0) { + return { + name: str, + list: [] + }; + } + + // 提取最后一个占位符后的单位 + const lastMatch = matches[matches.length - 1]; + const dw = str.substring(lastMatch.end).trim(); + + // 构建name部分(去除所有占位符) + const namePart = str + .substring(0, lastMatch.start) + .replace(regex, '') + .trim(); + + // 解析resultInfo + const values = resultInfo.split(',').map(v => v.trim()); + + // 构建list数组 + const list = matches.map((match, index) => ({ + value: index < values.length ? values[index] : '', + maxvalue: parseInt(match.number, 10), + dw: index === matches.length - 1 ? dw : '' + })); + + return { + label: namePart, + list + }; + }, async getinfo() { //获取详情 @@ -3443,69 +3495,14 @@ } } - - // this.recordslist = JSON.parse(objitem.records) || []; let recordsl = JSON.parse(objitem.records) || []; for (let xx of recordsl) { - // let titlestr = xx.info; - // let [labelPart, valuePart] = titlestr.split('{'); - // let maxvalue = parseInt(valuePart.replace('}', ''), 10); - // xx.label = labelPart; - // xx.maxvalue = maxvalue; let info = xx.info; let resultInfo = xx.resultInfo; - let [labelPart, valuePart] = info.split('{'); - let maxvalue = parseInt(valuePart.replace('}', ''), 10); - xx.label = labelPart; - // 初始化结果数组 - xx.infopadlist = []; + xx.infopadobj = this.parseStr(info, resultInfo); + //infopadlist - // 判断是否存在冒号分隔符 - if (resultInfo.includes(',')) { - // 按冒号分割成左右两部分 - let [leftPart, rightPart] = info.split(':'); - - // 提取大括号内的数字(支持嵌套) - let max1 = leftPart.match(/\{(\d+)\}/)?.[1] || 0; - let max2 = rightPart.match(/\{(\d+)\}/)?.[1] || 0; - - // 提取单位(最后一个非数字字符) - let unit = rightPart.replace(/\d+$/, ''); - - if (resultInfo.includes(',')) { - let reslist = resultInfo.split(','); - // console.log('444444', reslist); - // 分割resultInfo并构建对象数组 - reslist.forEach((val, index) => { - xx.infopadlist.push({ - value: val, - maxvalue: index === 0 ? max1 : max2, - dw: unit || 'm' // 默认单位'm' - }); - }); - - } else { - xx.infopadlist.push({ - value: '', - maxvalue: '', - dw: ':' // 默认单位'm' - }, { - value: '', - maxvalue: '', - dw: 'm' // 默认单位'm' - }); - } - - - } else { - let maxvalue = parseInt(valuePart.replace('}', ''), 10); - xx.infopadlist.push({ - value: xx.resultInfo, - maxvalue: maxvalue, - dw: '' // 默认单位'm' - }); - } } console.log('777777777', recordsl); @@ -3628,12 +3625,16 @@ for (let mm of this.locationslist) { mm.selectFlag = null; } - for (let m of this.formdata.checkPointids) { - let index = this.locationslist.findIndex(element => element.standardLocationId == m); // 使用 findIndex 直接获取索引 - if (index != -1) { - this.locationslist[index].selectFlag = true; + if (this.formdata.checkPointids) { + for (let m of this.formdata.checkPointids) { + let index = this.locationslist.findIndex(element => element.standardLocationId == + m); // 使用 findIndex 直接获取索引 + if (index != -1) { + this.locationslist[index].selectFlag = true; + } } } + if (this.formdata.imgUrlbase64list) { this.formdata.imgUrlbase64list = JSON.stringify(this.formdata.imgUrlbase64list); } @@ -3641,9 +3642,10 @@ this.formdata.imgUrl = this.imgfileList1.toString(); // this.formdata.voiceUrl = this.voiceUrlfileList1.toString(); + if (this.formdata.records) { for (let s of this.formdata.records) { - let vallsit = s.infopadlist.map(item => item.value); + let vallsit = s.infopadobj.list.map(item => item.value); s.resultInfo = vallsit.toString(); } this.formdata.records = JSON.stringify(this.formdata.records); @@ -3746,6 +3748,11 @@ let xinzneg = await this.$dbUtils.upnewdateSQL('xiaofangdb', 'projectxianchangtable', updata, 'uuid', this .formdata .uuid); + if (xinzneg) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } console.log('更新结果:', xinzneg, this .formdata .uuid); @@ -3753,7 +3760,11 @@ console.log('马上新增11111:', updata); let xinzneg = await this.$dbUtils.addTabItems('xiaofangdb', 'projectxianchangtable', [updata]); - + if (xinzneg) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } console.log('新增结果:', xinzneg, this .formdata .uuid); @@ -3780,12 +3791,18 @@ for (let mm of this.locationslist) { mm.selectFlag = null; } - for (let m of this.formdata.checkPointids) { - let index = this.locationslist.findIndex(element => element.standardLocationId == m); // 使用 findIndex 直接获取索引 - if (index != -1) { - this.locationslist[index].selectFlag = true; + + if (this.formdata.checkPointids) { + for (let m of this.formdata.checkPointids) { + let index = this.locationslist.findIndex(element => element.standardLocationId == + m); // 使用 findIndex 直接获取索引 + if (index != -1) { + this.locationslist[index].selectFlag = true; + } } } + + if (this.formdata.imgUrlbase64list) { this.formdata.imgUrlbase64list = JSON.stringify(this.formdata.imgUrlbase64list); } @@ -3807,9 +3824,12 @@ if (this.formdata.materialActivityFiles) { this.formdata.materialActivityFiles = JSON.stringify(this.formdata.materialActivityFiles) } + + + if (this.formdata.records) { for (let s of this.formdata.records) { - let vallsit = s.infopadlist.map(item => item.value); + let vallsit = s.infopadobj.list.map(item => item.value); s.resultInfo = vallsit.toString(); } this.formdata.records = JSON.stringify(this.formdata.records); @@ -3896,6 +3916,11 @@ let xinzneg = await this.$dbUtils.upnewdateSQL('xiaofangdb', 'projectxianchangtable', updata, 'uuid', this .formdata .uuid); + if (xinzneg) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } console.log('更新结果:', xinzneg, this .formdata .uuid); @@ -3903,7 +3928,11 @@ console.log('马上新增11111:', updata); let xinzneg = await this.$dbUtils.addTabItems('xiaofangdb', 'projectxianchangtable', [updata]); - + if (xinzneg) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } console.log('新增结果:', xinzneg, this .formdata .uuid); @@ -3921,73 +3950,12 @@ this.regulatoryCompanyMaplist = JSON.parse(this.objitem.regulatoryCompanyMap) || []; // this.recordslist = JSON.parse(objitem.records) || []; let recordsl = JSON.parse(this.objitem.records) || []; - // for (let xx of recordsl) { - // let titlestr = xx.info; - // let [labelPart, valuePart] = titlestr.split('{'); - // let maxvalue = parseInt(valuePart.replace('}', ''), 10); - // xx.label = labelPart; - // xx.maxvalue = maxvalue; - - // } for (let xx of recordsl) { - // let titlestr = xx.info; - // let [labelPart, valuePart] = titlestr.split('{'); - // let maxvalue = parseInt(valuePart.replace('}', ''), 10); - // xx.label = labelPart; - // xx.maxvalue = maxvalue; let info = xx.info; let resultInfo = xx.resultInfo; - let [labelPart, valuePart] = info.split('{'); - let maxvalue = parseInt(valuePart.replace('}', ''), 10); - xx.label = labelPart; - // 初始化结果数组 - xx.infopadlist = []; - - // 判断是否存在冒号分隔符 - if (resultInfo.includes(',')) { - // 按冒号分割成左右两部分 - let [leftPart, rightPart] = info.split(':'); - - // 提取大括号内的数字(支持嵌套) - let max1 = leftPart.match(/\{(\d+)\}/)?.[1] || 0; - let max2 = rightPart.match(/\{(\d+)\}/)?.[1] || 0; - - // 提取单位(最后一个非数字字符) - let unit = rightPart.replace(/\d+$/, ''); - - if (resultInfo.includes(',')) { - let reslist = resultInfo.split(','); - // console.log('444444', reslist); - // 分割resultInfo并构建对象数组 - reslist.forEach((val, index) => { - xx.infopadlist.push({ - value: val, - maxvalue: index === 0 ? max1 : max2, - dw: unit || 'm' // 默认单位'm' - }); - }); - - } else { - xx.infopadlist.push({ - value: '', - maxvalue: '', - dw: ':' // 默认单位'm' - }, { - value: '', - maxvalue: '', - dw: 'm' // 默认单位'm' - }); - } + xx.infopadobj = this.parseStr(info, resultInfo); - } else { - let maxvalue = parseInt(valuePart.replace('}', ''), 10); - xx.infopadlist.push({ - value: xx.resultInfo, - maxvalue: maxvalue, - dw: '' // 默认单位'm' - }); - } } @@ -4008,6 +3976,13 @@ this.formdata.tableLevel4Id = null; this.formdata.tableLevel4Code = null; this.fubiaoobj = null; + this.formdata.attachmentJson = null; + this.formdata.buildingId = null; + this.formdata.checkPointids = null; + this.formdata.remark = null; + this.formdata.issue = null; + this.formdata.resultType = null; + this.formdata.checkPoint = null; if (this.formdata.attachmentType) { this.fubiaoobj = { typeid: this.formdata.attachmentType, @@ -4016,6 +3991,7 @@ jsonmap: null, datalist: [], } + if (this.formdata.attachmentJson) { this.fubiaoobj.formdata = JSON.parse(this.formdata.attachmentJson); let jsonlist = fujianjson.fubiaolist; diff --git a/src/pages/zhixing/fucha.vue b/src/pages/zhixing/fucha.vue index 60b5784..748b9d5 100644 --- a/src/pages/zhixing/fucha.vue +++ b/src/pages/zhixing/fucha.vue @@ -476,9 +476,19 @@ if (chalist.length == 0) { //没有则插入 const result = await this.$dbUtils.addTabItems('xiaofangdb', 'fctable', [updata]); + if (result) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } } else { //更新 let gengxin = await this.$dbUtils.upnewdateSQL('xiaofangdb', 'fctable', updata, 'uuid', chalist[0].uuid); + if (gengxin) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } } this.$emit("tkeventclose"); //执行父级函数 diff --git a/src/pages/zhixing/fuchaxwt.vue b/src/pages/zhixing/fuchaxwt.vue index a706ce8..509f106 100644 --- a/src/pages/zhixing/fuchaxwt.vue +++ b/src/pages/zhixing/fuchaxwt.vue @@ -533,9 +533,19 @@ if (chalist.length == 0) { //没有则插入 const result = await this.$dbUtils.addTabItems('xiaofangdb', 'fcxwttable', [updata]); + if (result) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } } else { //更新 let gengxin = await this.$dbUtils.upnewdateSQL('xiaofangdb', 'fcxwttable', updata, 'uuid', chalist[0].uuid); + if (gengxin) { + this.$modal.msgSuccess("保存成功!") + } else { + this.$modal.msgError("保存失败!") + } } this.$emit("tkeventclose"); //执行父级函数 }, diff --git a/src/pages/zhixing/xianchang.vue b/src/pages/zhixing/xianchang.vue index e8c149e..5101cbd 100644 --- a/src/pages/zhixing/xianchang.vue +++ b/src/pages/zhixing/xianchang.vue @@ -76,7 +76,7 @@ + :span-method="spanMethodWithColspan" v-if="tableshow&&projectcount"> @@ -174,14 +174,7 @@ + + 暂无当前项目数据请联网下载! - - - - - - - + + @@ -419,9 +410,19 @@ activeitemtableLevel4Id: 0, currentvalue: 0, tabsshow: true, + projectcount: 0, } }, computed: { + activepageloadingtext() { + const shujuStore = useshujuStore(); + return shujuStore.pageloadingtext + }, + activepageloading() { + const shujuStore = useshujuStore(); + return shujuStore.pageloading + }, + activeprojectid() { // debugger // return userStore.usernam @@ -469,33 +470,52 @@ onShow() { }, - onLoad() { + async onLoad() { // this.getlistinfo(); //获取检查列表 + const userStore = useUserStore(); + userStore.setparentmenutitle('执行'); + userStore.setchildrenmenutitle('现场检查'); this.queryParams.projectId = this.shujuStore.activeprojectid; - + console.error('eewrewr:', this.shujuStore.activeprojectid, this.shujuStore.activeprojetname); // console.error('项目下1级数据:', this.queryParams.projectId); if (this.queryParams.projectId) { - this.$dbUtils.getDataListAll('xiaofangdb', 'projectst1table', { projectId: this.queryParams.projectId }, { byName: 'sortNum', byType: 'asc' - }).then((data) => { + }).then(async (data) => { // shujuStore.setgongsishuju(data); console.error('项目下1级数据:', data); this.tabslist1 = data; this.queryParams.standardTableLevel1Id = this.tabslist1[0].key; + const xctableExists = await this.$dbUtils.isTable('xiaofangdb', 'projectxianchangtable') + if (!xctableExists) { + console.log("现场表不存在") + this.getjctree(); + return; + } + + let datasj = await this.$dbUtils.getprojectcount('xiaofangdb', 'projectxianchangtable', this + .queryParams + .projectId) + console.error('项目条数', datasj) + this.projectcount = datasj[0].projectcount; + if (this.projectcount == 0) { + this.getjctree(); + this.$modal.msgError("暂无当前项目数据请联网下载!"); + return; + } this.getlistinfo(); //获取查验列表 }); + + // this.getlistinfo(); //获取查验列表 } - const userStore = useUserStore(); - userStore.setparentmenutitle('执行'); - userStore.setchildrenmenutitle('现场检查'); + }, @@ -613,8 +633,11 @@ }, 100) }, - fuchfxxwt() { + fuchfxxwt(e) { // 复查发现新问题 + if (e) { + this.activeitem = e; + } if (!this.activeitem.tableLevel4Id) { this.$modal.msgError("请先创建检查点!"); return; @@ -715,6 +738,60 @@ this.imgboxshow = true; }, + recordsformatStr(str, values = "") { + if (!str) return ''; + + // 解析values参数 + const valueArray = values.split(',') + .map(v => v.trim()) + .filter(v => v !== ''); + + // 正则匹配所有{数字}占位符 + const regex = /\{(\d+)\}/g; + const matches = []; + let lastMatch = null; + + // 提取所有占位符信息 + let match; + while ((match = regex.exec(str)) !== null) { + matches.push({ + index: match.index, + length: match[0].length, + number: match[1] + }); + lastMatch = match; + } + + // 无占位符直接返回原始字符串 + if (matches.length === 0) return str; + + // 构建结果字符串 + let result = ''; + let lastIndex = 0; + let valueIndex = 0; + + // 替换所有占位符为values中的值 + for (const item of matches) { + // 添加占位符前的文本 + result += str.substring(lastIndex, item.index); + + // 添加替换值(处理值不足的情况) + const replacement = valueIndex < valueArray.length ? + String(valueArray[valueIndex]) : + ''; + + result += replacement; + + // 更新索引 + lastIndex = item.index + item.length; + valueIndex++; + } + + // 添加剩余文本(包含最后一个占位符后的单位) + result += str.substring(lastIndex); + + return result; + }, shanchujiancha() { //删除 let vm = this; @@ -838,9 +915,12 @@ this.qingchu(); console.error('标签索引改变时触发:', e); }, - changexiangmu(e) { + async changexiangmu(e) { // debugger - console.error('标签索引值:', this.currentvalue); + if (this.queryParams.projectId) { + this.shujuStore.setactiveprojectid(this.queryParams.projectId); + this.shujuStore.setactiveprojetname(e.name); + } if (this.queryParams.projectId) { this.$dbUtils.getDataListAll('xiaofangdb', 'projectst1table', { @@ -848,7 +928,7 @@ }, { byName: 'sortNum', byType: 'asc' - }).then((data) => { + }).then(async (data) => { // shujuStore.setgongsishuju(data); console.error('项目下1级数据:', data); this.currentvalue = 0; @@ -860,11 +940,35 @@ this.currentvalue = 0; this.queryParams.standardTableLevel1Id = this.tabslist1[0].key; + + const xctableExists = await this.$dbUtils.isTable('xiaofangdb', 'projectxianchangtable') + if (!xctableExists) { + console.log("现场表不存在") + this.getjctree(); + return; + } + + let datasj = await this.$dbUtils.getprojectcount('xiaofangdb', 'projectxianchangtable', this + .queryParams + .projectId) + console.error('项目条数', datasj) + this.projectcount = datasj[0].projectcount; + if (this.projectcount == 0) { + this.getjctree(); + this.$modal.msgError("暂无当前项目数据请联网下载!"); + + return; + } + console.error('标签索引值:', this.currentvalue); + + this.getlistinfo(); //获取查验列表 }); // this.getlistinfo(); //获取查验列表 } + + }, async getlistinfo() { //获取检查列表 @@ -874,7 +978,13 @@ this.activeitem = null; this.tableData = []; this.statistic = ''; + this.getjctree(); // this.clearSelection(); //清空 + const xctableExists = await this.$dbUtils.isTable('xiaofangdb', 'projectxianchangtable') + if (!xctableExists) { + console.log("现场表不存在") + return; + } let datalist = await this.$dbUtils.getDataListpadstatusAll('xiaofangdb', 'projectxianchangtable', this .queryParams); @@ -905,7 +1015,7 @@ - this.getjctree(); + }, diff --git a/src/store/usershuju.ts b/src/store/usershuju.ts index d82fb9b..8170297 100644 --- a/src/store/usershuju.ts +++ b/src/store/usershuju.ts @@ -16,12 +16,16 @@ import { exampleUsage } from '@/utils/usersqlite/posteditxianchang.js' import { parseObjectToArray, saveNetworkImage } from '@/utils/util' import { getpadlevel4project, getpadlevel4st1project, getpadlevel4companylist, getpadlevel4defaultst2, getpadlevel4list } from '@/apis/gongyong' // import { getUserProfile } from '@/apis/systemuser' - +import fileManager from '@/utils/fileManager.js' interface shujuInfoStoreInt { activeprojectid: string + activeprojetname: string xiangmushuju: any gongsishuju: any networkType: string + storagePath: string + pageloadingtext: string + pageloading: boolean } //networkType 状态 //wifi - WiFi 网络 @@ -37,16 +41,35 @@ export default defineStore( () => { const shujuInfo = ref({ activeprojectid: '', + activeprojetname: '', xiangmushuju: [], gongsishuju: [], - networkType: 'none' + networkType: 'none', + storagePath: '', + pageloadingtext: '加载中...', + pageloading: false }) //debugger shujuInfo.value.activeprojectid = storage.get(constant.activeprojectid) + shujuInfo.value.activeprojetname = storage.get(constant.activeprojetname) shujuInfo.value.xiangmushuju = storage.get(constant.xiangmushuju) shujuInfo.value.networkType = storage.get(constant.networkType) shujuInfo.value.gongsishuju = storage.get(constant.gongsishuju) + shujuInfo.value.storagePath = storage.get(constant.storagePath) + // shujuInfo.value.pageloadingtext = storage.get(constant.pageloadingtext) + // shujuInfo.value.pageloading = storage.get(constant.pageloading) + + const pageloadingtext = computed(() => { + return shujuInfo.value.pageloadingtext + }) + const pageloading = computed(() => { + return shujuInfo.value.pageloading + }) + + const storagePath = computed(() => { + return shujuInfo.value.storagePath + }) const gongsishuju = computed(() => { return shujuInfo.value.gongsishuju }) @@ -59,11 +82,31 @@ export default defineStore( const activeprojectid = computed(() => { return shujuInfo.value.activeprojectid }) + const activeprojetname = computed(() => { + return shujuInfo.value.activeprojetname + }) + function setpageloadingtext(pageloadingtext: any) { + shujuInfo.value.pageloadingtext = pageloadingtext + storage.set(constant.pageloadingtext, pageloadingtext) + } + function setpageloading(pageloading: any) { + shujuInfo.value.pageloading = pageloading + storage.set(constant.pageloading, pageloading) + } + + function setstoragePath(storagePath: any) { + shujuInfo.value.storagePath = storagePath + storage.set(constant.storagePath, storagePath) + } function setactiveprojectid(activeprojectid: any) { shujuInfo.value.activeprojectid = activeprojectid storage.set(constant.activeprojectid, activeprojectid) } + function setactiveprojetname(activeprojetname: any) { + shujuInfo.value.activeprojetname = activeprojetname + storage.set(constant.activeprojetname, activeprojetname) + } function setnetworkType(networkType: any) { shujuInfo.value.networkType = networkType @@ -217,7 +260,12 @@ export default defineStore( } } catch (error) { console.error('下载项目数据时发生错误:', error) - throw new Error(`项目数据下载失败: ${error.message}`) + return { + success: false, + data: '', + message: `项目数据下载失败: ${error.message}` + } + // throw new Error(`项目数据下载失败: ${error.message}`) } } @@ -302,8 +350,10 @@ export default defineStore( x.voiceUrllist = '' if (x.voiceUrl) { x.voiceUrllist = [] - let xbse64 = await saveNetworkImage(userStore1.allurl + x.voiceUrl) - x.voiceUrllist = [xbse64] + let result = await fileManager.saveNetworkImage(userStore1.allurl + x.voiceUrl, projectId) + x.voiceUrllist = [result] + // let xbse64 = await saveNetworkImage(userStore1.allurl + x.voiceUrl) + // x.voiceUrllist = [xbse64] } if (x.imgUrl) { x.imgUrlbase64list = [] @@ -312,13 +362,17 @@ export default defineStore( let imglist = x.imgUrl.split(',') for (let xx of imglist) { if (xx) { - let xbse64 = await saveNetworkImage(userStore1.allurl + xx) - x.imgUrlbase64list.push(xbse64) + // let xbse64 = await saveNetworkImage(userStore1.allurl + xx) + // x.imgUrlbase64list.push(xbse64) + let result = await fileManager.saveNetworkImage(userStore1.allurl + xx, projectId) + x.imgUrlbase64list.push(result) } } } else { - let xbse64 = await saveNetworkImage(userStore1.allurl + x.imgUrl) - x.imgUrlbase64list = [xbse64] + // let xbse64 = await saveNetworkImage(userStore1.allurl + x.imgUrl) + // x.imgUrlbase64list = [xbse64] + let result = await fileManager.saveNetworkImage(userStore1.allurl + x.imgUrl, projectId) + x.imgUrlbase64list = [result] } } @@ -336,8 +390,10 @@ export default defineStore( s.voiceUrllist = '' if (s.voiceUrl) { s.voiceUrllist = [] - let xbse64 = await saveNetworkImage(userStore1.allurl + s.voiceUrl) - s.voiceUrllist = [xbse64] + // let xbse64 = await saveNetworkImage(userStore1.allurl + s.voiceUrl) + // s.voiceUrllist = [xbse64] + let result = await fileManager.saveNetworkImage(userStore1.allurl + s.voiceUrl, projectId) + s.voiceUrllist = [result] } if (s.imgUrl) { s.imgUrlbase64list = [] @@ -346,13 +402,17 @@ export default defineStore( let imglist = s.imgUrl.split(',') for (let x of imglist) { if (x) { - let xbse64 = await saveNetworkImage(userStore1.allurl + x) - s.imgUrlbase64list.push(xbse64) + // let xbse64 = await saveNetworkImage(userStore1.allurl + x) + // s.imgUrlbase64list.push(xbse64) + let result = await fileManager.saveNetworkImage(userStore1.allurl + x, projectId) + s.imgUrlbase64list.push(result) } } } else { - let xbse64 = await saveNetworkImage(userStore1.allurl + s.imgUrl) - s.imgUrlbase64list = [xbse64] + // let xbse64 = await saveNetworkImage(userStore1.allurl + s.imgUrl) + // s.imgUrlbase64list = [xbse64] + let result = await fileManager.saveNetworkImage(userStore1.allurl + s.imgUrl, projectId) + s.imgUrlbase64list = [result] } } @@ -512,264 +572,6 @@ export default defineStore( throw new Error(`一级数据下载失败: ${error.message}`) } } - // async function projectDownload() { - // // return new Promise((resolve, reject) => { - // getpadlevel4project() - // .then(async (res1: any) => { - // console.log('项目下载', res1) - // //下载执行中所有项目 - // // let biaofields = "CREATE TABLE IF NOT EXISTS kuanglaqu_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // if (res1.rows.length > 0) { - // let biaofieldssql = generateTableFields('projecttable', res1.rows[0]) - // console.log('项目表字段 ' + biaofieldssql) - // if (!(await dbUtils.isTable('xiaofangdb', 'projecttable'))) { - // //表是否存在 - // //初始化表 - // await dbUtils.init('xiaofangdb', [ - // { - // tableName: 'projecttable', - // sql: biaofieldssql - // } - // ]) //初始化表 - // await syncProjectData('projecttable', res1.rows) - // } - - // // setTimeout(() => { - - // // }, 1000) - // } - // // resolve(res1) - // }) - // .catch((err) => { - // // reject(err) - // }) - // //}) - // } - // async function xianchanglistDownload(standardTableLevel1Id: string, projectid: string) { - // console.log('现场查验数据请求参数', projectid, standardTableLevel1Id) - // // return new Promise((resolve, reject) => { - // getpadlevel4list(projectid, standardTableLevel1Id) - // .then(async (res4: any) => { - // //debugger - // console.error('现场请求数据', res4) - // //下载执行中所有项目 - // // let biaofields = "CREATE TABLE IF NOT EXISTS kuanglaqu_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // if (res4.rows.length > 0) { - // for (let s of res4.rows) { - // if (s.buildingMap !== null && typeof s.buildingMap === 'object') { - // let buildingMap0 = parseObjectToArray(s.buildingMap) - // console.error('buildingMap0', buildingMap0) - // s.buildingMap = JSON.stringify(buildingMap0) - // } - // if (s.companyMap !== null && typeof s.companyMap === 'object') { - // let companyMap0 = parseObjectToArray(s.companyMap) - // console.error('companyMap0', companyMap0) - // s.companyMap = JSON.stringify(companyMap0) - // } - // if (s.regulatoryCompanyMap !== null && typeof s.regulatoryCompanyMap === 'object') { - // let regulatoryCompanyMap0 = parseObjectToArray(s.regulatoryCompanyMap) - // console.error('regulatoryCompanyMap0', regulatoryCompanyMap0) - // s.regulatoryCompanyMap = JSON.stringify(regulatoryCompanyMap0) - // } - // if (s.issueTypeMap !== null && typeof s.issueTypeMap === 'object') { - // let issueTypeMap0 = parseObjectToArray(s.issueTypeMap) - // console.error('issueTypeMap0', issueTypeMap0) - // s.issueTypeMap = JSON.stringify(issueTypeMap0) - // } - // if (s.checkResultTypeMap !== null && typeof s.checkResultTypeMap === 'object') { - // let checkResultTypeMap0 = parseObjectToArray(s.checkResultTypeMap) - // console.error('checkResultTypeMap0', checkResultTypeMap0) - // s.checkResultTypeMap = JSON.stringify(checkResultTypeMap0) - // } - - // if (s.records) { - // s.records = JSON.stringify(s.records) - // } - // if (s.location) { - // s.location = JSON.stringify(s.location) - // } - // if (s.locations) { - // s.locations = JSON.stringify(s.locations) - // } - // if (s.locationInfos) { - // s.locationInfos = JSON.stringify(s.locationInfos) - // } - // s.phaseTypes = '' - // if (s.phaseTypesControlInfo) { - // let plist = s.phaseTypesControlInfo.map((item3: any) => item3.phaseType) - // s.phaseTypesControlInfo = JSON.stringify(s.phaseTypesControlInfo) - // s.phaseTypes = JSON.stringify(plist) - // } - - // if (s.materialActivityFiles) { - // s.materialActivityFiles = JSON.stringify(s.materialActivityFiles) - // } - // if (s.standardCommonIssues) { - // s.standardCommonIssues = JSON.stringify(s.standardCommonIssues) - // } - // // if (s.logs) { - // // s.logs = JSON.stringify(s.logs) - // // } - // } - - // let biaofieldssql = generateTableFields('projectxianchangtable', res4.rows[0]) - // // console.log('现场表字段 ' + biaofieldssql) - // if (!(await dbUtils.isTable('xiaofangdb', 'projectxianchangtable'))) { - // //表是否存在 - // //初始化表 - // await dbUtils.init('xiaofangdb', [ - // { - // tableName: 'projectxianchangtable', - // sql: biaofieldssql - // } - // ]) //初始化表 - // await syncxianchangData('projectxianchangtable', res4.rows, projectid, standardTableLevel1Id) - // } - - // //setTimeout(() => { - - // // }, 1000) - // } - // // resolve(res4) - // }) - // .catch((err) => { - // // reject(err) - // }) - // // }) - // } - - // async function fenxianglistDownload(standardTableLevel1Id: string, projectid: string) { - // // return new Promise((resolve, reject) => { - // console.log('项目下2级请求参数', projectid, standardTableLevel1Id) - // getpadlevel4defaultst2(standardTableLevel1Id, projectid) - // .then(async (res5: any) => { - // //debugger - // console.log('项目下2级请求数据', res5) - // //下载执行中所有项目 - // // let biaofields = "CREATE TABLE IF NOT EXISTS kuanglaqu_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // if (res5.rows.length > 0) { - // for (let s of res5.rows) { - // s.projectId = projectid - // s.standardTableLevel1Id = standardTableLevel1Id - // } - - // let biaofieldssql = generateTableFields('projectst2table', res5.rows[0]) - // // console.log('项目下2级表字段 ' + biaofieldssql) - // if (!(await dbUtils.isTable('xiaofangdb', 'projectst2table'))) { - // //表是否存在 - // //初始化表 - // await dbUtils.init('xiaofangdb', [ - // { - // tableName: 'projectst2table', - // sql: biaofieldssql - // } - // ]) //初始化表 - // await syncst2Data('projectst2table', res5.rows, projectid, standardTableLevel1Id) - // } - - // //setTimeout(() => { - - // // }, 1000) - // } - // // resolve(res5) - // }) - // .catch((err) => { - // // reject(err) - // }) - // // }) - // } - - // async function fenbulistDownload(projectId: string) { - // // return new Promise((resolve, reject) => { - - // getpadlevel4st1project(projectId) - // .then(async (res3: any) => { - // //debugger - // // console.log('项目下1级', res3.rows) - // //下载执行中所有项目 - // // let biaofields = "CREATE TABLE IF NOT EXISTS kuanglaqu_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // if (res3.rows.length > 0) { - // for (let s of res3.rows) { - // s.projectId = projectId - // s.name = s.value - // } - - // let biaofieldssql = generateTableFields('projectst1table', res3.rows[0]) - // // console.log('项目下1级表字段 ' + biaofieldssql) - - // if (!(await dbUtils.isTable('xiaofangdb', 'projectst1table'))) { - // //表是否存在 - // //初始化表 - // await dbUtils.init('xiaofangdb', [ - // { - // tableName: 'projectst1table', - // sql: biaofieldssql - // } - // ]) //初始化表 - // await syncst1Data('projectst1table', res3.rows, projectId) - // } - - // // setTimeout(() => { - - // // }, 1000) - // } - // // resolve(res3) - // }) - // .catch((err) => { - // // reject(err) - // }) - // //}) - // } - - // async function canyudwDownload(projectId: string) { - // // return new Promise((resolve, reject) => { - // // getpadlevel4companylist({ projectId: projectId }) - // getpadlevel4companylist(projectId) - // .then(async (res2: any) => { - // //debugger - // // console.log('公司下拉', res2) - // //下载执行中所有项目 - // // let biaofields = "CREATE TABLE IF NOT EXISTS kuanglaqu_table (id INTEGER PRIMARY KEY AUTOINCREMENT," + - // // "jsondata TEXT DEFAULT '',createTime TEXT DEFAULT '',hole_info_ids TEXT DEFAULT '', drill_pipe_iddata TEXT DEFAULT '', androidurl TEXT DEFAULT '', updateTime TEXT DEFAULT ''," + - // // "shangchuan TEXT DEFAULT '',status TEXT DEFAULT '')" - // if (res2.rows.length > 0) { - // for (let s of res2.rows) { - // s.projectId = projectId - // } - - // let biaofieldssql = generateTableFields('projectgongsitable', res2.rows[0]) - // // console.log('公司表字段 ' + biaofieldssql) - // if (!(await dbUtils.isTable('xiaofangdb', 'projectgongsitable'))) { - // //表是否存在 - // //初始化表 - // await dbUtils.init('xiaofangdb', [ - // { - // tableName: 'projectgongsitable', - // sql: biaofieldssql - // } - // ]) //初始化表 - // await syncgongsiData('projectgongsitable', res2.rows, projectId) - // } - - // //setTimeout(() => { - - // // }, 1000) - // } - // // resolve(res2) - // }) - // .catch((err) => { - // // reject(err) - // }) - // // }) - // } // 下载项目信息-2 根据项目查询参与单位 async function canyudwDownload(projectId: string): Promise { @@ -836,14 +638,29 @@ export default defineStore( } if (shujuStore.networkType != 'none') { //有网络时判断 更新数据库数据进行下载 - uni.redirectTo({ - url: '/pages/login/dengdai' - }) + // uni.redirectTo({ + // url: '/pages/login/dengdai' + // }) + console.log('当前网络' + shujuStore.networkType) - - await exampleUsage() //先去提交数据 - - await shujuStore.projectDownload() //获取项目信息 + const xmtableExists = await dbUtils.isTable('xiaofangdb', 'projecttable') + if (!xmtableExists) { + //项目表不存在 + shujuStore.setpageloadingtext('基础数据数据下载中...') + shujuStore.setpageloading(true) + const xmresults = await shujuStore.projectDownload() //获取项目信息 + shujuStore.setpageloading(false) + if (xmresults.success) { + //下载成功后 + uni.redirectTo({ + url: '/pages/zhixing/xianchang' + }) + } + } else { + uni.redirectTo({ + url: '/pages/zhixing/xianchang' + }) + } } else { //没有网络 } @@ -857,6 +674,8 @@ export default defineStore( canyudwDownload, activeprojectid, setactiveprojectid, + activeprojetname, + setactiveprojetname, xiangmushuju, setxiangmushuju, setgongsishuju, @@ -864,7 +683,13 @@ export default defineStore( networkType, setnetworkType, generateTableFields, - inittable + inittable, + storagePath, + setstoragePath, + pageloadingtext, + pageloading, + setpageloadingtext, + setpageloading } }, { diff --git a/src/uni_modules/csr-uni-data-select/components/csr-uni-data-select/csr-uni-data-select.vue b/src/uni_modules/csr-uni-data-select/components/csr-uni-data-select/csr-uni-data-select.vue index 6568b08..4e64f23 100644 --- a/src/uni_modules/csr-uni-data-select/components/csr-uni-data-select/csr-uni-data-select.vue +++ b/src/uni_modules/csr-uni-data-select/components/csr-uni-data-select/csr-uni-data-select.vue @@ -192,6 +192,7 @@ // #endif // #ifdef VUE3 if (this.modelValue && this.modelValue.length > 0 && this.filterMixinDatacomResData.length > 0) { + this.current = this.modelValue.map(item => { let current = this.mixinDatacomResData.find(e => e[this.dataValue] == item @@ -207,16 +208,28 @@ // #ifndef VUE3 if (this.value || this.value == 0) { + + this.current = this.formatItemName(this.filterMixinDatacomResData.find(e => e[this.dataValue] == this.value )) } // #endif // #ifdef VUE3 + if (this.modelValue || this.value == 0) { + this.current = this.formatItemName(this.filterMixinDatacomResData.find(e => e[this.dataValue] == this.modelValue )) + + } else { + if (this.modelValue !== null && this.modelValue !== '' && this.modelValue !== undefined) { + + } else { + this.current = ""; + } + } // #endif } @@ -320,6 +333,7 @@ } }, initDefVal() { + // console.log('1sdfs8', this.current, this.modelValue) let defValue = '' if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) { defValue = this.valueCom @@ -357,6 +371,7 @@ this.currentArr = [] } } else { + // console.log('1sdfs7', this.current, this.modelValue) // const def = this.mixinDatacomResData.find(item => item[this.dataValue] === defValue) const def = this.mixinDatacomResData.find(item => item[this.dataValue] == defValue) this.current = def ? this.formatItemName(def) : '' @@ -422,8 +437,10 @@ } this.filterInput = "" } else { + this.showSelector = false this.current = this.formatItemName(item) + if (this.filterable) { this.filterInput = item[this.dataKey] } @@ -452,6 +469,7 @@ .dataValue])) this.$emit('change', currentArr) } else { + this.$emit('input', val) this.$emit('update:modelValue', val) const current = this.mixinDatacomResData.find(item => val == item[this.dataValue]) @@ -483,12 +501,14 @@ }) if (this.filterable && this.current && this.showSelector) { if (!this.multiple) { + this.placeholderOld = this.current // this.filterInput = "" } } else if (this.filterable && !this.current && !this.showSelector) { if (this.placeholderOld != this.placeholder) { if (!this.multiple) { + this.current = this.placeholderOld } } diff --git a/src/uni_modules/zero-loading/changelog.md b/src/uni_modules/zero-loading/changelog.md new file mode 100644 index 0000000..36d68f3 --- /dev/null +++ b/src/uni_modules/zero-loading/changelog.md @@ -0,0 +1,55 @@ +## 1.4.3(2025-10-22) +### 增加两个动画 +| book | 书籍 (自定义颜色) | +| cube | 立方体 (自定义颜色) | +## 1.4.2(2025-04-03) +## 增加两个动画 +| locating | 定位 (自定义颜色) | +| photo | 照片 (自定义颜色) | +## 1.4.1(2024-07-02) +### 1. 增加动画equal(等边), wobble(摇摆) +### 2. 原来的triangle(三角)改为surround(环绕) +### 3. 新增可自定义颜色项 +## 1.4.0(2024-06-28) + +## 增加 loading 加载文字提醒配置项,默认 false + +## 1.3.2(2023-10-31) + +修改遮罩默认透明度为 0.1 + +## 1.3.1(2023-10-31) + +## 新增支持,自定义动画颜色(仅部分动画支持) + +## 新增动画-annulus(圆环) + +## 1.3.0(2023-08-11) + +支持 vue3 使用, 增加动画类型 radar(雷达) + +## 1.2.2(2023-06-12) + +增加 maskOpacity, maskMini, maskDark 自定义参数, 提供更丰富的自定义遮罩层能力 + +## 1.2.1(2022-09-09) + +增加齿轮动画 type=gear + +## 1.2.0(2022-05-27) + +1. 增加加载类型-剑气(sword),原子(atom) +2. 默认类型改为 atom +3. 遮罩透明度调整 + +## 1.1.1(2022-04-02) + +更新使用说明 + +## 1.1.0(2022-02-23) + +增加 type="love" 的心形加载动画 + +## 1.0.0(2022-01-28) + +首次发布 diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-annulus.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-annulus.vue new file mode 100644 index 0000000..260301f --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-annulus.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-atom.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-atom.vue new file mode 100644 index 0000000..3b3b75e --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-atom.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-book.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-book.vue new file mode 100644 index 0000000..2faff0c --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-book.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-bounce.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-bounce.vue new file mode 100644 index 0000000..860d23d --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-bounce.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-circle.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-circle.vue new file mode 100644 index 0000000..958bb14 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-circle.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-cube.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-cube.vue new file mode 100644 index 0000000..0999fed --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-cube.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-equal.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-equal.vue new file mode 100644 index 0000000..b68b86c --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-equal.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-eyes.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-eyes.vue new file mode 100644 index 0000000..f7a18d1 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-eyes.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-gear.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-gear.vue new file mode 100644 index 0000000..19ce873 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-gear.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-locating.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-locating.vue new file mode 100644 index 0000000..7e140ec --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-locating.vue @@ -0,0 +1,81 @@ + + + + + \ No newline at end of file diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-photo.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-photo.vue new file mode 100644 index 0000000..3c9b383 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-photo.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-pulse.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-pulse.vue new file mode 100644 index 0000000..9c32c7e --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-pulse.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-radar.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-radar.vue new file mode 100644 index 0000000..ebafa85 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-radar.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-surround.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-surround.vue new file mode 100644 index 0000000..0e47a11 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-surround.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-sword.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-sword.vue new file mode 100644 index 0000000..8efb848 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-sword.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/static/loading-wobble.vue b/src/uni_modules/zero-loading/components/zero-loading/static/loading-wobble.vue new file mode 100644 index 0000000..d8f6283 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/static/loading-wobble.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/uni_modules/zero-loading/components/zero-loading/zero-loading.vue b/src/uni_modules/zero-loading/components/zero-loading/zero-loading.vue new file mode 100644 index 0000000..a8ec034 --- /dev/null +++ b/src/uni_modules/zero-loading/components/zero-loading/zero-loading.vue @@ -0,0 +1,186 @@ + + + + + diff --git a/src/uni_modules/zero-loading/package.json b/src/uni_modules/zero-loading/package.json new file mode 100644 index 0000000..47e5eb7 --- /dev/null +++ b/src/uni_modules/zero-loading/package.json @@ -0,0 +1,100 @@ +{ + "id": "zero-loading", + "displayName": "zero-loading(加载动画)", + "version": "1.4.3", + "description": "纯css加载动画, 一个标签元素即可实现炫酷的全屏loading效果,支持vue2,vue3", + "keywords": [ + "loading", + "加载动画", + "css动画", + "加载" +], + "repository": "", + "engines": { + "HBuilderX": "^3.1.0", + "uni-app": "^4.71", + "uni-app-x": "^4.71" + }, + "dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "插件不采集任何数据", + "permissions": "无" + }, + "npmurl": "", + "type": "component-vue", + "darkmode": "x", + "i18n": "x", + "widescreen": "x" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "√", + "aliyun": "√", + "alipay": "√" + }, + "client": { + "uni-app": { + "vue": { + "vue2": "√", + "vue3": "√" + }, + "web": { + "safari": "√", + "chrome": "√" + }, + "app": { + "vue": "√", + "nvue": "-", + "android": "√", + "ios": "√", + "harmony": "√" + }, + "mp": { + "weixin": "√", + "alipay": "√", + "toutiao": "√", + "baidu": "√", + "kuaishou": "√", + "jd": "√", + "harmony": "√", + "qq": "√", + "lark": "√" + }, + "quickapp": { + "huawei": "-", + "union": "-" + } + }, + "uni-app-x": { + "web": { + "safari": "-", + "chrome": "-" + }, + "app": { + "android": "-", + "ios": "-", + "harmony": "-" + }, + "mp": { + "weixin": "-" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/uni_modules/zero-loading/readme.md b/src/uni_modules/zero-loading/readme.md new file mode 100644 index 0000000..6064ad4 --- /dev/null +++ b/src/uni_modules/zero-loading/readme.md @@ -0,0 +1,71 @@ +# zero-loading + +> 仅测试于 vue2, vue3, 微信小程序. 其他平台自行测试 + +## 使用方法 + +导入 `uni_modules` 后直接使用即可 + +提供多种加载动画类型,传入 type 改变 loading 样式,不传默认 circle + +### 全屏使用 + +```html + +``` + +### 局部使用 + +**父元素的 `position` 记得改为 `relative` 不然可能影响效果** + +```html + +``` + +## 参数说明 + +| 参数 | 类型 | 默认值 | 描述 | +| ----------- | -------- | --------- | ---------------------------------------------- | +| type | String | atom | 样式 | +| position | String | fixed | 定位方式 | +| zIndex | Number | 9 | | +| mask | Boolean | false | 是否需要遮罩 (默认为全屏遮罩,背景色默认为黑色) | +| maskOpacity | Number | 0.1 | 遮罩透明度 | +| maskMini | Boolean | false | 传入 true 时,使用小遮罩 | +| maskDark | Boolean | true | 传入 false 时,遮罩背景色为白色 | +| color | String | #0396FF | 自定义颜色,仅部分支持 | +| showText | showText | false | 是否显示文字 | +| text | String | 加载中... | 文本内容 | +| textSize | String | 28rpx | 文字大小 | +| textColor | String | #333333 | 文字颜色 | +| textGap | String | 40rpx | 文字与 loading 动画的间距 | + +### type 可选值: + +| type 值 | 描述 | +| -------- | ----------------- | +| book | 书籍 (自定义颜色) | +| cube | 立方体 (自定义颜色) | +| locating | 定位 (自定义颜色) | +| photo | 照片 (自定义颜色) | +| equal | 等边 (自定义颜色) | +| wobble | 摇摆 (自定义颜色) | +| annulus | 圆环 (自定义颜色) | +| sword | 剑气 (自定义颜色) | +| atom | 原子 (自定义颜色) | +| pulse | 脉冲 (自定义颜色) | +| circle | 圆圈 (自定义颜色) | +| eyes | 眼睛 | +| surround | 环绕 | +| bounce | 弹跳 | +| radar | 雷达 | +| gear | 齿轮 | +| ~~love~~ | ~~爱心~~ (已废弃) | +| ~~sun~~ | ~~太阳~~(已废弃) | + +插件预览: +![code](https://cdn.zerojs.cn/image/common/code-z_1722414660881_1.jpg?imageMogr2/thumbnail/200x) +[](https://ext.dcloud.net.cn/plugin?id=7339) +> 小程序搜索: 零技术 + +> 预览的小程序不一定能及时更新当前插件 diff --git a/src/uni_modules/zjy-sqlite-manage/components/zjy-sqlite-manage/dbUtils.js b/src/uni_modules/zjy-sqlite-manage/components/zjy-sqlite-manage/dbUtils.js index 7015e1e..cb2d16b 100644 --- a/src/uni_modules/zjy-sqlite-manage/components/zjy-sqlite-manage/dbUtils.js +++ b/src/uni_modules/zjy-sqlite-manage/components/zjy-sqlite-manage/dbUtils.js @@ -1,13 +1,17 @@ /** * 打开数据库 */ +import useshujuStore from '@/store/usershuju' const openDb = (name) => { //如果数据库存在则打开,不存在则创建。 + //console.error('dsiasdjajd', `${useshujuStore().storagePath}/${name}.db`) return new Promise((resolve, reject) => { plus.sqlite.openDatabase({ name: name, //数据库名称 - path: `_doc/${name}.db`, //数据库地址 + // path: `_doc/${name}.db`, //数据库地址 // location: 'default', // 存储位置(默认应用私有目录) + path: `${useshujuStore().storagePath}/${name}.db`, //数据库地址 + success(e) { console.info("数据库打开成功", e) resolve(e); @@ -1181,6 +1185,25 @@ const deleteProjectIdData = async (dbName, tabName, projectId = '', standardTabl // } // return totalDeleted; // }; + +// 查询单个项目在表里的数据条数 +const getprojectcount = async (dbName, tabName, projectId = '') => { + let sql = `select count(*) as projectcount from ${tabName} where projectId = '${projectId}'` + // console.log('das', sql) + return new Promise((resolve, reject) => { + plus.sqlite.selectSql({ + name: dbName, + sql: sql, + success(e) { + resolve(e); + }, + fail(e) { + console.log(e) + reject(e); + } + }) + }) +} export default { openDb, //打开数据库 init, //初始化数据库 @@ -1206,4 +1229,5 @@ export default { clearTableWithReset, //清空表 delResetTable, // 清空数据表 deleteProjectIdData, //清空项目id等于值的数据表并且uuid 不重置 + getprojectcount, //查询单个项目在表里的数据条数 } \ No newline at end of file diff --git a/src/utils/constant.ts b/src/utils/constant.ts index 8d75b1e..6b5c486 100644 --- a/src/utils/constant.ts +++ b/src/utils/constant.ts @@ -20,7 +20,11 @@ const constant = { networkType: 'vuex_networkType', xiangmushuju: 'vuex_xiangmushuju', activeprojectid: 'vuex_activeprojectid', - gongsishuju: 'vuex_gongsishuju' + activeprojetname: 'vuex_activeprojetname', + gongsishuju: 'vuex_gongsishuju', + storagePath: 'vuex_storagePath', + pageloadingtext: 'vuex_pageloadingtext', + pageloading: 'vuex_pageloading' } export default constant diff --git a/src/utils/fileManager.js b/src/utils/fileManager.js new file mode 100644 index 0000000..63ae202 --- /dev/null +++ b/src/utils/fileManager.js @@ -0,0 +1,364 @@ +import useshujuStore from '@/store/usershuju' +export class FileManager { + constructor() { + this.basePath = '/storage/emulated/0/Android/data/uni.app.UNICBEBC0C'; + this.packageName = ''; // 将在初始化时设置 + this.privateStoragePath = ""; + } + + // 初始化包名 + init() { + //plus.io.PUBLIC_DOCUMENTS ---公共文档目录 /storage/emulated/0/Android/data/io.dcloud.HBuilder/documents/myAppData/ + //plus.io.PRIVATE_DOC ---应用私有文档目录 /storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/myAppData/ + + // 1. 获取应用的私有文档目录 + plus.io.requestFileSystem(plus.io.PUBLIC_DOCUMENTS, function(fs) { + // fs.root 是目录对象,代表应用的私有文档目录根目录 (/data/data//files/) + // /storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/myAppData/ + // 2. 创建目录 (myAppData) + fs.root.getDirectory('files', { + create: true + }, function(dirEntry) { + console.log('目录创建/获取成功:', dirEntry.fullPath); + + useshujuStore().setstoragePath(dirEntry.fullPath) + // this.privateStoragePath = dirEntry.fullPath; + + // 3. 在目录中创建文件 (userInfo.json) + // dirEntry.getFile('userInfo.json', { + // create: true + // }, function(fileEntry) { + // console.log('文件创建/获取成功:', fileEntry.fullPath); + + // 4. 创建文件写入对象 + // fileEntry.createWriter(function(writer) { + // writer.onwrite = function(e) { + // console.log('写入完成!'); + // }; + // writer.onerror = function(e) { + // console.error('写入失败:', e.message); + // }; + + // // 5. 写入内容 + // const content = JSON.stringify({ + // name: 'uni-app', + // version: '3.0' + // }); + // writer.write(content); + // }, function(e) { + // console.error('获取写入对象失败:', e.message); + // }); + // }, function(e) { + // console.error('获取文件失败:', e.message); + // }); + // }, function(e) { + // console.error('获取目录失败:', e.message); + // }); + }, function(e) { + console.error('请求文件系统失败:', e.message); + }); + }) + + } + + + // 从URL提取文件名 + generateFileName(url) { + // try { + // const urlParts = url.split('/'); + // const datePart = urlParts[urlParts.length - 2].replace(/-/g, ''); + // const fileName = urlParts[urlParts.length - 1]; + // return datePart + fileName; + // } catch (error) { + // console.error('文件名生成错误:', error); + // // 备用方案:使用时间戳 + // return Date.now() + '.jpg'; + // } + // 提取原始文件名 + let fileName = url.substring(url.lastIndexOf('/') + 1); + + // 去除查询参数(如果有) + if (fileName.includes('?')) { + fileName = fileName.substring(0, fileName.indexOf('?')); + } + + // 提取日期部分并格式化 + const dateMatch = url.match(/\/(\d{4}-\d{2}-\d{2})\//); + if (dateMatch) { + const datePart = dateMatch[1].replace(/-/g, ''); + // 将日期部分添加到文件名前面 + fileName = datePart + fileName; + } + + return fileName; + } + + // 获取项目文件夹路径 + getProjectFolderPath(projectId) { + return `${useshujuStore().storagePath}project${projectId}/`; + } + + // 检查文件是否存在 + async fileExists(filePath) { + return new Promise((resolve) => { + plus.io.resolveLocalFileSystemURL(filePath, () => { + resolve(true); + }, () => { + resolve(false); + }); + }); + } + + // 下载并保存图片 + async saveNetworkImage(imageUrl, projectId) { + try { + // 生成文件名和路径 + + const projectPath = this.getProjectFolderPath(projectId); + + // console.error('保存图片lj', filePath) + + // 获取文件系统 + const fs = await this.requestFileSystem(); + // 获取或创建项目目录 + const dirEntry = await this.getDirectory(fs, projectId); + // 格式化文件名 + const fileName = this.generateFileName(imageUrl); + // 检查文件是否已存在 + console.error(`文件${fileName}`) + const filePath = projectPath + fileName; + const fileExists = await this.checkFileExists(dirEntry, fileName); + if (fileExists) { + + console.error(`文件 ${fileName} 已存在,无需重复保存`) + return filePath; + } + console.error(`文件1${fileExists}`) + + const tempFilePath = await this.downloadFile(imageUrl, fileName); + const savedPath = await this.saveFileToDirectory(dirEntry, tempFilePath, fileName); + return savedPath; + // const tempFilePath = await this.downloadFile(imageUrl, filePath); + // // 检查文件是否已存在 + // const exists = await this.fileExists(filePath); + // console.error('保存图片lj1111111', exists) + // if (exists) { + // return { + // success: false, + // message: '文件已存在', + // path: filePath + // }; + // } + + // 确保项目目录存在 + // await this.ensureDirectoryExists(projectPath); + // console.error('保存图片0', imageUrl, filePath) + // 下载文件 + // const downloadResult = await this.downloadFile(imageUrl, filePath); + + // return { + // success: true, + // message: '保存成功', + // // path: filePath, + // fileName: fileName + // }; + + } catch (error) { + console.error('保存图片失败:', error); + return { + success: false, + message: '保存失败: ' + error.message + }; + } + } + + // 下载文件 + // async downloadFile(url, filePath) { + // console.error('保存图片', url, filePath) + // return new Promise((resolve, reject) => { + // const downloadTask = plus.downloader.createDownload(url, { + // filename: filePath + // }, (download, status) => { + // if (status === 200) { + // resolve(download); + // } else { + // reject(new Error(`下载失败,状态码: ${status}`)); + // } + // }); + + // downloadTask.start(); + // }); + // } + async downloadFile(url, fileName) { + console.error('保存图片', url, fileName) + return new Promise((resolve, reject) => { + uni.downloadFile({ + url: url, + success: (res) => { + if (res.statusCode === 200) { + resolve(res.tempFilePath); + } else { + reject(`下载失败,状态码: ${res.statusCode}`); + } + }, + fail: (error) => { + reject(error); + } + }); + }); + } + + + // 清空项目文件夹 + async clearProjectFolder(projectId) { + try { + const projectPath = this.getProjectFolderPath(projectId); + + return new Promise((resolve, reject) => { + plus.io.resolveLocalFileSystemURL(projectPath, (entry) => { + entry.removeRecursively(() => { + resolve({ + success: true, + message: '文件夹清空成功' + }); + }, (error) => { + reject(new Error('清空失败: ' + error.message)); + }); + }, () => { + resolve({ + success: true, + message: '文件夹不存在,无需清空' + }); + }); + }); + } catch (error) { + return { + success: false, + message: '清空失败: ' + error.message + }; + } + } + + // 获取项目文件夹中的文件列表 + async getProjectFiles(projectId) { + try { + const projectPath = this.getProjectFolderPath(projectId); + + return new Promise((resolve) => { + plus.io.resolveLocalFileSystemURL(projectPath, (entry) => { + const reader = entry.createReader(); + reader.readEntries((entries) => { + const files = entries.map(entry => ({ + name: entry.name, + path: entry.fullPath, + isDirectory: entry.isDirectory, + size: entry.size || 0 + })); + resolve(files); + }, () => { + resolve([]); + }); + }, () => { + resolve([]); + }); + }); + } catch (error) { + console.error('获取文件列表失败:', error); + return []; + } + } + + + // 请求文件系统 + requestFileSystem() { + return new Promise((resolve, reject) => { + plus.io.requestFileSystem(plus.io.PUBLIC_DOCUMENTS, (fs) => { + resolve(fs); + }, (error) => { + reject(error); + }); + }); + } + + // 创建或获取目录 + async getDirectory(fs, projectId) { + const dirName = `files/project${projectId}`; + return new Promise((resolve, reject) => { + fs.root.getDirectory(dirName, { + create: true + }, (dirEntry) => { + resolve(dirEntry); + }, (error) => { + reject(error); + }); + }); + } + + // 检查文件是否存在 + async checkFileExists(dirEntry, fileName) { + return new Promise((resolve, reject) => { + dirEntry.getFile(fileName, { + create: false + }, (fileEntry) => { + resolve(true); // 文件存在 + }, (error) => { + resolve(false); // 文件不存在 + }); + }); + } + + // // 下载文件 + // downloadFile(url, fileName) { + // return new Promise((resolve, reject) => { + // uni.downloadFile({ + // url: url, + // success: (res) => { + // if (res.statusCode === 200) { + // resolve(res.tempFilePath); + // } else { + // reject(`下载失败,状态码: ${res.statusCode}`); + // } + // }, + // fail: (error) => { + // reject(error); + // } + // }); + // }); + // } + // 保存文件到指定目录 + // 保存文件到指定目录 + async saveFileToDirectory(dirEntry, tempFilePath, fileName) { + return new Promise((resolve, reject) => { + // 获取目录路径 + const dirPath = dirEntry.fullPath; + + // 使用5+ API的移动文件方法 + plus.io.resolveLocalFileSystemURL(tempFilePath, (tempEntry) => { + // 目标文件路径 + const targetPath = dirPath + fileName; + + // 移动文件到目标位置 + tempEntry.moveTo(dirEntry, fileName, (movedEntry) => { + resolve(movedEntry.fullPath); + }, (error) => { + // 如果移动失败,尝试复制然后删除原文件 + tempEntry.copyTo(dirEntry, fileName, (copiedEntry) => { + // 删除临时文件 + tempEntry.remove(() => { + resolve(copiedEntry.fullPath); + }, (removeError) => { + console.warn('删除临时文件失败:', removeError); + resolve(copiedEntry.fullPath); + }); + }, (copyError) => { + reject(copyError); + }); + }); + }, (error) => { + reject(error); + }); + }); + } +} + +export default new FileManager(); \ No newline at end of file diff --git a/src/utils/http.ts b/src/utils/http.ts index 7f404ab..94f2435 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -132,10 +132,10 @@ const requestObj = { _this.methodstr = 'DELETE' // 当 expression 不匹配任何 case 时执行的代码 } - uni.showLoading({ - title: '加载中...', - duration: 15000 // 可根据实用场景设置时间 - }) + // uni.showLoading({ + // title: '加载中...', + // duration: 15000 // 可根据实用场景设置时间 + // }) uni.request({ url, @@ -146,7 +146,7 @@ const requestObj = { timeout: timeout, success(res) { // debugger - uni.hideLoading() + // uni.hideLoading() // console.log('55dfdsfsd5', res.data) res.data.code = res.data.code == 'ok' ? 200 : res.data.code const data = res.data as Response @@ -180,13 +180,13 @@ const requestObj = { } }, fail(err) { - uni.hideLoading() + // uni.hideLoading() console.log('fail', err) uni.showToast({ title: '网络错误', icon: 'none' }) reject({ message: '网络错误' }) }, complete() { - uni.hideLoading() + // uni.hideLoading() _this.isLock = false } }) diff --git a/src/utils/permissionManager.js b/src/utils/permissionManager.js new file mode 100644 index 0000000..6dc5f1b --- /dev/null +++ b/src/utils/permissionManager.js @@ -0,0 +1,93 @@ +import useshujuStore from '@/store/usershuju' + +class PermissionManager { + constructor() { + this.storagePermission = 'android.permission.WRITE_EXTERNAL_STORAGE'; + } + + // 检查权限 + checkPermission(permission) { + return new Promise((resolve) => { + if (plus.os.name.toLowerCase() !== 'android') { + resolve(true); + return; + } + + plus.android.requestPermissions([permission], (result) => { + resolve(result.granted && result.granted.length > 0); + }, (error) => { + console.error('权限检查错误:', error); + resolve(false); + }); + }); + } + + // 申请存储权限 + async requestStoragePermission() { + if (plus.os.name.toLowerCase() !== 'android') { + return true; + } + + return new Promise((resolve) => { + plus.android.requestPermissions([this.storagePermission], (result) => { + if (result.deniedAlways.length > 0) { + // 权限被永久拒绝 + this.showPermissionDialog('存储权限被永久拒绝,请到应用设置中开启权限'); + resolve(false); + } else if (result.deniedPresent.length > 0) { + // 权限被临时拒绝 + this.showPermissionDialog('需要存储权限来保存文件'); + resolve(false); + } else if (result.granted.length > 0) { + // 权限被允许 + console.log('存储权限已获取'); + resolve(true); + } + }, (error) => { + console.error('权限申请错误:', error); + resolve(false); + }); + }); + } + + // 显示权限提示对话框 + showPermissionDialog(message) { + uni.showModal({ + title: '权限提示', + content: message, + confirmText: '去设置', + success: (res) => { + if (res.confirm) { + this.openAppSettings(); + } + } + }); + } + + // 打开应用设置页面 + openAppSettings() { + if (plus.os.name.toLowerCase() === 'android') { + const Intent = plus.android.importClass('android.content.Intent'); + const Settings = plus.android.importClass('android.provider.Settings'); + const Uri = plus.android.importClass('android.net.Uri'); + + const mainActivity = plus.android.runtimeMainActivity(); + const intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + const uri = Uri.fromParts('package', mainActivity.getPackageName(), null); + intent.setData(uri); + mainActivity.startActivity(intent); + } + } + + // 检查并申请存储权限 + async ensureStoragePermission() { + const hasPermission = await this.checkPermission(this.storagePermission); + if (!hasPermission) { + return await this.requestStoragePermission(); + } + return true; + } +} + +export default new PermissionManager(); \ No newline at end of file diff --git a/src/utils/storage.ts b/src/utils/storage.ts index a38cfd4..c51d029 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -24,8 +24,12 @@ let storageNodeKeys = [ constant.androidappVersion, constant.networkType, constant.activeprojectid, + constant.activeprojetname, constant.xiangmushuju, - constant.gongsishuju + constant.gongsishuju, + constant.storagePath, + constant.pageloadingtext, + constant.pageloading ] const storage = { diff --git a/src/utils/usersqlite/posteditxianchang.js b/src/utils/usersqlite/posteditxianchang.js index ef03be5..47b44eb 100644 --- a/src/utils/usersqlite/posteditxianchang.js +++ b/src/utils/usersqlite/posteditxianchang.js @@ -40,16 +40,20 @@ async function processNewData(newDataList, results) { if (!newDataList || newDataList.length === 0) return; for (const item of newDataList) { + let oldimgUrl = ''; //旧的图片 + let oldvoiceUrl = ''; //旧的录音 try { // 1. 先上传图片并获取服务器URL const serverImgUrls = await uploadMultipleImages(item.imgUrl); if (serverImgUrls) { + oldimgUrl = JSON.parse(JSON.stringify(item.imgUrl)) // 2. 更新本地表中的图片URL为服务器返回的URL await updateLocalDataImage(item.uuid, serverImgUrls, 'projectxianchangtable'); } // 1. 先上传录音并获取服务器URL const servervoiceUrl = await uploadMultiplevoiceUrl(item.voiceUrl); if (servervoiceUrl) { + oldvoiceUrl = JSON.parse(JSON.stringify(item.voiceUrl)) // 2. 更新本地表中的录音URL为服务器返回的URL await updateLocalDatavoiceUrl(item.uuid, servervoiceUrl, 'projectxianchangtable'); @@ -65,6 +69,30 @@ async function processNewData(newDataList, results) { // 4. 新增成功后删除本地SQLite数据 if (insertResult.success) { await deleteLocalData(item.uuid, 'projectxianchangtable'); + if (oldimgUrl) { + uni.removeSavedFile({ + filePath: oldimgUrl, + success: () => { + console.log('临时图片删除成功'); + }, + fail: (err) => { + console.error('临时图片删除失败:' + oldimgUrl, err); + } + }); + } + + if (oldvoiceUrl) { + uni.removeSavedFile({ + filePath: oldvoiceUrl, + success: () => { + console.log('临时录音删除成功'); + }, + fail: (err) => { + console.error('临时录音删除失败:' + oldvoiceUrl, err); + } + }); + } + results.success.push({ id: item.uuid, @@ -681,7 +709,7 @@ function groupDataByPadStatus(dataList) { * @param {Array} padStatusList - 要查询的padstatus值数组,如[2,3,4] * @returns {Promise} 查询到的数据列表 */ -async function queryxianchangLocalDataByPadStatus(padStatusList, projectId = "") { +export async function queryxianchangLocalDataByPadStatus(padStatusList, projectId = "") { return new Promise((resolve, reject) => { if (!padStatusList || padStatusList.length === 0) { resolve([]); @@ -810,16 +838,20 @@ async function fcxwtprocessNewData(newDataList, results) { if (!newDataList || newDataList.length === 0) return; for (const item of newDataList) { + let oldimgUrl = ''; //旧的图片 + let oldvoiceUrl = ''; //旧的录音 try { // 1. 先上传图片并获取服务器URL const serverImgUrls = await uploadMultipleImages(item.imgUrl); if (serverImgUrls) { + oldimgUrl = JSON.parse(JSON.stringify(item.imgUrl)) // 2. 更新本地表中的图片URL为服务器返回的URL await updateLocalDataImage(item.uuid, serverImgUrls, 'fcxwttable'); } // 1. 先上传录音并获取服务器URL const servervoiceUrl = await uploadMultiplevoiceUrl(item.voiceUrl); if (servervoiceUrl) { + oldvoiceUrl = JSON.parse(JSON.stringify(item.voiceUrl)) // 2. 更新本地表中的录音URL为服务器返回的URL await updateLocalDatavoiceUrl(item.uuid, servervoiceUrl, 'fcxwttable'); @@ -837,7 +869,29 @@ async function fcxwtprocessNewData(newDataList, results) { console.log('复查新问题正在删除'); await deleteLocalData(item.uuid, 'fcxwttable'); + if (oldimgUrl) { + uni.removeSavedFile({ + filePath: oldimgUrl, + success: () => { + console.log('临时图片删除成功'); + }, + fail: (err) => { + console.error('临时图片删除失败:' + oldimgUrl, err); + } + }); + } + if (oldvoiceUrl) { + uni.removeSavedFile({ + filePath: oldvoiceUrl, + success: () => { + console.log('临时录音删除成功'); + }, + fail: (err) => { + console.error('临时录音删除失败:' + oldvoiceUrl, err); + } + }); + } results.success.push({ id: item.uuid, serverId: insertResult.data.uuid, @@ -866,19 +920,35 @@ async function fcxwtcallAddServerApi(data) { console.log('复查新问题一批量处理1'); if (data.locations) { - data.locations = JSON.parse(data.locations) - } - console.log('复查新问题一批量处理2'); - if (data.records) { - data.records = JSON.parse(data.records) - } - console.log('复查新问题一批量处理3'); - if (data.materialActivityFiles) { - data.materialActivityFiles = JSON.parse(data.materialActivityFiles) - } - console.log('复查新问题一批量处理4'); + if (data.locations == "[]") { + data.locations = null; + } else { + data.locations = JSON.parse(data.locations) + } - console.log(`复查新问题提交`, JSON.stringify(data)); + } + console.log('复查新问题一批量处理2', data.locations); + if (data.records) { + if (data.records == "[]") { + data.records = null; + } else { + data.records = JSON.parse(data.records) + } + + } + console.log('复查新问题一批量处理3', data.records); + if (data.materialActivityFiles) { + if (data.materialActivityFiles == "[]") { + data.materialActivityFiles = null; + } else { + data.materialActivityFiles = JSON.parse(data.materialActivityFiles) + } + + } + data.attachmentJson = null; + console.log('复查新问题一批量处理4', data.materialActivityFiles); + + console.log(`复查新问题提交`, data); return new Promise((resolve, reject) => { uni.request({ @@ -980,16 +1050,20 @@ async function fcprocessNewData(newDataList, results) { if (!newDataList || newDataList.length === 0) return; for (const item of newDataList) { + let oldimgUrl = ''; //旧的图片 + let oldvoiceUrl = ''; //旧的录音 try { // 1. 先上传图片并获取服务器URL const serverImgUrls = await uploadMultipleImages(item.imgUrl); if (serverImgUrls) { + oldimgUrl = JSON.parse(JSON.stringify(item.imgUrl)) // 2. 更新本地表中的图片URL为服务器返回的URL await updateLocalDataImage(item.uuid, serverImgUrls, 'fctable'); } // 1. 先上传录音并获取服务器URL const servervoiceUrl = await uploadMultiplevoiceUrl(item.voiceUrl); if (servervoiceUrl) { + oldvoiceUrl = JSON.parse(JSON.stringify(item.voiceUrl)) // 2. 更新本地表中的录音URL为服务器返回的URL await updateLocalDatavoiceUrl(item.uuid, servervoiceUrl, 'fctable'); @@ -1005,7 +1079,29 @@ async function fcprocessNewData(newDataList, results) { // 4. 新增成功后删除本地SQLite数据 if (insertResult.success) { await deleteLocalData(item.uuid, 'fctable'); + if (oldimgUrl) { + uni.removeSavedFile({ + filePath: oldimgUrl, + success: () => { + console.log('临时图片删除成功'); + }, + fail: (err) => { + console.error('临时图片删除失败:' + oldimgUrl, err); + } + }); + } + if (oldvoiceUrl) { + uni.removeSavedFile({ + filePath: oldvoiceUrl, + success: () => { + console.log('临时录音删除成功'); + }, + fail: (err) => { + console.error('临时录音删除失败:' + oldvoiceUrl, err); + } + }); + } results.success.push({ id: item.uuid, serverId: insertResult.data.uuid, @@ -1036,20 +1132,14 @@ export const exampleUsage = async (projectId = '') => { const tableExists = await dbUtils.isTable('xiaofangdb', 'projectxianchangtable') console.log('现场表是否存在', tableExists) if (!tableExists) { - return; + return { + success: false, + message: `现场表不存在!` + } } - // 1. 先查询本地现场数据表中padstatus为2、3、4的数据 const xianchanglocalData = await queryxianchangLocalDataByPadStatus([2, 3, 4], projectId); - - // if (!xianchanglocalData || xianchanglocalData.length === 0) { - // uni.showToast({ - // title: '没有需要处理的现场数据', - // icon: 'none' - // }); - // return; - // } if (xianchanglocalData || xianchanglocalData.length > 0) { console.log('查询的现场数据待处理数据:', xianchanglocalData); @@ -1059,16 +1149,16 @@ export const exampleUsage = async (projectId = '') => { // 3. 显示处理结果 if (xianchangresult.failed.length === 0) { - uni.showToast({ - title: `全部现场数据处理成功,共${xianchangresult.success.length}条`, - icon: 'success' - }); + // uni.showToast({ + // title: `全部现场数据处理成功,共${xianchangresult.success.length}条`, + // icon: 'success' + // }); } else { - uni.showModal({ - title: '现场数据处理结果', - content: `成功: ${xianchangresult.success.length}条, 失败: ${xianchangresult.failed.length}条`, - showCancel: false - }); + // uni.showModal({ + // title: '现场数据处理结果', + // content: `成功: ${xianchangresult.success.length}条, 失败: ${xianchangresult.failed.length}条`, + // showCancel: false + // }); // 可以在这里记录或显示失败详情 xianchangresult.failed.forEach(failedItem => { @@ -1099,16 +1189,16 @@ export const exampleUsage = async (projectId = '') => { // 3. 显示处理结果 if (fcxwtresult.failed.length === 0) { - uni.showToast({ - title: `全部复查新问题数据处理成功,共${fcxwtresult.success.length}条`, - icon: 'success' - }); + // uni.showToast({ + // title: `全部复查新问题数据处理成功,共${fcxwtresult.success.length}条`, + // icon: 'success' + // }); } else { - uni.showModal({ - title: '复查新问题数据处理结果', - content: `成功: ${fcxwtresult.success.length}条, 失败: ${fcxwtresult.failed.length}条`, - showCancel: false - }); + // uni.showModal({ + // title: '复查新问题数据处理结果', + // content: `成功: ${fcxwtresult.success.length}条, 失败: ${fcxwtresult.failed.length}条`, + // showCancel: false + // }); // 可以在这里记录或显示失败详情 fcxwtresult.failed.forEach(failedItem => { @@ -1140,16 +1230,16 @@ export const exampleUsage = async (projectId = '') => { // 3. 显示处理结果 if (fcresult.failed.length === 0) { - uni.showToast({ - title: `全部复查数据处理成功,共${fcresult.success.length}条`, - icon: 'success' - }); + // uni.showToast({ + // title: `全部复查数据处理成功,共${fcresult.success.length}条`, + // icon: 'success' + // }); } else { - uni.showModal({ - title: '复查数据处理结果', - content: `成功: ${fcresult.success.length}条, 失败: ${fcresult.failed.length}条`, - showCancel: false - }); + // uni.showModal({ + // title: '复查数据处理结果', + // content: `成功: ${fcresult.success.length}条, 失败: ${fcresult.failed.length}条`, + // showCancel: false + // }); // 可以在这里记录或显示失败详情 fcresult.failed.forEach(failedItem => { @@ -1160,11 +1250,18 @@ export const exampleUsage = async (projectId = '') => { } } - + return { + success: true, + message: `提交成功!` + }; } catch (error) { console.error('处理异常:', error); + return { + success: false, + message: `提交异常${error}!` + }; uni.showToast({ title: '查询或处理失败', icon: 'none' diff --git a/src/utils/usersqlite/projects.js b/src/utils/usersqlite/projects.js index a759e31..4aa8bca 100644 --- a/src/utils/usersqlite/projects.js +++ b/src/utils/usersqlite/projects.js @@ -187,6 +187,8 @@ const processProjectDownloads = async (projectData, shujuStore) => { shujuStore.setxiangmushuju(projectData); if (projectData.length > 0) { shujuStore.setactiveprojectid(projectData[0].projectId); + shujuStore.setactiveprojetname(projectData[0].name); + } // 使用并发控制处理项目下载 @@ -227,18 +229,22 @@ const executeConcurrentDownloads = async (projectData, shujuStore, concurrency = await new Promise(resolve => setTimeout(resolve, delay)); } + // // 并行执行公司下载和分布列表下载 + // const [companyResult, distributionResult] = await Promise.allSettled([ + // // shujuStore.canyudwDownload(project.projectId), + // shujuStore.fenbulistDownload(project.projectId) + // ]); // 并行执行公司下载和分布列表下载 - const [companyResult, distributionResult] = await Promise.allSettled([ - shujuStore.canyudwDownload(project.projectId), + const [distributionResult] = await Promise.allSettled([ + // shujuStore.canyudwDownload(project.projectId), shujuStore.fenbulistDownload(project.projectId) ]); - - const success = companyResult.status === 'fulfilled' && + const success = distributionResult.status === 'fulfilled'; if (!success) { console.error(`项目 ${project.projectId} 下载失败:`, { - company: companyResult.status, + company: 200, distribution: distributionResult.status }); } @@ -246,7 +252,7 @@ const executeConcurrentDownloads = async (projectData, shujuStore, concurrency = return { projectId: project.projectId, success, - companyError: companyResult.status === 'rejected' ? companyResult.reason : null, + // companyError: companyResult.status === 'rejected' ? companyResult.reason : null, distributionError: distributionResult.status === 'rejected' ? distributionResult.reason : null }; diff --git a/src/utils/usersqlite/projectxcdownload.js b/src/utils/usersqlite/projectxcdownload.js new file mode 100644 index 0000000..a910a43 --- /dev/null +++ b/src/utils/usersqlite/projectxcdownload.js @@ -0,0 +1,148 @@ +// sqlite.js 新增同步方法 +import { + getCurrentInstance, + onMounted +} from 'vue' + +import useshujuStore from '@/store/usershuju' +import dbUtils from '@/uni_modules/zjy-sqlite-manage/components/zjy-sqlite-manage/dbUtils.js' +/** + * 异步批量同步项目一级数据 + * @param {string} table - 表名 + * @param {Array} list - 数据列表 + * @param {string} proid - 项目ID + */ +//下载单个项目的 现场数据 +export const syncsprojectxcdownloadData = async (proid) => { + const shujuStore = useshujuStore(); + + try { + // // 1. 异步获取本地数据 + // const projectst1localData = await dbUtils.getDataListAll('xiaofangdb', 'projectst1table', { + // projectId: proid + // }); + + + // 3. 并行处理数据插入和后续操作 单个项目下载现场数据 + const results = await Promise.all([ + projectxianchangDataInsertion(proid, shujuStore), + ]); + + const [insertionResult] = results; + + return { + success: true, + updatedCount: insertionResult.insertedCount, + secondaryTasks: insertionResult.secondaryTasks, + message: `同步完成: 更新${insertionResult.insertedCount}条数据,触发${insertionResult.secondaryTasks}个二级任务` + }; + + } catch (err) { + console.error('一级数据同步失败:', err); + return { + success: false, + error: err.message + }; + } +}; + + + +/** + * 异步处理数据插入和二级数据下载 + */ +const projectxianchangDataInsertion = async (proid, shujuStore) => { + + try { + const secondaryTasks = await triggerxianchangaryDownloads(proid, shujuStore); + + return { + insertedCount: 0, + secondaryTasks: secondaryTasks + }; + } catch (error) { + console.error('现场数据插入失败:', error); + throw new Error(`数据插入失败: ${error.message}`); + } +}; + +/** + * 异步触发二级数据下载(优化版) + */ +const triggerxianchangaryDownloads = async (proid, shujuStore) => { + try { + const projectst1localData = await dbUtils.getDataListAll('xiaofangdb', 'projectst1table', { + projectId: proid + }); + + // console.log('本地项目下1级数据数量:', currentData.length); + + if (projectst1localData.length === 0) { + return 0; + } + + // 使用Promise.all并行处理所有二级数据下载 + const downloadPromises = projectst1localData.map((item, index) => + downloadSecondaryData(item, proid, shujuStore, index) + ); + + // 限制并发数量,避免同时发起过多请求 + const results = await throttlePromises(downloadPromises, 3); + + return results.filter(result => result.success).length; + } catch (error) { + console.error('现场数据下载失败:', error); + return 0; + } +}; + +/** + * 异步下载单个项目的二级数据 + */ +const downloadSecondaryData = async (item, proid, shujuStore, index) => { + try { + // console.log(`处理第${index + 1}个项目的二级数据:`, item.key, proid); + + // 并行执行二级数据下载,不使用setTimeout延迟 + const [xianchangResult] = await Promise.all([ + shujuStore.xianchanglistDownload(item.key, proid) + ]); + + return { + success: true, + xianchang: xianchangResult + }; + } catch (error) { + console.error(`项目id为${proid}的现场数据下载失败:`, error); + return { + success: false, + error: error.message + }; + } +}; + +/** + * Promise并发控制 + */ +const throttlePromises = async (promises, concurrency = 3) => { + const results = []; + const executing = new Set(); + + for (const promise of promises) { + // 如果达到并发限制,等待其中一个完成 + if (executing.size >= concurrency) { + await Promise.race(executing); + } + + const p = promise.then(result => { + executing.delete(p); + return result; + }); + + executing.add(p); + results.push(p); + } + + // 等待所有剩余任务完成 + return Promise.all(results); +}; \ No newline at end of file diff --git a/src/utils/usersqlite/st1.js b/src/utils/usersqlite/st1.js index 1628d81..d079184 100644 --- a/src/utils/usersqlite/st1.js +++ b/src/utils/usersqlite/st1.js @@ -174,7 +174,7 @@ const downloadSecondaryData = async (item, proid, shujuStore, index) => { // 并行执行二级数据下载,不使用setTimeout延迟 const [fenxiangResult, xianchangResult] = await Promise.all([ shujuStore.fenxianglistDownload(item.key, proid), - shujuStore.xianchanglistDownload(item.key, proid) + // shujuStore.xianchanglistDownload(item.key, proid) ]); return {