index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:09:41
  4. * @LastEditTime: 2025-01-23 09:21:07
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/pitch_power/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. 在风力发电机组中,变桨-功率散点图展示了风机叶片的桨距角(即叶片与风向的角度)与风机产生的功率之间的关系。这种散点图能够揭示在不同风速和操作条件下,叶片角度调整是如何影响风机的功率输出的。
  31. </div>
  32. </el-alert>
  33. <div></div>
  34. <div class="titleCharts">分析分图 :</div>
  35. <VirtualList
  36. :list="diagramRelationsDatas"
  37. keyField="fieldEngineCode"
  38. :itemSize="600"
  39. v-slot="{ item, index }"
  40. >
  41. <!-- <TwoDMarkersChart
  42. :key="item.fieldEngineCode"
  43. :index="index"
  44. :ref="item.fieldEngineCode"
  45. :fileAddr="item.fileAddr"
  46. ></TwoDMarkersChart> -->
  47. <TwoDMarkersChart
  48. v-if="getFileTypeFromUrl(item.fileAddr) === 'pitch_power'"
  49. :index="index + 'TwoDMarkersChart'"
  50. :key="item.fieldEngineCode + 'TwoDMarkersChart'"
  51. :ref="item.fieldEngineCode"
  52. :fileAddr="item.fileAddr"
  53. >
  54. </TwoDMarkersChart>
  55. <Time3DChart
  56. v-if="getFileTypeFromUrl(item.fileAddr) === '3D'"
  57. :key="item.fieldEngineCode + 'Time3DChart'"
  58. :index="index + 'fen'"
  59. :ref="item.fieldEngineCode + 'Time3DChart'"
  60. :fileAddr="item.fileAddr"
  61. >
  62. </Time3DChart>
  63. </VirtualList>
  64. <el-tabs value="first" v-if="isShowDescription">
  65. <el-tab-pane label="意见描述" name="first">
  66. <TinymceEditor
  67. ref="editor"
  68. v-model="comment"
  69. @input="handleEditorInput($event)"
  70. @onClick="onClick"
  71. >
  72. </TinymceEditor>
  73. </el-tab-pane>
  74. </el-tabs>
  75. <el-row type="flex" class="row-bg" justify="end" v-if="isShowDescription">
  76. <el-col :span="2" style="margin: 20px">
  77. <el-button type="primary" size="small" @click="handleComment"
  78. >提交评论</el-button
  79. >
  80. </el-col>
  81. </el-row>
  82. </div>
  83. <div class="right">
  84. <DicCard
  85. :batchCode="initBatchCode"
  86. :analysisTypeCode="analysisTypeCode"
  87. :commentDescriptionVos="commentDescriptionVos"
  88. >
  89. </DicCard>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import DicCard from "@/views/overview/components/dicCard/index.vue";
  95. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  96. import TwoDMarkersChart from "@/views/performance/components/chartsCom/TwoDMarkersChart.vue";
  97. import TinymceEditor from "@/components/Tinymce.vue";
  98. import Time3DChart from "@/views/performance/components/chartsCom/Time3DChart.vue";
  99. import {
  100. analysisDetail,
  101. queryAnalysisedEngine,
  102. analysisCommentEdit,
  103. } from "@/api/performance";
  104. export default {
  105. name: "pitchPower",
  106. components: {
  107. DicCard,
  108. FilterChart,
  109. TwoDMarkersChart,
  110. Time3DChart,
  111. TinymceEditor,
  112. },
  113. props: {
  114. initBatchCode: {
  115. default: "",
  116. type: String,
  117. },
  118. analysisTypeCode: {
  119. default: "",
  120. type: String,
  121. },
  122. batchCodeList: {
  123. default: "",
  124. type: Array,
  125. },
  126. },
  127. data() {
  128. return {
  129. form: {
  130. value2: "",
  131. },
  132. windEngineGroupList: [], //批次风机列表
  133. fieldEngineCodes: [], //选中风机
  134. comment: "",
  135. options: [],
  136. generalFilesDatas: [], //总图
  137. diagramRelationsDatas: [], //分图,
  138. commentDescriptionVos: [], //评论列表
  139. editableTabs: [],
  140. isShowDescription: false,
  141. };
  142. },
  143. watch: {
  144. initBatchCode(newVal) {
  145. if (newVal) {
  146. this.fetchData(); // 调用合并后的函数
  147. }
  148. },
  149. analysisTypeCode(newVal) {
  150. if (newVal) {
  151. this.fetchData(); // 调用合并后的函数
  152. }
  153. },
  154. },
  155. mounted() {
  156. if (this.initBatchCode && this.analysisTypeCode) {
  157. this.fetchData(); // 调用合并后的函数
  158. }
  159. },
  160. methods: {
  161. getFileTypeFromUrl(url) {
  162. // 判断文件名或路径是否包含关键字
  163. if (url.includes("3D")) {
  164. return "3D"; // 如果 URL 中包含 "3D" 字符串,判断为 3D 类型
  165. } else if (url.includes("pitch_power")) {
  166. return "pitch_power"; // 如果 URL 中包含 "pitch_power" 字符串,判断为 pitch_power 类型
  167. } else {
  168. return "Unknown"; // 如果都不包含,返回 Unknown 或其他提示
  169. }
  170. },
  171. async handleComment() {
  172. try {
  173. await analysisCommentEdit({
  174. batchCode: this.initBatchCode,
  175. analysisTypeCode: this.analysisTypeCode,
  176. commentList: this.editableTabs.map((item) => {
  177. return {
  178. commentTypeCode: item.commentTypeCode,
  179. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  180. };
  181. }),
  182. });
  183. this.$message({
  184. type: "success",
  185. message: "保存成功",
  186. });
  187. this.comment = "";
  188. this.getAnalysisDetail();
  189. } catch (e) {
  190. console.error(e);
  191. this.loading = false;
  192. }
  193. },
  194. onSubmit() {
  195. console.log("submit!");
  196. },
  197. // 合并后的函数,处理数据请求
  198. async fetchData() {
  199. try {
  200. console.log(
  201. this.initBatchCode,
  202. this.analysisTypeCode,
  203. "请求详情 分钟级"
  204. );
  205. // 获取分析详情
  206. await this.getAnalysisDetail();
  207. // 获取风机列表
  208. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  209. } catch (err) {
  210. console.error("Failed to fetch data:", err);
  211. }
  212. },
  213. // 获取分析详情接口
  214. async getAnalysisDetail() {
  215. try {
  216. const result = await analysisDetail({
  217. batchCode: this.initBatchCode,
  218. analysisTypeCode: this.analysisTypeCode,
  219. fieldEngineCodes:
  220. this.fieldEngineCodes.length === 0
  221. ? undefined
  222. : this.fieldEngineCodes.join(","),
  223. });
  224. if (result.data.length > 0) {
  225. this.isShowDescription = true;
  226. }
  227. if (
  228. result.data &&
  229. result.data[0] &&
  230. result.data[0].commentTypeRelations
  231. ) {
  232. this.editableTabs = result.data[0].commentTypeRelations;
  233. }
  234. //当前评论展示获取
  235. if (
  236. result.data &&
  237. result.data[0] &&
  238. result.data[0].commentDescriptionVos
  239. ) {
  240. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  241. }
  242. this.generalFilesDatas =
  243. (result.data &&
  244. result.data[0] &&
  245. result.data[0].generalFiles &&
  246. result.data[0].generalFiles.filter((item) =>
  247. item.fileAddr.endsWith(".json")
  248. )) ||
  249. []; //总图数据
  250. this.diagramRelationsDatas =
  251. (result.data &&
  252. result.data[0] &&
  253. result.data[0].diagramRelations &&
  254. result.data[0].diagramRelations.filter((item) =>
  255. item.fileAddr.endsWith(".json")
  256. )) ||
  257. [];
  258. } catch (err) {
  259. console.error("Failed to fetch analysis details:", err);
  260. }
  261. },
  262. // 请求风机列表
  263. async getWindEnfineList(batchCode, analysisTypeCode) {
  264. // console.log("请求风机列表 分钟级");
  265. const resEngineList = await queryAnalysisedEngine({
  266. batchCode: batchCode,
  267. analysisTypeCode,
  268. });
  269. this.windEngineGroupList = resEngineList.data;
  270. },
  271. handleEditorInput(index, newVal) {
  272. // 更新对应的 comment 值
  273. // 如果该功能没有实现,可以删除这个方法
  274. },
  275. //获取选中风机list
  276. getEnfineList(data) {
  277. this.fieldEngineCodes = data;
  278. this.getAnalysisDetail();
  279. },
  280. //下一条
  281. handleNext() {
  282. const index = this.batchCodeList.findIndex(
  283. (item) => item === this.initBatchCode
  284. );
  285. if (index === this.batchCodeList.length - 1) {
  286. this.$message.warning("已经是最后一个分析结果了");
  287. return;
  288. }
  289. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  290. },
  291. //上一条
  292. handlePrevious() {
  293. const index = this.batchCodeList.findIndex(
  294. (item) => item === this.initBatchCode
  295. );
  296. if (index === 0) {
  297. this.$message.warning("没有上一条了");
  298. return;
  299. }
  300. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  301. },
  302. onClick() {},
  303. },
  304. };
  305. </script>
  306. <style scoped lang="scss">
  307. .type-variable {
  308. display: flex;
  309. height: 90%;
  310. overflow: hidden;
  311. .left {
  312. width: 30%;
  313. height: 100%;
  314. overflow: auto;
  315. padding: 20px;
  316. flex: 1;
  317. }
  318. .right {
  319. width: 250px;
  320. height: 100%;
  321. overflow: hidden;
  322. }
  323. }
  324. .titleCharts {
  325. font-size: 16px;
  326. font-weight: 500;
  327. margin-top: 20px;
  328. }
  329. </style>