OutgoingGoodsInventory.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view>
  3. <view class="sweep_code-ul">
  4. <block v-for="(item, index) in out_detail.details" :key="index">
  5. <view class="sweep_code-li clearfix" v-if="item.num > 0">
  6. <view class="clearfix logs-goods">
  7. <view class="float_left goods-img">
  8. <image :src="item.images[0]" mode="aspectFill"></image>
  9. <view class="all-tag" v-if="Number(item.notOutNum) === 0">全部出库</view>
  10. </view>
  11. <view class="float_left goods-info">
  12. <view class="goods-name ellipsis">{{ item.materielName }}</view>
  13. <view class="goods-sku">{{ item.unitName }};{{ item.skuName }}</view>
  14. <view class="stock-region clearfix">
  15. <text class="label">仓库:</text>
  16. {{ item.warehouseName }}
  17. </view>
  18. <view class="stock-region clearfix" v-if="item.storageLocationName">
  19. <text class="label">库区库位:</text>
  20. {{ item.areaName }}-{{ item.storageLocationName }}
  21. </view>
  22. </view>
  23. </view>
  24. <view class="bottom clearfix">
  25. <view class="float_left">
  26. <text>待出库:</text>
  27. <text class="num">{{ $utils.formatNub(item.total) }}</text>
  28. <block v-if="Number(item.total) !== Number(item.num)">
  29. <text style="margin-left: 10rpx;">未出库:</text>
  30. <text class="num" style="color: #FA6400;">{{ Number(item.notOutNum) }}</text>
  31. </block>
  32. </view>
  33. <view class="float_right">
  34. <text style="margin-right: 24rpx;">实出</text>
  35. <u-number-box :index="index" :min="0" :max="Number(item.maxOutNum)" :value="item.num" @change="numChange"></u-number-box>
  36. </view>
  37. </view>
  38. </view>
  39. </block>
  40. </view>
  41. <view class="inform" @click="lookpop">
  42. 未出库商品清单:商品{{ notMaterielNum }} 数量{{ notGoodsTotal }}
  43. <view class="float_right"><u-icon name="arrow-right" size="30" color="#FA6400"></u-icon></view>
  44. </view>
  45. <view class="submit-btn clearfix">
  46. <view class="submit-btn-left float_left">本次出库:商品{{ outMaterielNum }} 数量{{ outGoodsTotal }}</view>
  47. <view class="btn-right float_right" :class="[outMaterielNum < 1 ? 'btn-min-no' : '']" @click="tipshow = true">确认</view>
  48. </view>
  49. <u-modal
  50. v-model="tipshow"
  51. @cancel="modalCancel"
  52. @confirm="modalConfirm"
  53. :show-cancel-button="true"
  54. :content="`本次出库:商品${outMaterielNum} 数量${outGoodsTotal}`"
  55. ></u-modal>
  56. <u-popup v-model="no_out_show" mode="bottom">
  57. <view class="poptitle">未出库商品清单:商品{{ notMaterielNum }} 数量{{ notGoodsTotal }}</view>
  58. <view class="sweep_code-ul" style="padding-bottom: 20rpx;">
  59. <block v-for="(item, index) in notOutMateriels" :key="index">
  60. <view class="sweep_code-li clearfix" style="padding-top:0">
  61. <view class="clearfix logs-goods">
  62. <view class="float_left goods-img"><image :src="item.images[0]" mode="aspectFill"></image></view>
  63. <view class="float_left goods-info">
  64. <view class="goods-name ellipsis">{{ item.materielName }}</view>
  65. <view class="goods-sku">{{ item.unitName }};{{ item.skuName }}</view>
  66. <view class="goods-sku">
  67. 待出库:
  68. <text class="num">{{ item.notOutNum }}</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </block>
  74. </view>
  75. </u-popup>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. data() {
  81. return {
  82. no_out_show: false,
  83. tipshow: false,
  84. out_detail: {
  85. details: []
  86. },
  87. goods_list: [],
  88. no_goods_list: []
  89. };
  90. },
  91. watch: {},
  92. computed: {
  93. userInfo() {
  94. return this.$store.state.userInfo;
  95. },
  96. // 出库商品种类
  97. outMaterielNum() {
  98. const list = this.out_detail.details.filter(item => item.num > 0).map(item => item.skuId);
  99. return [...new Set(list)].length;
  100. },
  101. // 出库合计数量
  102. outGoodsTotal() {
  103. let num = 0;
  104. this.out_detail.details.forEach(item => {
  105. num = this.$NP.plus(Number(item.num), num);
  106. });
  107. return num;
  108. },
  109. // 未出库 合计数量
  110. notGoodsTotal() {
  111. let num = 0;
  112. this.out_detail.details.forEach(item => {
  113. if (item.notOutNum > 0) {
  114. num = this.$NP.plus(item.notOutNum, num);
  115. }
  116. });
  117. return num;
  118. },
  119. // 未出库 合计数量
  120. notMaterielNum() {
  121. const list = this.out_detail.details.filter(item => item.notOutNum > 0).map(item => item.skuId);
  122. return [...new Set(list)].length;
  123. },
  124. notOutMateriels() {
  125. const list = this.out_detail.details.filter(item => item.notOutNum > 0);
  126. return this.$utils.unique(list, ['materielId', 'skuId']);
  127. }
  128. },
  129. onLoad() {},
  130. onShow() {
  131. this.isFirst = true;
  132. this.out_detail = uni.getStorageSync('outDetail');
  133. setTimeout(() => {
  134. this.isFirst = false;
  135. }, 2000);
  136. },
  137. methods: {
  138. // 因为步进器组件 v-model 动态渲染失效,所以使用 v-bind:value
  139. // 但是 v-bind:value 首次会触发 change 事件
  140. // 所以加了个首次渲染标示 isFirst
  141. numChange({ value, index }) {
  142. if (this.isFirst) {
  143. return;
  144. }
  145. const detailObj = this.$u.deepClone(this.out_detail);
  146. const target = detailObj.details;
  147. target[index].num = value;
  148. // 统计当前已经出库的数量
  149. let outnum = 0;
  150. let otherOutnum = 0;
  151. target.forEach(item => {
  152. if (item.skuId === target[index].skuId) {
  153. outnum += item.num;
  154. if (item.warehouseId !== target[index].warehouseId) {
  155. otherOutnum += item.num;
  156. }
  157. }
  158. });
  159. // 设置最大值
  160. if (Number(target[index].locationNum) && Number(target[index].locationNum) > Number(target[index].total)) {
  161. target[index].maxOutNum = this.$NP.minus(target[index].total, otherOutnum);
  162. } else {
  163. target[index].maxOutNum = this.$NP.minus(target[index].locationNum || target[index].total, otherOutnum);
  164. }
  165. // 设置未出库数量
  166. target.forEach(item => {
  167. if (item.skuId === target[index].skuId) {
  168. item.notOutNum = this.$NP.minus(item.total, outnum) <= 0 ? 0 : this.$NP.minus(item.total, outnum);
  169. }
  170. });
  171. detailObj.details = target;
  172. this.out_detail = detailObj;
  173. // this.$set(this.out_detail.details[index], 'num', value);
  174. },
  175. lookpop() {
  176. this.no_out_show = true;
  177. },
  178. modalCancel() {
  179. this.tipshow = false;
  180. },
  181. modalConfirm() {
  182. // 未出库商品
  183. const UnassignedSkuData = this.out_detail.details.filter(item => item.num < item.total);
  184. // 出库商品
  185. const outData = this.out_detail.details.filter(item => item.num > 0);
  186. let outobj = {};
  187. outData.forEach(item => {
  188. if (outobj[item.warehouseId]) {
  189. outobj[item.warehouseId].details.push(item);
  190. } else {
  191. outobj[item.warehouseId] = {
  192. details: [item],
  193. warehouseId: item.warehouseId,
  194. warehouseName: item.warehouseName
  195. };
  196. }
  197. });
  198. const outWarehouseData = Object.values(outobj);
  199. this.$u.api
  200. .updateSaleOutStatus({
  201. id: this.out_detail.id,
  202. auditName: this.userInfo.name,
  203. UnassignedSkuData: UnassignedSkuData,
  204. outWarehouseData: outWarehouseData
  205. })
  206. .then(res => {
  207. this.$u.toast('出库成功!');
  208. this.modalCancel();
  209. this.goPage('/pagesT/stock/SalesOrder', 'redirectTo');
  210. });
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. .sweep_code-ul {
  217. padding-bottom: 200rpx;
  218. .sweep_code-li {
  219. margin-top: 20rpx;
  220. width: 100%;
  221. background-color: #ffffff;
  222. padding-top: 24rpx;
  223. .logs-goods {
  224. position: relative;
  225. }
  226. .goods-img {
  227. position: relative;
  228. width: 150rpx;
  229. height: 150rpx;
  230. margin-right: 20rpx;
  231. margin-left: 24rpx;
  232. border-radius: 10rpx;
  233. overflow: hidden;
  234. .all-tag {
  235. line-height: 36rpx;
  236. height: 36rpx;
  237. background-color: #2dc584;
  238. text-align: center;
  239. width: 100%;
  240. color: #ffffff;
  241. font-size: 22rpx;
  242. position: absolute;
  243. left: 0;
  244. bottom: 0;
  245. }
  246. image {
  247. width: 100%;
  248. height: 100%;
  249. display: block;
  250. }
  251. }
  252. .goods-info {
  253. width: 520rpx;
  254. .goods-name {
  255. height: 40rpx;
  256. line-height: 40rpx;
  257. }
  258. .goods-sku {
  259. padding-top: 10rpx;
  260. color: #879bba;
  261. font-size: 24rpx;
  262. }
  263. .stock-region {
  264. padding-top: 10rpx;
  265. color: #879bba;
  266. font-size: 24rpx;
  267. line-height: 40rpx;
  268. border-bottom: 1px solid $uni-color-primary;
  269. .label {
  270. display: inline-block;
  271. vertical-align: middle;
  272. width: 120rpx;
  273. margin-right: 10rpx;
  274. }
  275. }
  276. }
  277. }
  278. .bottom {
  279. margin-top: 20rpx;
  280. border-top: 1px solid #eeeeee;
  281. height: 80rpx;
  282. line-height: 80rpx;
  283. padding: 0 24rpx;
  284. .float_left {
  285. color: #879bba;
  286. width: 320rpx;
  287. font-size: 22rpx;
  288. .num {
  289. font-size: 26rpx;
  290. color: #2d405e;
  291. }
  292. }
  293. .float_right {
  294. font-size: 26rpx;
  295. }
  296. }
  297. }
  298. .submit_cont {
  299. position: absolute;
  300. top: 40%;
  301. left: 50%;
  302. font-size: 30rpx;
  303. transform: translate(-50%, -50%);
  304. }
  305. .submit-btn {
  306. padding: 0;
  307. .submit-btn-left {
  308. padding-left: 24rpx;
  309. font-size: 24rpx;
  310. color: #879bba;
  311. line-height: 98rpx;
  312. }
  313. .btn-right {
  314. text-align: center;
  315. width: 300rpx;
  316. color: #ffffff;
  317. background-color: $uni-color-primary;
  318. line-height: 98rpx;
  319. border-radius: 0;
  320. &.btn-min-no {
  321. background-color: #879bba;
  322. }
  323. }
  324. }
  325. .inform {
  326. z-index: 9;
  327. padding: 0 24rpx;
  328. position: fixed;
  329. left: 0;
  330. bottom: 98rpx;
  331. width: 100%;
  332. height: 80rpx;
  333. line-height: 80rpx;
  334. font-size: 24rpx;
  335. color: #fa6400;
  336. background: #fdecee;
  337. }
  338. .poptitle {
  339. padding: 0 24rpx;
  340. height: 80rpx;
  341. line-height: 80rpx;
  342. }
  343. .submit {
  344. width: 100%;
  345. position: absolute;
  346. bottom: 0;
  347. left: 0;
  348. height: 80rpx;
  349. font-size: 30rpx;
  350. text-align: center;
  351. line-height: 80rpx;
  352. border-top: 2rpx solid rgb(241, 243, 247);
  353. .submit_left {
  354. width: 50%;
  355. }
  356. .submit_right {
  357. width: 50%;
  358. }
  359. }
  360. </style>