add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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"><span>*</span>到货日期</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"><span>*</span>采购负责人</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" :immediateChange="true">
  103. </u-picker>
  104. <u-picker title="入库类型" :show="receiptTypeShow" :columns="receiptTypeList" keyName="dictLabel"
  105. @cancel="receiptTypeShow=false" @confirm="receiptTypeConfirm" :immediateChange="true">
  106. </u-picker>
  107. <u-picker title="供应商" :show="merchantShow" :columns="merchantList" keyName="merchantName"
  108. @cancel="merchantShow=false" @confirm="merchantConfirm" :immediateChange="true">
  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. if(!this.receiptDto.arrivalDate) return this.$showToast('请选择到货日期');
  266. if(!this.receiptDto.purchaser) return this.$showToast('请输入采购负责人');
  267. let temp = JSON.parse(JSON.stringify(this.receiptDto.details));
  268. let details = temp.map(d=>{
  269. return {
  270. skuId: d.skuId,
  271. amount: d.amount,
  272. quantity: d.quantity,
  273. warehouseId: this.receiptDto.warehouseId,
  274. }
  275. })
  276. this.receiptDto.details = details;
  277. this.$api.post('/wms/receiptOrder/warehousing',this.receiptDto).then(res=>{
  278. if(res.data.code===0){
  279. this.$showToast('入库单新增成功');
  280. setTimeout(()=>{
  281. uni.redirectTo({
  282. url:'/pagesStorage/inStorage/index'
  283. })
  284. },1500)
  285. }else this.$showToast(res.data.msg)
  286. })
  287. },
  288. dateConfirm(e){
  289. this.receiptDto.arrivalDate = e[0];
  290. this.dateShow = false;
  291. }
  292. }
  293. }
  294. </script>
  295. <style>
  296. .storage-inp-ph{
  297. color: #B9C0C8 !important;
  298. }
  299. </style>
  300. <style scoped lang="less">
  301. .page{
  302. padding: 0 24rpx 186rpx;
  303. background: #F4F8FB;
  304. box-sizing: border-box;
  305. .box{
  306. width: 100%;
  307. padding: 36rpx 24rpx;
  308. box-sizing: border-box;
  309. background: #FFFFFF;
  310. border-radius: 16rpx;
  311. margin-top: 20rpx;
  312. .title{
  313. font-family: PingFang-SC, PingFang-SC;
  314. font-weight: bold;
  315. font-size: 36rpx;
  316. color: #1D2129;
  317. line-height: 36rpx;
  318. text-align: left;
  319. }
  320. .form{
  321. width: 100%;
  322. margin-top: 36rpx;
  323. .item{
  324. width: 100%;
  325. height: 90rpx;
  326. background: #FFFFFF;
  327. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. .left{
  332. display: flex;
  333. align-items: center;
  334. font-family: PingFangSC, PingFang SC;
  335. font-weight: 400;
  336. font-size: 30rpx;
  337. color: #1D2129;
  338. line-height: 42rpx;
  339. text-align: left;
  340. span{
  341. color: #F95050;
  342. }
  343. }
  344. .right{
  345. input{
  346. font-family: PingFangSC, PingFang SC;
  347. font-weight: 400;
  348. font-size: 30rpx;
  349. color: #4E5969;
  350. line-height: 42rpx;
  351. text-align: right;
  352. }
  353. text{
  354. font-family: PingFangSC, PingFang SC;
  355. font-weight: 400;
  356. font-size: 30rpx;
  357. color: #4E5969;
  358. line-height: 42rpx;
  359. text-align: right;
  360. &.tip{
  361. color: #B9C0C8;
  362. }
  363. }
  364. }
  365. }
  366. .zdjs{
  367. font-family: PingFangSC, PingFang SC;
  368. font-weight: 400;
  369. font-size: 26rpx;
  370. color: #198CFF;
  371. line-height: 37rpx;
  372. text-align: right;
  373. margin-top: 9rpx;
  374. }
  375. }
  376. .btns{
  377. width: 100%;
  378. height: 64rpx;
  379. display: flex;
  380. justify-content: space-between;
  381. margin-top: 26rpx;
  382. .btn{
  383. width: calc(50% - 12rpx);
  384. height: 62rpx;
  385. border-radius: 16rpx;
  386. border: 1rpx solid #198CFF;
  387. font-family: PingFang-SC, PingFang-SC;
  388. font-weight: bold;
  389. font-size: 26rpx;
  390. color: #198CFF;
  391. line-height: 62rpx;
  392. text-align: center;
  393. letter-spacing: 2rpx;
  394. }
  395. }
  396. .goods{
  397. width: 100%;
  398. margin-top: 10rpx;
  399. .good{
  400. width: 100%;
  401. padding: 36rpx 0;
  402. box-sizing: border-box;
  403. background: #FFFFFF;
  404. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  405. &>div{
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. }
  410. .title{
  411. text{
  412. font-family: PingFang-SC, PingFang-SC;
  413. font-weight: bold;
  414. font-size: 30rpx;
  415. color: #1D2129;
  416. line-height: 30rpx;
  417. text-align: left;
  418. }
  419. image{
  420. width: 28rpx;
  421. height: 28rpx;
  422. }
  423. }
  424. .info{
  425. margin-top: 24rpx;
  426. font-family: PingFangSC, PingFang SC;
  427. font-weight: 400;
  428. font-size: 24rpx;
  429. color: #86909C;
  430. line-height: 24rpx;
  431. span{
  432. color: #4E5969;
  433. }
  434. }
  435. .num,.money{
  436. margin-top: 24rpx;
  437. text{
  438. font-family: PingFangSC, PingFang SC;
  439. font-weight: 400;
  440. font-size: 24rpx;
  441. color: #86909C;
  442. line-height: 24rpx;
  443. text-align: left;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. .save{
  450. width: 100%;
  451. height: 148rpx;
  452. padding: 20rpx 48rpx 0;
  453. box-sizing: border-box;
  454. background: #FFFFFF;
  455. position: fixed;
  456. left: 0;
  457. bottom: 0;
  458. z-index: 9;
  459. .btn{
  460. width: 100%;
  461. height: 88rpx;
  462. background: #198CFF;
  463. border-radius: 16rpx;
  464. font-family: PingFang-SC, PingFang-SC;
  465. font-weight: bold;
  466. font-size: 32rpx;
  467. color: #FFFFFF;
  468. line-height: 88rpx;
  469. text-align: center;
  470. letter-spacing: 2rpx;
  471. }
  472. }
  473. }
  474. </style>