partList.vue 7.7 KB

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