assetssDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <!--
  2. * @Author: your name
  3. * @Date: 2024-05-27 09:25:45
  4. * @LastEditTime: 2024-08-05 09:52:56
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/performance/assetssDetail.vue
  8. -->
  9. <template>
  10. <div class="global-variable" v-loading="loading">
  11. <el-row type="flex" justify="space-between">
  12. <el-col :span="8">
  13. <el-button
  14. type="text"
  15. style="font-size: 20px"
  16. icon="el-icon-arrow-left"
  17. @click="() => $router.push('/home/performance/assetssMag')"
  18. >
  19. 返回
  20. </el-button>
  21. </el-col>
  22. <el-col :span="8">
  23. <h2 style="text-align: center">分析历史记录总览</h2>
  24. </el-col>
  25. <el-col :span="8">
  26. <div style="text-align: end; font-size: 16px">
  27. 分析时间:{{
  28. generalFiles.length > 0 ? generalFiles[0].createTime : "/"
  29. }}
  30. </div>
  31. </el-col>
  32. </el-row>
  33. <el-card class="box-card analysisType">
  34. <el-form
  35. :model="formInfo"
  36. :rules="rules"
  37. ref="ruleForm"
  38. label-width="100px"
  39. inline
  40. class="demo-ruleForm"
  41. >
  42. <el-row type="flex" justify="space-between">
  43. <el-col :span="8">
  44. <el-form-item label="分析类型" prop="analysisTypeCode">
  45. <el-select v-model="formInfo.analysisTypeCode" size="small">
  46. <el-option
  47. v-for="item in analysisTypeList"
  48. :key="item.analysisTypeCode"
  49. :label="item.analysisTypeName"
  50. :value="item.analysisTypeCode"
  51. ></el-option>
  52. </el-select>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="8">
  56. <el-form-item label="机组名称" prop="fieldEngineCode">
  57. <el-select v-model="formInfo.fieldEngineCode" size="small">
  58. <el-option
  59. v-for="item in windEngineGroupList"
  60. :key="item.engineCode"
  61. :label="item.engineName"
  62. :value="item.engineCode"
  63. ></el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="8">
  68. <el-form-item
  69. class="searchFrom"
  70. style="display: flex; justify-content: end"
  71. >
  72. <el-button type="primary" @click="onSubmit" size="small"
  73. >查询</el-button
  74. >
  75. <el-button @click="reset('ruleForm')" size="small"
  76. >重置</el-button
  77. >
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </el-form>
  82. </el-card>
  83. <el-empty :image-size="200" v-if="flage"></el-empty>
  84. <div v-else>
  85. <el-table
  86. v-if="
  87. this.formInfo.analysisTypeCode === 'yaw_error' &&
  88. this.csvData.length > 0
  89. "
  90. :data="csvData"
  91. border
  92. style="width: 100%"
  93. align="center"
  94. >
  95. <el-table-column prop="engine_name" label="风机名称"> </el-table-column>
  96. <el-table-column prop="yaw_error1" label="误差值"> </el-table-column>
  97. </el-table>
  98. <div v-else>
  99. <el-card class="box-card analysisType" v-if="generalFiles.length > 0">
  100. <div slot="header" class="clearfix">
  101. <span style="font-weight: 700; font-size: 16px">
  102. 分析总图{{ fileCheckResult1 }}
  103. </span>
  104. </div>
  105. <el-row class="assetssConent">
  106. <!-- :span="getSpan(index, 'generalFiles')" -->
  107. <!-- v-loading="
  108. loadings[index + generalFiles.length] &&
  109. getFileType(file.fileAddr) === 'html'
  110. " -->
  111. <el-col
  112. v-for="(file, index) in generalFiles"
  113. :key="index"
  114. :span="24"
  115. class="col_content"
  116. :style="{
  117. display: getFileType(file.fileAddr) === 'html' ? 'block' : 'none',
  118. }"
  119. >
  120. <iframe
  121. v-if="getFileType(file.fileAddr) === 'html'"
  122. :src="file.fileAddr"
  123. :ref="'iframe' + index"
  124. frameborder="0"
  125. @load="iframeLoad(index + generalFiles.length)"
  126. width="100%"
  127. height="100%"
  128. ></iframe>
  129. </el-col>
  130. </el-row>
  131. </el-card>
  132. <el-card class="box-card analysisType" v-if="diagramRelations.length > 0">
  133. <div slot="header" class="clearfix">
  134. <span style="font-weight: 700; font-size: 16px">
  135. 分析分图 {{ fileCheckResult1 }}
  136. </span>
  137. </div>
  138. <el-row class="assetssConent">
  139. <el-col
  140. v-for="(file, index) in diagramRelations"
  141. :key="index"
  142. :span="24"
  143. :style="{
  144. display: getFileType(file.fileAddr) === 'html' ? 'block' : 'none',
  145. }"
  146. class="col_content"
  147. >
  148. <iframe
  149. v-if="getFileType(file.fileAddr) === 'html'"
  150. :src="file.fileAddr"
  151. :ref="'iframe' + index + diagramRelations.length"
  152. frameborder="0"
  153. width="100%"
  154. height="100%"
  155. @load="iframeLoad(index + diagramRelations.length)"
  156. ></iframe>
  157. </el-col>
  158. </el-row>
  159. </el-card>
  160. </div>
  161. <el-card
  162. class="box-card"
  163. v-for="o in commentDescriptionVos"
  164. :key="o.commentTypeName"
  165. >
  166. <div slot="header" class="clearfix">
  167. <span style="font-weight: 700; font-size: 16px">{{
  168. o.commentTypeName
  169. }}</span>
  170. </div>
  171. <div class="text item">
  172. <div v-html="o.comment"></div>
  173. </div>
  174. </el-card>
  175. </div>
  176. </div>
  177. </template>
  178. <script>
  179. import {
  180. analysisDetail,
  181. queryAnalysisedType,
  182. queryAnalysisedEngine,
  183. queryAnalysisTypeConfig,
  184. } from "@/api/performance";
  185. import Papa from "papaparse";
  186. import axios from "axios";
  187. export default {
  188. data() {
  189. return {
  190. loadings: [],
  191. loading: false,
  192. fileCheckResult: null,
  193. fileCheckResult1: null,
  194. analysisTypeList: [],
  195. windEngineGroupList: [],
  196. generalFiles: [],
  197. diagramRelations: [],
  198. commentDescriptionVos: [],
  199. formInfo: {
  200. fieldEngineCode: null,
  201. analysisTypeCode: null,
  202. },
  203. csvData: [], // 解析后的数据
  204. csvHeaders: [], // CSV 表头
  205. rules: {},
  206. flage: false,
  207. };
  208. },
  209. created() {
  210. //获取分析 分析类型、机组编号 列表
  211. this.getWindCodeList();
  212. },
  213. mounted() {
  214. // this.initializeLoading();
  215. this.chartsTypeConfig();
  216. },
  217. methods: {
  218. async chartsTypeConfig() {
  219. const result = await queryAnalysisTypeConfig();
  220. console.log(result.data, "result");
  221. },
  222. iframeLoad(index) {
  223. this.$set(this.loadings, index, false);
  224. },
  225. initializeLoading() {
  226. // 计算总的文件数量,包括分析总图和分析分图
  227. const totalFiles =
  228. this.generalFiles.length + this.diagramRelations.length;
  229. // 初始化 loadings 数组,全部设置为 true,表示加载状态
  230. this.loadings = new Array(totalFiles).fill(true);
  231. },
  232. // 查询
  233. onSubmit() {
  234. this.getDetailInfo();
  235. },
  236. // 重置
  237. reset(formName) {
  238. this.$refs[formName].resetFields();
  239. this.getWindCodeList();
  240. },
  241. async getDetailInfo() {
  242. const formData = new FormData();
  243. formData.append("batchCode", this.$route.query.batchCode);
  244. formData.append("analysisTypeCode", this.formInfo.analysisTypeCode);
  245. formData.append("fieldEngineCode", this.formInfo.fieldEngineCode);
  246. this.loading = true;
  247. //获取详情信息
  248. try {
  249. const response = await analysisDetail(formData);
  250. if (response.data.length === 0 || response.data === null) {
  251. this.flage = true;
  252. } else {
  253. this.flage = false;
  254. }
  255. this.generalFiles = [];
  256. this.generalFiles =
  257. (response.data &&
  258. response.data.length > 0 &&
  259. response.data[0].generalFiles) ||
  260. [];
  261. this.diagramRelations = [];
  262. this.diagramRelations =
  263. (response.data &&
  264. response.data.length > 0 &&
  265. response.data[0].diagramRelations) ||
  266. [];
  267. console.log(this.diagramRelations, "this.diagramRelations");
  268. this.commentDescriptionVos =
  269. (response.data &&
  270. response.data.length > 0 &&
  271. response.data[0].commentDescriptionVos) ||
  272. [];
  273. if (this.formInfo.analysisTypeCode === "yaw_error") {
  274. this.getCsvData(response.data[0].generalFiles[0].fileAddr);
  275. }
  276. this.initializeLoading();
  277. this.loading = false;
  278. } catch (error) {
  279. console.error(error);
  280. this.loading = false;
  281. }
  282. },
  283. getCsvData(url) {
  284. // 使用 axios 获取 CSV 文件
  285. axios
  286. .get(url, { responseType: "blob" }) // 确保数据以 blob 格式返回
  287. .then((response) => {
  288. const reader = new FileReader();
  289. reader.onload = (e) => {
  290. const csvText = e.target.result;
  291. Papa.parse(csvText, {
  292. header: true, // 使用 CSV 第一行作为键
  293. complete: (result) => {
  294. this.csvHeaders = Object.keys(result.data[0]);
  295. this.csvData = result.data.filter(
  296. (row) => Object.keys(row).length
  297. ); // 过滤空行
  298. },
  299. error: (error) => {
  300. console.error("CSV 解析错误:", error);
  301. },
  302. });
  303. };
  304. reader.readAsText(response.data); // 读取 blob 数据
  305. })
  306. .catch((error) => {
  307. console.error("无法获取 CSV 文件:", error);
  308. });
  309. },
  310. async getWindCodeList() {
  311. this.loading = true;
  312. try {
  313. const resAnalysisedType = await queryAnalysisedType({
  314. batchCode: this.$route.query.batchCode,
  315. });
  316. if (resAnalysisedType.data && resAnalysisedType.data.length > 0) {
  317. const resEngineList = await queryAnalysisedEngine({
  318. batchCode: this.$route.query.batchCode,
  319. analysisTypeCode: resAnalysisedType.data[0].analysisTypeCode,
  320. });
  321. this.analysisTypeList = resAnalysisedType.data;
  322. this.windEngineGroupList = resEngineList.data;
  323. this.formInfo.fieldEngineCode =
  324. resEngineList.data !== null && resEngineList.data.length > 0
  325. ? resEngineList.data[0].engineCode
  326. : null;
  327. this.formInfo.analysisTypeCode =
  328. resAnalysisedType.data.length > 0
  329. ? resAnalysisedType.data[0].analysisTypeCode
  330. : "";
  331. this.loading = false;
  332. }
  333. this.getDetailInfo();
  334. } catch (error) {
  335. this.loading = false;
  336. console.error(error);
  337. }
  338. },
  339. // getSpan(index, type) {
  340. // let isLastElement = false;
  341. // if (type === "generalFiles") {
  342. // isLastElement = index === this.generalFiles.length - 1;
  343. // } else if (type === "diagramRelations") {
  344. // isLastElement = index === this.diagramRelations.length - 1;
  345. // }
  346. // const isOddPosition = (index + 1) % 2 !== 0;
  347. // if (isLastElement && isOddPosition) {
  348. // return 24;
  349. // }
  350. // return 12;
  351. // },
  352. getFileType(url) {
  353. // 使用 URL 对象解析 URL
  354. // 获取路径名部分
  355. let pathname = url.split("/").pop();
  356. // 截取路径名,去除加密乱码字符部分
  357. const index = pathname.indexOf(".html");
  358. if (index !== -1) {
  359. pathname = pathname.slice(0, index + 5); // '.html' 的长度是 5
  360. } else {
  361. pathname = pathname.slice(0, pathname.indexOf(".png") + 4); // '.png' 的长度是 4
  362. }
  363. // 正则表达式匹配图片扩展名
  364. const imageExtensions = /\.(png|jpg|jpeg|gif|bmp|svg)$/i;
  365. // 正则表达式匹配 HTML 扩展名
  366. const htmlExtensions = /\.html?$/i;
  367. if (imageExtensions.test(pathname)) {
  368. return "image";
  369. } else if (htmlExtensions.test(pathname)) {
  370. return "html";
  371. } else {
  372. return "unknown";
  373. }
  374. },
  375. },
  376. };
  377. </script>
  378. <style scoped lang="scss">
  379. .box-card {
  380. margin-top: 20px;
  381. }
  382. .imageDetail {
  383. padding: 80px 100px;
  384. }
  385. .analysisType {
  386. .assetssConent {
  387. height: 550px !important;
  388. .el-col-12 {
  389. height: 100%;
  390. }
  391. .el-col-24 {
  392. height: 100%;
  393. }
  394. iframe {
  395. width: 100%;
  396. height: 100%;
  397. }
  398. img {
  399. width: 100%;
  400. height: auto;
  401. margin: 0 auto;
  402. }
  403. }
  404. }
  405. ::v-deep .gjp .el-skeleton {
  406. width: 90% !important;
  407. height: 90% !important;
  408. margin: 0 auto !important;
  409. }
  410. </style>