<!-- 可引用的模板列表 --> <script lang="ts" setup name="QuoteTemplateListDialog"> import { ElMessage } from 'element-plus' import { ref } from 'vue' import type { DateModelType } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getDeviceNameList, getItemList, getModelAllList } from '@/api/business/measure/item' import { getDictByCode } from '@/api/system/dict' import type { dictType } from '@/global' const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) // 查询条件 const listQuery = ref({ asTemplate: '1', // 是否为模板(查询引用模板时该字段必传1) belongStandardEquipment: '', // 所属检校标准装置(字典code) dataSync: '', // 检定项数据是否同步(1/0) deviceName: '', // 设备名称 deviceType: '', // 设备分类(字典code) helpFieldInstruction: '', // 辅助字段说明 helpInstruction: '', // 辅助字段 itemCategoryId: '', // 设备检定项分类表id(查询引用模板时该字段必传) model: '', // 规格型号 noConfigFlag: '', // 未配置检定项(1查询未配置,不传为查询所有) syncTimeEnd: '', // 自动检定系统最新同步时间结束 syncTimeStart: '', // 自动检定系统最新同步时间开始 limit: 5, offset: 1, }) // 多选选中的内容 const checkoutList = ref([]) const loadingTable = ref(false) const list = ref([]) // 表格数据 const total = ref(0) const columns = ref<TableColumn[]>([ { text: '设备名称', value: 'deviceName', align: 'center' }, { text: '规格型号', value: 'model', align: 'center' }, { text: '辅助字段', value: 'helpInstruction', align: 'center' }, { text: '辅助字段说明', value: 'helpInstruction', align: 'center' }, { text: '设备分类', value: 'deviceTypeName', align: 'center' }, { text: '检校标准装置', value: 'belongStandardEquipmentName', align: 'center' }, { text: '设备检定项分类', value: 'itemCategoryName', align: 'center' }, { text: '检定项更新时间', value: 'updateTime', align: 'center', width: '180' }, { text: '自动检定系统数据是否同步', value: 'dataSyncStr', align: 'center' }, { text: '自动检定系统最新同步时间', value: 'updateTime', align: 'center', width: '180' }, ]) const timeRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const itemCategoryId = ref('') // 检定项分类id // ------------------------------------------字典---------------------------------------------- const deviceTypeList = ref<dictType[]>([])// 设备分类 const deviceTypeMap = ref({}) as any // 设备分类map const isSyncMap = ref({}) as any // 是否同步{1: 是} const isSyncList = ref({}) as any // 是否同步 const deviceNameList = ref<string[]>([]) // 设备名称 const modelList = ref<any[]>([])// 规格型号 const helpList = ref<any[]>([])// 辅助字段 const allList = ref<any[]>([]) async function getDict() { // 是否同步 getDictByCode('bizBusinessMeasureIsSync').then((response) => { isSyncList.value = response.data response.data.forEach((item: any) => { isSyncMap.value[`${item.value}`] = item.name }) }) // 设备分类 const res = await getDictByCode('eqptDeviceType') deviceTypeList.value = res.data res.data.forEach((item: any) => { deviceTypeMap.value[`${item.value}`] = item.name }) // 设备名称 getDeviceNameList().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))) helpList.value = Array.from(new Set(res.data.filter((item: any) => item.helpInstruction).map((item: any) => item.helpInstruction))) }) } getDict() // ------------------------------------------------------------------------------------------------ // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } listQuery.value.itemCategoryId = itemCategoryId.value getItemList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: { deviceType: string }) => { return { ...item, deviceTypeName: deviceTypeMap.value[item.deviceType], // 设备分类 } }) total.value = parseInt(response.data.total) loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { asTemplate: '1', // 是否为模板(查询引用模板时该字段必传1) belongStandardEquipment: '', // 所属检校标准装置(字典code) dataSync: '', // 检定项数据是否同步(1/0) deviceName: '', // 设备名称 deviceType: '', // 设备分类(字典code) helpFieldInstruction: '', // 辅助字段说明 helpInstruction: '', // 辅助字段 itemCategoryId: '', // 设备检定项分类表id(查询引用模板时该字段必传) model: '', // 规格型号 noConfigFlag: '', // 未配置检定项(1查询未配置,不传为查询所有) syncTimeEnd: '', // 自动检定系统最新同步时间结束 syncTimeStart: '', // 自动检定系统最新同步时间开始 limit: 5, offset: 1, } timeRange.value = ['', ''] fetchData() } // 搜索 const search = () => { fetchData(true) } // 多选选中 const handleSelectionChange = (val: any) => { checkoutList.value = val } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 } search() } // 点击确定 const confirmSelect = () => { if (!checkoutList.value.length) { ElMessage.warning('请选择模板') } else { emits('confirm', checkoutList.value) dialogFormVisible.value = false } } // 取消 const resetForm = () => { dialogFormVisible.value = false clearList() } // 初始化 const initDialog = (id: string) => { dialogFormVisible.value = true itemCategoryId.value = id fetchData() } watch(timeRange, (val) => { if (val) { listQuery.value.syncTimeStart = `${val[0]}` listQuery.value.syncTimeEnd = `${val[1]}` } else { listQuery.value.syncTimeStart = '' listQuery.value.syncTimeEnd = '' } }) defineExpose({ initDialog }) </script> <template> <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择模板" width="65%"> <search-area :need-clear="true" @search="search" @clear="clearList"> <search-item> <el-select v-model.trim="listQuery.deviceName" filterable class="short-input" placeholder="设备名称" clearable> <el-option v-for="item in deviceNameList" :key="item" :label="item" :value="item" /> </el-select> </search-item> <search-item> <el-select v-model.trim="listQuery.model" filterable class="short-input" placeholder="规格型号" clearable> <el-option v-for="item in modelList" :key="item" :label="item" :value="item" /> </el-select> </search-item> <search-item> <el-select v-model.trim="listQuery.helpInstruction" class="short-input" placeholder="辅助字段" clearable> <el-option v-for="item in helpList" :key="item" :label="item" :value="item" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.deviceType" placeholder="设备分类" class="short-input" filterable clearable > <el-option v-for="item in deviceTypeList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.dataSync" placeholder="检定点数据是否同步" filterable clearable > <el-option v-for="item in isSyncList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="完成同步时间(开始)" end-placeholder="完成同步时间(结束)" /> </search-item> </search-area> <!-- 查询结果Table显示 --> <div style="padding: 12px;"> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" is-showmulti-select :list-loading="loadingTable" :is-multi="false" :height="260" @change="changePage" @multi-select="handleSelectionChange" > <!-- 序号 --> <template #preColumns> <el-table-column label="#" width="55" align="center" fixed> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> </normal-table> </div> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="confirmSelect">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> :deep(.el-radio__label) { display: none; } </style>