SysUserOnlineList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="12">
  8. <a-form-item label="账号">
  9. <a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="8">
  13. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  15. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <!-- 查询区域-END -->
  22. <!-- table区域-begin -->
  23. <div>
  24. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  25. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  26. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  27. </div>
  28. <a-table
  29. ref="table"
  30. size="middle"
  31. :scroll="{x:true}"
  32. bordered
  33. rowKey="token"
  34. :columns="columns"
  35. :dataSource="dataSource"
  36. :pagination="ipagination"
  37. :loading="loading"
  38. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  39. class="j-table-force-nowrap"
  40. @change="handleTableChange">
  41. <template slot="avatarslot" slot-scope="text, record, index">
  42. <div class="anty-img-wrap">
  43. <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
  44. </div>
  45. </template>
  46. <span slot="action" slot-scope="text, record">
  47. <a-popconfirm title="强制退出用户?" @confirm="() => handleForce(record)">
  48. <a-button type="danger">强退</a-button>
  49. </a-popconfirm>
  50. </span>
  51. </a-table>
  52. </div>
  53. </a-card>
  54. </template>
  55. <script>
  56. import '@/assets/less/TableExpand.less'
  57. import { mixinDevice } from '@/utils/mixin'
  58. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  59. import { forceLogout } from '@/api/login'
  60. import {filterDictTextByCache} from '@/components/dict/JDictSelectUtil'
  61. import {getFileAccessHttpUrl} from '@/api/manage';
  62. import {ACCESS_TOKEN} from '@/store/mutation-types'
  63. export default {
  64. name: "SysUserOnlineList",
  65. mixins:[JeecgListMixin, mixinDevice],
  66. components: {},
  67. data () {
  68. let currentToken = this.$ls.get(ACCESS_TOKEN)
  69. return {
  70. description: '在线用户管理页面',
  71. queryParam: {
  72. username: ''
  73. },
  74. // 表头
  75. columns: [
  76. {
  77. title:'用户账号',
  78. align:"center",
  79. dataIndex: 'username',
  80. customRender: (text,record) => {
  81. if(record.token === currentToken) {
  82. return text + '(我)'
  83. }
  84. return text
  85. },
  86. },{
  87. title:'用户姓名',
  88. align:"center",
  89. dataIndex: 'realname'
  90. },{
  91. title: '头像',
  92. align: "center",
  93. width: 120,
  94. dataIndex: 'avatar',
  95. scopedSlots: {customRender: "avatarslot"}
  96. },{
  97. title:'生日',
  98. align:"center",
  99. dataIndex: 'birthday'
  100. },{
  101. title: '性别',
  102. align: "center",
  103. dataIndex: 'sex',
  104. customRender: (text) => {
  105. //字典值翻译通用方法
  106. return filterDictTextByCache('sex', text);
  107. }
  108. },{
  109. title:'手机号',
  110. align:"center",
  111. dataIndex: 'phone'
  112. },{
  113. title: '操作',
  114. dataIndex: 'action',
  115. scopedSlots: {customRender: 'action'},
  116. align: "center",
  117. width: 170
  118. }
  119. ],
  120. url: {
  121. list: "/sys/online/list"
  122. },
  123. dictOptions:{},
  124. }
  125. },
  126. created() {
  127. },
  128. computed: {
  129. importExcelUrl: function(){
  130. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  131. },
  132. },
  133. methods: {
  134. getAvatarView: function (avatar) {
  135. return getFileAccessHttpUrl(avatar)
  136. },
  137. handleForce(record) {
  138. let that = this;
  139. let forceParam = {
  140. token: record.token
  141. }
  142. return forceLogout(forceParam).then((res) => {
  143. if (res.success) {
  144. that.loadData();
  145. this.$message.success('强制退出用户”'+record.realname+'“成功!');
  146. } else {
  147. that.$message.warning(res.message);
  148. }
  149. })
  150. }
  151. }
  152. }
  153. </script>
  154. <style scoped>
  155. @import '~@assets/less/common.less';
  156. </style>