123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993 |
- <template>
- <div class="home" v-loading="loading">
- <div class="second">
- <div class="topPanel">
- <!-- 原始数据 -->
- <div class="tPanel">
- <el-table size="mini" :data="originalList">
- <el-table-column prop="dataName" label="数据" align="center">
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.dataName"
- placement="top"
- >
- <!-- @click="handleFile(scope.row.id, null)" -->
- <span class="file">{{ scope.row.dataName }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 去噪 -->
- <div class="tPanel">
- <el-table size="mini" :data="denoisingList">
- <el-table-column
- prop="processedDataName"
- label="处理前数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="beforeFile">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="resultDataName"
- label="处理后数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.resultDataName"
- placement="top"
- >
- <span class="file" @click="handleFile(scope.row, 2)">{{
- scope.row.resultDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="processStatus"
- label="状态"
- align="center"
- width="60"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.biz_process_status"
- :value="scope.row.processStatus"
- />
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 特征提取 -->
- <div class="tPanel">
- <el-table size="mini" :data="featureExtractionList">
- <el-table-column
- prop="processedDataName"
- label="处理前数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="beforeFile">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="resultDataName"
- label="处理后数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.resultDataName"
- placement="top"
- >
- <span class="file" @click="handleFile(scope.row, 4)">{{
- scope.row.resultDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="processStatus"
- label="状态"
- align="center"
- width="60"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.biz_process_status"
- :value="scope.row.processStatus"
- />
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 故障预测 -->
- <div class="tPanel">
- <el-table size="mini" :data="faultPredictionList">
- <el-table-column
- prop="processedDataName"
- label="处理前数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="beforeFile">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="resultDataName"
- label="处理后数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.resultDataName"
- placement="top"
- >
- <span class="file" @click="handleFile(scope.row, 6)">{{
- scope.row.resultDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="processStatus"
- label="状态"
- align="center"
- width="60"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.biz_process_status"
- :value="scope.row.processStatus"
- />
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <div class="step">
- <div class="yuan">
- <div class="img yuanBg odd">
- <div class="tag">原始数据</div>
- </div>
- </div>
- <div class="one">
- <div class="img oneBg even" @click="handleProcess(0)">
- <div class="tag">补全</div>
- </div>
- </div>
- <div class="two">
- <div class="img twoBg odd" @click="handleProcess(1)">
- <div class="tag">去噪</div>
- </div>
- </div>
- <div class="three">
- <div class="img threeBg even" @click="handleProcess(2)">
- <div class="tag">扩充</div>
- </div>
- </div>
- <div class="four">
- <div class="img fourBg odd" @click="handleProcess(3)">
- <div class="tag">特征提取</div>
- <div class="tag2">故障诊断</div>
- </div>
- </div>
- <div class="five">
- <div class="img fiveBg even" @click="handleProcess(4)">
- <div class="tag">退化评估</div>
- </div>
- </div>
- <div class="six">
- <div
- class="img sixBg odd noAfter"
- style="content: none"
- @click="handleProcess(5)"
- >
- <div class="tag">故障预测</div>
- </div>
- </div>
- </div>
- <div class="bottomPanel">
- <!-- 补全 -->
- <div class="bPanel">
- <el-table size="mini" :data="completionList">
- <el-table-column
- prop="processedDataName"
- label="处理前数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="beforeFile">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="resultDataName"
- label="处理后数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.resultDataName"
- placement="top"
- >
- <span class="file" @click="handleFile(scope.row, 1)">{{
- scope.row.resultDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="processStatus"
- label="状态"
- align="center"
- width="60"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.biz_process_status"
- :value="scope.row.processStatus"
- />
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 扩充 -->
- <div class="bPanel">
- <el-table size="mini" :data="expansionList">
- <el-table-column
- prop="processedDataName"
- label="处理前数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="beforeFile">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="resultDataName"
- label="处理后数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="file" @click="handleFile(scope.row, 3)">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="processStatus"
- label="状态"
- align="center"
- width="60"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.biz_process_status"
- :value="scope.row.processStatus"
- />
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 退化评估 -->
- <div class="bPanel">
- <el-table size="mini" :data="assessmentList">
- <el-table-column
- prop="processedDataName"
- label="处理前数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.processedDataName"
- placement="top"
- >
- <span class="beforeFile">{{
- scope.row.processedDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="resultDataName"
- label="处理后数据"
- align="center"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.resultDataName"
- placement="top"
- >
- <span class="file" @click="handleFile(scope.row, 5)">{{
- scope.row.resultDataName
- }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- prop="processStatus"
- label="状态"
- align="center"
- width="60"
- >
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.biz_process_status"
- :value="scope.row.processStatus"
- />
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div></div>
- </div>
- </div>
- <div class="first">
- <h4 style="margin: 13px 0px 0px 20px; color: #fff">算法统计</h4>
- <div class="chart">
- <RingChart
- v-if="flag"
- :total="ringTotal"
- :agloTypeData="agloTypeData"
- />
- <BarChart v-if="flag" :agloTypeData="agloTypeData" width="700px" />
- </div>
- </div>
- <el-dialog
- :title="title"
- :visible.sync="dialogVisible"
- width="30%"
- :close-on-click-modal="false"
- >
- <el-form ref="formRef" :model="form" :rules="rules" label-width="80px">
- <el-form-item
- v-if="dialogType === 3"
- label="选择数据类型"
- label-width="120px"
- >
- <el-radio-group v-removeAriaHidden v-model="type">
- <el-radio :label="2">去噪</el-radio>
- <el-radio :label="3">扩充</el-radio>
- <!-- <el-radio :label="4">特征提取</el-radio> -->
- </el-radio-group>
- </el-form-item>
- <el-form-item label="数据" prop="processType">
- <el-select
- v-model="form.processedDataId"
- placeholder="请选择执行的数据"
- >
- <el-option
- v-for="(item, index) in optionalData"
- :key="index"
- :label="item.dataName"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="算法" prop="processType">
- <el-select v-model="form.processAlgId" placeholder="请选择执行的算法">
- <el-option
- v-for="(item, index) in optionalAglo"
- :key="index"
- :label="item.algName"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="submitHandle()">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog
- v-loading="loading"
- title="数据展示"
- :visible.sync="fileShowVisible"
- width="80%"
- :close-on-click-modal="false"
- >
- <el-button
- v-if="!['4', '5'].includes(fileType)"
- style="margin-left: 50px"
- type="text"
- @click="changeShow"
- >{{ isTableShow ? "表格展示" : "曲线展示" }}</el-button
- >
- <div v-if="isTableShow && !['4', '5'].includes(fileType)">
- <vxe-table
- border="none"
- size="mini"
- show-overflow
- highlight-hover-row
- height="400"
- :row-config="{ isHover: true, isCurrent: true }"
- :sort-config="{ trigger: 'cell' }"
- :data="completionData"
- >
- <vxe-table-column
- v-for="(item, index) in completionHeadData"
- :key="index"
- align="center"
- :field="'val' + index"
- :title="item"
- ></vxe-table-column>
- </vxe-table>
- </div>
- <!-- <div v-if="!isTableShow && fileType !== '5'" ref="beforeChartRef" style="width: 100%; height: 400px;"></div> -->
- <PreCharts
- v-if="!isTableShow && !['4', '5'].includes(fileType)"
- :title="'处理前数据'"
- :chartData="preChartData"
- />
- <CurveCharts
- style="margin-top: 20px"
- v-if="!isTableShow && !['4', '5'].includes(fileType) && !isImgShow"
- :title="'处理后数据'"
- :chartData="resultChartData"
- />
- <!-- 有图片显示图片,没图片显示数据 -->
- <div
- v-if="!isTableShow && !['4', '5'].includes(fileType) && isImgShow"
- class="imgShow"
- >
- <div class="imgTitle">处理后图片</div>
- <ImagePreview class="image-preview" :src="imgUrl"></ImagePreview>
- </div>
- <!-- <div
- v-if="!isTableShow && !['4', '5'].includes(fileType)"
- ref="completionChartRef"
- style="width: 100%; height: 400px"
- ></div> -->
- <ImagePreview
- class="image-preview"
- v-if="['4', '5'].includes(fileType)"
- :src="imgPreviewUrl"
- ></ImagePreview>
- <div class="remark">指标结果:{{ agloRemark }}</div>
- </el-dialog>
- </div>
- </template>
- <script>
- import CountTo from "vue-count-to";
- import RingChart from "@/views/homePage/ringChart";
- import PreCharts from "@/views/homePage/preCharts";
- import CurveCharts from "@/views/homePage/curveCharts";
- import BarChart from "@/views/dashboard/BarChart";
- import { getAlgConfigByType, listAlgConfig } from "@/api/system/algConfig";
- import { getDataProcessByType, addProcess } from "@/api/system/process";
- import { getDataByType, getData, listData } from "@/api/system/data";
- export default {
- name: "Index",
- dicts: ["biz_alg_type", "biz_process_status"],
- components: {
- CountTo,
- RingChart,
- BarChart,
- PreCharts,
- CurveCharts,
- },
- data() {
- return {
- loading: false,
- rules: {},
- title: "选择数据",
- baseUrl: process.env.VUE_APP_BASE_API,
- dialogVisible: false,
- fileShowVisible: false,
- originalList: [],
- denoisingList: [],
- completionList: [],
- expansionList: [],
- featureExtractionList: [],
- assessmentList: [],
- faultPredictionList: [],
- optionalData: [],
- optionalAglo: [],
- form: {
- processedDataId: null,
- processAlgId: null,
- },
- // 对话框展示数据内容
- completionData: [],
- completionHeadData: [],
- isTableShow: false,
- resultFileId: null,
- // filePath: null,
- fileType: null,
- imgPreviewUrl: null,
- type: 2,
- dialogType: null,
- preChartData: {},
- resultChartData: {},
- nowRow: {},
- nowTypeNum: null,
- agloRemark: "",
- ringTotal: 0,
- agloTypeData: [],
- flag: false,
- isImgShow: false,
- imgUrl: null,
- };
- },
- mounted() {},
- created() {
- this.getTotal();
- this.getTableData();
- },
- watch: {
- fileShowVisible(value) {
- if (!value) {
- this.isTableShow = false;
- }
- },
- type(value) {
- getDataByType(value).then((res) => {
- this.optionalData = res.data;
- });
- getAlgConfigByType(3).then((res) => {
- this.optionalAglo = res.data;
- });
- },
- },
- methods: {
- getTotal() {
- const queryParams = { pageNum: 1, pageSize: 1000 };
- listAlgConfig(queryParams).then((response) => {
- this.total = response.total;
- const typeFrequency = response.rows.map((item) => {
- return item.algType;
- });
- const countedTypeFrequency = typeFrequency?.reduce((obj, name) => {
- if (name in obj) {
- obj[name]++;
- } else {
- obj[name] = 1;
- }
- return obj;
- }, {});
- const agloType = this.dict.type.biz_alg_type;
- for (let key in this.dict.type.biz_alg_type) {
- this.agloTypeData.push({
- value: countedTypeFrequency[key],
- name: agloType[key].label,
- });
- }
- this.flag = true;
- });
- },
- getTableData() {
- const query = {
- dataType: 0,
- };
- listData(query).then((res) => {
- this.originalList = [];
- this.originalList = res.rows;
- });
- getDataProcessByType(0).then((res) => {
- this.completionList = [];
- this.completionList = res.data;
- });
- getDataProcessByType(1).then((res) => {
- this.denoisingList = [];
- this.denoisingList = res.data;
- });
- getDataProcessByType(2).then((res) => {
- this.expansionList = [];
- this.expansionList = res.data;
- });
- getDataProcessByType(3).then((res) => {
- this.featureExtractionList = [];
- this.featureExtractionList = res.data;
- });
- getDataProcessByType(4).then((res) => {
- this.assessmentList = [];
- this.assessmentList = res.data;
- });
- getDataProcessByType(5).then((res) => {
- this.faultPredictionList = [];
- this.faultPredictionList = res.data;
- });
- },
- goTarget(href) {
- window.open(href, "_blank");
- },
- handleProcess(type) {
- this.dialogVisible = true;
- this.dialogType = type;
- let match;
- if (type === 3) {
- const relation = [
- [3, 2],
- [3, 3],
- ];
- match = relation.find((item) => item[0] === type)[1];
- } else if (type === 5) {
- match = type - 1;
- } else {
- match = type;
- }
- // const relation = [[1, 0], [2, 1], [3, 2], [4, 2], [4, 3], [5, 4], [6, 4]]
- // const match = relation.find(item => item[0] === type)[1];
- getDataByType(match).then((res) => {
- this.optionalData = res.data;
- });
- getAlgConfigByType(type).then((res) => {
- this.optionalAglo = res.data;
- });
- },
- submitHandle() {
- addProcess(this.form).then((response) => {
- this.$modal.msgSuccess("开始执行");
- this.dialogVisible = false;
- this.form = {
- processedDataId: null,
- processAlgId: null,
- };
- this.optionalData = [];
- this.optionalAglo = [];
- this.getTableData();
- });
- },
- handleFile(row, typeNum) {
- this.nowRow = row;
- this.nowTypeNum = typeNum;
- this.resultFileId = row.resultDataId;
- this.fileType = row.processType;
- let _this = this;
- this.loading = true;
- if (typeNum === 5 || typeNum === 6) {
- getData(row.resultDataId).then((res) => {
- this.agloRemark = res.data.remark;
- this.imgPreviewUrl = res.data.imagePath;
- this.loading = false;
- this.fileShowVisible = true;
- });
- } else {
- getData(row.processedDataId).then((processedRes) => {
- const resData = processedRes.data;
- const url = process.env.VUE_APP_BASE_API + resData.dataPath;
- this.fetchLogFile(url)
- .then((text) => {
- let data, content, head;
- data = this.handleFileData(text);
- content = data.contentData;
- head = data.headData;
- if (resData.dataType == 0) {
- this.handlePreChartOption(content, head, true);
- } else {
- this.handlePreChartOption(content, head, false);
- }
- })
- .catch((error) => {
- console.error("Failed to fetch the log file:", error);
- this.$modal.msgSuccess("文件读取错误");
- this.loading = false;
- });
- });
- getData(row.resultDataId)
- .then((resultRes) => {
- const resData = resultRes.data;
- this.agloRemark = resData.remark;
- const url = process.env.VUE_APP_BASE_API + resData.dataPath;
- // resultRes.data.imagePath =
- // "/profile/upload/2024/12/06/testdata1_故障预测_20241206181334A015.jpeg";
- // console.log("resData.dataType", resData);
- if (resData.imagePath && resData.dataType == "4") {
- this.imgUrl = resData.imagePath;
- this.isImgShow = true;
- this.loading = false;
- this.fileShowVisible = true;
- } else {
- this.fetchLogFile(url).then((text) => {
- let data, content, head;
- data = this.handleFileData(text);
- content = data.contentData;
- head = data.headData;
- this.switchHandle(content, head, resData.dataType);
- });
- }
- })
- .catch((error) => {
- console.error("Failed to fetch the log file:", error);
- this.$modal.msgSuccess("文件读取错误");
- this.loading = false;
- });
- }
- },
- switchHandle(content, head, dataType) {
- switch (dataType) {
- case "0":
- this.fileShowVisible = true;
- this.handleResultChartOption(content, head, true);
- // this.loading = false;
- break;
- case "1":
- this.fileShowVisible = true;
- this.handleResultChartOption(content, head, false);
- // this.loading = false;
- break;
- case "2":
- this.fileShowVisible = true;
- this.$nextTick(() => {
- this.handleResultChartOption(content, head, false);
- // this.loading = false;
- });
- break;
- case "3":
- this.fileShowVisible = true;
- this.$nextTick(() => {
- this.handleResultChartOption(content, head, false);
- // this.loading = false;
- });
- break;
- case "4":
- this.fileShowVisible = true;
- this.$nextTick(() => {
- this.handleResultChartOption(content, head, false);
- // this.loading = false;
- });
- break;
- case "5":
- break;
- case "6":
- break;
- default:
- break;
- }
- },
- // 读取文件内容
- async fetchLogFile(url) {
- try {
- const response = await fetch(url, { method: "GET" });
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
- return await response.text();
- } catch (error) {
- throw error;
- }
- },
- // 对数据的处理(不包含时间)
- handleFileData(fileData) {
- // 每行数据转换成数组、过滤出存在的空白行、将没行数据按照,号分割
- const data = fileData
- .split("\r\n")
- .filter((line) => line.trim() !== "")
- .map((row) => row.split(","));
- let headData = [];
- for (let i = 1; i <= data[0].length; i++) {
- headData.push(`曲线${i}`);
- }
- const contentData = Array.from({ length: headData.length }, () => []);
- for (let i = 0; i < data.length; i++) {
- data[i].forEach((value, index) => {
- contentData[index].push(value * 1);
- });
- }
- return { contentData, headData };
- },
- // 对数据的处理(包含时间)
- handleDataIncludeTime(fileData) {
- data = fileData
- .split("\r\n")
- .filter((line) => line.trim() !== "")
- .map((row) => row.split(","));
- data[0].shift();
- const completionHead = data[0];
- const completionContent = Array.from(
- { length: completionHead.length },
- () => []
- );
- const timeData = [];
- for (let i = 1; i < data.length; i++) {
- data[i].forEach((value, index) => {
- if (index === 0) {
- timeData.push(value);
- } else {
- completionContent[index - 1].push(value * 1);
- }
- });
- }
- return {
- contentData: completionContent,
- headData: completionHead,
- timeData,
- };
- },
- handlePreChartOption(content, head, ismarkPoint) {
- this.preChartData = {
- legendData: [],
- xAxisData: [],
- yAxisData: [],
- seriesData: [],
- };
- let series;
- if (ismarkPoint) {
- series = content.map((lineData, index) => ({
- name: `${head[index]}`,
- type: "line",
- data: lineData,
- connectNulls: true, // 连接相邻的非空数据点
- markPoint: {
- data: lineData
- .map((value, idx) => ({
- value: !value || value === 0 ? "-" : null,
- xAxis: idx,
- yAxis: lineData[idx - 1],
- // yAxis: 0,
- // itemStyle: { color: color[index] }, // 高亮显示缺失值
- }))
- .filter((point) => point.value),
- },
- }));
- } else {
- series = content.map((lineData, index) => ({
- name: `${head[index]}`,
- type: "line",
- // data: lineData,
- data: lineData,
- connectNulls: true,
- }));
- }
- this.preChartData.seriesData = series;
- this.preChartData.xAxisData = content[0].map((_, index) => index);
- },
- // 图表设置
- handleResultChartOption(content, head, ismarkPoint) {
- this.resultChartData = {
- legendData: [],
- xAxisData: [],
- yAxisData: [],
- seriesData: [],
- };
- let series;
- if (ismarkPoint) {
- series = content.map((lineData, index) => ({
- name: `${head[index]}`,
- type: "line",
- data: lineData,
- connectNulls: true, // 连接相邻的非空数据点
- markPoint: {
- data: lineData
- .map((value, idx) => ({
- value: value || value === 0 ? "缺失" : null,
- xAxis: idx,
- yAxis: lineData[idx - 1],
- // yAxis: value,
- // itemStyle: { color: color[index] }, // 高亮显示缺失值
- }))
- .filter((point) => point.value),
- },
- }));
- } else {
- series = content.map((lineData, index) => ({
- name: `${head[index]}`,
- type: "line",
- data: lineData,
- connectNulls: true,
- }));
- }
- this.resultChartData.seriesData = series;
- this.resultChartData.xAxisData = content[0].map((_, index) => index);
- this.loading = false;
- },
- // 切换表格/曲线展示
- changeShow() {
- this.isTableShow = !this.isTableShow;
- if (!this.isTableShow) {
- this.handleFile(this.nowRow, this.nowTypeNum);
- } else {
- this.tableShow(this.resultFileId);
- }
- },
- tableShow(id) {
- // const url = `${process.env.VUE_APP_BASE_API}${path}`;
- getData(id).then((res) => {
- const url = `${process.env.VUE_APP_BASE_API}${res.data.dataPath}`;
- this.fetchLogFile(url).then((text) => {
- const data = text
- .split("\r\n")
- .filter((line) => line.trim() !== "")
- .map((row) => row.split(","));
- this.completionHeadData = data.shift();
- this.completionData = data.map((row) => {
- const rowData = {};
- for (let i = 0; i < this.completionHeadData.length; i++) {
- rowData[`val${i}`] = row[i] === 0 ? null : row[i];
- }
- return rowData;
- });
- });
- });
- },
- imgShow(url, dataType) {
- this.fileType = dataType;
- this.imgPreviewUrl = url;
- this.fileShowVisible = true;
- },
- },
- };
- </script>
- <style scoped lang="scss">
- @import "./index.scss";
- </style>
|