add.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='盘库'></cus-header>
  4. <div class="box">
  5. <div class="title">盘库单基本信息</div>
  6. <div class="form">
  7. <div class="item">
  8. <div class="left"><span>*</span>盘库单号</div>
  9. <div class="right">
  10. <input type="text" placeholder-class="storage-inp-ph" placeholder="请输入盘库单号" v-model="checkDto.orderNo" @blur="e=>setReceipt(e,'orderNo')">
  11. </div>
  12. </div>
  13. <div class="item">
  14. <div class="left"><span>*</span>仓库</div>
  15. <div class="right">
  16. <text>{{checkDto.warehouseName}} ></text>
  17. </div>
  18. </div>
  19. <div class="item">
  20. <div class="left">盈亏数</div>
  21. <div class="right">
  22. <input type="text" v-model="checkDto.totalQuantity" disabled>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="box" :style="{'padding-bottom':checkDto.details.length?'0':'48rpx'}">
  28. <div class="title">商品明细</div>
  29. <div class="btn" @tap="toAddGoods">+ 新增库存</div>
  30. <div class="goods">
  31. <template v-if="checkDto.details.length">
  32. <div class="good" v-for="(good,idx) in checkDto.details" :key="good.skuId">
  33. <div class="title">
  34. <text>{{good.item.itemName}}</text>
  35. <image :src="imgBase+'storage/icon_remove_grey.png'" @tap="deleteGood(idx)" v-if="!good.id"></image>
  36. </div>
  37. <div class="info">
  38. <div>规格信息:<span>{{good.itemSku.skuName||''}} / {{good.itemSku.grossWeight||0}}kg / {{good.itemSku.width||0}}X{{good.itemSku.height||0}}cm</span></div>
  39. </div>
  40. <div class="info">
  41. <div>账面库存:<span>{{good.quantity||0}}</span></div>
  42. </div>
  43. <div class="info">
  44. <div>盈 亏 数:<span>{{good.profitLoss||0}}</span></div>
  45. </div>
  46. <div class="num">
  47. <text>实际库存:</text>
  48. <u-number-box v-model="good.checkQuantity" button-size="48" :integer="true" inputWidth="102rpx"
  49. @change="e=>changeStorageNum(e,idx)" bgColor="#F5F8FA"></u-number-box>
  50. </div>
  51. </div>
  52. </template>
  53. <div v-if="isLoading" class="loading">
  54. <u-loading-icon text="数据加载中..." textSize="32"></u-loading-icon>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="save">
  59. <div class="btn" @tap="saveReceipt">完成盘库</div>
  60. </div>
  61. <u-picker title="仓库" :show="warehouseShow" :columns="warehouseList" keyName="warehouseName"
  62. @cancel="warehouseShow=false" @confirm="warehouseConfirm" :immediateChange="true">
  63. </u-picker>
  64. </view>
  65. </template>
  66. <script>
  67. import { generateNo } from '@/utils/common.js'
  68. export default {
  69. data(){
  70. return {
  71. checkDto:{
  72. id: '',
  73. orderNo: '',
  74. orderStatus: 1,
  75. warehouseId: '',
  76. warehouseName: '',
  77. totalQuantity: 0,
  78. details: []
  79. },
  80. page:1,
  81. isOver:false,
  82. goodsList:[],
  83. isLoading:false
  84. }
  85. },
  86. onLoad(option) {
  87. this.checkDto.orderNo = generateNo('PK');
  88. this.checkDto.warehouseId = option.warehouseId;
  89. this.checkDto.warehouseName = option.warehouseName;
  90. this.getGoodList();
  91. },
  92. // onReachBottom() {
  93. // if(this.isOver) return
  94. // this.getGoodList();
  95. // },
  96. methods:{
  97. getGoodList(){
  98. this.isLoading = true;
  99. this.$api.get('/wms/inventory/boardList/item/?warehouseId='+this.checkDto.warehouseId+'&page='+this.page+'&limit=-1').then(res=>{
  100. if(res.data.code===0){
  101. // if(this.checkDto.details.length<res.data.data.total){
  102. // this.page++;
  103. this.checkDto.details = [...this.checkDto.details,...res.data.data.list];
  104. this.checkDto.details.forEach(d=>d.checkQuantity=+d.quantity);
  105. this.computeNum();
  106. this.isLoading = false;
  107. // }else this.isOver = true
  108. }else this.$showToast(res.data.msg)
  109. })
  110. },
  111. setReceipt(e,name){
  112. this.checkDto[name] = e.target.value;
  113. },
  114. toAddGoods(){
  115. let ids = this.goodsList.map(d=>d.skuId);
  116. let exitIds = this.checkDto.details.map(d=>d.skuId);
  117. uni.navigateTo({
  118. url:'/pagesStorage/checkStorage/goods?ids='+ids+'&exitIds='+exitIds,
  119. events:{
  120. addGoods:list=>{
  121. this.goodsList = list;
  122. this.goodsList.forEach((d,i)=>{
  123. d.quantity = 0;
  124. d.checkQuantity = d.checknum;
  125. })
  126. this.checkDto.details = [...this.checkDto.details,...this.goodsList];
  127. this.computeNum();
  128. }
  129. }
  130. })
  131. },
  132. deleteGood(index){
  133. this.checkDto.details.splice(index,1);
  134. this.$nextTick(()=>{
  135. this.computeNum();
  136. })
  137. },
  138. changeStorageNum(e,index){
  139. this.$set(this.checkDto.details[index],'checkQuantity',e.value);
  140. this.$set(this.checkDto.details[index],'profitLoss',+e.value-(+this.checkDto.details[index].quantity));
  141. this.$nextTick(()=>{
  142. this.computeNum();
  143. })
  144. },
  145. computeNum(){
  146. this.checkDto.totalQuantity = this.checkDto.details.reduce((cur,pre)=>cur+(pre.checkQuantity-pre.quantity),0);
  147. },
  148. saveReceipt(){
  149. if(!this.checkDto.orderNo) return this.$showToast('请输入盘库单号');
  150. if(!this.checkDto.warehouseId) return this.$showToast('请选择仓库');
  151. let temp = JSON.parse(JSON.stringify(this.checkDto.details));
  152. let details = temp.map(d=>{
  153. return {
  154. inventoryId: d?.id||'',
  155. skuId: d.itemSku.id,
  156. quantity: d.quantity,
  157. checkQuantity:d.checkQuantity,
  158. warehouseId: this.checkDto.warehouseId,
  159. }
  160. })
  161. this.checkDto.details = details;
  162. this.$api.post('/wms/checkOrder/check',this.checkDto).then(res=>{
  163. if(res.data.code===0){
  164. this.$showToast('盘库单新增成功');
  165. setTimeout(()=>{
  166. uni.redirectTo({
  167. url:'/pagesStorage/checkStorage/index'
  168. })
  169. },1500)
  170. }else this.$showToast(res.data.msg)
  171. })
  172. },
  173. }
  174. }
  175. </script>
  176. <style>
  177. .storage-inp-ph{
  178. color: #B9C0C8 !important;
  179. }
  180. </style>
  181. <style scoped lang="less">
  182. .page{
  183. padding: 0 24rpx 186rpx;
  184. background: #F4F8FB;
  185. box-sizing: border-box;
  186. .box{
  187. width: 100%;
  188. padding: 36rpx 24rpx;
  189. box-sizing: border-box;
  190. background: #FFFFFF;
  191. border-radius: 16rpx;
  192. margin-top: 20rpx;
  193. .title{
  194. font-family: PingFang-SC, PingFang-SC;
  195. font-weight: bold;
  196. font-size: 36rpx;
  197. color: #1D2129;
  198. line-height: 36rpx;
  199. text-align: left;
  200. }
  201. .form{
  202. width: 100%;
  203. margin-top: 36rpx;
  204. .item{
  205. width: 100%;
  206. height: 90rpx;
  207. background: #FFFFFF;
  208. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. .left{
  213. display: flex;
  214. align-items: center;
  215. font-family: PingFangSC, PingFang SC;
  216. font-weight: 400;
  217. font-size: 30rpx;
  218. color: #1D2129;
  219. line-height: 42rpx;
  220. text-align: left;
  221. span{
  222. color: #F95050;
  223. }
  224. }
  225. .right{
  226. input{
  227. font-family: PingFangSC, PingFang SC;
  228. font-weight: 400;
  229. font-size: 30rpx;
  230. color: #4E5969;
  231. line-height: 42rpx;
  232. text-align: right;
  233. }
  234. text{
  235. font-family: PingFangSC, PingFang SC;
  236. font-weight: 400;
  237. font-size: 30rpx;
  238. color: #4E5969;
  239. line-height: 42rpx;
  240. text-align: right;
  241. &.tip{
  242. color: #B9C0C8;
  243. }
  244. }
  245. }
  246. }
  247. .zdjs{
  248. font-family: PingFangSC, PingFang SC;
  249. font-weight: 400;
  250. font-size: 26rpx;
  251. color: #198CFF;
  252. line-height: 37rpx;
  253. text-align: right;
  254. margin-top: 9rpx;
  255. }
  256. }
  257. .btn{
  258. width: 100%;
  259. height: 64rpx;
  260. border-radius: 16rpx;
  261. border: 1rpx solid #198CFF;
  262. margin-top: 26rpx;
  263. font-family: PingFang-SC, PingFang-SC;
  264. font-weight: bold;
  265. font-size: 26rpx;
  266. color: #198CFF;
  267. line-height: 64rpx;
  268. text-align: center;
  269. letter-spacing: 2rpx;
  270. }
  271. .goods{
  272. width: 100%;
  273. margin-top: 10rpx;
  274. .good{
  275. width: 100%;
  276. padding: 36rpx 0;
  277. box-sizing: border-box;
  278. background: #FFFFFF;
  279. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  280. &>div{
  281. display: flex;
  282. align-items: center;
  283. justify-content: space-between;
  284. }
  285. .title{
  286. text{
  287. font-family: PingFang-SC, PingFang-SC;
  288. font-weight: bold;
  289. font-size: 30rpx;
  290. color: #1D2129;
  291. line-height: 30rpx;
  292. text-align: left;
  293. }
  294. image{
  295. width: 28rpx;
  296. height: 28rpx;
  297. }
  298. }
  299. .info{
  300. margin-top: 24rpx;
  301. font-family: PingFangSC, PingFang SC;
  302. font-weight: 400;
  303. font-size: 24rpx;
  304. color: #86909C;
  305. line-height: 24rpx;
  306. span{
  307. color: #4E5969;
  308. }
  309. }
  310. .num,.money{
  311. margin-top: 24rpx;
  312. text{
  313. font-family: PingFangSC, PingFang SC;
  314. font-weight: 400;
  315. font-size: 24rpx;
  316. color: #86909C;
  317. line-height: 24rpx;
  318. text-align: left;
  319. }
  320. }
  321. }
  322. .loading{
  323. width: 100%;
  324. padding: 70rpx 0 30rpx;
  325. display: flex;
  326. align-items: center;
  327. justify-content: center;
  328. }
  329. }
  330. }
  331. .save{
  332. width: 100%;
  333. height: 148rpx;
  334. padding: 20rpx 48rpx 0;
  335. box-sizing: border-box;
  336. background: #FFFFFF;
  337. position: fixed;
  338. left: 0;
  339. bottom: 0;
  340. .btn{
  341. width: 100%;
  342. height: 88rpx;
  343. background: #198CFF;
  344. border-radius: 16rpx;
  345. font-family: PingFang-SC, PingFang-SC;
  346. font-weight: bold;
  347. font-size: 32rpx;
  348. color: #FFFFFF;
  349. line-height: 88rpx;
  350. text-align: center;
  351. letter-spacing: 2rpx;
  352. }
  353. }
  354. }
  355. </style>