提交 3bb66450 authored 作者: 邓文彬's avatar 邓文彬

fix(文件读取): 文件读取

上级 4669d370
<script> <script>
import { import {
BASE_PATH,
SYNCHRONIZE_DATA_PATH,
SYNCHRONIZE_DATA_PAD, SYNCHRONIZE_DATA_PAD,
checkAndCreateDirectory, checkAndCreateDirectory,
checkFileExists, checkFileExists,
...@@ -13,7 +11,6 @@ import { ...@@ -13,7 +11,6 @@ import {
import { Base64 } from "js-base64"; import { Base64 } from "js-base64";
import {differenceBy} from "lodash"; import {differenceBy} from "lodash";
import { readDirectoryData } from "@/utils/IoReadingAndWriting.js";
export default { export default {
onLaunch: function () { onLaunch: function () {
// #ifdef APP-PLUS // #ifdef APP-PLUS
......
...@@ -2,52 +2,18 @@ ...@@ -2,52 +2,18 @@
<view class="search-com"> <view class="search-com">
<view class="search-com-left"> <view class="search-com-left">
<uni-data-select <uni-data-select
v-if="!hiddenSearch.includes('inspectionType')"
class="uni-search-item" class="uni-search-item"
v-model="searchFrom.inspectionType" v-model="searchFrom.reportTime"
:localdata="inspectArr" :localdata="inspectArr"
@change="(e) => change(e, 'inspectionType')" @change="(e) => change(e, 'reportTime')"
placeholder="巡检类型:全部" placeholder="选择月份"
:clear="true" :clear="true"
:key="new Date().getTime()" :key="new Date().getTime()"
></uni-data-select> ></uni-data-select>
<uni-data-select
v-if="!hiddenSearch.includes('synchronization')"
class="uni-search-item"
v-model="searchFrom.synchronization"
:localdata="synchronization"
placeholder="是否同步:全部"
@change="(e) => change(e, 'synchronization')"
:clear="true"
:key="new Date().getTime()"
></uni-data-select>
<uni-data-select
v-if="!hiddenSearch.includes('isException')"
class="uni-search-item"
v-model="searchFrom.isException"
:localdata="exceptionArr"
placeholder="有无异常:全部"
@change="(e) => change(e, 'isException')"
:clear="true"
:key="new Date().getTime()"
></uni-data-select>
</view> </view>
<view
class="search-com-right"
v-if="!hiddenSearch.includes('inspectionTime')"
>
<uni-datetime-picker
class="uni-datetime-picker"
type="daterange"
v-model="searchFrom.inspectionTime"
:border="false"
@change="(e) => change(e, 'inspectionTime')"
/>
</view>
</view> </view>
</template> </template>
<script> <script>
...@@ -64,27 +30,14 @@ export default { ...@@ -64,27 +30,14 @@ export default {
data() { data() {
return { return {
searchFrom: { searchFrom: {
inspectionType: "", // 巡检类型 reportTime: "202410",
synchronization: "", // 同部数据
isException: "", // 有无异常
inspectionTime: "", // 时间选择
}, },
inspectArr: [ inspectArr: [
{ value: "all", text: "全部" }, { value: "202410", text: "2024年10月" },
{ value: "1", text: "机房巡检" }, { value: "202411", text: "2024年11月" },
{ value: "2", text: "井道巡检" },
],
synchronization: [
{ value: "all", text: "全部" },
{ value: "0", text: "未同步" },
{ value: "1", text: "已同步" },
],
exceptionArr: [
{ value: "all", text: "全部" },
{ value: "1", text: "有异常" },
{ value: "0", text: "无异常" },
], ],
}; };
}, },
methods: { methods: {
...@@ -104,7 +57,7 @@ export default { ...@@ -104,7 +57,7 @@ export default {
.search-com-left { .search-com-left {
display: flex; display: flex;
align-items: center; align-items: center;
flex: 1; width: 200px;
.uni-search-item { .uni-search-item {
margin-right: 12px; margin-right: 12px;
width: 130px; width: 130px;
......
...@@ -2,18 +2,17 @@ ...@@ -2,18 +2,17 @@
<view class="home-page"> <view class="home-page">
<view class="left-tab"> <view class="left-tab">
<view class="user-info"> <view class="user-info">
<image class="user-img" src="@/static/img/add-img/home1.png"></image> <view class="user-img">
<image src="@/static/img/portrait.png"></image>
</view>
<text class="text">{{ userName }}</text> <text class="text">{{ userName }}</text>
</view> </view>
<view class="button-group"> <view class="button-group">
<!-- <view class="log-button" @click="updatePassword">修改密码?</view> <!-- <view class="log-button" @click="updatePassword">修改密码?</view>
<view class="log-button" @click="lookLog">操作日志</view> --> <view class="log-button" @click="lookLog">操作日志</view> -->
<view class="reset-password-button" @click="updatePassword" <view class="reset-password-button" @click="updatePassword"
>修改密码?</view >修改密码?</view
> >
...@@ -23,7 +22,6 @@ ...@@ -23,7 +22,6 @@
<!-- 内容区 --> <!-- 内容区 -->
<view class="right-container"> <view class="right-container">
<MonthReport /> <MonthReport />
<RouterView /> <RouterView />
</view> </view>
...@@ -43,16 +41,15 @@ ...@@ -43,16 +41,15 @@
<script> <script>
import OperLog from "@/pages/index/operLog.vue"; import OperLog from "@/pages/index/operLog.vue";
import MonthReport from "@/pages/monthReport/index.vue" import MonthReport from "@/pages/monthReport/index.vue";
export default { export default {
components: { components: {
OperLog, OperLog,
MonthReport MonthReport,
}, },
data() { data() {
return { return {
userName: this.$store.state.now_user.user, userName: this.$store.state.now_user.user,
}; };
}, },
...@@ -61,12 +58,8 @@ export default { ...@@ -61,12 +58,8 @@ export default {
return this.$store.state.now_user.isAdmin; return this.$store.state.now_user.isAdmin;
}, },
}, },
onLoad(options = {}) { onLoad(options = {}) {},
watch: {},
},
watch: {
},
methods: { methods: {
// 修改密码 // 修改密码
updatePassword() { updatePassword() {
...@@ -80,7 +73,6 @@ export default { ...@@ -80,7 +73,6 @@ export default {
uni.navigateTo({ uni.navigateTo({
url: "/pages/index/operLog", url: "/pages/index/operLog",
}); });
}, },
//退出--弹出对话框 //退出--弹出对话框
...@@ -95,9 +87,6 @@ export default { ...@@ -95,9 +87,6 @@ export default {
"last_time", "last_time",
this.$store.state.now_user.LastSynchronizationTime || "" this.$store.state.now_user.LastSynchronizationTime || ""
); );
}, },
}); });
}, },
...@@ -106,7 +95,6 @@ export default { ...@@ -106,7 +95,6 @@ export default {
this.$refs.inputDialog2.open(); this.$refs.inputDialog2.open();
}, },
toIndex() { toIndex() {
uni.navigateTo({ uni.navigateTo({
url: "/pages/index/index", url: "/pages/index/index",
...@@ -146,6 +134,10 @@ export default { ...@@ -146,6 +134,10 @@ export default {
border-radius: 50%; border-radius: 50%;
overflow: hidden; overflow: hidden;
box-shadow: 5px 5px 10px #e7e7e7; box-shadow: 5px 5px 10px #e7e7e7;
image{
height: 48px;
width: 48px;
}
} }
.text { .text {
font-size: 16px; font-size: 16px;
......
...@@ -22,12 +22,10 @@ export default { ...@@ -22,12 +22,10 @@ export default {
value: { value: {
type: Number, type: Number,
default: 0, default: 0,
} },
}, },
data() { data() {
return { return {};
};
}, },
onLoad() {}, onLoad() {},
...@@ -36,7 +34,6 @@ export default { ...@@ -36,7 +34,6 @@ export default {
let dataTmp = this.value || 0; let dataTmp = this.value || 0;
let max = 100; let max = 100;
let min = 0; let min = 0;
let scoresPercentage = dataTmp / max;
let name = "健康指数"; let name = "健康指数";
return { return {
backgroundColor: "#fff", backgroundColor: "#fff",
...@@ -115,7 +112,6 @@ export default { ...@@ -115,7 +112,6 @@ export default {
//底部点位名称 //底部点位名称
detail: { detail: {
show: false, show: false,
}, },
data: [ data: [
{ {
......
<template> <template>
<view class="padding_all_16 page_box"> <view class="padding_all_16 page_box">
<SearchCom @change="searchChange" />
<!-- 态势分析研判报告 --> <!-- 态势分析研判报告 -->
<view class="margin_t_16 padding_16_24 background_white"> <view class="margin_t_16 padding_16_24 background_white">
<common-top-title <common-top-title
...@@ -9,7 +12,7 @@ ...@@ -9,7 +12,7 @@
<view class="rightOne"> <view class="rightOne">
<rightPie <rightPie
class="margin_t_16 rightPie" class="margin_t_16 rightPie"
:value="detailData.report_value" :value="detailData.report_value "
/> />
<rightItem :detailData="detailData" class="rightItem" /> <rightItem :detailData="detailData" class="rightItem" />
</view> </view>
...@@ -280,7 +283,11 @@ import rightPie from "./components/rightPie.vue"; ...@@ -280,7 +283,11 @@ import rightPie from "./components/rightPie.vue";
import rightItem from "./components/rightItem.vue"; import rightItem from "./components/rightItem.vue";
import rightBar from "./components/rightBar.vue"; import rightBar from "./components/rightBar.vue";
import rightLine from "./components/rightLine.vue"; import rightLine from "./components/rightLine.vue";
import {mergeObjectsWithUnderscoreKey} from "./_monthReportUtil.js" import { mergeObjectsWithUnderscoreKey } from "./_monthReportUtil.js";
import { getReportList } from "@/request/index.js";
import SearchCom from "@/components/searchCom/index.vue"
import { import {
terminal, terminal,
...@@ -305,6 +312,7 @@ export default { ...@@ -305,6 +312,7 @@ export default {
rightItem, rightItem,
rightBar, rightBar,
rightLine, rightLine,
SearchCom
}, },
data() { data() {
return { return {
...@@ -318,16 +326,36 @@ export default { ...@@ -318,16 +326,36 @@ export default {
fbData, fbData,
detailData: {}, //数据详情 detailData: {}, //数据详情
allReport: [], // 所有汇报数据
defaultReportTime: "202410",// 默认选中时间
}; };
}, },
created() { created() {
this.getDetailData();
getReportList().then((res) => {
this.allReport = res.map(item => JSON.parse(item))
this.getDetailData(this.defaultReportTime)
});
}, },
methods: { methods: {
getDetailData() { getDetailData(reportTime) {
// const result = this.allReport.filter(item => item.data.reportTime == reportTime)[0]
// console.log("--result-", result)
// this.detailData = mergeObjectsWithUnderscoreKey(result.data);
this.detailData = mergeObjectsWithUnderscoreKey(result); this.detailData = mergeObjectsWithUnderscoreKey(result);
}, },
// 搜索 change
searchChange(val){
console.log("searchItem", val)
this.getDetailData(val.reportTime)
}
}, },
}; };
</script> </script>
......
...@@ -2,7 +2,8 @@ import store from "../store/index"; ...@@ -2,7 +2,8 @@ import store from "../store/index";
import { import {
readLogData, readLogData,
readInspectionData, readInspectionData,
readDarfData readDarfData,
readReportData
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import lodash from "lodash"; import lodash from "lodash";
...@@ -99,3 +100,24 @@ export const getDarft = () => { ...@@ -99,3 +100,24 @@ export const getDarft = () => {
}) })
}) })
} }
// 获取所有月报数据
export const getReportList = () => {
return new Promise((resolve, reject) => {
if(store.state.reportList.length){
resolve(store.state.reportList)
return;
}
readReportData()
.then((res) => {
store.commit("SET_REPORT_LIST", res);
resolve(res)
})
.catch((error) => {
reject(error)
})
})
}
差异被折叠。
...@@ -21,6 +21,8 @@ const store = new Vuex.Store({ ...@@ -21,6 +21,8 @@ const store = new Vuex.Store({
flgObj: false, flgObj: false,
roomNum: null, roomNum: null,
startTime: "", startTime: "",
reportList: [], // 所有月报数据
}, },
mutations: { mutations: {
SET_STARTTIME(state, payload) { SET_STARTTIME(state, payload) {
...@@ -71,6 +73,13 @@ const store = new Vuex.Store({ ...@@ -71,6 +73,13 @@ const store = new Vuex.Store({
// 保存 日志文件 // 保存 日志文件
state.log_list = payload; state.log_list = payload;
}, },
SET_REPORT_LIST(state, payload) {
// 保存 月报数据
state.reportList = payload;
},
}, },
}); });
......
...@@ -410,3 +410,20 @@ export const readDirectoryData = () => { ...@@ -410,3 +410,20 @@ export const readDirectoryData = () => {
}); });
}); });
}; };
// 读取报告数据
export const readReportData = () => {
const directoryPath = `${SYNCHRONIZE_DATA_PAD}/reportData`
return new Promise((resolve, reject) => {
readFilesInDirectory(directoryPath)
.then((res) => {
resolve(lodash.flattenDeep(res));
})
.catch((error) => reject(error));
});
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论