partList.vue 5.0 KB

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