list.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. dataList: [],
  40. req: {
  41. pageNum: 1,
  42. pageSize: 10,
  43. keyword: null,
  44. },
  45. }
  46. },
  47. onLoad() {
  48. this.search()
  49. },
  50. onShow() {
  51. if(this.needRefresh) this.search();
  52. },
  53. methods: {
  54. toDtl(i){
  55. console.log(i)
  56. uni.navigateTo({
  57. url: '/pages/supplyChain/product/add?' + formateObjToParamStr(i)
  58. })
  59. },
  60. cancel() {
  61. this.req.keyword = null
  62. },
  63. search() {
  64. this.req.pageNum = 1
  65. this.status = 'more'
  66. this.dataList = []
  67. this.getList()
  68. },
  69. getList() {
  70. const v = this
  71. if (v.status === 'more') {
  72. v.status = 'loading'
  73. } else {
  74. return
  75. }
  76. v.$post('/api/basics/product/page', v.req).then(res => {
  77. res.data.records.map(items => {
  78. items.typeName = (items.type === 0) ? '半成品' : '成品'
  79. })
  80. v.dataList = [...v.dataList, ...res.data.records]
  81. if (res.data.pages === v.req.pageNum || res.data.pages === 0) {
  82. v.status = 'noMore'
  83. } else {
  84. v.status = 'more'
  85. v.req.pageNum++
  86. }
  87. })
  88. },
  89. },
  90. }
  91. </script>
  92. <style lang="less">
  93. </style>