index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" v-if="hasPerm('sysVisLog:page')">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="日志名称">
  8. <a-input v-model="queryParam.name" allow-clear placeholder="请输入日志名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="访问类型">
  13. <a-select v-model="queryParam.visType" allow-clear placeholder="请选择访问类型" >
  14. <a-select-option v-for="(item,index) in visTypeDict" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
  15. </a-select>
  16. </a-form-item>
  17. </a-col>
  18. <template v-if="advanced">
  19. <a-col :md="8" :sm="24">
  20. <a-form-item label="是否成功">
  21. <a-select v-model="queryParam.success" placeholder="请选择是否成功" >
  22. <a-select-option v-for="(item,index) in successDict" :key="index" :value="item.code" >{{ item.value }}</a-select-option>
  23. </a-select>
  24. </a-form-item>
  25. </a-col>
  26. </template>
  27. <a-col :md="!advanced && 8 || 24" :sm="24">
  28. <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
  29. <a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button>
  30. <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
  31. <a @click="toggleAdvanced" style="margin-left: 8px">
  32. {{ advanced ? '收起' : '展开' }}
  33. <a-icon :type="advanced ? 'up' : 'down'"/>
  34. </a>
  35. </span>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. </div>
  40. <div class="table-operator" v-if="hasPerm('sysVisLog:delete')">
  41. <a-popconfirm v-if="hasPerm('sysVisLog:delete')" placement="top" title="确认清空日志?" @confirm="() => sysVisLogDelete()">
  42. <a-button >清空日志</a-button>
  43. </a-popconfirm>
  44. </div>
  45. <s-table
  46. ref="table"
  47. size="default"
  48. :columns="columns"
  49. :data="loadData"
  50. :alert="true"
  51. :rowKey="(record) => record.id"
  52. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  53. >
  54. <span slot="name" slot-scope="text">
  55. <ellipsis :length="10" tooltip>{{ text }}</ellipsis>
  56. </span>
  57. <span slot="visTime" slot-scope="text">
  58. <ellipsis :length="10" tooltip>{{ text }}</ellipsis>
  59. </span>
  60. <span slot="visType" slot-scope="text">
  61. {{ visTypeFilter(text) }}
  62. </span>
  63. <span slot="success" slot-scope="text">
  64. {{ successFilter(text) }}
  65. </span>
  66. <span slot="action" slot-scope="text, record">
  67. <span slot="action" >
  68. <a @click="$refs.detailsVislog.details(record)">查看详情</a>
  69. </span>
  70. </span>
  71. </s-table>
  72. <details-vislog ref="detailsVislog"/>
  73. </a-card>
  74. </template>
  75. <script>
  76. import { STable, Ellipsis } from '@/components'
  77. import { sysVisLogPage, sysVisLogDelete } from '@/api/modular/system/logManage'
  78. import detailsVislog from './details'
  79. import { sysDictTypeDropDown } from '@/api/modular/system/dictManage'
  80. export default {
  81. components: {
  82. STable,
  83. Ellipsis,
  84. detailsVislog
  85. },
  86. data () {
  87. return {
  88. advanced: false,
  89. // 查询参数
  90. queryParam: {},
  91. // 表头
  92. columns: [
  93. {
  94. title: '日志名称',
  95. dataIndex: 'name',
  96. scopedSlots: { customRender: 'name' }
  97. },
  98. {
  99. title: '访问类型',
  100. dataIndex: 'visType',
  101. scopedSlots: { customRender: 'visType' }
  102. },
  103. {
  104. title: '是否成功',
  105. dataIndex: 'success',
  106. scopedSlots: { customRender: 'success' }
  107. },
  108. {
  109. title: 'ip',
  110. dataIndex: 'ip'
  111. },
  112. {
  113. title: '浏览器',
  114. dataIndex: 'browser'
  115. },
  116. {
  117. title: '访问时间',
  118. dataIndex: 'visTime',
  119. scopedSlots: { customRender: 'visTime' }
  120. },
  121. {
  122. title: '访问人',
  123. dataIndex: 'account'
  124. },
  125. {
  126. title: '详情',
  127. dataIndex: 'action',
  128. width: '150px',
  129. scopedSlots: { customRender: 'action' }
  130. }
  131. ],
  132. // 加载数据方法 必须为 Promise 对象
  133. loadData: parameter => {
  134. return sysVisLogPage(Object.assign(parameter, this.queryParam)).then((res) => {
  135. return res.data
  136. })
  137. },
  138. selectedRowKeys: [],
  139. selectedRows: [],
  140. defaultExpandedKeys: [],
  141. visTypeDict: [],
  142. successDict: []
  143. }
  144. },
  145. /**
  146. * 相当于html的onload方法,进来初始化
  147. */
  148. created () {
  149. this.sysDictTypeDropDown()
  150. },
  151. methods: {
  152. visTypeFilter (visType) {
  153. // eslint-disable-next-line eqeqeq
  154. const values = this.visTypeDict.filter(item => item.code == visType)
  155. if (values.length > 0) {
  156. return values[0].value
  157. }
  158. },
  159. successFilter (success) {
  160. // eslint-disable-next-line eqeqeq
  161. const values = this.successDict.filter(item => item.code == success)
  162. if (values.length > 0) {
  163. return values[0].value
  164. }
  165. },
  166. /**
  167. * 获取字典数据
  168. */
  169. sysDictTypeDropDown () {
  170. sysDictTypeDropDown({ code: 'vis_type' }).then((res) => {
  171. this.visTypeDict = res.data
  172. })
  173. sysDictTypeDropDown({ code: 'yes_or_no' }).then((res) => {
  174. this.successDict = res.data
  175. })
  176. },
  177. /**
  178. * 清空日志
  179. */
  180. sysVisLogDelete () {
  181. sysVisLogDelete().then((res) => {
  182. if (res.success) {
  183. this.$message.success('清空成功')
  184. this.$refs.table.refresh(true)
  185. } else {
  186. this.$message.error('清空失败:' + res.message)
  187. }
  188. })
  189. },
  190. toggleAdvanced () {
  191. this.advanced = !this.advanced
  192. },
  193. onSelectChange (selectedRowKeys, selectedRows) {
  194. this.selectedRowKeys = selectedRowKeys
  195. this.selectedRows = selectedRows
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="less">
  201. .table-operator {
  202. margin-bottom: 18px;
  203. }
  204. button {
  205. margin-right: 8px;
  206. }
  207. </style>