topoToolbox.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <el-tabs v-model="tabsActiveName" tab-position="left" class="topo-toolbox" @tab-click="handleTabsClick">
  3. <el-tab-pane name="1">
  4. <div slot="label" class="tab-item">
  5. <img v-if="tabsActiveName === '1'" width="24" height="24" src="@/assets/topo-img/images/edit_basic_active.png" />
  6. <img class="white-icon" v-else width="24" height="24" src="@/assets/topo-img/images/edit_basic_disable.png" />
  7. <span class="name" :class="{ active: tabsActiveName === '1' }">{{ $t('topo.topoToolbox.250932-0') }}</span>
  8. </div>
  9. <data-panel :data="jsonBase" />
  10. </el-tab-pane>
  11. <el-tab-pane name="2">
  12. <div slot="label" class="tab-item">
  13. <img v-if="tabsActiveName === '2'" width="24" height="24" src="@/assets/topo-img/images/edit_shape_active.png" />
  14. <img class="white-icon" v-else width="24" height="24" src="@/assets/topo-img/images/edit_shape_disable.png" />
  15. <span class="name" :class="{ active: tabsActiveName === '2' }">{{ $t('topo.topoToolbox.250932-1') }}</span>
  16. </div>
  17. <data-panel :data="jsonShape" />
  18. </el-tab-pane>
  19. <el-tab-pane name="3">
  20. <div slot="label" class="tab-item">
  21. <img v-if="tabsActiveName === '3'" width="24" height="24" src="@/assets/topo-img/images/edit_static_active.png" />
  22. <img class="white-icon" v-else width="24" height="24" src="@/assets/topo-img/images/edit_static_disable.png" />
  23. <span class="name" :class="{ active: tabsActiveName === '3' }">{{ $t('topo.topoToolbox.250932-2') }}</span>
  24. </div>
  25. <data-panel :data="jsonChart" />
  26. </el-tab-pane>
  27. <el-tab-pane name="4">
  28. <div slot="label" class="tab-item">
  29. <img v-if="tabsActiveName === '4'" width="24" height="24" src="@/assets/topo-img/images/edit_gallery_active.png" />
  30. <img class="white-icon" v-else width="24" height="24" src="@/assets/topo-img/images/edit_gallery_disable.png" />
  31. <span class="name" :class="{ active: tabsActiveName === '4' }">{{ $t('topo.topoToolbox.250932-3') }}</span>
  32. </div>
  33. <el-menu unique-opened @open="handleGalleryOpen">
  34. <el-submenu v-for="dict in dict.type.scada_gallery_type" :index="dict.value" :key="dict.value">
  35. <template slot="title">
  36. <span>{{ dict.label }}</span>
  37. </template>
  38. <data-panel v-loading="loading" element-loading-background="transparent" :data="gallerys" />
  39. </el-submenu>
  40. </el-menu>
  41. </el-tab-pane>
  42. <el-tab-pane name="5">
  43. <div slot="label" class="tab-item">
  44. <img v-if="tabsActiveName === '5'" width="24" height="24" src="@/assets/topo-img/images/edit_chart_active.png" />
  45. <img class="white-icon" v-else width="24" height="24" src="@/assets/topo-img/images/edit_chart_disable.png" />
  46. <span class="name" :class="{ active: tabsActiveName === '5' }">{{ $t('topo.topoToolbox.250932-4') }}</span>
  47. </div>
  48. <el-menu unique-opened @open="handleEchartOpen">
  49. <el-submenu v-for="dict in dict.type.scada_echart_type" :index="dict.value" :key="dict.value">
  50. <template slot="title">
  51. <span>{{ dict.label }}</span>
  52. </template>
  53. <data-panel v-loading="loading" element-loading-background="transparent" :data="echarts" />
  54. </el-submenu>
  55. </el-menu>
  56. </el-tab-pane>
  57. <el-tab-pane name="6">
  58. <div slot="label" class="tab-item">
  59. <img v-if="tabsActiveName === '6'" width="24" height="24" src="@/assets/topo-img/images/edit_more_active.png" />
  60. <img class="white-icon" v-else width="24" height="24" src="@/assets/topo-img/images/edit_more_disable.png" />
  61. <span class="name" :class="{ active: tabsActiveName === '6' }">{{ $t('topo.topoToolbox.250932-5') }}</span>
  62. </div>
  63. <data-panel v-loading="loading" element-loading-background="transparent" :data="components" />
  64. </el-tab-pane>
  65. </el-tabs>
  66. </template>
  67. <script>
  68. import { mapState } from 'vuex';
  69. import { listGallery } from '@/api/scada/gallery';
  70. import { listEchart } from '@/api/scada/echart';
  71. import { listComponent } from '@/api/scada/component';
  72. import jsonIcon from './data-toolbox/icon.json';
  73. import DataPanel from './data-panel/index';
  74. import jsonBase from './data-toolbox/base.json';
  75. import jsonShape from './data-toolbox/shape.json';
  76. import jsonChart from './data-toolbox/chart.json';
  77. export default {
  78. name: 'TopoToolbox',
  79. dicts: ['scada_gallery_type', 'scada_echart_type'],
  80. components: {
  81. DataPanel,
  82. },
  83. computed: {
  84. ...mapState({
  85. sidebar: (state) => state.app.sidebar,
  86. }),
  87. },
  88. data() {
  89. return {
  90. baseApi: process.env.VUE_APP_BASE_API,
  91. tabsActiveName: '1',
  92. jsonBase: jsonBase, // 基本组件
  93. jsonShape: jsonShape,
  94. jsonChart: jsonChart,
  95. jsonIcon: jsonIcon,
  96. loading: false,
  97. gallerys: {}, // 图库数据
  98. echarts: {}, // 图表数据
  99. components: {}, // 组件数据
  100. };
  101. },
  102. mounted() {},
  103. methods: {
  104. // 图片组件打开
  105. handleGalleryOpen(key) {
  106. this.getGalleryDatas(key);
  107. },
  108. // 图表组件打开
  109. handleEchartOpen(key) {
  110. this.getEchartDatas(key);
  111. },
  112. // tabs点击事件
  113. handleTabsClick(tab) {
  114. if (tab.name === '6') {
  115. this.getComponent('component');
  116. }
  117. },
  118. // 获取图库数据
  119. getGalleryDatas(name) {
  120. this.loading = true;
  121. const params = {
  122. pageNum: 1,
  123. pageSize: 10,
  124. categoryName: name,
  125. moduleGuid: this.$t('scada.gallery.309456-5'),
  126. orderByColumn: 'id',
  127. isAsc: 'desc',
  128. };
  129. listGallery(params).then((res) => {
  130. if (res.code === 200) {
  131. if (res.rows.length > 0) {
  132. let newJson = this.getJson(name);
  133. res.rows.forEach((item) => {
  134. newJson.title = item.categoryName;
  135. let newJsonItem = this.getImgJsonItem();
  136. newJsonItem.text = item.fileName;
  137. newJsonItem.icon = this.baseApi + item.resourceUrl;
  138. newJsonItem.info.style.url = this.baseApi + item.resourceUrl;
  139. newJson.items.push(newJsonItem);
  140. });
  141. this.gallerys = newJson;
  142. } else {
  143. this.gallerys = {};
  144. }
  145. }
  146. this.loading = false;
  147. });
  148. },
  149. // 获取图表数据
  150. getEchartDatas(name) {
  151. this.loading = true;
  152. const params = {
  153. pageNum: 1,
  154. pageSize: 10,
  155. echartType: name,
  156. };
  157. listEchart(params).then((res) => {
  158. if (res.code === 200) {
  159. if (res.rows.length > 0) {
  160. let newJson = this.getJson(name);
  161. res.rows.forEach((item) => {
  162. newJson.title = item.categoryName;
  163. let newJsonItem = this.getEchartJsonItem();
  164. newJsonItem.text = item.echartName;
  165. newJsonItem.icon = this.baseApi + item.echartImgae;
  166. newJsonItem.info.dataBind.echartOption = `echartId-${item.id}`;
  167. newJson.items.push(newJsonItem);
  168. });
  169. this.echarts = newJson;
  170. } else {
  171. this.echarts = {};
  172. }
  173. }
  174. this.loading = false;
  175. });
  176. },
  177. // 组件数据
  178. getComponent(type) {
  179. this.loading = true;
  180. const params = {
  181. pageNum: 1,
  182. pageSize: 9999,
  183. };
  184. listComponent(params).then((res) => {
  185. if (res.code === 200) {
  186. if (res.rows.length > 0) {
  187. let newJson = this.getJson(type);
  188. res.rows.forEach((item) => {
  189. newJson.title = item.categoryName;
  190. let newJsonItem = this.getComponentJsonItem();
  191. newJsonItem.text = item.componentName;
  192. newJsonItem.icon = this.baseApi + item.componentImage;
  193. newJsonItem.info.dataBind.componentId = item.id;
  194. newJson.items.push(newJsonItem);
  195. });
  196. this.components = newJson;
  197. } else {
  198. this.components = {};
  199. }
  200. }
  201. this.loading = false;
  202. });
  203. },
  204. getJson(type) {
  205. let newJson = {
  206. title: '',
  207. icon: type,
  208. opened: false,
  209. items: [],
  210. };
  211. return newJson;
  212. },
  213. // 生成图片json
  214. getImgJsonItem() {
  215. let newJson = {
  216. text: '',
  217. icon: '',
  218. type: 'service',
  219. info: {
  220. type: 'image',
  221. componentShow: ['动画', '单击', '组件颜色', '滤镜渲染', '状态开关', '参数绑定'],
  222. action: [],
  223. hdClassName: '',
  224. dataBind: {
  225. activeName: '变量状态',
  226. sceneModelId: '',
  227. sceneModelDeviceId: '',
  228. variableType: '',
  229. productId: '',
  230. serialNumber: '',
  231. identifier: '',
  232. modelName: '',
  233. modelValue: '',
  234. stateList: [],
  235. },
  236. dataEvent: {
  237. djAction: false,
  238. action: '1',
  239. sceneModelId: '',
  240. variableType: '',
  241. productId: '',
  242. serialNumber: '',
  243. slaveId: '',
  244. identifier: '',
  245. modelName: '',
  246. modelValue: '',
  247. redirectUrl: '',
  248. ztPage: '',
  249. },
  250. dataAction: {
  251. xyAction: false,
  252. xzAction: false,
  253. ssAction: false,
  254. hdAction: false,
  255. maAction: false,
  256. sceneModelId: '',
  257. sceneModelDeviceId: '',
  258. variableType: '',
  259. productId: '',
  260. serialNumber: '',
  261. identifier: '',
  262. modelName: '',
  263. paramJudge: '',
  264. paramJudgeData: '',
  265. rotationSpeed: '中',
  266. duration: '',
  267. translateList: [],
  268. },
  269. style: {
  270. position: {
  271. x: 200,
  272. y: 200,
  273. w: 100,
  274. h: 100,
  275. },
  276. backColor: 'rgba(255,255,255,0)',
  277. foreColor: 'rgba(255,255,255,0)',
  278. zIndex: 1,
  279. transform: 0,
  280. url: '',
  281. transformType: 'rotate(0deg)',
  282. isFilter: true,
  283. },
  284. },
  285. };
  286. return newJson;
  287. },
  288. // 生成图表json
  289. getEchartJsonItem() {
  290. let newJson = {
  291. text: '',
  292. icon: '',
  293. type: 'service',
  294. info: {
  295. type: 'chart-wrapper',
  296. componentShow: ['自定义echarts'],
  297. action: [],
  298. dataBind: {
  299. echartOption: '',
  300. echartRun: 0,
  301. echartData: '',
  302. httpSetting: {
  303. url: '',
  304. type: '',
  305. time: 60,
  306. unit: 's',
  307. params: {},
  308. body: {},
  309. headers: {},
  310. },
  311. },
  312. style: {
  313. position: {
  314. x: 0,
  315. y: 0,
  316. w: 350,
  317. h: 250,
  318. },
  319. backColor: 'rgba(255, 255, 255, 1)',
  320. foreColor: 'rgba(0, 0, 0, 1)',
  321. zIndex: 1,
  322. transform: 0,
  323. transformType: 'rotate(0deg)',
  324. },
  325. },
  326. };
  327. return newJson;
  328. },
  329. // 生成组件json
  330. getComponentJsonItem() {
  331. let newJson = {
  332. text: '',
  333. icon: '',
  334. type: 'service',
  335. info: {
  336. type: 'component',
  337. componentShow: ['动画'],
  338. action: [],
  339. dataBind: {},
  340. dataAction: {
  341. xyAction: false,
  342. xzAction: false,
  343. ssAction: false,
  344. hdAction: false,
  345. maAction: false,
  346. sceneModelId: '',
  347. sceneModelDeviceId: '',
  348. variableType: '',
  349. productId: '',
  350. serialNumber: '',
  351. identifier: '',
  352. modelName: '',
  353. paramJudge: '',
  354. paramJudgeData: '',
  355. rotationSpeed: '中',
  356. duration: '',
  357. translateList: [],
  358. },
  359. style: {
  360. position: {
  361. x: 0,
  362. y: 0,
  363. w: 350,
  364. h: 250,
  365. },
  366. backColor: 'rgba(255, 255, 255, 1)',
  367. foreColor: 'rgba(0, 0, 0, 1)',
  368. zIndex: 1,
  369. transform: 0,
  370. transformType: 'rotate(0deg)',
  371. },
  372. },
  373. };
  374. return newJson;
  375. },
  376. onDragstart(event, info) {
  377. var infoJson = JSON.stringify(info.info);
  378. event.dataTransfer.setData('my-info', infoJson);
  379. },
  380. },
  381. };
  382. </script>
  383. <style lang="scss" scoped>
  384. .topo-toolbox {
  385. height: 100%;
  386. border-right: #dcdfe6 solid 1px;
  387. ::v-deep .el-tabs__header {
  388. margin: 0;
  389. background: #222b3c;
  390. border-right: 1px solid white;
  391. .el-tabs__item {
  392. height: 88px;
  393. padding: 20px 16px;
  394. .tab-item {
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. font-size: 14px;
  399. .name {
  400. font-size: 14px;
  401. color: white;
  402. line-height: 24px;
  403. }
  404. }
  405. &.is-active {
  406. color: #486ff2;
  407. background: #ffffff;
  408. }
  409. }
  410. .el-tabs__active-bar {
  411. background: transparent;
  412. }
  413. .el-tabs__nav-wrap::after {
  414. background-color: transparent;
  415. }
  416. }
  417. .active {
  418. color: #486ff2 !important;
  419. }
  420. ::v-deep .el-tabs__content {
  421. height: 100%;
  422. overflow-y: auto;
  423. .el-submenu__title {
  424. height: 46px;
  425. line-height: 46px;
  426. font-size: 13px;
  427. }
  428. }
  429. }
  430. .white-icon {
  431. filter: brightness(0) invert(1);
  432. }
  433. ::v-deep .el-menu {
  434. background: #222b3c;
  435. .el-submenu .el-submenu__title {
  436. color: white !important;
  437. }
  438. .el-submenu__title:hover {
  439. color: black !important;
  440. }
  441. }
  442. </style>