wangting
2024-10-22 0f0d9178eb886612e2310514383d2b057779042b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<template>
  <basic-container>
    <avue-crud
      ref="userCrud"
      :before-open="beforeOpen"
      :data="tableData"
      :option="option"
      :page.sync="page"
      :table-loading="tableLoading"
      @on-load="getTableList"
      @refresh-change="handleRefresh"
      @search-change="handleSearch"
      @search-reset="handleReset"
      @size-change="sizeChange"
      @current-change="currentChange"
      @selection-change="selectChange"
      @row-click="rowClickHandler"
      @row-save="rowSaveHandler"
      @row-update="rowUpdateHandler"
    >
      <!-- 部门头部搜索插槽  -->
      <template slot-scope="{disabled,size}" slot="pkDepartmentNameSearch">
        <div style="display: flex;gap: 5px">
          <el-select v-model="departSearchValue" clearable placeholder="请选择部门">
            <el-option :label="departSearchObj.name" :value="departSearchObj.oid"></el-option>
          </el-select>
          <el-button size="small" type="success" @click="dialogDepartSearchHandler">选择部门</el-button>
        </div>
      </template>
 
      <template #menu="{row,index,size}">
        <el-button icon="el-icon-edit" size="small" type="text" @click.stop="rowEditHandler(row,index)">导出</el-button>
      </template>
 
      <template slot="menuLeft" slot-scope="scope">
        <el-button icon="el-icon-delete" plain size="small" type="danger" @click="allDelHandler">导出</el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
 
<script>
import basicOption from "@/util/basic-option";
import {getLogListByContion} from "@/api/log/logBasic";
import func from "@/util/func";
 
export default {
name: "index",
  data: function () {
    return {
      tableLoading: false,
      tableData: [],
      option: {
        ...basicOption,
        editBtn: false,
        delBtn: false,
        calcHeight: -60,
        column: [
          {
            label: '用户名',
            prop: 'truename',
            search:true,
            sortable:true,
          }, {
            label: '姓名',
            prop: 'username',
            search:true,
            sortable:true,
          },{
            label: '用户IP',
            prop: 'userIp',
            search:true,
            sortable:true,
          },{
            label: '模块',
            prop: 'moduleName',
            search:true,
            sortable:true,
          },{
            label: '操作',
            prop: 'type',
            search:true,
            sortable:true,
          },{
            label: '时间',
            prop: 'startDate',
            search:true,
            sortable:true,
          },{
            label: '操作结果',
            prop: 'result',
            search:true,
            sortable:true,
          },{
            label: '描述',
            prop: 'startDate',
            search:true,
            sortable:true,
          },
        ]
      },
      page: {
        currentPage: 1,
        pageSize: 50,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      searchParams: {}
    }
  },
  methods: {
    // 表格请求
    getTableList() {
      this.tableLoading = true;
      getLogListByContion(this.page.currentPage, this.page.pageSize, this.searchParams).then(res => {
        const data = res.data.data;
        this.tableData = data;
        this.page.total = res.data.total;
        this.tableLoading = false;
      })
    },
 
    // 搜索查询
    handleSearch(params, done) {
      this.searchParams = {};
      if(this.departSearchObj && this.departSearchValue){
        this.searchParams['conditionMap["pkDepartment"]'] = this.departSearchValue;
      }
 
      if (!func.isEmptyObject(params)) {
        for (let key in params) {
          if (params.hasOwnProperty(key)) {
            // 判断如果 key 是 'pkPersonName',则改为 'pkPerson' 分别为显示值和保存值
            let newKey = key === 'pkPersonName' ? 'pkPerson' : key;
            this.searchParams[`conditionMap["${newKey}"]`] = params[key];
          }
        }
      }
 
      if (func.isEmptyObject(params) && !this.departSearchValue) {
        this.searchParams = {};
      }
 
      this.getTableList();
      done();
    },
 
    // 重置搜索条件
    handleReset() {
      this.departSearchObj = {};
      this.departSearchValue = "";
      this.searchParams = {};
      this.getTableList();
    },
 
    // 条数
    sizeChange(val) {
      this.page.pageSize = val;
    },
 
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
    },
  }
}
</script>
 
<style scoped>
 
</style>