businessDict.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <van-nav-bar
  3. :title="$t('dict.name')"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. @click-right="onClickRight"
  8. >
  9. <template #right> {{$t('common.add')}} </template>
  10. </van-nav-bar>
  11. <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
  12. <van-pull-refresh v-model="loading" @refresh="onRefresh" >
  13. <div class="list">
  14. <van-list
  15. v-model:loading="loading"
  16. :finished="finished"
  17. :finished-text="$t('common.noMore')"
  18. @load="onLoad"
  19. style="margin-bottom:60px"
  20. >
  21. <commonList :data="listData" @onClick="toDtl" :config="listConfig"></commonList>
  22. </van-list>
  23. </div>
  24. </van-pull-refresh>
  25. </template>
  26. <script setup>
  27. import { ref, getCurrentInstance, onMounted } from 'vue'
  28. import commonList from '@/components/common-list.vue'
  29. import { useRoute } from 'vue-router'
  30. import { getUserInfo } from '@/utils/auth';
  31. const loading = ref(false)
  32. const router = useRoute()
  33. const req = ref({
  34. pageNum:1,
  35. keyword:null,
  36. tenantId:getUserInfo().tenantId
  37. })
  38. const finished = ref(false);
  39. const proxy = getCurrentInstance().proxy
  40. const listData = ref([])
  41. const listConfig = ref([
  42. {
  43. label: proxy.t('dict.dictionaryName'),
  44. prop: 'name',
  45. },
  46. {
  47. label: proxy.t('dict.dictionaryCode'),
  48. prop: 'code',
  49. },
  50. {
  51. label: proxy.t('dict.remark'),
  52. prop: 'remark',
  53. }
  54. ])
  55. const onRefresh = () => {
  56. req.value.pageNum = 1
  57. finished.value = false
  58. getList('refresh')
  59. }
  60. const onLoad = () => {
  61. getList()
  62. }
  63. const onClickLeft = () => proxy.$router.push('/main/working')
  64. const onClickRight = () => {
  65. proxy.$router.push('/main/businessAdd')
  66. }
  67. proxy.uploadDdRightBtn(onClickRight,proxy.t('common.add'))
  68. const toDtl = (row) => {
  69. console.log(row)
  70. proxy.$router.push({
  71. path: 'tenantDict',
  72. query: row
  73. })
  74. }
  75. const warehouseType = ref([])
  76. const getList = (type) => {
  77. loading.value = true
  78. proxy.post('/dictTenantType/page',req.value).then(res => {
  79. listData.value = type === 'refresh' ? res.data.rows : listData.value.concat(res.data.rows)
  80. if(req.value.pageNum * 10 >= res.data.total) {
  81. finished.value = true
  82. }
  83. req.value.pageNum++
  84. loading.value = false
  85. }).catch(err => {
  86. loading.value = false
  87. })
  88. }
  89. getList()
  90. </script>
  91. <style lang="scss" scoped>
  92. .list {
  93. min-height: 70vh;
  94. }
  95. </style>