partList.vue 8.2 KB

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