OperateJournal.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 { commonMixin } from '@/utils/mixin'
  50. import getDate from '@/libs/getDate'
  51. import { STable } from '@/components'
  52. import { journalList } from '@/api/OperateJournal.js'
  53. import rangeDate from '@/views/common/rangeDate.vue'
  54. export default {
  55. name: 'PowerOperateJournal',
  56. mixins: [commonMixin],
  57. components: { STable, rangeDate },
  58. data () {
  59. return {
  60. advanced: false, // 高级搜索 展开/关闭
  61. disabled: false, // 查询、重置按钮是否可操作
  62. tableHeight: 0,
  63. time: [
  64. getDate.getThreeday().starttime,
  65. getDate.getThreeday().endtime
  66. ],
  67. queryParam: {
  68. beginDate: getDate.getThreeday().starttime, // 查询的开始时间
  69. endDate: getDate.getThreeday().endtime, // 查询的结束时间
  70. actDesc: '',
  71. actorName: ''
  72. },
  73. dateFormat: 'YYYY-MM-DD',
  74. columns: [
  75. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  76. { title: '操作时间', dataIndex: 'actDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  77. { title: 'IP', dataIndex: 'ip', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  78. { title: '操作人', dataIndex: 'actorName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  79. { title: '操作信息', dataIndex: 'actDesc', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
  80. ],
  81. // 加载数据方法 必须为 Promise 对象
  82. loadData: parameter => {
  83. this.disabled = true
  84. this.queryParam.beginDate = this.queryParam.beginDate + ' 00:00:00'
  85. this.queryParam.endDate = this.queryParam.endDate + ' 23:59:59'
  86. return journalList(Object.assign(parameter, this.queryParam)).then(res => {
  87. let data
  88. if (res.status == 200) {
  89. data = res.data
  90. const no = (data.pageNo - 1) * data.pageSize
  91. for (var i = 0; i < data.list.length; i++) {
  92. data.list[i].no = no + i + 1
  93. }
  94. this.disabled = false
  95. }
  96. return data
  97. })
  98. }
  99. }
  100. },
  101. methods: {
  102. // 时间 change
  103. dateChange (date) {
  104. this.queryParam.beginDate = date[0]
  105. this.queryParam.endDate = date[1]
  106. },
  107. // 重置
  108. resetSearchForm () {
  109. this.$refs.rangeDate.resetDate(this.time)
  110. this.queryParam.beginDate = getDate.getThreeday().starttime
  111. this.queryParam.endDate = getDate.getThreeday().endtime
  112. this.queryParam.actDesc = ''
  113. this.queryParam.actorName = ''
  114. this.$refs.table.refresh(true)
  115. },
  116. pageInit () {
  117. const _this = this
  118. this.$nextTick(() => { // 页面渲染完成后的回调
  119. _this.setTableH()
  120. })
  121. },
  122. setTableH () {
  123. const tableSearchH = this.$refs.tableSearch.offsetHeight
  124. this.tableHeight = window.innerHeight - tableSearchH - 195
  125. }
  126. },
  127. watch: {
  128. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  129. this.setTableH()
  130. }
  131. },
  132. mounted () {
  133. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  134. this.pageInit()
  135. this.resetSearchForm()
  136. }
  137. },
  138. activated () {
  139. // 如果是新页签打开,则重置当前页面
  140. if (this.$store.state.app.isNewTab) {
  141. this.pageInit()
  142. this.resetSearchForm()
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="less">
  148. .operateJournal{
  149. .sTable{
  150. margin-top: 0;
  151. }
  152. }
  153. </style>