orderDetailPart.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <div class="order-detail-part">
  3. <div
  4. v-if="isLoading == 1"
  5. v-loading="true"
  6. class="com-loading"></div>
  7. <template v-else-if="isLoading == 2">
  8. <!-- <div class="eco-tip" v-if="orderDetail.Emission_Total_Kg && orderDetail.Emission_Total_Kg != '0'">
  9. <div class="eco-tip-title">
  10. <img src="@/assets/img/esg/leaf.png" alt="eco" class="eco-tip-icon" />
  11. <span> Protecting Nature Starts with Your Choice</span>
  12. </div>
  13. <div class="eco-tip-desc">
  14. Your Eco-Friendly Purchase Generated
  15. <span class="eco-tip-co2">{{ orderDetail.Emission_Total_Kg || 0 }} KG</span> Of Carbon Emissions. Together, We<br>
  16. Embrace Enyironmental Responsibility For A More Sustainable Future.
  17. </div>
  18. </div> -->
  19. <section class="main-header">
  20. <div class="main-header-mid flex between">
  21. <h1>Job Name:{{ orderDetail.Sales_Order_Title_Job_Name }}</h1>
  22. <img
  23. :src="orderDetail.user_logo"
  24. class="user_logo"
  25. v-if="orderDetail.user_logo" />
  26. </div>
  27. <div class="main-header-mid">
  28. <ul class="left">
  29. <li
  30. class="left-i link-div"
  31. v-if="isShow">
  32. <div @click="shareDialogVisible = true">
  33. <i class="el-icon-share"></i>
  34. <span>Client Tracking Share</span>
  35. </div>
  36. <!-- <div v-for="(item) in orderDetail.crm_esg_res?.flat()"
  37. @click="downloadEsg(item)"
  38. :key="item.id">
  39. <img src="@/assets/img/order/cer.png" />
  40. <span> DownLoad {{ item.name }}</span>
  41. </div> -->
  42. </li>
  43. <li
  44. class="left-i"
  45. v-if="orderDetail.crm_pr_res?.length">
  46. <image-list :data="orderDetail.crm_pr_res" />
  47. </li>
  48. </ul>
  49. <ul class="right">
  50. <li v-if="orderDetail.Job_Group && isShow">Order Type: {{ orderDetail.Job_Group }}</li>
  51. <li>Order No: {{ orderDetail.Reference }}</li>
  52. <li>Order Date: {{ formatStepDesc(orderDetail.Sales_Order_Created) }}</li>
  53. <li v-if="isShow">Payment Status: {{ orderDetail.Payment_Status1 }}</li>
  54. </ul>
  55. </div>
  56. <div class="steps margin-b-30">
  57. <p class="steps-title margin-b-50">Bulk Production</p>
  58. <el-steps
  59. :active="comOrderState"
  60. align-center
  61. :direction="computedStepDirection"
  62. finish-status="success"
  63. process-status="wait">
  64. <el-step
  65. title="Confirmed"
  66. :description="formatStepDesc(orderDetail.Order_Confirm)">
  67. </el-step>
  68. <el-step
  69. title="In Production"
  70. :description="formatStepDesc(orderDetail.Sampling_Factory_Confirm)"></el-step>
  71. <el-step
  72. title="QC Inspection"
  73. :description="formatStepDesc(orderDetail.GZ_WH)"></el-step>
  74. <el-step
  75. title="International Shipment"
  76. :description="formatStepDesc(orderDetail.International_transshipment)"></el-step>
  77. <el-step
  78. title="UK Warehouse"
  79. :description="formatStepDesc(orderDetail.AU_WH)"></el-step>
  80. <el-step
  81. :title="orderDetail.Order_Stage === 'Bulk Production Shipping' ? 'Domestic Delivery' : 'Shipped'"
  82. :description="formatStepDesc(orderDetail.AU_WH_Client)"></el-step>
  83. <el-step
  84. title="Delivered"
  85. :description="formatStepDesc(orderDetail.Delivered)"></el-step>
  86. </el-steps>
  87. </div>
  88. <div
  89. class="steps"
  90. :class="{ 'margin-b-30': stepShow }"
  91. v-if="orderDetail.Sample_Stage">
  92. <p
  93. class="steps-title pointer"
  94. :class="{ 'margin-b-50': stepShow }"
  95. @click="toggleStep">
  96. Sample Dispatch <i :class="stepShow ? 'el-icon-arrow-down' : 'el-icon-arrow-right'"></i>
  97. </p>
  98. <el-steps
  99. :active="comSampleState"
  100. align-center
  101. :space="180"
  102. v-if="stepShow"
  103. :direction="computedStepDirection"
  104. finish-status="success"
  105. process-status="wait">
  106. <el-step
  107. title="Factory Process"
  108. :description="formatStepDesc(orderDetail.Sample_Factory_Confirmed)">
  109. </el-step>
  110. <el-step
  111. title="Sample Dispatching"
  112. :description="formatStepDesc(orderDetail.Sample_Dispatching)"></el-step>
  113. <el-step
  114. title="Sample Delivered"
  115. :description="formatStepDesc(orderDetail.Sample_Delivered)"></el-step>
  116. </el-steps>
  117. </div>
  118. </section>
  119. <section class="main-custom">
  120. <p class="sharing-title">Customer information</p>
  121. <div>
  122. <p class="sharing-subtitle">{{ isShow ? 'Billing' : 'Supplier' }} Address</p>
  123. <div class="sharing-address">
  124. <p>{{ orderDetail.Account_Name_name }}</p>
  125. <p>{{ orderDetail.Billing_Unit_Building_Name }}</p>
  126. <p>{{ orderDetail.Billing_Street }}</p>
  127. <p>{{ orderDetail.Billing_City }}</p>
  128. <p>{{ orderDetail.Billing_State }}</p>
  129. <p>{{ orderDetail.Billing_Code }}</p>
  130. <p>{{ orderDetail.Billing_Country }}</p>
  131. </div>
  132. </div>
  133. <div>
  134. <p class="sharing-subtitle">Shipping Address</p>
  135. <div class="sharing-address">
  136. <p>{{ orderDetail.Shipping_Unit_Building_Name }}</p>
  137. <p>{{ orderDetail.Shipping_Street }}</p>
  138. <p>{{ orderDetail.Shipping_City }}</p>
  139. <p>{{ orderDetail.Shipping_State }}</p>
  140. <p>{{ orderDetail.Shipping_Code }}</p>
  141. <p>{{ orderDetail.Shipping_Country }}</p>
  142. </div>
  143. </div>
  144. </section>
  145. <section>
  146. <p class="sharing-title">Shipping information</p>
  147. <el-table
  148. :data="orderDetail.shipping_tracking"
  149. style="width: 100%"
  150. :header-cell-style="{ background: '#F7F8FC', color: '#101010', fontWeight: 'normal' }">
  151. <el-table-column
  152. type="expand"
  153. style="padding: 0">
  154. <template slot-scope="props">
  155. <el-table
  156. :data="props.row.test_pkg_details"
  157. style="margin-left: 50px; width: calc(100% - 50px)"
  158. :header-cell-style="{ background: '#F7F8FC', color: '#101010', fontWeight: 'normal' }">
  159. <el-table-column
  160. prop="Product_name"
  161. label="Item & Description"></el-table-column>
  162. <el-table-column
  163. prop="Quantity_to_pack"
  164. label="QTY"
  165. width="450"></el-table-column>
  166. </el-table>
  167. </template>
  168. </el-table-column>
  169. <el-table-column
  170. prop="Title"
  171. label="Job Name"
  172. width="190"></el-table-column>
  173. <el-table-column
  174. prop="Courier"
  175. label="Carrier"
  176. width="190"></el-table-column>
  177. <el-table-column
  178. prop="Tracking_No"
  179. label="Tracking#"
  180. width="190"></el-table-column>
  181. <el-table-column
  182. prop="Package_Status"
  183. label="Shipment Status"
  184. width="190"></el-table-column>
  185. <el-table-column
  186. label="Delivery Address"
  187. width="250">
  188. <template slot-scope="scope">
  189. <span>
  190. {{ scope.row.Shipping_Unit_Building_Name }}<br />
  191. {{ scope.row.Shipping_Street }}<br />
  192. {{ scope.row.Shipping_City }}<br />
  193. {{ scope.row.Shipping_State }}
  194. </span>
  195. </template>
  196. </el-table-column>
  197. <el-table-column
  198. prop="Tracking_URL"
  199. label=""
  200. width="200">
  201. <template
  202. slot-scope="scope"
  203. v-if="scope.row.Tracking_URL">
  204. <el-button
  205. size="mini"
  206. @click.native="openTracking_URL(scope.row.Tracking_URL)"
  207. style="background-color: rgb(0, 33, 59); color: #fff"
  208. plain
  209. >TRACK SHIPMENT</el-button
  210. ></template
  211. >
  212. </el-table-column>
  213. </el-table>
  214. </section>
  215. <section class="orderTable">
  216. <p class="sharing-title">Products Information</p>
  217. <el-table
  218. :data="orderDetail.sales_orders_details"
  219. style="width: 100%"
  220. :header-cell-style="{
  221. background: '#fff',
  222. color: '#101010',
  223. fontWeight: 'normal',
  224. }">
  225. <el-table-column
  226. type="index"
  227. label="S.NO"
  228. width="70"
  229. fixed>
  230. </el-table-column>
  231. <el-table-column
  232. label="Product Name"
  233. min-width="300">
  234. <template slot-scope="scope">
  235. <p class="colorBlue">{{ scope.row.product_name }}</p>
  236. <!-- <p class="table-list-co2" v-if="scope.row.Emision_Details_value && scope.row.Emision_Details_value != '0'">
  237. <img src="@/assets/img/esg/co2_green.png" alt="CO2" class="co2-icon" />
  238. <span>{{ scope.row.Emision_Details_value }} kg CO₂e</span>
  239. </p> -->
  240. <p v-html="scope.row.product_description"></p>
  241. <!-- <p :class="scope.row.showMore?'ellipsis':''" v-html="scope.row.product_description"></p>
  242. <p class="colorBlue cursor" @click="toggleShow(scope.row)" v-if="scope.row.product_description">{{scope.row.showMore?'Show More':'Conceal'}}<i :class="scope.row.showMore?'el-icon-caret-bottom':'el-icon-caret-top'"></i></p> -->
  243. </template>
  244. </el-table-column>
  245. <el-table-column
  246. prop="quantity"
  247. label="Quantity"
  248. align="left"
  249. :width="isShow ? 125 : 200">
  250. </el-table-column>
  251. <template v-if="isShow">
  252. <el-table-column
  253. prop="list_price"
  254. :label="`List Price(${comCurrency})`"
  255. width="125">
  256. <template slot-scope="scope">
  257. {{ transformNumber(scope.row.list_price) }}
  258. </template>
  259. </el-table-column>
  260. <el-table-column
  261. prop="amount"
  262. :label="`Amount(${comCurrency})`"
  263. width="125">
  264. <template slot-scope="scope">
  265. {{ transformNumber(scope.row.amount) }}
  266. </template>
  267. </el-table-column>
  268. <el-table-column
  269. prop="Tax"
  270. :label="`Tax(${comCurrency})`"
  271. width="125">
  272. <template slot-scope="scope">
  273. {{ transformNumber(scope.row.Tax) }}
  274. </template>
  275. </el-table-column>
  276. <el-table-column
  277. prop="Discount"
  278. :label="`Discount(${comCurrency})`"
  279. width="125">
  280. <template slot-scope="scope">
  281. {{ transformNumber(scope.row.Discount) }}
  282. </template>
  283. </el-table-column>
  284. <el-table-column
  285. prop="net_total"
  286. :label="`Total(${comCurrency})`"
  287. width="125">
  288. <template slot-scope="scope">
  289. {{ transformNumber(scope.row.net_total) }}
  290. </template>
  291. </el-table-column>
  292. </template>
  293. </el-table>
  294. <div
  295. class="table-wrap"
  296. v-if="isShow">
  297. <table class="total">
  298. <tr>
  299. <td>Sub Total</td>
  300. <td>{{ comCurrency }} {{ transformNumber(orderDetail.Sub_Total) }}</td>
  301. </tr>
  302. <tr>
  303. <td>Total Taxes</td>
  304. <td>{{ comCurrency }} {{ transformNumber(orderDetail.Tax_Total) }}</td>
  305. </tr>
  306. <tr>
  307. <td>Total Discount</td>
  308. <td>{{ comCurrency }} {{ transformNumber(orderDetail.Discount_Amount) }}</td>
  309. </tr>
  310. <tr>
  311. <td>Adjustment</td>
  312. <td>{{ comCurrency }} {{ transformNumber(orderDetail.Total_Adjustment) }}</td>
  313. </tr>
  314. <tr>
  315. <td>Grand Total</td>
  316. <td>{{ comCurrency }} {{ transformNumber(orderDetail.Grand_Total) }}</td>
  317. </tr>
  318. </table>
  319. </div>
  320. </section>
  321. <!-- <section
  322. v-if="orderDetail.Order_Stage === 'Sales Order Created'" style="text-align: right;border: none;">
  323. <el-button
  324. v-if="orderDetail.Order_Stage === 'Sales Order Created'"
  325. @click="openApproved(orderDetail)"
  326. size="small"
  327. style="background-color: rgb(0, 33, 59); color: #fff;"
  328. plain
  329. >Approved</el-button>
  330. </section> -->
  331. </template>
  332. <div v-else>
  333. <el-empty description="No Data"></el-empty>
  334. </div>
  335. <el-dialog
  336. :lock-scroll="false"
  337. :visible.sync="urlDialogShow"
  338. center
  339. width="850px"
  340. top="20vh">
  341. <iframe
  342. :src="Tracking_URL"
  343. style="width: 100%; height: 500px"
  344. frameborder="0"></iframe>
  345. </el-dialog>
  346. <export-dialog
  347. :emailForm="shareForm"
  348. :visible.sync="shareDialogVisible"
  349. :title="'Client Tracking Share (no pricing displayed)'"
  350. :labelShow="false"></export-dialog>
  351. </div>
  352. </template>
  353. <script>
  354. import throttle from 'lodash.throttle'
  355. import { round } from '@/utils/price.js'
  356. import { mapMutations } from 'vuex'
  357. export default {
  358. name: 'OrderDetailPart',
  359. props: {
  360. isShow: {
  361. // 订单分享页面隐藏元素
  362. type: Boolean,
  363. default: true,
  364. },
  365. hasUid: {
  366. type: Boolean,
  367. default: true,
  368. },
  369. },
  370. data() {
  371. return {
  372. orderDetail: {},
  373. isLoading: 1,
  374. packageTable: [],
  375. stepShow: false,
  376. urlDialogShow: false,
  377. shareDialogVisible: false,
  378. loginCount: 0,
  379. shareForm: {
  380. Link: '',
  381. },
  382. Tracking_URL: '',
  383. stepConfig: {
  384. 'Order Confirmed': 1,
  385. 'Factory Confirmed': 2,
  386. 'GZ WH': 3,
  387. Transshipment: 4,
  388. 'AU WH': 5,
  389. 'AUWH - Client': 6,
  390. 'Bulk Production Shipping': 6,
  391. 'Bulk Production Delivered': 7,
  392. 'Completed Sales Order': 7,
  393. 'Factory Process': 1,
  394. 'Sample Dispatching': 2,
  395. 'Sample Delivered': 3,
  396. },
  397. computedStepDirection: 'horizontal',
  398. }
  399. },
  400. computed: {
  401. loginSuccess() {
  402. return this.$store.state.loginSuccess
  403. },
  404. comCurrency() {
  405. return this.orderDetail.Currency
  406. },
  407. comOrderState() {
  408. if (this.orderDetail.Order_Stage === 'Cancelled') {
  409. return 0
  410. }
  411. return this.stepConfig[this.orderDetail.Order_Stage]
  412. },
  413. comSampleState() {
  414. return this.stepConfig[this.orderDetail.Sample_Stage]
  415. },
  416. },
  417. watch: {
  418. loginSuccess(newVal) {
  419. if (newVal) {
  420. this.getOrderDetail() // 当登录成功后调用获取订单详情
  421. this.$store.commit('setLoginSuccess', false)
  422. }
  423. },
  424. },
  425. beforeMount() {
  426. window.addEventListener('resize', this.judgeStepDirection, false)
  427. this.judgeStepDirection()
  428. },
  429. created() {
  430. this.getOrderDetail()
  431. },
  432. beforeDestroy() {
  433. window.removeEventListener('resize', this.judgeStepDirection, false)
  434. },
  435. methods: {
  436. ...mapMutations({ openDialog: 'openDialog' }),
  437. judgeStepDirection: throttle(function () {
  438. this.computedStepDirection = window.document.body.clientWidth >= 1000 ? 'horizontal' : 'vertical'
  439. }, 300),
  440. toggleStep() {
  441. this.stepShow = !this.stepShow
  442. },
  443. getOrderDetail() {
  444. let path = ''
  445. let data = {}
  446. if (this.isShow) {
  447. const { id } = this.$store.state.userInfo
  448. const { crm, id: queryId } = this.$route.query
  449. path = '/uk-api/crmdata/orders_detail'
  450. this.shareForm.Link = `https://www.trackship.uk/orderShare/${id}/${crm}/${queryId}`
  451. data = { accounts_id: crm, id: queryId }
  452. } else {
  453. path = '/uk-api/crmdata/showOrdersDetail'
  454. if (this.hasUid) {
  455. const { uid, aid, id } = this.$route.params
  456. data = { user_id: uid, accounts_id: aid, id }
  457. } else {
  458. const { aid, id } = this.$route.params
  459. data = { accounts_id: aid, id }
  460. }
  461. }
  462. this.$axios
  463. .post(path, data)
  464. .then(res => {
  465. if (res.result === null) {
  466. this.handleBranchLogic()
  467. }
  468. this.orderDetail = res.result
  469. if (this.orderDetail.shipping_tracking?.length) {
  470. let isDelivered = true
  471. for (const items of this.orderDetail.shipping_tracking) {
  472. if (items.test_pkg_details?.length) {
  473. items.test_pkg_details.forEach(item => {
  474. item.Courier = items.Courier
  475. item.Tracking_No = items.Tracking_No
  476. item.Package_Status = items.Package_Status
  477. item.Tracking_URL = items.Tracking_URL
  478. })
  479. }
  480. }
  481. }
  482. if (this.orderDetail.sales_orders_details?.length) {
  483. if (this.isShow) {
  484. this.orderDetail.sales_orders_details.forEach(items => {
  485. this.$set(items, 'showMore', true)
  486. })
  487. } else {
  488. this.orderDetail.sales_orders_details = this.orderDetail.sales_orders_details
  489. .filter(item => {
  490. return item.product_Product_Code !== 'PC Setup Service' && item.product_Product_Code !== 'PC Freight'
  491. })
  492. .map(item => {
  493. this.$set(item, 'showMore', true)
  494. return item
  495. })
  496. }
  497. }
  498. this.isLoading = 2
  499. })
  500. .catch(err => {
  501. this.handleBranchLogic()
  502. })
  503. },
  504. handleBranchLogic() {
  505. this.isLoading = 3
  506. if (this.loginCount) {
  507. this.$router.push('/')
  508. return
  509. }
  510. this.isShow &&
  511. setTimeout(() => {
  512. this.openDialog()
  513. this.loginCount = 1
  514. }, 1000)
  515. return
  516. },
  517. transformNumber(value) {
  518. return round(Number(value)).toFixed(2)
  519. },
  520. formatStepDesc(date, isUnix = false) {
  521. return this.$utils.formatTime(date, 'DD/MM/YYYY', isUnix)
  522. },
  523. toggleShow(row) {
  524. row.showMore = !row.showMore
  525. },
  526. openTracking_URL(url) {
  527. this.Tracking_URL = url
  528. this.urlDialogShow = true
  529. },
  530. download(url) {
  531. var urlStr = url.match('[^/]+(?!.*/)')[0]
  532. this.$utils.downloadBlob(url, urlStr)
  533. },
  534. downloadEsg(item) {
  535. if (!item.id) {
  536. this.$message.error('No report available for download')
  537. return
  538. }
  539. this.$axios
  540. .post('Crmdata/downloadreport', { id: item.id, name: item.name })
  541. .then(res => {
  542. if (res.result) {
  543. this.$utils.downloadBlob(res.result?.data, decodeURIComponent(res.result?.url_name))
  544. } else {
  545. this.$message.error('Download failed, please try again later')
  546. }
  547. })
  548. .catch(() => {
  549. this.$message.error('Download failed, please try again later')
  550. })
  551. },
  552. openApproved(row) {
  553. this.$confirm(
  554. `
  555. <div style="text-align:center;">
  556. <h3 style="margin:0 0 10px;color:#333;">Ready to order?</h3>
  557. <p style="margin:0;font-size:16px;color:#333;">Your total is <b>${this.transformNumber(
  558. row.Grand_Total
  559. )}</b>. Confirm to place your order.</p>
  560. </div>
  561. `,
  562. '',
  563. {
  564. dangerouslyUseHTMLString: true,
  565. confirmButtonText: 'Confirm',
  566. cancelButtonText: 'Cancel',
  567. confirmButtonClass: 'el-button',
  568. cancelButtonClass: 'el-button--info',
  569. center: true,
  570. showClose: false,
  571. confirmButtonClass: 'com-btnblack',
  572. }
  573. ).then(() => {
  574. this.$router.push({ path: '/so-confirm', query: { id: row.sales_orders_id, pc_psw: row.HASH } })
  575. })
  576. },
  577. },
  578. }
  579. </script>
  580. <style lang="scss" scoped>
  581. @import '../detail.scss';
  582. </style>