<template> <div class="app-container"> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> <el-form-item label="演练月份" prop="releaseTime"> <el-date-picker v-model="queryParams.mont" value-format="yyyy-MM" type="month" placeholder="选择日期" > </el-date-picker> </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-table v-loading="loading" :data="drillList" @selection-change="handleSelectionChange"> <!--<el-table-column type="selection" width="55" align="center" />--> <el-table-column label="月份" align="center" prop="mont" /> <el-table-column label="演练总次数" align="center" prop="totalNumberDrills" /> <el-table-column label="参演人数" align="center" prop="numberParticipants" /> </el-table> <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> </div> </template> <script> import { listDrill, getDrill, delDrill, addDrill, updateDrill, exportDrill } from "@/api/system/emergencyDrill"; import { listStaff } from "@/api/safetyManagement/staff"; import Editor from '@/components/Editor'; export default { name: "Drill", components: { Editor, }, data() { const generateData = _ => { const data = []; const cities = ['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu']; const pinyin = ['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu']; cities.forEach((city, index) => { data.push({ label: city, key: index, pinyin: pinyin[index] }); }); return data; }; return { data: generateData(), value: [], filterMethod(query, item) { return item.pinyin.indexOf(query) > -1; }, // 遮罩层 loading: true, readOnly:true, // 导出遮罩层 exportLoading: false, // 选中数组 ids: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 应急演练表格数据 drillList: [], // 弹出层标题 title: "", // 是否显示弹出层 open: false, open2:false, //评估 dialogFormVisible:false, // 演练类型字典 drillTypeOptions: [], // 演练形式字典 drillFormOptions: [], // 查询参数 queryParams: { pageNum: 1, pageSize: 10, mont:null, }, // 表单参数 form: {}, // 表单校验 rules: { } }; }, created() { this.getList(); this.getDicts("t_drill_type").then(response => { this.drillTypeOptions = response.data; }); this.getDicts("t_drill_form").then(response => { this.drillFormOptions = response.data; }); }, methods: { /** 查询应急演练列表 */ getList() { this.loading = true; listDrill(this.queryParams).then(response => { this.drillList = response.rows; this.total = response.total; this.loading = false; }); }, // 演练类型字典翻译 drillTypeFormat(row, column) { return this.selectDictLabel(this.drillTypeOptions, row.drillType); }, // 演练形式字典翻译 drillFormFormat(row, column) { return this.selectDictLabel(this.drillFormOptions, row.drillForm); }, // 取消按钮 cancel() { this.open = false; this.reset(); }, // 表单重置 reset() { this.form = { drillId: null, drillName: null, drillAddress: null, drillUnit: null, drillTime: null, drillType: null, drillForm: null, drillObjective: null, drillPeople: null, drillContent: null, assessment: null, createTime: null, createBy: null, isDel: null, evaluate:null, measures:null, }; this.resetForm("form"); }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1; this.getList(); }, /** 重置按钮操作 */ resetQuery() { this.resetForm("queryForm"); this.handleQuery(); }, // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.drillId) this.single = selection.length!==1 this.multiple = !selection.length }, /** 新增按钮操作 */ handleAdd() { listStaff(this.addDateRange(this.queryParams, this.dateRange)).then(response => { console.log(response.rows) this.cities = response.rows.staffName; generateData.cities=['shanghai', 'beijing', 'guangzhou', 'shenzhen', 'nanjing', 'xian', 'chengdu'] }); this.reset(); this.open = true; this.title = "添加应急演练"; }, /** 修改按钮操作 */ handleUpdate(row) { this.reset(); const drillId = row.drillId || this.ids getDrill(drillId).then(response => { this.form = response.data; this.open = true; this.title = "修改应急演练"; }); }, /** 评估按钮操作 */ assessment(row) { this.reset(); const drillId = row.drillId || this.ids getDrill(drillId).then(response => { this.form = response.data; this.dialogFormVisible = true; }); }, /*评估提交*/ submitAssessment(){ }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { console.log(this.form.drillId) if (valid) { if (this.form.drillId != null) { updateDrill(this.form).then(response => { this.msgSuccess("修改成功"); this.open = false; this.dialogFormVisible=false; this.getList(); }); } else { addDrill(this.form).then(response => { this.msgSuccess("新增成功"); this.open = false; this.getList(); }); } } }); }, /** 详情按钮操作 */ handleDetail(row) { getDrill(row.drillId).then(response => { this.form = response.data; this.form.drillType = this.selectDictLabel(this.drillTypeOptions, row.drillType); this.form.drillForm = this.selectDictLabel(this.drillFormOptions, row.drillForm); this.open2 = true; }); }, /** 删除按钮操作 */ handleDelete(row) { //const drillIds = row.drillId || this.ids; this.$confirm('是否确认删除数据项?', "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }).then(function() { return updateDrill({drillId:row.drillId,isDel:1}); }).then(() => { this.getList(); this.msgSuccess("删除成功"); }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { const queryParams = this.queryParams; this.$confirm('是否确认导出所有应急演练数据项?', "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }).then(() => { this.exportLoading = true; return exportDrill(queryParams); }).then(response => { this.download(response.msg); this.exportLoading = false; }).catch(() => {}); } } }; </script> <style> .div-kuang{ background: white; padding-top:20px ; padding-right: 20px; border-radius: 10px; } .division{ display:flex; flex-direction:row; justify-content:flex-start; } </style> <style lang="scss" scoped> ::v-deep .el-select{ width: 100%; } ::v-deep .el-dialog__header{ border-bottom: 1px solid #ccc; } ::v-deep .el-dialog{ background: #f7f7f7; } </style>