SysRequestLog.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  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.keyword" placeholder="请输入名称/类型名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8 || 24" :sm="24">
  12. <span class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="table-operator">
  21. <a-button v-if="$auth('upms-request-logs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="$auth('upms-request-logs-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('upms-request-logs-del')">
  24. <a-menu slot="overlay">
  25. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  26. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  27. </a-popconfirm>
  28. </a-menu>
  29. <a-button style="margin-left: 8px">
  30. 批量操作 <a-icon type="down" />
  31. </a-button>
  32. </a-dropdown>
  33. </div>
  34. <s-table
  35. ref="table"
  36. size="default"
  37. rowKey="id"
  38. :bordered="this.MyGlobalConstant.BORDERED"
  39. :columns="columns"
  40. :data="loadData"
  41. :alert="options.alert"
  42. :rowSelection="options.rowSelection"
  43. showPagination="auto"
  44. >
  45. <span slot="action" slot-scope="record">
  46. <template>
  47. <a @click="handleView(record)">查看</a>
  48. <operation-button
  49. v-if="$auth('upms-request-logs-edit')"
  50. @click="handleEdit(record)"
  51. >修改</operation-button>
  52. <operation-button
  53. v-if="$auth('upms-request-logs-del')"
  54. :type="2"
  55. title="是否要删除该条数据?"
  56. @confirm="batchDelete(record.id)">删除</operation-button>
  57. </template>
  58. </span>
  59. </s-table>
  60. <base-form ref="baseModal" @ok="handleOk"/>
  61. <detail ref="detailModal"/>
  62. </a-card>
  63. </template>
  64. <script>
  65. import { STable, Ellipsis } from '@/components'
  66. import BaseForm from './modules/BaseForm'
  67. import Detail from './modules/Detail'
  68. import { getSysRequestLogPage, deleteSysRequestLogs, fetchSysRequestLog, exportSysRequestLog } from '@/api/upms/request-log'
  69. export default {
  70. name: 'SysRequestLogList',
  71. components: {
  72. STable,
  73. Ellipsis,
  74. BaseForm,
  75. Detail
  76. },
  77. data () {
  78. return {
  79. // 查询参数
  80. queryParam: {
  81. },
  82. // 表头
  83. columns: [
  84. {
  85. title: '序号',
  86. dataIndex: 'index',
  87. customRender: (text, record, index) => {
  88. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  89. }
  90. },
  91. {
  92. title: '请求类型',
  93. dataIndex: 'type'
  94. },
  95. {
  96. title: '请求参数名',
  97. dataIndex: 'name'
  98. },
  99. {
  100. title: '请求地址',
  101. dataIndex: 'url'
  102. },
  103. {
  104. title: '请求方法',
  105. dataIndex: 'method'
  106. },
  107. {
  108. title: '响应code',
  109. dataIndex: 'code'
  110. },
  111. {
  112. title: '响应消息',
  113. dataIndex: 'message'
  114. },
  115. {
  116. title: '请求唯一标识',
  117. dataIndex: 'requestId'
  118. },
  119. {
  120. title: '请求参数json',
  121. dataIndex: 'params'
  122. },
  123. {
  124. title: '请求结果json',
  125. dataIndex: 'result'
  126. },
  127. {
  128. title: '备注',
  129. dataIndex: 'remark'
  130. },
  131. {
  132. title: '创建人名称',
  133. dataIndex: 'createdUserName'
  134. },
  135. {
  136. title: '创建日期',
  137. dataIndex: 'createdTime'
  138. },
  139. {
  140. title: '操作',
  141. key: 'action',
  142. width: '200px',
  143. align: 'center',
  144. scopedSlots: { customRender: 'action' }
  145. }
  146. ],
  147. // 下拉框map
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: parameter => {
  150. parameter = {
  151. ...parameter,
  152. ...this.queryParam
  153. }
  154. return getSysRequestLogPage(parameter)
  155. .then(res => {
  156. return res.data
  157. })
  158. },
  159. selectedRowKeys: [],
  160. selectedRows: [],
  161. options: {
  162. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  163. rowSelection: {
  164. selectedRowKeys: this.selectedRowKeys,
  165. onChange: this.onSelectChange
  166. }
  167. },
  168. optionAlertShow: false
  169. }
  170. },
  171. created () {
  172. // 下拉框map
  173. this.tableOption()
  174. },
  175. methods: {
  176. tableOption () {
  177. if (!this.optionAlertShow) {
  178. this.options = {
  179. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  180. rowSelection: {
  181. selectedRowKeys: this.selectedRowKeys,
  182. onChange: this.onSelectChange,
  183. getCheckboxProps: record => ({
  184. props: {
  185. disabled: false,
  186. name: record.id
  187. }
  188. })
  189. }
  190. }
  191. this.optionAlertShow = true
  192. } else {
  193. this.options = {
  194. alert: false,
  195. rowSelection: null
  196. }
  197. this.optionAlertShow = false
  198. }
  199. },
  200. batchDelete (id) {
  201. let ids = []
  202. if (this.BaseTool.String.isBlank(id)) {
  203. const length = this.selectedRows.length
  204. if (length === 0) {
  205. this.$message.info('请选择要删除的记录')
  206. return
  207. }
  208. ids = this.selectedRows.map(item => item.id)
  209. } else {
  210. ids = [id]
  211. }
  212. deleteSysRequestLogs(ids).then(res => {
  213. this.$message.info('删除成功')
  214. this.handleOk()
  215. this.$refs.table.clearSelected()
  216. })
  217. },
  218. handleEdit (record) {
  219. fetchSysRequestLog({ id: record.id }).then(res => {
  220. const modal = this.$refs.baseModal
  221. modal.base(res.data)
  222. })
  223. },
  224. handleView (record) {
  225. fetchSysRequestLog({ id: record.id }).then(res => {
  226. const modal = this.$refs.detailModal
  227. modal.base(res.data)
  228. })
  229. },
  230. handleOk () {
  231. this.$refs.table.refresh()
  232. },
  233. onSelectChange (selectedRowKeys, selectedRows) {
  234. this.selectedRowKeys = selectedRowKeys
  235. this.selectedRows = selectedRows
  236. },
  237. resetSearchForm () {
  238. this.queryParam = {
  239. }
  240. this.$refs.table.refresh(true)
  241. },
  242. doExport () {
  243. const parameter = {
  244. ...this.queryParam
  245. }
  246. exportSysRequestLog(parameter).then(file => {
  247. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  248. })
  249. },
  250. handleEnter () {
  251. this.$refs.table.refresh(true)
  252. }
  253. }
  254. }
  255. </script>