index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="layout-pd">
  3. <el-row>
  4. <!--操作-->
  5. <el-col :xs="24">
  6. <el-card class="mt8" shadow="hover">
  7. <el-form :model="state.filter" :inline="true" @submit.stop.prevent>
  8. <el-form-item prop="name" style="width: 100%">
  9. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  10. <el-form-item label="应用">
  11. <el-input v-model="state.appName" disabled></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  15. <el-form-item label="油机标识">
  16. <el-input v-model="state.filter.MachineId" placeholder="单行输入" clearable></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  20. <el-form-item label="设备sn">
  21. <el-input v-model="state.filter.SN" placeholder="单行输入" clearable></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  25. <el-form-item label="登录账户">
  26. <el-input v-model="state.filter.Account" placeholder="单行输入" clearable></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  30. <el-form-item label="使用类型">
  31. <el-input v-model="state.filter.OpreationType" placeholder="单行输入" clearable></el-input>
  32. </el-form-item>
  33. </el-col>
  34. </el-form-item>
  35. </el-form>
  36. <hr>
  37. <el-row justify="space-between" class="submit-button" style="margin-bottom: -9px;">
  38. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  39. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  40. </el-row>
  41. </el-card>
  42. </el-col>
  43. <!--表格-->
  44. <el-col :xs="24">
  45. <el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
  46. <el-table v-loading="state.loading" stripe :data="state.tableModel" row-key="id" style="width: 100%">
  47. <el-table-column type="selection" width="50"></el-table-column>
  48. <el-table-column v-for="column in state.dynamicColumns" :key="column.prop" :prop="column.prop"
  49. :label="column.label">
  50. </el-table-column>
  51. <el-table-column label="操作" fixed="right" header-align="center" align="center" class="right-operation"
  52. width="140">
  53. <template #default="{ row }">
  54. <el-link class="my-el-link mr12 ml12" type="primary" icon="ele-Upload" @click="onDataDetail(row)"
  55. :underline="false" target="_blank">详情</el-link>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. <div class="my-flex my-flex-end" style="margin-top: 20px">
  60. <el-pagination v-model:currentPage="pageState.pageInput.currentPage"
  61. v-model:page-size="pageState.pageInput.pageSize" :total="state.total" :page-sizes="[10, 15, 20, 50, 100]"
  62. small background @size-change="onSizeChange" @current-change="onCurrentChange"
  63. layout="total, sizes, prev, pager, next, jumper" />
  64. </div>
  65. </el-card>
  66. </el-col>
  67. </el-row>
  68. <RecordDetailDialog ref="recordDetailRef"></RecordDetailDialog>
  69. </div>
  70. </template>
  71. <script setup lang="ts">
  72. import { defineAsyncComponent, onBeforeMount, onMounted, reactive, ref, watch } from "vue";
  73. import eventBus from "/@/utils/mitt";
  74. import { Api } from "/@/api/appOperationRecord/api";
  75. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  76. // 使用组合式函数获取分页状态
  77. const pageState = useDynamicPageSize(10, 15);
  78. import { RecordOutput } from "/@/api/appOperationRecord/dto";
  79. import type { pageInput } from "/@/api/appOperationRecord/dto"
  80. import router from "/@/router";
  81. import { PermissionApi } from "/@/api/admin/Permission";
  82. import { ElMessage } from "element-plus";
  83. /**引入组件*/
  84. const RecordDetailDialog = defineAsyncComponent(() => import('./components/record_detail.vue'))
  85. const recordDetailRef = ref()
  86. /**数据对象*/
  87. const state = reactive({
  88. /**加载显示 */
  89. loading: false,
  90. /** 应用名称 */
  91. appName: "",
  92. /**条件查询模块 */
  93. filter: {
  94. /**油机唯一标识 */
  95. MachineId: "",
  96. /**应用的 app id */
  97. AppId: "",
  98. /**设备 sn */
  99. SN: "",
  100. /**登录账户 */
  101. Account: "",
  102. /**使用类型 */
  103. OpreationType: "",
  104. },
  105. /**表格信息 */
  106. tableModel: [] as RecordOutput,
  107. /**动态表头 */
  108. dynamicColumns: [
  109. { prop: 'machineId', label: '油机唯一标识' },
  110. { prop: 'sn', label: '设备 sn' },
  111. { prop: 'account', label: '登录账户' },
  112. { prop: 'opreationType', label: '使用类型' },
  113. // { prop: 'recodeJson', label: '使用记录' },
  114. { prop: 'createTime', label: '操作记录时间' },],
  115. /**分页标识 */
  116. pageInput: {
  117. CurrentPage: 1,
  118. PageSize: 10,
  119. } as pageInput,
  120. /**分页总数 */
  121. total: 0,
  122. })
  123. onMounted(() => {
  124. // 初始化分页大小
  125. state.pageInput.PageSize = pageState.pageInput.pageSize;
  126. init()
  127. eventBus.off('refreshView')
  128. eventBus.on('refreshView', async () => {
  129. await init()
  130. })
  131. console.log()
  132. })
  133. onBeforeMount(() => {
  134. eventBus.off('refreshView')
  135. })
  136. /**
  137. * 监听变换
  138. */
  139. // watch(() => { })
  140. /**条件查询 */
  141. const onQuery = async () => {
  142. state.loading = true;
  143. try {
  144. const res: any = await new Api().getList({
  145. ...pageState.pageInput,
  146. "Filter.MachineId": state.filter.MachineId,
  147. "Filter.SN": state.filter.SN,
  148. "Filter.Account": state.filter.Account,
  149. "Filter.AppId": state.filter.AppId,
  150. "Filter.OpreationType": state.filter.OpreationType
  151. })
  152. state.total = res?.data?.total ?? 0
  153. state.tableModel = res?.data?.list ?? []
  154. } catch (error) {
  155. console.error('获取操作记录列表失败:', error);
  156. ElMessage.error('获取操作记录列表失败');
  157. } finally {
  158. state.loading = false;
  159. }
  160. }
  161. /**初始化 */
  162. const init = async () => {
  163. try {
  164. const name = router.currentRoute.value.params.id;
  165. const appData = await new PermissionApi().getApplyInfo({ Name: name });
  166. state.appName = appData.data[0].name;
  167. state.filter.AppId = appData.data[0].appid;
  168. } catch (error) {
  169. console.error('获取应用信息失败:', error);
  170. ElMessage.error('获取应用信息失败');
  171. } finally {
  172. state.loading = false;
  173. onQuery();
  174. }
  175. state.loading = true
  176. state.loading = false
  177. }
  178. /**重置 */
  179. const onReset = () => { }
  180. /**详情 */
  181. const onDataDetail = (row) => {
  182. recordDetailRef.value.open(row)
  183. }
  184. /**
  185. * 页条变化
  186. * @param val
  187. */
  188. const onSizeChange = (val: number) => {
  189. state.pageInput.PageSize = val
  190. //需按照页面对象修改Data
  191. onQuery()
  192. }
  193. /**
  194. * 页数 变化
  195. * @param val
  196. */
  197. const onCurrentChange = (val: number) => {
  198. state.pageInput.CurrentPage = val
  199. //需按照页面对象修改Data
  200. onQuery()
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. .el-input,
  205. .el-select {
  206. width: 240px;
  207. }
  208. /* 输入框标签固定四个字符宽度 */
  209. ::v-deep .el-form-item__label {
  210. // 字体大小14,5个字符,12px右间距
  211. width: 14*5px+12px;
  212. justify-content: start;
  213. }
  214. /* 数据表头 设置灰色样式 */
  215. ::v-deep .el-table th.el-table__cell {
  216. background-color: #F6F6F6;
  217. }
  218. </style>