index.vue 11 KB

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