<!-- 智能模型证书管理 --> <script lang="ts" setup name="CertificateList"> import { reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import detailDialog from './components/detailDialog.vue' import { getCertificateList } from '@/api/eqpt/device/certificate' import { getDeviceNameList, getModelAllList, getModelList } from '@/api/eqpt/device/model' import { getAdminDept, getUserDept, getUserDeptSon, getUserList } from '@/api/system/user' import { getDeptList, getDeptTree, getDeptTreeList, getDeptTreeListByPid } from '@/api/system/dept' import showPhoto from '@/views/tested/device/info/components/showPhotoSinge.vue' import { getPhotoUrl } from '@/api/system/tool' import { getPostList } from '@/api/system/post' const { proxy } = getCurrentInstance() as any const listQuery = reactive({ certificateValidEnd: '', certificateValidStart: '', equipmentName: '', model: '', manufactureNo: '', companyId: '', deptId: '', usePositionId: '', directorName: '', checkOrganization: '', certificateNo: '', offset: 1, limit: 20, // sort: 'desc', // orderBy: 'create_time', }) const columns = ref([ { text: '智能模型名称', value: 'equipmentName', align: 'center', }, { text: '规格型号', value: 'model', align: 'center', }, { text: '出厂编号', value: 'manufactureNo', align: 'center', }, { text: '所在单位', value: 'companyName', align: 'center', }, { text: '使用部门', value: 'deptName', align: 'center', }, { text: '校准(检定)单位', value: 'checkOrganization', align: 'center', }, { text: '校准(检定)日期', value: 'checkDate', align: 'center', width: '130', }, { text: '证书编号', value: 'certificateNo', align: 'center', width: '140', }, { text: '证书有效期', value: 'certificateValid', align: 'center', width: '130', }, ]) const list = ref([]) const total = ref(0) const listLoading = ref(true) // 获取数据 const fetchData = (isNowPage = true) => { listLoading.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.offset = 1 } getCertificateList(listQuery).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 detailRef = ref() const handler = (row: any, type: string) => { if (!row.minioFileName) { ElMessage.warning('暂无文件') return } detailRef.value.initDialog(row.minioFileName) // getPhotoUrl(row.minioFileName).then((res) => { // window.open(res.data, '_blank') // }) } const range = ref() watch(() => range.value, (newVal) => { listQuery.certificateValidStart = '' listQuery.certificateValidEnd = '' if (Array.isArray(newVal)) { if (newVal.length) { listQuery.certificateValidStart = `${newVal[0]} 00:00:00` listQuery.certificateValidEnd = `${newVal[1]} 23:59:59` } } }, { deep: true, }) const reset = () => { range.value = [] listQuery.certificateValidEnd = '' listQuery.certificateValidStart = '' listQuery.equipmentName = '' listQuery.model = '' listQuery.manufactureNo = '' listQuery.companyId = '' listQuery.deptId = '' listQuery.usePositionId = '' listQuery.directorName = '' listQuery.checkOrganization = '' listQuery.certificateNo = '' listQuery.offset = 1 listQuery.limit = 20 // listQuery.sort = 'desc' // listQuery.orderBy = 'create_time' search() } // 智能模型名称 const deviceNameList = ref<string[]>([]) // 规格型号 const modelList = ref<any[]>([]) const allList = ref<any[]>([]) // 所在单位 const companyList = ref<{ id: string; value: string; name: string }[]>([]) // 部门 const deptList = ref<{ id: string; value: string; name: string }[]>([]) const deptListAll = ref<{ id: string; value: string; name: string }[]>([]) // 使用岗位 const usePositionList = ref<any[]>([]) // 负责人 const userList = ref<any[]>([]) const fetchDict = () => { // 智能模型名称 getDeviceNameList({ equipmentType: '1' }).then((res) => { deviceNameList.value = res.data }) // 规格型号 getModelAllList({}).then((res) => { allList.value = res.data modelList.value = Array.from(new Set(res.data.filter((item: any) => item.model).map((item: any) => item.model))).sort() }) // 获取使用单位 // getDeptTree({ pid: '0' }).then((res) => { // // 单位 // companyList.value = res.data.filter((item: any) => item.pid === '0').map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) // // 部门 // deptList.value = res.data.filter((item: any) => item.pids.split(',').length === 3).map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) // deptListAll.value = res.data.filter((item: any) => item.pids.split(',').length === 3).map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) // }) getUserDept().then((res) => { // companyInfo.value = res.data if (res.data.fullName === '顶级' || res.data.version === '1' || res.data.version === 1) { getAdminDept({}).then((res) => { companyList.value = res.data.map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) }) } else { companyList.value = [ { name: res.data.fullName, value: res.data.id, id: res.data.id, }, ] } }) // 使用岗位 getPostList({}).then((res) => { usePositionList.value = res.data }) // 负责人 getUserList({ offset: 1, limit: 99999 }).then((res) => { userList.value = res.data.rows }) } fetchDict() // 监听智能模型名称下拉框,修改规格型号和辅助字段 watch(() => listQuery.equipmentName, (newVal) => { if (newVal) { listQuery.model = '' // 修改规格型号和辅助字段列表 const data = allList.value.filter(item => item.equipmentName === newVal) modelList.value = Array.from(new Set(data.filter(item => item.model).map(item => item.model))).sort() } else { listQuery.model = '' modelList.value = Array.from(new Set(allList.value.filter(item => item.model).map(item => item.model))).sort() } }) // 监听所在单位,修改部门 watch(() => listQuery.companyId, (newVal) => { listQuery.deptId = '' if (newVal) { getUserDeptSon({ companyId: newVal }).then((res) => { deptList.value = res.data.map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) }) } else { deptList.value = [] } }, { deep: true, }) </script> <template> <app-container> <!-- 筛选条件 --> <detail-dialog ref="detailRef" /> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-select v-model.trim="listQuery.equipmentName" filterable placeholder="智能模型名称" clearable> <el-option v-for="(item, index) in deviceNameList" :key="index" :label="item" :value="item" /> </el-select> </search-item> <search-item> <el-select v-model.trim="listQuery.model" filterable placeholder="规格型号" clearable> <el-option v-for="item in modelList" :key="item" :label="item" :value="item" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.manufactureNo" placeholder="出厂编号" clearable /> </search-item> <search-item> <el-select v-model="listQuery.companyId" filterable placeholder="所在单位" clearable> <el-option v-for="item in companyList" :key="item.id" :label="item.name" :value="item.id" /> </el-select> </search-item> <search-item> <!-- <dept-select v-model="listQuery.deptIds" placeholder="使用部门" /> --> <el-select v-model="listQuery.deptId" filterable placeholder="使用部门" clearable> <el-option v-for="item in deptList" :key="item.id" :label="item.name" :value="item.id" /> </el-select> </search-item> <search-item> <!-- <el-input v-model.trim="listQuery.usePosition" placeholder="使用岗位" clearable /> --> <el-select v-model="listQuery.usePositionId" placeholder="使用岗位" clearable> <el-option v-for="item in usePositionList" :key="item.id" :label="item.positionName" :value="item.id" /> </el-select> </search-item> <search-item> <!-- <el-input v-model.trim="listQuery.directorName" placeholder="负责人" clearable /> --> <el-select v-model="listQuery.directorName" filterable clearable placeholder="负责人" style="width: 100%;"> <el-option v-for="(item) in userList" :key="item.id" :label="item.name" :value="item.name"> <span style="float: left;">{{ item.name }}</span> <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.deptName }}</span> </el-option> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.checkOrganization" placeholder="校准(检定)单位" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.certificateNo" placeholder="证书编号" clearable /> </search-item> <search-item> <el-date-picker v-model="range" type="daterange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" range-separator="至" start-placeholder="证书有效期开始时间" end-placeholder="证书有效期结束时间" clearable /> </search-item> <!-- <search-item> <el-input v-model.trim="listQuery.certificateNo" placeholder="证书编号" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.certificateName" placeholder="证书名称" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.equipmentNo" placeholder="统一编号" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.checkOrganization" placeholder="校准(检定)单位" clearable /> </search-item> <search-item> <el-date-picker v-model="range" type="daterange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" range-separator="至" start-placeholder="证书有效期开始时间" end-placeholder="证书有效期结束时间" /> </search-item> --> </search-area> <table-container> <!-- 普通表格 --> <normal-table :data="list" :total="total" :columns="columns as any" :query="listQuery" :list-loading="listLoading" :is-showmulti-select="true" @change="changePage" > <template #columns> <el-table-column label="操作" width="250" align="center"> <template #default="scope"> <el-button link type="primary" size="small" @click="handler(scope.row, 'detail')"> 查看 </el-button> <!-- <show-photo :minio-file-name="scope.row.minioFileName" show-name="查看" /> --> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>