<template> <!-- 长效运维子系统 验收台账 --> <div class="publicContainer"> <!-- 搜索区域 --> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> <el-form-item label="项目名称:" prop="projectCodes"> <el-select clearable v-model="queryParams.projectCodes" style="width: 180px" placeholder="请选择项目名称"> <el-option v-for="proj in projectTList" :key="proj.projectNo" :label="proj.projectName" :value="proj.projectNo" /> </el-select> </el-form-item> <el-form-item label="年份" prop="checkDate"> <el-date-picker type="year" v-model="queryParams.checkDate" value-format="YYYY" placeholder="请选择日期"></el-date-picker> </el-form-item> <el-form-item> <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <!-- 按钮区域 --> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" plain icon="Plus" @click="handleAdd">新增</el-button> <el-button icon="Download" type="warning" plain @click="Download">导出</el-button> </el-col> <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar> </el-row> <!-- 表格 --> <el-table v-loading="tableLoading" :data="tableData" max-height="580"> <el-table-column label="巡查日期" prop="checkDate" width="155" /> <el-table-column label="督察巡查类型" prop="patrolTypes"> <template #default="scope"> <dict-tag :options="patrol_type" :value="String(scope.row.patrolTypes)" /> </template> </el-table-column> <el-table-column label="项目名称" prop="projectCodes" width="400"> <template #default="scope"> <p v-for="item in scope.row.projectList">{{ item.projectName }}</p> </template> </el-table-column> <el-table-column label="巡查人员" prop="planUserIds"> <template #default="scope"> <p v-for="item in scope.row.taskUserList">{{ item.userName }}</p> </template> </el-table-column> <el-table-column label="巡查人数" prop="patUserNumber"> </el-table-column> <el-table-column label="项目数量" prop="projectNumber" /> <el-table-column label="参加单位" prop="intoUnit" /> <el-table-column label="创建时间" prop="createTime" width="155" /> <el-table-column label="备注" prop="remark" /> <el-table-column label="操作" width="160" class-name="small-padding fixed-width"> <template #default="scope"> <el-button link type="warning" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button> <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)"> 删除 </el-button> </template> </el-table-column> </el-table> <!-- 分页 --> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getDataList" /> <!-- 添加或修改弹窗 --> <el-dialog :title="dialogTitle" v-model="dialogShow" width="600px" append-to-body> <el-form ref="formRef" :model="formData" :rules="rulesForm" label-width="90px" class="publicForm"> <el-form-item label="巡查日期" prop="checkDate"> <el-date-picker type="date" v-model="formData.checkDate" value-format="YYYY-MM-DD" placeholder="请选择日期"></el-date-picker> </el-form-item> <el-form-item label="巡查类型:" prop="patrolTypes"> <el-select v-model="formData.patrolTypes" placeholder="请选择巡查类型" clearable style="width: 100%"> <el-option v-for="item in patrol_type" :key="item.value" :label="item.label" :value="item.value" /> </el-select> </el-form-item> <el-form-item label="项目名称" prop="projectList"> <el-select clearable filterable v-model="formData.projectList" style="width: 100%" placeholder="请选择项目名称" value-key="projectNo" multiple label="projectName" > <el-option v-for="proj in projectTList" :key="proj.projectNo" :label="proj.projectName" :value="proj.projectNo" /> </el-select> </el-form-item> <el-form-item label="巡查人员:" prop="patrolUserList"> <el-select v-model="formData.patrolUserList" placeholder="请选择巡查人员" clearable style="width: 100%" value-key="userId" label="nickName" multiple > <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId" /> </el-select> </el-form-item> <el-form-item label="巡查人数" prop="patUserNumber"> <el-input type="number" v-model="formData.patUserNumber" controls-position="right" placeholder="请输入巡查人数" /> </el-form-item> <el-form-item label="参加单位" prop="intoUnit"> <el-input type="textarea" v-model="formData.intoUnit" controls-position="right" placeholder="请输入参加单位" /> </el-form-item> <el-form-item label="备注" prop="remark"> <el-input type="textarea" v-model="formData.remark" controls-position="right" placeholder="请输入备注" /> </el-form-item> </el-form> <template #footer> <div class="dialog-footer"> <el-button type="info" @click="cancelForm">取 消</el-button> <el-button type="primary" @click="submitForm">确 定</el-button> </div> </template> </el-dialog> </div> </template> <script setup> import { overSeePage, overSeeAdd, overSeeDel, overSeeEdit } from '@/api/publicService/index'; import { listUser } from '@/api/system/user'; import { getProjectInfoList } from '@/api/preassess/targetManage'; const { proxy } = getCurrentInstance(); const { patrol_type } = proxy.useDict('patrol_type'); // 巡查类型的字典 const tableData = ref([]); const userList = ref([]); const tableLoading = ref(true); const total = ref(0); const dialogShow = ref(false); const dialogTitle = ref(''); const showSearch = ref(true); const projectTList = ref([]); const allData = reactive({ formData: {}, queryParams: { pageNum: 1, pageSize: 10, checkDate: '', }, rulesForm: { intoUnit: [{ required: true, message: '请输入参加单位', trigger: 'blur' }], patUserNumber: [{ required: true, message: '请输入巡检人数', trigger: 'blur' }], checkDate: [{ required: true, message: '请选择巡查日期', trigger: 'change' }], projectList: [{ required: true, message: '请选择项目名称', trigger: 'change' }], patrolUserList: [{ required: true, message: '请选择巡查人员', trigger: 'change' }], patrolTypes: [{ required: true, message: '请选择巡查类型', trigger: 'change' }], }, }); const { queryParams, formData, rulesForm } = toRefs(allData); /** 获取搜索数据列表 */ function getDataList() { tableLoading.value = true; overSeePage(queryParams.value).then(response => { tableData.value = response.data; total.value = response.total; tableLoading.value = false; }); } /** 取消按钮 */ function cancelForm() { dialogShow.value = false; proxy.resetForm('formRef'); //清空表单 } /** 搜索按钮操作 */ function handleQuery() { queryParams.value.pageNum = 1; getDataList(); } /** 重置按钮操作 */ function resetQuery() { proxy.resetForm('queryRef'); handleQuery(); } // 项目接口 async function projectTypeListM() { let { data } = await getProjectInfoList(); projectTList.value = data; } //搜索人员列表 function getUserList() { listUser().then(res => { userList.value = res.data || []; userList.value.map(item => { item.userId = String(item.userId); }); }); } /** 新增按钮操作 */ function handleAdd() { proxy.resetForm('formRef'); //清空表单 formData.value = {}; dialogShow.value = true; dialogTitle.value = '新增督查巡查台账'; } /** 修改按钮操作 */ function handleUpdate(row) { dialogShow.value = true; dialogTitle.value = '修改督查巡查台账'; formData.value = { ...row }; // 做修改回显判断 formData.value.patrolUserList = row.planUserIds ? row.planUserIds.split(',') : []; formData.value.patrolUserList.forEach(element => { element = element.userId; }); formData.value.projectList = row.projectCodes ? row.projectCodes.split(',') : []; } /** 提交按钮 */ function submitForm() { proxy.$refs['formRef'].validate(valid => { if (valid) { // 处理项目传参 formData.value.projectList = formData.value.projectList.map(obj => { // console.log(projectTList.value, 'projectTList.value'); let nameXm = ''; projectTList.value.forEach(item => { if (item.projectNo == obj) { nameXm = item.projectName; } }); return { projectNo: obj, projectName: nameXm }; }); // 处理人员传参 formData.value.patrolUserList = formData.value.patrolUserList.map(item => { return { userId: item }; }); // console.log(formData.value, 'formData.value'); if (dialogTitle.value == '修改督查巡查台账') { overSeeEdit(formData.value).then(response => { proxy.$modal.msgSuccess('修改成功'); dialogShow.value = false; getDataList(); }); } else { if (formData.value.id) delete formData.value.id; overSeeAdd(formData.value).then(response => { proxy.$modal.msgSuccess('新增成功'); dialogShow.value = false; getDataList(); }); } } }); } /** 删除按钮操作 */ function handleDelete(row) { const postIds = row.id; proxy.$modal .confirm('是否确认删除该数据项?') .then(function () { return overSeeDel(postIds); }) .then(() => { getDataList(); proxy.$modal.msgSuccess('删除成功'); }) .catch(() => {}); } //导出 function Download() { proxy.$modal .confirm('是否确认导出?') .then(async () => { proxy.download('/business/overSee/export', {}, `督查巡查台账${new Date().getTime()}.xlsx`); }) .catch(() => {}); } onMounted(() => { getDataList(); projectTypeListM(); getUserList(); }); </script>