partList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="partList-box">
  3. <view class="partList-title flex align_center justify_between">
  4. <text>配件列表</text>
  5. <view>
  6. {{list.length}}款,共<text>{{totalNums}}</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"><u-checkbox v-model="item.checked" :name="item.id" @change="checkChange" size="40" shape="circle"></u-checkbox></view>
  13. <view class="flex align_center flex_1">
  14. <view class="pimgs">
  15. <u-image width="128" height="128" border-radius="10"></u-image>
  16. </view>
  17. <view class="pinfo">
  18. <view class="pname">
  19. {{item.productName}}
  20. </view>
  21. <view class="ptxt flex align_center justify_between">
  22. <view>
  23. <text class="pcode">{{item.productCode}}</text>
  24. </view>
  25. <view>
  26. 调回数量:<text class="pnums">{{item.qty}}个</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="ptools flex align_center justify_between">
  33. <view></view>
  34. <view class="pcurnums">
  35. <text>实退数量</text>
  36. <u-number-box v-model="item.quitQty" :min="1" :max="item.qty"></u-number-box>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="nodata" v-if="list.length==0">
  41. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="120" :text="noDataText" img-width="120" mode="list"></u-empty>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. props: {
  49. list: {
  50. type: Array,
  51. default: function(){
  52. return []
  53. }
  54. },
  55. noDataText: {
  56. type: String,
  57. default: '暂无配件'
  58. }
  59. },
  60. watch: {
  61. list(newValue, oldValue) {
  62. newValue.map(item => {
  63. this.totalNums = this.totalNums + item.qty
  64. item.quitQty = item.qty
  65. item.checked = false
  66. })
  67. this.partList = JSON.parse(JSON.stringify(newValue))
  68. }
  69. },
  70. data() {
  71. return {
  72. partList: this.list,
  73. totalNums: 0
  74. }
  75. },
  76. methods: {
  77. // 全选
  78. allSelect(val){
  79. this.partList.map(item => {
  80. item.checked = val
  81. })
  82. this.partList.splice()
  83. },
  84. checkChange(e){
  85. const row = this.partList.find(item => item.id == e.name)
  86. console.log(row.checked)
  87. if(row){
  88. row.checked = !row.checked
  89. this.partList.splice()
  90. }
  91. // 判断是否全选
  92. const isAllNoChecked = this.partList.filter(item => !item.checked)
  93. this.$emit('allChecked',isAllNoChecked.length == 0)
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="less" scoped>
  99. .partList-box{
  100. .nodata{
  101. padding: 10vh 0;
  102. }
  103. .partList-title{
  104. padding: 20rpx 0;
  105. > text{
  106. font-size: 32rpx;
  107. color: #222222;
  108. }
  109. > view{
  110. font-size: 32rpx;
  111. text{
  112. color: red;
  113. margin: 0 5rpx;
  114. }
  115. }
  116. }
  117. .partList-list-box{
  118. padding: 10px 0;
  119. border-bottom: 2rpx solid #f5f5f5;
  120. &:last-child{
  121. border:0;
  122. }
  123. .product{
  124. flex-grow: 1;
  125. .checkbox{
  126. width: 60rpx;
  127. }
  128. .pinfo{
  129. flex-grow: 1;
  130. padding-left: 20rpx;
  131. .pname{
  132. font-size: 32rpx;
  133. color: #191919;
  134. font-weight: bold;
  135. margin-bottom: 10rpx;
  136. }
  137. .pno{
  138. background-color: rgba(3, 54, 146, 0.15);
  139. border-radius: 50rpx;
  140. padding: 0 20rpx;
  141. color: #033692;
  142. font-size: 24rpx;
  143. margin-right: 10rpx;
  144. }
  145. .ptxt{
  146. font-size: 28rpx;
  147. color: #999;
  148. .pnums{
  149. color: #222;
  150. }
  151. }
  152. }
  153. }
  154. .ptools{
  155. margin-top: 20rpx;
  156. .pcurnums{
  157. > text{
  158. margin-right: 20rpx;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. </style>