| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <div class="container">
- <Breadcrumb :items="['售后服务', '我的工单']" />
- <a-card title="工单列表">
- <a-button type="primary" size="large" @click="$router.push('/service/createOrder')">
- <template #icon>
- <icon-plus />
- </template>
- 提交工单
- </a-button>
- <a-table :data="data" stripe hoverable column-resizable class="table" :loading="loading" :columns="columns"
- :pagination="{
- showPageSize: true,
- showJumper: true,
- showTotal: true,
- pageSize: pagination.pagesize,
- current: pagination.current,
- total: pagination.total
- }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
- <template #create_time="{ record }">
- {{ stramptoTime(record.create_time) }}
- </template>
- <template #update_time="{ record }">
- {{ stramptoTime(record.update_time) }}
- </template>
- <template #state="{ record }">
- <a-tag color="orangered" v-if="record.state === 0">
- <template #icon>
- <icon-schedule />
- </template>
- 待处理
- </a-tag>
- <a-tag color="arcoblue" v-else-if="record.state === 1">
- <template #icon>
- <icon-customer-service />
- </template>
- 已回复
- </a-tag>
- <a-tag color="green" v-else-if="record.state === 2">
- <template #icon>
- <icon-check-circle />
- </template>
- 已关闭
- </a-tag>
- </template>
- <template #optional="{ record }">
- <a-button @click="$router.push(`/service/orderDetail/${record.id}`)">查看详情</a-button>
- </template>
- </a-table>
- </a-card>
- </div>
- </template>
- <script setup>
- import { ref, reactive, onMounted } from 'vue'
- import { orderList } from '@/api/workOrder'
- import { Notification } from '@arco-design/web-vue'
- const pagination = reactive({
- total: 0,
- current: 1,
- pagesize: 20
- })
- const columns = [
- {
- title: '工单ID',
- dataIndex: 'id',
- },
- {
- title: '工单标题',
- dataIndex: 'title',
- }, {
- title: '提醒邮箱',
- dataIndex: 'email',
- }, {
- title: '创建时间',
- slotName: 'create_time'
- }, {
- title: '最后更新时间',
- slotName: 'update_time'
- }, {
- title: '状态',
- slotName: 'state'
- }, {
- title: '操作',
- slotName: 'optional'
- }
- ]
- const loading = ref(false)
- const data = ref([])
- const getOrderList = async () => {
- try {
- loading.value = true
- const reqData = {
- pagesize: pagination.pagesize,
- current: pagination.current
- }
- const res = await orderList(reqData)
- if (!res || res.code !== 0)
- return Notification.error({
- title: '获取工单失败!',
- content: res?.msg ?? '请稍后再试'
- })
- data.value = res.data
- pagination.total = res.pagination.total
- } catch (error) {
- Notification.error({
- title: '获取工单失败!',
- content: error.message || '请稍后再试'
- })
- } finally {
- loading.value = false
- }
- }
- // 分页 - 页码变化
- const handlePageChange = (page) => {
- pagination.current = page
- getOrderList()
- }
- // 分页 - 每页条数变化
- const handlePageSizeChange = (size) => {
- pagination.pagesize = size
- pagination.current = 1 // 页大小变化后回到第一页
- getOrderList()
- }
- onMounted(() => {
- getOrderList()
- })
- const stramptoTime = (time) => {
- return new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
- }
- </script>
- <style scoped>
- .container {
- padding: 0 20px 20px 20px;
- }
- .table {
- margin-top: 15px;
- }
- </style>
|