list.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="p-4">
  3. <BasicTable @register="registerTable">
  4. <template #toolbar> </template>
  5. <template #cover="{ record }">
  6. <TableImg :size="150" :simpleShow="true" :imgList="[record.cover]" />
  7. </template>
  8. <template #orderType="{ record }"> {{ renderOrderTypeLabel(record.orderType) }} </template>
  9. <template #orderStatus="{ record }">
  10. {{ renderOrderStatusLabel(record.orderStatus) }}
  11. </template>
  12. <template #shipingStatus="{ record }">
  13. {{ renderShipingStatusLabel(record.shipingStatus) }}
  14. </template>
  15. <template #paymentStatus="{ record }">
  16. {{ renderPaymentStatusLabel(record.paymentStatus) }}
  17. </template>
  18. <template #action="{ record }">
  19. <TableAction
  20. :actions="[
  21. {
  22. icon: 'mdi:information-outline',
  23. label: '详情',
  24. onClick: () => {
  25. go(`/order/list/detail/${record.orderNo}`);
  26. },
  27. },
  28. {
  29. icon: 'mdi:printer-outline',
  30. label: '打印',
  31. color: 'error',
  32. onClick: () => {
  33. createMessage.info(`暂未接入`);
  34. },
  35. },
  36. ]"
  37. />
  38. </template>
  39. </BasicTable>
  40. </div>
  41. </template>
  42. <script lang="ts">
  43. import { defineComponent } from 'vue';
  44. import {
  45. BasicTable,
  46. useTable,
  47. BasicColumn,
  48. FormProps,
  49. TableAction,
  50. TableImg,
  51. } from '/@/components/Table';
  52. import { useMessage } from '/@/hooks/web/useMessage';
  53. import { uploadApi } from '/@/api/sys/upload';
  54. // import { Switch } from 'ant-design-vue';
  55. // import { h } from 'vue';
  56. import { ListApi } from '/@/api/order/list';
  57. import { useI18n } from '/@/hooks/web/useI18n';
  58. // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
  59. import { useGo } from '/@/hooks/web/usePage';
  60. export default defineComponent({
  61. components: { BasicTable, TableAction, TableImg },
  62. setup() {
  63. const { createMessage } = useMessage();
  64. const go = useGo();
  65. const { t } = useI18n();
  66. const columns: BasicColumn[] = [
  67. {
  68. title: 'ID',
  69. dataIndex: 'id',
  70. fixed: 'left',
  71. width: 60,
  72. },
  73. {
  74. title: '订单号',
  75. dataIndex: 'orderNo',
  76. width: 160,
  77. },
  78. {
  79. title: '会员昵称',
  80. dataIndex: 'name',
  81. width: 80,
  82. },
  83. {
  84. title: 'VR场景',
  85. dataIndex: 'scene.name',
  86. width: 80,
  87. },
  88. {
  89. title: '订单类型',
  90. dataIndex: 'orderType',
  91. slots: { customRender: 'orderType' },
  92. sorter: true,
  93. width: 80,
  94. },
  95. {
  96. title: '订单状态',
  97. dataIndex: 'orderStatus',
  98. sorter: true,
  99. slots: { customRender: 'orderStatus' },
  100. width: 80,
  101. },
  102. {
  103. title: '发货状态',
  104. dataIndex: 'shipingStatus',
  105. sorter: true,
  106. slots: { customRender: 'shipingStatus' },
  107. width: 80,
  108. },
  109. {
  110. title: '付款状态',
  111. dataIndex: 'paymentStatus',
  112. slots: { customRender: 'paymentStatus' },
  113. width: 60,
  114. },
  115. {
  116. title: '快递公司',
  117. dataIndex: 'shipingCompany',
  118. width: 60,
  119. },
  120. {
  121. title: '快递单号',
  122. dataIndex: 'shipingNo',
  123. width: 80,
  124. },
  125. {
  126. title: '实际支付金额',
  127. dataIndex: 'shipingAmount',
  128. width: 80,
  129. },
  130. {
  131. title: '下单时间',
  132. dataIndex: 'createTime',
  133. width: 120,
  134. },
  135. {
  136. title: '操作',
  137. dataIndex: '',
  138. slots: { customRender: 'action' },
  139. fixed: 'right',
  140. width: 140,
  141. },
  142. ];
  143. const searchForm: Partial<FormProps> = {
  144. labelWidth: 100,
  145. schemas: [
  146. {
  147. field: 'orderNo',
  148. label: '订单号',
  149. component: 'Input',
  150. colProps: {
  151. xl: 5,
  152. xxl: 5,
  153. },
  154. },
  155. ],
  156. };
  157. const [registerTable] = useTable({
  158. title: '订单列表',
  159. api: ListApi,
  160. columns: columns,
  161. useSearchForm: true,
  162. formConfig: searchForm,
  163. showTableSetting: true,
  164. tableSetting: { fullScreen: true },
  165. showIndexColumn: false,
  166. rowKey: 'id',
  167. pagination: { pageSize: 20 },
  168. bordered: true,
  169. });
  170. function renderOrderTypeLabel(type: number): string {
  171. switch (type) {
  172. case 0:
  173. return '立即购买';
  174. case 1:
  175. return '延后购买';
  176. default:
  177. return '立即购买';
  178. }
  179. }
  180. function renderOrderStatusLabel(type: number): string {
  181. switch (type) {
  182. case 0:
  183. return '已取消';
  184. case 1:
  185. return '待付款';
  186. case 2:
  187. return '已付款';
  188. case 3:
  189. return '已发货';
  190. case 4:
  191. return '已收货';
  192. default:
  193. return '';
  194. }
  195. }
  196. function renderShipingStatusLabel(type: number): string {
  197. switch (type) {
  198. case 0:
  199. return '未发货';
  200. case 1:
  201. return '已发货';
  202. default:
  203. return '';
  204. }
  205. }
  206. function renderPaymentStatusLabel(type: number): string {
  207. switch (type) {
  208. case 0:
  209. return '未付款';
  210. case 1:
  211. return '已付款';
  212. default:
  213. return '';
  214. }
  215. }
  216. return {
  217. registerTable,
  218. createMessage,
  219. t,
  220. go,
  221. renderOrderTypeLabel,
  222. renderOrderStatusLabel,
  223. renderShipingStatusLabel,
  224. renderPaymentStatusLabel,
  225. uploadApi: uploadApi as any,
  226. };
  227. },
  228. });
  229. </script>