<!-- 选择委托单及以下的设备 --> <script lang="ts" setup name="SelectOrderTestEquipment"> import { ElMessage } from 'element-plus' import { ref } from 'vue' import dayjs from 'dayjs' import type { DateModelType } from 'element-plus' import { getEquipmentList, getStandardList } from '@/api/equipment/standard/book' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getOrderDetail, getOrderList } from '@/api/business/manager/order' import { SCHEDULE } from '@/utils/scheduleDict' import { getUserList } from '@/api/system/user' import { getDictByCode } from '@/api/system/dict' import useUserStore from '@/store/modules/user' // 用户信息 const emits = defineEmits(['confirm']) const user = useUserStore() const dialogFormVisible = ref(false) const standardId = ref('') // 标准装置id // 查询条件 const listQuery = ref({ orderNo: '', // 任务单编号 customerId: '', // 委托方id customerName: '', // 委托方名称 createUserName: '', // 创建人 deliverer: '', // 送样人 createStartTime: '', // 创建开始时间 createEndTime: '', // 创建结束时间 receiveStatus: '', // 接收状态 dataSource: '', // 任务单来源 isOnSiteCheck: '', // 是否现场检定(1/0) measureCompany: '', // 检定(校准)单位(字典value,西昌实验室/海口实验室) offset: 1, limit: 20, }) const checkoutList = ref([]) // 多选选中的内容 const checkoutData: any = ref(null) // 选择好的数据 const loadingTable = ref(false) const list = ref([]) // 表格数据 const total = ref(0) const columns = ref<TableColumn[]>([ { text: '委托单编号', value: 'orderNo', align: 'center', width: '160' }, { text: '委托方名称', value: 'customerName', align: 'center' }, { text: '送检时间', value: 'undertakeTime', align: 'center', width: '180' }, { text: '联系人', value: 'deliverer', align: 'center' }, { text: '联系电话', value: 'customerPhone', align: 'center' }, { text: '是否加急', value: 'urgentValue', align: 'center' }, { text: '检定地点', value: 'measureCompany', align: 'center' }, { text: '仪器收发员', value: 'undertakerName', align: 'center', width: '180' }, ]) const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 // -----------------------------------------字典-------------------------------------------------------------- const measureLocationList = ref([])// 检定地点 const sampleStatusList = ref([])// 检定地点 const sampleStatusMap = ref([]) as any // 检定地点 const userList = ref<{ [key: string]: string }[]>([]) // 用户列表 async function getDict() { // 检定状态 const resSampleStatus = await getDictByCode('orderSampleStatus') sampleStatusList.value = resSampleStatus.data resSampleStatus.data.forEach((item: { value: any; name: any }) => { sampleStatusMap.value[`${item.value}`] = item.name }) // 获取用户列表 const res = await getUserList({ offset: 1, limit: 999999 }) userList.value = res.data.rows // 检定地点 getDictByCode('measureLocation').then((response) => { measureLocationList.value = response.data }) } getDict() // -----------------------------------委托单设备--------------------------------------------------- const equipmentList = ref([]) as any // 委托单设备 const equipmentLoadingTable = ref(false) // 委托单设备loading const checkoutEquipmentList = ref([]) as any // 选好的委托单设备 const equipmentColumns = ref<TableColumn[]>([ // 表头 { text: '委托单编号', value: 'taskNo', align: 'center', required: false }, { text: '设备名称', value: 'sampleName', align: 'center', required: true }, { text: '规格型号', value: 'sampleModel', align: 'center', required: true }, { text: '出厂编号', value: 'manufactureNo', align: 'center', required: true }, { text: '附件', value: 'appendixDescn', align: 'center', required: true }, // { text: '生产厂家', value: 'manufacturer', align: 'center', required: true }, { text: '仪器数量', value: 'measureContent', align: 'center', required: true }, { text: '特殊要求', value: 'specialRequire', align: 'center', required: true }, { text: '外观检查', value: 'appearanceInspect', align: 'center', required: true }, { text: '计量价格(元)', value: 'measurePrice', align: 'center', required: true }, { text: '业务类型', value: 'measureCategory', align: 'center', required: true }, { text: '承接专业', value: 'receiveMajor', align: 'center', required: true }, { text: '检定状态', value: 'sampleStatus', align: 'center', required: true }, { text: '分发时间', value: 'createTime', align: 'center', required: false }, { text: '完成时间', value: 'measureCompleteTime', align: 'center', required: true }, // { text: '是否验收', value: 'sfys', align: 'center', required: true, width: 130 }, { text: '是否现场', value: 'onSiteCheck', align: 'center', width: 90, required: true }, { text: '备注', value: 'remark', align: 'center', required: false }, ]) // 选择委托单设备 const handleSelectionChange = (val: any) => { checkoutEquipmentList.value = val } // ----------------------------------------标准装置---------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getOrderList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: { deliverer: string; delivererName: string; requireOverTime: string }) => { const index = userList.value.findIndex(i => i.id === item.deliverer) if (index !== -1) { item.delivererName = userList.value[index].name } item.requireOverTime = item.requireOverTime ? dayjs(item.requireOverTime).format('YYYY-MM-DD') : item.requireOverTime // 有效期(要求检完时间) return item }) total.value = parseInt(response.data.total) loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { orderNo: '', // 任务单编号 customerId: '', // 委托方id customerName: '', // 委托方名称 createUserName: '', // 创建人 deliverer: '', // 送样人 createStartTime: '', // 创建开始时间 createEndTime: '', // 创建结束时间 receiveStatus: '', // 接收状态 dataSource: '', // 任务单来源 isOnSiteCheck: '', // 是否现场检定(1/0) measureCompany: '', // 检定(校准)单位(字典value,西昌实验室/海口实验室) offset: 1, limit: 20, } dateRange.value = ['', ''] fetchData() } // 搜索 const search = () => { fetchData(true) } // 选中 const rowClick = (val: any) => { checkoutList.value = val equipmentLoadingTable.value = true checkoutData.value = { customerId: val.customerId, // 委托方id orderId: val.id, // 委托单id customerNo: val.customerNo, // 委托方代码 customerName: val.customerName, // 委托方名称 } // 请求标准装置下的配套设备 getOrderDetail({ id: val.id }).then((res) => { equipmentList.value = res.data.data.customerSampleInfoList.map((item: { editable: Boolean; sampleStatus: string | number; onSiteCheckTime: string }) => { return { ...item, editable: false, sampleStatusName: sampleStatusMap.value[item.sampleStatus], } }) equipmentLoadingTable.value = false }) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 (!checkoutEquipmentList.value.length) { ElMessage.warning('请选择设备') } else { const params = { ...checkoutEquipmentList.value[0], ...checkoutData.value, } console.log(params) emits('confirm', params) dialogFormVisible.value = false } } // 取消 const resetForm = () => { dialogFormVisible.value = false clearList() } // 初始化 const initDialog = async (id: string) => { equipmentList.value = [] // 清空配套设备 getDict().then(() => { dialogFormVisible.value = true fetchData() }) } defineExpose({ initDialog }) </script> <template> <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择委托单下的设备" width="90%"> <el-row :gutter="16"> <el-col :span="12"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="clearList"> <search-item> <el-input v-model.trim="listQuery.orderNo" placeholder="委托单编号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.customerName" placeholder="委托方名称" class="short-input" clearable /> </search-item> <search-item> <el-select v-model="listQuery.deliverer" placeholder="联系人" class="short-input" filterable clearable > <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.name" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.measureCompany" placeholder="检定地点" class="short-input" clearable /> </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="360" :page-sizes="[5]" @change="changePage" @row-click="rowClick" > <!-- 序号 --> <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> </el-col> <el-col :span="12"> <div style="padding: 12px;"> <normal-table :data="equipmentList" :total="total" :columns="equipmentColumns" :query="listQuery" is-showmulti-select :list-loading="equipmentLoadingTable" :is-multi="false" :height="460" :pagination="false" @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> </el-col> </el-row> <h5 style="color: red;margin: 0 10px;"> 注意:先选择左侧的委托单查询设备展示在右侧 </h5> <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>