index.vue 9.7 KB

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