add.vue 16 KB

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