add.vue 13 KB

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