list.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="home bg-f9">
  3. <header-bar addUrl="/warehouse/add" title="仓库维护"></header-bar>
  4. <uni-search-bar v-model="req.keyword" placeholder="输入关键词" @confirm="search" @cancel="cancel" bgColor="#fff"
  5. cancel-text="取消">
  6. </uni-search-bar>
  7. <!-- <common-approval></common-approval> -->
  8. <common-list :config="config" @listClick="toDtl" :data="dataList"></common-list>
  9. <button type="default" @click="getList()" style="margin-top:10rpx">
  10. {{status == 'more' ? '点击加载更多' : status == 'noMore' ? '已经到底了' : '加载中..'}}
  11. </button>
  12. </view>
  13. </template>
  14. <script>
  15. import commonApproval from '../../../components/common-approval/common-approval.vue'
  16. import headerBar from '../../../components/header-bar/index.vue'
  17. import commonList from '../../../components/common-list/common-list.vue'
  18. import {formateObjToParamStr} from '../../../util/uitl.js'
  19. import Vue from 'vue'
  20. export default {
  21. components: {
  22. headerBar,
  23. commonList,
  24. commonApproval
  25. },
  26. data() {
  27. return {
  28. status: 'more',
  29. config: [{
  30. label: "仓库类型",
  31. key: 'type',
  32. },
  33. {
  34. label: "仓库名称",
  35. key: 'name',
  36. },
  37. {
  38. label: "仓库说明",
  39. key: 'remarks',
  40. }
  41. ],
  42. dataList: [],
  43. req: {
  44. pageNum: 1,
  45. pageSize: 10,
  46. keyword: null,
  47. },
  48. }
  49. },
  50. onLoad() {
  51. this.search()
  52. },
  53. onShow() {
  54. if(this.needRefresh) this.search();
  55. },
  56. methods: {
  57. toDtl(i){
  58. console.log(i)
  59. uni.navigateTo({
  60. url: '/pages/supplyChain/warehouse/add?' + formateObjToParamStr(i)
  61. })
  62. },
  63. cancel() {
  64. this.req.keyword = null
  65. },
  66. search() {
  67. this.req.pageNum = 1
  68. this.status = 'more'
  69. this.dataList = []
  70. this.getList()
  71. },
  72. getList() {
  73. const v = this
  74. if (v.status === 'more') {
  75. v.status = 'loading'
  76. } else {
  77. return
  78. }
  79. v.$post('/api/basics/warehouse/page', v.req).then(res => {
  80. console.log(res)
  81. v.dataList = [...v.dataList, ...res.data.records]
  82. if (res.data.pages === v.req.pageNum || res.data.pages === 0) {
  83. v.status = 'noMore'
  84. } else {
  85. v.status = 'more'
  86. v.req.pageNum++
  87. }
  88. })
  89. },
  90. },
  91. }
  92. </script>
  93. <style lang="less">
  94. </style>