index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div style="padding-bottom: 60px">
  3. <van-nav-bar :title="'设备管理'" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
  4. <template #right> {{$t('common.add')}} </template>
  5. </van-nav-bar>
  6. <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
  7. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  8. <div class="list">
  9. <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
  10. <commonList :data="listData" :config="listConfig" @onClick="toDtl" :showMore="false"></commonList>
  11. </van-list>
  12. </div>
  13. </van-pull-refresh>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ref, getCurrentInstance, onMounted } from "vue";
  18. import commonList from "@/components/common-list.vue";
  19. import { useRoute } from "vue-router";
  20. const loading = ref(false);
  21. const router = useRoute();
  22. const req = ref({
  23. total: 3,
  24. pageNum: 1,
  25. pageSize: 10,
  26. });
  27. const finished = ref(false);
  28. const proxy = getCurrentInstance().proxy;
  29. const listData = ref([]);
  30. const listConfig = ref([
  31. {
  32. label: "业务公司",
  33. prop: "companyName",
  34. },
  35. {
  36. label: "设备编码",
  37. prop: "deviceCode",
  38. },
  39. {
  40. label: "设备名称",
  41. prop: "deviceName",
  42. },
  43. {
  44. label: "规格型号",
  45. prop: "deviceSpec",
  46. },
  47. {
  48. label: "制造商",
  49. prop: "makerName",
  50. },
  51. {
  52. label: "制造商电话",
  53. prop: "makerPhone",
  54. },
  55. {
  56. label: "出厂日期",
  57. prop: "deviceDeliveryTime",
  58. },
  59. {
  60. label: "备注",
  61. prop: "remark",
  62. },
  63. ]);
  64. const onRefresh = () => {
  65. req.value.pageNum = 1;
  66. finished.value = false;
  67. getList("refresh");
  68. };
  69. const onLoad = () => {
  70. getList();
  71. };
  72. const onClickLeft = () => proxy.$router.push("/main/working");
  73. const onClickRight = () => {
  74. proxy.$router.push({
  75. path: "/main/equipmentAdd",
  76. query: {
  77. type: "add",
  78. },
  79. });
  80. };
  81. proxy.uploadDdRightBtn(onClickRight, proxy.t("common.add"));
  82. const toDtl = (row) => {
  83. proxy.$router.push({
  84. path: "/main/equipmentAdd",
  85. query: {
  86. id: row.id,
  87. type: "edit",
  88. },
  89. });
  90. };
  91. const getList = (type) => {
  92. loading.value = true;
  93. proxy
  94. .post("/tdaDevice/page", req.value)
  95. .then((res) => {
  96. listData.value =
  97. type === "refresh"
  98. ? res.data.rows
  99. : listData.value.concat(res.data.rows);
  100. if (req.value.pageNum * 10 >= res.data.total) {
  101. finished.value = true;
  102. }
  103. req.value.pageNum++;
  104. loading.value = false;
  105. })
  106. .catch((err) => {
  107. loading.value = false;
  108. });
  109. };
  110. getList();
  111. </script>
  112. <style lang="scss" scoped>
  113. .list {
  114. min-height: 70vh;
  115. }
  116. </style>