index.vue 11 KB

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