index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:09:55
  4. * @LastEditTime: 2025-01-16 10:03:48
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/pitch_tsr_cp/index.vue
  8. -->
  9. <!-- pitchTsrCp -->
  10. <template>
  11. <div class="type-variable">
  12. <!-- 动态偏航误差分析--只有分图不存在总图 -->
  13. <div class="left">
  14. <FilterChart
  15. :windList="windEngineGroupList"
  16. @getEnfineList="getEnfineList"
  17. @handlePrevious="handlePrevious"
  18. @handleNext="handleNext"
  19. ></FilterChart>
  20. <el-alert type="info" :closable="false">
  21. <template v-slot:title>
  22. <div style="display: flex; align-items: center">
  23. <i
  24. class="el-icon-info"
  25. style="font-size: 20px; margin-right: 5px"
  26. ></i>
  27. <h3>分析说明:</h3>
  28. </div>
  29. </template>
  30. <div style="font-size: 12px; margin-top: 10px">
  31. 风能利用系数可以表示为变桨角度和叶尖速比的函数。每一个确定的桨距角,都存在一个最大风力利用系数,随着桨距角的变大,最大风力利用系数降低,其对应的叶尖速比也降低。此分析可以看出机组的发电情况表现。
  32. </div>
  33. </el-alert>
  34. <div class="charts" v-if="diagramRelationsDatas">
  35. <template v-for="(itemChart, indChart) in diagramRelationsDatas">
  36. <TwoDMarkersChart
  37. :key="itemChart.fieldEngineCode"
  38. @getResult="getResult"
  39. @changeRequestNum="changeRequestNum"
  40. :result="requestResult"
  41. :index="indChart"
  42. :ref="itemChart.fieldEngineCode"
  43. :fileAddr="itemChart.fileAddr"
  44. >
  45. </TwoDMarkersChart>
  46. </template>
  47. </div>
  48. <el-empty description="暂无分析记录" v-else></el-empty>
  49. <el-tabs value="first">
  50. <el-tab-pane label="意见描述" name="first">
  51. <TinymceEditor
  52. ref="editor"
  53. v-model="comment"
  54. @input="handleEditorInput($event)"
  55. @onClick="onClick"
  56. >
  57. </TinymceEditor>
  58. </el-tab-pane>
  59. </el-tabs>
  60. <el-row type="flex" class="row-bg" justify="end">
  61. <el-col :span="2" style="margin: 20px">
  62. <el-button type="primary" size="small">提交评论</el-button>
  63. </el-col>
  64. </el-row>
  65. </div>
  66. <div class="right">
  67. <DicCard
  68. :batchCode="initBatchCode"
  69. :analysisTypeCode="analysisTypeCode"
  70. :commentDescriptionVos="commentDescriptionVos"
  71. >
  72. </DicCard>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import DicCard from "@/views/overview/components/dicCard/index.vue";
  78. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  79. import TwoDMarkersChart from "@/views/performance/components/chartsCom/TwoDMarkersChart.vue";
  80. import TinymceEditor from "@/components/Tinymce.vue";
  81. import { analysisDetail, queryAnalysisedEngine } from "@/api/performance";
  82. export default {
  83. name: "pitchTsrCp",
  84. components: {
  85. DicCard,
  86. FilterChart,
  87. TwoDMarkersChart,
  88. TinymceEditor,
  89. },
  90. props: {
  91. initBatchCode: {
  92. default: "",
  93. type: String,
  94. },
  95. analysisTypeCode: {
  96. default: "",
  97. type: String,
  98. },
  99. batchCodeList: {
  100. default: "",
  101. type: Array,
  102. },
  103. },
  104. data() {
  105. return {
  106. form: {
  107. value2: "",
  108. },
  109. windEngineGroupList: [], //批次风机列表
  110. fieldEngineCodes: [], //选中风机
  111. comment: "",
  112. options: [],
  113. generalFilesDatas: [], //总图
  114. diagramRelationsDatas: [], //分图,
  115. requestResult: [], // 请求结果
  116. requestRecord: [],
  117. commentDescriptionVos: [], //评论列表
  118. editableTabs: [],
  119. };
  120. },
  121. watch: {
  122. initBatchCode(newVal) {
  123. if (newVal) {
  124. this.fetchData(); // 调用合并后的函数
  125. }
  126. },
  127. analysisTypeCode(newVal) {
  128. if (newVal) {
  129. this.fetchData(); // 调用合并后的函数
  130. }
  131. },
  132. },
  133. mounted() {
  134. if (this.initBatchCode && this.analysisTypeCode) {
  135. this.fetchData(); // 调用合并后的函数
  136. }
  137. },
  138. methods: {
  139. async handleComment() {
  140. try {
  141. await analysisCommentEdit({
  142. batchCode: this.initBatchCode,
  143. analysisTypeCode: this.analysisTypeCode,
  144. commentList: this.editableTabs.map((item) => {
  145. return {
  146. commentTypeCode: item.commentTypeCode,
  147. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  148. };
  149. }),
  150. });
  151. this.$message({
  152. type: "success",
  153. message: "保存成功",
  154. });
  155. this.comment = "";
  156. this.getAnalysisDetail();
  157. } catch (e) {
  158. console.error(e);
  159. this.loading = false;
  160. }
  161. },
  162. getResult({ index, result }) {
  163. console.log(index, result);
  164. this.$set(this.requestResult, index, result);
  165. // this.requestResult[index] = result
  166. this.requestRecord[index] = result;
  167. },
  168. changeRequestNum(index) {
  169. if (index <= 1) {
  170. this.$set(this.requestRecord, index, "start");
  171. return;
  172. }
  173. if (index > 1) {
  174. if (
  175. this.requestRecord.every((item) =>
  176. ["success", "error"].includes(item)
  177. )
  178. ) {
  179. this.$set(this.requestRecord, index, "start");
  180. this.$set(this.requestResult, index, "start");
  181. } else {
  182. this.$set(this.requestRecord, index, "start");
  183. }
  184. }
  185. },
  186. onSubmit() {
  187. console.log("submit!");
  188. },
  189. // 合并后的函数,处理数据请求
  190. async fetchData() {
  191. try {
  192. console.log(
  193. this.initBatchCode,
  194. this.analysisTypeCode,
  195. "请求详情 分钟级"
  196. );
  197. // 获取分析详情
  198. await this.getAnalysisDetail();
  199. // 获取风机列表
  200. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  201. } catch (err) {
  202. console.error("Failed to fetch data:", err);
  203. }
  204. },
  205. // 获取分析详情接口
  206. async getAnalysisDetail() {
  207. try {
  208. const result = await analysisDetail({
  209. batchCode: this.initBatchCode,
  210. analysisTypeCode: this.analysisTypeCode,
  211. fieldEngineCodes:
  212. this.fieldEngineCodes.length === 0
  213. ? undefined
  214. : this.fieldEngineCodes,
  215. });
  216. if (
  217. result.data &&
  218. result.data[0] &&
  219. result.data[0].commentTypeRelations
  220. ) {
  221. this.editableTabs = result.data[0].commentTypeRelations;
  222. }
  223. //当前评论展示获取
  224. if (
  225. result.data &&
  226. result.data[0] &&
  227. result.data[0].commentDescriptionVos
  228. ) {
  229. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  230. }
  231. this.generalFilesDatas =
  232. result.data && result.data[0] && result.data[0].generalFiles; //总图数据
  233. this.diagramRelationsDatas =
  234. result.data && result.data[0] && result.data[0].diagramRelations;
  235. } catch (err) {
  236. console.error("Failed to fetch analysis details:", err);
  237. }
  238. },
  239. // 请求风机列表
  240. async getWindEnfineList(batchCode, analysisTypeCode) {
  241. // console.log("请求风机列表 分钟级");
  242. const resEngineList = await queryAnalysisedEngine({
  243. batchCode: batchCode,
  244. analysisTypeCode,
  245. });
  246. this.windEngineGroupList = resEngineList.data;
  247. },
  248. handleEditorInput(index, newVal) {
  249. // 更新对应的 comment 值
  250. // 如果该功能没有实现,可以删除这个方法
  251. },
  252. //获取选中风机list
  253. getEnfineList(data) {
  254. this.fieldEngineCodes = data;
  255. console.log(this.fieldEngineCodes, "this.fieldEngineCodes");
  256. },
  257. //下一条
  258. handleNext() {
  259. const index = this.batchCodeList.findIndex(
  260. (item) => item === this.initBatchCode
  261. );
  262. if (index === this.batchCodeList.length - 1) {
  263. this.$message.warning("已经是最后一个分析结果了");
  264. return;
  265. }
  266. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  267. },
  268. //上一条
  269. handlePrevious() {
  270. const index = this.batchCodeList.findIndex(
  271. (item) => item === this.initBatchCode
  272. );
  273. if (index === 0) {
  274. this.$message.warning("没有上一条了");
  275. return;
  276. }
  277. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  278. },
  279. onClick() {},
  280. },
  281. };
  282. </script>
  283. <style scoped lang="scss">
  284. .type-variable {
  285. display: flex;
  286. height: 90%;
  287. overflow: hidden;
  288. .left {
  289. width: 30%;
  290. height: 100%;
  291. overflow: auto;
  292. padding: 20px;
  293. flex: 1;
  294. }
  295. .right {
  296. width: 250px;
  297. height: 100%;
  298. overflow: hidden;
  299. }
  300. }
  301. </style>