index.vue 11 KB

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