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

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

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