index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-09 18:08:00
  4. * @LastEditTime: 2025-01-20 13:32:39
  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 { analysisDetail, queryAnalysisedEngine } from "@/api/performance";
  103. export default {
  104. name: "cpWindspeed",
  105. components: {
  106. DicCard,
  107. FilterChart,
  108. lineAndChildLine,
  109. lineChartsFen,
  110. TinymceEditor,
  111. },
  112. props: {
  113. initBatchCode: {
  114. default: "",
  115. type: String,
  116. },
  117. analysisTypeCode: {
  118. default: "",
  119. type: String,
  120. },
  121. batchCodeList: {
  122. default: "",
  123. type: Array,
  124. },
  125. },
  126. data() {
  127. return {
  128. form: {
  129. value2: "",
  130. },
  131. comment: "",
  132. options: [],
  133. windEngineGroupList: [], //批次风机列表
  134. fieldEngineCodes: [], //选中风机
  135. generalFilesDatas: [], //总图
  136. diagramRelationsDatas: [], //分图
  137. commentDescriptionVos: [], //评论列表
  138. editableTabs: [],
  139. };
  140. },
  141. watch: {
  142. initBatchCode(newVal) {
  143. if (newVal) {
  144. this.fetchData(); // 调用合并后的函数
  145. }
  146. },
  147. analysisTypeCode(newVal) {
  148. if (newVal) {
  149. this.fetchData(); // 调用合并后的函数
  150. }
  151. },
  152. },
  153. mounted() {
  154. if (this.initBatchCode && this.analysisTypeCode) {
  155. this.fetchData(); // 调用合并后的函数
  156. }
  157. },
  158. methods: {
  159. async handleComment() {
  160. try {
  161. await analysisCommentEdit({
  162. batchCode: this.initBatchCode,
  163. analysisTypeCode: this.analysisTypeCode,
  164. commentList: this.editableTabs.map((item) => {
  165. return {
  166. commentTypeCode: item.commentTypeCode,
  167. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  168. };
  169. }),
  170. });
  171. this.$message({
  172. type: "success",
  173. message: "保存成功",
  174. });
  175. this.comment = "";
  176. this.getAnalysisDetail();
  177. } catch (e) {
  178. console.error(e);
  179. this.loading = false;
  180. }
  181. },
  182. onSubmit() {
  183. console.log("submit!");
  184. },
  185. // 合并后的函数,处理数据请求
  186. async fetchData() {
  187. try {
  188. // 获取分析详情
  189. await this.getAnalysisDetail();
  190. // 获取风机列表
  191. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  192. } catch (err) {
  193. console.error("Failed to fetch data:", err);
  194. }
  195. },
  196. // 获取分析详情接口
  197. async getAnalysisDetail() {
  198. try {
  199. const result = await analysisDetail({
  200. batchCode: this.initBatchCode,
  201. analysisTypeCode: this.analysisTypeCode,
  202. fieldEngineCodes:
  203. this.fieldEngineCodes.length === 0
  204. ? undefined
  205. : this.fieldEngineCodes.join(","),
  206. });
  207. if (
  208. result.data &&
  209. result.data[0] &&
  210. result.data[0].commentTypeRelations
  211. ) {
  212. this.editableTabs = result.data[0].commentTypeRelations;
  213. }
  214. //当前评论展示获取
  215. if (
  216. result.data &&
  217. result.data[0] &&
  218. result.data[0].commentDescriptionVos
  219. ) {
  220. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  221. }
  222. this.generalFilesDatas =
  223. result.data &&
  224. result.data[0] &&
  225. result.data[0].generalFiles &&
  226. result.data[0].generalFiles.filter((item) =>
  227. item.fileAddr.endsWith(".json")
  228. ); //总图数据
  229. this.diagramRelationsDatas =
  230. result.data &&
  231. result.data[0] &&
  232. result.data[0].diagramRelations.filter((item) =>
  233. item.fileAddr.endsWith(".json")
  234. );
  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. this.getAnalysisDetail();
  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. .titleCharts {
  302. font-size: 16px;
  303. font-weight: 500;
  304. margin-top: 20px;
  305. }
  306. </style>