add.vue 12 KB

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