Newer
Older
xc-business-system / src / views / resource / customer / info / order.vue
<!-- 委托方任务单列表 -->
<script name="CustomerInfoOrder" lang="ts" setup>
import type { TableColumn } from '@/components/NormalTable/table_interface'
import type { IList, IListQuery } from '@/views/business/manager/order/order-interface'
import { getOrderList } from '@/api/business/manager/order'

const props = defineProps({
  customerId: { type: String, default: '' },
})

const router = useRouter()

const listQuery = ref<IListQuery>({
  customerId: props.customerId, // 委托方名称
  offset: 1,
  limit: 10,
  orderNo: '', // 任务单编号
  customerName: '', // 委托方名称
  createUserName: '', // 创建人
  deliverer: '', // 送样人
  createStartTime: '', // 创建开始时间
  createEndTime: '', // 创建结束时间
  receiveStatus: '', // 接收状态
  dataSource: '', // 任务单来源
  isOnSiteCheck: '', // 是否现场检定(1/0)
  measureCompany: '', // 检定(校准)单位(字典value,西昌实验室/海口实验室)
})

const columns = ref<TableColumn[]>([ // 表头
  { text: '任务单编号', value: 'orderNo', align: 'center', width: '160' },
  // { text: '委托方', value: 'customerName', align: 'center' },
  { text: '受检设备数量', value: 'sampleCount', align: 'center', width: '120' },
  { text: '创建人', value: 'createUserName', align: 'center' },
  { text: '创建时间', value: 'createTime', align: 'center', width: '180' },
  { text: '送检人', value: 'deliverer', align: 'center' },
  { text: '接收状态', value: 'receiveStatusName', align: 'center', width: '150' },
  { text: '是否现场检定', value: 'isOnSiteCheckValue', align: 'center', width: '150' },
  { text: '任务单来源', value: 'dataSource', align: 'center', width: '150' },
])
const list = ref<IList[]>([]) // 表格数据
const total = ref(0) // 数据总数
const loadingTable = ref(false) // 表格加载状态

// 数据查询
function fetchData(isNowPage = false) {
  loadingTable.value = true
  if (!isNowPage) {
    // 是否显示当前页,否则跳转第一页
    listQuery.value.offset = 1
  }

  getOrderList(listQuery.value).then((response) => {
    list.value = response.data.rows
    total.value = parseInt(response.data.total)
    loadingTable.value = false
  })
}

// 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
const changePage = (val: { size?: number; page?: number }) => {
  if (val && val.size) {
    listQuery.value.limit = val.size
  }
  if (val && val.page) {
    listQuery.value.offset = val.page
  }
  fetchData(true)
}

const detailOrder = (row: IList) => {
  router.push({
    path: `/manager/detail/${row.id}`,
  })
}

watch(() => props.customerId, (newVal: string) => {
  listQuery.value.customerId = newVal
  if (newVal !== '') {
    fetchData()
  }
}, { immediate: true })
</script>

<template>
  <app-container>
    <table-container>
      <normal-table
        :data="list" :total="total" :columns="columns" :query="listQuery"
        :list-loading="loadingTable" @change="changePage"
      >
        <template #preColumns>
          <el-table-column label="序号" width="55" align="center">
            <template #default="scope">
              {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }}
            </template>
          </el-table-column>
        </template>

        <template #columns>
          <el-table-column fixed="right" label="操作" align="center" width="130">
            <template #default="{ row }">
              <el-button size="small" type="primary" link @click="detailOrder(row)">
                详情
              </el-button>
            </template>
          </el-table-column>
        </template>
      </normal-table>
    </table-container>
  </app-container>
</template>