You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.9 KiB

  1. <template>
  2. <div>
  3. <div class="empty" v-if="layout.length == 0">
  4. <el-empty description="暂未选择模块"></el-empty>
  5. </div>
  6. <div v-else class="my_grid" style="width: 100%; min-height: 800px; margin-top: 10px">
  7. <grid-layout
  8. :layout.sync="layout"
  9. :col-num="layoutColNum"
  10. :row-height="120"
  11. :is-draggable="true"
  12. :is-resizable="true"
  13. :is-mirrored="false"
  14. :vertical-compact="true"
  15. :margin="[10, 10]"
  16. :use-css-transforms="true"
  17. >
  18. <grid-item
  19. v-for="(item) in layout"
  20. :x="item.x"
  21. :y="item.y"
  22. :w="item.w"
  23. :h="item.h"
  24. :i="item.i"
  25. :key="item.i">
  26. <div class="m_content_card_title">
  27. <span><b>{{item.menuname}}</b></span>
  28. </div>
  29. <dsp source="GZT" v-if="item.menuid == 'dsp'"></dsp>
  30. <wdrw source="GZT" v-if="item.menuid == 'wdrw'"></wdrw>
  31. <wdcp source="GZT" v-if="item.menuid == 'wdcp'"></wdcp>
  32. <wdxm source="GZT" v-if="item.menuid == 'wdxm'"></wdxm>
  33. </grid-item>
  34. </grid-layout>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import dsp from '@/views/mdp/workflow/ru/task/TaskListAssigneeToMe.vue';
  40. import wdrw from '@/views/xm/core/xmTask/xmMyTaskCenter.vue';
  41. import wdcp from '@/views/xm/core/xmProduct/XmProductAllMng.vue';
  42. import wdxm from '@/views/xm/core/xmProject/XmProjectMng';
  43. import VueGridLayout from 'vue-grid-layout';
  44. import { mapGetters } from 'vuex'
  45. export default {
  46. components: {
  47. dsp,
  48. wdrw,
  49. wdcp,
  50. wdxm,
  51. GridLayout: VueGridLayout.GridLayout,
  52. GridItem: VueGridLayout.GridItem
  53. },
  54. computed: {
  55. ...mapGetters(['userInfo']),
  56. menuFavorite() {
  57. return this.$store.state.menuFavorite.fMenu;
  58. }
  59. },
  60. watch: {
  61. 'menuFavorite': {
  62. handler(val, oval) {
  63. this.layout = [];
  64. val.forEach((element, index) => {
  65. this.addItem(element, index);
  66. });
  67. }
  68. }
  69. },
  70. data() {
  71. return {
  72. // 布局位置数据
  73. layout: [],
  74. // 布局列数
  75. layoutColNum: 12,
  76. }
  77. },
  78. methods: {
  79. addItem: function(element, index) {
  80. this.layout.push(
  81. {
  82. ...element,
  83. // x: (this.layout.length * 6) % (this.layoutColNum || 12),
  84. x: 0,
  85. // y: this.layout.length + (this.layoutColNum || 12),
  86. y: 12,
  87. w: 12,
  88. h: 4,
  89. i: index,
  90. }
  91. )
  92. },
  93. },
  94. mounted() {
  95. this.$nextTick(() => {
  96. this.$store.dispatch('getUserFavoriteMenu', {userid: this.userInfo.displayUserid});
  97. })
  98. },
  99. }
  100. </script>
  101. <style>
  102. .my_grid .vue-grid-item.vue-grid-placeholder {
  103. background: rgb(214, 214, 214) !important;
  104. }
  105. </style>
  106. <style lang="scss" scoped>
  107. @import '../../common.scss';
  108. @import '../index.scss';
  109. .empty {
  110. height: 500px;
  111. background: #fff;
  112. margin: 11px;
  113. padding: 20px;
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. }
  118. .vue-grid-layout {
  119. background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.15) 1%, rgba(0, 0, 0, 0) 1%)
  120. ,linear-gradient(0deg,rgba(0, 0, 0, 0.15) 1%, rgba(0, 0, 0, 0) 1%);
  121. background-size: calc(100% / 12) calc(100% / 12); /*调节格子宽 高*/
  122. }
  123. .vue-grid-item:not(.vue-grid-placeholder) {
  124. background: #fff;
  125. }
  126. .vue-grid-item .resizing {
  127. opacity: 0.9;
  128. }
  129. .vue-grid-item .static {
  130. background: #cce;
  131. }
  132. .vue-grid-item .text {
  133. font-size: 24px;
  134. text-align: center;
  135. position: absolute;
  136. top: 0;
  137. bottom: 0;
  138. left: 0;
  139. right: 0;
  140. margin: auto;
  141. height: 100%;
  142. width: 100%;
  143. }
  144. .vue-grid-item .no-drag {
  145. height: 100%;
  146. width: 100%;
  147. }
  148. .vue-grid-item .minMax {
  149. font-size: 12px;
  150. }
  151. .vue-grid-item .add {
  152. cursor: pointer;
  153. }
  154. .vue-draggable-handle {
  155. position: absolute;
  156. width: 20px;
  157. height: 20px;
  158. top: 0;
  159. left: 0;
  160. background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><circle cx='5' cy='5' r='5' fill='#999999'/></svg>") no-repeat;
  161. background-position: bottom right;
  162. padding: 0 8px 8px 0;
  163. background-repeat: no-repeat;
  164. background-origin: content-box;
  165. box-sizing: border-box;
  166. cursor: pointer;
  167. }
  168. .m_content_card_title {
  169. height: 45px;
  170. padding: 20px 20px 40px 20px;
  171. span {
  172. font-size: 18px;
  173. font-weight: bold;
  174. color: #7D7D7D;
  175. }
  176. }
  177. </style>