assetssDetail.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <!--
  2. * @Author: your name
  3. * @Date: 2024-05-27 09:25:45
  4. * @LastEditTime: 2024-06-13 16:56:00
  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-d-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">分析总图</span>
  87. </div>
  88. <el-row class="assetssConent">
  89. <el-col
  90. v-for="(file, index) in generalFiles"
  91. :key="index"
  92. :span="getSpan(index, 'generalFiles')"
  93. >
  94. <iframe
  95. v-if="getFileType(file.fileAddr) === 'html'"
  96. :src="file.fileAddr"
  97. ref="iframe"
  98. frameborder="0"
  99. ></iframe>
  100. <img
  101. v-else-if="getFileType(file.fileAddr) === 'image'"
  102. v-lazy-load="{
  103. src: file.fileAddr,
  104. loadingImageSrc: '../../assets/img/loading.gif',
  105. errorImageSrc: '../../assets/img/loadingError.webp',
  106. }"
  107. alt=""
  108. />
  109. </el-col>
  110. </el-row>
  111. </el-card>
  112. <el-card class="box-card analysisType" v-if="diagramRelations.length > 0">
  113. <div slot="header" class="clearfix">
  114. <span style="font-weight: 700; font-size: 16px">分析分图</span>
  115. </div>
  116. <el-row class="assetssConent">
  117. <el-col
  118. v-for="(file, index) in diagramRelations"
  119. :key="index"
  120. :span="getSpan(index, 'diagramRelations')"
  121. >
  122. <!-- 文件内容渲染 -->
  123. <iframe
  124. v-if="getFileType(file.fileAddr) === 'html'"
  125. :src="file.fileAddr"
  126. ref="iframe"
  127. frameborder="0"
  128. ></iframe>
  129. <img
  130. v-else-if="getFileType(file.fileAddr) === 'image'"
  131. v-lazy-load="{
  132. src: file.fileAddr,
  133. loadingImageSrc: '../../assets/img/loading.gif',
  134. errorImageSrc: '../../assets/img/loadingError.webp',
  135. }"
  136. alt=""
  137. />
  138. </el-col>
  139. </el-row>
  140. </el-card>
  141. <el-card
  142. class="box-card"
  143. v-for="o in commentDescriptionVos"
  144. :key="o.commentTypeName"
  145. >
  146. <div slot="header" class="clearfix">
  147. <span style="font-weight: 700; font-size: 16px">{{
  148. o.commentTypeName
  149. }}</span>
  150. </div>
  151. <div class="text item">
  152. <div v-html="o.comment"></div>
  153. </div>
  154. </el-card>
  155. </div>
  156. </div>
  157. </template>
  158. <script>
  159. import { analysisDetail, analysisEditQuery } from "@/api/performance";
  160. export default {
  161. data() {
  162. return {
  163. analysisTypeList: [],
  164. windEngineGroupList: [],
  165. generalFiles: [],
  166. diagramRelations: [],
  167. commentDescriptionVos: [],
  168. formInfo: {
  169. fieldEngineCode: null,
  170. analysisTypeCode: null,
  171. },
  172. rules: {},
  173. flage: false,
  174. };
  175. },
  176. created() {
  177. //获取分析 分析类型、机组编号 列表
  178. this.getWindCodeList();
  179. },
  180. methods: {
  181. // 查询
  182. onSubmit() {
  183. this.getDetailInfo();
  184. },
  185. // 重置
  186. reset(formName) {
  187. this.$refs[formName].resetFields();
  188. this.getWindCodeList();
  189. },
  190. async getDetailInfo() {
  191. const formData = new FormData();
  192. formData.append("batchCode", this.$route.query.batchCode);
  193. formData.append("analysisTypeCode", this.formInfo.analysisTypeCode);
  194. formData.append("fieldEngineCode", this.formInfo.fieldEngineCode);
  195. //获取详情信息
  196. try {
  197. const response = await analysisDetail(formData);
  198. if (response.data.length === 0 || response.data === null) {
  199. this.flage = true;
  200. } else {
  201. this.flage = false;
  202. }
  203. this.generalFiles =
  204. (response.data &&
  205. response.data.length > 0 &&
  206. response.data[0].generalFiles) ||
  207. [];
  208. this.diagramRelations =
  209. (response.data &&
  210. response.data.length > 0 &&
  211. response.data[0].diagramRelations) ||
  212. [];
  213. this.commentDescriptionVos =
  214. (response.data &&
  215. response.data.length > 0 &&
  216. response.data[0].commentDescriptionVos) ||
  217. [];
  218. console.log(this.generalFiles, " this.generalFiles ");
  219. } catch (error) {
  220. console.error(error);
  221. }
  222. },
  223. async getWindCodeList() {
  224. try {
  225. const response = await analysisEditQuery({
  226. batchCode: this.$route.query.batchCode,
  227. });
  228. this.analysisTypeList = response.data.analysisTypeList;
  229. this.windEngineGroupList = response.data.windEngineGroupList;
  230. this.formInfo.fieldEngineCode = response.data.windEngineGroupList[0];
  231. this.formInfo.analysisTypeCode =
  232. response.data.analysisTypeList.length > 0
  233. ? response.data.analysisTypeList[0].typeCode
  234. : "";
  235. this.getDetailInfo();
  236. } catch (error) {
  237. console.error(error);
  238. }
  239. },
  240. getSpan(index, type) {
  241. let isLastElement = false;
  242. if (type === "generalFiles") {
  243. isLastElement = index === this.generalFiles.length - 1;
  244. } else if (type === "diagramRelations") {
  245. isLastElement = index === this.diagramRelations.length - 1;
  246. }
  247. const isOddPosition = (index + 1) % 2 !== 0;
  248. if (isLastElement && isOddPosition) {
  249. return 24;
  250. }
  251. return 12;
  252. },
  253. getFileType(url) {
  254. // 使用 URL 对象解析 URL
  255. const parsedUrl = new URL(url);
  256. // 获取路径名部分
  257. let pathname = parsedUrl.pathname;
  258. // 截取路径名,去除加密乱码字符部分
  259. const index = pathname.indexOf(".html");
  260. if (index !== -1) {
  261. pathname = pathname.slice(0, index + 5); // '.html' 的长度是 5
  262. } else {
  263. pathname = pathname.slice(0, pathname.indexOf(".png") + 4); // '.png' 的长度是 4
  264. }
  265. // 正则表达式匹配图片扩展名
  266. const imageExtensions = /\.(png|jpg|jpeg|gif|bmp|svg)$/i;
  267. // 正则表达式匹配 HTML 扩展名
  268. const htmlExtensions = /\.html?$/i;
  269. if (imageExtensions.test(pathname)) {
  270. return "image";
  271. } else if (htmlExtensions.test(pathname)) {
  272. return "html";
  273. } else {
  274. return "unknown";
  275. }
  276. },
  277. },
  278. };
  279. </script>
  280. <style scoped lang="scss">
  281. .box-card {
  282. margin-top: 20px;
  283. }
  284. .imageDetail {
  285. padding: 80px 100px;
  286. }
  287. .analysisType {
  288. .assetssConent {
  289. height: 450px !important;
  290. .el-col-12 {
  291. width: 50%;
  292. height: 100%;
  293. }
  294. iframe {
  295. width: 100%;
  296. height: 100%;
  297. }
  298. img {
  299. width: 100%;
  300. height: auto;
  301. margin: 0 auto;
  302. }
  303. }
  304. }
  305. </style>