index.vue 11 KB

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