chooseProduct.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="chooseProduct-wrap">
  3. <!-- 标题 -->
  4. <u-navbar title="选择产品" :safeAreaInsetTop="false" :border-bottom="true">
  5. <view class="u-nav-slot" slot="right" style="padding-right: 40rpx;">
  6. <u-icon name="search" color="#999" size="28" @click="openModal=true"></u-icon>查询
  7. </view>
  8. </u-navbar>
  9. <!-- 产品列表 -->
  10. <view class="product-list-box">
  11. <scroll-view class="product-list-con" :style="{height: scrollH+'upx'}" scroll-y @scrolltolower="onreachBottom">
  12. <view class="product-list-item border-b font_13 flex justify_between" v-for="(item, index) in listData" :key="item.id">
  13. <view class="list-item-tit">
  14. <u-section :title="item.productName":right="false" :line-color="$config('primaryColor')"></u-section>
  15. </view>
  16. <!-- <view class="pimgs">
  17. <u-image :src="item.productMainMsg?item.productMainMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  18. <view v-if="item.oosFlag == 1" class="sign" :style="{backgroundColor: $config('errorColor')}">急</view>
  19. <view v-if="item.price < item.cost" class="sign" :style="{backgroundColor: $config('errorColor')}">亏</view>
  20. <view v-if="item.price == 0" class="sign" :style="{backgroundColor: $config('errorColor')}">赠</view>
  21. </view>
  22. <view class="product-item-main flex_1">
  23. <view class="product-item-name">{{item.productName || '--'}}</view>
  24. <view class="product-item-txt flex align_center justify_between">
  25. <view>{{item.productCode || '--'}}</view>
  26. <u-icon @click="handleDel(item)" name="trash-fill" :color="$config('errorColor')" size="34"></u-icon>
  27. </view>
  28. <view class="product-item-txt color_6" style="font-size: 24upx;" v-if="item.warehouseEntity&&item.warehouseEntity.name || item.warehouseLocationEntity&&item.warehouseLocationEntity.name">{{item.warehouseEntity&&item.warehouseEntity.name}} > {{item.warehouseLocationEntity&&item.warehouseLocationEntity.name}}</view>
  29. <view class="product-item-txt flex align_center justify_between">
  30. <view class="product-item-priceInfo">
  31. <view :style="{color: $config('errorColor'), display: 'inline-block'}">¥<text style="font-size: 30upx;">{{toThousands(item.price||0, 2)}}</text></view>
  32. <text style="display: inline-block;margin: 0 10upx;">*</text>
  33. <text style="font-size: 30upx;">{{toThousands(item.qty||0)}}</text>
  34. {{item.productUnit}}
  35. </view>
  36. <view class="product-item-price">¥{{toThousands(item.totalAmount||0, 2)}}</view>
  37. </view>
  38. <view class="product-item-price">折后¥{{toThousands(item.discountedAmount||0, 2)}}</view>
  39. </view> -->
  40. </view>
  41. <view v-if="listData && listData.length == 0">
  42. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="30"></u-empty>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. <!-- 查询右侧弹框 -->
  47. <productSearch :openModal="openModal" :defaultParams="searchForm" @refresh="refresh" @close="openModal=false" />
  48. </view>
  49. </template>
  50. <script>
  51. import ProductSearch from './productSearch.vue'
  52. import { toThousands } from '@/libs/tools'
  53. import { querySumByProductLocation } from '@/api/stock'
  54. export default{
  55. components: { ProductSearch },
  56. data(){
  57. return{
  58. toThousands,
  59. customBtnStyle: { // 自定义按钮样式
  60. borderColor: this.$config('primaryColor'),
  61. backgroundColor: this.$config('primaryColor'),
  62. color: '#fff'
  63. },
  64. listData: [],
  65. pageNo: 1,
  66. pageSize: 6,
  67. totalNum: 0,
  68. noDataText: '暂无数据',
  69. searchForm: {},
  70. searchParams: {},
  71. openModal: false,
  72. theme: '',
  73. chooseProductList: [],
  74. scrollH: 0,
  75. }
  76. },
  77. onLoad(opt) {
  78. this.theme = getApp().globalData.theme
  79. if(opt){
  80. this.chooseProductList = opt.data ? JSON.parse(opt.data) : null
  81. }
  82. console.log(this.chooseProductList)
  83. this.getList()
  84. const _this = this
  85. let footerH = _this.$refs.productTotal && _this.$refs.productTotal.$el && _this.$refs.productTotal.$el.offsetHeight || 0
  86. uni.getSystemInfo({
  87. success: function (res) {
  88. const winH = res.windowHeight * 2
  89. _this.scrollH = winH - footerH - 85
  90. }
  91. })
  92. },
  93. methods: {
  94. // 获取查询参数 刷新列表
  95. refresh(params){
  96. const _this = this
  97. this.searchParams = Object.assign(params, this.searchForm)
  98. this.$nextTick(function(){
  99. // _this.$refs.productList.getList(1)
  100. })
  101. },
  102. // 列表
  103. getList(pageNo){
  104. const _this = this
  105. if (pageNo) {
  106. this.pageNo = pageNo
  107. }
  108. let params = {
  109. pageNo: this.pageNo,
  110. pageSize: this.pageSize
  111. }
  112. querySumByProductLocation(Object.assign(params, this.params)).then(res => {
  113. if (res.status == 200) {
  114. if(this.pageNo>1){
  115. this.listData = this.listData.concat(res.data.list || [])
  116. }else{
  117. this.listData = res.data.list || []
  118. }
  119. this.totalNum = res.data.count || 0
  120. } else {
  121. this.listData = []
  122. this.totalNum = 0
  123. this.noDataText = res.message
  124. }
  125. })
  126. },
  127. // scroll-view到底部加载更多
  128. onreachBottom() {
  129. if(this.listData.length < this.totalNum){
  130. this.pageNo += 1
  131. this.getList()
  132. }
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .chooseProduct-wrap{
  139. width: 100%;
  140. .product-list-box{
  141. padding: 20upx 20upx;
  142. }
  143. }
  144. </style>