index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="interfaceLog">
  3. <div class="interfaceLog_head flex">
  4. <div class="interfaceLog_head_time flex-wrap">
  5. <div class="interfaceLog_head_time_start mr10">
  6. <el-date-picker v-model="timeStart" size="default" type="datetime" placeholder="选择开始日期时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" :clearable="false" @change="timeSelectHandler" />
  7. </div>
  8. <div class="interfaceLog_head_time_end mr10">
  9. <el-date-picker v-model="timeEnd" size="default" type="datetime" placeholder="选择结束日期时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" :clearable="false" @change="timeSelectHandler" />
  10. </div>
  11. <div class="interfaceLog_head_select mr10">
  12. <el-select v-model="selMsg" size="medium" @change="timeSelectHandler" placeholder="请选择">
  13. <el-option v-for="item in selOptions" :key="item.value" :label="item.label" :value="item.value">
  14. </el-option>
  15. </el-select>
  16. </div>
  17. <div v-if="selMsg == '系统'" class="interfaceLog_head_result">
  18. <el-select v-model="resMsg" size="medium" @change="timeSelectHandler" placeholder="请选择">
  19. <el-option v-for="item in resOptions" :key="item.value" :label="item.label" :value="item.value">
  20. </el-option>
  21. </el-select>
  22. </div>
  23. </div>
  24. <div class="interfaceLog_head_btn">
  25. <Search v-permission="['log_management_search_button']" :is-title="false" @get-search-data="getSearchData" @clear-search-data="clearSearchData" />
  26. </div>
  27. </div>
  28. <div class="interfaceLog_content">
  29. <el-row :gutter="24">
  30. <el-col :span="24">
  31. <div class="app-containers">
  32. <DataTable class="table" highlight-current-row :data="tableData" height="calc(100vh - 180px)" :columns="tableColumns" />
  33. </div>
  34. </el-col>
  35. <el-col v-if="false" :span="5">
  36. <div class="interfaceLog_content_progress">
  37. <el-timeline>
  38. <el-timeline-item v-for="(item, index) in progressList" :key="index">
  39. <div class="list">
  40. <div class="list_status"></div>
  41. <div class="list_title">{{ item.logType }}</div>
  42. <div class="list_code">{{ item.resultCode }}</div>
  43. <div class="list_time">{{ item.logTime }}</div>
  44. <!-- <div class="list_detial">{{ item.resultDetails }}</div> -->
  45. </div>
  46. </el-timeline-item>
  47. </el-timeline>
  48. </div>
  49. </el-col>
  50. </el-row>
  51. </div>
  52. </div>
  53. </template>
  54. <script setup lang="ts">
  55. import DataTable from "@/components/SimpleTable/index.vue";
  56. import { ElMessage } from "element-plus";
  57. import { Query } from "@/api/webApi";
  58. import { CommonTableColumn } from "~/common";
  59. import { ellipsisCell } from "./customRender";
  60. type TableColumn = {
  61. label: string;
  62. key: string;
  63. };
  64. type progressItem = {
  65. logType: string;
  66. resultCode: string;
  67. logTime: string;
  68. resultDetails?: string;
  69. };
  70. const getSearchData = (text: string) => {
  71. console.log(text);
  72. };
  73. const clearSearchData = () => {};
  74. let page = 0;
  75. const loading = ref(false);
  76. const noMore = ref(false);
  77. const loadDisabled = computed(() => loading.value || noMore.value);
  78. //表头
  79. const tableColumns = ref<CommonTableColumn[]>([]);
  80. //列表
  81. const tableData = ref<any[]>([]);
  82. const resetTable = () => {
  83. page = 0;
  84. loading.value = false;
  85. noMore.value = false;
  86. tableData.value = [];
  87. };
  88. onMounted(() => {
  89. getToday();
  90. getTableData();
  91. });
  92. const getTableData = async () => {
  93. try {
  94. loading.value = true;
  95. const {
  96. code,
  97. returnData: { columnSet, listValues },
  98. } = await Query({
  99. id: DATACONTENT_ID.sysLogTable,
  100. // needPage: ++page,
  101. dataContent:
  102. selMsg.value == "系统"
  103. ? [timeStart.value, timeEnd.value, selMsg.value, resMsg.value]
  104. : [timeStart.value, timeEnd.value, selMsg.value],
  105. });
  106. if (Number(code) === 0) {
  107. // customRender: ellipsisCell,
  108. columnSet.map((item) => {
  109. if (item.columnName == "success") item.customRender = ellipsisCell;
  110. });
  111. tableColumns.value = [...columnSet];
  112. if (listValues.length === 0) {
  113. page--;
  114. noMore.value = true;
  115. }
  116. // tableData.value.push(...listValues);
  117. tableData.value = [...listValues];
  118. loading.value = false;
  119. } else {
  120. throw new Error("获取数据失败");
  121. }
  122. } catch (error: any) {
  123. page--;
  124. loading.value = false;
  125. ElMessage.error(error.message);
  126. }
  127. };
  128. const load = () => {
  129. if (loadDisabled.value) {
  130. return;
  131. }
  132. getTableData();
  133. };
  134. const timeStart = ref("");
  135. const timeEnd = ref("");
  136. const selMsg = ref("系统");
  137. const resMsg = ref("错误");
  138. const selOptions = ref([
  139. {
  140. value: "系统",
  141. label: "系统",
  142. },
  143. {
  144. value: "用户",
  145. label: "用户",
  146. },
  147. ]);
  148. const resOptions = ref([
  149. {
  150. value: "成功",
  151. label: "成功",
  152. },
  153. {
  154. value: "错误",
  155. label: "错误",
  156. },
  157. ]);
  158. const getToday = () => {
  159. function numberFormat(number) {
  160. const string = "0" + number;
  161. return string.slice(-2);
  162. }
  163. const now = new Date();
  164. const year = now.getFullYear();
  165. const month = now.getMonth() + 1;
  166. const date = now.getDate();
  167. const today = `${year}-${numberFormat(month)}-${numberFormat(date)}`;
  168. timeStart.value = `${today} 00:00:00`;
  169. timeEnd.value = `${today} 23:59:59`;
  170. };
  171. const timeSelectHandler = () => {
  172. const startTime = new Date(timeStart.value).getTime();
  173. const endTime = new Date(timeEnd.value).getTime();
  174. if (startTime > endTime) {
  175. ElMessage.error("开始时间不能大于结束时间");
  176. timeEnd.value = "";
  177. return;
  178. }
  179. if (startTime < endTime - (3 * 24 * 60 * 60 - 1) * 1000) {
  180. ElMessage.error("间隔时间不能大于三天");
  181. timeEnd.value = "";
  182. return;
  183. }
  184. resetTable();
  185. getTableData();
  186. };
  187. const progressList = ref<progressItem[]>([]);
  188. // progressList.value.push(
  189. // ...Array.from({ length: 3 }).map(() => ({
  190. // logType: '更新 Github 模板',
  191. // resultCode: '989665554',
  192. // logTime: '2022-4-26 15:48:55',
  193. // }))
  194. // )
  195. const rowClickHandler = (row, column, event) => {
  196. progressList.value = [];
  197. if (row.logObject) {
  198. tableData.value.forEach((record) => {
  199. if (record.logObject == row.logObject) {
  200. progressList.value.push(record);
  201. }
  202. });
  203. } else {
  204. progressList.value.push(row);
  205. }
  206. };
  207. </script>
  208. <style lang="scss" scoped>
  209. .interfaceLog {
  210. padding: 8px 32px 12px 8px;
  211. .mr10 {
  212. margin-right: 10px;
  213. }
  214. :deep .interfaceLog_head_time {
  215. .el-input__prefix {
  216. left: 10px;
  217. color: #101116;
  218. top: 10px;
  219. }
  220. // .el-input--prefix .el-input__inner {
  221. // padding-left: 50px;
  222. // }
  223. }
  224. .interfaceLog_head_btn {
  225. :deep .el-button {
  226. margin-right: 0;
  227. }
  228. }
  229. .interfaceLog_content {
  230. margin-top: 8px;
  231. :deep .table {
  232. color: #101116;
  233. thead {
  234. color: #101116;
  235. }
  236. .success {
  237. color: #33bf47;
  238. }
  239. .error {
  240. color: #df4545;
  241. }
  242. }
  243. &_progress {
  244. // width: 368px;
  245. background: #fafcff;
  246. margin-left: 8px;
  247. padding: 13px 32px;
  248. overflow: hidden;
  249. :deep .el-timeline {
  250. padding: 0;
  251. .el-timeline-item {
  252. position: relative;
  253. &::after {
  254. position: absolute;
  255. content: "";
  256. height: 1px;
  257. width: calc(100% + 4px);
  258. background-color: #dfe3ea;
  259. left: 28px;
  260. bottom: 20px;
  261. }
  262. &:last-child {
  263. &::after {
  264. height: 0;
  265. }
  266. }
  267. }
  268. .el-timeline-item__node--normal {
  269. z-index: 2;
  270. background-color: #fff;
  271. width: 10px;
  272. height: 10px;
  273. left: 0px;
  274. top: 2px;
  275. }
  276. .el-timeline-item__tail {
  277. border-left: 4px solid #dfe3ea;
  278. left: 3px;
  279. }
  280. .el-timeline-item:last-child .el-timeline-item__tail {
  281. height: 1000%;
  282. display: block;
  283. }
  284. .list {
  285. &_status {
  286. position: absolute;
  287. width: 20px;
  288. height: 20px;
  289. background: #ac014d;
  290. left: -5px;
  291. border-radius: 50%;
  292. z-index: 1;
  293. }
  294. &_title,
  295. &_code {
  296. margin-bottom: 7px;
  297. font-size: 14px;
  298. font-family: Microsoft YaHei;
  299. font-weight: bold;
  300. color: #101116;
  301. }
  302. &_time {
  303. font-size: 12px;
  304. font-family: Helvetica;
  305. font-weight: 400;
  306. color: #afb4bf;
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. .interfaceLog_content_progress {
  314. height: 100%;
  315. }
  316. // :deep.el-timeline .list_status {
  317. // background: #ac014d !important;
  318. // }
  319. </style>