index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-10 09:10:11
  4. * @LastEditTime: 2025-02-26 11:24:02
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/tsr/index.vue
  8. -->
  9. <template>
  10. <div class="type-variable">
  11. <!-- 叶尖速比和有功功率分析 -->
  12. <div class="left">
  13. <FilterChart
  14. :setUpimg="['叶尖速比']"
  15. :windList="windEngineGroupList"
  16. @getEnfineList="getEnfineList"
  17. @handlePrevious="handlePrevious"
  18. @handleNext="handleNext"
  19. ></FilterChart>
  20. <el-alert type="info" :closable="false">
  21. <template v-slot:title>
  22. <div style="display: flex; align-items: center">
  23. <i
  24. class="el-icon-info"
  25. style="font-size: 20px; margin-right: 5px"
  26. ></i>
  27. <h3>分析说明:</h3>
  28. </div>
  29. </template>
  30. <div style="font-size: 12px; margin-top: 10px">
  31. 叶尖速比的分析对于理解和优化风力发电机组的性能至关重要:叶尖速比直接影响风轮的空气动力学效率。一个合适的叶尖速比可以确保风轮以最高效率捕获风能。过高的叶尖速比可能会导致叶片承受过大的离心力和动态压力,从而增加机械负荷。通过监测和调整叶尖速比,可以防止过度磨损和损坏。
  32. </div>
  33. </el-alert>
  34. <div
  35. class="titleCharts"
  36. v-if="generalFilesDatas && generalFilesDatas.length > 0"
  37. >
  38. 分析总图 :
  39. </div>
  40. <div v-for="(item, index) in generalFilesDatas">
  41. <lineAndChildLine
  42. :setUpImgData="setUpImgData"
  43. :key="item.batchCode + index"
  44. :index="`${new Date().getTime()}` + index"
  45. :ref="item.batchCode"
  46. :fileAddr="item.fileAddr"
  47. >
  48. </lineAndChildLine>
  49. </div>
  50. <div
  51. class="titleCharts"
  52. v-if="diagramRelationsDatas && diagramRelationsDatas.length > 0"
  53. >
  54. 分析分图 :
  55. </div>
  56. <div v-for="(item, index) in diagramRelationsDatas">
  57. <lineChartsFen
  58. :setUpImgData="setUpImgData"
  59. :key="item.fieldEngineCode + index"
  60. :index="`${new Date().getTime()}` + index"
  61. :ref="item.fieldEngineCode"
  62. :fieldEngineCode="item.fieldEngineCode"
  63. :fileAddr="item.fileAddr"
  64. >
  65. </lineChartsFen>
  66. </div>
  67. <el-empty
  68. description="暂无分析记录"
  69. v-if="
  70. generalFilesDatas.length === 0 && diagramRelationsDatas.length === 0
  71. "
  72. ></el-empty>
  73. <el-dialog
  74. v-if="isShowDescription"
  75. title="添加评论"
  76. :visible="isShow"
  77. width="30%"
  78. v-dialogDrag
  79. :modal="false"
  80. :lock-scroll="false"
  81. :modal-append-to-body="false"
  82. @close="handleClose"
  83. >
  84. <el-tabs value="first">
  85. <el-tab-pane label="意见描述" name="first">
  86. <TinymceEditor
  87. ref="editor"
  88. v-model="comment"
  89. @input="handleEditorInput($event)"
  90. @onClick="onClick"
  91. >
  92. </TinymceEditor>
  93. </el-tab-pane>
  94. </el-tabs>
  95. <el-row
  96. type="flex"
  97. class="row-bg"
  98. justify="end"
  99. style="margin: 20px 60px 0 0"
  100. >
  101. <el-col :span="2">
  102. <el-button type="primary" size="small" @click="handleComment"
  103. >提交评论</el-button
  104. >
  105. </el-col>
  106. </el-row>
  107. </el-dialog>
  108. </div>
  109. <div class="right" v-if="isShowTinymceEditorCom">
  110. <DicCard
  111. :batchCode="initBatchCode"
  112. :analysisTypeCode="analysisTypeCode"
  113. :commentDescriptionVos="commentDescriptionVos"
  114. >
  115. </DicCard>
  116. </div>
  117. </div>
  118. </template>
  119. <script>
  120. import DicCard from "@/views/overview/components/dicCard/index.vue";
  121. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  122. import lineAndChildLine from "@/views/performance/components/chartsCom/lineAndChildLine.vue";
  123. import lineChartsFen from "@/views/performance/components/chartsCom/lineChartsFen.vue";
  124. import TinymceEditor from "@/components/Tinymce.vue";
  125. import {
  126. analysisDetail,
  127. queryAnalysisedEngine,
  128. analysisCommentEdit,
  129. } from "@/api/performance";
  130. export default {
  131. name: "tsr",
  132. components: {
  133. DicCard,
  134. FilterChart,
  135. lineAndChildLine,
  136. lineChartsFen,
  137. TinymceEditor,
  138. },
  139. props: {
  140. initBatchCode: {
  141. default: "",
  142. type: String,
  143. },
  144. isShowTinymceEditorCom: {
  145. default: true,
  146. type: Boolean,
  147. },
  148. isShow: {
  149. default: false,
  150. type: Boolean,
  151. },
  152. analysisTypeCode: {
  153. default: "",
  154. type: String,
  155. },
  156. batchCodeList: {
  157. default: "",
  158. type: Array,
  159. },
  160. },
  161. data() {
  162. return {
  163. form: {
  164. value2: "",
  165. },
  166. setUpImgData: [],
  167. comment: "",
  168. options: [],
  169. windEngineGroupList: [], //批次风机列表
  170. fieldEngineCodes: [], //选中风机
  171. generalFilesDatas: [], //总图
  172. diagramRelationsDatas: [], //分图
  173. commentDescriptionVos: [], //评论列表
  174. editableTabs: [],
  175. isShowDescription: false,
  176. };
  177. },
  178. watch: {
  179. isShow() {
  180. if (this.isShow) {
  181. if (!this.isShowDescription) {
  182. this.$message({
  183. message: "当前分析模型暂无分析,不能进行评论操作",
  184. type: "warning",
  185. });
  186. this.$emit("setIsShow");
  187. }
  188. }
  189. },
  190. initBatchCode(newVal) {
  191. if (newVal) {
  192. this.fetchData(); // 调用合并后的函数
  193. }
  194. },
  195. analysisTypeCode(newVal) {
  196. if (newVal) {
  197. this.fetchData(); // 调用合并后的函数
  198. }
  199. },
  200. },
  201. mounted() {
  202. if (this.initBatchCode && this.analysisTypeCode) {
  203. this.fetchData(); // 调用合并后的函数
  204. }
  205. },
  206. methods: {
  207. handleClose() {
  208. //关闭评论弹框
  209. this.$emit("setIsShow");
  210. },
  211. async handleComment() {
  212. try {
  213. await analysisCommentEdit({
  214. batchCode: this.initBatchCode,
  215. analysisTypeCode: this.analysisTypeCode,
  216. commentList: this.editableTabs.map((item) => {
  217. return {
  218. commentTypeCode: item.commentTypeCode,
  219. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  220. };
  221. }),
  222. });
  223. this.$message({
  224. type: "success",
  225. message: "保存成功",
  226. });
  227. this.comment = "";
  228. this.getAnalysisDetail();
  229. this.$emit("setIsShow");
  230. } catch (e) {
  231. console.error(e);
  232. this.loading = false;
  233. }
  234. },
  235. onSubmit() {
  236. console.log("submit!");
  237. },
  238. // 合并后的函数,处理数据请求
  239. async fetchData() {
  240. try {
  241. // 获取分析详情
  242. await this.getAnalysisDetail();
  243. // 获取风机列表
  244. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  245. } catch (err) {
  246. console.error("Failed to fetch data:", err);
  247. }
  248. },
  249. // 获取分析详情接口
  250. async getAnalysisDetail() {
  251. try {
  252. const result = await analysisDetail({
  253. batchCode: this.initBatchCode,
  254. analysisTypeCode: this.analysisTypeCode,
  255. fieldEngineCodes:
  256. this.fieldEngineCodes.length === 0
  257. ? undefined
  258. : this.fieldEngineCodes.join(","),
  259. });
  260. if (result.data.length > 0) {
  261. this.isShowDescription = true;
  262. }
  263. if (
  264. result.data &&
  265. result.data[0] &&
  266. result.data[0].commentTypeRelations
  267. ) {
  268. this.editableTabs = result.data[0].commentTypeRelations;
  269. }
  270. //当前评论展示获取
  271. if (
  272. result.data &&
  273. result.data[0] &&
  274. result.data[0].commentDescriptionVos
  275. ) {
  276. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  277. }
  278. this.generalFilesDatas =
  279. (result.data &&
  280. result.data[0] &&
  281. result.data[0].generalFiles &&
  282. result.data[0].generalFiles.filter((item) =>
  283. item.fileAddr.endsWith(".json")
  284. )) ||
  285. []; //总图数据
  286. this.diagramRelationsDatas =
  287. (result.data &&
  288. result.data[0] &&
  289. result.data[0].diagramRelations &&
  290. result.data[0].diagramRelations.filter((item) =>
  291. item.fileAddr.endsWith(".json")
  292. )) ||
  293. [];
  294. } catch (err) {
  295. console.error("Failed to fetch analysis details:", err);
  296. }
  297. },
  298. // 请求风机列表
  299. async getWindEnfineList(batchCode, analysisTypeCode) {
  300. // console.log("请求风机列表 分钟级");
  301. const resEngineList = await queryAnalysisedEngine({
  302. batchCode: batchCode,
  303. analysisTypeCode,
  304. });
  305. this.windEngineGroupList = resEngineList.data;
  306. },
  307. handleEditorInput(index, newVal) {
  308. // 更新对应的 comment 值
  309. // 如果该功能没有实现,可以删除这个方法
  310. },
  311. //获取选中风机list
  312. getEnfineList(data, setUpImg) {
  313. this.fieldEngineCodes = data;
  314. this.setUpImgData = [...setUpImg];
  315. this.getAnalysisDetail();
  316. },
  317. //下一条
  318. handleNext() {
  319. const index = this.batchCodeList.findIndex(
  320. (item) => item === this.initBatchCode
  321. );
  322. if (index === this.batchCodeList.length - 1) {
  323. this.$message.warning("已经是最后一个分析结果了");
  324. return;
  325. }
  326. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  327. },
  328. //上一条
  329. handlePrevious() {
  330. const index = this.batchCodeList.findIndex(
  331. (item) => item === this.initBatchCode
  332. );
  333. if (index === 0) {
  334. this.$message.warning("没有上一条了");
  335. return;
  336. }
  337. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  338. },
  339. onClick() {},
  340. },
  341. };
  342. </script>
  343. <style scoped lang="scss">
  344. .type-variable {
  345. display: flex;
  346. height: 90%;
  347. overflow: hidden;
  348. .left {
  349. width: 30%;
  350. height: 100%;
  351. overflow: auto;
  352. padding: 20px;
  353. flex: 1;
  354. /* 滚动条整体样式 */
  355. &::-webkit-scrollbar {
  356. width: 6px; /* 滚动条宽度 */
  357. }
  358. /* 滚动条轨道 */
  359. &::-webkit-scrollbar-track {
  360. background: #f5f7fa;
  361. border-radius: 3px;
  362. }
  363. /* 滚动条滑块 */
  364. &::-webkit-scrollbar-thumb {
  365. background: #c0c4cc;
  366. border-radius: 3px;
  367. }
  368. /* 滚动条滑块悬停时 */
  369. &::-webkit-scrollbar-thumb:hover {
  370. background: #909399;
  371. }
  372. }
  373. .right {
  374. width: 250px;
  375. height: 100%;
  376. overflow: hidden;
  377. }
  378. }
  379. .el-dialog__wrapper {
  380. position: relative !important;
  381. }
  382. ::v-deep .el-dialog {
  383. position: fixed !important;
  384. z-index: 999 !important;
  385. top: 50%;
  386. left: 50%;
  387. transform: translate(0, -50%);
  388. }
  389. .titleCharts {
  390. font-size: 16px;
  391. font-weight: 500;
  392. margin-top: 20px;
  393. }
  394. </style>