OperateJournal.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <a-card size="small" :bordered="false">
  3. <div class="operateJournal">
  4. <!-- 搜索框 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="操作时间">
  10. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="操作信息">
  15. <a-input allowClear v-model.trim="queryParam.actDesc" placeholder="请输入操作信息" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="操作人">
  20. <a-input allowClear v-model.trim="queryParam.actorName" placeholder="请输入操作人" />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="operateJournal-refresh">查询</a-button>
  25. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="operateJournal-reset">重置</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 列表 -->
  31. <s-table
  32. class="sTable fixPagination"
  33. ref="table"
  34. :style="{ height: tableHeight+84.5+'px' }"
  35. size="small"
  36. rowKey="id"
  37. :columns="columns"
  38. :data="loadData"
  39. :scroll="{ y: tableHeight }"
  40. :defaultLoadData="false"
  41. bordered>
  42. <span slot="actDesc" slot-scope="text, record">{{ record.actDate }}-{{ record.actDesc }}</span>
  43. <span slot="actorName" slot-scope="text, record">{{ record.actorName }}-{{ record.actorPhone }}</span>
  44. </s-table>
  45. </div>
  46. </a-card>
  47. </template>
  48. <script>
  49. import getDate from '@/libs/getDate'
  50. import { STable } from '@/components'
  51. import { journalList } from '@/api/OperateJournal.js'
  52. import rangeDate from '@/views/common/rangeDate.vue'
  53. export default {
  54. name: 'OperateJournal',
  55. components: { STable, rangeDate },
  56. data () {
  57. return {
  58. advanced: false, // 高级搜索 展开/关闭
  59. disabled: false, // 查询、重置按钮是否可操作
  60. tableHeight: 0,
  61. time: [
  62. getDate.getThreeday().starttime,
  63. getDate.getThreeday().endtime
  64. ],
  65. queryParam: {
  66. beginDate: getDate.getThreeday().starttime, // 查询的开始时间
  67. endDate: getDate.getThreeday().endtime, // 查询的结束时间
  68. actDesc: '',
  69. actorName: ''
  70. },
  71. dateFormat: 'YYYY-MM-DD',
  72. columns: [
  73. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  74. { title: '操作时间', dataIndex: 'actDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  75. { title: 'IP', dataIndex: 'ip', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  76. { title: '操作人', dataIndex: 'actorName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  77. { title: '操作信息', dataIndex: 'actDesc', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
  78. ],
  79. // 加载数据方法 必须为 Promise 对象
  80. loadData: parameter => {
  81. this.disabled = true
  82. this.queryParam.beginDate = this.queryParam.beginDate + ' 00:00:00'
  83. this.queryParam.endDate = this.queryParam.endDate + ' 23:59:59'
  84. return journalList(Object.assign(parameter, this.queryParam)).then(res => {
  85. let data
  86. if (res.status == 200) {
  87. data = res.data
  88. const no = (data.pageNo - 1) * data.pageSize
  89. for (var i = 0; i < data.list.length; i++) {
  90. data.list[i].no = no + i + 1
  91. }
  92. this.disabled = false
  93. }
  94. return data
  95. })
  96. }
  97. }
  98. },
  99. methods: {
  100. // 时间 change
  101. dateChange (date) {
  102. this.queryParam.beginDate = date[0]
  103. this.queryParam.endDate = date[1]
  104. },
  105. // 重置
  106. resetSearchForm () {
  107. this.$refs.rangeDate.resetDate(this.time)
  108. this.queryParam.beginDate = getDate.getThreeday().starttime
  109. this.queryParam.endDate = getDate.getThreeday().endtime
  110. this.queryParam.actDesc = ''
  111. this.queryParam.actorName = ''
  112. this.$refs.table.refresh(true)
  113. },
  114. pageInit () {
  115. const _this = this
  116. this.$nextTick(() => { // 页面渲染完成后的回调
  117. _this.setTableH()
  118. })
  119. },
  120. setTableH () {
  121. const tableSearchH = this.$refs.tableSearch.offsetHeight
  122. this.tableHeight = window.innerHeight - tableSearchH - 195
  123. }
  124. },
  125. watch: {
  126. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  127. this.setTableH()
  128. }
  129. },
  130. mounted () {
  131. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  132. this.pageInit()
  133. this.resetSearchForm()
  134. }
  135. },
  136. activated () {
  137. // 如果是新页签打开,则重置当前页面
  138. if (this.$store.state.app.isNewTab) {
  139. this.pageInit()
  140. this.resetSearchForm()
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="less">
  146. .operateJournal{
  147. .sTable{
  148. margin-top: 0;
  149. }
  150. }
  151. </style>