提交 7251cbba authored 作者: zs's avatar zs

表结构初始化

上级 9dbb531c
<script> <script>
import { import {
BASE_PATH, BASE_PATH,
SYNCHRONIZE_DATA_PATH, SYNCHRONIZE_DATA_PATH,
SYNCHRONIZE_DATA_PAD, SYNCHRONIZE_DATA_PAD,
checkAndCreateDirectory, checkAndCreateDirectory,
checkFileExists, checkFileExists,
createFileWithPlusIO, createFileWithPlusIO,
readFileContent, readFileContent,
USER_LiST, USER_LiST,
USER_FILE_NAME, USER_FILE_NAME,
} from "./utils/systemCofig"; } from "./utils/systemCofig";
import { Base64 } from "js-base64"; import {
import {differenceBy} from "lodash"; Base64
} from "js-base64";
import { readDirectoryData } from "@/utils/IoReadingAndWriting.js"; import {
export default { differenceBy
onLaunch: function () { } from "lodash";
// #ifdef APP-PLUS
plus.screen.lockOrientation("landscape-primary"); //锁定横屏 import {
// #endif readDirectoryData
} from "@/utils/IoReadingAndWriting.js";
// this.init(); import initService from '@/api/sqllite/init.js'
export default {
// #ifdef APP-PLUS onLaunch: function() {
plus.android.requestPermissions( // #ifdef APP-PLUS
["android.permission.WRITE_EXTERNAL_STORAGE"], plus.screen.lockOrientation("landscape-primary"); //锁定横屏
function (e) { // #endif
if (e.deniedAlways.length > 0) {
//权限被永久拒绝 // this.init();
// 弹出提示框解释为何需要读写手机储存权限,引导用户打开设置页面开启
uni.showModal({ // #ifdef APP-PLUS
title: "存储权限", plus.android.requestPermissions(
content: "您拒绝了存储权限,请去设置-应用开启存储权限。", ["android.permission.WRITE_EXTERNAL_STORAGE"],
success: function (res) { function(e) {
if (res.confirm) { if (e.deniedAlways.length > 0) {
} else if (res.cancel) { //权限被永久拒绝
} // 弹出提示框解释为何需要读写手机储存权限,引导用户打开设置页面开启
}, uni.showModal({
}); title: "存储权限",
} content: "您拒绝了存储权限,请去设置-应用开启存储权限。",
if (e.deniedPresent.length > 0) { success: function(res) {
//权限被临时拒绝 if (res.confirm) {} else if (res.cancel) {}
// 弹出提示框解释为何需要读写手机储存权限,可再次调用plus.android.requestPermissions申请权限 },
plus.android.requestPermissions([ });
"android.permission.WRITE_EXTERNAL_STORAGE", }
]); if (e.deniedPresent.length > 0) {
} //权限被临时拒绝
if (e.granted.length > 0) { // 弹出提示框解释为何需要读写手机储存权限,可再次调用plus.android.requestPermissions申请权限
//权限被允许 plus.android.requestPermissions([
init(); "android.permission.WRITE_EXTERNAL_STORAGE",
} ]);
}, }
function (e) {} if (e.granted.length > 0) {
); //权限被允许
// #endif init();
}, }
onShow: function () { },
const now_user = uni.getStorageSync("now_user") || {}; function(e) {}
if (now_user.user) { );
this.$store.commit("SET_USER", now_user); // #endif
} },
// this.init(); onShow: function() {
}, const now_user = uni.getStorageSync("now_user") || {};
onHide: function () { if (now_user.user) {
// app关闭时将数据存储到本地缓存 this.$store.commit("SET_USER", now_user);
uni.setStorageSync("now_user", this.$store.state.now_user); }
uni.setStorageSync("last_time", this.$store.state.now_user.LastSynchronizationTime); this.init();
},
// 清除store 数据 onLoad: function(query) {
this.$store.commit("SET_DARF_DATA", {}); console.log('即将开始初始化app')
this.$store.commit("SET_LOG_LIST", []); },
this.$store.commit("SET_ALL_DATA", []); onHide: function() {
}, // app关闭时将数据存储到本地缓存
onUnload() { uni.setStorageSync("now_user", this.$store.state.now_user);
}, uni.setStorageSync("last_time", this.$store.state.now_user.LastSynchronizationTime);
methods: {
/** // 清除store 数据
* 第一步: 检查目录是否存在,如果没有就创建 this.$store.commit("SET_DARF_DATA", {});
* 第二步:检查指定文件是否存在,如果存在就读取内容;否则就创建文件,并写入初始化数据 this.$store.commit("SET_LOG_LIST", []);
* 第三步:存储读取到的数据 this.$store.commit("SET_ALL_DATA", []);
*/ },
async init() { onUnload() {},
checkAndCreateDirectory(SYNCHRONIZE_DATA_PAD) methods: {
.then(() => { /**
return new Promise((resolve, reject) => { * 第一步: 检查目录是否存在,如果没有就创建
// 检查目录下的文件是否存在 * 第二步:检查指定文件是否存在,如果存在就读取内容;否则就创建文件,并写入初始化数据
checkFileExists(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME) * 第三步:存储读取到的数据
.then((fileEntry) => { */
// 文件存在, async init() {
return readFileContent(fileEntry) initService.init()
.then((res) => { return
resolve(res); checkAndCreateDirectory(SYNCHRONIZE_DATA_PAD)
}) .then(() => {
.catch((error) => { return new Promise((resolve, reject) => {
reject(error); // 检查目录下的文件是否存在
}); checkFileExists(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME)
}) .then((fileEntry) => {
.catch((error) => { // 文件存在,
// 文件不存在, 写入文件 return readFileContent(fileEntry)
const fileContent = JSON.stringify( .then((res) => {
Base64.encode(JSON.stringify(USER_LiST)) resolve(res);
); })
createFileWithPlusIO( .catch((error) => {
SYNCHRONIZE_DATA_PAD, reject(error);
USER_FILE_NAME, });
fileContent })
) .catch((error) => {
.then((res) => { // 文件不存在, 写入文件
resolve(res); const fileContent = JSON.stringify(
}) Base64.encode(JSON.stringify(USER_LiST))
.catch((error) => { );
reject(error); createFileWithPlusIO(
}); SYNCHRONIZE_DATA_PAD,
}); USER_FILE_NAME,
}) fileContent
.then(async (res) => { )
.then((res) => {
// 获取文件数据 resolve(res);
let userData = Base64.decode(res); })
.catch((error) => {
const diffUserList = await this.diffUserList(userData) reject(error);
if(diffUserList.length){ });
this.updateIpadUsetList([...USER_LiST,...diffUserList]) });
})
userData = JSON.stringify([...USER_LiST,...diffUserList]) .then(async (res) => {
}
// 获取文件数据
uni.setStorage({ let userData = Base64.decode(res);
key: "user_data",
data: userData, const diffUserList = await this.diffUserList(userData)
fail: (error) => { if (diffUserList.length) {
console.log("APP.vue 存储数据失败", error); this.updateIpadUsetList([...USER_LiST, ...diffUserList])
},
}); userData = JSON.stringify([...USER_LiST, ...diffUserList])
}) }
.catch((error) => {
console.log("---", error); uni.setStorage({
}); key: "user_data",
}) data: userData,
.catch((error) => { fail: (error) => {
console.log("---目录创建失败", error); console.log("APP.vue 存储数据失败", error);
}); },
}, });
})
// 比较代码中的用户列表 和 ipad中存储用户的 差异 .catch((error) => {
async diffUserList(ipadUserList = []){ console.log("---", error);
const temp = eval(ipadUserList) });
const diffResult = differenceBy(USER_LiST, temp, "userId") })
.catch((error) => {
return diffResult console.log("---目录创建失败", error);
}, });
},
// 更新 ipad 用户信息 // 比较代码中的用户列表 和 ipad中存储用户的 差异
updateIpadUsetList(tempPersonList){ async diffUserList(ipadUserList = []) {
const temp = JSON.stringify(tempPersonList); const temp = eval(ipadUserList)
const diffResult = differenceBy(USER_LiST, temp, "userId")
const fileContent = JSON.stringify(Base64.encode(temp));
createFileWithPlusIO( return diffResult
SYNCHRONIZE_DATA_PAD, },
USER_FILE_NAME,
fileContent
) // 更新 ipad 用户信息
} updateIpadUsetList(tempPersonList) {
}, const temp = JSON.stringify(tempPersonList);
};
const fileContent = JSON.stringify(Base64.encode(temp));
createFileWithPlusIO(
SYNCHRONIZE_DATA_PAD,
USER_FILE_NAME,
fileContent
)
}
},
};
</script> </script>
<style lang="less"> <style lang="less">
@import "./common/global.css"; @import "./common/global.css";
@import "~@/static/iconFont/iconfont.css"; @import "~@/static/iconFont/iconfont.css";
@font-face { @font-face {
font-family: AlibabaPuHuiTi-Medium; font-family: AlibabaPuHuiTi-Medium;
src: url("~@/static/font/Alibaba-PuHuiTi-Medium.ttf"); src: url("~@/static/font/Alibaba-PuHuiTi-Medium.ttf");
} }
@font-face {
font-family: "iconfont"; /* Project id 4374193 */ @font-face {
src: url("~@/static/iconFont/iconfont.woff2?t=1725876968366") format("woff2"), font-family: "iconfont";
url("~@/static/iconFont/iconfont.woff?t=1725876968366") format("woff"), /* Project id 4374193 */
url("~@/static/iconFont/iconfont.ttf?t=1725876968366") format("truetype"); src: url("~@/static/iconFont/iconfont.woff2?t=1725876968366") format("woff2"),
} url("~@/static/iconFont/iconfont.woff?t=1725876968366") format("woff"),
url("~@/static/iconFont/iconfont.ttf?t=1725876968366") format("truetype");
// @font-face { }
// font-family: "iconfont"; /* Project id 4374193 */
// src: url('iconfont.woff2?t=1725876968365') format('woff2'), // @font-face {
// url('iconfont.woff?t=1725876968365') format('woff'), // font-family: "iconfont"; /* Project id 4374193 */
// url('iconfont.ttf?t=1725876968365') format('truetype'); // src: url('iconfont.woff2?t=1725876968365') format('woff2'),
// } // url('iconfont.woff?t=1725876968365') format('woff'),
@font-face { // url('iconfont.ttf?t=1725876968365') format('truetype');
font-family: AlibabaPuHuiTi; // }
src: url("~@/static/font/Alibaba-PuHuiTi-Regular.ttf"); @font-face {
} font-family: AlibabaPuHuiTi;
src: url("~@/static/font/Alibaba-PuHuiTi-Regular.ttf");
@font-face { }
font-family: YouSheBiaoTiHei;
src: url("~@/static/font/YouSheBiaoTiHei.ttf"); @font-face {
} font-family: YouSheBiaoTiHei;
src: url("~@/static/font/YouSheBiaoTiHei.ttf");
body { }
width: 100vw;
// height: calc(100vh - 44px); body {
height: 100vh; width: 100vw;
background-color: #f3f6fa; // height: calc(100vh - 44px);
height: 100vh;
/* background-color: red; */ background-color: #f3f6fa;
}
/* background-color: red; */
* { }
box-sizing: border-box;
font-family: AlibabaPuHuiTi; * {
/* font-size: 9.41rpx; */ box-sizing: border-box;
} font-family: AlibabaPuHuiTi;
image { /* font-size: 9.41rpx; */
will-change: transform; }
/* 解决加载时瞬间拉伸问题 */
width: auto; image {
/* 解决加载时瞬间拉伸问题 */ will-change: transform;
height: auto; /* 解决加载时瞬间拉伸问题 */
/* 解决加载时瞬间拉伸问题 */ width: auto;
image-rendering: -moz-crisp-edges; /* 解决加载时瞬间拉伸问题 */
image-rendering: -o-crisp-edges; height: auto;
image-rendering: -webkit-optimize-contrast; /* 解决加载时瞬间拉伸问题 */
image-rendering: crisp-edges; image-rendering: -moz-crisp-edges;
-ms-interpolation-mode: nearest-neighbor; image-rendering: -o-crisp-edges;
} image-rendering: -webkit-optimize-contrast;
image-rendering: crisp-edges;
.uni-nav-bar-text { -ms-interpolation-mode: nearest-neighbor;
/* 导航栏文字大小 */ }
font-size: 24px !important;
letter-spacing: 1px; .uni-nav-bar-text {
} /* 导航栏文字大小 */
font-size: 24px !important;
.uni-navbar--shadow { letter-spacing: 1px;
box-shadow: none !important; }
}
.uni-navbar--shadow {
.uni-data-checklist .checklist-group { box-shadow: none !important;
flex-wrap: nowrap !important; }
}
/*每个页面公共css */ .uni-data-checklist .checklist-group {
</style> flex-wrap: nowrap !important;
}
/*每个页面公共css */
</style>
\ No newline at end of file
import SqlliteDbUtil from '@/utils/sqllitedb'
import table from './sqllite/table.js'
import {
fixNullVal
} from "@/utils/common";
// 巡检
export default {
async selectList() {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let rs = await sqllitedb.selectSQL(`select * from ${table.assRoomName}`)
return rs
},
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `select * from ${table.assRoomName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0]
}
},
async remove(id) {
if (!id) {
return
}
let sql = `delete from ${table.assRoomName} where id = '${id}'`;
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
await sqllitedb.executeSQL(sql);
},
async saveBatch(list) {
if (list.length === 0) {
return;
}
console.log('开始保存机房信息....' + list.length)
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
try {
for (let data of list) {
let column = ''
let values = ''
let idx = 0
for (let attr in data) {
let dataField = table['assRoom'].find(v => {
if (v.field === attr) {
return v
}
})
if (!dataField) {
continue
}
column += dataField.field + ','
values += "'" + fixNullVal(data[attr]) + "',"
idx++
}
column = column.endsWith(',') ? column.substring(0, column.length - 1) : column
values = values.endsWith(',') ? values.substring(0, values.length - 1) : values
let sql = `insert into ${table.assRoomName}(${column}) values(${values})`
let has = await this.info(data.id)
if (has && has.id) {
await this.remove(data.id)
}
await sqllitedb.executeSQL(sql)
}
} catch (e) {
console.log(e.message)
} finally {
await sqllitedb.closeDB();
}
console.log('导入完成...')
}
}
\ No newline at end of file
import SqlliteDbUtil from '@/utils/sqllitedb'
import table from './sqllite/table.js'
import {
fixNullVal
} from "@/utils/common";
// 井道
export default {
async selectList() {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let rs = await sqllitedb.selectSQL(`select * from ${table.assRoomName}`)
return rs
},
async remove(id) {
if (!id) {
return
}
let sql = `delete from ${table.assRoomName} where id = '${id}'`;
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
await sqllitedb.executeSQL(sql);
},
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `select * from ${table.assRoomName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0]
}
},
async saveBatch(list) {
if (list.length === 0) {
return;
}
console.log('开始保存管道信息....' + list)
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
try {
for (let data of list) {
let column = ''
let values = ''
let idx = 0
for (let attr in data) {
let dataField = table['assBuilding'].find(v => {
if (v.field === attr) {
return v
}
})
if (!dataField) {
continue
}
column += dataField.field + ','
values += "'" + fixNullVal(data[attr]) + "',"
idx++
}
column = column.endsWith(',') ? column.substring(0, column.length - 1) : column
values = values.endsWith(',') ? values.substring(0, values.length - 1) : values
let sql = `insert into ${table.assBuildingName}(${column}) values(${values})`
let has = await this.info(data.id)
if (has && has.id) {
await this.remove(data.id)
}
await sqllitedb.executeSQL(sql)
}
} catch (e) {
console.log(e.message)
} finally {
await sqllitedb.closeDB();
}
console.log('导入完成...')
}
}
\ No newline at end of file
import SqlliteDbUtil from '@/utils/sqllitedb'
import table from '@/constant/table'
import {
fixNullVal
} from "@/utils/common";
// 巡检
export default {
async selectList() {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let rs = await sqllitedb.selectSQL(`select * from ${table.inspectionRecordName}`)
return rs
},
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `select * from ${table.inspectionRecordName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0]
}
},
async remove(id) {
if (!id) {
return
}
let sql = `delete from ${table.inspectionRecordName} where id = '${id}'`;
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
await sqllitedb.executeSQL(sql);
},
async saveBatch(list) {
if (list.length === 0) {
return;
}
console.log('开始保存用户信息....' + list.length)
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
try {
for (let data of list) {
let column = ''
let values = ''
let idx = 0
for (let attr in data) {
let dataField = table['inspectionRecord'].find(v => {
if (v.field === attr) {
return v
}
})
if (!dataField) {
continue
}
column += dataField.field + ','
values += "'" + fixNullVal(data[attr]) + "',"
idx++
}
column = column.endsWith(',') ? column.substring(0, column.length - 1) : column
values = values.endsWith(',') ? values.substring(0, values.length - 1) : values
let sql = `insert into ${table.inspectionRecordName}(${column}) values(${values})`
let has = await this.info(data.id)
if (has && has.id) {
await this.remove(data.id)
}
await sqllitedb.executeSQL(sql)
}
} catch (e) {
console.log(e.message)
} finally {
await sqllitedb.closeDB();
}
console.log('导入完成...')
}
}
\ No newline at end of file
...@@ -3,7 +3,11 @@ import _Path from '@/constant/ioPath' ...@@ -3,7 +3,11 @@ import _Path from '@/constant/ioPath'
import ioUtil from '@/utils/ioUtil' import ioUtil from '@/utils/ioUtil'
import SqlliteDbUtil from '@/utils/sqllitedb' import SqlliteDbUtil from '@/utils/sqllitedb'
import userApi from '@/api/user' import userApi from '@/api/user'
import hoistwayApi from '@/api/hoistway'
import assRoomApi from '@/api/assRoom.js'
import hoistwayjson from '../../baseData/hoistway.json'
import userjson from '../../baseData/user.json' import userjson from '../../baseData/user.json'
import assroomjson from '../../baseData/assroom.json'
export default { export default {
// app初始化 // app初始化
...@@ -20,8 +24,9 @@ export default { ...@@ -20,8 +24,9 @@ export default {
// 导入用戶文件文件 // 导入用戶文件文件
// await this.importFileData(); // await this.importFileData();
await userApi.saveBatch(userjson) await userApi.saveBatch(userjson)
await hoistwayApi.saveBatch(hoistwayjson)
await assRoomApi.saveBatch(assroomjson)
// 初始化完成通知首页 // 初始化完成通知首页
uni.$emit("initDone", "ok") uni.$emit("initDone", "ok")
uni.hideLoading() uni.hideLoading()
...@@ -35,9 +40,6 @@ export default { ...@@ -35,9 +40,6 @@ export default {
console.log('导入基础数据开始') console.log('导入基础数据开始')
await fileImport.importBaseFile() await fileImport.importBaseFile()
console.log('导入基础数据结束!') console.log('导入基础数据结束!')
console.log('导入检查数据开始....')
await fileImport.importCheckFile()
console.log('导入检查数据结束!')
console.log('解压导入完成....') console.log('解压导入完成....')
} catch (e) { } catch (e) {
console.log(e.message) console.log(e.message)
...@@ -56,8 +58,12 @@ export default { ...@@ -56,8 +58,12 @@ export default {
try { try {
// 创建打开数据库,已经存在表则跳过 // 创建打开数据库,已经存在表则跳过
sqllitedb = await SqlliteDbUtil.initSqlliteDB() sqllitedb = await SqlliteDbUtil.initSqlliteDB()
console.log(sqllitedb,'是否存在')
// console.log('创建用户表...') // console.log('创建用户表...')
await sqllitedb.createTable(table.userName, table.user) await sqllitedb.createTable(table.userName, table.user)
await sqllitedb.createTable(table.inspectionRecordName, table.inspectionRecord)// 巡检记录表
await sqllitedb.createTable(table.assRoomName, table.assRoom) // 机房、井道信息表
await sqllitedb.createTable(table.assBuildingName, table.assBuilding) // 楼宇信息
} catch (e) { } catch (e) {
console.log(e.message) console.log(e.message)
} finally { } finally {
......
module.exports = { module.exports = {
// 用户表 // 用户表
userName: "SYS_USER", userName: "SYS_USER",
user: [ user: [{
{ field: "userId",
field: "userId", format: "TEXT",
format: "TEXT", },
}, {
{ field: "userName",
field: "userName", format: "TEXT",
format: "TEXT", },
}, {
{ field: "userType",
field: "userType", format: "TEXT",
format: "TEXT", },
}, {
{ field: "avatar",
field: "avatar", format: "TEXT",
format: "TEXT", },
}, {
{ field: "password",
field: "password", format: "TEXT",
format: "TEXT", },
}, {
{ field: "rememberPwd",
field: "rememberPwd", format: "TEXT",
format: "TEXT", },
}, ],
], // 巡检记录表
}; inspectionRecordName: "INSPECTION_RECORD",
inspectionRecord: [{
field: "id",
format: "TEXT NOT NULL",
},
{
field: "inspectionType",
format: "TEXT",
},
{
field: "recordName",
format: "TEXT",
},
{
field: "userId",
format: "TEXT",
},
{
field: "userName",
format: "TEXT",
},
{
field: "inspectionTime",
format: "TEXT",
},
{
field: "inspectionCode",
format: "TEXT",
},
{
field: "synFlag",
format: "TEXT",
},
{
field: "createTime",
format: "TEXT",
},
{
field: "createBy",
format: "TEXT",
},
{
field: "updateTime",
format: "TEXT",
},
{
field: "updateBy",
format: "TEXT",
},
{
field: "delFlag",
format: "TEXT",
},
{
field: "isException",
format: "TEXT",
},
{
field: "inspectionData",
format: "TEXT",
}
],
// 机房、井道信息表
assRoomName: "ASS_ROOM",
assRoom: [{
field: "id",
format: "TEXT NOT NULL",
},
{
field: "roomName",
format: "TEXT",
},
{
field: "buildingId",
format: "TEXT",
},
{
field: "buildingName",
format: "TEXT",
},
{
field: "roomType",
format: "TEXT",
},
{
field: "roomFile",
format: "TEXT",
},
{
field: "roomAddress",
format: "TEXT",
},
{
field: "keynoteFlag",
format: "TEXT",
},
{
field: "sort",
format: "TEXT",
},
{
field: "roomDesc",
format: "TEXT",
},
{
field: "remark",
format: "TEXT",
},
{
field: "createTime",
format: "TEXT",
},
{
field: "createBy",
format: "TEXT",
},
{
field: "updateTime",
format: "TEXT",
},
{
field: "updateBy",
format: "TEXT",
},
{
field: "delFlag",
format: "TEXT",
},
{
field: "synFlag",
format: "TEXT",
},
{
field: "SHOW",
format: "TEXT",
}
],
// 楼宇信息
assBuildingName: "ASS_BUILDING",
assBuilding: [{
field: "id",
format: "TEXT NOT NULL",
},
{
field: "buildingName",
format: "TEXT",
},
{
field: "sort",
format: "TEXT",
},
{
field: "remark",
format: "TEXT",
},
{
field: "createTime",
format: "TEXT",
},
{
field: "createBy",
format: "TEXT",
},
{
field: "updateTime",
format: "TEXT",
},
{
field: "updateBy",
format: "TEXT",
},
{
field: "delFlag",
format: "TEXT",
},
{
field: "synFlag",
format: "TEXT",
}
]
};
\ No newline at end of file
import SqlliteDbUtil from '@/utils/sqllitedb' import SqlliteDbUtil from '@/utils/sqllitedb'
import table from '@/constant/table' import table from '@/constant/table'
import store from '@/store'
import { import {
fixNullVal fixNullVal
} from "@/utils/common"; } from "@/utils/common";
...@@ -28,7 +27,14 @@ export default { ...@@ -28,7 +27,14 @@ export default {
msg: '登录成功' msg: '登录成功'
}; };
}, },
async remove(id) {
if (!id) {
return
}
let sql = `delete from ${table.userName} where userId = '${id}'`;
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
await sqllitedb.executeSQL(sql);
},
async info(id) { async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB() let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `select * from ${table.userName} where userId = '${id}'`; let sql = `select * from ${table.userName} where userId = '${id}'`;
...@@ -41,10 +47,11 @@ export default { ...@@ -41,10 +47,11 @@ export default {
async changePwd(data) { async changePwd(data) {
let { let {
userName, userName,
userpwd userPwd,
userId
} = data } = data
let sqllitedb = await SqlliteDbUtil.initSqlliteDB() let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `update ${table.userName} set userpwd = ${userpwd} where userName = '${userName} and userId = '${userId}'`; let sql = `update ${table.userName} set userPwd = ${userPwd} where userName = '${userName} and userId = '${userId}'`;
let res = await sqllitedb.executeSQL(sql); let res = await sqllitedb.executeSQL(sql);
}, },
......
[
{
"id": "f7f20d3d78902f8d105e7d62d6e60ba0",
"roomName": "测试机房1",
"show": "0",
"roomDesc": "G座-1层",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/25/20de409bc81f48dbbeaeb9c198683ee6_20250325143326A008.jpeg,http://192.168.100.103:8099/profile/upload/2025/03/25/1711459331134717_20250325143340A009.png",
"delFlag": "0",
"synFlag": 1,
"sort": 1,
"roomType": 1,
"buildingId": "8a02454d00bd9df7bda41f7d1a6c471e",
"buildingName": "G座",
"createBy": "",
"createTime": 1743593139000,
"updateBy": "",
"updateTime": 1743593139000,
"params": {}
},
{
"id": "d34d5168a7df3e58c572f295600a2fd6",
"roomName": "测试井道1",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 1,
"roomType": 0,
"buildingId": "71dbde340369e1188acbbb8307d4504e",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "34bb5866808c9314925e0b353489953f",
"roomName": "qwer1234",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 1,
"roomType": 0,
"buildingId": "10",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "225919124fe0774ff3979492c3c87e37",
"roomName": "测试C座井道",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 1,
"roomType": 0,
"buildingId": "cf53d80f01241013d498a9f52d58b793",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "85e2ce1eeb10420dd0e6e0017963c93e",
"roomName": "去去去",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 1,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "11",
"roomName": "A2汇聚机房",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
"delFlag": "0",
"synFlag": 1,
"sort": 2,
"createBy": "",
"createTime": 1742546558000,
"updateBy": "",
"updateTime": 1742546558000,
"params": {}
},
{
"id": "58566b7779d1610d31c426ada192739e",
"roomName": "222222",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 2,
"roomType": 0,
"buildingId": "10",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "d8303fa14fca8afcdc29c9dc2977ab3f",
"roomName": "1111111",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 2,
"roomType": 0,
"buildingId": "cf53d80f01241013d498a9f52d58b793",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "807175f27fd108634fc01ef1083163df",
"roomName": "测试井道2",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 2,
"roomType": 0,
"buildingId": "71dbde340369e1188acbbb8307d4504e",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "325ccc5ab7e1bb2c5a3be74856613e14",
"roomName": "井道11",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 2,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "bb45d9ec394eeacb7d92183ecc34a9f1",
"roomName": "55555",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 3,
"roomType": 0,
"buildingId": "10",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "cd3483cb9adce351c95981f5b06399ec",
"roomName": "测试井道1",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 3,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "c76f9904aef0094e7e47ecec84b8678b",
"roomName": "2222",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 3,
"roomType": 0,
"buildingId": "cf53d80f01241013d498a9f52d58b793",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "58b0d83a6d34ac1f39d3f6af0123d657",
"roomName": "A2汇聚机房2",
"show": "0",
"roomDesc": "A座3楼",
"roomFile": "/profile/upload/2025/03/24/sample_640×426 - 副本_20250324135659A007.JPG",
"delFlag": "0",
"synFlag": 1,
"sort": 4,
"roomType": 1,
"buildingId": "8",
"buildingName": "A座",
"createBy": "",
"createTime": 1742804535000,
"updateBy": "",
"updateTime": 1742804535000,
"params": {}
},
{
"id": "c0ac5f5aa0970d447948346309e41e64",
"roomName": "测试井道2",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 4,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "9",
"roomName": "F3内环机房",
"show": "0",
"roomDesc": "市民中心A座3楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/20de409bc81f48dbbeaeb9c198683ee6_20250318141902A009.jpeg",
"delFlag": "0",
"synFlag": 1,
"sort": 4,
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"createBy": "",
"createTime": 1742799587000,
"updateBy": "",
"updateTime": 1742799587000,
"params": {}
},
{
"id": "3e08f060b5fbb94b213be5dff7ee22a7",
"roomName": "泰源8楼",
"show": "0",
"roomDesc": "泰源8楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/27/微信截图_20250327155657_20250327155711A005.png",
"delFlag": "0",
"synFlag": 1,
"sort": 4,
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "1a66483b513da0e5f4b9d64ab1acd38a",
"roomName": "测试井道3",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 5,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "10",
"roomName": "A2汇聚机房3",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
"delFlag": "0",
"synFlag": 1,
"sort": 5,
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"createBy": "",
"createTime": 1742785634000,
"updateBy": "",
"updateTime": 1742785634000,
"params": {}
},
{
"id": "1",
"roomName": "A2汇聚机房4",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
"delFlag": "0",
"synFlag": 1,
"sort": 6,
"roomType": 1,
"buildingId": "8",
"buildingName": "A1座",
"createBy": "",
"createTime": 1742785643000,
"updateBy": "",
"updateTime": 1742785643000,
"params": {}
},
{
"id": "77e85f5e4b15e77eff938d9af1d1bbb2",
"roomName": "测试井道5",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 6,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "56a96f9529d5b5413f156f6b2b536370",
"roomName": "测试井道6",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 7,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "7",
"roomName": "A2汇聚机房5",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
"delFlag": "0",
"synFlag": 1,
"sort": 7,
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"createBy": "",
"createTime": 1742785651000,
"updateBy": "",
"updateTime": 1742785651000,
"params": {}
},
{
"id": "43167468c318376a2ae8d1a049c59de3",
"roomName": "测试井道7",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 8,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "0f11ebcbd958176e4c90b3e516af2f57",
"roomName": "测试井道8",
"show": "0",
"delFlag": "0",
"synFlag": 1,
"sort": 9,
"roomType": 0,
"buildingId": "8",
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
"updateTime": 1743407833000,
"params": {}
},
{
"id": "586a67286d9d1d6e737f32d9e42c3054",
"roomName": "测试机房2",
"show": "0",
"roomDesc": "A座-3楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/20/sample_640×426 - 副本_20250320091529A001.JPG",
"delFlag": "0",
"synFlag": 1,
"sort": 9,
"roomType": 1,
"buildingId": "8",
"buildingName": "A1座",
"createBy": "",
"createTime": 1742785675000,
"updateBy": "",
"updateTime": 1742785675000,
"params": {}
}
]
\ No newline at end of file
[
{
"id": "8",
"buildingName": "A座",
"delFlag": "0",
"synFlag": 1,
"createBy": "",
"createTime": 1742867634000,
"updateBy": "",
"updateTime": 1742867634000,
"params": {}
},
{
"id": "10",
"buildingName": "B座",
"delFlag": "0",
"synFlag": 1,
"createBy": "",
"createTime": 1742785840000,
"updateBy": "",
"updateTime": 1742785840000,
"params": {}
},
{
"id": "cf53d80f01241013d498a9f52d58b793",
"buildingName": "C座",
"delFlag": "0",
"synFlag": 1,
"sort": 3,
"createBy": "",
"createTime": 1742785712000,
"updateBy": "",
"updateTime": 1742785712000,
"params": {}
},
{
"id": "71dbde340369e1188acbbb8307d4504e",
"buildingName": "D座",
"delFlag": "0",
"synFlag": 1,
"sort": 4,
"createBy": "",
"createTime": 1742785730000,
"updateBy": "",
"params": {}
},
{
"id": "3de9fe52b218aee86e4541ab403a0c48",
"buildingName": "E座",
"delFlag": "0",
"synFlag": 1,
"sort": 5,
"createBy": "",
"createTime": 1742785736000,
"updateBy": "",
"params": {}
},
{
"id": "5fe48aae7cd5a580750e5f5f932eae66",
"buildingName": "F座",
"delFlag": "0",
"synFlag": 1,
"sort": 6,
"createBy": "",
"createTime": 1742785742000,
"updateBy": "",
"params": {}
},
{
"id": "8a02454d00bd9df7bda41f7d1a6c471e",
"buildingName": "G座",
"delFlag": "0",
"synFlag": 1,
"sort": 7,
"createBy": "",
"createTime": 1742867522000,
"updateBy": "",
"params": {}
}
]
\ No newline at end of file
<template> <template>
<!-- 登录页 --> <!-- 登录页 -->
<view class="content"> <view class="content">
<view class="login_wrap"> <view class="login_wrap">
{{personList}}
<view class="top-module"> <view class="top-module">
<image src="@/static/logo.png" mode="aspectFit" alt="" /> <image src="@/static/logo.png" mode="aspectFit" alt="" />
<view class="title">杭州内网监管在线-运维在线</view> <view class="title">杭州内网监管在线-运维在线</view>
...@@ -28,7 +26,6 @@ ...@@ -28,7 +26,6 @@
</template> </template>
<script> <script>
import initService from '@/api/sqllite/init.js'
import userApi from "@/api/user.js" import userApi from "@/api/user.js"
import SqlliteDbUtil from '@/utils/sqllitedb' import SqlliteDbUtil from '@/utils/sqllitedb'
import table from '@/api/sqllite/table.js' import table from '@/api/sqllite/table.js'
...@@ -64,11 +61,7 @@ ...@@ -64,11 +61,7 @@
return this.passwordVisible ? "密码" : "********"; return this.passwordVisible ? "密码" : "********";
}, },
}, },
onLoad: function(query) {
initService.init()
console.log('即将开始初始化app')
},
created() {}, created() {},
onShow() {}, onShow() {},
async mounted() { async mounted() {
...@@ -95,6 +88,13 @@ ...@@ -95,6 +88,13 @@
return true; return true;
}, },
methods: { methods: {
changePwd(){
userApi.changePwd({
userName:'叶一凡',
userPwd:'qwer1234',
userId:'29'
})
},
// 切换密码显示/隐藏 // 切换密码显示/隐藏
togglePasswordVisible() { togglePasswordVisible() {
this.passwordVisible = !this.passwordVisible; this.passwordVisible = !this.passwordVisible;
...@@ -103,6 +103,10 @@ ...@@ -103,6 +103,10 @@
async login() { async login() {
userApi.login(this.person).then((personList) => { userApi.login(this.person).then((personList) => {
this.personList = personList.data; this.personList = personList.data;
this.$store.commit("SET_USER", this.personList);
uni.navigateTo({
url: "/pages/home/home",
});
}); });
}, },
}, },
......
...@@ -198,11 +198,7 @@ async function importBaseFile() { ...@@ -198,11 +198,7 @@ async function importBaseFile() {
} else if (filename === 'user.json') { } else if (filename === 'user.json') {
await userApi.saveBatch(jsonData) await userApi.saveBatch(jsonData)
} }
} else if (fileEntry.isDirectory && fileEntry.name === 'template'){ }
// 廉政告知书、检查模板文件
const templateFileEntry = await ioUtil.getFileEntry(_Path.getTemplateFileDir())
await ioUtil.copyFileDir(fileEntry, templateFileEntry)
}
} }
// 删除文件和解压目录 // 删除文件和解压目录
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论