chooseProduct.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 font_13" v-for="(item, index) in listData" :key="item.id">
  13. <view class="list-item-tit">
  14. <view class="item-tit ellipsis-one" :style="{borderColor: $config('primaryColor')}">{{item.productName}}</view>
  15. </view>
  16. <view class="list-item-con flex align_center justify_between">
  17. <view class="pimgs">
  18. <u-image :src="item.productMainPic&&item.productMainPic.imageUrl?item.productMainPic.imageUrl:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  19. </view>
  20. <view class="flex_1">
  21. <view>产品编码:{{item.productCode || '--'}}</view>
  22. <view class="padding_3 flex align_center justify_between">
  23. <view>原厂编码:{{item.productOrigCode || '--'}}</view>
  24. <u-icon name="plus-circle" :color="$config('primaryColor')" size="40" class="close-circle" @click="clearWarehouse"></u-icon>
  25. </view>
  26. <view v-if="item.warehouseName || item.warehouseLocationName">仓库仓位:{{item.warehouseName}} > {{item.warehouseLocationName}}</view>
  27. </view>
  28. </view>
  29. <view class="list-item-footer flex align_center justify_between">
  30. <view class="footer-item">
  31. <view>{{toThousands(item.currentQty||0)}}{{item.unit}}</view>
  32. <view class="color_6">库存数量</view>
  33. </view>
  34. <view class="footer-item">
  35. <view>
  36. <text :style="{color: $config('errorColor')}">{{toThousands((item.lastSalePrice ? item.lastSalePrice : item.salePrice)||0, 2)}}</text>
  37. <text v-if="item.origSalePriceFlag == 1">(原)</text>
  38. </view>
  39. <view class="color_6">参考售价</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view v-if="listData && listData.length == 0">
  44. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="30"></u-empty>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <!-- 已选产品 -->
  49. <view ref="productTotal" class="selected-box flex align_center justify_between">
  50. <view class="choose-info flex_1 flex align_center justify_between" @click="lookProduct">
  51. <text>已选 3 款,合计 ¥96.00</text>
  52. <u-icon name="arrow-up" :color="$config('primaryColor')" size="34" class="close-circle"></u-icon>
  53. </view>
  54. <view class="choose-btn" @click="handleChoose" :style="{backgroundColor: $config('primaryColor')}">选好了</view>
  55. </view>
  56. <!-- 查询右侧弹框 -->
  57. <productSearch :openModal="openModal" :defaultParams="searchForm" @refresh="refresh" @close="openModal=false" />
  58. </view>
  59. </template>
  60. <script>
  61. import ProductSearch from './productSearch.vue'
  62. import { toThousands } from '@/libs/tools'
  63. import { querySumByProductLocation } from '@/api/stock'
  64. export default{
  65. components: { ProductSearch },
  66. data(){
  67. return{
  68. toThousands,
  69. customBtnStyle: { // 自定义按钮样式
  70. borderColor: this.$config('primaryColor'),
  71. backgroundColor: this.$config('primaryColor'),
  72. color: '#fff'
  73. },
  74. listData: [],
  75. pageNo: 1,
  76. pageSize: 6,
  77. totalNum: 0,
  78. noDataText: '暂无数据',
  79. searchForm: {},
  80. searchParams: {},
  81. openModal: false,
  82. theme: '',
  83. chooseProductList: [],
  84. scrollH: 0,
  85. }
  86. },
  87. onLoad(opt) {
  88. this.theme = getApp().globalData.theme
  89. if(opt){
  90. this.chooseProductList = opt.data ? JSON.parse(opt.data) : null
  91. }
  92. console.log(this.chooseProductList)
  93. this.getList()
  94. const _this = this
  95. uni.getSystemInfo({
  96. success: function (res) {
  97. const winH = res.windowHeight * 2
  98. _this.scrollH = winH - 200
  99. }
  100. })
  101. },
  102. methods: {
  103. // 获取查询参数 刷新列表
  104. refresh(params){
  105. const _this = this
  106. this.searchParams = Object.assign(params, this.searchForm)
  107. this.getList(1)
  108. },
  109. // 列表
  110. getList(pageNo){
  111. const _this = this
  112. if (pageNo) {
  113. this.pageNo = pageNo
  114. }
  115. let params = {
  116. pageNo: this.pageNo,
  117. pageSize: this.pageSize
  118. }
  119. querySumByProductLocation(Object.assign(params, this.searchParams)).then(res => {
  120. if (res.status == 200) {
  121. if(this.pageNo>1){
  122. this.listData = this.listData.concat(res.data.list || [])
  123. }else{
  124. this.listData = res.data.list || []
  125. }
  126. this.totalNum = res.data.count || 0
  127. } else {
  128. this.listData = []
  129. this.totalNum = 0
  130. this.noDataText = res.message
  131. }
  132. })
  133. },
  134. // scroll-view到底部加载更多
  135. onreachBottom() {
  136. if(this.listData.length < this.totalNum){
  137. this.pageNo += 1
  138. this.getList()
  139. }
  140. },
  141. // 选好了
  142. handleChoose(){},
  143. // 查看已选产品
  144. lookProduct(){
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. .chooseProduct-wrap{
  151. width: 100%;
  152. position: relative;
  153. .padding_3{
  154. padding: 6upx 0;
  155. }
  156. .color_6{
  157. color: #666;
  158. }
  159. .product-list-box{
  160. padding: 20upx 20upx;
  161. .product-list-con{
  162. .product-list-item{
  163. background: #ffffff;
  164. padding: 20upx 20upx 0;
  165. margin-bottom: 25upx;
  166. border-radius: 25upx;
  167. box-shadow: 1px 1px 3px #EEEEEE;
  168. .list-item-tit{
  169. padding-bottom: 12upx;
  170. border-bottom: 1px solid #e4e7ed;
  171. .item-tit{
  172. font-weight: bold;
  173. color: rgb(48, 49, 51);
  174. font-size: 28upx;
  175. padding-left: 10upx;
  176. border-left: 6upx solid #000;
  177. line-height: 1;
  178. }
  179. }
  180. .list-item-con{
  181. padding: 14upx 14upx 16upx;
  182. font-size: 26upx;
  183. .pimgs{
  184. margin-right: 16upx;
  185. }
  186. }
  187. .list-item-footer{
  188. border-top: 1px solid #e4e7ed;
  189. .footer-item{
  190. width: 50%;
  191. text-align: center;
  192. border-right: 1px solid #e4e7ed;
  193. font-size: 26upx;
  194. padding: 8upx 0 12upx;
  195. }
  196. .footer-item:last-child{
  197. border: none;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. .selected-box{
  204. position: fixed;
  205. bottom: 0;
  206. left: 0;
  207. width: 100%;
  208. background-color: #fff;
  209. box-shadow: 1px -1px 3px #EEEEEE;
  210. .choose-info{
  211. padding: 0 30upx;
  212. }
  213. .choose-btn{
  214. color: #fff;
  215. width: 28%;
  216. padding: 26upx 0;
  217. text-align: center;
  218. }
  219. }
  220. }
  221. </style>