tenantDict.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <van-nav-bar
  3. title="业务字典"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. @click-right="onClickRight"
  8. >
  9. <template #right> 添加 </template>
  10. </van-nav-bar>
  11. <van-search
  12. v-model="req.keyword"
  13. placeholder="请输入关键词"
  14. @search="onRefresh"
  15. />
  16. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  17. <div class="list">
  18. <van-list
  19. v-model:loading="loading"
  20. :finished="finished"
  21. finished-text="没有更多了"
  22. @load="onLoad"
  23. style="margin-bottom: 60px"
  24. >
  25. <commonList
  26. :data="listData"
  27. @onClick="toDtl"
  28. :config="listConfig"
  29. ></commonList>
  30. </van-list>
  31. </div>
  32. </van-pull-refresh>
  33. </template>
  34. <script setup>
  35. import { ref, getCurrentInstance, onMounted } from 'vue'
  36. import commonList from '@/components/common-list.vue'
  37. import { useRoute } from 'vue-router'
  38. import { getUserInfo } from '@/utils/auth'
  39. const loading = ref(false)
  40. const router = useRoute()
  41. const req = ref({
  42. pageNum: 1,
  43. keyword: null,
  44. tenantId: getUserInfo().tenantId,
  45. code: null,
  46. })
  47. const finished = ref(false)
  48. const proxy = getCurrentInstance().proxy
  49. const listData = ref([])
  50. const listConfig = ref([
  51. {
  52. label: '键',
  53. prop: 'dictKey',
  54. },
  55. {
  56. label: '值',
  57. prop: 'dictValue',
  58. },
  59. {
  60. label: '排序',
  61. prop: 'sort',
  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: 'tenantAdd',
  76. query: {
  77. dictCode:router.query.code
  78. },
  79. })
  80. }
  81. proxy.uploadDdRightBtn(onClickRight,'添加')
  82. const toDtl = (row) => {
  83. console.log(row)
  84. proxy.$router.push({
  85. path: 'tenantAdd',
  86. query: row,
  87. })
  88. }
  89. const warehouseType = ref([])
  90. const getList = (type) => {
  91. loading.value = true
  92. proxy
  93. .post('dictTenantData/page', req.value)
  94. .then((res) => {
  95. listData.value =
  96. type === 'refresh'
  97. ? res.data.rows
  98. : listData.value.concat(res.data.rows)
  99. if (req.value.pageNum * 10 >= res.data.total) {
  100. finished.value = true
  101. }
  102. req.value.pageNum++
  103. loading.value = false
  104. })
  105. .catch((err) => {
  106. loading.value = false
  107. })
  108. }
  109. onMounted(() => {
  110. req.value.dictCode = router.query.code
  111. getList()
  112. })
  113. </script>
  114. <style lang="scss" scoped>
  115. .list {
  116. min-height: 70vh;
  117. }
  118. </style>