index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <div class="home-container">
  3. <grid-layout
  4. :layout.sync="layout"
  5. :col-num="14"
  6. :row-height="30"
  7. :is-draggable="true"
  8. :is-resizable="true"
  9. :is-mirrored="false"
  10. :vertical-compact="true"
  11. :margin="[10, 10]"
  12. :use-css-transforms="true"
  13. >
  14. <grid-item :key="layout[0].i" :x="layout[0].x" :y="layout[0].y" :w="layout[0].w" :h="layout[0].h" :i="layout[0].i">
  15. <el-row type="flex" justify="center" class="searh-row">
  16. <el-col :span="10"><el-input placeholder="请输入搜索内容" /></el-col>
  17. <el-col :span="2"><el-button type="primary" icon="el-icon-search">智搜</el-button></el-col>
  18. </el-row>
  19. </grid-item>
  20. <grid-item :key="layout[1].i" :x="layout[1].x" :y="layout[1].y" :w="layout[1].w" :h="layout[1].h" :i="layout[1].i">
  21. <el-card class="card-box">
  22. <div slot="header" class="clearfix">
  23. <span>消息提醒</span>
  24. <el-button style="float: right; padding: 3px 0" type="text">More<i class="el-icon-arrow-right" /></el-button>
  25. </div>
  26. <el-tabs class="message-content" value="todo">
  27. <el-tab-pane :label="'待办('+ message.todo + ')'" name="todo">
  28. <div class="message-filter_box">
  29. <span>筛选条件:</span>
  30. <el-radio-group v-model="message.filter" size="mini">
  31. <el-radio-button label="0">全部</el-radio-button>
  32. <el-radio-button label="1">任务类</el-radio-button>
  33. <el-radio-button label="2">通知类</el-radio-button>
  34. <el-radio-button label="3">超期提醒类</el-radio-button>
  35. </el-radio-group>
  36. </div>
  37. <el-table :data="message.todoData" :show-header="false" size="mini" height="calc(100% - 30px)">
  38. <el-table-column width="40">
  39. <template>
  40. <el-avatar shape="square" size="small"><svg-icon icon-class="yujing" /></el-avatar>
  41. </template>
  42. </el-table-column>
  43. <el-table-column show-overflow-tooltip>
  44. <template slot-scope="scope">
  45. <div>{{ scope.row.title }} <span :class="'priority-box priority-level'+ scope.row.priority">{{ scope.row.priorityName }}</span> </div>
  46. <div>{{ scope.row.appName }}</div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column prop="createDate" width="140" />
  50. <el-table-column prop="createUser" width="70" show-overflow-tooltip />
  51. <el-table-column width="105">
  52. <template>
  53. <el-button size="mini">Mark Read</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. </el-tab-pane>
  58. <el-tab-pane :label="'已办('+ message.done + ')'" name="done">
  59. <div class="message-filter_box">
  60. <span>筛选条件:</span>
  61. <el-radio-group v-model="message.filter" size="mini">
  62. <el-radio-button label="0">全部</el-radio-button>
  63. <el-radio-button label="1">任务类</el-radio-button>
  64. <el-radio-button label="2">通知类</el-radio-button>
  65. <el-radio-button label="3">超期提醒类</el-radio-button>
  66. </el-radio-group>
  67. </div>
  68. <el-table :data="message.doneData" :show-header="false" size="mini" height="calc(100% - 30px)">
  69. <el-table-column width="40">
  70. <template>
  71. <el-avatar shape="square" size="small"><svg-icon icon-class="yujing" /></el-avatar>
  72. </template>
  73. </el-table-column>
  74. <el-table-column show-overflow-tooltip>
  75. <template slot-scope="scope">
  76. <div>{{ scope.row.title }} <span :class="'priority-box priority-level'+ scope.row.priority">{{ scope.row.priorityName }}</span> </div>
  77. <div>{{ scope.row.appName }}</div>
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="createDate" width="140" />
  81. <el-table-column prop="createUser" width="70" show-overflow-tooltip />
  82. <el-table-column width="105">
  83. <template>
  84. <el-button size="mini">不再提醒</el-button>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </el-tab-pane>
  89. </el-tabs>
  90. </el-card>
  91. </grid-item>
  92. <grid-item :key="layout[2].i" :x="layout[2].x" :y="layout[2].y" :w="layout[2].w" :h="layout[2].h" :i="layout[2].i">
  93. <el-card class="card-box">
  94. <div slot="header" class="clearfix">
  95. <span>我的业务</span>
  96. <el-button style="float: right; padding: 3px 0" type="text">More<i class="el-icon-arrow-right" /></el-button>
  97. </div>
  98. </el-card>
  99. </grid-item>
  100. <grid-item :key="layout[3].i" :x="layout[3].x" :y="layout[3].y" :w="layout[3].w" :h="layout[3].h" :i="layout[3].i">
  101. <el-card class="card-box">
  102. <div slot="header" class="clearfix">
  103. <span>我的应用</span>
  104. <el-button style="float: right; padding: 3px 0" type="text">More<i class="el-icon-arrow-right" /></el-button>
  105. </div>
  106. <el-carousel height="150px">
  107. <el-carousel-item v-for="item in 4" :key="item">
  108. <h3 class="small">{{ item }}</h3>
  109. </el-carousel-item>
  110. </el-carousel>
  111. </el-card>
  112. </grid-item>
  113. <grid-item :key="layout[4].i" :x="layout[4].x" :y="layout[4].y" :w="layout[4].w" :h="layout[4].h" :i="layout[4].i">
  114. <el-card class="card-box">
  115. <div slot="header" class="clearfix">
  116. <span>专项工具</span>
  117. <el-button style="float: right; padding: 3px 0" type="text">More<i class="el-icon-arrow-right" /></el-button>
  118. </div>
  119. <div v-for="o in 4" :key="o" class="item">
  120. {{ '列表内容 ' + o }}
  121. </div>
  122. </el-card>
  123. </grid-item>
  124. <grid-item :key="layout[5].i" :x="layout[5].x" :y="layout[5].y" :w="layout[5].w" :h="layout[5].h" :i="layout[5].i">
  125. <el-card class="card-box">
  126. <div slot="header" class="clearfix">
  127. <span>标准规范</span>
  128. <el-button style="float: right; padding: 3px 0" type="text">More<i class="el-icon-arrow-right" /></el-button>
  129. </div>
  130. <div v-for="o in 4" :key="o" class="item">
  131. {{ '列表内容 ' + o }}
  132. </div>
  133. </el-card>
  134. </grid-item>
  135. <grid-item :key="layout[6].i" :x="layout[6].x" :y="layout[6].y" :w="layout[6].w" :h="layout[6].h" :i="layout[6].i">
  136. <el-card class="card-box">
  137. <div slot="header" class="clearfix">
  138. <span>外部应用导航</span>
  139. <el-button style="float: right; padding: 3px 0" type="text">More<i class="el-icon-arrow-right" /></el-button>
  140. </div>
  141. <div v-for="o in 4" :key="o" class="item">
  142. {{ '列表内容 ' + o }}
  143. </div>
  144. </el-card>
  145. </grid-item>
  146. </grid-layout>
  147. </div>
  148. </template>
  149. <script>
  150. import { mapGetters } from 'vuex'
  151. import VueGridLayout from 'vue-grid-layout'
  152. let sseClient
  153. export default {
  154. name: 'Home',
  155. components: {
  156. GridLayout: VueGridLayout.GridLayout,
  157. GridItem: VueGridLayout.GridItem
  158. },
  159. data() {
  160. return {
  161. layout: [
  162. { 'x': 0, 'y': 0, 'w': 14, 'h': 2, 'i': '0' },
  163. { 'x': 0, 'y': 2, 'w': 6, 'h': 12, 'i': '1' },
  164. { 'x': 0, 'y': 14, 'w': 6, 'h': 8, 'i': '2' },
  165. { 'x': 6, 'y': 2, 'w': 8, 'h': 8, 'i': '3' },
  166. { 'x': 6, 'y': 10, 'w': 8, 'h': 6, 'i': '4' },
  167. { 'x': 6, 'y': 16, 'w': 8, 'h': 6, 'i': '5' },
  168. { 'x': 0, 'y': 22, 'w': 14, 'h': 4, 'i': '6' }
  169. ],
  170. message: {
  171. todo: 10,
  172. done: 45,
  173. filter: '0',
  174. todoData: [
  175. { 'id': 1, 'type': '1', 'app': 'zfbapt', 'appName': 'XXXX System', 'priority': '1', 'priorityName': 'Emergency', 'title': 'message test 1', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  176. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXX System System', 'priority': '2', 'priorityName': 'Normal', 'title': 'message test 2message test 2', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  177. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXX System', 'priority': '2', 'priorityName': 'Normal', 'title': 'I am a message 3', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  178. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXX System', 'priority': '2', 'priorityName': 'Normal', 'title': 'I am a message 3', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  179. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXX System', 'priority': '2', 'priorityName': 'Normal', 'title': 'I am a message 3', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  180. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXX System', 'priority': '2', 'priorityName': 'Normal', 'title': 'I am a message 3', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  181. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXX System', 'priority': '2', 'priorityName': 'Normal', 'title': 'I am a message 3', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' },
  182. { 'id': 2, 'type': '2', 'app': 'zfbapt', 'appName': 'XXXXXXXXXXXX System', 'priority': '2', 'priorityName': 'Normal', 'title': 'I am a message too 4', 'createDate': '2023-07-09 16:01:02', 'createUser': 'zhang san', 'status': '0' }
  183. ],
  184. todoData2: [],
  185. doneData: []
  186. }
  187. }
  188. },
  189. computed: {
  190. ...mapGetters([
  191. 'name'
  192. ])
  193. },
  194. mounted() {
  195. this.connect()
  196. },
  197. beforeDestroy() {
  198. if (sseClient) {
  199. sseClient.disconnect()
  200. }
  201. },
  202. methods: {
  203. connect() {
  204. sseClient = this.$sse.create({
  205. url: process.env.VUE_APP_BASE_API + '/subscribe/test1',
  206. format: 'json',
  207. withCredentials: true,
  208. polyfill: true
  209. })
  210. sseClient.on('error', (e) => {
  211. console.error('lost connection or failed to parse!', e)
  212. // If this error is due to an unexpected disconnection, EventSource will
  213. // automatically attempt to reconnect indefinitely. You will _not_ need to
  214. // re-add your handlers.
  215. })
  216. sseClient.on('message', this.handleMessage)
  217. sseClient.connect()
  218. .then(sse => {
  219. console.log('We\'re connected!')
  220. })
  221. .catch((err) => {
  222. // When this error is caught, it means the initial connection to the
  223. // events server failed. No automatic attempts to reconnect will be made.
  224. console.error('Failed to connect to server', err)
  225. })
  226. },
  227. handleMessage(message) {
  228. console.log(message)
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. $gridBgColor: #ffffff;
  235. $msgCardHeaderHeight: 43px;
  236. .searh-row {
  237. height: 100%;
  238. align-items: center;
  239. background-color: $gridBgColor;
  240. }
  241. .card-box {
  242. height: 100%;
  243. ::v-deep {
  244. .el-card__header {
  245. padding: 10px 10px !important;
  246. height: $msgCardHeaderHeight;
  247. span{
  248. font-weight: bold;
  249. }
  250. }
  251. .el-card__body {
  252. height: calc(100% - #{$msgCardHeaderHeight});
  253. padding: 0 10px 10px 10px;
  254. &>* {
  255. height: 100%;
  256. }
  257. }
  258. }
  259. }
  260. .message-content {
  261. .message-filter_box {
  262. height: 30px;
  263. &>span {
  264. display: inline-block;
  265. font-size: 14px;
  266. }
  267. }
  268. ::v-deep {
  269. .el-tabs__header {
  270. height: 40px;
  271. }
  272. .el-tabs__item {
  273. font-size: 18px !important;
  274. }
  275. .el-tabs__content {
  276. height: calc(100% - 55px);
  277. .el-tab-pane{
  278. height: 100%;
  279. }
  280. }
  281. .el-table .cell {
  282. padding-left: 0 !important;
  283. }
  284. }
  285. }
  286. .priority-box{
  287. display: inline-block;
  288. padding: 0 5px;
  289. color: #ffffff;
  290. }
  291. .priority-level1{
  292. background: #F85252;
  293. }
  294. .priority-level2{
  295. background: orange;
  296. }
  297. .priority-level3{
  298. background: yellow;
  299. }
  300. .priority-level4{
  301. background: blue;
  302. }
  303. .vue-grid-item:not(.vue-grid-placeholder) {
  304. background: #e0dede;
  305. }
  306. .vue-grid-item .resizing {
  307. opacity: 0.9;
  308. }
  309. .vue-grid-item .static {
  310. background: rgb(128, 128, 237);
  311. }
  312. .vue-grid-item .text {
  313. font-size: 24px;
  314. text-align: center;
  315. position: absolute;
  316. top: 0;
  317. bottom: 0;
  318. left: 0;
  319. right: 0;
  320. margin: auto;
  321. height: 100%;
  322. width: 100%;
  323. }
  324. .vue-grid-item .no-drag {
  325. height: 100%;
  326. width: 100%;
  327. }
  328. .vue-grid-item .minMax {
  329. font-size: 12px;
  330. }
  331. .vue-grid-item .add {
  332. cursor: pointer;
  333. }
  334. .vue-draggable-handle {
  335. position: absolute;
  336. width: 20px;
  337. height: 20px;
  338. top: 0;
  339. left: 0;
  340. 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;
  341. background-position: bottom right;
  342. padding: 0 8px 8px 0;
  343. background-repeat: no-repeat;
  344. background-origin: content-box;
  345. box-sizing: border-box;
  346. cursor: pointer;
  347. }
  348. </style>