index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-10 09:11:23
  4. * @LastEditTime: 2025-01-20 17:31:50
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/wind_spee/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. <BarChart
  41. :key="item.batchCode + index"
  42. :inds="index + 'barChart'"
  43. :ref="item.batchCode"
  44. :fileAddr="item.fileAddr"
  45. ></BarChart>
  46. </VirtualList>
  47. <el-tabs value="first">
  48. <el-tab-pane label="意见描述" name="first">
  49. <TinymceEditor
  50. ref="editor"
  51. v-model="comment"
  52. @input="handleEditorInput($event)"
  53. @onClick="onClick"
  54. >
  55. </TinymceEditor>
  56. </el-tab-pane>
  57. </el-tabs>
  58. <el-row type="flex" class="row-bg" justify="end">
  59. <el-col :span="2" style="margin: 20px">
  60. <el-button type="primary" size="small" @click="handleComment"
  61. >提交评论</el-button
  62. >
  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 BarChart from "@/views/performance/components/chartsCom/BarChart.vue";
  80. import TinymceEditor from "@/components/Tinymce.vue";
  81. import { analysisDetail, queryAnalysisedEngine } from "@/api/performance";
  82. export default {
  83. name: "windSpee",
  84. components: {
  85. DicCard,
  86. FilterChart,
  87. BarChart,
  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. comment: "",
  110. options: [],
  111. windEngineGroupList: [], //批次风机列表
  112. fieldEngineCodes: [], //选中风机
  113. generalFilesDatas: [], //总图
  114. diagramRelationsDatas: [], //分图
  115. commentDescriptionVos: [], //评论列表
  116. editableTabs: [],
  117. };
  118. },
  119. watch: {
  120. initBatchCode(newVal) {
  121. if (newVal) {
  122. this.fetchData(); // 调用合并后的函数
  123. }
  124. },
  125. analysisTypeCode(newVal) {
  126. if (newVal) {
  127. this.fetchData(); // 调用合并后的函数
  128. }
  129. },
  130. },
  131. mounted() {
  132. if (this.initBatchCode && this.analysisTypeCode) {
  133. this.fetchData(); // 调用合并后的函数
  134. }
  135. },
  136. methods: {
  137. async handleComment() {
  138. try {
  139. await analysisCommentEdit({
  140. batchCode: this.initBatchCode,
  141. analysisTypeCode: this.analysisTypeCode,
  142. commentList: this.editableTabs.map((item) => {
  143. return {
  144. commentTypeCode: item.commentTypeCode,
  145. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  146. };
  147. }),
  148. });
  149. this.$message({
  150. type: "success",
  151. message: "保存成功",
  152. });
  153. this.comment = "";
  154. this.getAnalysisDetail();
  155. } catch (e) {
  156. console.error(e);
  157. this.loading = false;
  158. }
  159. },
  160. onSubmit() {
  161. console.log("submit!");
  162. },
  163. // 合并后的函数,处理数据请求
  164. async fetchData() {
  165. try {
  166. // 获取分析详情
  167. await this.getAnalysisDetail();
  168. // 获取风机列表
  169. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  170. } catch (err) {
  171. console.error("Failed to fetch data:", err);
  172. }
  173. },
  174. // 获取分析详情接口
  175. async getAnalysisDetail() {
  176. try {
  177. const result = await analysisDetail({
  178. batchCode: this.initBatchCode,
  179. analysisTypeCode: this.analysisTypeCode,
  180. fieldEngineCodes:
  181. this.fieldEngineCodes.length === 0
  182. ? undefined
  183. : this.fieldEngineCodes.join(","),
  184. });
  185. if (
  186. result.data &&
  187. result.data[0] &&
  188. result.data[0].commentTypeRelations
  189. ) {
  190. this.editableTabs = result.data[0].commentTypeRelations;
  191. }
  192. //当前评论展示获取
  193. if (
  194. result.data &&
  195. result.data[0] &&
  196. result.data[0].commentDescriptionVos
  197. ) {
  198. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  199. }
  200. this.generalFilesDatas =
  201. result.data &&
  202. result.data[0] &&
  203. result.data[0].generalFiles &&
  204. result.data[0].generalFiles.filter((item) =>
  205. item.fileAddr.endsWith(".json")
  206. ); //总图数据
  207. this.diagramRelationsDatas =
  208. result.data &&
  209. result.data[0] &&
  210. result.data[0].diagramRelations.filter((item) =>
  211. item.fileAddr.endsWith(".json")
  212. );
  213. } catch (err) {
  214. console.error("Failed to fetch analysis details:", err);
  215. }
  216. },
  217. // 请求风机列表
  218. async getWindEnfineList(batchCode, analysisTypeCode) {
  219. // console.log("请求风机列表 分钟级");
  220. const resEngineList = await queryAnalysisedEngine({
  221. batchCode: batchCode,
  222. analysisTypeCode,
  223. });
  224. this.windEngineGroupList = resEngineList.data;
  225. },
  226. handleEditorInput(index, newVal) {
  227. // 更新对应的 comment 值
  228. // 如果该功能没有实现,可以删除这个方法
  229. },
  230. //获取选中风机list
  231. getEnfineList(data) {
  232. this.fieldEngineCodes = data;
  233. this.getAnalysisDetail();
  234. },
  235. //下一条
  236. handleNext() {
  237. const index = this.batchCodeList.findIndex(
  238. (item) => item === this.initBatchCode
  239. );
  240. if (index === this.batchCodeList.length - 1) {
  241. this.$message.warning("已经是最后一个分析结果了");
  242. return;
  243. }
  244. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  245. },
  246. //上一条
  247. handlePrevious() {
  248. const index = this.batchCodeList.findIndex(
  249. (item) => item === this.initBatchCode
  250. );
  251. if (index === 0) {
  252. this.$message.warning("没有上一条了");
  253. return;
  254. }
  255. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  256. },
  257. onClick() {},
  258. },
  259. };
  260. </script>
  261. <style scoped lang="scss">
  262. .type-variable {
  263. display: flex;
  264. height: 90%;
  265. overflow: hidden;
  266. .left {
  267. width: 30%;
  268. height: 100%;
  269. overflow: auto;
  270. padding: 20px;
  271. flex: 1;
  272. /* 滚动条整体样式 */
  273. &::-webkit-scrollbar {
  274. width: 6px; /* 滚动条宽度 */
  275. }
  276. /* 滚动条轨道 */
  277. &::-webkit-scrollbar-track {
  278. background: #f5f7fa;
  279. border-radius: 3px;
  280. }
  281. /* 滚动条滑块 */
  282. &::-webkit-scrollbar-thumb {
  283. background: #c0c4cc;
  284. border-radius: 3px;
  285. }
  286. /* 滚动条滑块悬停时 */
  287. &::-webkit-scrollbar-thumb:hover {
  288. background: #909399;
  289. }
  290. }
  291. .right {
  292. width: 250px;
  293. height: 100%;
  294. overflow: hidden;
  295. }
  296. }
  297. .titleCharts {
  298. font-size: 16px;
  299. font-weight: 500;
  300. margin-top: 20px;
  301. }
  302. </style>