index.vue 11 KB

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