沙钢智慧能源系统前端代码
houzhongjian
2024-10-09 314507f8ddadd9c66e98d260c3b2a5dad1a04015
提交 | 用户 | 时间
314507 1 <template>
H 2   <ContentWrap>
3     <!-- 搜索工作栏 -->
4     <el-form
5       class="-mb-15px"
6       :model="queryParams"
7       ref="queryFormRef"
8       :inline="true"
9       label-width="68px"
10     >
11       <el-form-item label="操作人" prop="userId">
12         <el-select
13           v-model="queryParams.userId"
14           clearable
15           filterable
16           placeholder="请输入操作人员"
17           class="!w-240px"
18         >
19           <el-option
20             v-for="user in userList"
21             :key="user.id"
22             :label="user.nickname"
23             :value="user.id"
24           />
25         </el-select>
26       </el-form-item>
27       <el-form-item label="操作模块" prop="type">
28         <el-input
29           v-model="queryParams.type"
30           placeholder="请输入操作模块"
31           clearable
32           @keyup.enter="handleQuery"
33           class="!w-240px"
34         />
35       </el-form-item>
36       <el-form-item label="操作名" prop="subType">
37         <el-input
38           v-model="queryParams.subType"
39           placeholder="请输入操作名"
40           clearable
41           @keyup.enter="handleQuery"
42           class="!w-240px"
43         />
44       </el-form-item>
45       <el-form-item label="操作内容" prop="action">
46         <el-input
47           v-model="queryParams.action"
48           placeholder="请输入操作名"
49           clearable
50           @keyup.enter="handleQuery"
51           class="!w-240px"
52         />
53       </el-form-item>
54       <el-form-item label="操作时间" prop="createTime">
55         <el-date-picker
56           v-model="queryParams.createTime"
57           value-format="YYYY-MM-DD HH:mm:ss"
58           type="daterange"
59           start-placeholder="开始日期"
60           end-placeholder="结束日期"
61           :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
62           class="!w-220px"
63         />
64       </el-form-item>
65       <el-form-item label="业务编号" prop="bizId">
66         <el-input
67           v-model="queryParams.bizId"
68           placeholder="请输入业务编号"
69           clearable
70           @keyup.enter="handleQuery"
71           class="!w-240px"
72         />
73       </el-form-item>
74       <el-form-item>
75         <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
76         <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
77         <el-button
78           type="success"
79           plain
80           @click="handleExport"
81           :loading="exportLoading"
82           v-hasPermi="['infra:operate-log:export']"
83         >
84           <Icon icon="ep:download" class="mr-5px" /> 导出
85         </el-button>
86       </el-form-item>
87     </el-form>
88   </ContentWrap>
89
90   <!-- 列表 -->
91   <ContentWrap>
92     <el-table v-loading="loading" :data="list">
93       <el-table-column label="日志编号" align="center" prop="id" width="100" />
94       <el-table-column label="操作人" align="center" prop="userName" width="120" />
95       <el-table-column label="操作模块" align="center" prop="type" width="120" />
96       <el-table-column label="操作名" align="center" prop="subType" width="160" />
97       <el-table-column label="操作内容" align="center" prop="action" />
98       <el-table-column
99         label="操作时间"
100         align="center"
101         prop="createTime"
102         width="180"
103         :formatter="dateFormatter"
104       />
105       <el-table-column label="业务编号" align="center" prop="bizId" width="120" />
106       <el-table-column label="操作 IP" align="center" prop="userIp" width="120" />
107       <el-table-column label="操作" align="center" fixed="right" width="60">
108         <template #default="scope">
109           <el-button
110             link
111             type="primary"
112             @click="openDetail(scope.row)"
113             v-hasPermi="['infra:operate-log:query']"
114           >
115             详情
116           </el-button>
117         </template>
118       </el-table-column>
119     </el-table>
120     <!-- 分页 -->
121     <Pagination
122       :total="total"
123       v-model:page="queryParams.pageNo"
124       v-model:limit="queryParams.pageSize"
125       @pagination="getList"
126     />
127   </ContentWrap>
128
129   <!-- 表单弹窗:详情 -->
130   <OperateLogDetail ref="detailRef" />
131 </template>
132 <script lang="ts" setup>
133 import { dateFormatter } from '@/utils/formatTime'
134 import download from '@/utils/download'
135 import * as OperateLogApi from '@/api/system/operatelog'
136 import OperateLogDetail from './OperateLogDetail.vue'
137 import * as UserApi from '@/api/system/user'
138 const userList = ref<UserApi.UserVO[]>([]) // 用户列表
139
140 defineOptions({ name: 'SystemOperateLog' })
141
142 const message = useMessage() // 消息弹窗
143
144 const loading = ref(true) // 列表的加载中
145 const total = ref(0) // 列表的总页数
146 const list = ref([]) // 列表的数据
147 const queryParams = reactive({
148   pageNo: 1,
149   pageSize: 10,
150   userId: undefined,
151   type: undefined,
152   subType: undefined,
153   action: undefined,
154   createTime: [],
155   bizId: undefined
156 })
157 const queryFormRef = ref() // 搜索的表单
158 const exportLoading = ref(false) // 导出的加载中
159
160 /** 查询列表 */
161 const getList = async () => {
162   loading.value = true
163   try {
164     const data = await OperateLogApi.getOperateLogPage(queryParams)
165     list.value = data.list
166     total.value = data.total
167   } finally {
168     loading.value = false
169   }
170 }
171
172 /** 搜索按钮操作 */
173 const handleQuery = () => {
174   queryParams.pageNo = 1
175   getList()
176 }
177
178 /** 重置按钮操作 */
179 const resetQuery = () => {
180   queryFormRef.value.resetFields()
181   handleQuery()
182 }
183
184 /** 详情操作 */
185 const detailRef = ref()
186 const openDetail = (data: OperateLogApi.OperateLogVO) => {
187   detailRef.value.open(data)
188 }
189
190 /** 导出按钮操作 */
191 const handleExport = async () => {
192   try {
193     // 导出的二次确认
194     await message.exportConfirm()
195     // 发起导出
196     exportLoading.value = true
197     const data = await OperateLogApi.exportOperateLog(queryParams)
198     download.excel(data, '操作日志.xls')
199   } catch {
200   } finally {
201     exportLoading.value = false
202   }
203 }
204
205 /** 初始化 **/
206 onMounted(async () => {
207   await getList()
208   // 获得用户列表
209   userList.value = await UserApi.getSimpleUserList()
210 })
211 </script>