Browse Source

对接操作日志

chenrui 4 years ago
parent
commit
0a2f45180c
2 changed files with 73 additions and 55 deletions
  1. 20 0
      src/libs/getDate.js
  2. 53 55
      src/views/power/OperateJournal/OperateJournal.vue

+ 20 - 0
src/libs/getDate.js

@@ -36,6 +36,26 @@ export default {
     obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
     return obj
   },
+  //  近7天  年月日时分秒
+  getRecentTime () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 6).format('YYYY-MM-DD HH:mm:ss')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    return obj
+  },
+  //  近3天
+  getThreeday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 2).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
   // 获取昨日的开始结束时间
   getYesterday () {
     const obj = {

+ 53 - 55
src/views/power/OperateJournal/OperateJournal.vue

@@ -7,21 +7,29 @@
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
               <a-form-item label="操作时间">
-                <rangeDateTime ref="rangeDate" :value="time" @change="dateChange" />
+                <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-form-item label="操作人"><a-input allowClear v-model.trim="searchData.queryWord" placeholder="请输入" /></a-form-item>
+              <a-form-item label="操作信息">
+                <a-input allowClear v-model.trim="queryParam.actDesc" placeholder="请输入操作信息" />
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-item label="操作人">
+                <a-input allowClear v-model.trim="queryParam.actorName" placeholder="请输入操作人" />
+              </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-button style="margin-right: 10px;" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
-              <a-button type="" @click="resetForm">重置</a-button>
+              <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="operateJournal-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="operateJournal-reset">重置</a-button>
             </a-col>
           </a-row>
         </a-form>
       </div>
       <!-- 列表 -->
       <s-table
+        class="sTable"
         ref="table"
         size="default"
         rowKey="id"
@@ -40,63 +48,45 @@ import moment from 'moment'
 import getDate from '@/libs/getDate'
 import { STable } from '@/components'
 import { journalList } from '@/api/OperateJournal.js'
-import rangeDateTime from '@/views/common/rangeDateTime.vue'
+import rangeDate from '@/views/common/rangeDate.vue'
 export default {
   name: 'OperateJournal',
-  components: { STable, rangeDateTime },
+  components: { STable, rangeDate },
   data () {
     return {
-      // 列表
-      form: this.$form.createForm(this, {
-        name: 'OperateJournal'
-      }),
+      advanced: false, // 高级搜索 展开/关闭
+      disabled: false, //  查询、重置按钮是否可操作
       time: [
-        moment(getDate.getTodayTime().starttime, this.dateFormat),
-        moment(getDate.getTodayTime().endtime, this.dateFormat)
+        moment(getDate.getThreeday().starttime, this.dateFormat),
+        moment(getDate.getThreeday().endtime, this.dateFormat)
       ],
-      searchData: {
-        beginDate: getDate.getTodayTime().starttime, // 查询的开始时间
-        endDate: getDate.getTodayTime().endtime, // 查询的结束时间
-        queryWord: '' // 操作人
+      queryParam: {
+        beginDate: getDate.getThreeday().starttime, // 查询的开始时间
+        endDate: getDate.getThreeday().endtime, // 查询的结束时间
+        actDesc: '',
+        actorName: ''
       },
-      dateFormat: 'YYYY-MM-DD HH:mm:ss',
+      dateFormat: 'YYYY-MM-DD',
       columns: [
-        {
-          title: '序号',
-          dataIndex: 'no',
-          minWidth: '40',
-          align: 'center'
-        },
-        {
-          title: '操作人',
-          dataIndex: 'actorName',
-          minWidth: '100',
-          align: 'center',
-          scopedSlots: { customRender: 'actorName' }
-        },
-        {
-          title: 'IP',
-          dataIndex: 'ip',
-          minWidth: '100',
-          align: 'center'
-        },
-        {
-          title: '日志明细',
-          dataIndex: 'actDesc',
-          minWidth: '100',
-          align: 'center',
-          scopedSlots: { customRender: 'actDesc' }
-        }
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
+        { title: '操作时间', dataIndex: 'actDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: 'IP', dataIndex: 'ip', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作人', dataIndex: 'actorName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '操作信息', dataIndex: 'actDesc', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        return journalList(Object.assign(parameter, this.searchData)).then(res => {
-          const no = (res.data.data.pageNo - 1) * res.data.data.pageSize
-          for (let i = 0; i < res.data.data.list.length; i++) {
-            const _item = res.data.data.list[i]
-            _item.no = no + i + 1
+        this.disabled = true
+        this.queryParam.beginDate = this.queryParam.beginDate + ' 00:00:00'
+        this.queryParam.endDate = this.queryParam.endDate + ' 23:59:59'
+        return journalList(Object.assign(parameter, this.queryParam)).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
           }
-          return res.data.data
+          this.disabled = false
+          return data
         })
       }
     }
@@ -104,17 +94,25 @@ export default {
   methods: {
     //  时间  change
     dateChange (date) {
-      this.searchData.beginDate = date[0]
-      this.searchData.endDate = date[1]
+      this.queryParam.beginDate = date[0]
+      this.queryParam.endDate = date[1]
     },
     // 重置
-    resetForm () {
+    resetSearchForm () {
       this.$refs.rangeDate.resetDate(this.time)
-      this.searchData.beginDate = getDate.getTodayTime().starttime
-      this.searchData.endDate = getDate.getTodayTime().endtime
-      this.searchData.queryWord = ''
+      this.queryParam.beginDate = getDate.getThreeday().starttime
+      this.queryParam.endDate = getDate.getThreeday().endtime
+      this.queryParam.actDesc = ''
+      this.queryParam.actorName = ''
       this.$refs.table.refresh(true)
     }
   }
 }
 </script>
+<style lang="less">
+  .operateJournal{
+    .sTable{
+      margin-top: 10px;
+    }
+  }
+</style>