goodsAllocation.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <!-- 选择货位 -->
  3. <view class="assign-container">
  4. <u-popup :show="popShow" @close="close">
  5. <view class="main">
  6. <view class="tag-wrap">
  7. <view class="item" v-for="item in tag" :key="item.name">
  8. <view class="tag" :class="item.color">
  9. </view>
  10. <view class="label">
  11. {{item.name}}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="hw-wrap">
  16. <view class="item" @click="handlCurrent(item)"
  17. :class="[dict.type[item.allocationStatus],item.goodsAllocationId == current.goodsAllocationId ? 'active' :'']"
  18. v-for="(item,index) in dataInfo" :key="index">
  19. {{item.goodsAllocationCode}}
  20. </view>
  21. </view>
  22. <view class="fixed-bottom">
  23. <view class="item" @click="close">
  24. 取消
  25. </view>
  26. <view class="item s1" @click="confirm">
  27. 确定
  28. </view>
  29. </view>
  30. </view>
  31. </u-popup>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. post,
  37. get,
  38. postJ
  39. } from '@/utils/api.js'
  40. export default {
  41. props:{
  42. dataInfo:{
  43. type:Array,
  44. default(){
  45. return []
  46. }
  47. }
  48. },
  49. data() {
  50. return {
  51. popShow: false,
  52. tag: [{
  53. name: '空置',
  54. color: 'kz'
  55. },
  56. {
  57. name: '在用',
  58. color: 'zy'
  59. },
  60. {
  61. name: '已满',
  62. color: 'ym'
  63. },
  64. {
  65. name: '失效',
  66. color: 'sx'
  67. }
  68. ],
  69. dataList: [{
  70. name: 'D002',
  71. id: 1,
  72. type: 0
  73. },
  74. {
  75. name: 'D003',
  76. id: 2,
  77. type: 1
  78. },
  79. {
  80. name: 'D004',
  81. id: 3,
  82. type: 2
  83. },
  84. {
  85. name: 'D001',
  86. id: 4,
  87. type: 3
  88. },
  89. ],
  90. current: '',
  91. dict: {
  92. type: {
  93. 1: 'kz',
  94. 2: 'zy',
  95. 3: 'ym',
  96. 4: 'sx',
  97. }
  98. }
  99. }
  100. },
  101. created() {
  102. },
  103. methods: {
  104. open() {
  105. this.popShow = true
  106. },
  107. close() {
  108. this.popShow = false
  109. // 重置
  110. this.current = ''
  111. },
  112. handlCurrent(item) {
  113. if(item.type == 3 || item.type == 4){
  114. uni.showToast({
  115. title: '货位已满或失效',
  116. icon: 'none'
  117. })
  118. return
  119. }
  120. this.current = item
  121. },
  122. confirm() {
  123. if(!this.current){
  124. uni.showToast({
  125. title: '请选择货位',
  126. icon: 'none'
  127. })
  128. }
  129. this.$emit('succeed',{
  130. data:this.current
  131. })
  132. this.close()
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. $cols: 5; // 列数
  139. $marginWidth: 10rpx; // 间隔
  140. .main {
  141. padding: 20rpx;
  142. position: relative;
  143. .kz {
  144. background: #caf982;
  145. }
  146. .zy {
  147. background: #81d3f8;
  148. }
  149. .ym {
  150. background: #ff0e0e;
  151. }
  152. .sx {
  153. background: #d7d7d7;
  154. }
  155. .tag-wrap {
  156. display: flex;
  157. justify-content: center;
  158. margin-bottom: 20rpx;
  159. .item {
  160. display: flex;
  161. justify-content: center;
  162. align-items: center;
  163. margin: 0 10rpx;
  164. .tag {
  165. width: 26rpx;
  166. height: 26rpx;
  167. }
  168. .label {
  169. font-size: 28rpx;
  170. color: #333;
  171. margin-left: 10rpx;
  172. }
  173. }
  174. }
  175. .hw-wrap {
  176. display: flex;
  177. flex-wrap: wrap;
  178. align-content: flex-start;
  179. min-height: 300rpx;
  180. max-height: 800rpx;
  181. overflow-y: auto;
  182. .item {
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. height: 90rpx;
  187. width: calc((100% - #{($cols - 1) * $marginWidth}) / #{$cols});
  188. margin-left: $marginWidth;
  189. margin-bottom: $marginWidth;
  190. box-sizing: border-box;
  191. &.active {
  192. border: 4rpx solid #b8741a;
  193. }
  194. }
  195. .item:nth-of-type(#{$cols}n + 1) {
  196. margin-left: 0;
  197. }
  198. }
  199. }
  200. .fixed-bottom {
  201. margin-top: 20rpx;
  202. background-color: #fff;
  203. width: 100%;
  204. box-sizing: border-box;
  205. display: flex;
  206. border: 1px solid #157a2c;
  207. .item {
  208. flex: 1;
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. height: 80rpx;
  213. font-size: 28rpx;
  214. color: #333;
  215. &.s1 {
  216. background-color: #157a2c;
  217. color: #fff;
  218. }
  219. }
  220. }
  221. </style>