add.vue 9.2 KB

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