add.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. this.receiptDto.details = list;
  186. this.receiptDto.details.forEach((d,i)=>{
  187. let amount = d.checknum*d.itemSku.costPrice;
  188. this.$set(this.receiptDto.details[i],'amount',amount);
  189. this.$set(this.receiptDto.details[i],'quantity',d.checknum);
  190. })
  191. this.computeNum();
  192. }
  193. }
  194. })
  195. },
  196. deleteGood(index){
  197. this.receiptDto.details.splice(index,1);
  198. this.$nextTick(()=>{
  199. this.computeNum();
  200. })
  201. },
  202. changeRkNum(e,index){
  203. this.$set(this.receiptDto.details[index],'quantity',e.value);
  204. this.$nextTick(()=>{
  205. this.computeNum();
  206. })
  207. },
  208. changeRkMoney(e,index){
  209. this.$set(this.receiptDto.details[index],'amount',e.value);
  210. },
  211. computeNum(){
  212. this.receiptDto.totalQuantity = this.receiptDto.details.reduce((cur,pre)=>cur+pre.quantity,0);
  213. },
  214. saveReceipt(){
  215. if(!this.receiptDto.orderNo) return this.$showToast('请输入入库单号');
  216. if(!this.receiptDto.warehouseId) return this.$showToast('请选择仓库');
  217. let temp = JSON.parse(JSON.stringify(this.receiptDto.details));
  218. let details = temp.map(d=>{
  219. return {
  220. id: d?.id||'',
  221. skuId: d.itemSku.id,
  222. amount: d.amount,
  223. quantity: d.quantity,
  224. warehouseId: this.receiptDto.warehouseId,
  225. }
  226. })
  227. this.receiptDto.details = details;
  228. this.$api.post('/wms/receiptOrder',this.receiptDto).then(res=>{
  229. if(res.data.code===0){
  230. this.$showToast('入库单新增成功');
  231. setTimeout(()=>{
  232. uni.redirectTo({
  233. url:'/pagesStorage/inStorage/index'
  234. })
  235. },1500)
  236. }else this.$showToast(res.data.msg)
  237. })
  238. },
  239. }
  240. }
  241. </script>
  242. <style>
  243. .storage-inp-ph{
  244. color: #B9C0C8 !important;
  245. }
  246. </style>
  247. <style scoped lang="less">
  248. .page{
  249. padding: 0 24rpx 186rpx;
  250. background: #F4F8FB;
  251. box-sizing: border-box;
  252. .box{
  253. width: 100%;
  254. padding: 36rpx 24rpx;
  255. box-sizing: border-box;
  256. background: #FFFFFF;
  257. border-radius: 16rpx;
  258. margin-top: 20rpx;
  259. .title{
  260. font-family: PingFang-SC, PingFang-SC;
  261. font-weight: bold;
  262. font-size: 36rpx;
  263. color: #1D2129;
  264. line-height: 36rpx;
  265. text-align: left;
  266. }
  267. .form{
  268. width: 100%;
  269. margin-top: 36rpx;
  270. .item{
  271. width: 100%;
  272. height: 90rpx;
  273. background: #FFFFFF;
  274. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  275. display: flex;
  276. align-items: center;
  277. justify-content: space-between;
  278. .left{
  279. display: flex;
  280. align-items: center;
  281. font-family: PingFangSC, PingFang SC;
  282. font-weight: 400;
  283. font-size: 30rpx;
  284. color: #1D2129;
  285. line-height: 42rpx;
  286. text-align: left;
  287. span{
  288. color: #F95050;
  289. }
  290. }
  291. .right{
  292. input{
  293. font-family: PingFangSC, PingFang SC;
  294. font-weight: 400;
  295. font-size: 30rpx;
  296. color: #4E5969;
  297. line-height: 42rpx;
  298. text-align: right;
  299. }
  300. text{
  301. font-family: PingFangSC, PingFang SC;
  302. font-weight: 400;
  303. font-size: 30rpx;
  304. color: #4E5969;
  305. line-height: 42rpx;
  306. text-align: right;
  307. &.tip{
  308. color: #B9C0C8;
  309. }
  310. }
  311. }
  312. }
  313. .zdjs{
  314. font-family: PingFangSC, PingFang SC;
  315. font-weight: 400;
  316. font-size: 26rpx;
  317. color: #198CFF;
  318. line-height: 37rpx;
  319. text-align: right;
  320. margin-top: 9rpx;
  321. }
  322. }
  323. .btn{
  324. width: 100%;
  325. height: 64rpx;
  326. border-radius: 16rpx;
  327. border: 1rpx solid #198CFF;
  328. margin-top: 26rpx;
  329. font-family: PingFang-SC, PingFang-SC;
  330. font-weight: bold;
  331. font-size: 26rpx;
  332. color: #198CFF;
  333. line-height: 64rpx;
  334. text-align: center;
  335. letter-spacing: 2rpx;
  336. }
  337. .goods{
  338. width: 100%;
  339. margin-top: 10rpx;
  340. .good{
  341. width: 100%;
  342. padding: 36rpx 0;
  343. box-sizing: border-box;
  344. background: #FFFFFF;
  345. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  346. &>div{
  347. display: flex;
  348. align-items: center;
  349. justify-content: space-between;
  350. }
  351. .title{
  352. text{
  353. font-family: PingFang-SC, PingFang-SC;
  354. font-weight: bold;
  355. font-size: 30rpx;
  356. color: #1D2129;
  357. line-height: 30rpx;
  358. text-align: left;
  359. }
  360. image{
  361. width: 28rpx;
  362. height: 28rpx;
  363. }
  364. }
  365. .info{
  366. margin-top: 24rpx;
  367. font-family: PingFangSC, PingFang SC;
  368. font-weight: 400;
  369. font-size: 24rpx;
  370. color: #86909C;
  371. line-height: 24rpx;
  372. span{
  373. color: #4E5969;
  374. }
  375. }
  376. .num,.money{
  377. margin-top: 24rpx;
  378. text{
  379. font-family: PingFangSC, PingFang SC;
  380. font-weight: 400;
  381. font-size: 24rpx;
  382. color: #86909C;
  383. line-height: 24rpx;
  384. text-align: left;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .save{
  391. width: 100%;
  392. height: 148rpx;
  393. padding: 20rpx 48rpx 0;
  394. box-sizing: border-box;
  395. background: #FFFFFF;
  396. position: fixed;
  397. left: 0;
  398. bottom: 0;
  399. .btn{
  400. width: 100%;
  401. height: 88rpx;
  402. background: #198CFF;
  403. border-radius: 16rpx;
  404. font-family: PingFang-SC, PingFang-SC;
  405. font-weight: bold;
  406. font-size: 32rpx;
  407. color: #FFFFFF;
  408. line-height: 88rpx;
  409. text-align: center;
  410. letter-spacing: 2rpx;
  411. }
  412. }
  413. }
  414. </style>