Newer
Older
smart-metering-front / src / views / business / subpackage / certificate / list.vue
<!-- 分包证书管理列表 -->
<script lang="ts" setup name="CertificateList">
import type { Ref } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import type { DateModelType } from 'element-plus'
import type { IListQueryRecord } from '../subpackage-interface'
import { printJSON } from '@/utils/printUtils'
import { exportFile } from '@/utils/exportUtils'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { SCHEDULE } from '@/utils/scheduleDict'
const $router = useRouter()
const { proxy } = getCurrentInstance() as any
// 查询条件
const listQuery: Ref<IListQueryRecord> = ref({
  businessSize: '', // 业务规模-字典code
  formId: SCHEDULE.BUSINESS_SUBPACKAGE_MANAGE, // 表单id
  grade: '', // 	履约评级-字典code
  ids: [],
  outsourcerName: '', // 分包方公司名字
  outsourcerNo: '', // 编号
  offset: 1,
  limit: 20,
})
const loadingTable = ref(false)
// 表头
const columns = ref<TableColumn[]>([
  { text: '证书号', value: 'interchangeCode', align: 'center', width: '160px' },
  { text: '证书名称', value: 'customerNo', align: 'center', width: '160px' },
  { text: '样品编号', value: 'customerName', align: 'center', width: '160px' },
  { text: '样品名称', value: 'reciever', align: 'center', width: '180px' },
  { text: '型号', value: 'deliverer', align: 'center', width: '180px' },
  { text: '出厂编号', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '检测单位', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '打印状态', value: 'deliverTime', align: 'center', width: '180px' },
  { text: '创建时间', value: 'deliverTime', align: 'center', width: '180px' },
])
const list = ref([])
const total = ref(0)

// 数据查询
function fetchData(isNowPage = false) {
  loadingTable.value = true
  if (!isNowPage) {
    // 是否显示当前页,否则跳转第一页
    listQuery.value.offset = 1
  }
  // 模拟数据
  loadingTable.value = false
  // getListPage(listQuery.value).then((response) => {
  //   list.value = response.data.rows
  //   let interfaceStr = ''
  //   for (const key in response.data.rows[0]) {
  //     const item = response.data.rows[0][key]
  //     interfaceStr += `${key}:${typeof (item)}\n`
  //   }
  //   console.log(interfaceStr)
  //   total.value = parseInt(response.data.total)
  //   loadingTable.value = false
  // })
}
// 搜索
const searchList = () => {
  fetchData(true)
}

// 清除条件
const clearList = () => {
  listQuery.value = {
    businessSize: '',
    // evaluation: '',
    formId: '',
    grade: '',
    outsourcerName: '',
    outsourcerNo: '',
    offset: 1,
    limit: 20,
  }
  fetchData()
}
// 导出
const exportAll = () => {

}
// 打印
const printList = () => {

}
// 分页
const changePage = () => {

}
// 选中
const handleSelectionChange = () => {

}
// 详情
const handleDetail = (row) => {

}

onMounted(async () => {
  fetchData()
})
</script>

<template>
  <div>
    <!-- 布局 -->
    <app-container>
      <search-area :need-clear="true" @search="searchList" @clear="clearList">
        <search-item>
          <el-input v-model.trim="listQuery.outsourcerNo" placeholder="证书号" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.outsourcerName" placeholder="证书名称" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.businessSize" placeholder="样品编号" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.grade" placeholder="样品名称" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-input v-model.trim="listQuery.grade" placeholder="监测单位" class="short-input" clearable />
        </search-item>
        <search-item>
          <el-select
            v-model="listQuery.grade"
            placeholder="打印状态"
            class="short-input"
          >
            <el-option label="可打印" value="1" />
            <el-option label="不可打印" value="2" />
          </el-select>
        </search-item>
      </search-area>
      <table-container>
        <template #btns-right>
          <icon-button icon="icon-import" title="批量导入" type="primary" />
          <icon-button icon="icon-template" title="模板下载" type="primary" />
          <icon-button icon="icon-add" title="新建" type="primary" />
          <icon-button icon="icon-export" title="导出" type="primary" @click="exportAll" />
          <icon-button icon="icon-print" title="打印" type="primary" @click="printList" />
        </template>
        <normal-table
          :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable"
          is-showmulti-select @change="changePage" @multi-select="handleSelectionChange"
        >
          <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 label="操作" align="center" fixed="right" width="120">
              <template #default="{ row }">
                <el-button size="small" link type="primary" @click="handleDetail(row)">
                  详情
                </el-button>
              </template>
            </el-table-column>
          </template>
        </normal-table>
      </table-container>
    </app-container>
  </div>
</template>