add.vue 10 KB

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