global-detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. <template>
  2. <cwg-page-wrapper>
  3. <view class="order-detail-page">
  4. <!-- Content -->
  5. <view class="content">
  6. <view class="section-card">
  7. <view class="success-icon-wrap">
  8. <image v-if="detailData.status === 'success'" src="/static/images/vector.png" alt="" mode="widthFix" />
  9. <image v-else-if="detailData.status === 'fail' || detailData.status === 'cancel'" src="/static/images/vector2.png" alt="" mode="widthFix" />
  10. <image v-else src="/static/images/vector3.png" alt="" mode="widthFix" />
  11. <text class="success-text">{{ t(globalStatusText[detailData.status]) }}</text>
  12. <text v-if="approveDesc" class="success-text">{{ approveDesc }}</text>
  13. </view>
  14. </view>
  15. <view class="section-card">
  16. <view class="section-header">
  17. <uni-icons type="wallet" size="18" color="#2563eb" />
  18. <text class="section-title">{{ t('Ib.Report.Title3') }}</text>
  19. </view>
  20. <view class="info-list">
  21. <view class="info-row" v-if="detailData.merchantOrderNo">
  22. <text class="info-label">{{ t('card.Form.f35') }}</text>
  23. <view class="info-value-wrapper">
  24. <text class="info-value">{{ detailData.merchantOrderNo }}</text>
  25. <cwg-icon name="copy" :size="14" color="#9ca3af" @click.stop="copyOrderNo" />
  26. </view>
  27. </view>
  28. <view class="info-row">
  29. <text class="info-label">{{ t('card.Form.f37') }}</text>
  30. <text class="info-value amount-highlight">
  31. {{ detailData.deductionAmount || '0' }}
  32. <text class="info-valuecurrency">USD</text>
  33. </text>
  34. </view>
  35. <view class="info-row">
  36. <text class="info-label">{{ t('card.Form.f30') }}</text>
  37. <text class="info-value">
  38. {{ detailData.deductionFee || '0' }}
  39. <text class="currency">USD</text>
  40. </text>
  41. </view>
  42. <view class="info-row">
  43. <text class="info-label">{{ t('global.p12') }}</text>
  44. <text class="info-value">
  45. {{ detailData.exchangeRate ? `1 : ${detailData.exchangeRate}` : '-- ' }}
  46. </text>
  47. </view>
  48. <view class="divider"></view>
  49. <view class="info-row" v-for="(item, index) in list.common" :key="index">
  50. <text class="info-label">{{ item.name }}</text>
  51. <text class="info-value">{{ item.value }}</text>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="section-card">
  56. <view class="section-header">
  57. <uni-icons type="list" size="18" color="#2563eb" />
  58. <text class="section-title">{{ getGroupTitle('sender') }}</text>
  59. </view>
  60. <view class="info-list">
  61. <view class="info-row" v-for="(item, index) in list.sender" :key="index">
  62. <text class="info-label">{{ item.name }}</text>
  63. <text class="info-value">{{ item.value }}</text>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="section-card">
  68. <view class="section-header">
  69. <uni-icons type="list" size="18" color="#2563eb" />
  70. <text class="section-title">{{ getGroupTitle('receiver') }}</text>
  71. </view>
  72. <view class="info-list">
  73. <view class="info-row" v-for="(item, index) in list.receiver" :key="index">
  74. <text class="info-label">{{ item.name }}</text>
  75. <text class="info-value">{{ item.value }}</text>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="content" v-if="complianceStatus">
  81. <view>
  82. <view class="section-header">
  83. <uni-icons type="list" size="18" color="#2563eb" />
  84. <text class="section-title">{{ getGroupTitle('submitRfi') }}</text>
  85. </view>
  86. </view>
  87. <DynamicForm ref="globalFormRef" :fields="complianceItems" :globalForm="globalForm" :step2="true" type="2">
  88. </DynamicForm>
  89. </view>
  90. <!-- Bottom Actions -->
  91. <view class="bottom-actions"
  92. v-if="(detailData.approveStatus == 1 && detailData.status != 'cancel') || detailData.needSupplement">
  93. <view v-if="detailData.approveStatus == 1 && detailData.status != 'cancel'" class="action-btn cancel-btn"
  94. @click="cancelOrder">
  95. <text class="btn-text">{{ t('global.GlobalOrder.CancelOrder') }}</text>
  96. </view>
  97. <view v-if="detailData.needSupplement" class="action-btn appeal-btn" @click="appealOrder">
  98. <text class="btn-text">{{ t('global.GlobalOrder.submitRfi') }}</text>
  99. </view>
  100. </view>
  101. </view>
  102. </cwg-page-wrapper>
  103. </template>
  104. <script setup lang="ts">
  105. import { ref, watch, nextTick, computed } from 'vue'
  106. import { onLoad, onUnload } from '@dcloudio/uni-app';
  107. import { useI18n } from 'vue-i18n';
  108. import useCardStore from '@/stores/use-card-store';
  109. import { ucardApi } from "@/api/ucard";
  110. import DynamicForm from "./components/DynamicForm.vue";
  111. import { useOrderFields } from './composable/useOrderFields';
  112. import { globalApprovalText, globalComplianceText, globalStatusText } from '@/utils/dataMap';
  113. import useUserStore from "@/stores/use-user-store";
  114. const { t, locale } = useI18n();
  115. const userStore = useUserStore();
  116. const approveDesc = ref('');
  117. const getApproveDesc = () => {
  118. const d = detailData.value.approveDesc
  119. if (!d) return
  120. const c = userStore.reasonsOptions
  121. const a = c[d || '']
  122. const b = locale.value == 'cn' || locale.value == 'zhHant' ? a.content : a.enContent
  123. if (!b) {
  124. reasonsRefusalList()
  125. }
  126. approveDesc.value = b;
  127. }
  128. async function reasonsRefusalList() {
  129. try {
  130. const res = await ucardApi.reasonsRefusalList();
  131. if (res.code === 200) {
  132. pickFields(res.data);
  133. getApproveDesc()
  134. } else {
  135. uni.$u.toast(res.msg || t("login.msg0"));
  136. }
  137. } catch (error) {
  138. console.log(error, 111);
  139. }
  140. }
  141. function pickFields(source, fields = ['content', 'enContent']) {
  142. const result = {}
  143. Object.entries(source).forEach(([key, value]) => {
  144. result[key] = fields.reduce((acc, f) => {
  145. acc[f] = value[f] ?? null
  146. return acc
  147. }, {})
  148. })
  149. userStore.saveReasonsOptions(result);
  150. }
  151. const cardStore = useCardStore();
  152. const getGroupTitle = (type) => {
  153. const map = {
  154. common: "global.GlobalOrder.common",
  155. receiver: "global.GlobalOrder.receiver",
  156. sender: "global.GlobalOrder.sender",
  157. other: "global.GlobalOrder.other",
  158. submitRfi: "global.GlobalOrder.submitRfi",
  159. };
  160. return t(map[type] || type);
  161. }
  162. // 复制订单号
  163. const copyOrderNo = () => {
  164. uni.setClipboardData({
  165. data: detailData.value.merchantOrderNo,
  166. success: () => {
  167. uni.showToast({
  168. title: t('card.Msg.m8') || '复制成功',
  169. icon: 'success'
  170. });
  171. }
  172. });
  173. };
  174. // 取消订单
  175. const cancelOrder = () => {
  176. uni.showModal({
  177. title: t('Msg.SystemPrompt'),
  178. cancelText: t('common.cancel'),
  179. confirmText: t('common.confirm'),
  180. content: t('global.GlobalOrder.ConfirmCancelOrder'),
  181. success: async (e) => {
  182. if (e.confirm) {
  183. const res = await ucardApi.globalCancelOrder({ id: detailData.value.id })
  184. if (res.code == 200) {
  185. // 刷新订单详情
  186. uni.showToast({
  187. title: t('global.GlobalOrder.CancelOrderSuccess'),
  188. icon: 'success'
  189. });
  190. await getOrderDetail(detailData.value.id);
  191. }
  192. }
  193. }
  194. });
  195. };
  196. const globalFormRef = ref(null)
  197. const setRfiInfos = () => {
  198. let list = []
  199. list = complianceItems.value.filter(item => globalForm.value[item.fieldName])
  200. const rfiInfos = list.map((item) => {
  201. const { fieldType, rfiId } = item;
  202. let rfiValue = undefined;
  203. let rfiValueUrl = undefined;
  204. if (fieldType === "file") {
  205. rfiValueUrl = globalForm.value[item.fieldName]
  206. } else {
  207. rfiValue = globalForm.value[item.fieldName];
  208. }
  209. return {
  210. rfiId,
  211. fieldType,
  212. rfiValueUrl,
  213. rfiValue,
  214. };
  215. });
  216. return {
  217. orderNo: detailData.value.orderNo,
  218. rfiInfos,
  219. };
  220. }
  221. // 申诉订单
  222. const appealOrder = async () => {
  223. try {
  224. const isValid = await globalFormRef.value.validateForm();
  225. if (!isValid) {
  226. return;
  227. }
  228. const params = setRfiInfos();
  229. const res = await ucardApi.globalSupplementary(params);
  230. if (res.code == 200) {
  231. await getOrderDetail(detailData.value.id);
  232. }
  233. } catch (error) {
  234. console.log(error);
  235. }
  236. };
  237. const isLoading = ref(false) // 接口加载状态
  238. const detailData = ref<any>({})
  239. const list = ref<Record<string, any[]>>({})
  240. const complianceItems = ref<any[]>([])
  241. const globalForm = ref<any>({})
  242. const complianceStatus = ref(false)
  243. const type = ref<'1' | '2'>('1')
  244. const { fieldGroups } = useOrderFields(detailData)
  245. /** 自动同步字段分组到列表 */
  246. watch(
  247. fieldGroups,
  248. (val) => {
  249. list.value = { ...val }
  250. },
  251. { immediate: true, deep: true }
  252. )
  253. /**
  254. * 处理合规字段和状态
  255. * 从 detailData 中提取并处理合规相关数据
  256. */
  257. function processComplianceData() {
  258. // 处理合规字段
  259. complianceItems.value = (detailData.value.dataDtos || []).map(item => {
  260. const fieldName = `${item.customerType}_${item.fieldName}`
  261. if (item.status !== "pending_check" && item.status !== "approved") {
  262. globalForm.value[fieldName] =
  263. item.fieldType === 'file'
  264. ? item.rfiValueUrl
  265. : item.rfiValue
  266. return { ...item, fieldName, disabled: true }
  267. } else {
  268. if (item.status == "pending" || item.status == "approved") {
  269. return {
  270. ...item, fieldName,
  271. disabled: true,
  272. };
  273. } else {
  274. return { ...item };
  275. }
  276. }
  277. })
  278. // 更新合规状态
  279. complianceStatus.value = complianceItems.value.length > 0
  280. }
  281. /**
  282. * 获取订单详情
  283. * 接口返回后会更新 detailData,通过 watch 自动同步到 list
  284. */
  285. async function getOrderDetail(id: string | number) {
  286. try {
  287. isLoading.value = true
  288. const res = await ucardApi.globalOrdersDetail({ id })
  289. if (res.code !== 200) {
  290. console.warn('获取订单详情失败:', res.msg)
  291. return
  292. }
  293. Object.assign(detailData.value, res.data)
  294. await nextTick()
  295. processComplianceData()
  296. getApproveDesc()
  297. } catch (e) {
  298. console.error('获取订单详情异常:', e)
  299. } finally {
  300. isLoading.value = false
  301. }
  302. }
  303. // 页面加载时,先使用缓存数据渲染,然后获取最新数据
  304. onLoad((e) => {
  305. const cachedData = cardStore.orderDetail
  306. if (cachedData) {
  307. try {
  308. const clonedData = JSON.parse(JSON.stringify(cachedData))
  309. Object.assign(detailData.value, clonedData)
  310. nextTick()
  311. console.log(clonedData, detailData.value, 'clonedDataclonedDataclonedDataclonedData');
  312. processComplianceData()
  313. } catch (error) {
  314. console.error('加载缓存数据失败:', error)
  315. }
  316. }
  317. if (e.id) {
  318. nextTick(() => {
  319. getOrderDetail(e.id)
  320. })
  321. }
  322. });
  323. // 离开页面时清空订单详情
  324. onUnload(() => {
  325. cardStore.clearOrderDetail();
  326. });
  327. </script>
  328. <style scoped lang="scss">
  329. @import "@/uni.scss";
  330. .page-wrapper {
  331. padding: 0;
  332. }
  333. .success-icon-wrap {
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. flex-wrap: wrap;
  338. background-color: #ffffff;
  339. image {
  340. width: 100%;
  341. }
  342. .success-text {
  343. width: 100%;
  344. text-align: center;
  345. font-size: px2rpx(18);
  346. color: #111827;
  347. margin-bottom: px2rpx(24);
  348. }
  349. }
  350. .order-detail-page {
  351. background-color: #f9fafb;
  352. padding-bottom: px2rpx(80);
  353. }
  354. /* Header */
  355. .header {
  356. background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
  357. padding: px2rpx(12) px2rpx(16);
  358. padding-top: calc(px2rpx(12) + env(safe-area-inset-top));
  359. }
  360. .header-nav {
  361. display: flex;
  362. align-items: center;
  363. justify-content: space-between;
  364. }
  365. .back-btn {
  366. width: px2rpx(40);
  367. height: px2rpx(40);
  368. display: flex;
  369. align-items: center;
  370. justify-content: center;
  371. }
  372. .header-title {
  373. color: #ffffff;
  374. font-size: px2rpx(18);
  375. }
  376. .header-action {
  377. width: px2rpx(40);
  378. }
  379. /* Content */
  380. .content {
  381. padding: px2rpx(16);
  382. }
  383. /* Status Card */
  384. .status-card {
  385. background-color: #ffffff;
  386. border-radius: px2rpx(16);
  387. padding: px2rpx(32) px2rpx(24);
  388. margin-bottom: px2rpx(16);
  389. display: flex;
  390. flex-direction: column;
  391. align-items: center;
  392. }
  393. .status-icon-wrapper {
  394. margin-bottom: px2rpx(16);
  395. }
  396. .status-icon {
  397. width: px2rpx(80);
  398. height: px2rpx(80);
  399. border-radius: 50%;
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. }
  404. .status-icon-success {
  405. background-color: #f0fdf4;
  406. }
  407. .status-icon-processing {
  408. background-color: #fefce8;
  409. }
  410. .status-icon-failed {
  411. background-color: #fef2f2;
  412. }
  413. .status-icon-cancelled {
  414. background-color: #f9fafb;
  415. }
  416. .status-title {
  417. font-size: px2rpx(22);
  418. color: #111827;
  419. margin-bottom: px2rpx(8);
  420. }
  421. .status-subtitle {
  422. font-size: px2rpx(14);
  423. color: #6b7280;
  424. text-align: center;
  425. }
  426. /* Section Card */
  427. .section-card {
  428. background-color: #ffffff;
  429. border-radius: px2rpx(12);
  430. padding: px2rpx(16);
  431. margin-bottom: px2rpx(16);
  432. }
  433. .section-header {
  434. display: flex;
  435. align-items: center;
  436. gap: px2rpx(8);
  437. margin-bottom: px2rpx(16);
  438. }
  439. .section-title {
  440. font-size: px2rpx(16);
  441. color: #111827;
  442. }
  443. /* Approval Timeline */
  444. .approval-timeline {
  445. display: flex;
  446. flex-direction: column;
  447. }
  448. .timeline-item {
  449. display: flex;
  450. gap: px2rpx(12);
  451. }
  452. .timeline-left {
  453. display: flex;
  454. flex-direction: column;
  455. align-items: center;
  456. flex-shrink: 0;
  457. }
  458. .timeline-dot {
  459. width: px2rpx(24);
  460. height: px2rpx(24);
  461. border-radius: 50%;
  462. background-color: #f3f4f6;
  463. border: 2px solid #e5e7eb;
  464. display: flex;
  465. align-items: center;
  466. justify-content: center;
  467. flex-shrink: 0;
  468. }
  469. .timeline-dot-active {
  470. background-color: #22c55e;
  471. border-color: #22c55e;
  472. }
  473. .timeline-dot-current {
  474. background-color: #eab308;
  475. border-color: #eab308;
  476. animation: pulse 2s infinite;
  477. }
  478. @keyframes pulse {
  479. 0%,
  480. 100% {
  481. opacity: 1;
  482. }
  483. 50% {
  484. opacity: 0.7;
  485. }
  486. }
  487. .timeline-line {
  488. width: px2rpx(2);
  489. flex: 1;
  490. background-color: #e5e7eb;
  491. margin: px2rpx(4) 0;
  492. }
  493. .timeline-right {
  494. flex: 1;
  495. padding-bottom: px2rpx(24);
  496. }
  497. .timeline-header {
  498. display: flex;
  499. align-items: center;
  500. justify-content: space-between;
  501. margin-bottom: px2rpx(6);
  502. }
  503. .timeline-title {
  504. font-size: px2rpx(15);
  505. color: #111827;
  506. }
  507. .timeline-status {
  508. display: flex;
  509. align-items: center;
  510. gap: px2rpx(4);
  511. padding: px2rpx(2) px2rpx(8);
  512. border-radius: px2rpx(12);
  513. }
  514. .timeline-status.completed {
  515. background-color: #f0fdf4;
  516. }
  517. .timeline-status.current {
  518. background-color: #fefce8;
  519. }
  520. .timeline-status.pending {
  521. background-color: #f9fafb;
  522. }
  523. .timeline-status-text {
  524. font-size: px2rpx(12);
  525. }
  526. .timeline-status.completed .timeline-status-text {
  527. color: #22c55e;
  528. }
  529. .timeline-status.current .timeline-status-text {
  530. color: #eab308;
  531. }
  532. .timeline-status.pending .timeline-status-text {
  533. color: #9ca3af;
  534. }
  535. .timeline-operator {
  536. font-size: px2rpx(13);
  537. color: #6b7280;
  538. display: block;
  539. margin-bottom: px2rpx(4);
  540. }
  541. .timeline-time {
  542. font-size: px2rpx(12);
  543. color: #9ca3af;
  544. display: block;
  545. margin-bottom: px2rpx(4);
  546. }
  547. .timeline-remark {
  548. font-size: px2rpx(13);
  549. color: #6b7280;
  550. display: block;
  551. margin-top: px2rpx(6);
  552. padding: px2rpx(8);
  553. background-color: #f9fafb;
  554. border-radius: px2rpx(6);
  555. }
  556. /* Info List */
  557. .info-list {
  558. display: flex;
  559. flex-direction: column;
  560. gap: px2rpx(12);
  561. }
  562. .info-row {
  563. display: flex;
  564. align-items: center;
  565. justify-content: space-between;
  566. gap: px2rpx(12);
  567. padding: px2rpx(4) 0;
  568. }
  569. .info-row.vertical {
  570. flex-direction: column;
  571. align-items: flex-start;
  572. }
  573. .info-label {
  574. font-size: px2rpx(14);
  575. color: #6b7280;
  576. flex-shrink: 0;
  577. }
  578. .info-value {
  579. font-size: px2rpx(14);
  580. color: #111827;
  581. text-align: right;
  582. word-break: break-all;
  583. }
  584. .info-value-wrapper {
  585. display: flex;
  586. align-items: center;
  587. gap: px2rpx(8);
  588. flex: 1;
  589. justify-content: flex-end;
  590. }
  591. .amount-highlight {
  592. font-size: px2rpx(20);
  593. color: #2563eb;
  594. }
  595. .total-label {
  596. font-size: px2rpx(15);
  597. color: #111827;
  598. }
  599. .total-value {
  600. font-size: px2rpx(18);
  601. color: #ef4444;
  602. }
  603. .remark-text {
  604. text-align: left;
  605. color: #6b7280;
  606. line-height: 1.6;
  607. }
  608. .divider {
  609. height: px2rpx(1);
  610. background-color: #f3f4f6;
  611. margin: px2rpx(4) 0;
  612. }
  613. /* Service Card */
  614. .service-card {
  615. background-color: #ffffff;
  616. border-radius: px2rpx(12);
  617. padding: px2rpx(16);
  618. display: flex;
  619. align-items: center;
  620. gap: px2rpx(12);
  621. margin-bottom: px2rpx(16);
  622. }
  623. .service-text {
  624. flex: 1;
  625. font-size: px2rpx(15);
  626. color: #111827;
  627. }
  628. /* Bottom Actions */
  629. .bottom-actions {
  630. position: fixed;
  631. bottom: 0;
  632. left: 0;
  633. right: 0;
  634. background-color: #ffffff;
  635. border-top: 1px solid #e5e7eb;
  636. padding: px2rpx(12) px2rpx(16);
  637. padding-bottom: calc(px2rpx(12) + env(safe-area-inset-bottom));
  638. display: flex;
  639. gap: px2rpx(12);
  640. }
  641. .action-btn {
  642. flex: 1;
  643. height: px2rpx(44);
  644. border-radius: px2rpx(8);
  645. display: flex;
  646. align-items: center;
  647. justify-content: center;
  648. }
  649. .cancel-btn {
  650. background-color: #f3f4f6;
  651. }
  652. .cancel-btn .btn-text {
  653. color: #6b7280;
  654. }
  655. .appeal-btn {
  656. background-color: #2563eb;
  657. }
  658. .appeal-btn .btn-text {
  659. color: #ffffff;
  660. }
  661. .delete-btn {
  662. background-color: #f3f4f6;
  663. }
  664. .delete-btn .btn-text {
  665. color: #ef4444;
  666. }
  667. .btn-text {
  668. font-size: px2rpx(15);
  669. }
  670. .currency {
  671. font-size: px2rpx(12);
  672. }
  673. </style>