index.vue 9.0 KB

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