partList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="partList-box">
  3. <view class="partList-title flex align_center justify_between">
  4. <text>{{title}}</text>
  5. <view>{{list.length}}款,共<text>{{totalNums}}</text>件</view>
  6. </view>
  7. <view class="partList-list">
  8. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  9. <view class="product flex align_center">
  10. <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>
  11. <view class="flex align_center flex_1">
  12. <view class="pimgs">
  13. <u-image :src="item.product&&item.product.productMsg?item.product.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  14. </view>
  15. <view class="pinfo">
  16. <view class="pname" v-if="pageType=='replenishmentSign'">{{item.product&&item.product.name?item.product.name:'--'}}</view>
  17. <view class="pname" v-else>{{item.productName}}</view>
  18. <view class="ptxt flex align_center justify_between">
  19. <view>
  20. <text class="pcode" v-if="pageType=='replenishmentSign'">{{item.product&&item.product.code?item.product.code:'--'}}</text>
  21. <text class="pcode" v-else>{{item.productCode}}</text>
  22. </view>
  23. <view v-if="pageType=='replenishmentSign'">
  24. 实发数量:<text class="pnums">{{item.confirmQty}}个</text>
  25. </view>
  26. <view v-if="pageType=='recall'">
  27. 调回数量:<text class="pnums">{{item.qty}}个</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 有复选框 -->
  34. <view v-if="model == 'checkbox'" class="ptools flex align_center justify_between">
  35. <view></view>
  36. <view class="pcurnums flex align_center" v-if="pageType==''">
  37. <text>数量</text>
  38. <view class="u-ninput">
  39. <u-number-box color="#000" bg-color="#fff" v-model="item.retQty" :min="1" :max="item.qty"></u-number-box>
  40. </view>
  41. </view>
  42. <view class="pcurnums flex align_center" v-if="pageType=='recall'">
  43. <text>实退数量</text>
  44. <view class="u-ninput">
  45. <u-number-box color="#000" bg-color="#fff" v-model="item.quitQty" :min="1" :max="item.qty"></u-number-box>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 无复选框 -->
  50. <view v-if="model == 'view'" class="ptools flex align_center justify_between">
  51. <view></view>
  52. <view class="pcurnums flex align_center" v-if="pageType=='replenishmentSign'">
  53. <text>入库数量</text>
  54. <view class="u-ninput">
  55. <u-number-box color="#000" bg-color="#fff" v-model="item.putQty" @change="numberChange" :min="0" :max="item.confirmQty"></u-number-box>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="nodata" v-if="list.length==0">
  61. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="120" :text="noDataText" img-width="120" mode="list"></u-empty>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. props: {
  69. list: {
  70. type: Array,
  71. default: function(){
  72. return []
  73. }
  74. },
  75. noDataText: {
  76. type: String,
  77. default: '暂无配件'
  78. },
  79. title: {
  80. type: String,
  81. default: '列表'
  82. },
  83. // model: checkbox 可选择模式,view 只显示
  84. model: {
  85. type: String,
  86. default: 'checkbox'
  87. },
  88. // 那个功能页面调用,展示不同的字段,recall: 调回单,replenishmentSign:补货签收
  89. fromPage: {
  90. type: String,
  91. default: ''
  92. }
  93. },
  94. watch: {
  95. list(newValue, oldValue) {
  96. const _this = this
  97. newValue.map(item => {
  98. if(_this.pageType=='replenishmentSign'){ // 补货签收
  99. this.totalNums = this.totalNums + item.putQty
  100. }else{
  101. this.totalNums = this.totalNums + item.qty
  102. }
  103. item.quitQty = item.qty
  104. item.checked = false
  105. })
  106. this.partList = JSON.parse(JSON.stringify(newValue))
  107. this.pageType = this.fromPage
  108. }
  109. },
  110. onLoad() {
  111. this.theme = getApp().globalData.theme
  112. },
  113. data() {
  114. return {
  115. partList: this.list,
  116. totalNums: 0,
  117. pageType: this.fromPage,
  118. theme: ''
  119. }
  120. },
  121. methods: {
  122. // 全选
  123. allSelect(val){
  124. this.partList.map(item => {
  125. item.checked = val
  126. })
  127. this.partList.splice()
  128. },
  129. checkChange(e){
  130. const row = this.partList.find(item => item.id == e.name)
  131. console.log(row.checked)
  132. if(row){
  133. row.checked = !row.checked
  134. this.partList.splice()
  135. }
  136. // 判断是否全选
  137. const isAllNoChecked = this.partList.filter(item => !item.checked)
  138. this.$emit('allChecked',isAllNoChecked.length == 0)
  139. },
  140. // 获取所有选择的
  141. getAllChecked(){
  142. return this.partList.filter(item => item.checked)
  143. },
  144. // 获取所有数据
  145. getAllData(){
  146. return this.partList
  147. },
  148. // 数量 change
  149. numberChange(value, index){
  150. this.$emit('numberChange', value, index)
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="less" scoped>
  156. .partList-box{
  157. .nodata{
  158. padding: 10vh 0;
  159. }
  160. .partList-title{
  161. padding: 20rpx 0;
  162. > text{
  163. font-size: 32rpx;
  164. color: #222222;
  165. }
  166. > view{
  167. font-size: 32rpx;
  168. text{
  169. color: red;
  170. margin: 0 5rpx;
  171. }
  172. }
  173. }
  174. .partList-list-box{
  175. padding: 10px 0;
  176. border-bottom: 2rpx solid #f5f5f5;
  177. &:last-child{
  178. border:0;
  179. }
  180. .product{
  181. flex-grow: 1;
  182. .checkbox{
  183. width: 60rpx;
  184. }
  185. .pinfo{
  186. flex-grow: 1;
  187. padding-left: 20rpx;
  188. .pname{
  189. font-size: 32rpx;
  190. color: #191919;
  191. font-weight: bold;
  192. margin-bottom: 10rpx;
  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. }
  208. }
  209. }
  210. }
  211. .ptools{
  212. margin-top: 20rpx;
  213. .pcurnums{
  214. > text{
  215. margin-right: 20rpx;
  216. }
  217. }
  218. .u-ninput{
  219. border: 2rpx solid #eee;
  220. border-radius: 50rpx;
  221. padding: 0 6rpx;
  222. }
  223. /deep/ .u-icon-disabled{
  224. background: #fff!important;
  225. }
  226. /deep/ .u-number-input{
  227. margin: 0 0;
  228. border: 2rpx solid #eee;
  229. border-top: 0;
  230. border-bottom: 0;
  231. }
  232. /deep/ .u-icon-plus, /deep/ .u-icon-minus{
  233. border-radius: 50rpx;
  234. }
  235. }
  236. }
  237. }
  238. </style>