index.vue 10 KB

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