index.vue 10 KB

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