index.vue 11 KB

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