西藏巴青项目

index.vue 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="sp-detail-page">
  3. <scroll-view scroll-y class="sp-detail-scroll" enable-back-to-top>
  4. <view v-if="loading" class="sp-empty">
  5. <text class="sp-empty__txt">加载中…</text>
  6. </view>
  7. <template v-else-if="detail">
  8. <view class="sp-block">
  9. <view class="sp-block__head">
  10. <text class="sp-block__title">订单信息</text>
  11. <text class="sp-block__status" :class="statusClass">{{ statusText }}</text>
  12. </view>
  13. <view class="sp-field" v-for="field in orderFields" :key="field.label">
  14. <text class="sp-field__label">{{ field.label }}</text>
  15. <text class="sp-field__value">{{ field.value }}</text>
  16. </view>
  17. </view>
  18. <view class="sp-block">
  19. <text class="sp-block__title sp-block__title--solo">牦牛明细</text>
  20. <view class="sp-line-table">
  21. <view class="sp-line-table__head">
  22. <text class="sp-line-table__th sp-line-table__th--tag">耳标号</text>
  23. <text class="sp-line-table__th">重量(kg)</text>
  24. <text class="sp-line-table__th sp-line-table__th--amt">金额(元)</text>
  25. </view>
  26. <view v-if="!lineList.length" class="sp-line-table__empty">
  27. <text class="sp-line-table__empty-txt">暂无明细</text>
  28. </view>
  29. <view v-for="(line, idx) in lineList" :key="line.id || idx" class="sp-line-table__row">
  30. <text class="sp-line-table__td sp-line-table__td--tag">{{ line.earTag || DASH }}</text>
  31. <text class="sp-line-table__td">{{ line.weight != null ? line.weight : DASH }}</text>
  32. <text class="sp-line-table__td sp-line-table__td--amt">{{ formatPrice(line.amount) }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="sp-block">
  37. <text class="sp-block__title sp-block__title--solo">支付信息</text>
  38. <view class="sp-field">
  39. <text class="sp-field__label">订单支付时间</text>
  40. <text class="sp-field__value">{{ formatDateTime(detail.finishTime) }}</text>
  41. </view>
  42. <view class="sp-voucher-row">
  43. <text class="sp-field__label">支付凭证</text>
  44. <image
  45. v-if="payVoucherUrl"
  46. class="sp-voucher-img"
  47. :src="payVoucherUrl"
  48. mode="aspectFill"
  49. @tap="previewImage(payVoucherUrl)"
  50. />
  51. <view v-else class="sp-voucher-placeholder">
  52. <text class="sp-voucher-placeholder__txt">暂无</text>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="sp-block">
  57. <text class="sp-block__title sp-block__title--solo">结算信息</text>
  58. <view class="sp-field">
  59. <text class="sp-field__label">订单结算时间</text>
  60. <text class="sp-field__value">{{ formatDateTime(detail.settleFinishTime) }}</text>
  61. </view>
  62. <view class="sp-field">
  63. <text class="sp-field__label">服务费金额(元)</text>
  64. <text class="sp-field__value">{{ formatPrice(detail.serviceFeeAmount) }}</text>
  65. </view>
  66. <view class="sp-field">
  67. <text class="sp-field__label">实际结算金额(元)</text>
  68. <text class="sp-field__value">{{ formatPrice(detail.payableAmount) }}</text>
  69. </view>
  70. <view class="sp-voucher-row">
  71. <text class="sp-field__label">结算凭证</text>
  72. <image
  73. v-if="settleVoucherUrl"
  74. class="sp-voucher-img"
  75. :src="settleVoucherUrl"
  76. mode="aspectFill"
  77. @tap="previewImage(settleVoucherUrl)"
  78. />
  79. <view v-else class="sp-voucher-placeholder">
  80. <text class="sp-voucher-placeholder__txt">暂无</text>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <view v-else class="sp-empty">
  86. <text class="sp-empty__txt">订单不存在或无权查看</text>
  87. </view>
  88. <view class="sp-footer-spacer" />
  89. </scroll-view>
  90. </view>
  91. </template>
  92. <script>
  93. import { getSupplierOrder, getSupplierSettlement } from '@/api/supplier/order'
  94. import { resolveResourceUrl } from '@/utils/resourceUrl'
  95. import { DASH, formatDateTime, formatPrice } from '@/utils/format'
  96. export default {
  97. data() {
  98. return {
  99. DASH,
  100. kind: 'order',
  101. id: '',
  102. loading: false,
  103. detail: null
  104. }
  105. },
  106. computed: {
  107. lineList() {
  108. return (this.detail && this.detail.lineList) || []
  109. },
  110. statusText() {
  111. if (!this.detail) return DASH
  112. if (this.kind === 'settlement') {
  113. return this.detail.settlementStatusName || '待结算'
  114. }
  115. return this.detail.orderStatusName || DASH
  116. },
  117. statusClass() {
  118. const text = this.statusText
  119. if (String(text).includes('完成')) return 'sp-block__status--done'
  120. if (String(text).includes('待')) return 'sp-block__status--pending'
  121. return ''
  122. },
  123. orderFields() {
  124. const d = this.detail || {}
  125. return [
  126. { label: '订单编号', value: d.orderNo || d.settlementNo || DASH },
  127. { label: '订单创建时间', value: formatDateTime(d.createTime) },
  128. { label: '供应商', value: d.supplierName || DASH },
  129. { label: '承销商', value: d.distributorName || DASH },
  130. { label: '交易总头数(头)', value: d.totalHeads != null ? d.totalHeads : DASH },
  131. { label: '交易总金额(元)', value: formatPrice(d.totalAmount) }
  132. ]
  133. },
  134. payVoucherUrl() {
  135. const d = this.detail
  136. return resolveResourceUrl(d && (d.payVoucherUrl || d.payVoucherPath))
  137. },
  138. settleVoucherUrl() {
  139. const d = this.detail
  140. return resolveResourceUrl(d && (d.settleVoucherUrl || d.settleVoucherPath))
  141. }
  142. },
  143. onLoad(query) {
  144. this.kind = query.kind === 'settlement' ? 'settlement' : 'order'
  145. this.id = query.id || ''
  146. this.loadDetail()
  147. },
  148. methods: {
  149. formatDateTime,
  150. formatPrice,
  151. loadDetail() {
  152. if (!this.id) return
  153. this.loading = true
  154. const req = this.kind === 'settlement'
  155. ? getSupplierSettlement(this.id)
  156. : getSupplierOrder(this.id)
  157. req
  158. .then((res) => {
  159. this.detail = res.data || null
  160. })
  161. .catch(() => {
  162. this.detail = null
  163. })
  164. .finally(() => {
  165. this.loading = false
  166. })
  167. },
  168. previewImage(url) {
  169. if (!url) return
  170. uni.previewImage({ urls: [url], current: url })
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. @import '@/styles/morandi.scss';
  177. @import '@/styles/detail-page.scss';
  178. .sp-detail-page {
  179. @include detail-page-root;
  180. }
  181. .sp-detail-scroll {
  182. @include detail-page-scroll;
  183. }
  184. .sp-block {
  185. margin: 24rpx 24rpx 0;
  186. padding: 24rpx;
  187. border-radius: 16rpx;
  188. background: $morandi-bg-card;
  189. border: 1rpx solid $morandi-border-soft;
  190. }
  191. .sp-block__head {
  192. display: flex;
  193. flex-direction: row;
  194. align-items: center;
  195. justify-content: space-between;
  196. margin-bottom: 20rpx;
  197. }
  198. .sp-block__title {
  199. font-size: 30rpx;
  200. font-weight: 600;
  201. color: $morandi-text;
  202. }
  203. .sp-block__title--solo {
  204. display: block;
  205. margin-bottom: 20rpx;
  206. }
  207. .sp-block__status {
  208. font-size: 26rpx;
  209. color: $morandi-text-secondary;
  210. }
  211. .sp-block__status--pending {
  212. color: #ea580c;
  213. }
  214. .sp-block__status--done {
  215. color: #16a34a;
  216. }
  217. .sp-field {
  218. display: flex;
  219. flex-direction: row;
  220. align-items: flex-start;
  221. justify-content: space-between;
  222. gap: 24rpx;
  223. padding: 14rpx 0;
  224. border-bottom: 1rpx solid $morandi-border-soft;
  225. }
  226. .sp-field:last-child {
  227. border-bottom-width: 0;
  228. }
  229. .sp-field__label {
  230. flex-shrink: 0;
  231. font-size: 26rpx;
  232. color: $morandi-text-muted;
  233. }
  234. .sp-field__value {
  235. flex: 1;
  236. min-width: 0;
  237. font-size: 26rpx;
  238. color: $morandi-text;
  239. text-align: right;
  240. word-break: break-all;
  241. }
  242. .sp-line-table__head,
  243. .sp-line-table__row {
  244. display: flex;
  245. flex-direction: row;
  246. align-items: center;
  247. padding: 12rpx 0;
  248. }
  249. .sp-line-table__head {
  250. border-bottom: 1rpx solid $morandi-border-soft;
  251. }
  252. .sp-line-table__row {
  253. border-bottom: 1rpx solid $morandi-border-soft;
  254. }
  255. .sp-line-table__row:last-child {
  256. border-bottom-width: 0;
  257. }
  258. .sp-line-table__th,
  259. .sp-line-table__td {
  260. flex: 1;
  261. font-size: 24rpx;
  262. color: $morandi-text-secondary;
  263. text-align: center;
  264. }
  265. .sp-line-table__th {
  266. font-weight: 600;
  267. color: $morandi-text-muted;
  268. }
  269. .sp-line-table__th--tag,
  270. .sp-line-table__td--tag {
  271. flex: 1.2;
  272. text-align: left;
  273. }
  274. .sp-line-table__th--amt,
  275. .sp-line-table__td--amt {
  276. flex: 1;
  277. text-align: right;
  278. }
  279. .sp-line-table__empty {
  280. padding: 24rpx 0;
  281. text-align: center;
  282. }
  283. .sp-line-table__empty-txt {
  284. font-size: 24rpx;
  285. color: $morandi-text-muted;
  286. }
  287. .sp-voucher-row {
  288. display: flex;
  289. flex-direction: row;
  290. align-items: center;
  291. justify-content: space-between;
  292. padding-top: 16rpx;
  293. }
  294. .sp-voucher-img {
  295. width: 120rpx;
  296. height: 120rpx;
  297. border-radius: 8rpx;
  298. background: #e5e7eb;
  299. }
  300. .sp-voucher-placeholder {
  301. width: 120rpx;
  302. height: 120rpx;
  303. border-radius: 8rpx;
  304. background: #f3f4f6;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. }
  309. .sp-voucher-placeholder__txt {
  310. font-size: 22rpx;
  311. color: $morandi-text-muted;
  312. }
  313. .sp-empty {
  314. padding: 80rpx 24rpx;
  315. text-align: center;
  316. }
  317. .sp-empty__txt {
  318. font-size: 28rpx;
  319. color: $morandi-text-muted;
  320. }
  321. .sp-footer-spacer {
  322. height: 40rpx;
  323. }
  324. </style>