index.vue 11 KB

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