add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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"><span>*</span>出库日期</div>
  36. <div class="right" @tap="dateShow = true">
  37. <text v-if="shipmentDto.shipmentDate">{{shipmentDto.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"><span>*</span>领料人</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" :immediateChange="true">
  100. </u-picker>
  101. <u-picker title="出库类型" :show="ShipmentTypeShow" :columns="ShipmentTypeList" keyName="dictLabel"
  102. @cancel="ShipmentTypeShow=false" @confirm="ShipmentTypeConfirm" :immediateChange="true">
  103. </u-picker>
  104. <u-picker title="客户" :show="merchantShow" :columns="merchantList" keyName="merchantName"
  105. @cancel="merchantShow=false" @confirm="merchantConfirm" :immediateChange="true">
  106. </u-picker>
  107. <u-calendar title='出库日期' :minDate="minDate" :maxDate="maxDate" :monthNum="5" :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. minDate:'',
  140. maxDate:''
  141. }
  142. },
  143. mounted() {
  144. this.shipmentDto.orderNo = generateNo('CK');
  145. this.minDate = new Date(new Date().setMonth(new Date().getMonth() - 3)).Format('yyyy-MM-dd');
  146. this.maxDate = new Date(new Date().setMonth(new Date().getMonth() + 1)).Format('yyyy-MM-dd');
  147. },
  148. methods:{
  149. selectWarehouse(){
  150. this.warehouseShow = true;
  151. this.$nextTick(()=>{
  152. this.$api.get('/wms/warehouse/page').then(res=>{
  153. if(res.data.code===0){
  154. this.warehouseList = [res.data.data.list];
  155. }else this.$showToast(res.data.msg)
  156. })
  157. })
  158. },
  159. warehouseConfirm(e){
  160. this.shipmentDto.warehouseId = e.value[0].id;
  161. this.shipmentDto.warehouseName = e.value[0].warehouseName;
  162. this.warehouseShow = false;
  163. },
  164. selectShipmentType(){
  165. this.ShipmentTypeShow = true;
  166. this.$nextTick(()=>{
  167. this.$api.get('/sys/dict/data/getListByType/wms_shipment_type').then(res=>{
  168. if(res.data.code===0){
  169. this.ShipmentTypeList = [res.data.data];
  170. }else this.$showToast(res.data.msg)
  171. })
  172. })
  173. },
  174. ShipmentTypeConfirm(e){
  175. this.shipmentDto.optType = e.value[0].dictValue;
  176. this.shipmentDto.optTypeName = e.value[0].dictLabel;
  177. this.ShipmentTypeShow = false;
  178. },
  179. selectMerchant(){
  180. this.merchantShow = true;
  181. this.$nextTick(()=>{
  182. this.$api.get('/wms/merchant/page').then(res=>{
  183. if(res.data.code===0){
  184. this.merchantList = [res.data.data.list];
  185. }else this.$showToast(res.data.msg)
  186. })
  187. })
  188. },
  189. merchantConfirm(e){
  190. this.shipmentDto.merchantId = e.value[0].id;
  191. this.shipmentDto.merchantName = e.value[0].merchantName;
  192. this.merchantShow = false;
  193. },
  194. setShipment(e,name){
  195. this.shipmentDto[name] = e.target.value;
  196. },
  197. autoCalculate(){
  198. this.shipmentDto.totalAmount = this.shipmentDto.details.reduce((cur,pre)=>cur+(+pre.amount||0),0);
  199. },
  200. toAddGoods(){
  201. if(!this.shipmentDto.warehouseId) return this.$showToast('请先选择仓库')
  202. let ids = this.shipmentDto.details.map(d=>d.skuId);
  203. uni.navigateTo({
  204. url:'/pagesStorage/outStorage/goods?ids='+ids+'&warehouseId='+this.shipmentDto.warehouseId,
  205. events:{
  206. addGoods:list=>{
  207. let aList = JSON.parse(JSON.stringify(list));
  208. this.shipmentDto.details.forEach(d=>{
  209. aList = list.filter(l=>l.skuId!=d.skuId)
  210. })
  211. aList.forEach((d,i)=>{
  212. let amount = d.checknum*d.itemSku.costPrice;
  213. this.$set(aList[i],'amount',amount);
  214. this.$set(aList[i],'quantity',d.checknum);
  215. })
  216. this.shipmentDto.details = [...this.shipmentDto.details,...aList];
  217. this.computeNum();
  218. this.autoCalculate();
  219. }
  220. }
  221. })
  222. },
  223. deleteGood(index){
  224. this.shipmentDto.details.splice(index,1);
  225. this.$nextTick(()=>{
  226. this.computeNum();
  227. this.autoCalculate();
  228. })
  229. },
  230. changeRkNum(e,index){
  231. this.$set(this.shipmentDto.details[index],'quantity',e.value);
  232. this.$nextTick(()=>{
  233. this.computeNum();
  234. })
  235. },
  236. changeRkMoney(e,index){
  237. this.$set(this.shipmentDto.details[index],'amount',e.value);
  238. this.autoCalculate();
  239. },
  240. computeNum(){
  241. this.shipmentDto.totalQuantity = this.shipmentDto.details.reduce((cur,pre)=>cur+pre.quantity,0);
  242. },
  243. saveShipment(){
  244. if(!this.shipmentDto.orderNo) return this.$showToast('请输入出库单号');
  245. if(!this.shipmentDto.warehouseId) return this.$showToast('请选择仓库');
  246. if(!this.shipmentDto.optType) return this.$showToast('请选择出库类型');
  247. if(!this.shipmentDto.shipmentDate) return this.$showToast('请选择出库日期');
  248. if(!this.shipmentDto.collector) return this.$showToast('请输入领料人');
  249. let temp = JSON.parse(JSON.stringify(this.shipmentDto.details));
  250. let details = temp.map(d=>{
  251. return {
  252. skuId: d.itemSku.id,
  253. amount: d.amount,
  254. quantity: d.quantity,
  255. warehouseId: this.shipmentDto.warehouseId,
  256. }
  257. })
  258. this.shipmentDto.details = details;
  259. this.$api.post('/wms/shipmentOrder/shipment',this.shipmentDto).then(res=>{
  260. if(res.data.code===0){
  261. this.$showToast('出库单新增成功');
  262. setTimeout(()=>{
  263. uni.redirectTo({
  264. url:'/pagesStorage/outStorage/index'
  265. })
  266. },1500)
  267. }else this.$showToast(res.data.msg)
  268. })
  269. },
  270. dateConfirm(e){
  271. this.shipmentDto.shipmentDate = e[0];
  272. this.dateShow = false;
  273. }
  274. }
  275. }
  276. </script>
  277. <style>
  278. .storage-inp-ph{
  279. color: #B9C0C8 !important;
  280. }
  281. </style>
  282. <style scoped lang="less">
  283. .page{
  284. padding: 0 24rpx 186rpx;
  285. background: #F4F8FB;
  286. box-sizing: border-box;
  287. .box{
  288. width: 100%;
  289. padding: 36rpx 24rpx;
  290. box-sizing: border-box;
  291. background: #FFFFFF;
  292. border-radius: 16rpx;
  293. margin-top: 20rpx;
  294. .title{
  295. font-family: PingFang-SC, PingFang-SC;
  296. font-weight: bold;
  297. font-size: 36rpx;
  298. color: #1D2129;
  299. line-height: 36rpx;
  300. text-align: left;
  301. }
  302. .form{
  303. width: 100%;
  304. margin-top: 36rpx;
  305. .item{
  306. width: 100%;
  307. height: 90rpx;
  308. background: #FFFFFF;
  309. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  310. display: flex;
  311. align-items: center;
  312. justify-content: space-between;
  313. .left{
  314. display: flex;
  315. align-items: center;
  316. font-family: PingFangSC, PingFang SC;
  317. font-weight: 400;
  318. font-size: 30rpx;
  319. color: #1D2129;
  320. line-height: 42rpx;
  321. text-align: left;
  322. span{
  323. color: #F95050;
  324. }
  325. }
  326. .right{
  327. input{
  328. font-family: PingFangSC, PingFang SC;
  329. font-weight: 400;
  330. font-size: 30rpx;
  331. color: #4E5969;
  332. line-height: 42rpx;
  333. text-align: right;
  334. }
  335. text{
  336. font-family: PingFangSC, PingFang SC;
  337. font-weight: 400;
  338. font-size: 30rpx;
  339. color: #4E5969;
  340. line-height: 42rpx;
  341. text-align: right;
  342. &.tip{
  343. color: #B9C0C8;
  344. }
  345. }
  346. }
  347. }
  348. .zdjs{
  349. font-family: PingFangSC, PingFang SC;
  350. font-weight: 400;
  351. font-size: 26rpx;
  352. color: #198CFF;
  353. line-height: 37rpx;
  354. text-align: right;
  355. margin-top: 9rpx;
  356. }
  357. }
  358. .btn{
  359. width: 100%;
  360. height: 64rpx;
  361. border-radius: 16rpx;
  362. border: 1rpx solid #198CFF;
  363. margin-top: 26rpx;
  364. font-family: PingFang-SC, PingFang-SC;
  365. font-weight: bold;
  366. font-size: 26rpx;
  367. color: #198CFF;
  368. line-height: 64rpx;
  369. text-align: center;
  370. letter-spacing: 2rpx;
  371. }
  372. .goods{
  373. width: 100%;
  374. margin-top: 10rpx;
  375. .good{
  376. width: 100%;
  377. padding: 36rpx 0;
  378. box-sizing: border-box;
  379. background: #FFFFFF;
  380. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #ECECEC;
  381. &>div{
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-between;
  385. }
  386. .title{
  387. text{
  388. font-family: PingFang-SC, PingFang-SC;
  389. font-weight: bold;
  390. font-size: 30rpx;
  391. color: #1D2129;
  392. line-height: 30rpx;
  393. text-align: left;
  394. }
  395. image{
  396. width: 28rpx;
  397. height: 28rpx;
  398. }
  399. }
  400. .info{
  401. margin-top: 24rpx;
  402. font-family: PingFangSC, PingFang SC;
  403. font-weight: 400;
  404. font-size: 24rpx;
  405. color: #86909C;
  406. line-height: 24rpx;
  407. span{
  408. color: #4E5969;
  409. }
  410. }
  411. .num,.money{
  412. margin-top: 24rpx;
  413. text{
  414. font-family: PingFangSC, PingFang SC;
  415. font-weight: 400;
  416. font-size: 24rpx;
  417. color: #86909C;
  418. line-height: 24rpx;
  419. text-align: left;
  420. }
  421. }
  422. }
  423. }
  424. }
  425. .save{
  426. width: 100%;
  427. height: 148rpx;
  428. padding: 20rpx 48rpx 0;
  429. box-sizing: border-box;
  430. background: #FFFFFF;
  431. position: fixed;
  432. left: 0;
  433. bottom: 0;
  434. .btn{
  435. width: 100%;
  436. height: 88rpx;
  437. background: #198CFF;
  438. border-radius: 16rpx;
  439. font-family: PingFang-SC, PingFang-SC;
  440. font-weight: bold;
  441. font-size: 32rpx;
  442. color: #FFFFFF;
  443. line-height: 88rpx;
  444. text-align: center;
  445. letter-spacing: 2rpx;
  446. }
  447. }
  448. }
  449. </style>