productList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="partList-box flex flex_column">
  3. <view class="partList-title flex align_center justify_between" v-if="partList.length">
  4. <text>{{title}}</text>
  5. <view class="heji">
  6. 共 <text>{{partList.length}}</text> 产品
  7. </view>
  8. </view>
  9. <view class="partList-list">
  10. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  11. <view class="product flex align_center">
  12. <view class="checkbox">
  13. <u-checkbox v-model="item.checked" :name="item.id" @change="checkChange" size="40" shape="circle"></u-checkbox>
  14. </view>
  15. <view class="flex align_center flex_1" @click="checkChange({name:item.id})">
  16. <view class="pimgs">
  17. <u-image :src="item.product&&item.product.images?item.product.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  18. </view>
  19. <view class="pinfo">
  20. <view class="pname">
  21. <text>{{item.shelfPlaceCode}}</text>{{item.productCode}}
  22. </view>
  23. <view class="pname pname1">
  24. {{item.product.productName}}
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 有复选框 -->
  30. <view class="ptools flex align_center justify_between">
  31. <view class="ptxt">
  32. 本次上架:<text class="pnums">{{item.qty}}{{item.product&&item.product.unit}}</text>
  33. </view>
  34. <view class="pcurnums flex align_center">
  35. <text>打印数量</text>
  36. <view class="u-ninput">
  37. <u-number-box :input-height="60" color="#000" bg-color="#fff" v-model="item.printQty" :min="1"></u-number-box>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="nodata" v-if="partList.length==0">
  43. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="120" :text="noDataText" img-width="120" mode="list"></u-empty>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. props: {
  51. list: {
  52. type: Array,
  53. default: function(){
  54. return []
  55. }
  56. },
  57. noDataText: {
  58. type: String,
  59. default: '暂无产品'
  60. },
  61. title: {
  62. type: String,
  63. default: '列表'
  64. },
  65. // model: checkbox 可选择模式,view 只显示
  66. model: {
  67. type: String,
  68. default: 'checkbox'
  69. },
  70. },
  71. data() {
  72. return {
  73. partList: [],
  74. }
  75. },
  76. methods: {
  77. setData(list){
  78. const _this = this
  79. list.map(item => {
  80. item.printQty = item.qty
  81. item.checked = false
  82. })
  83. this.partList = JSON.parse(JSON.stringify(list))
  84. },
  85. // 全选
  86. allSelect(val){
  87. this.partList.map(item => {
  88. item.checked = val
  89. })
  90. this.partList.splice()
  91. },
  92. checkChange(e){
  93. const row = this.partList.find(item => item.id == e.name)
  94. if(row){
  95. row.checked = !row.checked
  96. this.partList.splice()
  97. }
  98. // 判断是否全选
  99. const isAllNoChecked = this.partList.filter(item => !item.checked)
  100. this.$emit('allChecked',isAllNoChecked.length == 0)
  101. },
  102. // 获取所有选择的
  103. getAllChecked(){
  104. return this.partList.filter(item => item.checked && item.printQty)
  105. },
  106. // 获取所有数据
  107. getAllData(){
  108. return this.partList
  109. },
  110. // 数量 change
  111. numberChange(value, index){
  112. this.$emit('numberChange', value, index)
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="less" scoped>
  118. .partList-box{
  119. height: 100%;
  120. position: relative;
  121. .nodata{
  122. padding: 10vh 0;
  123. }
  124. .partList-title{
  125. padding: 15rpx 20rpx;
  126. border-bottom: 1rpx solid #eee;
  127. width: 100%;
  128. background-color: #fff;
  129. > text{
  130. font-size: 32rpx;
  131. color: #222222;
  132. }
  133. > view{
  134. font-size: 30rpx;
  135. text{
  136. color: red;
  137. margin: 0 5rpx;
  138. }
  139. }
  140. }
  141. .partList-list{
  142. flex-grow: 1;
  143. }
  144. .partList-list-box{
  145. padding: 10px 0;
  146. border-bottom: 2rpx solid #f5f5f5;
  147. &:last-child{
  148. border:0;
  149. }
  150. .product{
  151. flex-grow: 1;
  152. .checkbox{
  153. width: 60rpx;
  154. }
  155. .pinfo{
  156. flex-grow: 1;
  157. padding-left: 20rpx;
  158. .pname{
  159. color: #666;
  160. margin-bottom: 10rpx;
  161. text{
  162. font-weight: normal;
  163. margin-right: 6rpx;
  164. padding: 0 20rpx;
  165. background: rgba(3, 54, 146, 0.15);
  166. border-radius: 100rpx;
  167. color: #033692;
  168. font-size: 24rpx;
  169. }
  170. }
  171. .pname1{
  172. font-weight: bold;
  173. font-size: 30rpx;
  174. }
  175. .pno{
  176. background-color: rgba(3, 54, 146, 0.15);
  177. border-radius: 50rpx;
  178. padding: 0 20rpx;
  179. color: #033692;
  180. font-size: 24rpx;
  181. margin-right: 10rpx;
  182. }
  183. }
  184. }
  185. .ptools{
  186. margin-top: 20rpx;
  187. .ptxt{
  188. font-size: 28rpx;
  189. color: #999;
  190. .pnums{
  191. color: #222;
  192. padding: 0 4upx;
  193. }
  194. }
  195. .pcurnums{
  196. > text{
  197. margin-right: 20rpx;
  198. font-size: 28rpx;
  199. color: #999;
  200. }
  201. }
  202. .u-ninput{
  203. border: 2rpx solid #eee;
  204. border-radius: 50rpx;
  205. padding: 0 6rpx;
  206. }
  207. ::v-deep .u-icon-disabled{
  208. background: #fff!important;
  209. }
  210. ::v-deep .u-number-input{
  211. margin: 0 0;
  212. border: 2rpx solid #eee;
  213. border-top: 0;
  214. border-bottom: 0;
  215. }
  216. ::v-deep .u-icon-plus, ::v-deep .u-icon-minus{
  217. border-radius: 50rpx;
  218. }
  219. }
  220. }
  221. }
  222. </style>