index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-10 09:11:34
  4. * @LastEditTime: 2025-07-10 15:07:29
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/overview/components/wind_speed_frequency/index.vue
  8. -->
  9. <template>
  10. <div class="type-variable">
  11. <!-- 风速频率分析 -->
  12. <div class="left">
  13. <FilterChart
  14. :setUpimg="[]"
  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="titleCharts">分析分图 :</div>
  35. <VirtualList
  36. :list="diagramRelationsDatas"
  37. keyField="fieldEngineCode"
  38. :itemSize="452"
  39. v-slot="{ item, index }"
  40. v-if="diagramRelationsDatas && diagramRelationsDatas.length > 0"
  41. >
  42. <BarChart
  43. :setUpImgData="setUpImgData"
  44. :key="item.fieldEngineCode + index"
  45. :inds="`${new Date().getTime()}` + index + 'barChart'"
  46. :ref="item.fieldEngineCode"
  47. :fileAddr="item.fileAddr"
  48. ></BarChart>
  49. </VirtualList>
  50. <el-empty description="暂无分析记录" v-else></el-empty>
  51. <el-dialog
  52. v-if="isShowDescription"
  53. title="添加评论"
  54. :visible="isShow"
  55. width="30%"
  56. v-dialogDrag
  57. :modal="false"
  58. :lock-scroll="false"
  59. :modal-append-to-body="false"
  60. @close="handleClose"
  61. >
  62. <el-tabs value="first">
  63. <el-tab-pane label="意见描述" name="first">
  64. <TinymceEditor
  65. ref="editor"
  66. v-model="comment"
  67. @input="handleEditorInput($event)"
  68. @onClick="onClick"
  69. >
  70. </TinymceEditor>
  71. </el-tab-pane>
  72. </el-tabs>
  73. <el-row
  74. type="flex"
  75. class="row-bg"
  76. justify="end"
  77. style="margin: 20px 60px 0 0"
  78. >
  79. <el-col :span="2">
  80. <el-button type="primary" size="small" @click="handleComment"
  81. >提交评论</el-button
  82. >
  83. </el-col>
  84. </el-row>
  85. </el-dialog>
  86. </div>
  87. <div class="right" v-if="isShowTinymceEditorCom">
  88. <DicCard
  89. :batchCode="initBatchCode"
  90. :analysisTypeCode="analysisTypeCode"
  91. :commentDescriptionVos="commentDescriptionVos"
  92. >
  93. </DicCard>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import DicCard from "@/views/overview/components/dicCard/index.vue";
  99. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  100. import BarChart from "@/views/performance/components/chartsCom/BarChart.vue";
  101. import TinymceEditor from "@/components/Tinymce.vue";
  102. import {
  103. analysisDetail,
  104. queryAnalysisedEngine,
  105. analysisCommentEdit,
  106. } from "@/api/performance";
  107. export default {
  108. name: "windSpeedFrequency",
  109. components: {
  110. DicCard,
  111. FilterChart,
  112. BarChart,
  113. TinymceEditor,
  114. },
  115. props: {
  116. initBatchCode: {
  117. default: "",
  118. type: String,
  119. },
  120. isShowTinymceEditorCom: {
  121. default: true,
  122. type: Boolean,
  123. },
  124. isShow: {
  125. default: false,
  126. type: Boolean,
  127. },
  128. analysisTypeCode: {
  129. default: "",
  130. type: String,
  131. },
  132. batchCodeList: {
  133. default: "",
  134. type: Array,
  135. },
  136. },
  137. data() {
  138. return {
  139. form: {
  140. value2: "",
  141. },
  142. setUpImgData: [],
  143. comment: "",
  144. options: [],
  145. windEngineGroupList: [], //批次风机列表
  146. fieldEngineCodes: [], //选中风机
  147. generalFilesDatas: [], //总图
  148. diagramRelationsDatas: [], //分图
  149. commentDescriptionVos: [], //评论列表
  150. editableTabs: [],
  151. isShowDescription: false,
  152. };
  153. },
  154. watch: {
  155. isShow() {
  156. if (this.isShow) {
  157. if (!this.isShowDescription) {
  158. this.$message({
  159. message: "当前分析模型暂无分析,不能进行评论操作",
  160. type: "warning",
  161. });
  162. this.$emit("setIsShow");
  163. }
  164. }
  165. },
  166. initBatchCode(newVal) {
  167. if (newVal) {
  168. this.fetchData(); // 调用合并后的函数
  169. }
  170. },
  171. analysisTypeCode(newVal) {
  172. if (newVal) {
  173. this.fetchData(); // 调用合并后的函数
  174. }
  175. },
  176. },
  177. mounted() {
  178. if (this.initBatchCode && this.analysisTypeCode) {
  179. this.fetchData(); // 调用合并后的函数
  180. }
  181. },
  182. methods: {
  183. handleClose() {
  184. //关闭评论弹框
  185. this.$emit("setIsShow");
  186. },
  187. async handleComment() {
  188. try {
  189. await analysisCommentEdit({
  190. batchCode: this.initBatchCode,
  191. analysisTypeCode: this.analysisTypeCode,
  192. commentList: this.editableTabs.map((item) => {
  193. return {
  194. commentTypeCode: item.commentTypeCode,
  195. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  196. };
  197. }),
  198. });
  199. this.$message({
  200. type: "success",
  201. message: "保存成功",
  202. });
  203. this.comment = "";
  204. this.getAnalysisDetail();
  205. this.$emit("setIsShow");
  206. } catch (e) {
  207. console.error(e);
  208. this.loading = false;
  209. }
  210. },
  211. onSubmit() {
  212. console.log("submit!");
  213. },
  214. // 合并后的函数,处理数据请求
  215. async fetchData() {
  216. try {
  217. // 获取分析详情
  218. await this.getAnalysisDetail();
  219. // 获取风机列表
  220. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  221. } catch (err) {
  222. console.error("Failed to fetch data:", err);
  223. }
  224. },
  225. // 获取分析详情接口
  226. async getAnalysisDetail() {
  227. try {
  228. const result = await analysisDetail({
  229. batchCode: this.initBatchCode,
  230. analysisTypeCode: this.analysisTypeCode,
  231. fieldEngineCodes:
  232. this.fieldEngineCodes.length === 0
  233. ? undefined
  234. : this.fieldEngineCodes.join(","),
  235. });
  236. if (result.data.length > 0) {
  237. this.isShowDescription = true;
  238. }
  239. if (
  240. result.data &&
  241. result.data[0] &&
  242. result.data[0].commentTypeRelations
  243. ) {
  244. this.editableTabs = result.data[0].commentTypeRelations;
  245. }
  246. //当前评论展示获取
  247. if (
  248. result.data &&
  249. result.data[0] &&
  250. result.data[0].commentDescriptionVos
  251. ) {
  252. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  253. }
  254. this.generalFilesDatas =
  255. (result.data &&
  256. result.data[0] &&
  257. result.data[0].generalFiles &&
  258. result.data[0].generalFiles.filter((item) =>
  259. item.fileAddr.endsWith(".json")
  260. )) ||
  261. []; //总图数据
  262. this.diagramRelationsDatas =
  263. (result.data &&
  264. result.data[0] &&
  265. result.data[0].diagramRelations &&
  266. result.data[0].diagramRelations.filter((item) =>
  267. item.fileAddr.endsWith(".json")
  268. )) ||
  269. [];
  270. } catch (err) {
  271. console.error("Failed to fetch analysis details:", err);
  272. }
  273. },
  274. // 请求风机列表
  275. async getWindEnfineList(batchCode, analysisTypeCode) {
  276. // console.log("请求风机列表 分钟级");
  277. const resEngineList = await queryAnalysisedEngine({
  278. batchCode: batchCode,
  279. analysisTypeCode,
  280. });
  281. this.windEngineGroupList = resEngineList.data;
  282. },
  283. handleEditorInput(index, newVal) {
  284. // 更新对应的 comment 值
  285. // 如果该功能没有实现,可以删除这个方法
  286. },
  287. //获取选中风机list
  288. getEnfineList(data, setUpImg) {
  289. this.fieldEngineCodes = data;
  290. this.setUpImgData = [...setUpImg];
  291. this.getAnalysisDetail();
  292. },
  293. //下一条
  294. handleNext() {
  295. const index = this.batchCodeList.findIndex(
  296. (item) => item === this.initBatchCode
  297. );
  298. if (index === this.batchCodeList.length - 1) {
  299. this.$message.warning("已经是最后一个分析结果了");
  300. return;
  301. }
  302. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  303. },
  304. //上一条
  305. handlePrevious() {
  306. const index = this.batchCodeList.findIndex(
  307. (item) => item === this.initBatchCode
  308. );
  309. if (index === 0) {
  310. this.$message.warning("没有上一条了");
  311. return;
  312. }
  313. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  314. },
  315. onClick() {},
  316. },
  317. };
  318. </script>
  319. <style scoped lang="scss">
  320. .type-variable {
  321. display: flex;
  322. height: 90%;
  323. overflow: hidden;
  324. .left {
  325. width: 30%;
  326. height: 100%;
  327. overflow: auto;
  328. padding: 20px;
  329. flex: 1;
  330. /* 滚动条整体样式 */
  331. &::-webkit-scrollbar {
  332. width: 6px; /* 滚动条宽度 */
  333. }
  334. /* 滚动条轨道 */
  335. &::-webkit-scrollbar-track {
  336. background: #f5f7fa;
  337. border-radius: 3px;
  338. }
  339. /* 滚动条滑块 */
  340. &::-webkit-scrollbar-thumb {
  341. background: #c0c4cc;
  342. border-radius: 3px;
  343. }
  344. /* 滚动条滑块悬停时 */
  345. &::-webkit-scrollbar-thumb:hover {
  346. background: #909399;
  347. }
  348. }
  349. .right {
  350. width: 0px;
  351. height: 100%;
  352. overflow: hidden;
  353. }
  354. }
  355. .el-dialog__wrapper {
  356. position: relative !important;
  357. }
  358. ::v-deep .el-dialog {
  359. position: fixed !important;
  360. z-index: 999 !important;
  361. top: 50%;
  362. left: 50%;
  363. transform: translate(0, -50%);
  364. }
  365. .titleCharts {
  366. font-size: 16px;
  367. font-weight: 500;
  368. margin-top: 20px;
  369. }
  370. </style>