partList.vue 7.3 KB

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