index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <el-table
  3. v-loading="loading"
  4. :data="tableData"
  5. style="width: 100%"
  6. border
  7. size="large"
  8. @cell-click="cellClick"
  9. >
  10. <el-table-column prop="index" label="#" align="center" />
  11. <el-table-column prop="numId" label="编号" align="center" />
  12. <el-table-column prop="name" label="测试产品名称" align="center" />
  13. <el-table-column prop="testState" label="测试类型状态" align="center" />
  14. <el-table-column prop="remark" label="备注" align="center" />
  15. <el-table-column label="创建时间" align="center">
  16. <template #default="scope">
  17. <div>{{ dayjs(scope.row.dateTime).format("YYYY-MM-DD HH:mm:ss") }}</div>
  18. </template>
  19. </el-table-column>
  20. </el-table>
  21. <div class="mt-5 flex items-center justify-end">
  22. <el-pagination
  23. background
  24. layout="prev, pager, next"
  25. :total="total"
  26. :page-size="10"
  27. :pager-count="11"
  28. :current-page="page.current"
  29. @current-change="currentChange"
  30. />
  31. </div>
  32. <Drawer
  33. @drawClose="DrawerVisible = false"
  34. v-if="DrawerVisible"
  35. :testId="id"
  36. :visible="DrawerVisible"
  37. ></Drawer>
  38. </template>
  39. <script setup >
  40. import dayjs from "dayjs";
  41. import Drawer from "./Drawer.vue";
  42. import { productList } from "@/api/login";
  43. import { onMounted, ref } from "vue";
  44. const tableData = ref([]);
  45. const page = ref({
  46. current: 1,
  47. size: 10,
  48. });
  49. const total = ref(0);
  50. const loading = ref(false);
  51. const getList = async () => {
  52. loading.value = true;
  53. let { code, data } = await productList(page.value);
  54. loading.value = false;
  55. if (code != 200) return;
  56. tableData.value = data.records.map((item, i) => ({
  57. ...item,
  58. index: (page.value.current - 1) * 10 + i + 1,
  59. }));
  60. total.value = data.total;
  61. };
  62. const currentChange = (val) => {
  63. page.value.current = val;
  64. getList();
  65. };
  66. const DrawerVisible = ref(false);
  67. const id = ref("");
  68. const cellClick = async ({ testId }) => {
  69. id.value = testId + "";
  70. DrawerVisible.value = true;
  71. };
  72. onMounted(() => {
  73. getList();
  74. });
  75. </script>
  76. <script>
  77. export default {
  78. name: "Home",
  79. };
  80. </script>
  81. <style scoped lang="scss">
  82. </style>