OperateJournal.vue 5.4 KB

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