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

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

上级 3bb66450
...@@ -4,19 +4,18 @@ ...@@ -4,19 +4,18 @@
<uni-data-select <uni-data-select
class="uni-search-item" class="uni-search-item"
v-model="searchFrom.reportTime" v-model="searchFrom.reportTime"
:localdata="inspectArr" :localdata="reportList"
@change="(e) => change(e, 'reportTime')" @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>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { getReportSearch } from "@/request/index.js";
export default { export default {
props: { props: {
hiddenSearch: { hiddenSearch: {
...@@ -30,16 +29,17 @@ export default { ...@@ -30,16 +29,17 @@ export default {
data() { data() {
return { return {
searchFrom: { searchFrom: {
reportTime: "202410", reportTime: "",
}, },
reportList: [],
inspectArr: [
{ value: "202410", text: "2024年10月" },
{ value: "202411", text: "2024年11月" },
],
}; };
}, },
created() {
getReportSearch().then((res) => {
this.searchFrom.reportTime = res.defaultReportTime;
this.reportList = res.reportList;
});
},
methods: { methods: {
change(e, key) { change(e, key) {
this.searchFrom[key] = e; this.searchFrom[key] = e;
......
<template> <template>
<view class="padding_all_16 page_box"> <view class="padding_all_16 page_box">
<SearchCom @change="searchChange" /> <SearchCom @change="searchChange" />
<!-- 态势分析研判报告 --> <!-- 态势分析研判报告 -->
...@@ -12,7 +11,7 @@ ...@@ -12,7 +11,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>
...@@ -285,9 +284,9 @@ import rightBar from "./components/rightBar.vue"; ...@@ -285,9 +284,9 @@ 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 { getReportList, getReportSearch } from "@/request/index.js";
import SearchCom from "@/components/searchCom/index.vue" import SearchCom from "@/components/searchCom/index.vue";
import { import {
terminal, terminal,
...@@ -312,7 +311,7 @@ export default { ...@@ -312,7 +311,7 @@ export default {
rightItem, rightItem,
rightBar, rightBar,
rightLine, rightLine,
SearchCom SearchCom,
}, },
data() { data() {
return { return {
...@@ -329,33 +328,36 @@ export default { ...@@ -329,33 +328,36 @@ export default {
allReport: [], // 所有汇报数据 allReport: [], // 所有汇报数据
defaultReportTime: "202410",// 默认选中时间
}; };
}, },
created() { created() {
this.init();
},
methods: {
async init() {
const allReport = await getReportList();
this.allReport = allReport;
getReportList().then((res) => { getReportSearch().then((res) => {
this.allReport = res.map(item => JSON.parse(item)) console.log("-getReportSearch-", res);
this.getDetailData(this.defaultReportTime) this.getDetailData(res.defaultReportTime);
}); });
}, },
methods: {
getDetailData(reportTime) { getDetailData(reportTime) {
// const result = this.allReport.filter(item => item.data.reportTime == reportTime)[0] // const result = this.allReport.filter(item => item.data.reportTime == reportTime)[0]
// console.log("--result-", result) // console.log("--result-", result)
// this.detailData = mergeObjectsWithUnderscoreKey(result.data); // this.detailData = mergeObjectsWithUnderscoreKey(result.data);
this.detailData = mergeObjectsWithUnderscoreKey(result);
this.detailData = mergeObjectsWithUnderscoreKey(result);
}, },
// 搜索 change // 搜索 change
searchChange(val){ searchChange(val) {
console.log("searchItem", val) console.log("searchItem", val);
this.getDetailData(val.reportTime) this.getDetailData(val.reportTime);
},
}
}, },
}; };
</script> </script>
......
...@@ -3,7 +3,9 @@ import { ...@@ -3,7 +3,9 @@ import {
readLogData, readLogData,
readInspectionData, readInspectionData,
readDarfData, readDarfData,
readReportData readReportData,
readReportSEarchData
} from "@/utils/IoReadingAndWriting.js"; } from "@/utils/IoReadingAndWriting.js";
import lodash from "lodash"; import lodash from "lodash";
...@@ -112,8 +114,31 @@ export const getReportList = () => { ...@@ -112,8 +114,31 @@ export const getReportList = () => {
readReportData() readReportData()
.then((res) => { .then((res) => {
store.commit("SET_REPORT_LIST", res); const temp = res.map(item => JSON.parse(item))
resolve(res) store.commit("SET_REPORT_LIST", temp);
resolve(temp)
})
.catch((error) => {
reject(error)
})
})
}
// 获取 内置搜索内容
export const getReportSearch = () => {
return new Promise((resolve, reject) => {
if(store.state.reportSearch.length){
resolve(store.state.reportSearch)
return;
}
readReportSEarchData()
.then((res) => {
store.commit("SET_REPORT_SEARCH", JSON.parse(res[0]));
resolve(JSON.parse(res[0]))
}) })
.catch((error) => { .catch((error) => {
reject(error) reject(error)
......
No preview for this file type
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论