add.vue 8.9 KB

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