<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="提交人" prop="submitter">
        <el-input v-model="queryParams.submitter" placeholder="请输入提交人" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="队室负责人" prop="teamLeader">
        <el-input v-model="queryParams.teamLeader" placeholder="请输入队室负责人" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['ledger:leaderDuty:export']">导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
    </el-row>
    <el-table v-loading="loading" :data="list">
      <el-table-column label="提交人" align="center" prop="submitter" width="100" />
      <el-table-column label="队室负责人" align="center" prop="teamLeader" width="110" />
      <el-table-column label="队室质控员" align="center" prop="qualityOfficer" width="110" />
      <el-table-column label="工作提示" align="center" prop="workTip" min-width="150" show-overflow-tooltip />
      <el-table-column label="问题处置及整改措施" align="center" prop="problemHandling" min-width="200" show-overflow-tooltip />
      <el-table-column label="本班点评" align="center" prop="classComment" min-width="200" show-overflow-tooltip />
      <el-table-column label="导入时间" align="center" prop="createTime" width="160">
        <template #default="{ row }">{{ parseTime(row.createTime) }}</template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  </div>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { listLeaderDuty, exportLeaderDuty } from '@/api/ledger/index'
import { parseTime } from '@/utils/ruoyi'
defineOptions({ name: 'LedgerLeaderDuty' })
const loading = ref(false), list = ref([]), total = ref(0), showSearch = ref(true)
const queryRef = ref(null)
const queryParams = reactive({ pageNum: 1, pageSize: 10, submitter: '', teamLeader: '' })
function getList() {
  loading.value = true
  listLeaderDuty({ ...queryParams }).then(r => { list.value = r.rows; total.value = r.total }).finally(() => loading.value = false)
}
function handleQuery() { queryParams.pageNum = 1; getList() }
function resetQuery() { queryRef.value?.resetFields(); handleQuery() }
function handleExport() { exportLeaderDuty({ ...queryParams }) }
onMounted(getList)
</script>
