add.vue 15 KB

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