<!-- 提前/延迟送检申请列表 --> <script lang="ts" setup name="InspectionList"> import { reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { getListPage } from '@/api/eqpt/measurementPlan/early' import { SCHEDULE } from '@/utils/scheduleDict' const $props = defineProps({ // 申请类型(字典值,提前/延迟) approvalType: { type: String, required: true, }, // 审批状态名字(全部/审批等) statusName: { type: String, required: true, }, }) const applyDict = ref<{ [key: string]: string }>({ 审批: '2', 草稿箱: '1', 审批中: '3', 已通过: '4', 未通过: '5', 已取消: '6', }) const { proxy } = getCurrentInstance() as any const listQuery = reactive({ approvalName: '', // 申请名称 approvalNo: '', // 申请编号 createDeptName: '', // 创建单位 createUserName: '', // 创建人 createTimeEnd: '', // 结束时间 createTimeStart: '', // 开始时间 approvalType: $props.approvalType, offset: 1, limit: 20, formId: '', }) // 设置formid const setFormID = () => { if ($props.approvalType === '0') { listQuery.formId = SCHEDULE.METERING_PLAN_EARLY } else { listQuery.formId = SCHEDULE.METERING_PLAN_DEALY } } setFormID() // 开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { if (newVal.length === 2) { listQuery.createTimeStart = newVal[0] listQuery.createTimeEnd = newVal[1] } }) const columns = ref([ { text: '申请编号', value: 'approvalNo', align: 'center', }, { text: '申请名称', value: 'approvalName', align: 'center', }, { text: '创建单位', value: 'createDeptName', align: 'center', }, { text: '创建人', value: 'createUserName', align: 'center', }, { text: '创建时间', value: 'createTimeStart', align: 'center', }, ]) const list = ref([]) const total = ref(0) const listLoading = ref(true) // 获取数据 const fetchData = (isNowPage = true) => { listLoading.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.offset = 1 } getListPage(listQuery, $props.statusName).then((response) => { list.value = response.data.rows total.value = parseInt(response.data.total) listLoading.value = false }) } fetchData() // 查询数据 const search = () => { fetchData(false) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size: number; page: number }) => { if (val && val.size) { listQuery.limit = val.size } if (val && val.page) { listQuery.offset = val.page } fetchData() } const $router = useRouter() // 新建编辑操作 const handler = (row: any, type: string) => { $router.push({ path: `/ealy/${type}`, query: { row: JSON.stringify(row), id: row.id, approvalType: $props.approvalType, // 申请类型(字典值,提前/延迟) statusName: $props.statusName, // statusName }, }) } // 删除 const delHandler = (row: any) => { ElMessageBox.confirm( '确认删除此分组信息吗?', '确认', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ).then(() => { // delGroup(row.id).then((res) => { // ElMessage.success('操作成功') // search() // }) }) } // 审批状态发生变化 watch(() => $props.statusName, (newVal) => { fetchData() }, { deep: true, // immediate: true, }) </script> <template> <app-container> <!-- 筛选条件 --> <search-area @search="search"> <search-item> <el-input v-model.trim="listQuery.approvalNo" placeholder="申请编号" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.approvalName" placeholder="申请名称" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.createDeptName" placeholder="创建单位" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.createUserName" placeholder="创建人" clearable /> </search-item> <search-item> <el-date-picker v-model="datetimerange" type="datetimerange" value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss" range-separator="至" start-placeholder="证书有效期开始时间" end-placeholder="证书有效期结束时间" /> </search-item> </search-area> <table-container> <template #btns-right> <icon-button icon="icon-add" title="新增" @click="handler({}, 'create')" /> <icon-button icon="icon-export" title="导出" /> </template> <!-- 普通表格 --> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="listLoading" :is-showmulti-select="true" @change="changePage" > <template #columns> <el-table-column label="操作" width="140" align="center"> <template #default="scope"> <el-button link type="primary" size="small" @click="handler(scope.row, 'detail')"> 查看 </el-button> <el-button link type="primary" size="small" @click="handler(scope.row, 'update')"> 编辑 </el-button> <el-button link type="danger" size="small" @click="delHandler(scope.row)"> 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>