index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="公司名" prop="companyId">
  5. <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名" @change="companyChange" clearable size="small">
  6. <el-option
  7. v-for="item in companys"
  8. :key="item.companyId"
  9. :label="item.companyName"
  10. :value="item.companyId"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <!-- <el-form-item>
  15. <treeselect style="width: 220px" :clearable="false" v-model="queryParams.deptId" :options="deptOptions" clearable :show-count="true" placeholder="请选择归属部门" />
  16. </el-form-item> -->
  17. <el-form-item label="系统模块" prop="title">
  18. <el-input
  19. v-model="queryParams.title"
  20. placeholder="请输入系统模块"
  21. clearable
  22. style="width: 240px;"
  23. size="small"
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="操作人员" prop="operName">
  28. <el-input
  29. v-model="queryParams.operName"
  30. placeholder="请输入操作人员"
  31. clearable
  32. style="width: 240px;"
  33. size="small"
  34. @keyup.enter.native="handleQuery"
  35. />
  36. </el-form-item>
  37. <el-form-item label="类型" prop="businessType">
  38. <el-select
  39. v-model="queryParams.businessType"
  40. placeholder="操作类型"
  41. clearable
  42. size="small"
  43. style="width: 240px"
  44. >
  45. <el-option
  46. v-for="dict in typeOptions"
  47. :key="dict.dictValue"
  48. :label="dict.dictLabel"
  49. :value="dict.dictValue"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="状态" prop="status">
  54. <el-select
  55. v-model="queryParams.status"
  56. placeholder="操作状态"
  57. clearable
  58. size="small"
  59. style="width: 240px"
  60. >
  61. <el-option
  62. v-for="dict in statusOptions"
  63. :key="dict.dictValue"
  64. :label="dict.dictLabel"
  65. :value="dict.dictValue"
  66. />
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item label="操作时间">
  70. <el-date-picker
  71. v-model="dateRange"
  72. size="small"
  73. style="width: 240px"
  74. value-format="yyyy-MM-dd"
  75. type="daterange"
  76. range-separator="-"
  77. start-placeholder="开始日期"
  78. end-placeholder="结束日期"
  79. ></el-date-picker>
  80. </el-form-item>
  81. <el-form-item>
  82. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  83. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  84. </el-form-item>
  85. </el-form>
  86. <el-row :gutter="10" class="mb8">
  87. <el-col :span="1.5">
  88. <el-button
  89. type="danger"
  90. plain
  91. icon="el-icon-delete"
  92. size="mini"
  93. :disabled="multiple"
  94. @click="handleDelete"
  95. v-hasPermi="['platform:companyOperLog:remove']"
  96. >删除</el-button>
  97. </el-col>
  98. <!-- <el-col :span="1.5">
  99. <el-button
  100. type="danger"
  101. plain
  102. icon="el-icon-delete"
  103. size="mini"
  104. @click="handleClean"
  105. v-hasPermi="['monitor:operlog:remove']"
  106. >清空</el-button>
  107. </el-col> -->
  108. <el-col :span="1.5">
  109. <el-button
  110. type="warning"
  111. plain
  112. icon="el-icon-download"
  113. size="mini"
  114. :loading="exportLoading"
  115. @click="handleExport"
  116. v-hasPermi="['platform:companyOperLog:export']"
  117. >导出</el-button>
  118. </el-col>
  119. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  120. </el-row>
  121. <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
  122. <el-table-column type="selection" width="55" align="center" />
  123. <el-table-column label="日志编号" align="center" prop="operId" />
  124. <el-table-column label="公司名称" align="center" prop="companyName" />
  125. <el-table-column label="系统模块" align="center" prop="title" />
  126. <el-table-column label="操作类型" align="center" prop="businessType">
  127. <template slot-scope="scope">
  128. <dict-tag :options="typeOptions" :value="scope.row.businessType"/>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="请求方式" align="center" prop="requestMethod" />
  132. <el-table-column label="操作人员" align="center" prop="operName" width="100" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
  133. <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
  134. <el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" />
  135. <el-table-column label="操作状态" align="center" prop="status">
  136. <template slot-scope="scope">
  137. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="操作日期" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
  141. <template slot-scope="scope">
  142. <span>{{ parseTime(scope.row.operTime) }}</span>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  146. <template slot-scope="scope">
  147. <el-button
  148. size="mini"
  149. type="text"
  150. icon="el-icon-view"
  151. @click="handleView(scope.row,scope.index)"
  152. v-hasPermi="['platform:companyOperLog:query']"
  153. >详细</el-button>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. <pagination
  158. v-show="total>0"
  159. :total="total"
  160. :page.sync="queryParams.pageNum"
  161. :limit.sync="queryParams.pageSize"
  162. @pagination="getList"
  163. />
  164. <!-- 操作日志详细 -->
  165. <el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body>
  166. <el-form ref="form" :model="form" label-width="100px" size="mini">
  167. <el-row>
  168. <el-col :span="12">
  169. <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item>
  170. <el-form-item
  171. label="登录信息:"
  172. >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item>
  173. </el-col>
  174. <el-col :span="12">
  175. <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item>
  176. <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item>
  177. </el-col>
  178. <el-col :span="24">
  179. <el-form-item label="操作方法:">{{ form.method }}</el-form-item>
  180. </el-col>
  181. <el-col :span="24">
  182. <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item>
  183. </el-col>
  184. <el-col :span="24">
  185. <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item>
  186. </el-col>
  187. <el-col :span="12">
  188. <el-form-item label="操作状态:">
  189. <div v-if="form.status === 0">正常</div>
  190. <div v-else-if="form.status === 1">失败</div>
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="12">
  194. <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item>
  195. </el-col>
  196. <el-col :span="24">
  197. <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item>
  198. </el-col>
  199. </el-row>
  200. </el-form>
  201. <div slot="footer" class="dialog-footer">
  202. <el-button @click="open = false">关 闭</el-button>
  203. </div>
  204. </el-dialog>
  205. </div>
  206. </template>
  207. <script>
  208. import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/company/companyOperLog";
  209. import { listAllCompanies } from "@/api/admin/sysCompany";
  210. export default {
  211. name: "Operlog",
  212. watch: {
  213. // 监听deptId
  214. 'deptId': 'currDeptChange'
  215. },
  216. data() {
  217. return {
  218. companys:[],
  219. deptOptions:[],
  220. companyId:undefined,
  221. deptId:undefined,
  222. // 遮罩层
  223. loading: true,
  224. // 导出遮罩层
  225. exportLoading: false,
  226. // 选中数组
  227. ids: [],
  228. // 非多个禁用
  229. multiple: true,
  230. // 显示搜索条件
  231. showSearch: true,
  232. // 总条数
  233. total: 0,
  234. // 表格数据
  235. list: [],
  236. // 是否显示弹出层
  237. open: false,
  238. // 类型数据字典
  239. typeOptions: [],
  240. // 类型数据字典
  241. statusOptions: [],
  242. // 日期范围
  243. dateRange: [],
  244. // 默认排序
  245. defaultSort: {prop: 'operTime', order: 'descending'},
  246. // 表单参数
  247. form: {},
  248. // 查询参数
  249. queryParams: {
  250. pageNum: 1,
  251. pageSize: 10,
  252. title: undefined,
  253. operName: undefined,
  254. businessType: undefined,
  255. status: undefined
  256. }
  257. };
  258. },
  259. created() {
  260. this.getList();
  261. this.getDicts("sys_oper_type").then(response => {
  262. this.typeOptions = response.data;
  263. });
  264. this.getDicts("sys_common_status").then(response => {
  265. this.statusOptions = response.data;
  266. });
  267. listAllCompanies().then(response => {
  268. // admin端返回TableDataInfo格式(rows),字段为id/tenantName,映射为companyId/companyName
  269. const rows = response.rows || [];
  270. this.companys = rows.map(item => ({
  271. companyId: item.id,
  272. companyName: item.tenantName
  273. }));
  274. if(this.companys!=null&&this.companys.length>0){
  275. this.companyId=this.companys[0].companyId;
  276. }
  277. this.companys.push({companyId:"-1",companyName:"无"})
  278. });
  279. },
  280. methods: {
  281. /** 查询登录日志 */
  282. getList() {
  283. this.loading = true;
  284. list(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
  285. this.list = response.rows;
  286. this.total = response.total;
  287. this.loading = false;
  288. }
  289. );
  290. },
  291. // 操作日志类型字典翻译
  292. typeFormat(row, column) {
  293. return this.selectDictLabel(this.typeOptions, row.businessType);
  294. },
  295. /** 搜索按钮操作 */
  296. handleQuery() {
  297. this.queryParams.pageNum = 1;
  298. this.getList();
  299. },
  300. /** 重置按钮操作 */
  301. resetQuery() {
  302. this.dateRange = [];
  303. this.resetForm("queryForm");
  304. this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
  305. this.handleQuery();
  306. },
  307. /** 多选框选中数据 */
  308. handleSelectionChange(selection) {
  309. this.ids = selection.map(item => item.operId)
  310. this.multiple = !selection.length
  311. },
  312. /** 排序触发事件 */
  313. handleSortChange(column, prop, order) {
  314. this.queryParams.orderByColumn = column.prop;
  315. this.queryParams.isAsc = column.order;
  316. this.getList();
  317. },
  318. /** 详细按钮操作 */
  319. handleView(row) {
  320. this.open = true;
  321. this.form = row;
  322. },
  323. /** 删除按钮操作 */
  324. handleDelete(row) {
  325. const operIds = row.operId || this.ids;
  326. this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', "警告", {
  327. confirmButtonText: "确定",
  328. cancelButtonText: "取消",
  329. type: "warning"
  330. }).then(function() {
  331. return delOperlog(operIds);
  332. }).then(() => {
  333. this.getList();
  334. this.msgSuccess("删除成功");
  335. }).catch(() => {});
  336. },
  337. /** 清空按钮操作 */
  338. handleClean() {
  339. this.$confirm('是否确认清空所有操作日志数据项?', "警告", {
  340. confirmButtonText: "确定",
  341. cancelButtonText: "取消",
  342. type: "warning"
  343. }).then(function() {
  344. return cleanOperlog();
  345. }).then(() => {
  346. this.getList();
  347. this.msgSuccess("清空成功");
  348. }).catch(() => {});
  349. },
  350. /** 查询部门下拉树结构 */
  351. getTreeselect() {
  352. // treeselect已移除,保留空方法避免报错
  353. },
  354. companyChange(val){
  355. console.log(val);
  356. this.companyId=val;
  357. },
  358. currDeptChange(val){
  359. console.log(val)
  360. this.queryParams.deptId=val;
  361. this.getList();
  362. },
  363. /** 导出按钮操作 */
  364. handleExport() {
  365. const queryParams = this.queryParams;
  366. this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
  367. confirmButtonText: "确定",
  368. cancelButtonText: "取消",
  369. type: "warning"
  370. }).then(() => {
  371. this.exportLoading = true;
  372. return exportOperlog(queryParams);
  373. }).then(response => {
  374. this.download(response.msg);
  375. this.exportLoading = false;
  376. }).catch(() => {});
  377. }
  378. }
  379. };
  380. </script>