list.vue 2.2 KB

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