index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:05:58
  4. * @LastEditTime: 2025-01-22 09:07:14
  5. * @LastEditors: milo-MacBook-Pro.local
  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="item.batchCode + index"
  46. :index="index"
  47. :ref="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="item.fieldEngineCode + index"
  62. :index="index"
  63. :ref="item.fieldEngineCode"
  64. :fieldEngineCode="item.fieldEngineCode"
  65. :fileAddr="item.fileAddr"
  66. >
  67. </lineChartsFen>
  68. </div>
  69. <el-tabs value="first" v-if="isShowDescription">
  70. <el-tab-pane label="意见描述" name="first">
  71. <TinymceEditor
  72. ref="editor"
  73. v-model="comment"
  74. @input="handleEditorInput($event)"
  75. @onClick="onClick"
  76. >
  77. </TinymceEditor>
  78. </el-tab-pane>
  79. </el-tabs>
  80. <el-row type="flex" class="row-bg" justify="end" v-if="isShowDescription">
  81. <el-col :span="2" style="margin: 20px">
  82. <el-button type="primary" size="small" @click="handleComment"
  83. >提交评论</el-button
  84. >
  85. </el-col>
  86. </el-row>
  87. </div>
  88. <div class="right">
  89. <DicCard
  90. :batchCode="initBatchCode"
  91. :analysisTypeCode="analysisTypeCode"
  92. :commentDescriptionVos="commentDescriptionVos"
  93. >
  94. </DicCard>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import DicCard from "@/views/overview/components/dicCard/index.vue";
  100. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  101. import lineAndChildLine from "@/views/performance/components/chartsCom/lineAndChildLine.vue";
  102. import lineChartsFen from "@/views/performance/components/chartsCom/lineChartsFen.vue";
  103. import TinymceEditor from "@/components/Tinymce.vue";
  104. import {
  105. analysisDetail,
  106. queryAnalysisedEngine,
  107. analysisCommentEdit,
  108. } from "@/api/performance";
  109. export default {
  110. name: "cp",
  111. components: {
  112. DicCard,
  113. FilterChart,
  114. lineAndChildLine,
  115. lineChartsFen,
  116. TinymceEditor,
  117. },
  118. props: {
  119. initBatchCode: {
  120. default: "",
  121. type: String,
  122. },
  123. analysisTypeCode: {
  124. default: "",
  125. type: String,
  126. },
  127. batchCodeList: {
  128. default: "",
  129. type: Array,
  130. },
  131. },
  132. data() {
  133. return {
  134. form: {
  135. value2: "",
  136. },
  137. comment: "",
  138. options: [],
  139. windEngineGroupList: [], //批次风机列表
  140. fieldEngineCodes: [], //选中风机
  141. generalFilesDatas: [], //总图
  142. diagramRelationsDatas: [], //分图
  143. commentDescriptionVos: [], //评论列表
  144. editableTabs: [],
  145. isShowDescription: false,
  146. };
  147. },
  148. watch: {
  149. initBatchCode(newVal) {
  150. if (newVal) {
  151. this.fetchData(); // 调用合并后的函数
  152. }
  153. },
  154. analysisTypeCode(newVal) {
  155. if (newVal) {
  156. this.fetchData(); // 调用合并后的函数
  157. }
  158. },
  159. },
  160. mounted() {
  161. if (this.initBatchCode && this.analysisTypeCode) {
  162. this.fetchData(); // 调用合并后的函数
  163. }
  164. },
  165. methods: {
  166. async handleComment() {
  167. try {
  168. await analysisCommentEdit({
  169. batchCode: this.initBatchCode,
  170. analysisTypeCode: this.analysisTypeCode,
  171. commentList: this.editableTabs.map((item) => {
  172. return {
  173. commentTypeCode: item.commentTypeCode,
  174. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  175. };
  176. }),
  177. });
  178. this.$message({
  179. type: "success",
  180. message: "保存成功",
  181. });
  182. this.comment = "";
  183. this.getAnalysisDetail();
  184. } catch (e) {
  185. console.error(e);
  186. this.loading = false;
  187. }
  188. },
  189. onSubmit() {
  190. console.log("submit!");
  191. },
  192. // 合并后的函数,处理数据请求
  193. async fetchData() {
  194. try {
  195. // 获取分析详情
  196. await this.getAnalysisDetail();
  197. // 获取风机列表
  198. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  199. } catch (err) {
  200. console.error("Failed to fetch data:", err);
  201. }
  202. },
  203. // 获取分析详情接口
  204. async getAnalysisDetail() {
  205. try {
  206. const result = await analysisDetail({
  207. batchCode: this.initBatchCode,
  208. analysisTypeCode: this.analysisTypeCode,
  209. fieldEngineCodes:
  210. this.fieldEngineCodes.length === 0
  211. ? undefined
  212. : this.fieldEngineCodes.join(","),
  213. });
  214. if (result.data.length > 0) {
  215. this.isShowDescription = true;
  216. }
  217. if (
  218. result.data &&
  219. result.data[0] &&
  220. result.data[0].commentTypeRelations
  221. ) {
  222. this.editableTabs = result.data[0].commentTypeRelations;
  223. }
  224. //当前评论展示获取
  225. if (
  226. result.data &&
  227. result.data[0] &&
  228. result.data[0].commentDescriptionVos
  229. ) {
  230. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  231. }
  232. this.generalFilesDatas =
  233. (result.data &&
  234. result.data[0] &&
  235. result.data[0].generalFiles &&
  236. result.data[0].generalFiles.filter((item) =>
  237. item.fileAddr.endsWith(".json")
  238. )) ||
  239. []; //总图数据
  240. this.diagramRelationsDatas =
  241. (result.data &&
  242. result.data[0] &&
  243. result.data[0].diagramRelations &&
  244. result.data[0].diagramRelations.filter((item) =>
  245. item.fileAddr.endsWith(".json")
  246. )) ||
  247. [];
  248. } catch (err) {
  249. console.error("Failed to fetch analysis details:", err);
  250. }
  251. },
  252. // 请求风机列表
  253. async getWindEnfineList(batchCode, analysisTypeCode) {
  254. // console.log("请求风机列表 分钟级");
  255. const resEngineList = await queryAnalysisedEngine({
  256. batchCode: batchCode,
  257. analysisTypeCode,
  258. });
  259. this.windEngineGroupList = resEngineList.data;
  260. },
  261. handleEditorInput(index, newVal) {
  262. // 更新对应的 comment 值
  263. // 如果该功能没有实现,可以删除这个方法
  264. },
  265. //获取选中风机list
  266. getEnfineList(data) {
  267. this.fieldEngineCodes = data;
  268. this.getAnalysisDetail();
  269. },
  270. //下一条
  271. handleNext() {
  272. const index = this.batchCodeList.findIndex(
  273. (item) => item === this.initBatchCode
  274. );
  275. if (index === this.batchCodeList.length - 1) {
  276. this.$message.warning("已经是最后一个分析结果了");
  277. return;
  278. }
  279. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  280. },
  281. //上一条
  282. handlePrevious() {
  283. const index = this.batchCodeList.findIndex(
  284. (item) => item === this.initBatchCode
  285. );
  286. if (index === 0) {
  287. this.$message.warning("没有上一条了");
  288. return;
  289. }
  290. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  291. },
  292. onClick() {},
  293. },
  294. };
  295. </script>
  296. <style scoped lang="scss">
  297. .type-variable {
  298. display: flex;
  299. height: 90%;
  300. overflow: hidden;
  301. .left {
  302. width: 30%;
  303. height: 100%;
  304. overflow: auto;
  305. padding: 20px;
  306. flex: 1;
  307. &::-webkit-scrollbar {
  308. width: 6px; /* 滚动条宽度 */
  309. }
  310. /* 滚动条轨道 */
  311. &::-webkit-scrollbar-track {
  312. background: #f5f7fa;
  313. border-radius: 3px;
  314. }
  315. /* 滚动条滑块 */
  316. &::-webkit-scrollbar-thumb {
  317. background: #c0c4cc;
  318. border-radius: 3px;
  319. }
  320. /* 滚动条滑块悬停时 */
  321. &::-webkit-scrollbar-thumb:hover {
  322. background: #909399;
  323. }
  324. }
  325. .right {
  326. width: 250px;
  327. height: 100%;
  328. overflow: hidden;
  329. }
  330. }
  331. .titleCharts {
  332. font-size: 16px;
  333. font-weight: 500;
  334. margin-top: 20px;
  335. }
  336. </style>