orderList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="container">
  3. <Breadcrumb :items="['售后服务', '我的工单']" />
  4. <a-card title="工单列表">
  5. <a-button type="primary" size="large" @click="$router.push('/service/createOrder')">
  6. <template #icon>
  7. <icon-plus />
  8. </template>
  9. 提交工单
  10. </a-button>
  11. <a-table :data="data" stripe hoverable column-resizable class="table" :loading="loading" :columns="columns"
  12. :pagination="{
  13. showPageSize: true,
  14. showJumper: true,
  15. showTotal: true,
  16. pageSize: pagination.pagesize,
  17. current: pagination.current,
  18. total: pagination.total
  19. }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
  20. <template #create_time="{ record }">
  21. {{ stramptoTime(record.create_time) }}
  22. </template>
  23. <template #update_time="{ record }">
  24. {{ stramptoTime(record.update_time) }}
  25. </template>
  26. <template #state="{ record }">
  27. <a-tag color="orangered" v-if="record.state === 0">
  28. <template #icon>
  29. <icon-schedule />
  30. </template>
  31. 待处理
  32. </a-tag>
  33. <a-tag color="arcoblue" v-else-if="record.state === 1">
  34. <template #icon>
  35. <icon-customer-service />
  36. </template>
  37. 已回复
  38. </a-tag>
  39. <a-tag color="green" v-else-if="record.state === 2">
  40. <template #icon>
  41. <icon-check-circle />
  42. </template>
  43. 已关闭
  44. </a-tag>
  45. </template>
  46. <template #optional="{ record }">
  47. <a-button @click="$router.push(`/service/orderDetail/${record.id}`)">查看详情</a-button>
  48. </template>
  49. </a-table>
  50. </a-card>
  51. </div>
  52. </template>
  53. <script setup>
  54. import { ref, reactive, onMounted } from 'vue'
  55. import { orderList } from '@/api/workOrder'
  56. import { Notification } from '@arco-design/web-vue'
  57. const pagination = reactive({
  58. total: 0,
  59. current: 1,
  60. pagesize: 20
  61. })
  62. const columns = [
  63. {
  64. title: '工单ID',
  65. dataIndex: 'id',
  66. },
  67. {
  68. title: '工单标题',
  69. dataIndex: 'title',
  70. }, {
  71. title: '提醒邮箱',
  72. dataIndex: 'email',
  73. }, {
  74. title: '创建时间',
  75. slotName: 'create_time'
  76. }, {
  77. title: '最后更新时间',
  78. slotName: 'update_time'
  79. }, {
  80. title: '状态',
  81. slotName: 'state'
  82. }, {
  83. title: '操作',
  84. slotName: 'optional'
  85. }
  86. ]
  87. const loading = ref(false)
  88. const data = ref([])
  89. const getOrderList = async () => {
  90. try {
  91. loading.value = true
  92. const reqData = {
  93. pagesize: pagination.pagesize,
  94. current: pagination.current
  95. }
  96. const res = await orderList(reqData)
  97. if (!res || res.code !== 0)
  98. return Notification.error({
  99. title: '获取工单失败!',
  100. content: res?.msg ?? '请稍后再试'
  101. })
  102. data.value = res.data
  103. pagination.total = res.pagination.total
  104. } catch (error) {
  105. Notification.error({
  106. title: '获取工单失败!',
  107. content: error.message || '请稍后再试'
  108. })
  109. } finally {
  110. loading.value = false
  111. }
  112. }
  113. // 分页 - 页码变化
  114. const handlePageChange = (page) => {
  115. pagination.current = page
  116. getOrderList()
  117. }
  118. // 分页 - 每页条数变化
  119. const handlePageSizeChange = (size) => {
  120. pagination.pagesize = size
  121. pagination.current = 1 // 页大小变化后回到第一页
  122. getOrderList()
  123. }
  124. onMounted(() => {
  125. getOrderList()
  126. })
  127. const stramptoTime = (time) => {
  128. return new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
  129. }
  130. </script>
  131. <style scoped>
  132. .container {
  133. padding: 0 20px 20px 20px;
  134. }
  135. .table {
  136. margin-top: 15px;
  137. }
  138. </style>