index.vue 11 KB

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