partList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 v-if="pageType=''">
  26. 数量:<text class="pnums">{{item.qty}}个</text>
  27. </view>
  28. <view v-if="pageType='recall'">
  29. 调回数量:<text class="pnums">{{item.qty}}个</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-if="model == 'checkbox'" class="ptools flex align_center justify_between">
  36. <view></view>
  37. <view class="pcurnums" v-if="pageType=''">
  38. <text>数量</text>
  39. <u-number-box v-model="item.retQty" :min="1" :max="item.qty"></u-number-box>
  40. </view>
  41. <view class="pcurnums" v-if="pageType='recall'">
  42. <text>实退数量</text>
  43. <u-number-box v-model="item.quitQty" :min="1" :max="item.qty"></u-number-box>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="nodata" v-if="list.length==0">
  48. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="120" :text="noDataText" img-width="120" mode="list"></u-empty>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. props: {
  56. list: {
  57. type: Array,
  58. default: function(){
  59. return []
  60. }
  61. },
  62. noDataText: {
  63. type: String,
  64. default: '暂无配件'
  65. },
  66. title: {
  67. type: String,
  68. default: '列表'
  69. },
  70. // model: checkbox 可选择模式,view 只显示
  71. model: {
  72. type: String,
  73. default: 'checkbox'
  74. },
  75. // 那个功能页面调用,展示不同的字段,recall: 调回单,
  76. fromPage: {
  77. type: String,
  78. default: ''
  79. }
  80. },
  81. watch: {
  82. list(newValue, oldValue) {
  83. newValue.map(item => {
  84. this.totalNums = this.totalNums + item.qty
  85. item.quitQty = item.qty
  86. item.checked = false
  87. })
  88. this.partList = JSON.parse(JSON.stringify(newValue))
  89. this.pageType = this.fromPage
  90. }
  91. },
  92. data() {
  93. return {
  94. partList: this.list,
  95. totalNums: 0,
  96. pageType: this.fromPage
  97. }
  98. },
  99. methods: {
  100. // 全选
  101. allSelect(val){
  102. this.partList.map(item => {
  103. item.checked = val
  104. })
  105. this.partList.splice()
  106. },
  107. checkChange(e){
  108. const row = this.partList.find(item => item.id == e.name)
  109. console.log(row.checked)
  110. if(row){
  111. row.checked = !row.checked
  112. this.partList.splice()
  113. }
  114. // 判断是否全选
  115. const isAllNoChecked = this.partList.filter(item => !item.checked)
  116. this.$emit('allChecked',isAllNoChecked.length == 0)
  117. },
  118. // 获取所有选择的
  119. getAllChecked(){
  120. return this.partList.filter(item => item.checked)
  121. },
  122. // 获取所有数据
  123. getAllData(){
  124. return this.partList
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="less" scoped>
  130. .partList-box{
  131. .nodata{
  132. padding: 10vh 0;
  133. }
  134. .partList-title{
  135. padding: 20rpx 0;
  136. > text{
  137. font-size: 32rpx;
  138. color: #222222;
  139. }
  140. > view{
  141. font-size: 32rpx;
  142. text{
  143. color: red;
  144. margin: 0 5rpx;
  145. }
  146. }
  147. }
  148. .partList-list-box{
  149. padding: 10px 0;
  150. border-bottom: 2rpx solid #f5f5f5;
  151. &:last-child{
  152. border:0;
  153. }
  154. .product{
  155. flex-grow: 1;
  156. .checkbox{
  157. width: 60rpx;
  158. }
  159. .pinfo{
  160. flex-grow: 1;
  161. padding-left: 20rpx;
  162. .pname{
  163. font-size: 32rpx;
  164. color: #191919;
  165. font-weight: bold;
  166. margin-bottom: 10rpx;
  167. }
  168. .pno{
  169. background-color: rgba(3, 54, 146, 0.15);
  170. border-radius: 50rpx;
  171. padding: 0 20rpx;
  172. color: #033692;
  173. font-size: 24rpx;
  174. margin-right: 10rpx;
  175. }
  176. .ptxt{
  177. font-size: 28rpx;
  178. color: #999;
  179. .pnums{
  180. color: #222;
  181. }
  182. }
  183. }
  184. }
  185. .ptools{
  186. margin-top: 20rpx;
  187. .pcurnums{
  188. > text{
  189. margin-right: 20rpx;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>