add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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="receiptDto.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" @tap="selectWarehouse">
  16. <text v-if="receiptDto.warehouseName">{{receiptDto.warehouseName}} ></text>
  17. <text class="tip" v-else>请选择仓库 ></text>
  18. </div>
  19. </div>
  20. <div class="item">
  21. <div class="left"><span>*</span>入库类型</div>
  22. <div class="right" @tap="selectReceiptType">
  23. <text v-if="receiptDto.optTypeName">{{receiptDto.optTypeName}} ></text>
  24. <text class="tip" v-else>请选择 ></text>
  25. </div>
  26. </div>
  27. <div class="item">
  28. <div class="left">供应商</div>
  29. <div class="right" @tap="selectMerchant">
  30. <text v-if="receiptDto.merchantName">{{receiptDto.merchantName}} ></text>
  31. <text class="tip" v-else>请选择 ></text>
  32. </div>
  33. </div>
  34. <div class="item">
  35. <div class="left">到货日期</div>
  36. <div class="right" @tap="dateShow = true">
  37. <text v-if="receiptDto.arrivalDate">{{receiptDto.arrivalDate}} ></text>
  38. <text class="tip" v-else>请选择 ></text>
  39. </div>
  40. </div>
  41. <div class="item">
  42. <div class="left">业务单号</div>
  43. <div class="right">
  44. <input type="text" placeholder-class="storage-inp-ph" placeholder="请输入" v-model="receiptDto.bizOrderNo" @blur="e=>setReceipt(e,'bizOrderNo')">
  45. </div>
  46. </div>
  47. <!-- <div class="item">
  48. <div class="left">总数量</div>
  49. <div class="right">
  50. <input type="text" v-model="receiptDto.totalQuantity" disabled>
  51. </div>
  52. </div> -->
  53. <div class="item">
  54. <div class="left">采购负责人</div>
  55. <div class="right">
  56. <input type="text" placeholder-class="storage-inp-ph" placeholder="请输入" v-model="receiptDto.purchaser" @blur="e=>setReceipt(e,'purchaser')">
  57. </div>
  58. </div>
  59. <div class="item">
  60. <div class="left">总金额</div>
  61. <div class="right">
  62. <input type="text" placeholder-class="storage-inp-ph" placeholder="请输入" v-model="receiptDto.totalAmount" @blur="e=>setReceipt(e,'totalAmount')">
  63. </div>
  64. </div>
  65. <div class="zdjs" @tap="autoCalculate">自动计算</div>
  66. </div>
  67. </div>
  68. <div class="box" :style="{'padding-bottom':receiptDto.details.length?'0':'48rpx'}">
  69. <div class="title">商品明细</div>
  70. <div class="btns">
  71. <div class="btn" @tap="toAddGoods">+ 添加商品</div>
  72. <div class="btn" @tap="toScan">+ 扫码添加</div>
  73. </div>
  74. <div class="goods">
  75. <template v-if="receiptDto.details.length">
  76. <div class="good" v-for="(good,idx) in receiptDto.details" :key="good.skuId">
  77. <div class="title">
  78. <text>{{good.item.itemName}}</text>
  79. <image :src="imgBase+'storage/icon_remove_grey.png'" @tap="deleteGood(idx)"></image>
  80. </div>
  81. <div class="info">
  82. <div>规格信息:<span>{{good.itemSku.skuName||''}} / {{good.itemSku.grossWeight||0}}kg / {{good.itemSku.width||0}}X{{good.itemSku.height||0}}cm</span></div>
  83. </div>
  84. <div class="num">
  85. <text>入库数量:</text>
  86. <u-number-box v-model="good.quantity" button-size="48" :integer="true" inputWidth="102rpx"
  87. @change="e=>changeRkNum(e,idx)" bgColor="#F5F8FA"></u-number-box>
  88. </div>
  89. <div class="num">
  90. <text>金额:</text>
  91. <u-number-box v-model="good.amount" button-size="48" :integer="false" :canSmall="true" inputWidth="102rpx"
  92. @change="e=>changeRkMoney(e,idx)" bgColor="#F5F8FA"></u-number-box>
  93. </div>
  94. </div>
  95. </template>
  96. </div>
  97. </div>
  98. <div class="save">
  99. <div class="btn" @tap="saveReceipt">保存</div>
  100. </div>
  101. <u-picker title="仓库" :show="warehouseShow" :columns="warehouseList" keyName="warehouseName"
  102. @cancel="warehouseShow=false" @confirm="warehouseConfirm">
  103. </u-picker>
  104. <u-picker title="入库类型" :show="receiptTypeShow" :columns="receiptTypeList" keyName="dictLabel"
  105. @cancel="receiptTypeShow=false" @confirm="receiptTypeConfirm">
  106. </u-picker>
  107. <u-picker title="供应商" :show="merchantShow" :columns="merchantList" keyName="merchantName"
  108. @cancel="merchantShow=false" @confirm="merchantConfirm">
  109. </u-picker>
  110. <u-calendar title="到货日期" :minDate="minDate" :maxDate="maxDate" :monthNum="5" :show="dateShow" mode="single" @confirm="dateConfirm" @close="dateShow = false"></u-calendar>
  111. </view>
  112. </template>
  113. <script>
  114. import { generateNo } from '@/utils/common.js'
  115. export default {
  116. data(){
  117. return {
  118. receiptDto:{
  119. id: '',
  120. orderNo: '',
  121. optType: '',
  122. optTypeName: '',
  123. merchantId: '',
  124. merchantName: '',
  125. bizOrderNo: '',
  126. totalAmount: '',
  127. orderStatus: 1,
  128. warehouseId: '',
  129. warehouseName: '',
  130. totalQuantity: 0,
  131. purchaser:'',
  132. arrivalDate:'',
  133. details: []
  134. },
  135. warehouseShow:false,
  136. warehouseList:[],
  137. receiptTypeShow:false,
  138. receiptTypeList:[],
  139. merchantShow:false,
  140. merchantList:[],
  141. dateShow:false,
  142. minDate:'',
  143. maxDate:''
  144. }
  145. },
  146. mounted() {
  147. this.receiptDto.orderNo = generateNo('RK');
  148. this.minDate = new Date(new Date().setMonth(new Date().getMonth() - 3)).Format('yyyy-MM-dd');
  149. this.maxDate = new Date(new Date().setMonth(new Date().getMonth() + 1)).Format('yyyy-MM-dd');
  150. },
  151. methods:{
  152. selectWarehouse(){
  153. this.warehouseShow = true;
  154. this.$nextTick(()=>{
  155. this.$api.get('/wms/warehouse/page').then(res=>{
  156. if(res.data.code===0){
  157. this.warehouseList = [res.data.data.list];
  158. }else this.$showToast(res.data.msg)
  159. })
  160. })
  161. },
  162. warehouseConfirm(e){
  163. this.receiptDto.warehouseId = e.value[0].id;
  164. this.receiptDto.warehouseName = e.value[0].warehouseName;
  165. this.warehouseShow = false;
  166. },
  167. selectReceiptType(){
  168. this.receiptTypeShow = true;
  169. this.$nextTick(()=>{
  170. this.$api.get('/sys/dict/data/getListByType/wms_receipt_type').then(res=>{
  171. if(res.data.code===0){
  172. this.receiptTypeList = [res.data.data];
  173. }else this.$showToast(res.data.msg)
  174. })
  175. })
  176. },
  177. receiptTypeConfirm(e){
  178. this.receiptDto.optType = e.value[0].dictValue;
  179. this.receiptDto.optTypeName = e.value[0].dictLabel;
  180. this.receiptTypeShow = false;
  181. },
  182. selectMerchant(){
  183. this.merchantShow = true;
  184. this.$nextTick(()=>{
  185. this.$api.get('/wms/merchant/page').then(res=>{
  186. if(res.data.code===0){
  187. this.merchantList = [res.data.data.list];
  188. }else this.$showToast(res.data.msg)
  189. })
  190. })
  191. },
  192. merchantConfirm(e){
  193. this.receiptDto.merchantId = e.value[0].id;
  194. this.receiptDto.merchantName = e.value[0].merchantName;
  195. this.merchantShow = false;
  196. },
  197. setReceipt(e,name){
  198. this.receiptDto[name] = e.target.value;
  199. },
  200. autoCalculate(){
  201. this.receiptDto.totalAmount = this.receiptDto.details.reduce((cur,pre)=>cur+(+pre.amount||0),0);
  202. },
  203. toAddGoods(){
  204. let ids = this.receiptDto.details.map(d=>d.skuId);
  205. uni.navigateTo({
  206. url:'/pagesStorage/inStorage/goods?ids='+ids,
  207. events:{
  208. addGoods:list=>{
  209. let aList = JSON.parse(JSON.stringify(list));
  210. this.receiptDto.details.forEach(d=>{
  211. aList = aList.filter(l=>l.skuId!=d.skuId)
  212. })
  213. aList.forEach((d,i)=>{
  214. let amount = d.checknum*d.itemSku.costPrice;
  215. this.$set(aList[i],'amount',amount);
  216. this.$set(aList[i],'quantity',d.checknum);
  217. })
  218. this.receiptDto.details = [...this.receiptDto.details,...aList];
  219. this.computeNum();
  220. this.autoCalculate();
  221. }
  222. }
  223. })
  224. },
  225. toScan(){
  226. uni.navigateTo({
  227. url:'/pagesStorage/inStorage/scan',
  228. events:{
  229. addGoods:list=>{
  230. let aList = JSON.parse(JSON.stringify(list));
  231. this.receiptDto.details.forEach(d=>{
  232. aList = aList.filter(l=>l.skuId!=d.skuId)
  233. })
  234. this.receiptDto.details = [...this.receiptDto.details,...aList];
  235. this.computeNum();
  236. this.autoCalculate();
  237. }
  238. }
  239. })
  240. },
  241. deleteGood(index){
  242. this.receiptDto.details.splice(index,1);
  243. this.$nextTick(()=>{
  244. this.computeNum();
  245. this.autoCalculate();
  246. })
  247. },
  248. changeRkNum(e,index){
  249. this.$set(this.receiptDto.details[index],'quantity',e.value);
  250. this.$nextTick(()=>{
  251. this.computeNum();
  252. })
  253. },
  254. changeRkMoney(e,index){
  255. this.$set(this.receiptDto.details[index],'amount',e.value);
  256. this.autoCalculate();
  257. },
  258. computeNum(){
  259. this.receiptDto.totalQuantity = this.receiptDto.details.reduce((cur,pre)=>cur+pre.quantity,0);
  260. },
  261. saveReceipt(){
  262. if(!this.receiptDto.orderNo) return this.$showToast('请输入入库单号');
  263. if(!this.receiptDto.warehouseId) return this.$showToast('请选择仓库');
  264. if(!this.receiptDto.optType) return this.$showToast('请选择入库类型');
  265. let temp = JSON.parse(JSON.stringify(this.receiptDto.details));
  266. let details = temp.map(d=>{
  267. return {
  268. skuId: d.skuId,
  269. amount: d.amount,
  270. quantity: d.quantity,
  271. warehouseId: this.receiptDto.warehouseId,
  272. }
  273. })
  274. this.receiptDto.details = details;
  275. this.$api.post('/wms/receiptOrder/warehousing',this.receiptDto).then(res=>{
  276. if(res.data.code===0){
  277. this.$showToast('入库单新增成功');
  278. setTimeout(()=>{
  279. uni.redirectTo({
  280. url:'/pagesStorage/inStorage/index'
  281. })
  282. },1500)
  283. }else this.$showToast(res.data.msg)
  284. })
  285. },
  286. dateConfirm(e){
  287. this.receiptDto.arrivalDate = e[0];
  288. this.dateShow = false;
  289. }
  290. }
  291. }
  292. </script>
  293. <style>
  294. .storage-inp-ph{
  295. color: #B9C0C8 !important;
  296. }
  297. </style>
  298. <style scoped lang="less">
  299. .page{
  300. padding: 0 24rpx 186rpx;
  301. background: #F4F8FB;
  302. box-sizing: border-box;
  303. .box{
  304. width: 100%;
  305. padding: 36rpx 24rpx;
  306. box-sizing: border-box;
  307. background: #FFFFFF;
  308. border-radius: 16rpx;
  309. margin-top: 20rpx;
  310. .title{
  311. font-family: PingFang-SC, PingFang-SC;
  312. font-weight: bold;
  313. font-size: 36rpx;
  314. color: #1D2129;
  315. line-height: 36rpx;
  316. text-align: left;
  317. }
  318. .form{
  319. width: 100%;
  320. margin-top: 36rpx;
  321. .item{
  322. width: 100%;
  323. height: 90rpx;
  324. background: #FFFFFF;
  325. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  326. display: flex;
  327. align-items: center;
  328. justify-content: space-between;
  329. .left{
  330. display: flex;
  331. align-items: center;
  332. font-family: PingFangSC, PingFang SC;
  333. font-weight: 400;
  334. font-size: 30rpx;
  335. color: #1D2129;
  336. line-height: 42rpx;
  337. text-align: left;
  338. span{
  339. color: #F95050;
  340. }
  341. }
  342. .right{
  343. input{
  344. font-family: PingFangSC, PingFang SC;
  345. font-weight: 400;
  346. font-size: 30rpx;
  347. color: #4E5969;
  348. line-height: 42rpx;
  349. text-align: right;
  350. }
  351. text{
  352. font-family: PingFangSC, PingFang SC;
  353. font-weight: 400;
  354. font-size: 30rpx;
  355. color: #4E5969;
  356. line-height: 42rpx;
  357. text-align: right;
  358. &.tip{
  359. color: #B9C0C8;
  360. }
  361. }
  362. }
  363. }
  364. .zdjs{
  365. font-family: PingFangSC, PingFang SC;
  366. font-weight: 400;
  367. font-size: 26rpx;
  368. color: #198CFF;
  369. line-height: 37rpx;
  370. text-align: right;
  371. margin-top: 9rpx;
  372. }
  373. }
  374. .btns{
  375. width: 100%;
  376. height: 64rpx;
  377. display: flex;
  378. justify-content: space-between;
  379. margin-top: 26rpx;
  380. .btn{
  381. width: calc(50% - 12rpx);
  382. height: 62rpx;
  383. border-radius: 16rpx;
  384. border: 1rpx solid #198CFF;
  385. font-family: PingFang-SC, PingFang-SC;
  386. font-weight: bold;
  387. font-size: 26rpx;
  388. color: #198CFF;
  389. line-height: 62rpx;
  390. text-align: center;
  391. letter-spacing: 2rpx;
  392. }
  393. }
  394. .goods{
  395. width: 100%;
  396. margin-top: 10rpx;
  397. .good{
  398. width: 100%;
  399. padding: 36rpx 0;
  400. box-sizing: border-box;
  401. background: #FFFFFF;
  402. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  403. &>div{
  404. display: flex;
  405. align-items: center;
  406. justify-content: space-between;
  407. }
  408. .title{
  409. text{
  410. font-family: PingFang-SC, PingFang-SC;
  411. font-weight: bold;
  412. font-size: 30rpx;
  413. color: #1D2129;
  414. line-height: 30rpx;
  415. text-align: left;
  416. }
  417. image{
  418. width: 28rpx;
  419. height: 28rpx;
  420. }
  421. }
  422. .info{
  423. margin-top: 24rpx;
  424. font-family: PingFangSC, PingFang SC;
  425. font-weight: 400;
  426. font-size: 24rpx;
  427. color: #86909C;
  428. line-height: 24rpx;
  429. span{
  430. color: #4E5969;
  431. }
  432. }
  433. .num,.money{
  434. margin-top: 24rpx;
  435. text{
  436. font-family: PingFangSC, PingFang SC;
  437. font-weight: 400;
  438. font-size: 24rpx;
  439. color: #86909C;
  440. line-height: 24rpx;
  441. text-align: left;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. .save{
  448. width: 100%;
  449. height: 148rpx;
  450. padding: 20rpx 48rpx 0;
  451. box-sizing: border-box;
  452. background: #FFFFFF;
  453. position: fixed;
  454. left: 0;
  455. bottom: 0;
  456. z-index: 9;
  457. .btn{
  458. width: 100%;
  459. height: 88rpx;
  460. background: #198CFF;
  461. border-radius: 16rpx;
  462. font-family: PingFang-SC, PingFang-SC;
  463. font-weight: bold;
  464. font-size: 32rpx;
  465. color: #FFFFFF;
  466. line-height: 88rpx;
  467. text-align: center;
  468. letter-spacing: 2rpx;
  469. }
  470. }
  471. }
  472. </style>