From f91c24d2b2b513716ffe9f4259a8a343c841bb00 Mon Sep 17 00:00:00 2001 From: 13937891274 <kxc0822> Date: 星期六, 30 七月 2022 18:10:28 +0800 Subject: [PATCH] 数据对接 --- src/views/contingencyManagement/emergencyPlanStartRecord/component/selectEmergencyPlan.vue | 406 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 229 insertions(+), 177 deletions(-) diff --git a/src/views/contingencyManagement/emergencyPlanStartRecord/component/selectEmergencyPlan.vue b/src/views/contingencyManagement/emergencyPlanStartRecord/component/selectEmergencyPlan.vue index 2d72476..4bd255b 100644 --- a/src/views/contingencyManagement/emergencyPlanStartRecord/component/selectEmergencyPlan.vue +++ b/src/views/contingencyManagement/emergencyPlanStartRecord/component/selectEmergencyPlan.vue @@ -1,202 +1,254 @@ <template> - <el-dialog - v-model="dialogVisible" - title="选择应急预案" - width="900px" - draggable - :fullscreen="full" - > - <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button> - <el-row> - <el-col :span="18"> - <el-row> - <el-col :span="24"> - <el-form ref="ruleFormRef" :model="ruleForm" :inline="true" status-icon> - <el-form-item> - <el-input size="default" v-model="ruleForm.pass" placeholder="预案名称" style="max-width: 215px;"/> - </el-form-item> - <el-form-item> - <el-input size="default" v-model="ruleForm.checkPass" placeholder="预案类型" style="max-width: 215px;padding: 0 12px;"/> - </el-form-item> - <el-form-item> - <el-button size="default" type="primary" @click="submitForm(ruleFormRef)">查询</el-button> - <el-button size="default" @click="resetForm(ruleFormRef)">重置</el-button> - </el-form-item> - </el-form> - </el-col> - <el-col :span="24"> - <el-button size="default" :icon="Delete" style="margin-top: 15px;">清除选择</el-button> - </el-col> - </el-row> - <el-table :data="tableData" style="width: 100%;margin-top:20px"> - <el-table-column width="55"> - <template #default="scope"> - <el-radio-group v-model="radio1" @change="radio"> - <el-radio :label="scope.row.pass" size="large">{{null}}</el-radio> - </el-radio-group> - </template> - </el-table-column> - <el-table-column align="center" prop="pass" label="预案名称" /> - <el-table-column align="center" prop="checkPass" label="预案类型"/> - </el-table> - <div class="pages"> - <el-pagination - v-model:currentPage="currentPage4" - v-model:page-size="pageSize4" - :page-sizes="[100, 200, 300, 400]" - :small="small" - :disabled="disabled" - :background="background" - layout="total, sizes, prev, pager, next, jumper" - :total="400" - @size-change="handleSizeChange" - @current-change="handleCurrentChange" - /> - </div> - </el-col> - <el-col :span="6"> - <el-tag - v-for="tag in dynamicTags" - :key="tag" - class="mx-1" - style="margin: 5px" - closable - :disable-transitions="false" - @close="handleClose(tag)" + <el-dialog v-model="dialogVisible" title="选择应急预案" width="900px" draggable :fullscreen="full"> + <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button> + <el-row> + <el-col :span="18"> + <el-row> + <el-col :span="24"> + <el-form ref="ruleFormRef" :inline="true" :model="ruleForm" status-icon> + <el-form-item> + <el-input size="default" v-model="listQuery.searchParams.name" placeholder="预案名称" style="max-width: 215px" /> + </el-form-item> + <el-form-item> + <el-select size="default" v-model="listQuery.searchParams.type" placeholder="请选择预案类型" class="ml10" style="max-width: 215px;margin-right: 12px;"> + <el-option label="综合应急预案" value="admin"></el-option> + <el-option label="现场处置方案" value="common"></el-option> + <el-option label="专项应急预案" value="common"></el-option> + <el-option label="其他预案" value="common"></el-option> + </el-select> + </el-form-item> + <el-form-item> + <el-button size="default" type="primary" @click="onSubmit">查询</el-button> + <el-button size="default" @click="submitReset">重置</el-button> + </el-form-item> + </el-form> + </el-col> + <el-col :span="24"> + <el-button size="default" :icon="Delete" style="margin-top: 15px">清除选择</el-button> + </el-col> + </el-row> + <el-table + :data="tableData" + style="width: 100%; + margin-top: 20px" + @cell-click="radio" > - {{ tag }} - </el-tag> - </el-col> - </el-row> - <template #footer> + <el-table-column width="55"> + <template #default="scope"> + <el-radio-group v-model="radio1"> + <el-radio :label="scope.row" size="large">{{ null }}</el-radio> + </el-radio-group> + </template> + </el-table-column> + <el-table-column align="center" prop="name" label="预案名称" /> + <el-table-column align="center" prop="type" label="预案类型" /> + </el-table> + <div class="pages"> + <el-pagination + v-model:currentPage="pageIndex" + v-model:page-size="pageSize" + :page-sizes="[10, 20, 30]" + layout="total, sizes, prev, pager, next, jumper" + :total="total" + @size-change="onHandleSizeChange" + @current-change="onHandleCurrentChange" + /> + </div> + </el-col> + <el-col :span="6"> + <div v-if="dynamicTags[0] == '' ? false : true"> + <el-tag + v-for="tag in dynamicTags" + :key="tag" + class="mx-1" + style="margin: 5px" + closable + :disable-transitions="false" + @close="handleClose(tag)" + > + {{ tag.name }} + </el-tag> + </div> + </el-col> + </el-row> + <template #footer> <span class="dialog-footer"> <el-button @click="dialogVisible = false" size="default">关闭</el-button> - <el-button type="primary" @click="dialogVisible = false" size="default">确定</el-button> + <el-button type="primary" @click="submitForm" size="default">确定</el-button> </span> - </template> - </el-dialog> + </template> + </el-dialog> </template> <script lang="ts"> -import { - defineComponent, - reactive, - ref -} from 'vue'; -import { - Delete, - FullScreen -} from '@element-plus/icons-vue'; +import { defineComponent, reactive, ref, onMounted } from 'vue'; +import { ElMessage } from 'element-plus'; +import { Delete, FullScreen } from '@element-plus/icons-vue'; +import { emergencyPlanLogApi } from '/@/api/emergencyPlanLog'; +import { emergencyPlanApi } from '/@/api/emergencyPlan'; export default defineComponent({ - setup() { - const dialogVisible = ref<boolean>(false); - const openDailog = () => { - dialogVisible.value = true; - }; - // 搜索条件 - const ruleForm = reactive({ - pass: '', - checkPass: '', + setup(props, { emit }) { + const dialogVisible = ref<boolean>(false); + const openDailog = () => { + dialogVisible.value = true; + listApi() + }; + // 搜索条件 + const listQuery = reactive({ + pageIndex: 1, + pageSize: 10, + searchParams: { + name: '', + type: '', + }, + }); + // 列表参数 + const listQuery2 = reactive({ + pageIndex: 1, + pageSize: 10, + searchParams: { + planId: '', + }, }); - // 表格 - const tableData = [ - { - pass: '生产安全事故应急预案202102', - checkPass: '1', - }, - { - pass: '生产安全事故应急预案', - checkPass: '2', - }, - { - pass: '作业人员触电事故现场处置方案', - checkPass: '4', - }, - { - pass: '船舶碰撞码头事故专项应急预案', - checkPass: '2', - }, - ]; - const pageSize4 = ref(100); - const handleSizeChange = (val: number) => { - console.log(`${val} items per page`); + // 定义表格数据 + const tableData = ref([]); + // 请求列表数据 + const onSubmit = async () => { + let res = await emergencyPlanLogApi().getEmergencyPlanLogList(listQuery2); + if (res.data.code == 200) { + tableData.value = res.data.data; + pageIndex.value = res.data.pageIndex; + pageSize.value = res.data.pageSize; + total.value = res.data.total; + } else { + ElMessage.error(res.data.msg); + } + }; + // 重置 + const submitReset = () => { + listQuery.searchParams.name = ''; + listQuery.searchParams.type = ''; + onSubmit(); }; - const handleCurrentChange = (val: number) => { - console.log(`current page: ${val}`); - }; - // 右方点击添加后显示标签 - const dynamicTags = ref(['船舶碰撞码头事故专项应急预案']); - const handleClose = (tag: string) => { - dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1); - radio1.value="" - }; - const radio1=ref('生产安全事故应急预案202102') - const radio=(event:any)=>{ - dynamicTags.value[0]=event - } - //全屏 - const full = ref(false); - const toggleFullscreen = () => { - if (full.value == false) { - full.value = true; - } else { - full.value = false; - } - }; - return { - dialogVisible, - openDailog, - ruleForm, - tableData, - pageSize4, - handleSizeChange, - handleCurrentChange, - dynamicTags, - handleClose, - Delete, - radio1, - radio, - toggleFullscreen, - FullScreen, - full, - }; - }, + + // 列表请求数据 + const listApi = async () => { + let res = await emergencyPlanApi().getEmergencyPlanList(listQuery); + if (res.data.code === '200') { + tableData.value = res.data.data; + pageIndex.value = res.data.pageIndex; + pageSize.value = res.data.pageSize; + total.value = res.data.total; + } else { + ElMessage({ + showClose: true, + type: 'error', + message: res.data.msg, + }); + } + }; + // 分页 + const pageIndex = ref(); + const pageSize = ref(); + const total = ref(); + // 分页改变 + const onHandleSizeChange = (val: number) => { + listQuery.pageSize = val; + }; + // 分页未改变 + const onHandleCurrentChange = (val: number) => { + listQuery.pageIndex = val; + }; + // 右方点击添加后显示标签 + const dynamicTags = ref(['']); + const handleClose = (tag: string) => { + dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1); + radio1.value = ''; + }; + const radio1 = ref(''); + const radio = (event: any) => { + dynamicTags.value[0] = event; + }; + //全屏 + const full = ref(false); + const toggleFullscreen = () => { + if (full.value == false) { + full.value = true; + } else { + full.value = false; + } + }; + + const submitForm = () => { + let obj = JSON.parse(JSON.stringify(dynamicTags.value)); + emit('SearchUser', obj[0]); + dialogVisible.value = false; + }; + onMounted(() => { + onSubmit(); + }); + return { + dialogVisible, + openDailog, + tableData, + pageSize, + pageIndex, + onHandleSizeChange, + onHandleCurrentChange, + dynamicTags, + handleClose, + Delete, + radio1, + radio, + toggleFullscreen, + FullScreen, + full, + submitReset, + onMounted, + listQuery, + onSubmit, + submitForm, + listApi, + listQuery2, + total, + }; + }, }); </script> <style scoped> -.el-form--inline .el-form-item{ - margin-bottom: 0; - margin-right: 0; +.el-form--inline .el-form-item { + margin-bottom: 0; + margin-right: 0; } /*分页*/ -.pages{ - margin-top: 15px; +.pages { + margin-top: 15px; } ::v-deep .el-pagination .el-pager li { - margin: 0 5px; - background-color: #f4f4f5; - color: #606266; - min-width: 30px; - border-radius: 2px; + margin: 0 5px; + background-color: #f4f4f5; + color: #606266; + min-width: 30px; + border-radius: 2px; } ::v-deep .el-pagination .el-pager li.is-active { - background-color: #409eff; - color: #fff; + background-color: #409eff; + color: #fff; } ::v-deep .el-pagination .btn-prev { - margin: 0 5px; - background-color: #f4f4f5; - color: #606266; - min-width: 30px; - border-radius: 2px; + margin: 0 5px; + background-color: #f4f4f5; + color: #606266; + min-width: 30px; + border-radius: 2px; } -::v-deep .el-pagination button:disabled{ - color: #c0c4cc; +::v-deep .el-pagination button:disabled { + color: #c0c4cc; } -::v-deep .el-pagination .btn-next{ - margin: 0 5px; - background-color: #f4f4f5; - color: #606266; - min-width: 30px; - border-radius: 2px; +::v-deep .el-pagination .btn-next { + margin: 0 5px; + background-color: #f4f4f5; + color: #606266; + min-width: 30px; + border-radius: 2px; } </style> -- Gitblit v1.9.2