productList.vue 5.0 KB

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