OrderDetailForm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <ContentWrap>
  3. <!-- 订单信息 -->
  4. <el-descriptions title="订单信息">
  5. <el-descriptions-item label="订单号: ">{{ orderInfo.no }}</el-descriptions-item>
  6. <el-descriptions-item label="配送方式: ">
  7. <dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="orderInfo.deliveryType" />
  8. </el-descriptions-item>
  9. <!-- TODO 营销活动待实现 -->
  10. <el-descriptions-item label="营销活动: ">秒杀活动</el-descriptions-item>
  11. <el-descriptions-item label="订单类型: ">
  12. <dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="orderInfo.type" />
  13. </el-descriptions-item>
  14. <el-descriptions-item label="收货人: ">{{ orderInfo.receiverName }}</el-descriptions-item>
  15. <el-descriptions-item label="买家留言: ">{{ orderInfo.userRemark }}</el-descriptions-item>
  16. <el-descriptions-item label="订单来源: ">
  17. <dict-tag :type="DICT_TYPE.TERMINAL" :value="orderInfo.terminal" />
  18. </el-descriptions-item>
  19. <el-descriptions-item label="联系电话: ">{{ orderInfo.receiverMobile }}</el-descriptions-item>
  20. <el-descriptions-item label="商家备注: ">{{ orderInfo.remark }}</el-descriptions-item>
  21. <el-descriptions-item label="支付单号: ">{{ orderInfo.payOrderId }}</el-descriptions-item>
  22. <el-descriptions-item label="付款方式: ">
  23. <dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="orderInfo.payChannelCode" />
  24. </el-descriptions-item>
  25. <!-- <el-descriptions-item label="买家: ">{{ orderInfo.user.nickname }}</el-descriptions-item> -->
  26. <!-- TODO 芋艿:待实现:跳转会员 -->
  27. <el-descriptions-item label="收货地址: ">
  28. {{ orderInfo.receiverAreaName }} {{ orderInfo.receiverDetailAddress }}
  29. <el-link
  30. v-clipboard:copy="orderInfo.receiverAreaName + ' ' + orderInfo.receiverDetailAddress"
  31. v-clipboard:success="clipboardSuccess"
  32. icon="ep:document-copy"
  33. type="primary"
  34. />
  35. </el-descriptions-item>
  36. </el-descriptions>
  37. <!-- 订单状态 -->
  38. <el-descriptions :column="1" title="订单状态">
  39. <el-descriptions-item label="订单状态: ">
  40. <dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="orderInfo.status" />
  41. </el-descriptions-item>
  42. <el-descriptions-item label-class-name="no-colon">
  43. <el-button type="primary" @click="openForm('adjustPrice')">调整价格</el-button>
  44. <el-button type="primary" @click="openForm('remark')">备注</el-button>
  45. <el-button type="primary" @click="openForm('delivery')">发货</el-button>
  46. <el-button type="primary" @click="openForm('adjustAddress')">修改地址</el-button>
  47. </el-descriptions-item>
  48. <el-descriptions-item>
  49. <template #label><span style="color: red">提醒: </span></template>
  50. 买家付款成功后,货款将直接进入您的商户号(微信、支付宝)<br />
  51. 请及时关注你发出的包裹状态,确保可以配送至买家手中 <br />
  52. 如果买家表示没收到货或货物有问题,请及时联系买家处理,友好协商
  53. </el-descriptions-item>
  54. </el-descriptions>
  55. <!-- 商品信息 -->
  56. <el-descriptions title="商品信息">
  57. <el-descriptions-item labelClassName="no-colon">
  58. <el-row :gutter="20">
  59. <el-col :span="15">
  60. <el-table :data="orderInfo.items" border>
  61. <el-table-column label="商品" prop="spuName" width="auto">
  62. <template #default="{ row }">
  63. {{ row.spuName }}
  64. <el-tag v-for="property in row.properties" :key="property.propertyId">
  65. {{ property.propertyName }}: {{ property.valueName }}
  66. </el-tag>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="商品原价(元)" prop="price" width="150">
  70. <template #default="{ row }">{{ formatToFraction(row.price) }}</template>
  71. </el-table-column>
  72. <el-table-column label="数量" prop="count" width="100" />
  73. <el-table-column label="合计(元)" prop="payPrice" width="150">
  74. <template #default="{ row }">{{ formatToFraction(row.payPrice) }}</template>
  75. </el-table-column>
  76. <el-table-column label="售后状态" prop="afterSaleStatus" width="120">
  77. <template #default="{ row }">
  78. <dict-tag
  79. :type="DICT_TYPE.TRADE_ORDER_ITEM_AFTER_SALE_STATUS"
  80. :value="row.afterSaleStatus"
  81. />
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </el-col>
  86. <el-col :span="10" />
  87. </el-row>
  88. </el-descriptions-item>
  89. </el-descriptions>
  90. <el-descriptions :column="6">
  91. <el-descriptions-item label="商品总额: ">
  92. {{ formatToFraction(orderInfo.totalPrice) }}元
  93. </el-descriptions-item>
  94. <el-descriptions-item label="运费金额: ">
  95. {{ formatToFraction(orderInfo.deliveryPrice) }}元
  96. </el-descriptions-item>
  97. <el-descriptions-item label="订单调价: ">
  98. {{ formatToFraction(orderInfo.adjustPrice) }}元
  99. </el-descriptions-item>
  100. <el-descriptions-item>
  101. <template #label><span style="color: red">商品优惠: </span></template>
  102. {{ formatToFraction(orderInfo.couponPrice) }}元
  103. </el-descriptions-item>
  104. <el-descriptions-item>
  105. <template #label><span style="color: red">订单优惠: </span></template>
  106. {{ formatToFraction(orderInfo.discountPrice) }}元
  107. </el-descriptions-item>
  108. <el-descriptions-item>
  109. <template #label><span style="color: red">积分抵扣: </span></template>
  110. {{ formatToFraction(orderInfo.pointPrice) }}元
  111. </el-descriptions-item>
  112. <el-descriptions-item v-for="item in 5" :key="item" label-class-name="no-colon" />
  113. <!-- 占位 -->
  114. <el-descriptions-item label="应付金额: ">
  115. {{ formatToFraction(orderInfo.payPrice) }}元
  116. </el-descriptions-item>
  117. </el-descriptions>
  118. <!-- TODO 芋艿:需要改改 -->
  119. <div v-for="group in detailGroups" :key="group.title">
  120. <el-descriptions :title="group.title" v-bind="group.groupProps">
  121. <!-- 订单操作日志 -->
  122. <el-descriptions-item v-if="group.key === 'orderLog'" labelClassName="no-colon">
  123. <el-timeline>
  124. <el-timeline-item
  125. v-for="activity in detailInfo[group.key]"
  126. :key="activity.timestamp"
  127. :timestamp="activity.timestamp"
  128. >
  129. {{ activity.content }}
  130. </el-timeline-item>
  131. </el-timeline>
  132. </el-descriptions-item>
  133. <!-- 物流信息 TODO 等物流接口搞定重构一下 -->
  134. <!-- TODO @xiaobai:改成一个包裹哈;目前只允许发货一次 -->
  135. <el-descriptions-item v-if="group.key === 'expressInfo'" labelClassName="no-colon">
  136. <!-- 循环包裹物流信息 -->
  137. <div v-show="(pkgInfo = detailInfo[group.key]) !== null" style="border: 1px dashed">
  138. <!-- 包裹详情 -->
  139. <el-descriptions class="m-5">
  140. <el-descriptions-item
  141. v-for="(pkgChild, pkgCIdx) in group.children"
  142. :key="`pkgChild_${pkgCIdx}`"
  143. :label="pkgChild.label"
  144. v-bind="pkgChild.childProps"
  145. >
  146. <!-- 包裹商品列表 -->
  147. <template v-if="pkgChild.valueKey === 'goodsList' && pkgInfo[pkgChild.valueKey]">
  148. <div
  149. v-for="(goodInfo, goodInfoIdx) in pkgInfo[pkgChild.valueKey]"
  150. :key="`goodInfo_${goodInfoIdx}`"
  151. style="display: flex"
  152. >
  153. <el-image
  154. :src="goodInfo.imgUrl"
  155. style="width: 100px; height: 100px; flex: none"
  156. />
  157. <el-descriptions :column="1">
  158. <el-descriptions-item labelClassName="no-colon"
  159. >{{ goodInfo.name }}
  160. </el-descriptions-item>
  161. <el-descriptions-item label="数量"
  162. >{{ goodInfo.count }}
  163. </el-descriptions-item>
  164. </el-descriptions>
  165. </div>
  166. </template>
  167. <!-- 包裹物流详情 -->
  168. <template v-else-if="pkgChild.valueKey === 'wlxq'">
  169. <el-row :gutter="10">
  170. <el-col :offset="1" :span="6">
  171. <el-timeline>
  172. <el-timeline-item
  173. v-for="(activity, index) in pkgInfo[pkgChild.valueKey]"
  174. :key="index"
  175. :timestamp="activity.timestamp"
  176. >
  177. {{ activity.content }}
  178. </el-timeline-item>
  179. </el-timeline>
  180. </el-col>
  181. </el-row>
  182. </template>
  183. <template v-else>
  184. {{ pkgInfo[pkgChild.valueKey] }}
  185. </template>
  186. </el-descriptions-item>
  187. </el-descriptions>
  188. </div>
  189. </el-descriptions-item>
  190. </el-descriptions>
  191. </div>
  192. </ContentWrap>
  193. <!-- 各种操作的弹窗 -->
  194. <DeliveryOrderForm ref="deliveryFormRef" @success="getDetail" />
  195. <OrderRemarksForm ref="remarksFormRef" @success="getDetail" />
  196. <OrderAdjustAddressForm ref="adjustAddressFormRef" @success="getDetail" />
  197. <OrderAdjustPriceForm ref="adjustPriceFormRef" @success="getDetail" />
  198. </template>
  199. <script lang="ts" setup>
  200. import * as TradeOrderApi from '@/api/mall/trade/order'
  201. import { formatToFraction } from '@/utils'
  202. import { DICT_TYPE } from '@/utils/dict'
  203. import OrderRemarksForm from '@/views/mall/trade/order/components/OrderRemarksForm.vue'
  204. import DeliveryOrderForm from '@/views/mall/trade/order/components/DeliveryOrderForm.vue'
  205. import OrderAdjustAddressForm from '@/views/mall/trade/order/components/OrderAdjustAddressForm.vue'
  206. import OrderAdjustPriceForm from '@/views/mall/trade/order/components/OrderAdjustPriceForm.vue'
  207. // TODO @puhui999:TradeOrderDetailForm 可以挪到 order/detail/index.vue 中,它是一个 vue 界面哈。
  208. defineOptions({ name: 'TradeOrderDetailForm' })
  209. const message = useMessage() // 消息弹窗
  210. const { params } = useRoute() // 查询参数
  211. // TODO @puhui999:orderInfo 应该不用把属性弄出来也;
  212. const orderInfo = ref<TradeOrderApi.OrderVO>({
  213. no: '',
  214. createTime: null,
  215. type: null,
  216. terminal: null,
  217. userId: null,
  218. userIp: '',
  219. userRemark: '',
  220. status: null,
  221. productCount: null,
  222. finishTime: null,
  223. cancelTime: null,
  224. cancelType: null,
  225. remark: '',
  226. payOrderId: null,
  227. payed: false,
  228. payTime: null,
  229. payChannelCode: '',
  230. originalPrice: null,
  231. orderPrice: null,
  232. discountPrice: null,
  233. deliveryPrice: null,
  234. adjustPrice: null,
  235. payPrice: null,
  236. deliveryTemplateId: null,
  237. logisticsId: null,
  238. logisticsNo: '',
  239. deliveryStatus: null,
  240. deliveryTime: null,
  241. receiveTime: null,
  242. receiverName: '',
  243. receiverMobile: '',
  244. receiverAreaId: null,
  245. receiverPostCode: null,
  246. receiverDetailAddress: '',
  247. afterSaleStatus: null,
  248. refundPrice: null,
  249. couponPrice: null,
  250. pointPrice: null,
  251. receiverAreaName: '',
  252. items: [],
  253. user: {}
  254. })
  255. // TODO @puhui999:这个改成直接读属性,不用按照这种写法;
  256. const detailGroups = ref([
  257. {
  258. title: '物流信息',
  259. key: 'expressInfo',
  260. children: [
  261. { label: '发货时间: ', valueKey: 'fhsj' },
  262. { label: '物流公司: ', valueKey: 'wlgs' },
  263. { label: '运单号: ', valueKey: 'ydh' },
  264. { label: '物流状态: ', valueKey: 'wlzt', childProps: { span: 3 } },
  265. { label: '物流详情: ', valueKey: 'wlxq' }
  266. ]
  267. },
  268. {
  269. title: '订单操作日志',
  270. key: 'orderLog'
  271. }
  272. ])
  273. // TODO @puhui999:从后台读数据哈。
  274. const detailInfo = ref({
  275. // 物流信息
  276. expressInfo: {
  277. label: '包裹1',
  278. name: 'bg1',
  279. fhsj: '2022-11-03 16:50:45',
  280. wlgs: '极兔',
  281. ydh: '2132123',
  282. wlzt: '不支持此快递公司',
  283. wlxq: [
  284. {
  285. content: '正在派送途中,请您准备签收(派件人:王涛,电话:13854563814)',
  286. timestamp: '2018-04-15 15:00:16'
  287. },
  288. {
  289. content: '快件到达 【烟台龙口东江村委营业点】',
  290. timestamp: '2018-04-13 14:54:19'
  291. },
  292. {
  293. content: '快件已发车',
  294. timestamp: '2018-04-11 12:55:52'
  295. },
  296. {
  297. content: '快件已发车',
  298. timestamp: '2018-04-11 12:55:52'
  299. },
  300. {
  301. content: '快件已发车',
  302. timestamp: '2018-04-11 12:55:52'
  303. }
  304. ]
  305. },
  306. orderLog: [
  307. // 订单操作日志
  308. {
  309. content: '买家【乌鸦】关闭了订单',
  310. timestamp: '2018-04-15 15:00:16'
  311. },
  312. {
  313. content: '买家【乌鸦】下单了',
  314. timestamp: '2018-04-15 15:00:16'
  315. }
  316. ],
  317. goodsInfo: [] // 商品详情tableData
  318. })
  319. const deliveryFormRef = ref() // 发货表单 Ref
  320. const remarksFormRef = ref() // 订单备注表单 Ref
  321. const adjustAddressFormRef = ref() // 收货地址表单 Ref
  322. const adjustPriceFormRef = ref() // 订单调价表单 Ref
  323. const openForm = (type: string) => {
  324. switch (type) {
  325. case 'remark':
  326. remarksFormRef.value?.open(orderInfo.value)
  327. break
  328. case 'delivery':
  329. deliveryFormRef.value?.open(orderInfo.value.id)
  330. break
  331. case 'adjustAddress':
  332. adjustAddressFormRef.value?.open(orderInfo.value)
  333. break
  334. case 'adjustPrice':
  335. adjustPriceFormRef.value?.open(orderInfo.value)
  336. break
  337. }
  338. }
  339. /** 获得详情 */
  340. const getDetail = async () => {
  341. const id = params.orderId as unknown as number
  342. if (id) {
  343. const res = (await TradeOrderApi.getOrder(id)) as TradeOrderApi.OrderVO
  344. orderInfo.value = res
  345. }
  346. }
  347. onMounted(async () => {
  348. await getDetail()
  349. })
  350. const clipboardSuccess = () => {
  351. message.success('复制成功')
  352. }
  353. </script>
  354. <style lang="scss" scoped>
  355. :deep(.el-descriptions) {
  356. &:not(:nth-child(1)) {
  357. margin-top: 20px;
  358. }
  359. .el-descriptions__title {
  360. display: flex;
  361. align-items: center;
  362. &::before {
  363. display: inline-block;
  364. width: 3px;
  365. height: 20px;
  366. margin-right: 10px;
  367. background-color: #409eff;
  368. content: '';
  369. }
  370. }
  371. .el-descriptions-item__container {
  372. margin: 0 10px;
  373. .no-colon {
  374. margin: 0;
  375. &::after {
  376. content: '';
  377. }
  378. }
  379. }
  380. }
  381. </style>