productList.vue 5.4 KB

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