chooseProduct.vue 6.3 KB

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