index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <div class="global-variable" v-loading="loading">
  3. <div class="left">
  4. <div class="leftTitle">
  5. <el-input
  6. class="filterInput"
  7. placeholder="输入关键字进行过滤"
  8. v-model="filterText"
  9. >
  10. </el-input>
  11. <el-dropdown>
  12. <span class="el-dropdown-link">
  13. <i class="el-icon-more-outline"></i>
  14. </span>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item>
  17. <span @click="handleClick(true)"> 展开 </span>
  18. </el-dropdown-item>
  19. <el-dropdown-item>
  20. <span @click="handleClick(false)">收起</span>
  21. </el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. </div>
  25. <el-tree
  26. class="filter-tree"
  27. :data="data"
  28. highlight-current
  29. :props="defaultProps"
  30. :default-expanded-keys="expandedKeys"
  31. :current-node-key="initBatchCode"
  32. :filter-node-method="filterNode"
  33. @node-click="handleNodeClick"
  34. :node-key="'codeNumber'"
  35. ref="tree"
  36. />
  37. </div>
  38. <div class="right">
  39. <el-menu
  40. :default-active="activeIndex"
  41. class="el-menu-demo"
  42. mode="horizontal"
  43. @select="handleSelect"
  44. >
  45. <template v-for="menuItem in assetssTypeData">
  46. <el-submenu
  47. :index="menuItem.typeCode + menuItem.typeName"
  48. v-if="menuItem.children && menuItem.children.length"
  49. >
  50. <template slot="title">{{ menuItem.typeName }}</template>
  51. <el-menu-item
  52. v-for="submenuItem in menuItem.children"
  53. :index="
  54. submenuItem.typeName === '机组指标'
  55. ? 'production_indicator_unit'
  56. : submenuItem.typeName === '全场指标'
  57. ? 'production_indicator_all'
  58. : submenuItem.typeName === '机组故障统计'
  59. ? 'fault_unit'
  60. : submenuItem.typeName === '全场故障统计'
  61. ? 'fault_all'
  62. : submenuItem.typeName === '齿轮箱-高速轴温度分析'
  63. ? 'temperature_large_components_hig'
  64. : submenuItem.typeName === '齿轮箱-中速轴温度分析'
  65. ? 'temperature_large_components_mid'
  66. : submenuItem.typeName === '齿轮箱-低速轴温度分析'
  67. ? 'temperature_large_components_low'
  68. : submenuItem.typeName === '主轴承温度分析'
  69. ? 'temperature_large_components_min'
  70. : submenuItem.typeName === '发电机-驱动端轴承温度分析'
  71. ? 'temperature_large_components_adriven'
  72. : submenuItem.typeName === '发电机-非驱动端轴承温度分析'
  73. ? 'temperature_large_components_undriven'
  74. : submenuItem.typeName === '发电机-轴承温度偏差分析'
  75. ? 'temperature_large_components_tem_deviation'
  76. : submenuItem.typeName === '发电机-绕组温度分析'
  77. ? 'temperature_large_components_Winding_tem'
  78. : submenuItem.typeCode
  79. "
  80. >{{ submenuItem.typeName }}</el-menu-item
  81. >
  82. </el-submenu>
  83. <el-menu-item :index="menuItem.typeCode" v-else>{{
  84. menuItem.typeName
  85. }}</el-menu-item>
  86. </template>
  87. </el-menu>
  88. <!-- 动态渲染组件 -->
  89. <keep-alive>
  90. <component
  91. :ref="analysisTypeCode"
  92. :is="currentComponent"
  93. :initBatchCode="initBatchCode"
  94. :analysisTypeCode="analysisTypeCode"
  95. :batchCodeList="batchCodeList"
  96. @setInitBathCode="setInitBathCode"
  97. @setIsShow="setIsShow"
  98. :isShow="isShow"
  99. :isShowTinymceEditorCom="true"
  100. ></component>
  101. </keep-alive>
  102. </div>
  103. <div
  104. class="tousutiwen_box"
  105. @click="handleTousutiwen"
  106. v-if="activeIndex !== 'analysis_information'"
  107. >
  108. <el-tooltip
  109. class="item"
  110. effect="dark"
  111. content="添加评论"
  112. placement="right"
  113. >
  114. <div class="tousutiwen_icon">
  115. <svg-icon icon-class="tousutiwen" style="width: 30px; height: 30px" />
  116. </div>
  117. </el-tooltip>
  118. </div>
  119. <el-dialog
  120. :title="'分析主题:' + batchTitle"
  121. :visible="isShowComment"
  122. width="40%"
  123. v-dialogDrag
  124. :modal="false"
  125. :lock-scroll="false"
  126. :modal-append-to-body="false"
  127. @close="handleClose"
  128. >
  129. <component
  130. :ref="analysisTypeCode"
  131. :is="currentComponent"
  132. :initBatchCode="dialogInitBatchCode"
  133. :analysisTypeCode="analysisTypeCode"
  134. :batchCodeList="batchCodeList"
  135. @setInitBathCode="setInitBathCode"
  136. @setIsShow="setIsShow"
  137. :isShow="isShow"
  138. :isShowTinymceEditorCom="false"
  139. ></component>
  140. </el-dialog>
  141. <!-- <el-empty description="暂无数据"></el-empty> -->
  142. </div>
  143. </template>
  144. <script>
  145. import { queryAllAnalysisType } from "@/api/performance";
  146. import { getAnalysisCodeInfo } from "@/api/overview";
  147. export default {
  148. data() {
  149. return {
  150. loading: false,
  151. filterText: "",
  152. data: [],
  153. isShow: false, //控制评论框是否显示
  154. isShowComment: false, //控制上一条、下一条是否显示
  155. // 用于控制是否展开/收起
  156. isExpanded: false,
  157. expandedKeys: [], //默认展开的节点
  158. batchCodeList: [], //批次数组用于切换上一条、下一条
  159. batchList: [], //批次列表
  160. batchTitle: "", //浮窗title
  161. initBatchCode: "", // 初始化分析编号
  162. dialogInitBatchCode: "",
  163. analysisTypeCode: "", // 当前选中的分析模型
  164. windEngineGroupList: "", //风机编码
  165. defaultProps: {
  166. children: "children",
  167. label: "fieldOrCompanyName",
  168. },
  169. currentComponent: () =>
  170. import("./components/analysis_information/index.vue"), // 默认加载AnalysisInformation组件
  171. assetssTypeData: [
  172. {
  173. id: "1",
  174. label: "分析概述",
  175. typeCode: "analysis_information",
  176. },
  177. ],
  178. activeIndex: "analysis_information", // 默认选中的菜单项
  179. };
  180. },
  181. watch: {
  182. filterText(val) {
  183. this.$refs.tree.filter(val);
  184. },
  185. // 监听 initBatchCode 的变化,确保树节点正确选中
  186. initBatchCode(newVal) {
  187. this.$nextTick(() => {
  188. const tree = this.$refs.tree;
  189. if (tree) {
  190. tree.setCurrentKey(newVal); // 设置当前选中的节点
  191. }
  192. });
  193. },
  194. analysisTypeCode(newVal) {
  195. console.log(newVal, "分析模型 ");
  196. },
  197. },
  198. async created() {
  199. if (this.$route.query.batchCode) {
  200. this.initBatchCode = this.$route.query.batchCode;
  201. }
  202. await Promise.all([this.getTreeData(), this.queryAllAnalysisType()]);
  203. // 初始化逻辑
  204. },
  205. methods: {
  206. setIsShow() {
  207. this.isShow = false;
  208. },
  209. handleTousutiwen() {
  210. this.isShow = true;
  211. },
  212. //展开/收起
  213. handleClick(expand) {
  214. // 设置展开或收起状态
  215. this.isExpanded = expand;
  216. if (expand) {
  217. this.$refs.tree.store._getAllNodes().forEach((node) => {
  218. node.expanded = true;
  219. });
  220. } else {
  221. // 折叠所有节点
  222. this.$refs.tree.store._getAllNodes().forEach((node) => {
  223. node.expanded = false;
  224. });
  225. }
  226. },
  227. // 获取树形结构数据
  228. getTreeData() {
  229. this.loading = true;
  230. getAnalysisCodeInfo()
  231. .then((res) => {
  232. if (res.code === 200) {
  233. this.loading = false;
  234. this.batchCodeList = [];
  235. const formattedData = this.formatData(res.data);
  236. this.data = formattedData;
  237. console.log(formattedData[0], "formattedData[0]");
  238. this.expandedKeys.push(formattedData[0]?.children[0]?.codeNumber);
  239. // =
  240. // [
  241. // formattedData[0]?.codeNumber,
  242. // formattedData[0]?.children[0]?.codeNumber,
  243. // ] || [];
  244. // 确保数据加载完成后才查询其他分析模型
  245. // this.queryAllAnalysisType();
  246. }
  247. })
  248. .catch((err) => {});
  249. },
  250. //数据格式化树形结构
  251. formatData(data) {
  252. return (
  253. data &&
  254. data.map((item) => {
  255. item.levelstate = "1";
  256. if (item.children && item.children.length > 0) {
  257. item.children = item.children.map((child) => ({
  258. //二级
  259. fieldOrCompanyName: child.fieldOrCompanyName,
  260. codeNumber: child.codeNumber,
  261. levelstate: "2",
  262. children: child.batchCodes
  263. ? child.batchCodes.map((bc) => {
  264. if (this.initBatchCode === "") {
  265. this.initBatchCode = bc.batchCode; // 初始化选中的节点
  266. }
  267. this.batchCodeList.push(bc.batchCode);
  268. this.batchList.push({
  269. batchCode: bc.batchCode,
  270. batchName: bc.analysisName,
  271. });
  272. return {
  273. //三级
  274. fieldOrCompanyName: bc.analysisName,
  275. codeNumber: bc.batchCode,
  276. levelstate: "3",
  277. };
  278. })
  279. : [],
  280. }));
  281. }
  282. return item;
  283. })
  284. );
  285. },
  286. // 点击树形节点时
  287. handleNodeClick(data) {
  288. if (
  289. (data.children &&
  290. data.children.length <= 0 &&
  291. data.levelstate === "1") ||
  292. (data.children && data.children.length <= 0 && data.levelstate === "2")
  293. ) {
  294. this.$message.warning("当前选中风场未进行任何分析,请重新选择");
  295. } else {
  296. if (!data.children) {
  297. this.initBatchCode = data.codeNumber; // 更新选中的节点
  298. }
  299. }
  300. },
  301. //获取
  302. queryAllAnalysisType() {
  303. queryAllAnalysisType().then((res) => {
  304. if (res.code === 200) {
  305. this.assetssTypeData = [
  306. {
  307. id: "1",
  308. typeName: "分析概述",
  309. typeCode: "analysis_information",
  310. },
  311. ...res.data,
  312. ];
  313. }
  314. });
  315. },
  316. // 过滤树形节点的方法
  317. filterNode(value, data) {
  318. if (!value) return true; // 如果没有输入过滤文本,则返回true,显示所有节点
  319. // 先判断当前节点是否符合过滤条件
  320. let isMatch = data.fieldOrCompanyName.indexOf(value) !== -1;
  321. // 如果当前节点有子节点且子节点长度大于0,强制显示父节点并保留所有子节点
  322. if (data.children && data.children.length > 0) {
  323. // 递归过滤子节点,如果子节点有一个匹配,则保留父节点
  324. isMatch =
  325. isMatch ||
  326. data.children.some((child) => this.filterNode(value, child));
  327. }
  328. return isMatch;
  329. },
  330. // filterNode(value, data) {
  331. // if (!value) return true;
  332. // return data.fieldOrCompanyName.indexOf(value) !== -1;
  333. // },
  334. setInitBathCode(val) {
  335. // this.initBatchCode = val;
  336. this.isShowComment = true;
  337. this.dialogInitBatchCode = val;
  338. const batchObj = this.batchList.find((item) =>
  339. item.batchCode === val ? item.batchName : ""
  340. );
  341. this.batchTitle = batchObj.batchName;
  342. console.log(this.batchTitle, "this.batchTitle");
  343. },
  344. // 关闭上一条、下一条弹窗展示组件设置
  345. handleClose() {
  346. this.isShowComment = false;
  347. },
  348. // 菜单选中项的事件
  349. handleSelect(key, keyPath) {
  350. this.analysisTypeCode = key;
  351. this.activeIndex = key;
  352. this.currentComponent = () => import(`./components/${key}/index.vue`);
  353. },
  354. },
  355. };
  356. </script>
  357. <style scoped lang="scss">
  358. .global-variable {
  359. display: flex;
  360. height: 90vh;
  361. overflow: hidden;
  362. .left {
  363. width: 200px;
  364. border-right: 1px solid #ebeef5;
  365. padding-right: 20px;
  366. margin-bottom: 20px;
  367. overflow-y: scroll;
  368. .leftTitle {
  369. display: flex;
  370. align-items: center;
  371. justify-content: space-between;
  372. .el-icon-more-outline {
  373. margin-left: 10px;
  374. transform: rotate(90deg);
  375. }
  376. }
  377. /* 滚动条整体样式 */
  378. &::-webkit-scrollbar {
  379. width: 0px; /* 滚动条宽度 */
  380. }
  381. /* 滚动条轨道 */
  382. &::-webkit-scrollbar-track {
  383. background: #f5f7fa;
  384. border-radius: 3px;
  385. }
  386. /* 滚动条滑块 */
  387. &::-webkit-scrollbar-thumb {
  388. background: #c0c4cc;
  389. border-radius: 3px;
  390. }
  391. /* 滚动条滑块悬停时 */
  392. &::-webkit-scrollbar-thumb:hover {
  393. background: #909399;
  394. }
  395. .filterInput {
  396. margin: 20px 0;
  397. }
  398. }
  399. .right {
  400. flex: 1;
  401. padding-left: 20px;
  402. overflow: hidden;
  403. /* 横向滚动设置 */
  404. .el-menu-demo {
  405. max-width: 100%; /* 容器宽度为100% */
  406. white-space: nowrap; /* 阻止换行 */
  407. overflow-x: auto; /* 允许横向滚动 */
  408. display: flex; /* 让子菜单元素保持在同一行 */
  409. /* 滚动条整体样式 */
  410. &::-webkit-scrollbar {
  411. height: 6px; /* 滚动条宽度 */
  412. }
  413. /* 滚动条轨道 */
  414. &::-webkit-scrollbar-track {
  415. background: #f5f7fa;
  416. border-radius: 3px;
  417. }
  418. /* 滚动条滑块 */
  419. &::-webkit-scrollbar-thumb {
  420. background: #c0c4cc;
  421. border-radius: 3px;
  422. }
  423. /* 滚动条滑块悬停时 */
  424. &::-webkit-scrollbar-thumb:hover {
  425. background: #909399;
  426. }
  427. }
  428. }
  429. .tousutiwen_box {
  430. position: fixed;
  431. right: 80px;
  432. bottom: 15%;
  433. background: rgb(255, 255, 255);
  434. border-radius: 50%;
  435. width: 50px;
  436. height: 50px;
  437. color: rgb(132, 145, 165);
  438. box-shadow: rgba(0, 0, 0, 0.1) 0px 2px 4px;
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. }
  443. .tousutiwen_box:hover {
  444. background: rgb(196, 199, 206);
  445. }
  446. .el-menu-demo {
  447. border-bottom: 1px solid #ebeef5;
  448. }
  449. ::v-deep .el-submenu__title {
  450. padding: 0 10px !important;
  451. }
  452. }
  453. .el-dialog__wrapper {
  454. position: relative !important;
  455. }
  456. ::v-deep .el-dialog {
  457. position: fixed !important;
  458. z-index: 999 !important;
  459. top: 50%;
  460. left: 50%;
  461. transform: translate(0, -50%);
  462. }
  463. ::v-deep .el-dialog__body {
  464. overflow-y: scroll;
  465. height: 80vh;
  466. }
  467. </style>