carpoolModal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <el-drawer v-loading="load" :title="'订单发货(共' + data.length + '单)'" :visible.sync="drawer" :direction="direction"
  3. size="50%">
  4. <div class="content">
  5. <div class="order-cont" v-if="data && data[0]">
  6. <div class="cont-left">
  7. <!-- <div class="order-code">订单号:{{data[0].id}}</div> -->
  8. <div class="order-other">
  9. <div class="receive-name">姓名:{{ data[0].receiverName }}</div>
  10. <div class="address">目的地:<span>{{ data[0].receiverProvince + '-' + data[0].receiverCity }}</span></div>
  11. <!-- <div class="time">预计送达:8月6日 12:00前</div> -->
  12. </div>
  13. </div>
  14. <!-- <i class="el-icon-arrow-right"></i> -->
  15. </div>
  16. <deliveryGoodsInfo :hideOrderCode="true" :sendState="true" @editState="editState" @editResult="editResult"
  17. @emptyInventory="emptyInventory" ref="info" />
  18. <!-- <deliveryPrice v-if="priceData && priceData.length > 0" :data="priceData" :currentValue="currentPrice" @prichChange="prichChange" /> -->
  19. </div>
  20. <div class="space"></div>
  21. <div class="deli-footer">
  22. <div class="d-left">
  23. <!-- <div class="estimate-total">
  24. 预计总价<span class="total">¥{{currentPrice.estimateFreight?currentPrice.estimateFreight:'0.00'}}</span>
  25. </div>
  26. <div class="agreement">
  27. <el-checkbox v-model="checked">已读并同意《XXX电子运单协议》</el-checkbox>
  28. </div> -->
  29. </div>
  30. <div class="send-btn" @click="btn">确认发货</div>
  31. </div>
  32. </el-drawer>
  33. </template>
  34. <script lang="ts">
  35. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  36. import DeliveryGoodsInfo from "./deliveryGoodsInfo.vue";
  37. import DeliveryPrice from "./deliveryPrice.vue";
  38. import { add, multiply, subtract, divide } from '@/benyun/utils/accuracy'
  39. import { getMultipleToOnePrice, addMultipleToOne, getInventoryByStoreHouseIdAndSkuids } from '@/api/delivery'
  40. import api from '@/api/currency'
  41. import Format from '@/benyun/utils/dateFormat'
  42. @Component({ components: { DeliveryGoodsInfo, DeliveryPrice } })
  43. export default class CarpoolModal extends Vue {
  44. isEmptyInventory: boolean = false;
  45. drawer = false;
  46. direction = 'rtl'
  47. checked = false;
  48. stopHandle = false;
  49. load = false;
  50. onAct = '1';
  51. data: Array<any> = [];
  52. priceData: Array<any> = []
  53. currentPrice: any = {}
  54. value: any = {};
  55. setShow(v: boolean) {
  56. this.drawer = v;
  57. this.stopHandle = false;
  58. this.priceData = [];
  59. this.currentPrice = {}
  60. }
  61. setValue(data: Array<any>) {
  62. this.data = data;
  63. this.value = {};
  64. this.value.tmsTransportMethod = '整车';
  65. this.value.tmsBusinessMan = (this as any).$store.getters.userInfo.nickName;
  66. this.value.tmsBusinessPhone = (this as any).$store.getters.userInfo.phonenumber;
  67. this.value.subItem = [];
  68. this.value.weight = data[0].weight;
  69. this.value.tmsUnloadingProvince = data[0].receiverProvince;
  70. this.value.tmsUnloadingProvinceNo = data[0].receiverProvinceCode;
  71. this.value.tmsUnloadingCity = data[0].receiverCity;
  72. this.value.tmsUnloadingCityNo = data[0].receiverCityCode;
  73. this.value.tmsUnloadingRegion = data[0].receiverDistrict;
  74. this.value.tmsUnloadingRegionNo = data[0].receiverDistrictCode;
  75. this.value.tmsUnloadingStreet = data[0].receiverTown;
  76. this.value.tmsUnloadingStreetNo = data[0].receiverTownCode;
  77. this.value.tmsUnloadingAddress = data[0].receiverAddress;
  78. this.value.tmsUnloadingConsignor = data[0].receiverName;
  79. this.value.tmsUnloadingContacts = data[0].receiverMobile;
  80. this.value.wmsSendType = 'B2BCK';
  81. this.value.tmsArrivalDate = this.getTime(3600 * 1000 * 24 * 2);
  82. this.value.tmsDeliveryDate = this.getTime(3600 * 1000 * (24 * 2 + 2));
  83. this.checked = false;
  84. const requestId = new Date().getTime() + this.getUuid();
  85. this.value.requestId = requestId;
  86. for (let item of data) {
  87. if (item.items) {
  88. for (const i of item.items) {
  89. let total: any = 0;
  90. if (Number(i.qty) && Number(i.price)) {
  91. total = multiply(Number(i.qty), Number(i.price))
  92. }
  93. this.value.subItem.push({
  94. requestId: requestId,
  95. omsOrderId: item.id,
  96. isGift: i.isGift,
  97. barCode: i.barCode,
  98. omsOrderItemId: i.itemId,
  99. tmsGoodsModel: i.styleId,
  100. tmsGoodsCode: i.skuId,
  101. // omsOrderItemSkuId:i.itemId,
  102. tmsQuantity: Number(i.qty) ? Number(i.qty) : 0,
  103. remainAmount: 0,
  104. tmsGoodsTotalPrice: total,
  105. name: i.name,
  106. price: i.price,
  107. weight: i.weight
  108. })
  109. }
  110. }
  111. }
  112. this.loadWarehouse()
  113. // this.$nextTick(()=>{
  114. // (this.$refs.info as any).setValue(this.value);
  115. // this.drawer = false;
  116. // (this.$refs.info as any).showModal = true;
  117. // })
  118. }
  119. loadWarehouse() {
  120. api.pageList({
  121. pageNo: 1,
  122. pageSize: 1000
  123. }, 'maindataStorehouse').then((res: any) => {
  124. let warehouseData = res.data.records;
  125. if (warehouseData.length > 0) {
  126. this.value.tmsShipmentConsignor = warehouseData[0].shipper;
  127. this.value.tmsShipmentContacts = warehouseData[0].shipperPhone;
  128. this.value.tmsShipmentProvince = warehouseData[0].province;
  129. this.value.tmsShipmentProvinceNo = warehouseData[0].provinceCode;
  130. this.value.tmsShipmentCity = warehouseData[0].city;
  131. this.value.tmsShipmentCityNo = warehouseData[0].cityCode;
  132. this.value.tmsShipmentRegion = warehouseData[0].region;
  133. this.value.tmsShipmentRegionNo = warehouseData[0].regionCode;
  134. this.value.tmsShipmentStreetNo = warehouseData[0].streetCode;
  135. this.value.tmsShipmentStreet = warehouseData[0].street;
  136. this.value.tmsShipmentAddress = warehouseData[0].address;
  137. this.value.storeHouseId = warehouseData[0].id;
  138. this.value.storeHouseName = warehouseData[0].name;
  139. (this.$refs.info as any).setValue(this.value);
  140. }
  141. }).catch(() => { })
  142. }
  143. getTime(n: number) {
  144. const start = new Date();
  145. start.setTime(start.getTime() + n);
  146. const t = Format(new Date(start), 'yyyy-MM-dd HH:mm:ss');
  147. return t
  148. }
  149. getUuid() {
  150. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  151. }
  152. prichChange(index: number) {
  153. this.currentPrice = this.priceData[index];
  154. this.$forceUpdate();
  155. }
  156. getPriceInfo(data: any) {
  157. let params: any = {};
  158. params.startStoreHouseId = data.storeHouseId;
  159. // params.startAddressCode = data.tmsShipmentCityNo + '00000';
  160. params.endAddressCode = data.tmsUnloadingCityNo + '00000';
  161. params.planType = data.tmsTransportMethod;
  162. params.omsIds = [];
  163. for (const item of this.data) {
  164. params.omsIds.push(item.id);
  165. }
  166. this.load = true;
  167. getMultipleToOnePrice(params).then((res: any) => {
  168. this.load = false;
  169. let current: any = null;
  170. for (let item of res.data[0].data) {
  171. let d = new Date().getTime() + item.duration * 60 * 60 * 1000;
  172. item.endTime = Format(new Date(d), 'MM月dd日 HH:mm');
  173. if (!current) current = item;
  174. if (Number(current.estimateFreight) > Number(item.estimateFreight)) {
  175. current = item
  176. }
  177. }
  178. this.priceData = res.data[0].data;
  179. this.currentPrice = current;
  180. }).catch((err: any) => {
  181. this.load = false;
  182. })
  183. }
  184. btn() {
  185. if (this.isEmptyInventory) {
  186. this.$message('订单商品暂无库存');
  187. }
  188. // if(this.stopHandle){
  189. // this.$message('库存不足!')
  190. // return
  191. // }
  192. // if(!this.checked){
  193. // this.$message('请阅读并同意运单协议!')
  194. // return
  195. // }
  196. if (!this.value.tmsBusinessMan || !this.value.tmsBusinessPhone || !this.value.tmsShipmentConsignor || !this.value.tmsShipmentContacts || !this.value.tmsUnloadingConsignor || !this.value.tmsUnloadingContacts || !this.value.tmsUnloadingProvince || !this.value.tmsUnloadingAddress || !this.value.storeHouseId) {
  197. this.$message("订单信息不完整,请编辑信息!");
  198. return
  199. }
  200. if (this.value.tmsBusinessMan.length > 10) {
  201. this.$message("业务员名称不能超过10个字符!");
  202. return
  203. }
  204. let params: any = (this as any).$lodash.cloneDeep(this.value);
  205. // if(this.priceData){
  206. // try{
  207. // params.pricePlan = JSON.stringify(this.priceData)
  208. // }catch(e){}
  209. // }
  210. // if(this.currentPrice){
  211. // params.priceId = this.currentPrice.id;
  212. // }
  213. params.omsOrderIds = []
  214. for (const item of this.data) {
  215. params.omsOrderIds.push(item.id);
  216. }
  217. params.tmsMaterials = [];
  218. if (this.value.subItem) {
  219. for (const item of this.value.subItem) {
  220. params.tmsMaterials.push({
  221. storeHouseId: this.value.storeHouseId,
  222. materialSkuId: item.omsOrderItemId,
  223. qty: item.tmsQuantity
  224. })
  225. }
  226. }
  227. delete params.subItem;
  228. this.load = true;
  229. addMultipleToOne(params).then((res: any) => {
  230. this.load = false;
  231. if (res.code == 200) {
  232. this.$message({
  233. message: '订单发货成功!',
  234. type: 'success'
  235. })
  236. this.$emit('handleSuccess');
  237. this.drawer = false;
  238. }
  239. }).catch(() => {
  240. this.load = false;
  241. })
  242. }
  243. //查库存
  244. getStoreCount(item: any, callback?: Function) {
  245. let params: any = {};
  246. params.storeHouseId = item.storeHouseId;
  247. params.skuIds = []
  248. if (item.subItem) {
  249. for (const i of item.subItem) {
  250. if (params.skuIds.indexOf(i.omsOrderItemId) == -1) {
  251. params.skuIds.push(i.omsOrderItemId)
  252. }
  253. }
  254. }
  255. this.load = true;
  256. getInventoryByStoreHouseIdAndSkuids(params).then((res: any) => {
  257. this.load = false;
  258. let m = '';
  259. for (const i of item.subItem) {
  260. for (const d of res.data) {
  261. let s = Number(d.inventory) - Number(d.useInventory) - Number(i.tmsQuantity);
  262. if (i.omsOrderItemId == d.skuid && ++
  263. s < 0) {
  264. m = m ? m + ',' + i.name : i.name;
  265. } else {
  266. d.inventory = subtract(d.inventory, i.tmsQuantity);
  267. }
  268. }
  269. }
  270. if (m) {
  271. this.$message({
  272. message: '商品“' + m + '”库存不足!',
  273. type: 'error'
  274. })
  275. this.stopHandle = true;
  276. return
  277. }
  278. }).catch(() => {
  279. this.load = false;
  280. })
  281. }
  282. editResult(v: any) {
  283. this.value = v;
  284. // this.getPriceInfo(v);
  285. // this.getStoreCount(v);
  286. }
  287. editState(v: boolean) {
  288. this.drawer = v
  289. }
  290. emptyInventory(v: boolean) {
  291. console.info("无库存提示....");
  292. this.isEmptyInventory = v;
  293. }
  294. }
  295. </script>
  296. <style lang="scss" scoped>
  297. .content {
  298. width: 100%;
  299. box-sizing: border-box;
  300. padding: 0 16px;
  301. background-color: #FFF;
  302. .order-cont {
  303. height: 60px;
  304. width: 100%;
  305. box-sizing: border-box;
  306. border: solid 1px #BBB;
  307. border-radius: 5px;
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. padding: 0 16px;
  312. margin-bottom: 16px;
  313. cursor: pointer;
  314. .cont-left {
  315. // width: calc(100% - 40px);
  316. width: 100%;
  317. .order-code {
  318. width: 100%;
  319. font-size: 14px;
  320. padding: 6px 0 4px;
  321. }
  322. .order-other {
  323. width: 100%;
  324. display: flex;
  325. font-size: 14px;
  326. .receive-name {
  327. width: 150px;
  328. overflow: hidden;
  329. text-overflow: ellipsis;
  330. white-space: nowrap;
  331. }
  332. .address {
  333. width: calc(100% - 150px);
  334. overflow: hidden;
  335. text-overflow: ellipsis;
  336. white-space: nowrap;
  337. span {
  338. color: #F00;
  339. }
  340. }
  341. // .time{
  342. // width: calc(100% - 120px - 150px);
  343. // }
  344. }
  345. }
  346. }
  347. .order-cont:hover,
  348. .onAct {
  349. background-color: rgba(160, 205, 255, 0.22);
  350. }
  351. }
  352. .deli-footer {
  353. height: 60px;
  354. width: 100%;
  355. padding: 0 16px;
  356. box-sizing: border-box;
  357. box-shadow: 0 -5px 10px #EEE;
  358. display: flex;
  359. justify-content: space-between;
  360. align-items: center;
  361. position: absolute;
  362. background-color: #FFF;
  363. left: 0;
  364. bottom: 0;
  365. z-index: 10;
  366. .d-left {
  367. width: 70%;
  368. .estimate-total {
  369. font-size: 14px;
  370. padding-bottom: 4px;
  371. .total {
  372. font-size: 16px;
  373. color: #F00;
  374. }
  375. .detail {
  376. color: #1684FC;
  377. padding-left: 16px;
  378. cursor: pointer;
  379. }
  380. }
  381. }
  382. .send-btn {
  383. width: 120px;
  384. height: 40px;
  385. line-height: 40px;
  386. border-radius: 8px;
  387. background: linear-gradient(129.2deg, rgba(22, 132, 252, 1) 9.81%, rgba(93, 167, 249, 1) 97.4%);
  388. color: rgba(255, 255, 255, 100);
  389. font-size: 14px;
  390. text-align: center;
  391. box-shadow: 0px 2px 6px 0px rgba(93, 167, 249, 100);
  392. cursor: pointer;
  393. }
  394. }
  395. .space {
  396. height: 60px;
  397. width: 100%;
  398. margin-top: 16px;
  399. }
  400. </style>