<!-- 外送任务单弹窗-单选 --> <script lang="ts" setup name="SelectOrder"> import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getListPage1 } from '@/api/eqpt/subpackage/task' import { getListPage } from '@/api/eqpt/subpackage/directory' import { SCHEDULE } from '@/utils/scheduleDict' import { getAdminDept, getUserDept } from '@/api/system/user' import { getDeptTreeList } from '@/api/system/dept' import { toTreeList } from '@/utils/structure' import { keepSearchParams } from '@/utils/keepQuery' import { getDictByCode } from '@/api/system/dict' import useUserStore from '@/store/modules/user' const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) const singleChecked = ref(-1) const listQuery = reactive({ createTimeEnd: '', createTimeStart: '', createUserName: '', orderNo: '', createDeptId: '', createCompanyId: '', subcontractorCompanyName: '', offset: 1, limit: 5, // approvalStatus: '4', executeFlag: '', formId: SCHEDULE.SUBCONTRACT_DELIVERY_APPROVAL, }) const columns = ref([ { text: '文件编号', value: 'orderNo', align: 'center', }, { text: '外送机构名称', value: 'subcontractorCompanyName', align: 'center', }, { text: '外送机构联系人', value: 'contact', align: 'center', }, { text: '外送机构联系电话', value: 'contactNumber', align: 'center', }, { text: '申请单位', value: 'createCompanyName', align: 'center', }, { text: '申请部门', value: 'createDeptName', align: 'center', }, { text: '申请人', value: 'createUserName', align: 'center', }, { text: '外送设备数量', value: 'equipmentNum', align: 'center', }, { text: '执行情况', value: 'executeFlagName', align: 'center', }, { text: '申请时间', value: 'createTime', align: 'center', }, ]) const list = ref([]) const total = ref(0) const listLoading = ref(true) const userStore = useUserStore() // 获取列表数据 const fetchData = (isNowPage = true) => { list.value = [] // total.value = 0 listLoading.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.offset = 1 } getListPage1(listQuery, '全部').then((response) => { list.value = response.data.rows total.value = parseInt(response.data.total) listLoading.value = false }).catch(() => { listLoading.value = false }) } fetchData() // 开始结束时间 const datetimerange = ref() watch(() => datetimerange.value, (newVal) => { listQuery.createTimeStart = '' listQuery.createTimeEnd = '' if (Array.isArray(newVal)) { if (newVal.length) { listQuery.createTimeStart = `${newVal[0]} 00:00:00` listQuery.createTimeEnd = `${newVal[1]} 23:59:59` } } }) // 查询数据 const search = () => { fetchData(false) } // 重置 const reset = () => { datetimerange.value = [] listQuery.createTimeEnd = '' listQuery.createTimeStart = '' listQuery.createUserName = '' listQuery.orderNo = '' listQuery.createDeptId = '' listQuery.createCompanyId = '' listQuery.subcontractorCompanyName = '' listQuery.executeFlag = '' listQuery.offset = 1 listQuery.limit = 5 search() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 companyList = ref<{ id: string; value: string; name: string }[]>([]) // 执行情况 const executeFlagList = ref<{ id: string; value: string; name: string }[]>([]) const deptList = ref<any>([]) // 检定单位 const measureCompanyList = ref<{ id: string; value: string; name: string }[]>() const fetchCommpany = () => { // 获取单位 getUserDept().then((res) => { if ((res.data.fullName === '顶级' || res.data.version === '1' || res.data.version === 1) && userStore.dataSopeType === '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, }, ] } }) getListPage({ offset: 1, limit: 9999 }, '全部').then((res) => { // console.log(res.data, '1111') measureCompanyList.value = res.data.rows.map((item: any) => ({ name: item.companyName, value: item.id, id: item.id })) }) // 执行情况 getDictByCode('executeFlag').then((res) => { executeFlagList.value = res.data }) } fetchCommpany() watch(() => listQuery.createCompanyId, (newVal) => { listQuery.createDeptId = '' if (newVal) { getDeptTreeList({ pid: newVal }).then((res) => { deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) }) } else { deptList.value = [] } }) // 取消 const resetForm = () => { dialogFormVisible.value = false } // 初始化 const initDialog = () => { dialogFormVisible.value = true } defineExpose({ initDialog }) const submitForm = () => { if (singleChecked.value === -1) { ElMessage.warning('请选择任务单') return } emits('confirm', list.value.filter((item: any) => item.id === singleChecked.value)[0]) dialogFormVisible.value = false } const radioChange = (val: any) => { console.log(val, 'val') } </script> <template> <el-dialog v-model="dialogFormVisible" title="选择任务单" width="75%"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="reset"> <search-item> <el-input v-model.trim="listQuery.orderNo" placeholder="文件编号" clearable /> </search-item> <search-item> <!-- <el-input v-model.trim="listQuery.subcontractorCompanyName" placeholder="外送机构名称" clearable /> --> <el-select v-model="listQuery.subcontractorCompanyName" filterable placeholder="外送机构名称" style="width: 100%;"> <el-option v-for="item in measureCompanyList" :key="item.id" :label="item.name" :value="item.name" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.createCompanyId" clearable filterable placeholder="申请单位" style="width: 100%;"> <el-option v-for="item in companyList" :key="item.id" :label="item.name" :value="item.id" /> </el-select> </search-item> <search-item> <el-tree-select v-model="listQuery.createDeptId" style="width: 100%;" :data="deptList" :render-after-expand="false" check-strictly placeholder="部门" /> </search-item> <search-item> <el-select v-model="listQuery.executeFlag" filterable placeholder="执行情况" style="width: 100%;"> <el-option v-for="item in executeFlagList" :key="item.id" :label="item.name" :value="item.name" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.createUserName" placeholder="申请人" clearable /> </search-item> <search-item> <el-date-picker v-model="datetimerange" type="daterange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" range-separator="至" start-placeholder="申请开始时间" end-placeholder="申请结束时间" clearable /> </search-item> </search-area> <table-container> <!-- 普通表格 --> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="listLoading" :is-showmulti-select="false" :is-multi="true" @change="changePage" > <template #preColumns> <el-table-column label="#" width="55" align="center"> <template #default="scope"> <el-radio v-model="singleChecked" :label="scope.row.id" class="radio" @change="radioChange" /> </template> </el-table-column> </template> </normal-table> </table-container> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="submitForm">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> :deep(.el-radio__label) { display: none; } </style>