partList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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" v-if="model == '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 v-if="model == 'checkbox'" 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. title: {
  60. type: String,
  61. default: '列表'
  62. },
  63. // model: checkbox 可选择模式,view 只显示
  64. model: {
  65. type: String,
  66. default: 'checkbox'
  67. }
  68. },
  69. watch: {
  70. list(newValue, oldValue) {
  71. newValue.map(item => {
  72. this.totalNums = this.totalNums + item.qty
  73. item.quitQty = item.qty
  74. item.checked = false
  75. })
  76. this.partList = JSON.parse(JSON.stringify(newValue))
  77. }
  78. },
  79. data() {
  80. return {
  81. partList: this.list,
  82. totalNums: 0
  83. }
  84. },
  85. methods: {
  86. // 全选
  87. allSelect(val){
  88. this.partList.map(item => {
  89. item.checked = val
  90. })
  91. this.partList.splice()
  92. },
  93. checkChange(e){
  94. const row = this.partList.find(item => item.id == e.name)
  95. console.log(row.checked)
  96. if(row){
  97. row.checked = !row.checked
  98. this.partList.splice()
  99. }
  100. // 判断是否全选
  101. const isAllNoChecked = this.partList.filter(item => !item.checked)
  102. this.$emit('allChecked',isAllNoChecked.length == 0)
  103. },
  104. // 获取所有选择的
  105. getAllChecked(){
  106. return this.partList.filter(item => item.checked)
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="less" scoped>
  112. .partList-box{
  113. .nodata{
  114. padding: 10vh 0;
  115. }
  116. .partList-title{
  117. padding: 20rpx 0;
  118. > text{
  119. font-size: 32rpx;
  120. color: #222222;
  121. }
  122. > view{
  123. font-size: 32rpx;
  124. text{
  125. color: red;
  126. margin: 0 5rpx;
  127. }
  128. }
  129. }
  130. .partList-list-box{
  131. padding: 10px 0;
  132. border-bottom: 2rpx solid #f5f5f5;
  133. &:last-child{
  134. border:0;
  135. }
  136. .product{
  137. flex-grow: 1;
  138. .checkbox{
  139. width: 60rpx;
  140. }
  141. .pinfo{
  142. flex-grow: 1;
  143. padding-left: 20rpx;
  144. .pname{
  145. font-size: 32rpx;
  146. color: #191919;
  147. font-weight: bold;
  148. margin-bottom: 10rpx;
  149. }
  150. .pno{
  151. background-color: rgba(3, 54, 146, 0.15);
  152. border-radius: 50rpx;
  153. padding: 0 20rpx;
  154. color: #033692;
  155. font-size: 24rpx;
  156. margin-right: 10rpx;
  157. }
  158. .ptxt{
  159. font-size: 28rpx;
  160. color: #999;
  161. .pnums{
  162. color: #222;
  163. }
  164. }
  165. }
  166. }
  167. .ptools{
  168. margin-top: 20rpx;
  169. .pcurnums{
  170. > text{
  171. margin-right: 20rpx;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. </style>