index.vue 8.8 KB

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