提交 c528b6d4 authored 作者: JaxBBLL's avatar JaxBBLL
......@@ -8,6 +8,7 @@ import assRoomApi from '@/api/assRoom.js'
import hoistwayjson from '../../baseData/hoistway.json'
import userjson from '../../baseData/user.json'
import assroomjson from '../../baseData/assroom.json'
import fileImport from '@/utils/fileImport.js'
export default {
// app初始化
......@@ -25,8 +26,8 @@ export default {
// 导入用戶文件文件
// await this.importFileData();
await userApi.saveBatch(userjson)
await hoistwayApi.saveBatch(hoistwayjson)
await assRoomApi.saveBatch(assroomjson)
// await hoistwayApi.saveBatch(hoistwayjson)
// await assRoomApi.saveBatch(assroomjson)
// 初始化完成通知首页
uni.$emit("initDone", "ok")
uni.hideLoading()
......
......@@ -28,7 +28,8 @@ module.exports = {
],
// 巡检记录表
inspectionRecordName: "INSPECTION_RECORD",
inspectionRecord: [{
inspectionRecord: [
{
field: "id",
format: "TEXT NOT NULL",
},
......@@ -93,7 +94,8 @@ module.exports = {
// 机房、井道信息表
assRoomName: "ASS_ROOM",
assRoom: [{
assRoom: [
{
field: "id",
format: "TEXT NOT NULL",
},
......@@ -166,11 +168,20 @@ module.exports = {
{
field: "SHOW",
format: "TEXT",
},
{
field: "roomFeature",
format: "TEXT",
},
{
field: "dictValue",
format: "TEXT",
}
],
// 楼宇信息
assBuildingName: "ASS_BUILDING",
assBuilding: [{
assBuilding: [
{
field: "id",
format: "TEXT NOT NULL",
},
......
......@@ -15,9 +15,10 @@ export default {
async login(data) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let account = data.account
let pwd = data.pwd
let {
account,
pwd
} = data
const sql = `select * from ${table.userName} where userName = '${account}'`
let res = await sqllitedb.selectSQL(sql);
......@@ -27,7 +28,7 @@ export default {
msg: '登录成功'
};
},
async remove(id) {
async remove(id) {
if (!id) {
return
}
......@@ -47,12 +48,30 @@ async remove(id) {
async changePwd(data) {
let {
userName,
userPwd,
oldPwd,
newPwd,
userId
} = data
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `update ${table.userName} set userPwd = ${userPwd} where userName = '${userName} and userId = '${userId}'`;
let res = await sqllitedb.executeSQL(sql);
const [current] = await sqllitedb.selectSQL(
`select * from ${table.userName} where userId = '${userId}' and userName = '${userName}'`, [userId,
userName
]
);
if (current.password !== oldPwd) {
return {
data: false,
msg: '原密码错误'
};
}
const update = await sqllitedb.executeSQL(
`UPDATE ${table.userName} SET password = '${newPwd}'
WHERE userId = '${userId}'`
);
return {
data: true,
msg: '恭喜您,密码更新成功。'
};
},
async saveBatch(list) {
......
[
{
"id": "f7f20d3d78902f8d105e7d62d6e60ba0",
"roomName": "测试机房1",
"id": "1",
"roomName": "F3内环屏蔽机房",
"roomFeature":"2",
"dictValue": "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,
"synFlag": 0,
"sort": 1,
"roomType": 1,
"buildingId": "8a02454d00bd9df7bda41f7d1a6c471e",
"buildingName": "G座",
"keynoteFlag": 0,
"roomFeature": "1",
"roomArea": "60",
"createBy": "",
"createTime": 1743593139000,
"createTime": 1744009761000,
"updateBy": "",
"updateTime": 1743593139000,
"updateTime": 1744009761000,
"params": {}
},
{
......@@ -26,6 +31,7 @@
"sort": 1,
"roomType": 0,
"buildingId": "71dbde340369e1188acbbb8307d4504e",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -41,6 +47,7 @@
"sort": 1,
"roomType": 0,
"buildingId": "10",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -56,6 +63,7 @@
"sort": 1,
"roomType": 0,
"buildingId": "cf53d80f01241013d498a9f52d58b793",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -71,6 +79,7 @@
"sort": 1,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -86,6 +95,7 @@
"delFlag": "0",
"synFlag": 1,
"sort": 2,
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742546558000,
"updateBy": "",
......@@ -101,6 +111,7 @@
"sort": 2,
"roomType": 0,
"buildingId": "10",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -116,6 +127,7 @@
"sort": 2,
"roomType": 0,
"buildingId": "cf53d80f01241013d498a9f52d58b793",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -131,6 +143,7 @@
"sort": 2,
"roomType": 0,
"buildingId": "71dbde340369e1188acbbb8307d4504e",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -146,6 +159,7 @@
"sort": 2,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -161,6 +175,7 @@
"sort": 3,
"roomType": 0,
"buildingId": "10",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -176,6 +191,7 @@
"sort": 3,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -191,6 +207,7 @@
"sort": 3,
"roomType": 0,
"buildingId": "cf53d80f01241013d498a9f52d58b793",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -198,8 +215,10 @@
"params": {}
},
{
"id": "58b0d83a6d34ac1f39d3f6af0123d657",
"roomName": "A2汇聚机房2",
"id": "2",
"roomName": "F3外环屏蔽机房",
"roomFeature":"2",
"dictValue": "2",
"show": "0",
"roomDesc": "A座3楼",
"roomFile": "/profile/upload/2025/03/24/sample_640×426 - 副本_20250324135659A007.JPG",
......@@ -209,6 +228,7 @@
"roomType": 1,
"buildingId": "8",
"buildingName": "A座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742804535000,
"updateBy": "",
......@@ -224,6 +244,7 @@
"sort": 4,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -231,8 +252,10 @@
"params": {}
},
{
"id": "9",
"roomName": "F3内环机房",
"id": "3",
"roomName": "F2汇聚机房",
"roomFeature":"1",
"dictValue": "3",
"show": "0",
"roomDesc": "市民中心A座3楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/20de409bc81f48dbbeaeb9c198683ee6_20250318141902A009.jpeg",
......@@ -242,6 +265,7 @@
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742799587000,
"updateBy": "",
......@@ -249,8 +273,10 @@
"params": {}
},
{
"id": "3e08f060b5fbb94b213be5dff7ee22a7",
"roomName": "泰源8楼",
"id": "4",
"roomName": " A2汇聚机房",
"roomFeature":"1",
"dictValue": "4",
"show": "0",
"roomDesc": "泰源8楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/27/微信截图_20250327155657_20250327155711A005.png",
......@@ -260,6 +286,7 @@
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -275,6 +302,7 @@
"sort": 5,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -282,8 +310,11 @@
"params": {}
},
{
"id": "10",
"roomName": "A2汇聚机房3",
"id": "5",
"roomName": "A3屏蔽机房",
"roomFeature":"2",
"dictValue": "5",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
......@@ -293,6 +324,7 @@
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785634000,
"updateBy": "",
......@@ -300,8 +332,10 @@
"params": {}
},
{
"id": "1",
"roomName": "A2汇聚机房4",
"id": "6",
"roomName": "A-1UPS间",
"roomFeature":"3",
"dictValue": "6",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
......@@ -311,6 +345,7 @@
"roomType": 1,
"buildingId": "8",
"buildingName": "A1座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785643000,
"updateBy": "",
......@@ -326,6 +361,7 @@
"sort": 6,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -341,6 +377,7 @@
"sort": 7,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -349,7 +386,9 @@
},
{
"id": "7",
"roomName": "A2汇聚机房5",
"roomName": "B2汇聚机房",
"roomFeature":"1",
"dictValue": "7",
"show": "0",
"roomDesc": "市民中心A座4楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/18/1711459331134717_20250318150705A002.png",
......@@ -359,6 +398,7 @@
"roomType": 1,
"buildingId": "10",
"buildingName": "B座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785651000,
"updateBy": "",
......@@ -374,6 +414,7 @@
"sort": 8,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -389,6 +430,7 @@
"sort": 9,
"roomType": 0,
"buildingId": "8",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1743407833000,
"updateBy": "",
......@@ -396,8 +438,73 @@
"params": {}
},
{
"id": "586a67286d9d1d6e737f32d9e42c3054",
"roomName": "测试机房2",
"id": "8",
"roomName": "C2汇聚机房",
"roomFeature":"1",
"dictValue": "8",
"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座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785675000,
"updateBy": "",
"updateTime": 1742785675000,
"params": {}
},
{
"id": "9",
"roomName": "D2汇聚机房",
"roomFeature":"1",
"dictValue": "9",
"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座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785675000,
"updateBy": "",
"updateTime": 1742785675000,
"params": {}
},
{
"id": "10",
"roomName": "E2汇聚机房",
"roomFeature":"1",
"dictValue": "10",
"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座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785675000,
"updateBy": "",
"updateTime": 1742785675000,
"params": {}
},
{
"id": "11",
"roomName": "F-2UPS间",
"roomFeature":"1",
"dictValue": "11",
"show": "0",
"roomDesc": "A座-3楼",
"roomFile": "http://192.168.100.103:8099/profile/upload/2025/03/20/sample_640×426 - 副本_20250320091529A001.JPG",
......@@ -407,6 +514,7 @@
"roomType": 1,
"buildingId": "8",
"buildingName": "A1座",
"keynoteFlag": 0,
"createBy": "",
"createTime": 1742785675000,
"updateBy": "",
......
[ {
"userId": 29,
"userName": "叶一凡",
"userId": 1,
"userName": "姜安平",
"userType": "normal",
"avatar": "",
"password": "Jap@123",
"rememberPwd": "0"
}, {
"userId": 2,
"userName": "段树梁",
"userType": "sys_user",
"avatar": "",
"password": "Dsl@123",
"rememberPwd": "0"
}, {
"userId": 3,
"userName": "孔佳真",
"userType": "sys_user",
"avatar": "",
"password": "123456",
"password": "Kjz@123",
"rememberPwd": "0"
}, {
"userId": 30,
"userName": "bjqxj",
"userId": 4,
"userName": "钟校明",
"userType": "sys_user",
"avatar": "",
"password": "JF85250920",
"password": "Zxm@123",
"rememberPwd": "0"
}]
\ No newline at end of file
......@@ -28,9 +28,9 @@
src="@/static/img/add-img/home1.png"
mode="aspectFit"
></image>
<!-- <view class="change-password" @click="updatePassword"
<view class="change-password" @click="updatePassword"
>修改密码</view
> -->
>
</view>
<view class="username">{{ userName }}</view>
</view>
......@@ -76,24 +76,23 @@
export default {
data() {
return {
cards: [
{
image: "../../static/img/jf.png",
text: "机房巡检",
url: "/pages/inspectionContent/inspectionContentList?backValue=home",
cards: [{
image: '../../static/img/jf.png',
text: '机房巡检',
url:"/pages/inspectionContent/inspectionContentList?backValue=home"
},
{
image: "../../static/img/jd.png",
text: "井道巡检",
url: "/pages/shaftInspection/shaftInspectionList?backValue=home",
image: '../../static/img/jd.png',
text: '井道巡检',
url:"/pages/shaftInspection/shaftInspectionList?backValue=home"
},
{
image: "../../static/img/sj.png",
text: "设备上架",
url: "/pages/listingManagement/index?backValue=home",
},
image: '../../static/img/sj.png',
text: '设备上架',
url: "/pages/listingManagement/index?backValue=home"
}
],
userName: this.$store.state.now_user.user,
userName: this.$store.state.now_user.userName,
};
},
computed: {
......@@ -119,10 +118,11 @@ export default {
});
},
// 三模块卡片跳转页面
toList(url) {
toList(url){
uni.navigateTo({
url: url,
});
},
// 巡检管理
toInspectionManagement() {
......@@ -155,7 +155,8 @@ export default {
},
});
},
},
}
};
</script>
......
<template>
<view class="edit-password">
<uni-nav-bar
:fixed="true"
background-color="rgba(214, 240, 255, 0.0)"
status-bar
rightWidth="300"
>
<uni-nav-bar :fixed="true" background-color="rgba(214, 240, 255, 0.0)" status-bar rightWidth="300">
<block slot="left">
<view class="uni-nav-bar-text" @click="back">
<text class="iconfont icon-fanhui"></text
></view>
<text class="iconfont icon-fanhui"></text>
</view>
</block>
</uni-nav-bar>
{{user}}
<view class="edit-main">
<!-- 占位---不可删除 -->
<view class="seize-seat"> </view>
......@@ -23,28 +18,15 @@
<!-- <input type="text" class="uni-input" v-model="user.user" disabled="true" > -->
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-forms-item>
<uni-easyinput
class="uni-input"
v-model="user.user"
:disabled="true"
></uni-easyinput>
<uni-easyinput class="uni-input" v-model="user.userName" :disabled="true"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="oldPd">
<uni-easyinput
type="password"
class="uni-input"
placeholder="原密码"
v-model="formData.oldPd"
>
<uni-easyinput type="password" class="uni-input" placeholder="原密码" v-model="formData.oldPd">
</uni-easyinput>
</uni-forms-item>
<uni-forms-item name="newPd">
<uni-easyinput
type="password"
class="uni-input"
placeholder="新密码(密码必须为字母、数字,6-18个字符,区分大小写)"
v-model="formData.newPd"
>
<uni-easyinput type="password" class="uni-input" placeholder="新密码(密码必须为字母、数字,6-18个字符,区分大小写)"
v-model="formData.newPd">
</uni-easyinput>
</uni-forms-item>
<button type="primary" class="uni-btn" @click="clickEdit">
......@@ -58,20 +40,23 @@
</template>
<script>
import getDateTime from "@/common/getdateTime.js";
import { Base64 } from "js-base64";
import {
import getDateTime from "@/common/getdateTime.js";
import {
Base64
} from "js-base64";
import {
addLog,
getLogContent,
LOG_TYPE_ENUM,
} from "@/utils/IoReadingAndWriting.js";
} from "@/utils/IoReadingAndWriting.js";
import {
import {
SYNCHRONIZE_DATA_PAD,
createFileWithPlusIO,
USER_FILE_NAME,
} from "@/utils/systemCofig";
export default {
} from "@/utils/systemCofig";
import userApi from '@/api/user.js'
export default {
data() {
return {
user: {},
......@@ -82,16 +67,13 @@ export default {
},
rules: {
oldPd: {
rules: [
{
rules: [{
required: true,
errorMessage: "请输入原密码",
},
],
}, ],
},
newPd: {
rules: [
{
rules: [{
required: true,
errorMessage: "请输入新密码",
},
......@@ -99,8 +81,7 @@ export default {
{
minLength: 6,
maxLength: 18,
errorMessage:
"更新失败,密码必须为字母、数字,{minLength}-{maxLength}个字符,区分大小写",
errorMessage: "更新失败,密码必须为字母、数字,{minLength}-{maxLength}个字符,区分大小写",
},
],
label: "新密码",
......@@ -113,6 +94,7 @@ export default {
},
onShow() {
const value = this.$store.state.now_user;
console.log(value, '----')
if (value) {
this.user = value;
}
......@@ -141,73 +123,50 @@ export default {
.validate()
.then((res) => {
// 输入密码与该账号密码一致
if (this.formData.oldPd == this.user.passWord) {
const userId = this.user.userId;
const tempPersonList = this.personList.map((item) => {
if (item.userId == userId) {
item.passWord = this.formData.newPd;
}
return item;
});
const temp = JSON.stringify(tempPersonList);
const fileContent = JSON.stringify(Base64.encode(temp));
createFileWithPlusIO(
SYNCHRONIZE_DATA_PAD,
USER_FILE_NAME,
fileContent
).then((res) => {
uni.setStorageSync("user_data", temp);
userApi.changePwd({
userId: this.user.userId,
userName: this.user.userName,
oldPwd: this.formData.oldPd,
newPwd: this.formData.newPd
}).then((res) => {
if(res.data){
uni.showToast({
title: "恭喜您,密码更新成功!",
icon: "none",
duration: 2000,
});
// 生成日志
const logContent = getLogContent(LOG_TYPE_ENUM.updatePassword);
const log_list = this.$store.state.log_list;
log_list.push(logContent);
this.$store.commit("SET_LOG_LIST", log_list);
addLog(log_list).then((res) => {
icon: "success",
duration: 3000,
});
this.logOut();
});
} else {
this.formData = {
oldPd: "",
newPd: "",
};
}else{
uni.showToast({
title: "更新失败,原密码错误,请重新输入!",
icon: "none",
duration: 2000,
title: res.msg,
icon: "error",
duration: 3000,
});
}
});
})
.catch((err) => {});
},
},
};
};
</script>
<style lang="less" scoped>
.uni-easyinput__placeholder-class {
.uni-easyinput__placeholder-class {
font-size: 14px !important;
}
}
.edit-password {
.edit-password {
width: 100%;
height: 100%;
background-image: linear-gradient(
90deg,
background-image: linear-gradient(90deg,
#e9f7fe 0%,
#dceffe 40%,
#d5ebfd 66%,
#c9e8fe 100%
);
#c9e8fe 100%);
.edit-main {
margin-top: -44px;
......@@ -254,14 +213,13 @@ export default {
.seize-seat {
height: 50px;
width: 100%;
background-image: linear-gradient(
90deg,
background-image: linear-gradient(90deg,
#e9f7fe 0%,
#dceffe 40%,
#d5ebfd 66%,
#c9e8fe 100%
);
#c9e8fe 100%);
}
// 导航栏样式
.uni-nav-bar-text {
height: 36px;
......@@ -272,10 +230,11 @@ export default {
border-radius: 50%;
color: #333;
text-align: center;
.iconfont {
font-size: 20px;
line-height: 36px;
}
}
}
}
</style>
\ No newline at end of file
......@@ -43,11 +43,8 @@
data() {
return {
person: {
// user: "bjqxj",
// pd: "JF85250920",
account: "叶一凡", // 超管账号
pwd: "123456",
account: "姜安平", // 超管账号
pwd: "Jap@123",
},
backButtonPress: 0,
personList: [],
......@@ -88,25 +85,20 @@
return true;
},
methods: {
changePwd(){
userApi.changePwd({
userName:'叶一凡',
userPwd:'qwer1234',
userId:'29'
})
},
// 切换密码显示/隐藏
togglePasswordVisible() {
this.passwordVisible = !this.passwordVisible;
},
// 点击登录
async login() {
userApi.login(this.person).then((personList) => {
this.personList = personList.data;
userApi.login(this.person).then((res) => {
if (res.data) {
this.personList = res.data;
this.$store.commit("SET_USER", this.personList);
uni.navigateTo({
url: "/pages/home/home",
});
}
});
},
},
......
......@@ -9,19 +9,12 @@
// const userFilePath = "/storage/emulated/0/Android/data/io.dcloud.HBuilder/inspect/user/user.json"
// const userFilePath = "/storage/emulated/0/Android/data/io.dcloud.HBuilder/inspect/export/"
import userApi from '@/api/service/user'
import feedbackApi from '@/api/service/feedback'
import checkDetailApi from '@/api/service/checkDetail'
import templateApi from '@/api/service/feedbackTemplate'
import peopleApi from '@/api/service/peopleConfig'
import sampleApi from '@/api/service/sample'
import presenceApi from '@/api/service/presence'
import doubleRandomApi from '@/api/service/doubleRandom'
import userApi from '@/api/user.js'
import assroomApi from '@/api/assRoom.js'
import hoistwayApi from '@/api/hoistway.js'
import inspectApi from '@/api/inspect.js'
import _Path from '@/constant/ioPath'
import logger from './logger'
import ioUtil from "./ioUtil";
import dateUtil from "./date";
import cookie from './cookie'
// 检查是否有zip包
async function hasCheckFile() {
......@@ -31,126 +24,6 @@ async function hasCheckFile() {
zipFiles = zipFiles.filter(i => i.name.indexOf('.zip') !== -1);
return zipFiles.length;
}
// 导入检查数据
async function importCheckFile() {
const baseFilePath = _Path.getImportData()
const baseFileEntry = await ioUtil.getFileEntry(baseFilePath)
const unzipPath = baseFileEntry.fullPath + 'unzip/';
const zipFiles = await ioUtil.getFiles(baseFileEntry);
if (!zipFiles || zipFiles.length === 0) {
return
}
// 此处为每次导入的包
for (let zipFile of zipFiles) {
// 解压
if (zipFile.isDirectory || zipFile.name.indexOf('.zip') === -1) {
continue;
}
let dirName = zipFile.name.indexOf('.') > -1 ? zipFile.name.substring(0, zipFile.name.indexOf('.')) : zipFile.name
let unzipDir = unzipPath + dirName + '/'
await ioUtil.removeExistFile(unzipDir)
// 防止解压文件有问题
try{
let errorInfo = await ioUtil.decompressZip(zipFile.fullPath, unzipDir)
if (errorInfo && errorInfo.message) {
const errorDate = dateUtil.parseTime(new Date(), '{y}-{m}-{d}')
await ioUtil.createDir(_Path.getErrorDir(), errorDate)
const errorDirEntry = await ioUtil.getFileEntry(_Path.getErrorDir() + errorDate + '/')
await ioUtil.moveFile(zipFile, errorDirEntry)
}
}catch(e){
console.log(e.message)
}
let unzipDirEntry = await ioUtil.getFileEntry(unzipDir)
let checkZipFiles = await ioUtil.getFiles(unzipDirEntry)
// 导入数据
// 仅仅保证单个完整包不重复导入,单词导出检查数据是一致的
let checkList = []
for (let checkZipEntry of checkZipFiles) {
if (!checkZipEntry.isFile || checkZipEntry.name.indexOf('.zip') === -1) {
continue
}
let filename = ioUtil.getFilenameNoExt(checkZipEntry.name)
if (!filename || checkList.indexOf(filename) > -1) {
continue;
}
checkList.push(filename)
let nameArr = filename.split('_')
let id = nameArr[0]
let checkType = nameArr[1]
let checkPath = unzipDir + checkType + '/' + id
await ioUtil.decompressZip(checkZipEntry.fullPath, checkPath)
// 导入
await importCheck(checkPath, id, checkType)
}
// 处理完毕删除
await ioUtil.removeExistFile(zipFile.fullPath)
await ioUtil.removeExistFile(unzipDirEntry.fullPath)
}
}
// 导入检查
async function importCheck(checkPath, id, checkType) {
const checkDirEntry = await ioUtil.getFileEntry(checkPath)
const files = await ioUtil.getFiles(checkDirEntry)
if (!files || files.length === 0) {
return
}
// 创建附件文件目录
let checkFilePath = _Path.getCheckFileDir() + checkType + '/' + id
await ioUtil.removeExistFile(checkFilePath)
await ioUtil.createDir(_Path.getCheckFileDir(), checkType)
await ioUtil.createDir(_Path.getCheckFileDir() + '/' + checkType, id)
let checkFileEntry = await ioUtil.getFileEntry(checkFilePath)
for (let checkEntry of files) {
if (checkEntry.isFile && checkEntry.name.indexOf('.json') !== -1) {
// 写入数据库
let data = await ioUtil.readFile(checkEntry)
if (!data) {
continue
}
let checkData = JSON.parse(data)
// 把评分结果预先存入缓存,用于判断首页用户是否已评分
let checkScored = cookie.get('checkScored')
if (!checkScored) {
checkScored = {}
cookie.set('checkScored', checkScored)
}
const key = checkData.id + '_' + checkData.checkType
if (checkData.recheck === '1' && checkData.recheckScore) {
checkScored[key] = true
} else if (checkData.recheck === '0' && checkData.firstScore) {
checkScored[key] = true
} else {
checkScored[key] = false
}
cookie.set('checkScored', checkScored)
// 评分
await feedbackApi.saveBatch(checkData.feedbackList)
// 明细
await checkDetailApi.saveBatch(checkData.checkDetailList)
// 检查
if (checkData.checkType === '1') {
await sampleApi.save(checkData)
} else if (checkData.checkType === '2') {
await presenceApi.save(checkData)
} else if (checkData.checkType > 2) {
await doubleRandomApi.save(checkData)
}
} else {
await ioUtil.copyFileDir(checkEntry, checkFileEntry)
}
}
}
// 导入基础数据,包括:用户、人员配置、检查明细、评分表模板等
async function importBaseFile() {
......@@ -166,6 +39,7 @@ async function importBaseFile() {
await ioUtil.decompressZip(zipFileEntry.fullPath, unzipPath)
unzipEntry = await ioUtil.getFileEntry(unzipPath);
}
debugger
// 导入
let fileEntries = []
if (unzipEntry) {
......@@ -207,7 +81,6 @@ async function importBaseFile() {
}
export default {
importCheckFile,
importBaseFile,
hasCheckFile
};
......@@ -109,7 +109,6 @@ export default class SqlliteDB {
// 增删改使用
async executeSQL(sql) {
await this.checkDB();
// console.log('excuteSQL:' + sql)
return new Promise((resolve, reject) => {
plus.sqlite.executeSql({
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论