productList.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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">
  19. <view class="pimgs" @click="checkChange({name:item.id})">
  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" @click="checkChange({name:item.id})">
  24. <text>{{item.shelfPlaceCode}}</text>{{item.productCode}}
  25. </view>
  26. <view class="pname pname1" @click="checkChange({name:item.id})">
  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" :long-press="false" :input-height="60" 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.map(item => {
  95. item.printQty = this.printNum == 2 ? item.maxQty : item.qty
  96. })
  97. this.partList.splice()
  98. },
  99. // 全选
  100. allSelect(val){
  101. this.partList.map(item => {
  102. item.checked = val
  103. })
  104. this.partList.splice()
  105. },
  106. checkChange(e){
  107. const row = this.partList.find(item => item.id == e.name)
  108. if(row){
  109. row.checked = !row.checked
  110. this.partList.splice()
  111. }
  112. // 判断是否全选
  113. const isAllNoChecked = this.partList.filter(item => !item.checked)
  114. this.$emit('allChecked',isAllNoChecked.length == 0)
  115. },
  116. // 获取所有选择的
  117. getAllChecked(){
  118. return this.partList.filter(item => item.checked && item.printQty)
  119. },
  120. // 获取所有数据
  121. getAllData(){
  122. return this.partList
  123. },
  124. // 数量 change
  125. numberChange(value, index){
  126. this.$emit('numberChange', value, index)
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="less" scoped>
  132. .partList-box{
  133. height: 100%;
  134. position: relative;
  135. .nodata{
  136. padding: 10vh 0;
  137. }
  138. .partList-title{
  139. padding: 10rpx 20rpx;
  140. border-bottom: 1rpx solid #eee;
  141. width: 100%;
  142. position: fixed;
  143. left: 0;
  144. top: 0;
  145. background-color: #fff;
  146. z-index: 1000;
  147. > text{
  148. font-size: 32rpx;
  149. color: #222222;
  150. }
  151. > view{
  152. font-size: 32rpx;
  153. text{
  154. color: red;
  155. margin: 0 5rpx;
  156. }
  157. }
  158. }
  159. .partList-list{
  160. flex-grow: 1;
  161. padding-top: 70upx;
  162. }
  163. .partList-list-box{
  164. padding: 10px 0;
  165. border-bottom: 2rpx solid #f5f5f5;
  166. &:last-child{
  167. border:0;
  168. }
  169. .product{
  170. flex-grow: 1;
  171. .checkbox{
  172. width: 60rpx;
  173. }
  174. .pinfo{
  175. flex-grow: 1;
  176. padding-left: 20rpx;
  177. .pname{
  178. color: #666;
  179. margin-bottom: 10rpx;
  180. text{
  181. font-weight: normal;
  182. margin-right: 6rpx;
  183. padding: 0 20rpx;
  184. background: rgba(3, 54, 146, 0.15);
  185. border-radius: 100rpx;
  186. color: #033692;
  187. font-size: 24rpx;
  188. }
  189. }
  190. .pname1{
  191. font-weight: bold;
  192. font-size: 30rpx;
  193. }
  194. .pno{
  195. background-color: rgba(3, 54, 146, 0.15);
  196. border-radius: 50rpx;
  197. padding: 0 20rpx;
  198. color: #033692;
  199. font-size: 24rpx;
  200. margin-right: 10rpx;
  201. }
  202. .ptxt{
  203. font-size: 28rpx;
  204. color: #999;
  205. .pnums{
  206. color: #222;
  207. padding: 0 4upx;
  208. }
  209. }
  210. }
  211. }
  212. .ptools{
  213. margin-top: 20rpx;
  214. .pcurnums{
  215. > text{
  216. margin-right: 20rpx;
  217. }
  218. }
  219. .u-ninput{
  220. border: 2rpx solid #eee;
  221. border-radius: 50rpx;
  222. padding: 0 6rpx;
  223. }
  224. /deep/ .u-icon-disabled{
  225. background: #fff!important;
  226. }
  227. /deep/ .u-number-input{
  228. margin: 0 0;
  229. border: 2rpx solid #eee;
  230. border-top: 0;
  231. border-bottom: 0;
  232. }
  233. /deep/ .u-icon-plus, /deep/ .u-icon-minus{
  234. border-radius: 50rpx;
  235. }
  236. }
  237. }
  238. }
  239. </style>