index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <!--
  2. * @Author: your name
  3. * @Date: 2025-01-10 09:11:12
  4. * @LastEditTime: 2025-01-21 16:06:41
  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">
  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="diagramRelationsDatas"
  36. keyField="fieldEngineCode"
  37. :itemSize="452"
  38. v-slot="{ item, index }"
  39. >
  40. <WindRoseChart
  41. :key="item.fieldEngineCode + index"
  42. :inds="index"
  43. :ref="item.fieldEngineCode"
  44. :fileAddr="item.fileAddr"
  45. ></WindRoseChart>
  46. </VirtualList>
  47. <el-tabs value="first" v-if="isShowDescription">
  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" v-if="isShowDescription">
  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 WindRoseChart from "@/views/performance/components/chartsCom/WindRoseChart.vue";
  78. import DicCard from "@/views/overview/components/dicCard/index.vue";
  79. import FilterChart from "@/views/overview/components/filterChart/index.vue";
  80. import TinymceEditor from "@/components/Tinymce.vue";
  81. import {
  82. analysisDetail,
  83. queryAnalysisedEngine,
  84. analysisCommentEdit,
  85. } from "@/api/performance";
  86. export default {
  87. name: "windDirectionFrequency",
  88. components: {
  89. DicCard,
  90. FilterChart,
  91. TinymceEditor,
  92. WindRoseChart,
  93. },
  94. props: {
  95. initBatchCode: {
  96. default: "",
  97. type: String,
  98. },
  99. analysisTypeCode: {
  100. default: "",
  101. type: String,
  102. },
  103. batchCodeList: {
  104. default: "",
  105. type: Array,
  106. },
  107. },
  108. data() {
  109. return {
  110. form: {
  111. value2: "",
  112. },
  113. comment: "",
  114. options: [],
  115. windEngineGroupList: [], //批次风机列表
  116. fieldEngineCodes: [], //选中风机
  117. generalFilesDatas: [], //总图
  118. diagramRelationsDatas: [], //分图
  119. commentDescriptionVos: [], //评论列表
  120. editableTabs: [],
  121. isShowDescription: false,
  122. };
  123. },
  124. watch: {
  125. initBatchCode(newVal) {
  126. if (newVal) {
  127. this.fetchData(); // 调用合并后的函数
  128. }
  129. },
  130. analysisTypeCode(newVal) {
  131. if (newVal) {
  132. this.fetchData(); // 调用合并后的函数
  133. }
  134. },
  135. },
  136. mounted() {
  137. if (this.initBatchCode && this.analysisTypeCode) {
  138. this.fetchData(); // 调用合并后的函数
  139. }
  140. },
  141. methods: {
  142. async handleComment() {
  143. try {
  144. await analysisCommentEdit({
  145. batchCode: this.initBatchCode,
  146. analysisTypeCode: this.analysisTypeCode,
  147. commentList: this.editableTabs.map((item) => {
  148. return {
  149. commentTypeCode: item.commentTypeCode,
  150. comment: item.commentTypeName === "分析评论" ? this.comment : "",
  151. };
  152. }),
  153. });
  154. this.$message({
  155. type: "success",
  156. message: "保存成功",
  157. });
  158. this.comment = "";
  159. this.getAnalysisDetail();
  160. } catch (e) {
  161. console.error(e);
  162. this.loading = false;
  163. }
  164. },
  165. onSubmit() {
  166. console.log("submit!");
  167. },
  168. // 合并后的函数,处理数据请求
  169. async fetchData() {
  170. try {
  171. console.log(
  172. this.initBatchCode,
  173. this.analysisTypeCode,
  174. "请求详情 分钟级"
  175. );
  176. // 获取分析详情
  177. await this.getAnalysisDetail();
  178. // 获取风机列表
  179. await this.getWindEnfineList(this.initBatchCode, this.analysisTypeCode);
  180. } catch (err) {
  181. console.error("Failed to fetch data:", err);
  182. }
  183. },
  184. // 获取分析详情接口
  185. async getAnalysisDetail() {
  186. try {
  187. const result = await analysisDetail({
  188. batchCode: this.initBatchCode,
  189. analysisTypeCode: this.analysisTypeCode,
  190. fieldEngineCodes:
  191. this.fieldEngineCodes.length === 0
  192. ? undefined
  193. : this.fieldEngineCodes.join(","),
  194. });
  195. if (result.data.length > 0) {
  196. this.isShowDescription = true;
  197. }
  198. if (
  199. result.data &&
  200. result.data[0] &&
  201. result.data[0].commentTypeRelations
  202. ) {
  203. this.editableTabs = result.data[0].commentTypeRelations;
  204. }
  205. //当前评论展示获取
  206. if (
  207. result.data &&
  208. result.data[0] &&
  209. result.data[0].commentDescriptionVos
  210. ) {
  211. this.commentDescriptionVos = result.data[0].commentDescriptionVos;
  212. }
  213. this.generalFilesDatas =
  214. (result.data &&
  215. result.data[0] &&
  216. result.data[0].generalFiles &&
  217. result.data[0].generalFiles.filter((item) =>
  218. item.fileAddr.endsWith(".json")
  219. )) ||
  220. []; //总图数据
  221. this.diagramRelationsDatas =
  222. (result.data &&
  223. result.data[0] &&
  224. result.data[0].diagramRelations &&
  225. result.data[0].diagramRelations.filter((item) =>
  226. item.fileAddr.endsWith(".json")
  227. )) ||
  228. [];
  229. } catch (err) {
  230. console.error("Failed to fetch analysis details:", err);
  231. }
  232. },
  233. // 请求风机列表
  234. async getWindEnfineList(batchCode, analysisTypeCode) {
  235. // console.log("请求风机列表 分钟级");
  236. const resEngineList = await queryAnalysisedEngine({
  237. batchCode: batchCode,
  238. analysisTypeCode,
  239. });
  240. this.windEngineGroupList = resEngineList.data;
  241. },
  242. handleEditorInput(index, newVal) {
  243. // 更新对应的 comment 值
  244. // 如果该功能没有实现,可以删除这个方法
  245. },
  246. //获取选中风机list
  247. getEnfineList(data) {
  248. this.fieldEngineCodes = data;
  249. this.getAnalysisDetail();
  250. },
  251. //下一条
  252. handleNext() {
  253. const index = this.batchCodeList.findIndex(
  254. (item) => item === this.initBatchCode
  255. );
  256. if (index === this.batchCodeList.length - 1) {
  257. this.$message.warning("已经是最后一个分析结果了");
  258. return;
  259. }
  260. this.$emit("setInitBathCode", this.batchCodeList[index + 1]);
  261. },
  262. //上一条
  263. handlePrevious() {
  264. const index = this.batchCodeList.findIndex(
  265. (item) => item === this.initBatchCode
  266. );
  267. if (index === 0) {
  268. this.$message.warning("没有上一条了");
  269. return;
  270. }
  271. this.$emit("setInitBathCode", this.batchCodeList[index - 1]);
  272. },
  273. onClick() {},
  274. },
  275. };
  276. </script>
  277. <style scoped lang="scss">
  278. .type-variable {
  279. display: flex;
  280. height: 90%;
  281. overflow: hidden;
  282. .left {
  283. width: 30%;
  284. height: 100%;
  285. overflow: auto;
  286. padding: 20px;
  287. flex: 1;
  288. /* 滚动条整体样式 */
  289. &::-webkit-scrollbar {
  290. width: 6px; /* 滚动条宽度 */
  291. }
  292. /* 滚动条轨道 */
  293. &::-webkit-scrollbar-track {
  294. background: #f5f7fa;
  295. border-radius: 3px;
  296. }
  297. /* 滚动条滑块 */
  298. &::-webkit-scrollbar-thumb {
  299. background: #c0c4cc;
  300. border-radius: 3px;
  301. }
  302. /* 滚动条滑块悬停时 */
  303. &::-webkit-scrollbar-thumb:hover {
  304. background: #909399;
  305. }
  306. }
  307. .right {
  308. width: 250px;
  309. height: 100%;
  310. overflow: hidden;
  311. }
  312. }
  313. .titleCharts {
  314. font-size: 16px;
  315. font-weight: 500;
  316. margin-top: 20px;
  317. }
  318. </style>