add.vue 13 KB

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