assetssDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <!--
  2. * @Author: your name
  3. * @Date: 2024-05-27 09:25:45
  4. * @LastEditTime: 2024-06-14 14:25:04
  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">
  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.go(-1)"
  18. >返回</el-button
  19. ></el-col
  20. >
  21. <el-col :span="8"
  22. ><h2 style="text-align: center">分析历史记录总览</h2></el-col
  23. >
  24. <el-col :span="8">
  25. <div style="text-align: end; font-size: 16px">
  26. 分析时间:{{
  27. generalFiles.length > 0 ? generalFiles[0].createTime : "/"
  28. }}
  29. </div>
  30. </el-col>
  31. </el-row>
  32. <el-card class="box-card analysisType">
  33. <el-form
  34. :model="formInfo"
  35. :rules="rules"
  36. ref="ruleForm"
  37. label-width="100px"
  38. inline
  39. class="demo-ruleForm"
  40. >
  41. <el-row type="flex" justify="space-between">
  42. <el-col :span="8">
  43. <el-form-item label="分析类型" prop="analysisTypeCode">
  44. <el-select v-model="formInfo.analysisTypeCode" size="small">
  45. <el-option
  46. v-for="item in analysisTypeList"
  47. :key="item.typeCode"
  48. :label="item.typeName"
  49. :value="item.typeCode"
  50. ></el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="8">
  55. <el-form-item label="机组编号" prop="fieldEngineCode">
  56. <el-select v-model="formInfo.fieldEngineCode" size="small">
  57. <el-option
  58. v-for="item in windEngineGroupList"
  59. :key="item"
  60. :label="item"
  61. :value="item"
  62. ></el-option>
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item
  68. class="searchFrom"
  69. style="display: flex; justify-content: end"
  70. >
  71. <el-button type="primary" @click="onSubmit" size="small"
  72. >查询</el-button
  73. >
  74. <el-button @click="reset('ruleForm')" size="small"
  75. >重置</el-button
  76. >
  77. </el-form-item>
  78. </el-col>
  79. </el-row>
  80. </el-form>
  81. </el-card>
  82. <el-empty :image-size="200" v-if="flage"></el-empty>
  83. <div v-else>
  84. <el-card class="box-card analysisType" v-if="generalFiles.length > 0">
  85. <div slot="header" class="clearfix">
  86. <span style="font-weight: 700; font-size: 16px"
  87. >分析总图{{ fileCheckResult1 }}</span
  88. >
  89. </div>
  90. <el-row class="assetssConent">
  91. <el-col
  92. v-for="(file, index) in generalFiles"
  93. :key="index"
  94. :span="getSpan(index, 'generalFiles')"
  95. >
  96. <!-- <iframe
  97. v-if="getFileType(file.fileAddr) === 'html'"
  98. :src="fileAddrFn(file.fileAddr)"
  99. ref="iframe"
  100. frameborder="0"
  101. ></iframe> -->
  102. <iframe
  103. v-if="getFileType(file.fileAddr) === 'html'"
  104. :src="file.fileAddr"
  105. ref="iframe"
  106. frameborder="0"
  107. ></iframe>
  108. <!-- <img
  109. v-if="getFileType(file.fileAddr) === 'html' && !fileCheckResult1"
  110. src="../../assets//img/loadingError.webp"
  111. alt=""
  112. /> -->
  113. <img
  114. v-if="getFileType(file.fileAddr) === 'image'"
  115. v-lazy-load="{
  116. src: file.fileAddr,
  117. loadingImageSrc: '../../assets/img/loading.gif',
  118. errorImageSrc: '../../assets/img/loadingError.webp',
  119. }"
  120. alt=""
  121. />
  122. </el-col>
  123. </el-row>
  124. </el-card>
  125. <el-card class="box-card analysisType" v-if="diagramRelations.length > 0">
  126. <div slot="header" class="clearfix">
  127. <span style="font-weight: 700; font-size: 16px"
  128. >分析分图 {{ fileCheckResult1 }}</span
  129. >
  130. </div>
  131. <el-row class="assetssConent">
  132. <el-col
  133. v-for="(file, index) in diagramRelations"
  134. :key="index"
  135. :span="getSpan(index, 'diagramRelations')"
  136. >
  137. <!-- 文件内容渲染 -->
  138. <!-- <iframe
  139. v-if="getFileType(file.fileAddr) === 'html'"
  140. :src="file.fileAddr"
  141. ref="iframe"
  142. frameborder="0"
  143. ></iframe> -->
  144. <iframe
  145. v-if="getFileType(file.fileAddr) === 'html'"
  146. :src="file.fileAddr"
  147. ref="iframe"
  148. frameborder="0"
  149. ></iframe>
  150. <!-- <img
  151. v-if="getFileType(file.fileAddr) === 'html' && !fileCheckResult"
  152. src="../../assets/img/loadingError.webp"
  153. alt=""
  154. /> -->
  155. <img
  156. v-if="getFileType(file.fileAddr) === 'image'"
  157. v-lazy-load="{
  158. src: file.fileAddr,
  159. loadingImageSrc: '../../assets/img/loading.gif',
  160. errorImageSrc: '../../assets/img/loadingError.webp',
  161. }"
  162. alt=""
  163. />
  164. </el-col>
  165. </el-row>
  166. </el-card>
  167. <el-card
  168. class="box-card"
  169. v-for="o in commentDescriptionVos"
  170. :key="o.commentTypeName"
  171. >
  172. <div slot="header" class="clearfix">
  173. <span style="font-weight: 700; font-size: 16px">{{
  174. o.commentTypeName
  175. }}</span>
  176. </div>
  177. <div class="text item">
  178. <div v-html="o.comment"></div>
  179. </div>
  180. </el-card>
  181. </div>
  182. </div>
  183. </template>
  184. <script>
  185. import { analysisDetail, analysisEditQuery } from "@/api/performance";
  186. import axios from "axios";
  187. export default {
  188. data() {
  189. return {
  190. fileCheckResult: null,
  191. fileCheckResult1: null,
  192. analysisTypeList: [],
  193. windEngineGroupList: [],
  194. generalFiles: [],
  195. diagramRelations: [],
  196. commentDescriptionVos: [],
  197. formInfo: {
  198. fieldEngineCode: null,
  199. analysisTypeCode: null,
  200. },
  201. rules: {},
  202. flage: false,
  203. };
  204. },
  205. created() {
  206. //获取分析 分析类型、机组编号 列表
  207. this.getWindCodeList();
  208. },
  209. methods: {
  210. async fileAddrFn(file) {
  211. try {
  212. const res = await axios.get(file);
  213. console.log(res, file, "res成功");
  214. this.fileCheckResult = true;
  215. return true;
  216. } catch (e) {
  217. console.error(file, e, "失败1111");
  218. this.fileCheckResult = false;
  219. }
  220. },
  221. // 查询
  222. onSubmit() {
  223. this.getDetailInfo();
  224. },
  225. // 重置
  226. reset(formName) {
  227. this.$refs[formName].resetFields();
  228. this.getWindCodeList();
  229. },
  230. async getDetailInfo() {
  231. const formData = new FormData();
  232. formData.append("batchCode", this.$route.query.batchCode);
  233. formData.append("analysisTypeCode", this.formInfo.analysisTypeCode);
  234. formData.append("fieldEngineCode", this.formInfo.fieldEngineCode);
  235. //获取详情信息
  236. try {
  237. const response = await analysisDetail(formData);
  238. if (response.data.length === 0 || response.data === null) {
  239. this.flage = true;
  240. } else {
  241. this.flage = false;
  242. }
  243. this.generalFiles =
  244. (response.data &&
  245. response.data.length > 0 &&
  246. response.data[0].generalFiles) ||
  247. [];
  248. this.diagramRelations =
  249. (response.data &&
  250. response.data.length > 0 &&
  251. response.data[0].diagramRelations) ||
  252. [];
  253. this.commentDescriptionVos =
  254. (response.data &&
  255. response.data.length > 0 &&
  256. response.data[0].commentDescriptionVos) ||
  257. [];
  258. console.log(this.generalFiles, " this.generalFiles ");
  259. } catch (error) {
  260. console.error(error);
  261. }
  262. },
  263. async getWindCodeList() {
  264. try {
  265. const response = await analysisEditQuery({
  266. batchCode: this.$route.query.batchCode,
  267. });
  268. this.analysisTypeList = response.data.analysisTypeList;
  269. this.windEngineGroupList = response.data.windEngineGroupList;
  270. this.formInfo.fieldEngineCode = response.data.windEngineGroupList[0];
  271. this.formInfo.analysisTypeCode =
  272. response.data.analysisTypeList.length > 0
  273. ? response.data.analysisTypeList[0].typeCode
  274. : "";
  275. this.getDetailInfo();
  276. } catch (error) {
  277. console.error(error);
  278. }
  279. },
  280. getSpan(index, type) {
  281. let isLastElement = false;
  282. if (type === "generalFiles") {
  283. isLastElement = index === this.generalFiles.length - 1;
  284. } else if (type === "diagramRelations") {
  285. isLastElement = index === this.diagramRelations.length - 1;
  286. }
  287. const isOddPosition = (index + 1) % 2 !== 0;
  288. if (isLastElement && isOddPosition) {
  289. return 24;
  290. }
  291. return 12;
  292. },
  293. getFileType(url) {
  294. // 使用 URL 对象解析 URL
  295. const parsedUrl = new URL(url);
  296. // 获取路径名部分
  297. let pathname = parsedUrl.pathname;
  298. // 截取路径名,去除加密乱码字符部分
  299. const index = pathname.indexOf(".html");
  300. if (index !== -1) {
  301. pathname = pathname.slice(0, index + 5); // '.html' 的长度是 5
  302. } else {
  303. pathname = pathname.slice(0, pathname.indexOf(".png") + 4); // '.png' 的长度是 4
  304. }
  305. // 正则表达式匹配图片扩展名
  306. const imageExtensions = /\.(png|jpg|jpeg|gif|bmp|svg)$/i;
  307. // 正则表达式匹配 HTML 扩展名
  308. const htmlExtensions = /\.html?$/i;
  309. if (imageExtensions.test(pathname)) {
  310. return "image";
  311. } else if (htmlExtensions.test(pathname)) {
  312. return "html";
  313. } else {
  314. return "unknown";
  315. }
  316. },
  317. },
  318. };
  319. </script>
  320. <style scoped lang="scss">
  321. .box-card {
  322. margin-top: 20px;
  323. }
  324. .imageDetail {
  325. padding: 80px 100px;
  326. }
  327. .analysisType {
  328. .assetssConent {
  329. height: 450px !important;
  330. .el-col-12 {
  331. width: 50%;
  332. height: 100%;
  333. }
  334. iframe {
  335. width: 100%;
  336. height: 100%;
  337. }
  338. img {
  339. width: 100%;
  340. height: auto;
  341. margin: 0 auto;
  342. }
  343. }
  344. }
  345. </style>