正在显示
9 个修改的文件
包含
2893 行增加
和
2911 行删除
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="任务名称" prop="jobName"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.jobName" | ||
| 7 | - placeholder="请输入任务名称" | ||
| 8 | - clearable | ||
| 9 | - size="small" | ||
| 10 | - @keyup.enter.native="handleQuery" | ||
| 11 | - /> | ||
| 12 | - </el-form-item> | ||
| 13 | - <el-form-item label="任务组名" prop="jobGroup"> | ||
| 14 | - <el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable size="small"> | ||
| 15 | - <el-option | ||
| 16 | - v-for="dict in jobGroupOptions" | ||
| 17 | - :key="dict.dictValue" | ||
| 18 | - :label="dict.dictLabel" | ||
| 19 | - :value="dict.dictValue" | ||
| 20 | - /> | ||
| 21 | - </el-select> | ||
| 22 | - </el-form-item> | ||
| 23 | - <el-form-item label="任务状态" prop="status"> | ||
| 24 | - <el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable size="small"> | ||
| 25 | - <el-option | ||
| 26 | - v-for="dict in statusOptions" | ||
| 27 | - :key="dict.dictValue" | ||
| 28 | - :label="dict.dictLabel" | ||
| 29 | - :value="dict.dictValue" | ||
| 30 | - /> | ||
| 31 | - </el-select> | ||
| 32 | - </el-form-item> | ||
| 33 | - <el-form-item> | ||
| 34 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 35 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 36 | - </el-form-item> | ||
| 37 | - </el-form> | ||
| 38 | - | ||
| 39 | - <el-row :gutter="10" class="mb8"> | ||
| 40 | - <el-col :span="1.5"> | ||
| 41 | - <el-button | ||
| 42 | - type="primary" | ||
| 43 | - plain | ||
| 44 | - icon="el-icon-plus" | ||
| 45 | - size="mini" | ||
| 46 | - @click="handleAdd" | ||
| 47 | - v-hasPermi="['monitor:job:add']" | ||
| 48 | - >新增</el-button> | ||
| 49 | - </el-col> | ||
| 50 | - <el-col :span="1.5"> | ||
| 51 | - <el-button | ||
| 52 | - type="success" | ||
| 53 | - plain | ||
| 54 | - icon="el-icon-edit" | ||
| 55 | - size="mini" | ||
| 56 | - :disabled="single" | ||
| 57 | - @click="handleUpdate" | ||
| 58 | - v-hasPermi="['monitor:job:edit']" | ||
| 59 | - >修改</el-button> | ||
| 60 | - </el-col> | ||
| 61 | - <el-col :span="1.5"> | ||
| 62 | - <el-button | ||
| 63 | - type="danger" | ||
| 64 | - plain | ||
| 65 | - icon="el-icon-delete" | ||
| 66 | - size="mini" | ||
| 67 | - :disabled="multiple" | ||
| 68 | - @click="handleDelete" | ||
| 69 | - v-hasPermi="['monitor:job:remove']" | ||
| 70 | - >删除</el-button> | ||
| 71 | - </el-col> | ||
| 72 | - <el-col :span="1.5"> | ||
| 73 | - <el-button | ||
| 74 | - type="warning" | ||
| 75 | - plain | ||
| 76 | - icon="el-icon-download" | ||
| 77 | - size="mini" | ||
| 78 | - :loading="exportLoading" | ||
| 79 | - @click="handleExport" | ||
| 80 | - v-hasPermi="['monitor:job:export']" | ||
| 81 | - >导出</el-button> | ||
| 82 | - </el-col> | ||
| 83 | - <el-col :span="1.5"> | ||
| 84 | - <el-button | ||
| 85 | - type="info" | ||
| 86 | - plain | ||
| 87 | - icon="el-icon-s-operation" | ||
| 88 | - size="mini" | ||
| 89 | - @click="handleJobLog" | ||
| 90 | - v-hasPermi="['monitor:job:query']" | ||
| 91 | - >日志</el-button> | ||
| 92 | - </el-col> | ||
| 93 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 94 | - </el-row> | ||
| 95 | - | ||
| 96 | - <el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange"> | ||
| 97 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 98 | - <el-table-column label="任务编号" align="center" prop="jobId" /> | ||
| 99 | - <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> | ||
| 100 | - <el-table-column label="任务组名" align="center" prop="jobGroup" :formatter="jobGroupFormat" /> | ||
| 101 | - <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" /> | ||
| 102 | - <el-table-column label="cron执行表达式" align="center" prop="cronExpression" :show-overflow-tooltip="true" /> | ||
| 103 | - <el-table-column label="状态" align="center"> | ||
| 104 | - <template slot-scope="scope"> | ||
| 105 | - <el-switch | ||
| 106 | - v-model="scope.row.status" | ||
| 107 | - active-value="0" | ||
| 108 | - inactive-value="1" | ||
| 109 | - @change="handleStatusChange(scope.row)" | ||
| 110 | - ></el-switch> | ||
| 111 | - </template> | ||
| 112 | - </el-table-column> | ||
| 113 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 114 | - <template slot-scope="scope"> | ||
| 115 | - <el-button | ||
| 116 | - size="mini" | ||
| 117 | - type="text" | ||
| 118 | - icon="el-icon-edit" | ||
| 119 | - @click="handleUpdate(scope.row)" | ||
| 120 | - v-hasPermi="['monitor:job:edit']" | ||
| 121 | - >修改</el-button> | ||
| 122 | - <el-button | ||
| 123 | - size="mini" | ||
| 124 | - type="text" | ||
| 125 | - icon="el-icon-delete" | ||
| 126 | - @click="handleDelete(scope.row)" | ||
| 127 | - v-hasPermi="['monitor:job:remove']" | ||
| 128 | - >删除</el-button> | ||
| 129 | - <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['monitor:job:changeStatus', 'monitor:job:query']"> | ||
| 130 | - <span class="el-dropdown-link"> | ||
| 131 | - <i class="el-icon-d-arrow-right el-icon--right"></i>更多 | ||
| 132 | - </span> | ||
| 133 | - <el-dropdown-menu slot="dropdown"> | ||
| 134 | - <el-dropdown-item command="handleRun" icon="el-icon-caret-right" | ||
| 135 | - v-hasPermi="['monitor:job:changeStatus']">执行一次</el-dropdown-item> | ||
| 136 | - <el-dropdown-item command="handleView" icon="el-icon-view" | ||
| 137 | - v-hasPermi="['monitor:job:query']">任务详细</el-dropdown-item> | ||
| 138 | - <el-dropdown-item command="handleJobLog" icon="el-icon-s-operation" | ||
| 139 | - v-hasPermi="['monitor:job:query']">调度日志</el-dropdown-item> | ||
| 140 | - </el-dropdown-menu> | ||
| 141 | - </el-dropdown> | ||
| 142 | - </template> | ||
| 143 | - </el-table-column> | ||
| 144 | - </el-table> | ||
| 145 | - | ||
| 146 | - <pagination | ||
| 147 | - v-show="total>0" | ||
| 148 | - :total="total" | ||
| 149 | - :page.sync="queryParams.pageNum" | ||
| 150 | - :limit.sync="queryParams.pageSize" | ||
| 151 | - @pagination="getList" | ||
| 152 | - /> | ||
| 153 | - | ||
| 154 | - <!-- 添加或修改定时任务对话框 --> | ||
| 155 | - <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body> | ||
| 156 | - <el-form ref="form" :model="form" :rules="rules" label-width="120px"> | ||
| 157 | - <el-row> | ||
| 158 | - <el-col :span="12"> | ||
| 159 | - <el-form-item label="任务名称" prop="jobName"> | ||
| 160 | - <el-input v-model="form.jobName" placeholder="请输入任务名称" /> | ||
| 161 | - </el-form-item> | ||
| 162 | - </el-col> | ||
| 163 | - <el-col :span="12"> | ||
| 164 | - <el-form-item label="任务分组" prop="jobGroup"> | ||
| 165 | - <el-select v-model="form.jobGroup" placeholder="请选择"> | ||
| 166 | - <el-option | ||
| 167 | - v-for="dict in jobGroupOptions" | ||
| 168 | - :key="dict.dictValue" | ||
| 169 | - :label="dict.dictLabel" | ||
| 170 | - :value="dict.dictValue" | ||
| 171 | - ></el-option> | ||
| 172 | - </el-select> | ||
| 173 | - </el-form-item> | ||
| 174 | - </el-col> | ||
| 175 | - <el-col :span="24"> | ||
| 176 | - <el-form-item prop="invokeTarget"> | ||
| 177 | - <span slot="label"> | ||
| 178 | - 调用方法 | ||
| 179 | - <el-tooltip placement="top"> | ||
| 180 | - <div slot="content"> | ||
| 181 | - Bean调用示例:ryTask.ryParams('ry') | ||
| 182 | - <br />Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') | ||
| 183 | - <br />参数说明:支持字符串,布尔类型,长整型,浮点型,整型 | ||
| 184 | - </div> | ||
| 185 | - <i class="el-icon-question"></i> | ||
| 186 | - </el-tooltip> | ||
| 187 | - </span> | ||
| 188 | - <el-input v-model="form.invokeTarget" placeholder="请输入调用目标字符串" /> | ||
| 189 | - </el-form-item> | ||
| 190 | - </el-col> | ||
| 191 | - <el-col :span="12"> | ||
| 192 | - <el-form-item label="cron表达式" prop="cronExpression"> | ||
| 193 | - <el-input v-model="form.cronExpression" placeholder="请输入cron执行表达式" /> | ||
| 194 | - </el-form-item> | ||
| 195 | - </el-col> | ||
| 196 | - <el-col :span="12"> | ||
| 197 | - <el-form-item label="是否并发" prop="concurrent"> | ||
| 198 | - <el-radio-group v-model="form.concurrent" size="small"> | ||
| 199 | - <el-radio-button label="0">允许</el-radio-button> | ||
| 200 | - <el-radio-button label="1">禁止</el-radio-button> | ||
| 201 | - </el-radio-group> | ||
| 202 | - </el-form-item> | ||
| 203 | - </el-col> | ||
| 204 | - <el-col :span="24"> | ||
| 205 | - <el-form-item label="错误策略" prop="misfirePolicy"> | ||
| 206 | - <el-radio-group v-model="form.misfirePolicy" size="small"> | ||
| 207 | - <el-radio-button label="1">立即执行</el-radio-button> | ||
| 208 | - <el-radio-button label="2">执行一次</el-radio-button> | ||
| 209 | - <el-radio-button label="3">放弃执行</el-radio-button> | ||
| 210 | - </el-radio-group> | ||
| 211 | - </el-form-item> | ||
| 212 | - </el-col> | ||
| 213 | - <el-col :span="24"> | ||
| 214 | - <el-form-item label="状态"> | ||
| 215 | - <el-radio-group v-model="form.status"> | ||
| 216 | - <el-radio | ||
| 217 | - v-for="dict in statusOptions" | ||
| 218 | - :key="dict.dictValue" | ||
| 219 | - :label="dict.dictValue" | ||
| 220 | - >{{dict.dictLabel}}</el-radio> | ||
| 221 | - </el-radio-group> | ||
| 222 | - </el-form-item> | ||
| 223 | - </el-col> | ||
| 224 | - </el-row> | ||
| 225 | - </el-form> | ||
| 226 | - <div slot="footer" class="dialog-footer"> | ||
| 227 | - <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 228 | - <el-button @click="cancel">取 消</el-button> | ||
| 229 | - </div> | ||
| 230 | - </el-dialog> | ||
| 231 | - | ||
| 232 | - <!-- 任务日志详细 --> | ||
| 233 | - <el-dialog title="任务详细" :visible.sync="openView" width="700px" append-to-body> | ||
| 234 | - <el-form ref="form" :model="form" label-width="120px" size="mini"> | ||
| 235 | - <el-row> | ||
| 236 | - <el-col :span="12"> | ||
| 237 | - <el-form-item label="任务编号:">{{ form.jobId }}</el-form-item> | ||
| 238 | - <el-form-item label="任务名称:">{{ form.jobName }}</el-form-item> | ||
| 239 | - </el-col> | ||
| 240 | - <el-col :span="12"> | ||
| 241 | - <el-form-item label="任务分组:">{{ jobGroupFormat(form) }}</el-form-item> | ||
| 242 | - <el-form-item label="创建时间:">{{ form.createTime }}</el-form-item> | ||
| 243 | - </el-col> | ||
| 244 | - <el-col :span="12"> | ||
| 245 | - <el-form-item label="cron表达式:">{{ form.cronExpression }}</el-form-item> | ||
| 246 | - </el-col> | ||
| 247 | - <el-col :span="12"> | ||
| 248 | - <el-form-item label="下次执行时间:">{{ parseTime(form.nextValidTime) }}</el-form-item> | ||
| 249 | - </el-col> | ||
| 250 | - <el-col :span="24"> | ||
| 251 | - <el-form-item label="调用目标方法:">{{ form.invokeTarget }}</el-form-item> | ||
| 252 | - </el-col> | ||
| 253 | - <el-col :span="12"> | ||
| 254 | - <el-form-item label="任务状态:"> | ||
| 255 | - <div v-if="form.status == 0">正常</div> | ||
| 256 | - <div v-else-if="form.status == 1">失败</div> | ||
| 257 | - </el-form-item> | ||
| 258 | - </el-col> | ||
| 259 | - <el-col :span="12"> | ||
| 260 | - <el-form-item label="是否并发:"> | ||
| 261 | - <div v-if="form.concurrent == 0">允许</div> | ||
| 262 | - <div v-else-if="form.concurrent == 1">禁止</div> | ||
| 263 | - </el-form-item> | ||
| 264 | - </el-col> | ||
| 265 | - <el-col :span="12"> | ||
| 266 | - <el-form-item label="执行策略:"> | ||
| 267 | - <div v-if="form.misfirePolicy == 0">默认策略</div> | ||
| 268 | - <div v-else-if="form.misfirePolicy == 1">立即执行</div> | ||
| 269 | - <div v-else-if="form.misfirePolicy == 2">执行一次</div> | ||
| 270 | - <div v-else-if="form.misfirePolicy == 3">放弃执行</div> | ||
| 271 | - </el-form-item> | ||
| 272 | - </el-col> | ||
| 273 | - </el-row> | ||
| 274 | - </el-form> | ||
| 275 | - <div slot="footer" class="dialog-footer"> | ||
| 276 | - <el-button @click="openView = false">关 闭</el-button> | ||
| 277 | - </div> | ||
| 278 | - </el-dialog> | ||
| 279 | - </div> | ||
| 280 | -</template> | ||
| 281 | - | ||
| 282 | -<script> | ||
| 283 | -import { listJob, getJob, delJob, addJob, updateJob, exportJob, runJob, changeJobStatus } from "@/api/monitor/job"; | ||
| 284 | - | ||
| 285 | -export default { | ||
| 286 | - name: "Job", | ||
| 287 | - data() { | ||
| 288 | - return { | ||
| 289 | - // 遮罩层 | ||
| 290 | - loading: true, | ||
| 291 | - // 导出遮罩层 | ||
| 292 | - exportLoading: false, | ||
| 293 | - // 选中数组 | ||
| 294 | - ids: [], | ||
| 295 | - // 非单个禁用 | ||
| 296 | - single: true, | ||
| 297 | - // 非多个禁用 | ||
| 298 | - multiple: true, | ||
| 299 | - // 显示搜索条件 | ||
| 300 | - showSearch: true, | ||
| 301 | - // 总条数 | ||
| 302 | - total: 0, | ||
| 303 | - // 定时任务表格数据 | ||
| 304 | - jobList: [], | ||
| 305 | - // 弹出层标题 | ||
| 306 | - title: "", | ||
| 307 | - // 是否显示弹出层 | ||
| 308 | - open: false, | ||
| 309 | - // 是否显示详细弹出层 | ||
| 310 | - openView: false, | ||
| 311 | - // 任务组名字典 | ||
| 312 | - jobGroupOptions: [], | ||
| 313 | - // 状态字典 | ||
| 314 | - statusOptions: [], | ||
| 315 | - // 查询参数 | ||
| 316 | - queryParams: { | ||
| 317 | - pageNum: 1, | ||
| 318 | - pageSize: 10, | ||
| 319 | - jobName: undefined, | ||
| 320 | - jobGroup: undefined, | ||
| 321 | - status: undefined | ||
| 322 | - }, | ||
| 323 | - // 表单参数 | ||
| 324 | - form: {}, | ||
| 325 | - // 表单校验 | ||
| 326 | - rules: { | ||
| 327 | - jobName: [ | ||
| 328 | - { required: true, message: "任务名称不能为空", trigger: "blur" } | ||
| 329 | - ], | ||
| 330 | - invokeTarget: [ | ||
| 331 | - { required: true, message: "调用目标字符串不能为空", trigger: "blur" } | ||
| 332 | - ], | ||
| 333 | - cronExpression: [ | ||
| 334 | - { required: true, message: "cron执行表达式不能为空", trigger: "blur" } | ||
| 335 | - ] | ||
| 336 | - } | ||
| 337 | - }; | ||
| 338 | - }, | ||
| 339 | - created() { | ||
| 340 | - this.getList(); | ||
| 341 | - this.getDicts("sys_job_group").then(response => { | ||
| 342 | - this.jobGroupOptions = response.data; | ||
| 343 | - }); | ||
| 344 | - this.getDicts("sys_job_status").then(response => { | ||
| 345 | - this.statusOptions = response.data; | ||
| 346 | - }); | ||
| 347 | - }, | ||
| 348 | - methods: { | ||
| 349 | - /** 查询定时任务列表 */ | ||
| 350 | - getList() { | ||
| 351 | - this.loading = true; | ||
| 352 | - listJob(this.queryParams).then(response => { | ||
| 353 | - this.jobList = response.rows; | ||
| 354 | - this.total = response.total; | ||
| 355 | - this.loading = false; | ||
| 356 | - }); | ||
| 357 | - }, | ||
| 358 | - // 任务组名字典翻译 | ||
| 359 | - jobGroupFormat(row, column) { | ||
| 360 | - return this.selectDictLabel(this.jobGroupOptions, row.jobGroup); | ||
| 361 | - }, | ||
| 362 | - // 状态字典翻译 | ||
| 363 | - statusFormat(row, column) { | ||
| 364 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 365 | - }, | ||
| 366 | - // 取消按钮 | ||
| 367 | - cancel() { | ||
| 368 | - this.open = false; | ||
| 369 | - this.reset(); | ||
| 370 | - }, | ||
| 371 | - // 表单重置 | ||
| 372 | - reset() { | ||
| 373 | - this.form = { | ||
| 374 | - jobId: undefined, | ||
| 375 | - jobName: undefined, | ||
| 376 | - jobGroup: undefined, | ||
| 377 | - invokeTarget: undefined, | ||
| 378 | - cronExpression: undefined, | ||
| 379 | - misfirePolicy: 1, | ||
| 380 | - concurrent: 1, | ||
| 381 | - status: "0" | ||
| 382 | - }; | ||
| 383 | - this.resetForm("form"); | ||
| 384 | - }, | ||
| 385 | - /** 搜索按钮操作 */ | ||
| 386 | - handleQuery() { | ||
| 387 | - this.queryParams.pageNum = 1; | ||
| 388 | - this.getList(); | ||
| 389 | - }, | ||
| 390 | - /** 重置按钮操作 */ | ||
| 391 | - resetQuery() { | ||
| 392 | - this.resetForm("queryForm"); | ||
| 393 | - this.handleQuery(); | ||
| 394 | - }, | ||
| 395 | - // 多选框选中数据 | ||
| 396 | - handleSelectionChange(selection) { | ||
| 397 | - this.ids = selection.map(item => item.jobId); | ||
| 398 | - this.single = selection.length != 1; | ||
| 399 | - this.multiple = !selection.length; | ||
| 400 | - }, | ||
| 401 | - // 更多操作触发 | ||
| 402 | - handleCommand(command, row) { | ||
| 403 | - switch (command) { | ||
| 404 | - case "handleRun": | ||
| 405 | - this.handleRun(row); | ||
| 406 | - break; | ||
| 407 | - case "handleView": | ||
| 408 | - this.handleView(row); | ||
| 409 | - break; | ||
| 410 | - case "handleJobLog": | ||
| 411 | - this.handleJobLog(row); | ||
| 412 | - break; | ||
| 413 | - default: | ||
| 414 | - break; | ||
| 415 | - } | ||
| 416 | - }, | ||
| 417 | - // 任务状态修改 | ||
| 418 | - handleStatusChange(row) { | ||
| 419 | - let text = row.status === "0" ? "启用" : "停用"; | ||
| 420 | - this.$confirm('确认要"' + text + '""' + row.jobName + '"任务吗?', "警告", { | ||
| 421 | - confirmButtonText: "确定", | ||
| 422 | - cancelButtonText: "取消", | ||
| 423 | - type: "warning" | ||
| 424 | - }).then(function() { | ||
| 425 | - return changeJobStatus(row.jobId, row.status); | ||
| 426 | - }).then(() => { | ||
| 427 | - this.msgSuccess(text + "成功"); | ||
| 428 | - }).catch(function() { | ||
| 429 | - row.status = row.status === "0" ? "1" : "0"; | ||
| 430 | - }); | ||
| 431 | - }, | ||
| 432 | - /* 立即执行一次 */ | ||
| 433 | - handleRun(row) { | ||
| 434 | - this.$confirm('确认要立即执行一次"' + row.jobName + '"任务吗?', "警告", { | ||
| 435 | - confirmButtonText: "确定", | ||
| 436 | - cancelButtonText: "取消", | ||
| 437 | - type: "warning" | ||
| 438 | - }).then(function() { | ||
| 439 | - return runJob(row.jobId, row.jobGroup); | ||
| 440 | - }).then(() => { | ||
| 441 | - this.msgSuccess("执行成功"); | ||
| 442 | - }).catch(() => {}); | ||
| 443 | - }, | ||
| 444 | - /** 任务详细信息 */ | ||
| 445 | - handleView(row) { | ||
| 446 | - getJob(row.jobId).then(response => { | ||
| 447 | - this.form = response.data; | ||
| 448 | - this.openView = true; | ||
| 449 | - }); | ||
| 450 | - }, | ||
| 451 | - /** 任务日志列表查询 */ | ||
| 452 | - handleJobLog(row) { | ||
| 453 | - const jobId = row.jobId || 0; | ||
| 454 | - this.$router.push({ path: '/monitor/job-log/index', query: { jobId: jobId } }) | ||
| 455 | - }, | ||
| 456 | - /** 新增按钮操作 */ | ||
| 457 | - handleAdd() { | ||
| 458 | - this.reset(); | ||
| 459 | - this.open = true; | ||
| 460 | - this.title = "添加任务"; | ||
| 461 | - }, | ||
| 462 | - /** 修改按钮操作 */ | ||
| 463 | - handleUpdate(row) { | ||
| 464 | - this.reset(); | ||
| 465 | - const jobId = row.jobId || this.ids; | ||
| 466 | - getJob(jobId).then(response => { | ||
| 467 | - this.form = response.data; | ||
| 468 | - this.open = true; | ||
| 469 | - this.title = "修改任务"; | ||
| 470 | - }); | ||
| 471 | - }, | ||
| 472 | - /** 提交按钮 */ | ||
| 473 | - submitForm: function() { | ||
| 474 | - this.$refs["form"].validate(valid => { | ||
| 475 | - if (valid) { | ||
| 476 | - if (this.form.jobId != undefined) { | ||
| 477 | - updateJob(this.form).then(response => { | ||
| 478 | - this.msgSuccess("修改成功"); | ||
| 479 | - this.open = false; | ||
| 480 | - this.getList(); | ||
| 481 | - }); | ||
| 482 | - } else { | ||
| 483 | - addJob(this.form).then(response => { | ||
| 484 | - this.msgSuccess("新增成功"); | ||
| 485 | - this.open = false; | ||
| 486 | - this.getList(); | ||
| 487 | - }); | ||
| 488 | - } | ||
| 489 | - } | ||
| 490 | - }); | ||
| 491 | - }, | ||
| 492 | - /** 删除按钮操作 */ | ||
| 493 | - handleDelete(row) { | ||
| 494 | - const jobIds = row.jobId || this.ids; | ||
| 495 | - this.$confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?', "警告", { | ||
| 496 | - confirmButtonText: "确定", | ||
| 497 | - cancelButtonText: "取消", | ||
| 498 | - type: "warning" | ||
| 499 | - }).then(function() { | ||
| 500 | - return delJob(jobIds); | ||
| 501 | - }).then(() => { | ||
| 502 | - this.getList(); | ||
| 503 | - this.msgSuccess("删除成功"); | ||
| 504 | - }).catch(() => {}); | ||
| 505 | - }, | ||
| 506 | - /** 导出按钮操作 */ | ||
| 507 | - handleExport() { | ||
| 508 | - const queryParams = this.queryParams; | ||
| 509 | - this.$confirm("是否确认导出所有定时任务数据项?", "警告", { | ||
| 510 | - confirmButtonText: "确定", | ||
| 511 | - cancelButtonText: "取消", | ||
| 512 | - type: "warning" | ||
| 513 | - }).then(() => { | ||
| 514 | - this.exportLoading = true; | ||
| 515 | - return exportJob(queryParams); | ||
| 516 | - }).then(response => { | ||
| 517 | - this.download(response.msg); | ||
| 518 | - this.exportLoading = false; | ||
| 519 | - }).catch(() => {}); | ||
| 520 | - } | ||
| 521 | - } | ||
| 522 | -}; | ||
| 523 | -</script> | ||
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="任务名称" prop="jobName"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.jobName" | ||
| 7 | + placeholder="请输入任务名称" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + @keyup.enter.native="handleQuery" | ||
| 11 | + /> | ||
| 12 | + </el-form-item> | ||
| 13 | + <el-form-item label="任务组名" prop="jobGroup"> | ||
| 14 | + <el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable size="small"> | ||
| 15 | + <el-option | ||
| 16 | + v-for="dict in jobGroupOptions" | ||
| 17 | + :key="dict.dictValue" | ||
| 18 | + :label="dict.dictLabel" | ||
| 19 | + :value="dict.dictValue" | ||
| 20 | + /> | ||
| 21 | + </el-select> | ||
| 22 | + </el-form-item> | ||
| 23 | + <el-form-item label="任务状态" prop="status"> | ||
| 24 | + <el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable size="small"> | ||
| 25 | + <el-option | ||
| 26 | + v-for="dict in statusOptions" | ||
| 27 | + :key="dict.dictValue" | ||
| 28 | + :label="dict.dictLabel" | ||
| 29 | + :value="dict.dictValue" | ||
| 30 | + /> | ||
| 31 | + </el-select> | ||
| 32 | + </el-form-item> | ||
| 33 | + <el-form-item> | ||
| 34 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 35 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 36 | + </el-form-item> | ||
| 37 | + </el-form> | ||
| 38 | + | ||
| 39 | + <el-row :gutter="10" class="mb8"> | ||
| 40 | + <el-col :span="1.5"> | ||
| 41 | + <el-button | ||
| 42 | + type="primary" | ||
| 43 | + plain | ||
| 44 | + icon="el-icon-plus" | ||
| 45 | + size="mini" | ||
| 46 | + @click="handleAdd" | ||
| 47 | + v-hasPermi="['monitor:job:add']" | ||
| 48 | + >新增</el-button> | ||
| 49 | + </el-col> | ||
| 50 | + <el-col :span="1.5"> | ||
| 51 | + <el-button | ||
| 52 | + type="success" | ||
| 53 | + plain | ||
| 54 | + icon="el-icon-edit" | ||
| 55 | + size="mini" | ||
| 56 | + :disabled="single" | ||
| 57 | + @click="handleUpdate" | ||
| 58 | + v-hasPermi="['monitor:job:edit']" | ||
| 59 | + >修改</el-button> | ||
| 60 | + </el-col> | ||
| 61 | + <el-col :span="1.5"> | ||
| 62 | + <el-button | ||
| 63 | + type="danger" | ||
| 64 | + plain | ||
| 65 | + icon="el-icon-delete" | ||
| 66 | + size="mini" | ||
| 67 | + :disabled="multiple" | ||
| 68 | + @click="handleDelete" | ||
| 69 | + v-hasPermi="['monitor:job:remove']" | ||
| 70 | + >删除</el-button> | ||
| 71 | + </el-col> | ||
| 72 | + <el-col :span="1.5"> | ||
| 73 | + <el-button | ||
| 74 | + type="warning" | ||
| 75 | + plain | ||
| 76 | + icon="el-icon-download" | ||
| 77 | + size="mini" | ||
| 78 | + :loading="exportLoading" | ||
| 79 | + @click="handleExport" | ||
| 80 | + v-hasPermi="['monitor:job:export']" | ||
| 81 | + >导出</el-button> | ||
| 82 | + </el-col> | ||
| 83 | + <el-col :span="1.5"> | ||
| 84 | + <el-button | ||
| 85 | + type="info" | ||
| 86 | + plain | ||
| 87 | + icon="el-icon-s-operation" | ||
| 88 | + size="mini" | ||
| 89 | + @click="handleJobLog" | ||
| 90 | + v-hasPermi="['monitor:job:query']" | ||
| 91 | + >日志</el-button> | ||
| 92 | + </el-col> | ||
| 93 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 94 | + </el-row> | ||
| 95 | + | ||
| 96 | + <el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange"> | ||
| 97 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 98 | + <el-table-column label="任务编号" align="center" prop="jobId" /> | ||
| 99 | + <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> | ||
| 100 | + <el-table-column label="任务组名" align="center" prop="jobGroup"> | ||
| 101 | + <template slot-scope="scope"> | ||
| 102 | + <dict-tag :options="jobGroupOptions" :value="scope.row.jobGroup"/> | ||
| 103 | + </template> | ||
| 104 | + </el-table-column> | ||
| 105 | + <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" /> | ||
| 106 | + <el-table-column label="cron执行表达式" align="center" prop="cronExpression" :show-overflow-tooltip="true" /> | ||
| 107 | + <el-table-column label="状态" align="center"> | ||
| 108 | + <template slot-scope="scope"> | ||
| 109 | + <el-switch | ||
| 110 | + v-model="scope.row.status" | ||
| 111 | + active-value="0" | ||
| 112 | + inactive-value="1" | ||
| 113 | + @change="handleStatusChange(scope.row)" | ||
| 114 | + ></el-switch> | ||
| 115 | + </template> | ||
| 116 | + </el-table-column> | ||
| 117 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 118 | + <template slot-scope="scope"> | ||
| 119 | + <el-button | ||
| 120 | + size="mini" | ||
| 121 | + type="text" | ||
| 122 | + icon="el-icon-edit" | ||
| 123 | + @click="handleUpdate(scope.row)" | ||
| 124 | + v-hasPermi="['monitor:job:edit']" | ||
| 125 | + >修改</el-button> | ||
| 126 | + <el-button | ||
| 127 | + size="mini" | ||
| 128 | + type="text" | ||
| 129 | + icon="el-icon-delete" | ||
| 130 | + @click="handleDelete(scope.row)" | ||
| 131 | + v-hasPermi="['monitor:job:remove']" | ||
| 132 | + >删除</el-button> | ||
| 133 | + <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['monitor:job:changeStatus', 'monitor:job:query']"> | ||
| 134 | + <span class="el-dropdown-link"> | ||
| 135 | + <i class="el-icon-d-arrow-right el-icon--right"></i>更多 | ||
| 136 | + </span> | ||
| 137 | + <el-dropdown-menu slot="dropdown"> | ||
| 138 | + <el-dropdown-item command="handleRun" icon="el-icon-caret-right" | ||
| 139 | + v-hasPermi="['monitor:job:changeStatus']">执行一次</el-dropdown-item> | ||
| 140 | + <el-dropdown-item command="handleView" icon="el-icon-view" | ||
| 141 | + v-hasPermi="['monitor:job:query']">任务详细</el-dropdown-item> | ||
| 142 | + <el-dropdown-item command="handleJobLog" icon="el-icon-s-operation" | ||
| 143 | + v-hasPermi="['monitor:job:query']">调度日志</el-dropdown-item> | ||
| 144 | + </el-dropdown-menu> | ||
| 145 | + </el-dropdown> | ||
| 146 | + </template> | ||
| 147 | + </el-table-column> | ||
| 148 | + </el-table> | ||
| 149 | + | ||
| 150 | + <pagination | ||
| 151 | + v-show="total>0" | ||
| 152 | + :total="total" | ||
| 153 | + :page.sync="queryParams.pageNum" | ||
| 154 | + :limit.sync="queryParams.pageSize" | ||
| 155 | + @pagination="getList" | ||
| 156 | + /> | ||
| 157 | + | ||
| 158 | + <!-- 添加或修改定时任务对话框 --> | ||
| 159 | + <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body> | ||
| 160 | + <el-form ref="form" :model="form" :rules="rules" label-width="120px"> | ||
| 161 | + <el-row> | ||
| 162 | + <el-col :span="12"> | ||
| 163 | + <el-form-item label="任务名称" prop="jobName"> | ||
| 164 | + <el-input v-model="form.jobName" placeholder="请输入任务名称" /> | ||
| 165 | + </el-form-item> | ||
| 166 | + </el-col> | ||
| 167 | + <el-col :span="12"> | ||
| 168 | + <el-form-item label="任务分组" prop="jobGroup"> | ||
| 169 | + <el-select v-model="form.jobGroup" placeholder="请选择"> | ||
| 170 | + <el-option | ||
| 171 | + v-for="dict in jobGroupOptions" | ||
| 172 | + :key="dict.dictValue" | ||
| 173 | + :label="dict.dictLabel" | ||
| 174 | + :value="dict.dictValue" | ||
| 175 | + ></el-option> | ||
| 176 | + </el-select> | ||
| 177 | + </el-form-item> | ||
| 178 | + </el-col> | ||
| 179 | + <el-col :span="24"> | ||
| 180 | + <el-form-item prop="invokeTarget"> | ||
| 181 | + <span slot="label"> | ||
| 182 | + 调用方法 | ||
| 183 | + <el-tooltip placement="top"> | ||
| 184 | + <div slot="content"> | ||
| 185 | + Bean调用示例:ryTask.ryParams('ry') | ||
| 186 | + <br />Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') | ||
| 187 | + <br />参数说明:支持字符串,布尔类型,长整型,浮点型,整型 | ||
| 188 | + </div> | ||
| 189 | + <i class="el-icon-question"></i> | ||
| 190 | + </el-tooltip> | ||
| 191 | + </span> | ||
| 192 | + <el-input v-model="form.invokeTarget" placeholder="请输入调用目标字符串" /> | ||
| 193 | + </el-form-item> | ||
| 194 | + </el-col> | ||
| 195 | + <el-col :span="12"> | ||
| 196 | + <el-form-item label="cron表达式" prop="cronExpression"> | ||
| 197 | + <el-input v-model="form.cronExpression" placeholder="请输入cron执行表达式" /> | ||
| 198 | + </el-form-item> | ||
| 199 | + </el-col> | ||
| 200 | + <el-col :span="12"> | ||
| 201 | + <el-form-item label="是否并发" prop="concurrent"> | ||
| 202 | + <el-radio-group v-model="form.concurrent" size="small"> | ||
| 203 | + <el-radio-button label="0">允许</el-radio-button> | ||
| 204 | + <el-radio-button label="1">禁止</el-radio-button> | ||
| 205 | + </el-radio-group> | ||
| 206 | + </el-form-item> | ||
| 207 | + </el-col> | ||
| 208 | + <el-col :span="24"> | ||
| 209 | + <el-form-item label="错误策略" prop="misfirePolicy"> | ||
| 210 | + <el-radio-group v-model="form.misfirePolicy" size="small"> | ||
| 211 | + <el-radio-button label="1">立即执行</el-radio-button> | ||
| 212 | + <el-radio-button label="2">执行一次</el-radio-button> | ||
| 213 | + <el-radio-button label="3">放弃执行</el-radio-button> | ||
| 214 | + </el-radio-group> | ||
| 215 | + </el-form-item> | ||
| 216 | + </el-col> | ||
| 217 | + <el-col :span="24"> | ||
| 218 | + <el-form-item label="状态"> | ||
| 219 | + <el-radio-group v-model="form.status"> | ||
| 220 | + <el-radio | ||
| 221 | + v-for="dict in statusOptions" | ||
| 222 | + :key="dict.dictValue" | ||
| 223 | + :label="dict.dictValue" | ||
| 224 | + >{{dict.dictLabel}}</el-radio> | ||
| 225 | + </el-radio-group> | ||
| 226 | + </el-form-item> | ||
| 227 | + </el-col> | ||
| 228 | + </el-row> | ||
| 229 | + </el-form> | ||
| 230 | + <div slot="footer" class="dialog-footer"> | ||
| 231 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 232 | + <el-button @click="cancel">取 消</el-button> | ||
| 233 | + </div> | ||
| 234 | + </el-dialog> | ||
| 235 | + | ||
| 236 | + <!-- 任务日志详细 --> | ||
| 237 | + <el-dialog title="任务详细" :visible.sync="openView" width="700px" append-to-body> | ||
| 238 | + <el-form ref="form" :model="form" label-width="120px" size="mini"> | ||
| 239 | + <el-row> | ||
| 240 | + <el-col :span="12"> | ||
| 241 | + <el-form-item label="任务编号:">{{ form.jobId }}</el-form-item> | ||
| 242 | + <el-form-item label="任务名称:">{{ form.jobName }}</el-form-item> | ||
| 243 | + </el-col> | ||
| 244 | + <el-col :span="12"> | ||
| 245 | + <el-form-item label="任务分组:">{{ jobGroupFormat(form) }}</el-form-item> | ||
| 246 | + <el-form-item label="创建时间:">{{ form.createTime }}</el-form-item> | ||
| 247 | + </el-col> | ||
| 248 | + <el-col :span="12"> | ||
| 249 | + <el-form-item label="cron表达式:">{{ form.cronExpression }}</el-form-item> | ||
| 250 | + </el-col> | ||
| 251 | + <el-col :span="12"> | ||
| 252 | + <el-form-item label="下次执行时间:">{{ parseTime(form.nextValidTime) }}</el-form-item> | ||
| 253 | + </el-col> | ||
| 254 | + <el-col :span="24"> | ||
| 255 | + <el-form-item label="调用目标方法:">{{ form.invokeTarget }}</el-form-item> | ||
| 256 | + </el-col> | ||
| 257 | + <el-col :span="12"> | ||
| 258 | + <el-form-item label="任务状态:"> | ||
| 259 | + <div v-if="form.status == 0">正常</div> | ||
| 260 | + <div v-else-if="form.status == 1">失败</div> | ||
| 261 | + </el-form-item> | ||
| 262 | + </el-col> | ||
| 263 | + <el-col :span="12"> | ||
| 264 | + <el-form-item label="是否并发:"> | ||
| 265 | + <div v-if="form.concurrent == 0">允许</div> | ||
| 266 | + <div v-else-if="form.concurrent == 1">禁止</div> | ||
| 267 | + </el-form-item> | ||
| 268 | + </el-col> | ||
| 269 | + <el-col :span="12"> | ||
| 270 | + <el-form-item label="执行策略:"> | ||
| 271 | + <div v-if="form.misfirePolicy == 0">默认策略</div> | ||
| 272 | + <div v-else-if="form.misfirePolicy == 1">立即执行</div> | ||
| 273 | + <div v-else-if="form.misfirePolicy == 2">执行一次</div> | ||
| 274 | + <div v-else-if="form.misfirePolicy == 3">放弃执行</div> | ||
| 275 | + </el-form-item> | ||
| 276 | + </el-col> | ||
| 277 | + </el-row> | ||
| 278 | + </el-form> | ||
| 279 | + <div slot="footer" class="dialog-footer"> | ||
| 280 | + <el-button @click="openView = false">关 闭</el-button> | ||
| 281 | + </div> | ||
| 282 | + </el-dialog> | ||
| 283 | + </div> | ||
| 284 | +</template> | ||
| 285 | + | ||
| 286 | +<script> | ||
| 287 | +import { listJob, getJob, delJob, addJob, updateJob, exportJob, runJob, changeJobStatus } from "@/api/monitor/job"; | ||
| 288 | + | ||
| 289 | +export default { | ||
| 290 | + name: "Job", | ||
| 291 | + data() { | ||
| 292 | + return { | ||
| 293 | + // 遮罩层 | ||
| 294 | + loading: true, | ||
| 295 | + // 导出遮罩层 | ||
| 296 | + exportLoading: false, | ||
| 297 | + // 选中数组 | ||
| 298 | + ids: [], | ||
| 299 | + // 非单个禁用 | ||
| 300 | + single: true, | ||
| 301 | + // 非多个禁用 | ||
| 302 | + multiple: true, | ||
| 303 | + // 显示搜索条件 | ||
| 304 | + showSearch: true, | ||
| 305 | + // 总条数 | ||
| 306 | + total: 0, | ||
| 307 | + // 定时任务表格数据 | ||
| 308 | + jobList: [], | ||
| 309 | + // 弹出层标题 | ||
| 310 | + title: "", | ||
| 311 | + // 是否显示弹出层 | ||
| 312 | + open: false, | ||
| 313 | + // 是否显示详细弹出层 | ||
| 314 | + openView: false, | ||
| 315 | + // 任务组名字典 | ||
| 316 | + jobGroupOptions: [], | ||
| 317 | + // 状态字典 | ||
| 318 | + statusOptions: [], | ||
| 319 | + // 查询参数 | ||
| 320 | + queryParams: { | ||
| 321 | + pageNum: 1, | ||
| 322 | + pageSize: 10, | ||
| 323 | + jobName: undefined, | ||
| 324 | + jobGroup: undefined, | ||
| 325 | + status: undefined | ||
| 326 | + }, | ||
| 327 | + // 表单参数 | ||
| 328 | + form: {}, | ||
| 329 | + // 表单校验 | ||
| 330 | + rules: { | ||
| 331 | + jobName: [ | ||
| 332 | + { required: true, message: "任务名称不能为空", trigger: "blur" } | ||
| 333 | + ], | ||
| 334 | + invokeTarget: [ | ||
| 335 | + { required: true, message: "调用目标字符串不能为空", trigger: "blur" } | ||
| 336 | + ], | ||
| 337 | + cronExpression: [ | ||
| 338 | + { required: true, message: "cron执行表达式不能为空", trigger: "blur" } | ||
| 339 | + ] | ||
| 340 | + } | ||
| 341 | + }; | ||
| 342 | + }, | ||
| 343 | + created() { | ||
| 344 | + this.getList(); | ||
| 345 | + this.getDicts("sys_job_group").then(response => { | ||
| 346 | + this.jobGroupOptions = response.data; | ||
| 347 | + }); | ||
| 348 | + this.getDicts("sys_job_status").then(response => { | ||
| 349 | + this.statusOptions = response.data; | ||
| 350 | + }); | ||
| 351 | + }, | ||
| 352 | + methods: { | ||
| 353 | + /** 查询定时任务列表 */ | ||
| 354 | + getList() { | ||
| 355 | + this.loading = true; | ||
| 356 | + listJob(this.queryParams).then(response => { | ||
| 357 | + this.jobList = response.rows; | ||
| 358 | + this.total = response.total; | ||
| 359 | + this.loading = false; | ||
| 360 | + }); | ||
| 361 | + }, | ||
| 362 | + // 任务组名字典翻译 | ||
| 363 | + jobGroupFormat(row, column) { | ||
| 364 | + return this.selectDictLabel(this.jobGroupOptions, row.jobGroup); | ||
| 365 | + }, | ||
| 366 | + // 取消按钮 | ||
| 367 | + cancel() { | ||
| 368 | + this.open = false; | ||
| 369 | + this.reset(); | ||
| 370 | + }, | ||
| 371 | + // 表单重置 | ||
| 372 | + reset() { | ||
| 373 | + this.form = { | ||
| 374 | + jobId: undefined, | ||
| 375 | + jobName: undefined, | ||
| 376 | + jobGroup: undefined, | ||
| 377 | + invokeTarget: undefined, | ||
| 378 | + cronExpression: undefined, | ||
| 379 | + misfirePolicy: 1, | ||
| 380 | + concurrent: 1, | ||
| 381 | + status: "0" | ||
| 382 | + }; | ||
| 383 | + this.resetForm("form"); | ||
| 384 | + }, | ||
| 385 | + /** 搜索按钮操作 */ | ||
| 386 | + handleQuery() { | ||
| 387 | + this.queryParams.pageNum = 1; | ||
| 388 | + this.getList(); | ||
| 389 | + }, | ||
| 390 | + /** 重置按钮操作 */ | ||
| 391 | + resetQuery() { | ||
| 392 | + this.resetForm("queryForm"); | ||
| 393 | + this.handleQuery(); | ||
| 394 | + }, | ||
| 395 | + // 多选框选中数据 | ||
| 396 | + handleSelectionChange(selection) { | ||
| 397 | + this.ids = selection.map(item => item.jobId); | ||
| 398 | + this.single = selection.length != 1; | ||
| 399 | + this.multiple = !selection.length; | ||
| 400 | + }, | ||
| 401 | + // 更多操作触发 | ||
| 402 | + handleCommand(command, row) { | ||
| 403 | + switch (command) { | ||
| 404 | + case "handleRun": | ||
| 405 | + this.handleRun(row); | ||
| 406 | + break; | ||
| 407 | + case "handleView": | ||
| 408 | + this.handleView(row); | ||
| 409 | + break; | ||
| 410 | + case "handleJobLog": | ||
| 411 | + this.handleJobLog(row); | ||
| 412 | + break; | ||
| 413 | + default: | ||
| 414 | + break; | ||
| 415 | + } | ||
| 416 | + }, | ||
| 417 | + // 任务状态修改 | ||
| 418 | + handleStatusChange(row) { | ||
| 419 | + let text = row.status === "0" ? "启用" : "停用"; | ||
| 420 | + this.$confirm('确认要"' + text + '""' + row.jobName + '"任务吗?', "警告", { | ||
| 421 | + confirmButtonText: "确定", | ||
| 422 | + cancelButtonText: "取消", | ||
| 423 | + type: "warning" | ||
| 424 | + }).then(function() { | ||
| 425 | + return changeJobStatus(row.jobId, row.status); | ||
| 426 | + }).then(() => { | ||
| 427 | + this.msgSuccess(text + "成功"); | ||
| 428 | + }).catch(function() { | ||
| 429 | + row.status = row.status === "0" ? "1" : "0"; | ||
| 430 | + }); | ||
| 431 | + }, | ||
| 432 | + /* 立即执行一次 */ | ||
| 433 | + handleRun(row) { | ||
| 434 | + this.$confirm('确认要立即执行一次"' + row.jobName + '"任务吗?', "警告", { | ||
| 435 | + confirmButtonText: "确定", | ||
| 436 | + cancelButtonText: "取消", | ||
| 437 | + type: "warning" | ||
| 438 | + }).then(function() { | ||
| 439 | + return runJob(row.jobId, row.jobGroup); | ||
| 440 | + }).then(() => { | ||
| 441 | + this.msgSuccess("执行成功"); | ||
| 442 | + }).catch(() => {}); | ||
| 443 | + }, | ||
| 444 | + /** 任务详细信息 */ | ||
| 445 | + handleView(row) { | ||
| 446 | + getJob(row.jobId).then(response => { | ||
| 447 | + this.form = response.data; | ||
| 448 | + this.openView = true; | ||
| 449 | + }); | ||
| 450 | + }, | ||
| 451 | + /** 任务日志列表查询 */ | ||
| 452 | + handleJobLog(row) { | ||
| 453 | + const jobId = row.jobId || 0; | ||
| 454 | + this.$router.push({ path: '/monitor/job-log/index', query: { jobId: jobId } }) | ||
| 455 | + }, | ||
| 456 | + /** 新增按钮操作 */ | ||
| 457 | + handleAdd() { | ||
| 458 | + this.reset(); | ||
| 459 | + this.open = true; | ||
| 460 | + this.title = "添加任务"; | ||
| 461 | + }, | ||
| 462 | + /** 修改按钮操作 */ | ||
| 463 | + handleUpdate(row) { | ||
| 464 | + this.reset(); | ||
| 465 | + const jobId = row.jobId || this.ids; | ||
| 466 | + getJob(jobId).then(response => { | ||
| 467 | + this.form = response.data; | ||
| 468 | + this.open = true; | ||
| 469 | + this.title = "修改任务"; | ||
| 470 | + }); | ||
| 471 | + }, | ||
| 472 | + /** 提交按钮 */ | ||
| 473 | + submitForm: function() { | ||
| 474 | + this.$refs["form"].validate(valid => { | ||
| 475 | + if (valid) { | ||
| 476 | + if (this.form.jobId != undefined) { | ||
| 477 | + updateJob(this.form).then(response => { | ||
| 478 | + this.msgSuccess("修改成功"); | ||
| 479 | + this.open = false; | ||
| 480 | + this.getList(); | ||
| 481 | + }); | ||
| 482 | + } else { | ||
| 483 | + addJob(this.form).then(response => { | ||
| 484 | + this.msgSuccess("新增成功"); | ||
| 485 | + this.open = false; | ||
| 486 | + this.getList(); | ||
| 487 | + }); | ||
| 488 | + } | ||
| 489 | + } | ||
| 490 | + }); | ||
| 491 | + }, | ||
| 492 | + /** 删除按钮操作 */ | ||
| 493 | + handleDelete(row) { | ||
| 494 | + const jobIds = row.jobId || this.ids; | ||
| 495 | + this.$confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?', "警告", { | ||
| 496 | + confirmButtonText: "确定", | ||
| 497 | + cancelButtonText: "取消", | ||
| 498 | + type: "warning" | ||
| 499 | + }).then(function() { | ||
| 500 | + return delJob(jobIds); | ||
| 501 | + }).then(() => { | ||
| 502 | + this.getList(); | ||
| 503 | + this.msgSuccess("删除成功"); | ||
| 504 | + }).catch(() => {}); | ||
| 505 | + }, | ||
| 506 | + /** 导出按钮操作 */ | ||
| 507 | + handleExport() { | ||
| 508 | + const queryParams = this.queryParams; | ||
| 509 | + this.$confirm("是否确认导出所有定时任务数据项?", "警告", { | ||
| 510 | + confirmButtonText: "确定", | ||
| 511 | + cancelButtonText: "取消", | ||
| 512 | + type: "warning" | ||
| 513 | + }).then(() => { | ||
| 514 | + this.exportLoading = true; | ||
| 515 | + return exportJob(queryParams); | ||
| 516 | + }).then(response => { | ||
| 517 | + this.download(response.msg); | ||
| 518 | + this.exportLoading = false; | ||
| 519 | + }).catch(() => {}); | ||
| 520 | + } | ||
| 521 | + } | ||
| 522 | +}; | ||
| 523 | +</script> |
| @@ -110,10 +110,18 @@ | @@ -110,10 +110,18 @@ | ||
| 110 | <el-table-column type="selection" width="55" align="center" /> | 110 | <el-table-column type="selection" width="55" align="center" /> |
| 111 | <el-table-column label="日志编号" width="80" align="center" prop="jobLogId" /> | 111 | <el-table-column label="日志编号" width="80" align="center" prop="jobLogId" /> |
| 112 | <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> | 112 | <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> |
| 113 | - <el-table-column label="任务组名" align="center" prop="jobGroup" :formatter="jobGroupFormat" :show-overflow-tooltip="true" /> | 113 | + <el-table-column label="任务组名" align="center" prop="jobGroup" :show-overflow-tooltip="true"> |
| 114 | + <template slot-scope="scope"> | ||
| 115 | + <dict-tag :options="jobGroupOptions" :value="scope.row.jobGroup"/> | ||
| 116 | + </template> | ||
| 117 | + </el-table-column> | ||
| 114 | <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" /> | 118 | <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" /> |
| 115 | <el-table-column label="日志信息" align="center" prop="jobMessage" :show-overflow-tooltip="true" /> | 119 | <el-table-column label="日志信息" align="center" prop="jobMessage" :show-overflow-tooltip="true" /> |
| 116 | - <el-table-column label="执行状态" align="center" prop="status" :formatter="statusFormat" /> | 120 | + <el-table-column label="执行状态" align="center" prop="status"> |
| 121 | + <template slot-scope="scope"> | ||
| 122 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 123 | + </template> | ||
| 124 | + </el-table-column> | ||
| 117 | <el-table-column label="执行时间" align="center" prop="createTime" width="180"> | 125 | <el-table-column label="执行时间" align="center" prop="createTime" width="180"> |
| 118 | <template slot-scope="scope"> | 126 | <template slot-scope="scope"> |
| 119 | <span>{{ parseTime(scope.row.createTime) }}</span> | 127 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| @@ -247,14 +255,6 @@ export default { | @@ -247,14 +255,6 @@ export default { | ||
| 247 | } | 255 | } |
| 248 | ); | 256 | ); |
| 249 | }, | 257 | }, |
| 250 | - // 执行状态字典翻译 | ||
| 251 | - statusFormat(row, column) { | ||
| 252 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 253 | - }, | ||
| 254 | - // 任务组名字典翻译 | ||
| 255 | - jobGroupFormat(row, column) { | ||
| 256 | - return this.selectDictLabel(this.jobGroupOptions, row.jobGroup); | ||
| 257 | - }, | ||
| 258 | // 返回按钮 | 258 | // 返回按钮 |
| 259 | handleClose() { | 259 | handleClose() { |
| 260 | this.$store.dispatch("tagsView/delView", this.$route); | 260 | this.$store.dispatch("tagsView/delView", this.$route); |
| @@ -325,4 +325,4 @@ export default { | @@ -325,4 +325,4 @@ export default { | ||
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | }; | 327 | }; |
| 328 | -</script> | ||
| 328 | +</script> |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="登录地址" prop="ipaddr"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.ipaddr" | ||
| 7 | - placeholder="请输入登录地址" | ||
| 8 | - clearable | ||
| 9 | - style="width: 240px;" | ||
| 10 | - size="small" | ||
| 11 | - @keyup.enter.native="handleQuery" | ||
| 12 | - /> | ||
| 13 | - </el-form-item> | ||
| 14 | - <el-form-item label="用户名称" prop="userName"> | ||
| 15 | - <el-input | ||
| 16 | - v-model="queryParams.userName" | ||
| 17 | - placeholder="请输入用户名称" | ||
| 18 | - clearable | ||
| 19 | - style="width: 240px;" | ||
| 20 | - size="small" | ||
| 21 | - @keyup.enter.native="handleQuery" | ||
| 22 | - /> | ||
| 23 | - </el-form-item> | ||
| 24 | - <el-form-item label="状态" prop="status"> | ||
| 25 | - <el-select | ||
| 26 | - v-model="queryParams.status" | ||
| 27 | - placeholder="登录状态" | ||
| 28 | - clearable | ||
| 29 | - size="small" | ||
| 30 | - style="width: 240px" | ||
| 31 | - > | ||
| 32 | - <el-option | ||
| 33 | - v-for="dict in statusOptions" | ||
| 34 | - :key="dict.dictValue" | ||
| 35 | - :label="dict.dictLabel" | ||
| 36 | - :value="dict.dictValue" | ||
| 37 | - /> | ||
| 38 | - </el-select> | ||
| 39 | - </el-form-item> | ||
| 40 | - <el-form-item label="登录时间"> | ||
| 41 | - <el-date-picker | ||
| 42 | - v-model="dateRange" | ||
| 43 | - size="small" | ||
| 44 | - style="width: 240px" | ||
| 45 | - value-format="yyyy-MM-dd" | ||
| 46 | - type="daterange" | ||
| 47 | - range-separator="-" | ||
| 48 | - start-placeholder="开始日期" | ||
| 49 | - end-placeholder="结束日期" | ||
| 50 | - ></el-date-picker> | ||
| 51 | - </el-form-item> | ||
| 52 | - <el-form-item> | ||
| 53 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 54 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 55 | - </el-form-item> | ||
| 56 | - </el-form> | ||
| 57 | - | ||
| 58 | - <el-row :gutter="10" class="mb8"> | ||
| 59 | - <el-col :span="1.5"> | ||
| 60 | - <el-button | ||
| 61 | - type="danger" | ||
| 62 | - plain | ||
| 63 | - icon="el-icon-delete" | ||
| 64 | - size="mini" | ||
| 65 | - :disabled="multiple" | ||
| 66 | - @click="handleDelete" | ||
| 67 | - v-hasPermi="['monitor:logininfor:remove']" | ||
| 68 | - >删除</el-button> | ||
| 69 | - </el-col> | ||
| 70 | - <el-col :span="1.5"> | ||
| 71 | - <el-button | ||
| 72 | - type="danger" | ||
| 73 | - plain | ||
| 74 | - icon="el-icon-delete" | ||
| 75 | - size="mini" | ||
| 76 | - @click="handleClean" | ||
| 77 | - v-hasPermi="['monitor:logininfor:remove']" | ||
| 78 | - >清空</el-button> | ||
| 79 | - </el-col> | ||
| 80 | - <el-col :span="1.5"> | ||
| 81 | - <el-button | ||
| 82 | - type="warning" | ||
| 83 | - plain | ||
| 84 | - icon="el-icon-download" | ||
| 85 | - size="mini" | ||
| 86 | - :loading="exportLoading" | ||
| 87 | - @click="handleExport" | ||
| 88 | - v-hasPermi="['monitor:logininfor:export']" | ||
| 89 | - >导出</el-button> | ||
| 90 | - </el-col> | ||
| 91 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 92 | - </el-row> | ||
| 93 | - | ||
| 94 | - <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> | ||
| 95 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 96 | - <el-table-column label="访问编号" align="center" prop="infoId" /> | ||
| 97 | - <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" /> | ||
| 98 | - <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" /> | ||
| 99 | - <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> | ||
| 100 | - <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" /> | ||
| 101 | - <el-table-column label="操作系统" align="center" prop="os" /> | ||
| 102 | - <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" /> | ||
| 103 | - <el-table-column label="操作信息" align="center" prop="msg" /> | ||
| 104 | - <el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180"> | ||
| 105 | - <template slot-scope="scope"> | ||
| 106 | - <span>{{ parseTime(scope.row.loginTime) }}</span> | ||
| 107 | - </template> | ||
| 108 | - </el-table-column> | ||
| 109 | - </el-table> | ||
| 110 | - | ||
| 111 | - <pagination | ||
| 112 | - v-show="total>0" | ||
| 113 | - :total="total" | ||
| 114 | - :page.sync="queryParams.pageNum" | ||
| 115 | - :limit.sync="queryParams.pageSize" | ||
| 116 | - @pagination="getList" | ||
| 117 | - /> | ||
| 118 | - </div> | ||
| 119 | -</template> | ||
| 120 | - | ||
| 121 | -<script> | ||
| 122 | -import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor"; | ||
| 123 | - | ||
| 124 | -export default { | ||
| 125 | - name: "Logininfor", | ||
| 126 | - data() { | ||
| 127 | - return { | ||
| 128 | - // 遮罩层 | ||
| 129 | - loading: true, | ||
| 130 | - // 导出遮罩层 | ||
| 131 | - exportLoading: false, | ||
| 132 | - // 选中数组 | ||
| 133 | - ids: [], | ||
| 134 | - // 非多个禁用 | ||
| 135 | - multiple: true, | ||
| 136 | - // 显示搜索条件 | ||
| 137 | - showSearch: true, | ||
| 138 | - // 总条数 | ||
| 139 | - total: 0, | ||
| 140 | - // 表格数据 | ||
| 141 | - list: [], | ||
| 142 | - // 状态数据字典 | ||
| 143 | - statusOptions: [], | ||
| 144 | - // 日期范围 | ||
| 145 | - dateRange: [], | ||
| 146 | - // 默认排序 | ||
| 147 | - defaultSort: {prop: 'loginTime', order: 'descending'}, | ||
| 148 | - // 查询参数 | ||
| 149 | - queryParams: { | ||
| 150 | - pageNum: 1, | ||
| 151 | - pageSize: 10, | ||
| 152 | - ipaddr: undefined, | ||
| 153 | - userName: undefined, | ||
| 154 | - status: undefined | ||
| 155 | - } | ||
| 156 | - }; | ||
| 157 | - }, | ||
| 158 | - created() { | ||
| 159 | - this.getList(); | ||
| 160 | - this.getDicts("sys_common_status").then(response => { | ||
| 161 | - this.statusOptions = response.data; | ||
| 162 | - }); | ||
| 163 | - }, | ||
| 164 | - methods: { | ||
| 165 | - /** 查询登录日志列表 */ | ||
| 166 | - getList() { | ||
| 167 | - this.loading = true; | ||
| 168 | - list(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||
| 169 | - this.list = response.rows; | ||
| 170 | - this.total = response.total; | ||
| 171 | - this.loading = false; | ||
| 172 | - } | ||
| 173 | - ); | ||
| 174 | - }, | ||
| 175 | - // 登录状态字典翻译 | ||
| 176 | - statusFormat(row, column) { | ||
| 177 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 178 | - }, | ||
| 179 | - /** 搜索按钮操作 */ | ||
| 180 | - handleQuery() { | ||
| 181 | - this.queryParams.pageNum = 1; | ||
| 182 | - this.getList(); | ||
| 183 | - }, | ||
| 184 | - /** 重置按钮操作 */ | ||
| 185 | - resetQuery() { | ||
| 186 | - this.dateRange = []; | ||
| 187 | - this.resetForm("queryForm"); | ||
| 188 | - this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) | ||
| 189 | - this.handleQuery(); | ||
| 190 | - }, | ||
| 191 | - /** 多选框选中数据 */ | ||
| 192 | - handleSelectionChange(selection) { | ||
| 193 | - this.ids = selection.map(item => item.infoId) | ||
| 194 | - this.multiple = !selection.length | ||
| 195 | - }, | ||
| 196 | - /** 排序触发事件 */ | ||
| 197 | - handleSortChange(column, prop, order) { | ||
| 198 | - this.queryParams.orderByColumn = column.prop; | ||
| 199 | - this.queryParams.isAsc = column.order; | ||
| 200 | - this.getList(); | ||
| 201 | - }, | ||
| 202 | - /** 删除按钮操作 */ | ||
| 203 | - handleDelete(row) { | ||
| 204 | - const infoIds = row.infoId || this.ids; | ||
| 205 | - this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", { | ||
| 206 | - confirmButtonText: "确定", | ||
| 207 | - cancelButtonText: "取消", | ||
| 208 | - type: "warning" | ||
| 209 | - }).then(function() { | ||
| 210 | - return delLogininfor(infoIds); | ||
| 211 | - }).then(() => { | ||
| 212 | - this.getList(); | ||
| 213 | - this.msgSuccess("删除成功"); | ||
| 214 | - }).catch(() => {}); | ||
| 215 | - }, | ||
| 216 | - /** 清空按钮操作 */ | ||
| 217 | - handleClean() { | ||
| 218 | - this.$confirm('是否确认清空所有登录日志数据项?', "警告", { | ||
| 219 | - confirmButtonText: "确定", | ||
| 220 | - cancelButtonText: "取消", | ||
| 221 | - type: "warning" | ||
| 222 | - }).then(function() { | ||
| 223 | - return cleanLogininfor(); | ||
| 224 | - }).then(() => { | ||
| 225 | - this.getList(); | ||
| 226 | - this.msgSuccess("清空成功"); | ||
| 227 | - }).catch(() => {}); | ||
| 228 | - }, | ||
| 229 | - /** 导出按钮操作 */ | ||
| 230 | - handleExport() { | ||
| 231 | - const queryParams = this.queryParams; | ||
| 232 | - this.$confirm('是否确认导出所有操作日志数据项?', "警告", { | ||
| 233 | - confirmButtonText: "确定", | ||
| 234 | - cancelButtonText: "取消", | ||
| 235 | - type: "warning" | ||
| 236 | - }).then(() => { | ||
| 237 | - this.exportLoading = true; | ||
| 238 | - return exportLogininfor(queryParams); | ||
| 239 | - }).then(response => { | ||
| 240 | - this.download(response.msg); | ||
| 241 | - this.exportLoading = false; | ||
| 242 | - }).catch(() => {}); | ||
| 243 | - } | ||
| 244 | - } | ||
| 245 | -}; | ||
| 246 | -</script> | ||
| 247 | - | 1 | +<template> |
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="登录地址" prop="ipaddr"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.ipaddr" | ||
| 7 | + placeholder="请输入登录地址" | ||
| 8 | + clearable | ||
| 9 | + style="width: 240px;" | ||
| 10 | + size="small" | ||
| 11 | + @keyup.enter.native="handleQuery" | ||
| 12 | + /> | ||
| 13 | + </el-form-item> | ||
| 14 | + <el-form-item label="用户名称" prop="userName"> | ||
| 15 | + <el-input | ||
| 16 | + v-model="queryParams.userName" | ||
| 17 | + placeholder="请输入用户名称" | ||
| 18 | + clearable | ||
| 19 | + style="width: 240px;" | ||
| 20 | + size="small" | ||
| 21 | + @keyup.enter.native="handleQuery" | ||
| 22 | + /> | ||
| 23 | + </el-form-item> | ||
| 24 | + <el-form-item label="状态" prop="status"> | ||
| 25 | + <el-select | ||
| 26 | + v-model="queryParams.status" | ||
| 27 | + placeholder="登录状态" | ||
| 28 | + clearable | ||
| 29 | + size="small" | ||
| 30 | + style="width: 240px" | ||
| 31 | + > | ||
| 32 | + <el-option | ||
| 33 | + v-for="dict in statusOptions" | ||
| 34 | + :key="dict.dictValue" | ||
| 35 | + :label="dict.dictLabel" | ||
| 36 | + :value="dict.dictValue" | ||
| 37 | + /> | ||
| 38 | + </el-select> | ||
| 39 | + </el-form-item> | ||
| 40 | + <el-form-item label="登录时间"> | ||
| 41 | + <el-date-picker | ||
| 42 | + v-model="dateRange" | ||
| 43 | + size="small" | ||
| 44 | + style="width: 240px" | ||
| 45 | + value-format="yyyy-MM-dd" | ||
| 46 | + type="daterange" | ||
| 47 | + range-separator="-" | ||
| 48 | + start-placeholder="开始日期" | ||
| 49 | + end-placeholder="结束日期" | ||
| 50 | + ></el-date-picker> | ||
| 51 | + </el-form-item> | ||
| 52 | + <el-form-item> | ||
| 53 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 54 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 55 | + </el-form-item> | ||
| 56 | + </el-form> | ||
| 57 | + | ||
| 58 | + <el-row :gutter="10" class="mb8"> | ||
| 59 | + <el-col :span="1.5"> | ||
| 60 | + <el-button | ||
| 61 | + type="danger" | ||
| 62 | + plain | ||
| 63 | + icon="el-icon-delete" | ||
| 64 | + size="mini" | ||
| 65 | + :disabled="multiple" | ||
| 66 | + @click="handleDelete" | ||
| 67 | + v-hasPermi="['monitor:logininfor:remove']" | ||
| 68 | + >删除</el-button> | ||
| 69 | + </el-col> | ||
| 70 | + <el-col :span="1.5"> | ||
| 71 | + <el-button | ||
| 72 | + type="danger" | ||
| 73 | + plain | ||
| 74 | + icon="el-icon-delete" | ||
| 75 | + size="mini" | ||
| 76 | + @click="handleClean" | ||
| 77 | + v-hasPermi="['monitor:logininfor:remove']" | ||
| 78 | + >清空</el-button> | ||
| 79 | + </el-col> | ||
| 80 | + <el-col :span="1.5"> | ||
| 81 | + <el-button | ||
| 82 | + type="warning" | ||
| 83 | + plain | ||
| 84 | + icon="el-icon-download" | ||
| 85 | + size="mini" | ||
| 86 | + :loading="exportLoading" | ||
| 87 | + @click="handleExport" | ||
| 88 | + v-hasPermi="['monitor:logininfor:export']" | ||
| 89 | + >导出</el-button> | ||
| 90 | + </el-col> | ||
| 91 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 92 | + </el-row> | ||
| 93 | + | ||
| 94 | + <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> | ||
| 95 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 96 | + <el-table-column label="访问编号" align="center" prop="infoId" /> | ||
| 97 | + <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" /> | ||
| 98 | + <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" /> | ||
| 99 | + <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> | ||
| 100 | + <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" /> | ||
| 101 | + <el-table-column label="操作系统" align="center" prop="os" /> | ||
| 102 | + <el-table-column label="登录状态" align="center" prop="status"> | ||
| 103 | + <template slot-scope="scope"> | ||
| 104 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 105 | + </template> | ||
| 106 | + </el-table-column> | ||
| 107 | + <el-table-column label="操作信息" align="center" prop="msg" /> | ||
| 108 | + <el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180"> | ||
| 109 | + <template slot-scope="scope"> | ||
| 110 | + <span>{{ parseTime(scope.row.loginTime) }}</span> | ||
| 111 | + </template> | ||
| 112 | + </el-table-column> | ||
| 113 | + </el-table> | ||
| 114 | + | ||
| 115 | + <pagination | ||
| 116 | + v-show="total>0" | ||
| 117 | + :total="total" | ||
| 118 | + :page.sync="queryParams.pageNum" | ||
| 119 | + :limit.sync="queryParams.pageSize" | ||
| 120 | + @pagination="getList" | ||
| 121 | + /> | ||
| 122 | + </div> | ||
| 123 | +</template> | ||
| 124 | + | ||
| 125 | +<script> | ||
| 126 | +import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor"; | ||
| 127 | + | ||
| 128 | +export default { | ||
| 129 | + name: "Logininfor", | ||
| 130 | + data() { | ||
| 131 | + return { | ||
| 132 | + // 遮罩层 | ||
| 133 | + loading: true, | ||
| 134 | + // 导出遮罩层 | ||
| 135 | + exportLoading: false, | ||
| 136 | + // 选中数组 | ||
| 137 | + ids: [], | ||
| 138 | + // 非多个禁用 | ||
| 139 | + multiple: true, | ||
| 140 | + // 显示搜索条件 | ||
| 141 | + showSearch: true, | ||
| 142 | + // 总条数 | ||
| 143 | + total: 0, | ||
| 144 | + // 表格数据 | ||
| 145 | + list: [], | ||
| 146 | + // 状态数据字典 | ||
| 147 | + statusOptions: [], | ||
| 148 | + // 日期范围 | ||
| 149 | + dateRange: [], | ||
| 150 | + // 默认排序 | ||
| 151 | + defaultSort: {prop: 'loginTime', order: 'descending'}, | ||
| 152 | + // 查询参数 | ||
| 153 | + queryParams: { | ||
| 154 | + pageNum: 1, | ||
| 155 | + pageSize: 10, | ||
| 156 | + ipaddr: undefined, | ||
| 157 | + userName: undefined, | ||
| 158 | + status: undefined | ||
| 159 | + } | ||
| 160 | + }; | ||
| 161 | + }, | ||
| 162 | + created() { | ||
| 163 | + this.getList(); | ||
| 164 | + this.getDicts("sys_common_status").then(response => { | ||
| 165 | + this.statusOptions = response.data; | ||
| 166 | + }); | ||
| 167 | + }, | ||
| 168 | + methods: { | ||
| 169 | + /** 查询登录日志列表 */ | ||
| 170 | + getList() { | ||
| 171 | + this.loading = true; | ||
| 172 | + list(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||
| 173 | + this.list = response.rows; | ||
| 174 | + this.total = response.total; | ||
| 175 | + this.loading = false; | ||
| 176 | + } | ||
| 177 | + ); | ||
| 178 | + }, | ||
| 179 | + /** 搜索按钮操作 */ | ||
| 180 | + handleQuery() { | ||
| 181 | + this.queryParams.pageNum = 1; | ||
| 182 | + this.getList(); | ||
| 183 | + }, | ||
| 184 | + /** 重置按钮操作 */ | ||
| 185 | + resetQuery() { | ||
| 186 | + this.dateRange = []; | ||
| 187 | + this.resetForm("queryForm"); | ||
| 188 | + this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) | ||
| 189 | + this.handleQuery(); | ||
| 190 | + }, | ||
| 191 | + /** 多选框选中数据 */ | ||
| 192 | + handleSelectionChange(selection) { | ||
| 193 | + this.ids = selection.map(item => item.infoId) | ||
| 194 | + this.multiple = !selection.length | ||
| 195 | + }, | ||
| 196 | + /** 排序触发事件 */ | ||
| 197 | + handleSortChange(column, prop, order) { | ||
| 198 | + this.queryParams.orderByColumn = column.prop; | ||
| 199 | + this.queryParams.isAsc = column.order; | ||
| 200 | + this.getList(); | ||
| 201 | + }, | ||
| 202 | + /** 删除按钮操作 */ | ||
| 203 | + handleDelete(row) { | ||
| 204 | + const infoIds = row.infoId || this.ids; | ||
| 205 | + this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", { | ||
| 206 | + confirmButtonText: "确定", | ||
| 207 | + cancelButtonText: "取消", | ||
| 208 | + type: "warning" | ||
| 209 | + }).then(function() { | ||
| 210 | + return delLogininfor(infoIds); | ||
| 211 | + }).then(() => { | ||
| 212 | + this.getList(); | ||
| 213 | + this.msgSuccess("删除成功"); | ||
| 214 | + }).catch(() => {}); | ||
| 215 | + }, | ||
| 216 | + /** 清空按钮操作 */ | ||
| 217 | + handleClean() { | ||
| 218 | + this.$confirm('是否确认清空所有登录日志数据项?', "警告", { | ||
| 219 | + confirmButtonText: "确定", | ||
| 220 | + cancelButtonText: "取消", | ||
| 221 | + type: "warning" | ||
| 222 | + }).then(function() { | ||
| 223 | + return cleanLogininfor(); | ||
| 224 | + }).then(() => { | ||
| 225 | + this.getList(); | ||
| 226 | + this.msgSuccess("清空成功"); | ||
| 227 | + }).catch(() => {}); | ||
| 228 | + }, | ||
| 229 | + /** 导出按钮操作 */ | ||
| 230 | + handleExport() { | ||
| 231 | + const queryParams = this.queryParams; | ||
| 232 | + this.$confirm('是否确认导出所有操作日志数据项?', "警告", { | ||
| 233 | + confirmButtonText: "确定", | ||
| 234 | + cancelButtonText: "取消", | ||
| 235 | + type: "warning" | ||
| 236 | + }).then(() => { | ||
| 237 | + this.exportLoading = true; | ||
| 238 | + return exportLogininfor(queryParams); | ||
| 239 | + }).then(response => { | ||
| 240 | + this.download(response.msg); | ||
| 241 | + this.exportLoading = false; | ||
| 242 | + }).catch(() => {}); | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | +}; | ||
| 246 | +</script> | ||
| 247 | + |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="系统模块" prop="title"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.title" | ||
| 7 | - placeholder="请输入系统模块" | ||
| 8 | - clearable | ||
| 9 | - style="width: 240px;" | ||
| 10 | - size="small" | ||
| 11 | - @keyup.enter.native="handleQuery" | ||
| 12 | - /> | ||
| 13 | - </el-form-item> | ||
| 14 | - <el-form-item label="操作人员" prop="operName"> | ||
| 15 | - <el-input | ||
| 16 | - v-model="queryParams.operName" | ||
| 17 | - placeholder="请输入操作人员" | ||
| 18 | - clearable | ||
| 19 | - style="width: 240px;" | ||
| 20 | - size="small" | ||
| 21 | - @keyup.enter.native="handleQuery" | ||
| 22 | - /> | ||
| 23 | - </el-form-item> | ||
| 24 | - <el-form-item label="类型" prop="businessType"> | ||
| 25 | - <el-select | ||
| 26 | - v-model="queryParams.businessType" | ||
| 27 | - placeholder="操作类型" | ||
| 28 | - clearable | ||
| 29 | - size="small" | ||
| 30 | - style="width: 240px" | ||
| 31 | - > | ||
| 32 | - <el-option | ||
| 33 | - v-for="dict in typeOptions" | ||
| 34 | - :key="dict.dictValue" | ||
| 35 | - :label="dict.dictLabel" | ||
| 36 | - :value="dict.dictValue" | ||
| 37 | - /> | ||
| 38 | - </el-select> | ||
| 39 | - </el-form-item> | ||
| 40 | - <el-form-item label="状态" prop="status"> | ||
| 41 | - <el-select | ||
| 42 | - v-model="queryParams.status" | ||
| 43 | - placeholder="操作状态" | ||
| 44 | - clearable | ||
| 45 | - size="small" | ||
| 46 | - style="width: 240px" | ||
| 47 | - > | ||
| 48 | - <el-option | ||
| 49 | - v-for="dict in statusOptions" | ||
| 50 | - :key="dict.dictValue" | ||
| 51 | - :label="dict.dictLabel" | ||
| 52 | - :value="dict.dictValue" | ||
| 53 | - /> | ||
| 54 | - </el-select> | ||
| 55 | - </el-form-item> | ||
| 56 | - <el-form-item label="操作时间"> | ||
| 57 | - <el-date-picker | ||
| 58 | - v-model="dateRange" | ||
| 59 | - size="small" | ||
| 60 | - style="width: 240px" | ||
| 61 | - value-format="yyyy-MM-dd" | ||
| 62 | - type="daterange" | ||
| 63 | - range-separator="-" | ||
| 64 | - start-placeholder="开始日期" | ||
| 65 | - end-placeholder="结束日期" | ||
| 66 | - ></el-date-picker> | ||
| 67 | - </el-form-item> | ||
| 68 | - <el-form-item> | ||
| 69 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 70 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 71 | - </el-form-item> | ||
| 72 | - </el-form> | ||
| 73 | - | ||
| 74 | - <el-row :gutter="10" class="mb8"> | ||
| 75 | - <el-col :span="1.5"> | ||
| 76 | - <el-button | ||
| 77 | - type="danger" | ||
| 78 | - plain | ||
| 79 | - icon="el-icon-delete" | ||
| 80 | - size="mini" | ||
| 81 | - :disabled="multiple" | ||
| 82 | - @click="handleDelete" | ||
| 83 | - v-hasPermi="['monitor:operlog:remove']" | ||
| 84 | - >删除</el-button> | ||
| 85 | - </el-col> | ||
| 86 | - <el-col :span="1.5"> | ||
| 87 | - <el-button | ||
| 88 | - type="danger" | ||
| 89 | - plain | ||
| 90 | - icon="el-icon-delete" | ||
| 91 | - size="mini" | ||
| 92 | - @click="handleClean" | ||
| 93 | - v-hasPermi="['monitor:operlog:remove']" | ||
| 94 | - >清空</el-button> | ||
| 95 | - </el-col> | ||
| 96 | - <el-col :span="1.5"> | ||
| 97 | - <el-button | ||
| 98 | - type="warning" | ||
| 99 | - plain | ||
| 100 | - icon="el-icon-download" | ||
| 101 | - size="mini" | ||
| 102 | - :loading="exportLoading" | ||
| 103 | - @click="handleExport" | ||
| 104 | - v-hasPermi="['monitor:operlog:export']" | ||
| 105 | - >导出</el-button> | ||
| 106 | - </el-col> | ||
| 107 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 108 | - </el-row> | ||
| 109 | - | ||
| 110 | - <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> | ||
| 111 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 112 | - <el-table-column label="日志编号" align="center" prop="operId" /> | ||
| 113 | - <el-table-column label="系统模块" align="center" prop="title" /> | ||
| 114 | - <el-table-column label="操作类型" align="center" prop="businessType" :formatter="typeFormat" /> | ||
| 115 | - <el-table-column label="请求方式" align="center" prop="requestMethod" /> | ||
| 116 | - <el-table-column label="操作人员" align="center" prop="operName" width="100" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" /> | ||
| 117 | - <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" /> | ||
| 118 | - <el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" /> | ||
| 119 | - <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" /> | ||
| 120 | - <el-table-column label="操作日期" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180"> | ||
| 121 | - <template slot-scope="scope"> | ||
| 122 | - <span>{{ parseTime(scope.row.operTime) }}</span> | ||
| 123 | - </template> | ||
| 124 | - </el-table-column> | ||
| 125 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 126 | - <template slot-scope="scope"> | ||
| 127 | - <el-button | ||
| 128 | - size="mini" | ||
| 129 | - type="text" | ||
| 130 | - icon="el-icon-view" | ||
| 131 | - @click="handleView(scope.row,scope.index)" | ||
| 132 | - v-hasPermi="['monitor:operlog:query']" | ||
| 133 | - >详细</el-button> | ||
| 134 | - </template> | ||
| 135 | - </el-table-column> | ||
| 136 | - </el-table> | ||
| 137 | - | ||
| 138 | - <pagination | ||
| 139 | - v-show="total>0" | ||
| 140 | - :total="total" | ||
| 141 | - :page.sync="queryParams.pageNum" | ||
| 142 | - :limit.sync="queryParams.pageSize" | ||
| 143 | - @pagination="getList" | ||
| 144 | - /> | ||
| 145 | - | ||
| 146 | - <!-- 操作日志详细 --> | ||
| 147 | - <el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body> | ||
| 148 | - <el-form ref="form" :model="form" label-width="100px" size="mini"> | ||
| 149 | - <el-row> | ||
| 150 | - <el-col :span="12"> | ||
| 151 | - <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item> | ||
| 152 | - <el-form-item | ||
| 153 | - label="登录信息:" | ||
| 154 | - >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item> | ||
| 155 | - </el-col> | ||
| 156 | - <el-col :span="12"> | ||
| 157 | - <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item> | ||
| 158 | - <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item> | ||
| 159 | - </el-col> | ||
| 160 | - <el-col :span="24"> | ||
| 161 | - <el-form-item label="操作方法:">{{ form.method }}</el-form-item> | ||
| 162 | - </el-col> | ||
| 163 | - <el-col :span="24"> | ||
| 164 | - <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item> | ||
| 165 | - </el-col> | ||
| 166 | - <el-col :span="24"> | ||
| 167 | - <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item> | ||
| 168 | - </el-col> | ||
| 169 | - <el-col :span="12"> | ||
| 170 | - <el-form-item label="操作状态:"> | ||
| 171 | - <div v-if="form.status === 0">正常</div> | ||
| 172 | - <div v-else-if="form.status === 1">失败</div> | ||
| 173 | - </el-form-item> | ||
| 174 | - </el-col> | ||
| 175 | - <el-col :span="12"> | ||
| 176 | - <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item> | ||
| 177 | - </el-col> | ||
| 178 | - <el-col :span="24"> | ||
| 179 | - <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item> | ||
| 180 | - </el-col> | ||
| 181 | - </el-row> | ||
| 182 | - </el-form> | ||
| 183 | - <div slot="footer" class="dialog-footer"> | ||
| 184 | - <el-button @click="open = false">关 闭</el-button> | ||
| 185 | - </div> | ||
| 186 | - </el-dialog> | ||
| 187 | - </div> | ||
| 188 | -</template> | ||
| 189 | - | ||
| 190 | -<script> | ||
| 191 | -import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog"; | ||
| 192 | - | ||
| 193 | -export default { | ||
| 194 | - name: "Operlog", | ||
| 195 | - data() { | ||
| 196 | - return { | ||
| 197 | - // 遮罩层 | ||
| 198 | - loading: true, | ||
| 199 | - // 导出遮罩层 | ||
| 200 | - exportLoading: false, | ||
| 201 | - // 选中数组 | ||
| 202 | - ids: [], | ||
| 203 | - // 非多个禁用 | ||
| 204 | - multiple: true, | ||
| 205 | - // 显示搜索条件 | ||
| 206 | - showSearch: true, | ||
| 207 | - // 总条数 | ||
| 208 | - total: 0, | ||
| 209 | - // 表格数据 | ||
| 210 | - list: [], | ||
| 211 | - // 是否显示弹出层 | ||
| 212 | - open: false, | ||
| 213 | - // 类型数据字典 | ||
| 214 | - typeOptions: [], | ||
| 215 | - // 类型数据字典 | ||
| 216 | - statusOptions: [], | ||
| 217 | - // 日期范围 | ||
| 218 | - dateRange: [], | ||
| 219 | - // 默认排序 | ||
| 220 | - defaultSort: {prop: 'operTime', order: 'descending'}, | ||
| 221 | - // 表单参数 | ||
| 222 | - form: {}, | ||
| 223 | - // 查询参数 | ||
| 224 | - queryParams: { | ||
| 225 | - pageNum: 1, | ||
| 226 | - pageSize: 10, | ||
| 227 | - title: undefined, | ||
| 228 | - operName: undefined, | ||
| 229 | - businessType: undefined, | ||
| 230 | - status: undefined | ||
| 231 | - } | ||
| 232 | - }; | ||
| 233 | - }, | ||
| 234 | - created() { | ||
| 235 | - this.getList(); | ||
| 236 | - this.getDicts("sys_oper_type").then(response => { | ||
| 237 | - this.typeOptions = response.data; | ||
| 238 | - }); | ||
| 239 | - this.getDicts("sys_common_status").then(response => { | ||
| 240 | - this.statusOptions = response.data; | ||
| 241 | - }); | ||
| 242 | - }, | ||
| 243 | - methods: { | ||
| 244 | - /** 查询登录日志 */ | ||
| 245 | - getList() { | ||
| 246 | - this.loading = true; | ||
| 247 | - list(this.addDateRange(this.queryParams, this.dateRange)).then( response => { | ||
| 248 | - this.list = response.rows; | ||
| 249 | - this.total = response.total; | ||
| 250 | - this.loading = false; | ||
| 251 | - } | ||
| 252 | - ); | ||
| 253 | - }, | ||
| 254 | - // 操作日志状态字典翻译 | ||
| 255 | - statusFormat(row, column) { | ||
| 256 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 257 | - }, | ||
| 258 | - // 操作日志类型字典翻译 | ||
| 259 | - typeFormat(row, column) { | ||
| 260 | - return this.selectDictLabel(this.typeOptions, row.businessType); | ||
| 261 | - }, | ||
| 262 | - /** 搜索按钮操作 */ | ||
| 263 | - handleQuery() { | ||
| 264 | - this.queryParams.pageNum = 1; | ||
| 265 | - this.getList(); | ||
| 266 | - }, | ||
| 267 | - /** 重置按钮操作 */ | ||
| 268 | - resetQuery() { | ||
| 269 | - this.dateRange = []; | ||
| 270 | - this.resetForm("queryForm"); | ||
| 271 | - this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) | ||
| 272 | - this.handleQuery(); | ||
| 273 | - }, | ||
| 274 | - /** 多选框选中数据 */ | ||
| 275 | - handleSelectionChange(selection) { | ||
| 276 | - this.ids = selection.map(item => item.operId) | ||
| 277 | - this.multiple = !selection.length | ||
| 278 | - }, | ||
| 279 | - /** 排序触发事件 */ | ||
| 280 | - handleSortChange(column, prop, order) { | ||
| 281 | - this.queryParams.orderByColumn = column.prop; | ||
| 282 | - this.queryParams.isAsc = column.order; | ||
| 283 | - this.getList(); | ||
| 284 | - }, | ||
| 285 | - /** 详细按钮操作 */ | ||
| 286 | - handleView(row) { | ||
| 287 | - this.open = true; | ||
| 288 | - this.form = row; | ||
| 289 | - }, | ||
| 290 | - /** 删除按钮操作 */ | ||
| 291 | - handleDelete(row) { | ||
| 292 | - const operIds = row.operId || this.ids; | ||
| 293 | - this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', "警告", { | ||
| 294 | - confirmButtonText: "确定", | ||
| 295 | - cancelButtonText: "取消", | ||
| 296 | - type: "warning" | ||
| 297 | - }).then(function() { | ||
| 298 | - return delOperlog(operIds); | ||
| 299 | - }).then(() => { | ||
| 300 | - this.getList(); | ||
| 301 | - this.msgSuccess("删除成功"); | ||
| 302 | - }).catch(() => {}); | ||
| 303 | - }, | ||
| 304 | - /** 清空按钮操作 */ | ||
| 305 | - handleClean() { | ||
| 306 | - this.$confirm('是否确认清空所有操作日志数据项?', "警告", { | ||
| 307 | - confirmButtonText: "确定", | ||
| 308 | - cancelButtonText: "取消", | ||
| 309 | - type: "warning" | ||
| 310 | - }).then(function() { | ||
| 311 | - return cleanOperlog(); | ||
| 312 | - }).then(() => { | ||
| 313 | - this.getList(); | ||
| 314 | - this.msgSuccess("清空成功"); | ||
| 315 | - }).catch(() => {}); | ||
| 316 | - }, | ||
| 317 | - /** 导出按钮操作 */ | ||
| 318 | - handleExport() { | ||
| 319 | - const queryParams = this.queryParams; | ||
| 320 | - this.$confirm('是否确认导出所有操作日志数据项?', "警告", { | ||
| 321 | - confirmButtonText: "确定", | ||
| 322 | - cancelButtonText: "取消", | ||
| 323 | - type: "warning" | ||
| 324 | - }).then(() => { | ||
| 325 | - this.exportLoading = true; | ||
| 326 | - return exportOperlog(queryParams); | ||
| 327 | - }).then(response => { | ||
| 328 | - this.download(response.msg); | ||
| 329 | - this.exportLoading = false; | ||
| 330 | - }).catch(() => {}); | ||
| 331 | - } | ||
| 332 | - } | ||
| 333 | -}; | ||
| 334 | -</script> | ||
| 335 | - | 1 | +<template> |
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="系统模块" prop="title"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.title" | ||
| 7 | + placeholder="请输入系统模块" | ||
| 8 | + clearable | ||
| 9 | + style="width: 240px;" | ||
| 10 | + size="small" | ||
| 11 | + @keyup.enter.native="handleQuery" | ||
| 12 | + /> | ||
| 13 | + </el-form-item> | ||
| 14 | + <el-form-item label="操作人员" prop="operName"> | ||
| 15 | + <el-input | ||
| 16 | + v-model="queryParams.operName" | ||
| 17 | + placeholder="请输入操作人员" | ||
| 18 | + clearable | ||
| 19 | + style="width: 240px;" | ||
| 20 | + size="small" | ||
| 21 | + @keyup.enter.native="handleQuery" | ||
| 22 | + /> | ||
| 23 | + </el-form-item> | ||
| 24 | + <el-form-item label="类型" prop="businessType"> | ||
| 25 | + <el-select | ||
| 26 | + v-model="queryParams.businessType" | ||
| 27 | + placeholder="操作类型" | ||
| 28 | + clearable | ||
| 29 | + size="small" | ||
| 30 | + style="width: 240px" | ||
| 31 | + > | ||
| 32 | + <el-option | ||
| 33 | + v-for="dict in typeOptions" | ||
| 34 | + :key="dict.dictValue" | ||
| 35 | + :label="dict.dictLabel" | ||
| 36 | + :value="dict.dictValue" | ||
| 37 | + /> | ||
| 38 | + </el-select> | ||
| 39 | + </el-form-item> | ||
| 40 | + <el-form-item label="状态" prop="status"> | ||
| 41 | + <el-select | ||
| 42 | + v-model="queryParams.status" | ||
| 43 | + placeholder="操作状态" | ||
| 44 | + clearable | ||
| 45 | + size="small" | ||
| 46 | + style="width: 240px" | ||
| 47 | + > | ||
| 48 | + <el-option | ||
| 49 | + v-for="dict in statusOptions" | ||
| 50 | + :key="dict.dictValue" | ||
| 51 | + :label="dict.dictLabel" | ||
| 52 | + :value="dict.dictValue" | ||
| 53 | + /> | ||
| 54 | + </el-select> | ||
| 55 | + </el-form-item> | ||
| 56 | + <el-form-item label="操作时间"> | ||
| 57 | + <el-date-picker | ||
| 58 | + v-model="dateRange" | ||
| 59 | + size="small" | ||
| 60 | + style="width: 240px" | ||
| 61 | + value-format="yyyy-MM-dd" | ||
| 62 | + type="daterange" | ||
| 63 | + range-separator="-" | ||
| 64 | + start-placeholder="开始日期" | ||
| 65 | + end-placeholder="结束日期" | ||
| 66 | + ></el-date-picker> | ||
| 67 | + </el-form-item> | ||
| 68 | + <el-form-item> | ||
| 69 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 70 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 71 | + </el-form-item> | ||
| 72 | + </el-form> | ||
| 73 | + | ||
| 74 | + <el-row :gutter="10" class="mb8"> | ||
| 75 | + <el-col :span="1.5"> | ||
| 76 | + <el-button | ||
| 77 | + type="danger" | ||
| 78 | + plain | ||
| 79 | + icon="el-icon-delete" | ||
| 80 | + size="mini" | ||
| 81 | + :disabled="multiple" | ||
| 82 | + @click="handleDelete" | ||
| 83 | + v-hasPermi="['monitor:operlog:remove']" | ||
| 84 | + >删除</el-button> | ||
| 85 | + </el-col> | ||
| 86 | + <el-col :span="1.5"> | ||
| 87 | + <el-button | ||
| 88 | + type="danger" | ||
| 89 | + plain | ||
| 90 | + icon="el-icon-delete" | ||
| 91 | + size="mini" | ||
| 92 | + @click="handleClean" | ||
| 93 | + v-hasPermi="['monitor:operlog:remove']" | ||
| 94 | + >清空</el-button> | ||
| 95 | + </el-col> | ||
| 96 | + <el-col :span="1.5"> | ||
| 97 | + <el-button | ||
| 98 | + type="warning" | ||
| 99 | + plain | ||
| 100 | + icon="el-icon-download" | ||
| 101 | + size="mini" | ||
| 102 | + :loading="exportLoading" | ||
| 103 | + @click="handleExport" | ||
| 104 | + v-hasPermi="['monitor:operlog:export']" | ||
| 105 | + >导出</el-button> | ||
| 106 | + </el-col> | ||
| 107 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 108 | + </el-row> | ||
| 109 | + | ||
| 110 | + <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> | ||
| 111 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 112 | + <el-table-column label="日志编号" align="center" prop="operId" /> | ||
| 113 | + <el-table-column label="系统模块" align="center" prop="title" /> | ||
| 114 | + <el-table-column label="操作类型" align="center" prop="businessType"> | ||
| 115 | + <template slot-scope="scope"> | ||
| 116 | + <dict-tag :options="typeOptions" :value="scope.row.businessType"/> | ||
| 117 | + </template> | ||
| 118 | + </el-table-column> | ||
| 119 | + <el-table-column label="请求方式" align="center" prop="requestMethod" /> | ||
| 120 | + <el-table-column label="操作人员" align="center" prop="operName" width="100" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" /> | ||
| 121 | + <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" /> | ||
| 122 | + <el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" /> | ||
| 123 | + <el-table-column label="操作状态" align="center" prop="status"> | ||
| 124 | + <template slot-scope="scope"> | ||
| 125 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 126 | + </template> | ||
| 127 | + </el-table-column> | ||
| 128 | + <el-table-column label="操作日期" align="center" prop="operTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180"> | ||
| 129 | + <template slot-scope="scope"> | ||
| 130 | + <span>{{ parseTime(scope.row.operTime) }}</span> | ||
| 131 | + </template> | ||
| 132 | + </el-table-column> | ||
| 133 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 134 | + <template slot-scope="scope"> | ||
| 135 | + <el-button | ||
| 136 | + size="mini" | ||
| 137 | + type="text" | ||
| 138 | + icon="el-icon-view" | ||
| 139 | + @click="handleView(scope.row,scope.index)" | ||
| 140 | + v-hasPermi="['monitor:operlog:query']" | ||
| 141 | + >详细</el-button> | ||
| 142 | + </template> | ||
| 143 | + </el-table-column> | ||
| 144 | + </el-table> | ||
| 145 | + | ||
| 146 | + <pagination | ||
| 147 | + v-show="total>0" | ||
| 148 | + :total="total" | ||
| 149 | + :page.sync="queryParams.pageNum" | ||
| 150 | + :limit.sync="queryParams.pageSize" | ||
| 151 | + @pagination="getList" | ||
| 152 | + /> | ||
| 153 | + | ||
| 154 | + <!-- 操作日志详细 --> | ||
| 155 | + <el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body> | ||
| 156 | + <el-form ref="form" :model="form" label-width="100px" size="mini"> | ||
| 157 | + <el-row> | ||
| 158 | + <el-col :span="12"> | ||
| 159 | + <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item> | ||
| 160 | + <el-form-item | ||
| 161 | + label="登录信息:" | ||
| 162 | + >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item> | ||
| 163 | + </el-col> | ||
| 164 | + <el-col :span="12"> | ||
| 165 | + <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item> | ||
| 166 | + <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item> | ||
| 167 | + </el-col> | ||
| 168 | + <el-col :span="24"> | ||
| 169 | + <el-form-item label="操作方法:">{{ form.method }}</el-form-item> | ||
| 170 | + </el-col> | ||
| 171 | + <el-col :span="24"> | ||
| 172 | + <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item> | ||
| 173 | + </el-col> | ||
| 174 | + <el-col :span="24"> | ||
| 175 | + <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item> | ||
| 176 | + </el-col> | ||
| 177 | + <el-col :span="12"> | ||
| 178 | + <el-form-item label="操作状态:"> | ||
| 179 | + <div v-if="form.status === 0">正常</div> | ||
| 180 | + <div v-else-if="form.status === 1">失败</div> | ||
| 181 | + </el-form-item> | ||
| 182 | + </el-col> | ||
| 183 | + <el-col :span="12"> | ||
| 184 | + <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item> | ||
| 185 | + </el-col> | ||
| 186 | + <el-col :span="24"> | ||
| 187 | + <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item> | ||
| 188 | + </el-col> | ||
| 189 | + </el-row> | ||
| 190 | + </el-form> | ||
| 191 | + <div slot="footer" class="dialog-footer"> | ||
| 192 | + <el-button @click="open = false">关 闭</el-button> | ||
| 193 | + </div> | ||
| 194 | + </el-dialog> | ||
| 195 | + </div> | ||
| 196 | +</template> | ||
| 197 | + | ||
| 198 | +<script> | ||
| 199 | +import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog"; | ||
| 200 | + | ||
| 201 | +export default { | ||
| 202 | + name: "Operlog", | ||
| 203 | + data() { | ||
| 204 | + return { | ||
| 205 | + // 遮罩层 | ||
| 206 | + loading: true, | ||
| 207 | + // 导出遮罩层 | ||
| 208 | + exportLoading: false, | ||
| 209 | + // 选中数组 | ||
| 210 | + ids: [], | ||
| 211 | + // 非多个禁用 | ||
| 212 | + multiple: true, | ||
| 213 | + // 显示搜索条件 | ||
| 214 | + showSearch: true, | ||
| 215 | + // 总条数 | ||
| 216 | + total: 0, | ||
| 217 | + // 表格数据 | ||
| 218 | + list: [], | ||
| 219 | + // 是否显示弹出层 | ||
| 220 | + open: false, | ||
| 221 | + // 类型数据字典 | ||
| 222 | + typeOptions: [], | ||
| 223 | + // 类型数据字典 | ||
| 224 | + statusOptions: [], | ||
| 225 | + // 日期范围 | ||
| 226 | + dateRange: [], | ||
| 227 | + // 默认排序 | ||
| 228 | + defaultSort: {prop: 'operTime', order: 'descending'}, | ||
| 229 | + // 表单参数 | ||
| 230 | + form: {}, | ||
| 231 | + // 查询参数 | ||
| 232 | + queryParams: { | ||
| 233 | + pageNum: 1, | ||
| 234 | + pageSize: 10, | ||
| 235 | + title: undefined, | ||
| 236 | + operName: undefined, | ||
| 237 | + businessType: undefined, | ||
| 238 | + status: undefined | ||
| 239 | + } | ||
| 240 | + }; | ||
| 241 | + }, | ||
| 242 | + created() { | ||
| 243 | + this.getList(); | ||
| 244 | + this.getDicts("sys_oper_type").then(response => { | ||
| 245 | + this.typeOptions = response.data; | ||
| 246 | + }); | ||
| 247 | + this.getDicts("sys_common_status").then(response => { | ||
| 248 | + this.statusOptions = response.data; | ||
| 249 | + }); | ||
| 250 | + }, | ||
| 251 | + methods: { | ||
| 252 | + /** 查询登录日志 */ | ||
| 253 | + getList() { | ||
| 254 | + this.loading = true; | ||
| 255 | + list(this.addDateRange(this.queryParams, this.dateRange)).then( response => { | ||
| 256 | + this.list = response.rows; | ||
| 257 | + this.total = response.total; | ||
| 258 | + this.loading = false; | ||
| 259 | + } | ||
| 260 | + ); | ||
| 261 | + }, | ||
| 262 | + // 操作日志类型字典翻译 | ||
| 263 | + typeFormat(row, column) { | ||
| 264 | + return this.selectDictLabel(this.typeOptions, row.businessType); | ||
| 265 | + }, | ||
| 266 | + /** 搜索按钮操作 */ | ||
| 267 | + handleQuery() { | ||
| 268 | + this.queryParams.pageNum = 1; | ||
| 269 | + this.getList(); | ||
| 270 | + }, | ||
| 271 | + /** 重置按钮操作 */ | ||
| 272 | + resetQuery() { | ||
| 273 | + this.dateRange = []; | ||
| 274 | + this.resetForm("queryForm"); | ||
| 275 | + this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) | ||
| 276 | + this.handleQuery(); | ||
| 277 | + }, | ||
| 278 | + /** 多选框选中数据 */ | ||
| 279 | + handleSelectionChange(selection) { | ||
| 280 | + this.ids = selection.map(item => item.operId) | ||
| 281 | + this.multiple = !selection.length | ||
| 282 | + }, | ||
| 283 | + /** 排序触发事件 */ | ||
| 284 | + handleSortChange(column, prop, order) { | ||
| 285 | + this.queryParams.orderByColumn = column.prop; | ||
| 286 | + this.queryParams.isAsc = column.order; | ||
| 287 | + this.getList(); | ||
| 288 | + }, | ||
| 289 | + /** 详细按钮操作 */ | ||
| 290 | + handleView(row) { | ||
| 291 | + this.open = true; | ||
| 292 | + this.form = row; | ||
| 293 | + }, | ||
| 294 | + /** 删除按钮操作 */ | ||
| 295 | + handleDelete(row) { | ||
| 296 | + const operIds = row.operId || this.ids; | ||
| 297 | + this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', "警告", { | ||
| 298 | + confirmButtonText: "确定", | ||
| 299 | + cancelButtonText: "取消", | ||
| 300 | + type: "warning" | ||
| 301 | + }).then(function() { | ||
| 302 | + return delOperlog(operIds); | ||
| 303 | + }).then(() => { | ||
| 304 | + this.getList(); | ||
| 305 | + this.msgSuccess("删除成功"); | ||
| 306 | + }).catch(() => {}); | ||
| 307 | + }, | ||
| 308 | + /** 清空按钮操作 */ | ||
| 309 | + handleClean() { | ||
| 310 | + this.$confirm('是否确认清空所有操作日志数据项?', "警告", { | ||
| 311 | + confirmButtonText: "确定", | ||
| 312 | + cancelButtonText: "取消", | ||
| 313 | + type: "warning" | ||
| 314 | + }).then(function() { | ||
| 315 | + return cleanOperlog(); | ||
| 316 | + }).then(() => { | ||
| 317 | + this.getList(); | ||
| 318 | + this.msgSuccess("清空成功"); | ||
| 319 | + }).catch(() => {}); | ||
| 320 | + }, | ||
| 321 | + /** 导出按钮操作 */ | ||
| 322 | + handleExport() { | ||
| 323 | + const queryParams = this.queryParams; | ||
| 324 | + this.$confirm('是否确认导出所有操作日志数据项?', "警告", { | ||
| 325 | + confirmButtonText: "确定", | ||
| 326 | + cancelButtonText: "取消", | ||
| 327 | + type: "warning" | ||
| 328 | + }).then(() => { | ||
| 329 | + this.exportLoading = true; | ||
| 330 | + return exportOperlog(queryParams); | ||
| 331 | + }).then(response => { | ||
| 332 | + this.download(response.msg); | ||
| 333 | + this.exportLoading = false; | ||
| 334 | + }).catch(() => {}); | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | +}; | ||
| 338 | +</script> | ||
| 339 | + |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="参数名称" prop="configName"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.configName" | ||
| 7 | - placeholder="请输入参数名称" | ||
| 8 | - clearable | ||
| 9 | - size="small" | ||
| 10 | - style="width: 240px" | ||
| 11 | - @keyup.enter.native="handleQuery" | ||
| 12 | - /> | ||
| 13 | - </el-form-item> | ||
| 14 | - <el-form-item label="参数键名" prop="configKey"> | ||
| 15 | - <el-input | ||
| 16 | - v-model="queryParams.configKey" | ||
| 17 | - placeholder="请输入参数键名" | ||
| 18 | - clearable | ||
| 19 | - size="small" | ||
| 20 | - style="width: 240px" | ||
| 21 | - @keyup.enter.native="handleQuery" | ||
| 22 | - /> | ||
| 23 | - </el-form-item> | ||
| 24 | - <el-form-item label="系统内置" prop="configType"> | ||
| 25 | - <el-select v-model="queryParams.configType" placeholder="系统内置" clearable size="small"> | ||
| 26 | - <el-option | ||
| 27 | - v-for="dict in typeOptions" | ||
| 28 | - :key="dict.dictValue" | ||
| 29 | - :label="dict.dictLabel" | ||
| 30 | - :value="dict.dictValue" | ||
| 31 | - /> | ||
| 32 | - </el-select> | ||
| 33 | - </el-form-item> | ||
| 34 | - <el-form-item label="创建时间"> | ||
| 35 | - <el-date-picker | ||
| 36 | - v-model="dateRange" | ||
| 37 | - size="small" | ||
| 38 | - style="width: 240px" | ||
| 39 | - value-format="yyyy-MM-dd" | ||
| 40 | - type="daterange" | ||
| 41 | - range-separator="-" | ||
| 42 | - start-placeholder="开始日期" | ||
| 43 | - end-placeholder="结束日期" | ||
| 44 | - ></el-date-picker> | ||
| 45 | - </el-form-item> | ||
| 46 | - <el-form-item> | ||
| 47 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 48 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 49 | - </el-form-item> | ||
| 50 | - </el-form> | ||
| 51 | - | ||
| 52 | - <el-row :gutter="10" class="mb8"> | ||
| 53 | - <el-col :span="1.5"> | ||
| 54 | - <el-button | ||
| 55 | - type="primary" | ||
| 56 | - plain | ||
| 57 | - icon="el-icon-plus" | ||
| 58 | - size="mini" | ||
| 59 | - @click="handleAdd" | ||
| 60 | - v-hasPermi="['system:config:add']" | ||
| 61 | - >新增</el-button> | ||
| 62 | - </el-col> | ||
| 63 | - <el-col :span="1.5"> | ||
| 64 | - <el-button | ||
| 65 | - type="success" | ||
| 66 | - plain | ||
| 67 | - icon="el-icon-edit" | ||
| 68 | - size="mini" | ||
| 69 | - :disabled="single" | ||
| 70 | - @click="handleUpdate" | ||
| 71 | - v-hasPermi="['system:config:edit']" | ||
| 72 | - >修改</el-button> | ||
| 73 | - </el-col> | ||
| 74 | - <el-col :span="1.5"> | ||
| 75 | - <el-button | ||
| 76 | - type="danger" | ||
| 77 | - plain | ||
| 78 | - icon="el-icon-delete" | ||
| 79 | - size="mini" | ||
| 80 | - :disabled="multiple" | ||
| 81 | - @click="handleDelete" | ||
| 82 | - v-hasPermi="['system:config:remove']" | ||
| 83 | - >删除</el-button> | ||
| 84 | - </el-col> | ||
| 85 | - <el-col :span="1.5"> | ||
| 86 | - <el-button | ||
| 87 | - type="warning" | ||
| 88 | - plain | ||
| 89 | - icon="el-icon-download" | ||
| 90 | - size="mini" | ||
| 91 | - :loading="exportLoading" | ||
| 92 | - @click="handleExport" | ||
| 93 | - v-hasPermi="['system:config:export']" | ||
| 94 | - >导出</el-button> | ||
| 95 | - </el-col> | ||
| 96 | - <el-col :span="1.5"> | ||
| 97 | - <el-button | ||
| 98 | - type="danger" | ||
| 99 | - plain | ||
| 100 | - icon="el-icon-refresh" | ||
| 101 | - size="mini" | ||
| 102 | - @click="handleRefreshCache" | ||
| 103 | - v-hasPermi="['system:config:remove']" | ||
| 104 | - >刷新缓存</el-button> | ||
| 105 | - </el-col> | ||
| 106 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 107 | - </el-row> | ||
| 108 | - | ||
| 109 | - <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange"> | ||
| 110 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 111 | - <el-table-column label="参数主键" align="center" prop="configId" /> | ||
| 112 | - <el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> | ||
| 113 | - <el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> | ||
| 114 | - <el-table-column label="参数键值" align="center" prop="configValue" /> | ||
| 115 | - <el-table-column label="系统内置" align="center" prop="configType" :formatter="typeFormat" /> | ||
| 116 | - <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | ||
| 117 | - <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 118 | - <template slot-scope="scope"> | ||
| 119 | - <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 120 | - </template> | ||
| 121 | - </el-table-column> | ||
| 122 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 123 | - <template slot-scope="scope"> | ||
| 124 | - <el-button | ||
| 125 | - size="mini" | ||
| 126 | - type="text" | ||
| 127 | - icon="el-icon-edit" | ||
| 128 | - @click="handleUpdate(scope.row)" | ||
| 129 | - v-hasPermi="['system:config:edit']" | ||
| 130 | - >修改</el-button> | ||
| 131 | - <el-button | ||
| 132 | - size="mini" | ||
| 133 | - type="text" | ||
| 134 | - icon="el-icon-delete" | ||
| 135 | - @click="handleDelete(scope.row)" | ||
| 136 | - v-hasPermi="['system:config:remove']" | ||
| 137 | - >删除</el-button> | ||
| 138 | - </template> | ||
| 139 | - </el-table-column> | ||
| 140 | - </el-table> | ||
| 141 | - | ||
| 142 | - <pagination | ||
| 143 | - v-show="total>0" | ||
| 144 | - :total="total" | ||
| 145 | - :page.sync="queryParams.pageNum" | ||
| 146 | - :limit.sync="queryParams.pageSize" | ||
| 147 | - @pagination="getList" | ||
| 148 | - /> | ||
| 149 | - | ||
| 150 | - <!-- 添加或修改参数配置对话框 --> | ||
| 151 | - <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||
| 152 | - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 153 | - <el-form-item label="参数名称" prop="configName"> | ||
| 154 | - <el-input v-model="form.configName" placeholder="请输入参数名称" /> | ||
| 155 | - </el-form-item> | ||
| 156 | - <el-form-item label="参数键名" prop="configKey"> | ||
| 157 | - <el-input v-model="form.configKey" placeholder="请输入参数键名" /> | ||
| 158 | - </el-form-item> | ||
| 159 | - <el-form-item label="参数键值" prop="configValue"> | ||
| 160 | - <el-input v-model="form.configValue" placeholder="请输入参数键值" /> | ||
| 161 | - </el-form-item> | ||
| 162 | - <el-form-item label="系统内置" prop="configType"> | ||
| 163 | - <el-radio-group v-model="form.configType"> | ||
| 164 | - <el-radio | ||
| 165 | - v-for="dict in typeOptions" | ||
| 166 | - :key="dict.dictValue" | ||
| 167 | - :label="dict.dictValue" | ||
| 168 | - >{{dict.dictLabel}}</el-radio> | ||
| 169 | - </el-radio-group> | ||
| 170 | - </el-form-item> | ||
| 171 | - <el-form-item label="备注" prop="remark"> | ||
| 172 | - <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> | ||
| 173 | - </el-form-item> | ||
| 174 | - </el-form> | ||
| 175 | - <div slot="footer" class="dialog-footer"> | ||
| 176 | - <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 177 | - <el-button @click="cancel">取 消</el-button> | ||
| 178 | - </div> | ||
| 179 | - </el-dialog> | ||
| 180 | - </div> | ||
| 181 | -</template> | ||
| 182 | - | ||
| 183 | -<script> | ||
| 184 | -import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, refreshCache } from "@/api/system/config"; | ||
| 185 | - | ||
| 186 | -export default { | ||
| 187 | - name: "Config", | ||
| 188 | - data() { | ||
| 189 | - return { | ||
| 190 | - // 遮罩层 | ||
| 191 | - loading: true, | ||
| 192 | - // 导出遮罩层 | ||
| 193 | - exportLoading: false, | ||
| 194 | - // 选中数组 | ||
| 195 | - ids: [], | ||
| 196 | - // 非单个禁用 | ||
| 197 | - single: true, | ||
| 198 | - // 非多个禁用 | ||
| 199 | - multiple: true, | ||
| 200 | - // 显示搜索条件 | ||
| 201 | - showSearch: true, | ||
| 202 | - // 总条数 | ||
| 203 | - total: 0, | ||
| 204 | - // 参数表格数据 | ||
| 205 | - configList: [], | ||
| 206 | - // 弹出层标题 | ||
| 207 | - title: "", | ||
| 208 | - // 是否显示弹出层 | ||
| 209 | - open: false, | ||
| 210 | - // 类型数据字典 | ||
| 211 | - typeOptions: [], | ||
| 212 | - // 日期范围 | ||
| 213 | - dateRange: [], | ||
| 214 | - // 查询参数 | ||
| 215 | - queryParams: { | ||
| 216 | - pageNum: 1, | ||
| 217 | - pageSize: 10, | ||
| 218 | - configName: undefined, | ||
| 219 | - configKey: undefined, | ||
| 220 | - configType: undefined | ||
| 221 | - }, | ||
| 222 | - // 表单参数 | ||
| 223 | - form: {}, | ||
| 224 | - // 表单校验 | ||
| 225 | - rules: { | ||
| 226 | - configName: [ | ||
| 227 | - { required: true, message: "参数名称不能为空", trigger: "blur" } | ||
| 228 | - ], | ||
| 229 | - configKey: [ | ||
| 230 | - { required: true, message: "参数键名不能为空", trigger: "blur" } | ||
| 231 | - ], | ||
| 232 | - configValue: [ | ||
| 233 | - { required: true, message: "参数键值不能为空", trigger: "blur" } | ||
| 234 | - ] | ||
| 235 | - } | ||
| 236 | - }; | ||
| 237 | - }, | ||
| 238 | - created() { | ||
| 239 | - this.getList(); | ||
| 240 | - this.getDicts("sys_yes_no").then(response => { | ||
| 241 | - this.typeOptions = response.data; | ||
| 242 | - }); | ||
| 243 | - }, | ||
| 244 | - methods: { | ||
| 245 | - /** 查询参数列表 */ | ||
| 246 | - getList() { | ||
| 247 | - this.loading = true; | ||
| 248 | - listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||
| 249 | - this.configList = response.rows; | ||
| 250 | - this.total = response.total; | ||
| 251 | - this.loading = false; | ||
| 252 | - } | ||
| 253 | - ); | ||
| 254 | - }, | ||
| 255 | - // 参数系统内置字典翻译 | ||
| 256 | - typeFormat(row, column) { | ||
| 257 | - return this.selectDictLabel(this.typeOptions, row.configType); | ||
| 258 | - }, | ||
| 259 | - // 取消按钮 | ||
| 260 | - cancel() { | ||
| 261 | - this.open = false; | ||
| 262 | - this.reset(); | ||
| 263 | - }, | ||
| 264 | - // 表单重置 | ||
| 265 | - reset() { | ||
| 266 | - this.form = { | ||
| 267 | - configId: undefined, | ||
| 268 | - configName: undefined, | ||
| 269 | - configKey: undefined, | ||
| 270 | - configValue: undefined, | ||
| 271 | - configType: "Y", | ||
| 272 | - remark: undefined | ||
| 273 | - }; | ||
| 274 | - this.resetForm("form"); | ||
| 275 | - }, | ||
| 276 | - /** 搜索按钮操作 */ | ||
| 277 | - handleQuery() { | ||
| 278 | - this.queryParams.pageNum = 1; | ||
| 279 | - this.getList(); | ||
| 280 | - }, | ||
| 281 | - /** 重置按钮操作 */ | ||
| 282 | - resetQuery() { | ||
| 283 | - this.dateRange = []; | ||
| 284 | - this.resetForm("queryForm"); | ||
| 285 | - this.handleQuery(); | ||
| 286 | - }, | ||
| 287 | - /** 新增按钮操作 */ | ||
| 288 | - handleAdd() { | ||
| 289 | - this.reset(); | ||
| 290 | - this.open = true; | ||
| 291 | - this.title = "添加参数"; | ||
| 292 | - }, | ||
| 293 | - // 多选框选中数据 | ||
| 294 | - handleSelectionChange(selection) { | ||
| 295 | - this.ids = selection.map(item => item.configId) | ||
| 296 | - this.single = selection.length!=1 | ||
| 297 | - this.multiple = !selection.length | ||
| 298 | - }, | ||
| 299 | - /** 修改按钮操作 */ | ||
| 300 | - handleUpdate(row) { | ||
| 301 | - this.reset(); | ||
| 302 | - const configId = row.configId || this.ids | ||
| 303 | - getConfig(configId).then(response => { | ||
| 304 | - this.form = response.data; | ||
| 305 | - this.open = true; | ||
| 306 | - this.title = "修改参数"; | ||
| 307 | - }); | ||
| 308 | - }, | ||
| 309 | - /** 提交按钮 */ | ||
| 310 | - submitForm: function() { | ||
| 311 | - this.$refs["form"].validate(valid => { | ||
| 312 | - if (valid) { | ||
| 313 | - if (this.form.configId != undefined) { | ||
| 314 | - updateConfig(this.form).then(response => { | ||
| 315 | - this.msgSuccess("修改成功"); | ||
| 316 | - this.open = false; | ||
| 317 | - this.getList(); | ||
| 318 | - }); | ||
| 319 | - } else { | ||
| 320 | - addConfig(this.form).then(response => { | ||
| 321 | - this.msgSuccess("新增成功"); | ||
| 322 | - this.open = false; | ||
| 323 | - this.getList(); | ||
| 324 | - }); | ||
| 325 | - } | ||
| 326 | - } | ||
| 327 | - }); | ||
| 328 | - }, | ||
| 329 | - /** 删除按钮操作 */ | ||
| 330 | - handleDelete(row) { | ||
| 331 | - const configIds = row.configId || this.ids; | ||
| 332 | - this.$confirm('是否确认删除参数编号为"' + configIds + '"的数据项?', "警告", { | ||
| 333 | - confirmButtonText: "确定", | ||
| 334 | - cancelButtonText: "取消", | ||
| 335 | - type: "warning" | ||
| 336 | - }).then(function() { | ||
| 337 | - return delConfig(configIds); | ||
| 338 | - }).then(() => { | ||
| 339 | - this.getList(); | ||
| 340 | - this.msgSuccess("删除成功"); | ||
| 341 | - }).catch(() => {}); | ||
| 342 | - }, | ||
| 343 | - /** 导出按钮操作 */ | ||
| 344 | - handleExport() { | ||
| 345 | - const queryParams = this.queryParams; | ||
| 346 | - this.$confirm('是否确认导出所有参数数据项?', "警告", { | ||
| 347 | - confirmButtonText: "确定", | ||
| 348 | - cancelButtonText: "取消", | ||
| 349 | - type: "warning" | ||
| 350 | - }).then(() => { | ||
| 351 | - this.exportLoading = true; | ||
| 352 | - return exportConfig(queryParams); | ||
| 353 | - }).then(response => { | ||
| 354 | - this.download(response.msg); | ||
| 355 | - this.exportLoading = false; | ||
| 356 | - }).catch(() => {}); | ||
| 357 | - }, | ||
| 358 | - /** 刷新缓存按钮操作 */ | ||
| 359 | - handleRefreshCache() { | ||
| 360 | - refreshCache().then(() => { | ||
| 361 | - this.msgSuccess("刷新成功"); | ||
| 362 | - }); | ||
| 363 | - } | ||
| 364 | - } | ||
| 365 | -}; | ||
| 366 | -</script> | ||
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="参数名称" prop="configName"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.configName" | ||
| 7 | + placeholder="请输入参数名称" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + style="width: 240px" | ||
| 11 | + @keyup.enter.native="handleQuery" | ||
| 12 | + /> | ||
| 13 | + </el-form-item> | ||
| 14 | + <el-form-item label="参数键名" prop="configKey"> | ||
| 15 | + <el-input | ||
| 16 | + v-model="queryParams.configKey" | ||
| 17 | + placeholder="请输入参数键名" | ||
| 18 | + clearable | ||
| 19 | + size="small" | ||
| 20 | + style="width: 240px" | ||
| 21 | + @keyup.enter.native="handleQuery" | ||
| 22 | + /> | ||
| 23 | + </el-form-item> | ||
| 24 | + <el-form-item label="系统内置" prop="configType"> | ||
| 25 | + <el-select v-model="queryParams.configType" placeholder="系统内置" clearable size="small"> | ||
| 26 | + <el-option | ||
| 27 | + v-for="dict in typeOptions" | ||
| 28 | + :key="dict.dictValue" | ||
| 29 | + :label="dict.dictLabel" | ||
| 30 | + :value="dict.dictValue" | ||
| 31 | + /> | ||
| 32 | + </el-select> | ||
| 33 | + </el-form-item> | ||
| 34 | + <el-form-item label="创建时间"> | ||
| 35 | + <el-date-picker | ||
| 36 | + v-model="dateRange" | ||
| 37 | + size="small" | ||
| 38 | + style="width: 240px" | ||
| 39 | + value-format="yyyy-MM-dd" | ||
| 40 | + type="daterange" | ||
| 41 | + range-separator="-" | ||
| 42 | + start-placeholder="开始日期" | ||
| 43 | + end-placeholder="结束日期" | ||
| 44 | + ></el-date-picker> | ||
| 45 | + </el-form-item> | ||
| 46 | + <el-form-item> | ||
| 47 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 48 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 49 | + </el-form-item> | ||
| 50 | + </el-form> | ||
| 51 | + | ||
| 52 | + <el-row :gutter="10" class="mb8"> | ||
| 53 | + <el-col :span="1.5"> | ||
| 54 | + <el-button | ||
| 55 | + type="primary" | ||
| 56 | + plain | ||
| 57 | + icon="el-icon-plus" | ||
| 58 | + size="mini" | ||
| 59 | + @click="handleAdd" | ||
| 60 | + v-hasPermi="['system:config:add']" | ||
| 61 | + >新增</el-button> | ||
| 62 | + </el-col> | ||
| 63 | + <el-col :span="1.5"> | ||
| 64 | + <el-button | ||
| 65 | + type="success" | ||
| 66 | + plain | ||
| 67 | + icon="el-icon-edit" | ||
| 68 | + size="mini" | ||
| 69 | + :disabled="single" | ||
| 70 | + @click="handleUpdate" | ||
| 71 | + v-hasPermi="['system:config:edit']" | ||
| 72 | + >修改</el-button> | ||
| 73 | + </el-col> | ||
| 74 | + <el-col :span="1.5"> | ||
| 75 | + <el-button | ||
| 76 | + type="danger" | ||
| 77 | + plain | ||
| 78 | + icon="el-icon-delete" | ||
| 79 | + size="mini" | ||
| 80 | + :disabled="multiple" | ||
| 81 | + @click="handleDelete" | ||
| 82 | + v-hasPermi="['system:config:remove']" | ||
| 83 | + >删除</el-button> | ||
| 84 | + </el-col> | ||
| 85 | + <el-col :span="1.5"> | ||
| 86 | + <el-button | ||
| 87 | + type="warning" | ||
| 88 | + plain | ||
| 89 | + icon="el-icon-download" | ||
| 90 | + size="mini" | ||
| 91 | + :loading="exportLoading" | ||
| 92 | + @click="handleExport" | ||
| 93 | + v-hasPermi="['system:config:export']" | ||
| 94 | + >导出</el-button> | ||
| 95 | + </el-col> | ||
| 96 | + <el-col :span="1.5"> | ||
| 97 | + <el-button | ||
| 98 | + type="danger" | ||
| 99 | + plain | ||
| 100 | + icon="el-icon-refresh" | ||
| 101 | + size="mini" | ||
| 102 | + @click="handleRefreshCache" | ||
| 103 | + v-hasPermi="['system:config:remove']" | ||
| 104 | + >刷新缓存</el-button> | ||
| 105 | + </el-col> | ||
| 106 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 107 | + </el-row> | ||
| 108 | + | ||
| 109 | + <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange"> | ||
| 110 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 111 | + <el-table-column label="参数主键" align="center" prop="configId" /> | ||
| 112 | + <el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> | ||
| 113 | + <el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> | ||
| 114 | + <el-table-column label="参数键值" align="center" prop="configValue" /> | ||
| 115 | + <el-table-column label="系统内置" align="center" prop="configType"> | ||
| 116 | + <template slot-scope="scope"> | ||
| 117 | + <dict-tag :options="typeOptions" :value="scope.row.configType"/> | ||
| 118 | + </template> | ||
| 119 | + </el-table-column> | ||
| 120 | + <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | ||
| 121 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 122 | + <template slot-scope="scope"> | ||
| 123 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 124 | + </template> | ||
| 125 | + </el-table-column> | ||
| 126 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 127 | + <template slot-scope="scope"> | ||
| 128 | + <el-button | ||
| 129 | + size="mini" | ||
| 130 | + type="text" | ||
| 131 | + icon="el-icon-edit" | ||
| 132 | + @click="handleUpdate(scope.row)" | ||
| 133 | + v-hasPermi="['system:config:edit']" | ||
| 134 | + >修改</el-button> | ||
| 135 | + <el-button | ||
| 136 | + size="mini" | ||
| 137 | + type="text" | ||
| 138 | + icon="el-icon-delete" | ||
| 139 | + @click="handleDelete(scope.row)" | ||
| 140 | + v-hasPermi="['system:config:remove']" | ||
| 141 | + >删除</el-button> | ||
| 142 | + </template> | ||
| 143 | + </el-table-column> | ||
| 144 | + </el-table> | ||
| 145 | + | ||
| 146 | + <pagination | ||
| 147 | + v-show="total>0" | ||
| 148 | + :total="total" | ||
| 149 | + :page.sync="queryParams.pageNum" | ||
| 150 | + :limit.sync="queryParams.pageSize" | ||
| 151 | + @pagination="getList" | ||
| 152 | + /> | ||
| 153 | + | ||
| 154 | + <!-- 添加或修改参数配置对话框 --> | ||
| 155 | + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||
| 156 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 157 | + <el-form-item label="参数名称" prop="configName"> | ||
| 158 | + <el-input v-model="form.configName" placeholder="请输入参数名称" /> | ||
| 159 | + </el-form-item> | ||
| 160 | + <el-form-item label="参数键名" prop="configKey"> | ||
| 161 | + <el-input v-model="form.configKey" placeholder="请输入参数键名" /> | ||
| 162 | + </el-form-item> | ||
| 163 | + <el-form-item label="参数键值" prop="configValue"> | ||
| 164 | + <el-input v-model="form.configValue" placeholder="请输入参数键值" /> | ||
| 165 | + </el-form-item> | ||
| 166 | + <el-form-item label="系统内置" prop="configType"> | ||
| 167 | + <el-radio-group v-model="form.configType"> | ||
| 168 | + <el-radio | ||
| 169 | + v-for="dict in typeOptions" | ||
| 170 | + :key="dict.dictValue" | ||
| 171 | + :label="dict.dictValue" | ||
| 172 | + >{{dict.dictLabel}}</el-radio> | ||
| 173 | + </el-radio-group> | ||
| 174 | + </el-form-item> | ||
| 175 | + <el-form-item label="备注" prop="remark"> | ||
| 176 | + <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> | ||
| 177 | + </el-form-item> | ||
| 178 | + </el-form> | ||
| 179 | + <div slot="footer" class="dialog-footer"> | ||
| 180 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 181 | + <el-button @click="cancel">取 消</el-button> | ||
| 182 | + </div> | ||
| 183 | + </el-dialog> | ||
| 184 | + </div> | ||
| 185 | +</template> | ||
| 186 | + | ||
| 187 | +<script> | ||
| 188 | +import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, refreshCache } from "@/api/system/config"; | ||
| 189 | + | ||
| 190 | +export default { | ||
| 191 | + name: "Config", | ||
| 192 | + data() { | ||
| 193 | + return { | ||
| 194 | + // 遮罩层 | ||
| 195 | + loading: true, | ||
| 196 | + // 导出遮罩层 | ||
| 197 | + exportLoading: false, | ||
| 198 | + // 选中数组 | ||
| 199 | + ids: [], | ||
| 200 | + // 非单个禁用 | ||
| 201 | + single: true, | ||
| 202 | + // 非多个禁用 | ||
| 203 | + multiple: true, | ||
| 204 | + // 显示搜索条件 | ||
| 205 | + showSearch: true, | ||
| 206 | + // 总条数 | ||
| 207 | + total: 0, | ||
| 208 | + // 参数表格数据 | ||
| 209 | + configList: [], | ||
| 210 | + // 弹出层标题 | ||
| 211 | + title: "", | ||
| 212 | + // 是否显示弹出层 | ||
| 213 | + open: false, | ||
| 214 | + // 类型数据字典 | ||
| 215 | + typeOptions: [], | ||
| 216 | + // 日期范围 | ||
| 217 | + dateRange: [], | ||
| 218 | + // 查询参数 | ||
| 219 | + queryParams: { | ||
| 220 | + pageNum: 1, | ||
| 221 | + pageSize: 10, | ||
| 222 | + configName: undefined, | ||
| 223 | + configKey: undefined, | ||
| 224 | + configType: undefined | ||
| 225 | + }, | ||
| 226 | + // 表单参数 | ||
| 227 | + form: {}, | ||
| 228 | + // 表单校验 | ||
| 229 | + rules: { | ||
| 230 | + configName: [ | ||
| 231 | + { required: true, message: "参数名称不能为空", trigger: "blur" } | ||
| 232 | + ], | ||
| 233 | + configKey: [ | ||
| 234 | + { required: true, message: "参数键名不能为空", trigger: "blur" } | ||
| 235 | + ], | ||
| 236 | + configValue: [ | ||
| 237 | + { required: true, message: "参数键值不能为空", trigger: "blur" } | ||
| 238 | + ] | ||
| 239 | + } | ||
| 240 | + }; | ||
| 241 | + }, | ||
| 242 | + created() { | ||
| 243 | + this.getList(); | ||
| 244 | + this.getDicts("sys_yes_no").then(response => { | ||
| 245 | + this.typeOptions = response.data; | ||
| 246 | + }); | ||
| 247 | + }, | ||
| 248 | + methods: { | ||
| 249 | + /** 查询参数列表 */ | ||
| 250 | + getList() { | ||
| 251 | + this.loading = true; | ||
| 252 | + listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||
| 253 | + this.configList = response.rows; | ||
| 254 | + this.total = response.total; | ||
| 255 | + this.loading = false; | ||
| 256 | + } | ||
| 257 | + ); | ||
| 258 | + }, | ||
| 259 | + // 取消按钮 | ||
| 260 | + cancel() { | ||
| 261 | + this.open = false; | ||
| 262 | + this.reset(); | ||
| 263 | + }, | ||
| 264 | + // 表单重置 | ||
| 265 | + reset() { | ||
| 266 | + this.form = { | ||
| 267 | + configId: undefined, | ||
| 268 | + configName: undefined, | ||
| 269 | + configKey: undefined, | ||
| 270 | + configValue: undefined, | ||
| 271 | + configType: "Y", | ||
| 272 | + remark: undefined | ||
| 273 | + }; | ||
| 274 | + this.resetForm("form"); | ||
| 275 | + }, | ||
| 276 | + /** 搜索按钮操作 */ | ||
| 277 | + handleQuery() { | ||
| 278 | + this.queryParams.pageNum = 1; | ||
| 279 | + this.getList(); | ||
| 280 | + }, | ||
| 281 | + /** 重置按钮操作 */ | ||
| 282 | + resetQuery() { | ||
| 283 | + this.dateRange = []; | ||
| 284 | + this.resetForm("queryForm"); | ||
| 285 | + this.handleQuery(); | ||
| 286 | + }, | ||
| 287 | + /** 新增按钮操作 */ | ||
| 288 | + handleAdd() { | ||
| 289 | + this.reset(); | ||
| 290 | + this.open = true; | ||
| 291 | + this.title = "添加参数"; | ||
| 292 | + }, | ||
| 293 | + // 多选框选中数据 | ||
| 294 | + handleSelectionChange(selection) { | ||
| 295 | + this.ids = selection.map(item => item.configId) | ||
| 296 | + this.single = selection.length!=1 | ||
| 297 | + this.multiple = !selection.length | ||
| 298 | + }, | ||
| 299 | + /** 修改按钮操作 */ | ||
| 300 | + handleUpdate(row) { | ||
| 301 | + this.reset(); | ||
| 302 | + const configId = row.configId || this.ids | ||
| 303 | + getConfig(configId).then(response => { | ||
| 304 | + this.form = response.data; | ||
| 305 | + this.open = true; | ||
| 306 | + this.title = "修改参数"; | ||
| 307 | + }); | ||
| 308 | + }, | ||
| 309 | + /** 提交按钮 */ | ||
| 310 | + submitForm: function() { | ||
| 311 | + this.$refs["form"].validate(valid => { | ||
| 312 | + if (valid) { | ||
| 313 | + if (this.form.configId != undefined) { | ||
| 314 | + updateConfig(this.form).then(response => { | ||
| 315 | + this.msgSuccess("修改成功"); | ||
| 316 | + this.open = false; | ||
| 317 | + this.getList(); | ||
| 318 | + }); | ||
| 319 | + } else { | ||
| 320 | + addConfig(this.form).then(response => { | ||
| 321 | + this.msgSuccess("新增成功"); | ||
| 322 | + this.open = false; | ||
| 323 | + this.getList(); | ||
| 324 | + }); | ||
| 325 | + } | ||
| 326 | + } | ||
| 327 | + }); | ||
| 328 | + }, | ||
| 329 | + /** 删除按钮操作 */ | ||
| 330 | + handleDelete(row) { | ||
| 331 | + const configIds = row.configId || this.ids; | ||
| 332 | + this.$confirm('是否确认删除参数编号为"' + configIds + '"的数据项?', "警告", { | ||
| 333 | + confirmButtonText: "确定", | ||
| 334 | + cancelButtonText: "取消", | ||
| 335 | + type: "warning" | ||
| 336 | + }).then(function() { | ||
| 337 | + return delConfig(configIds); | ||
| 338 | + }).then(() => { | ||
| 339 | + this.getList(); | ||
| 340 | + this.msgSuccess("删除成功"); | ||
| 341 | + }).catch(() => {}); | ||
| 342 | + }, | ||
| 343 | + /** 导出按钮操作 */ | ||
| 344 | + handleExport() { | ||
| 345 | + const queryParams = this.queryParams; | ||
| 346 | + this.$confirm('是否确认导出所有参数数据项?', "警告", { | ||
| 347 | + confirmButtonText: "确定", | ||
| 348 | + cancelButtonText: "取消", | ||
| 349 | + type: "warning" | ||
| 350 | + }).then(() => { | ||
| 351 | + this.exportLoading = true; | ||
| 352 | + return exportConfig(queryParams); | ||
| 353 | + }).then(response => { | ||
| 354 | + this.download(response.msg); | ||
| 355 | + this.exportLoading = false; | ||
| 356 | + }).catch(() => {}); | ||
| 357 | + }, | ||
| 358 | + /** 刷新缓存按钮操作 */ | ||
| 359 | + handleRefreshCache() { | ||
| 360 | + refreshCache().then(() => { | ||
| 361 | + this.msgSuccess("刷新成功"); | ||
| 362 | + }); | ||
| 363 | + } | ||
| 364 | + } | ||
| 365 | +}; | ||
| 366 | +</script> |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> | ||
| 4 | - <el-form-item label="部门名称" prop="deptName"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.deptName" | ||
| 7 | - placeholder="请输入部门名称" | ||
| 8 | - clearable | ||
| 9 | - size="small" | ||
| 10 | - @keyup.enter.native="handleQuery" | ||
| 11 | - /> | ||
| 12 | - </el-form-item> | ||
| 13 | - <el-form-item label="状态" prop="status"> | ||
| 14 | - <el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small"> | ||
| 15 | - <el-option | ||
| 16 | - v-for="dict in statusOptions" | ||
| 17 | - :key="dict.dictValue" | ||
| 18 | - :label="dict.dictLabel" | ||
| 19 | - :value="dict.dictValue" | ||
| 20 | - /> | ||
| 21 | - </el-select> | ||
| 22 | - </el-form-item> | ||
| 23 | - <el-form-item> | ||
| 24 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 25 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 26 | - </el-form-item> | ||
| 27 | - </el-form> | ||
| 28 | - | ||
| 29 | - <el-row :gutter="10" class="mb8"> | ||
| 30 | - <el-col :span="1.5"> | ||
| 31 | - <el-button | ||
| 32 | - type="primary" | ||
| 33 | - plain | ||
| 34 | - icon="el-icon-plus" | ||
| 35 | - size="mini" | ||
| 36 | - @click="handleAdd" | ||
| 37 | - v-hasPermi="['system:dept:add']" | ||
| 38 | - >新增</el-button> | ||
| 39 | - </el-col> | ||
| 40 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 41 | - </el-row> | ||
| 42 | - | ||
| 43 | - <el-table | ||
| 44 | - v-loading="loading" | ||
| 45 | - :data="deptList" | ||
| 46 | - row-key="deptId" | ||
| 47 | - default-expand-all | ||
| 48 | - :tree-props="{children: 'children', hasChildren: 'hasChildren'}" | ||
| 49 | - > | ||
| 50 | - <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> | ||
| 51 | - <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> | ||
| 52 | - <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column> | ||
| 53 | - <el-table-column label="创建时间" align="center" prop="createTime" width="200"> | ||
| 54 | - <template slot-scope="scope"> | ||
| 55 | - <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 56 | - </template> | ||
| 57 | - </el-table-column> | ||
| 58 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 59 | - <template slot-scope="scope"> | ||
| 60 | - <el-button | ||
| 61 | - size="mini" | ||
| 62 | - type="text" | ||
| 63 | - icon="el-icon-edit" | ||
| 64 | - @click="handleUpdate(scope.row)" | ||
| 65 | - v-hasPermi="['system:dept:edit']" | ||
| 66 | - >修改</el-button> | ||
| 67 | - <el-button | ||
| 68 | - size="mini" | ||
| 69 | - type="text" | ||
| 70 | - icon="el-icon-plus" | ||
| 71 | - @click="handleAdd(scope.row)" | ||
| 72 | - v-hasPermi="['system:dept:add']" | ||
| 73 | - >新增</el-button> | ||
| 74 | - <el-button | ||
| 75 | - v-if="scope.row.parentId != 0" | ||
| 76 | - size="mini" | ||
| 77 | - type="text" | ||
| 78 | - icon="el-icon-delete" | ||
| 79 | - @click="handleDelete(scope.row)" | ||
| 80 | - v-hasPermi="['system:dept:remove']" | ||
| 81 | - >删除</el-button> | ||
| 82 | - </template> | ||
| 83 | - </el-table-column> | ||
| 84 | - </el-table> | ||
| 85 | - | ||
| 86 | - <!-- 添加或修改部门对话框 --> | ||
| 87 | - <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> | ||
| 88 | - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 89 | - <el-row> | ||
| 90 | - <el-col :span="24" v-if="form.parentId !== 0"> | ||
| 91 | - <el-form-item label="上级部门" prop="parentId"> | ||
| 92 | - <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" /> | ||
| 93 | - </el-form-item> | ||
| 94 | - </el-col> | ||
| 95 | - <el-col :span="12"> | ||
| 96 | - <el-form-item label="部门名称" prop="deptName"> | ||
| 97 | - <el-input v-model="form.deptName" placeholder="请输入部门名称" /> | ||
| 98 | - </el-form-item> | ||
| 99 | - </el-col> | ||
| 100 | - <el-col :span="12"> | ||
| 101 | - <el-form-item label="显示排序" prop="orderNum"> | ||
| 102 | - <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> | ||
| 103 | - </el-form-item> | ||
| 104 | - </el-col> | ||
| 105 | - <el-col :span="12"> | ||
| 106 | - <el-form-item label="负责人" prop="leader"> | ||
| 107 | - <el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> | ||
| 108 | - </el-form-item> | ||
| 109 | - </el-col> | ||
| 110 | - <el-col :span="12"> | ||
| 111 | - <el-form-item label="联系电话" prop="phone"> | ||
| 112 | - <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" /> | ||
| 113 | - </el-form-item> | ||
| 114 | - </el-col> | ||
| 115 | - <el-col :span="12"> | ||
| 116 | - <el-form-item label="邮箱" prop="email"> | ||
| 117 | - <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> | ||
| 118 | - </el-form-item> | ||
| 119 | - </el-col> | ||
| 120 | - <el-col :span="12"> | ||
| 121 | - <el-form-item label="部门状态"> | ||
| 122 | - <el-radio-group v-model="form.status"> | ||
| 123 | - <el-radio | ||
| 124 | - v-for="dict in statusOptions" | ||
| 125 | - :key="dict.dictValue" | ||
| 126 | - :label="dict.dictValue" | ||
| 127 | - >{{dict.dictLabel}}</el-radio> | ||
| 128 | - </el-radio-group> | ||
| 129 | - </el-form-item> | ||
| 130 | - </el-col> | ||
| 131 | - </el-row> | ||
| 132 | - </el-form> | ||
| 133 | - <div slot="footer" class="dialog-footer"> | ||
| 134 | - <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 135 | - <el-button @click="cancel">取 消</el-button> | ||
| 136 | - </div> | ||
| 137 | - </el-dialog> | ||
| 138 | - </div> | ||
| 139 | -</template> | ||
| 140 | - | ||
| 141 | -<script> | ||
| 142 | -import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; | ||
| 143 | -import Treeselect from "@riophae/vue-treeselect"; | ||
| 144 | -import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||
| 145 | - | ||
| 146 | -export default { | ||
| 147 | - name: "Dept", | ||
| 148 | - components: { Treeselect }, | ||
| 149 | - data() { | ||
| 150 | - return { | ||
| 151 | - // 遮罩层 | ||
| 152 | - loading: true, | ||
| 153 | - // 显示搜索条件 | ||
| 154 | - showSearch: true, | ||
| 155 | - // 表格树数据 | ||
| 156 | - deptList: [], | ||
| 157 | - // 部门树选项 | ||
| 158 | - deptOptions: [], | ||
| 159 | - // 弹出层标题 | ||
| 160 | - title: "", | ||
| 161 | - // 是否显示弹出层 | ||
| 162 | - open: false, | ||
| 163 | - // 状态数据字典 | ||
| 164 | - statusOptions: [], | ||
| 165 | - // 查询参数 | ||
| 166 | - queryParams: { | ||
| 167 | - deptName: undefined, | ||
| 168 | - status: undefined | ||
| 169 | - }, | ||
| 170 | - // 表单参数 | ||
| 171 | - form: {}, | ||
| 172 | - // 表单校验 | ||
| 173 | - rules: { | ||
| 174 | - parentId: [ | ||
| 175 | - { required: true, message: "上级部门不能为空", trigger: "blur" } | ||
| 176 | - ], | ||
| 177 | - deptName: [ | ||
| 178 | - { required: true, message: "部门名称不能为空", trigger: "blur" } | ||
| 179 | - ], | ||
| 180 | - orderNum: [ | ||
| 181 | - { required: true, message: "显示排序不能为空", trigger: "blur" } | ||
| 182 | - ], | ||
| 183 | - email: [ | ||
| 184 | - { | ||
| 185 | - type: "email", | ||
| 186 | - message: "'请输入正确的邮箱地址", | ||
| 187 | - trigger: ["blur", "change"] | ||
| 188 | - } | ||
| 189 | - ], | ||
| 190 | - phone: [ | ||
| 191 | - { | ||
| 192 | - pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, | ||
| 193 | - message: "请输入正确的手机号码", | ||
| 194 | - trigger: "blur" | ||
| 195 | - } | ||
| 196 | - ] | ||
| 197 | - } | ||
| 198 | - }; | ||
| 199 | - }, | ||
| 200 | - created() { | ||
| 201 | - this.getList(); | ||
| 202 | - this.getDicts("sys_normal_disable").then(response => { | ||
| 203 | - this.statusOptions = response.data; | ||
| 204 | - }); | ||
| 205 | - }, | ||
| 206 | - methods: { | ||
| 207 | - /** 查询部门列表 */ | ||
| 208 | - getList() { | ||
| 209 | - this.loading = true; | ||
| 210 | - listDept(this.queryParams).then(response => { | ||
| 211 | - this.deptList = this.handleTree(response.data, "deptId"); | ||
| 212 | - this.loading = false; | ||
| 213 | - }); | ||
| 214 | - }, | ||
| 215 | - /** 转换部门数据结构 */ | ||
| 216 | - normalizer(node) { | ||
| 217 | - if (node.children && !node.children.length) { | ||
| 218 | - delete node.children; | ||
| 219 | - } | ||
| 220 | - return { | ||
| 221 | - id: node.deptId, | ||
| 222 | - label: node.deptName, | ||
| 223 | - children: node.children | ||
| 224 | - }; | ||
| 225 | - }, | ||
| 226 | - // 字典状态字典翻译 | ||
| 227 | - statusFormat(row, column) { | ||
| 228 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 229 | - }, | ||
| 230 | - // 取消按钮 | ||
| 231 | - cancel() { | ||
| 232 | - this.open = false; | ||
| 233 | - this.reset(); | ||
| 234 | - }, | ||
| 235 | - // 表单重置 | ||
| 236 | - reset() { | ||
| 237 | - this.form = { | ||
| 238 | - deptId: undefined, | ||
| 239 | - parentId: undefined, | ||
| 240 | - deptName: undefined, | ||
| 241 | - orderNum: undefined, | ||
| 242 | - leader: undefined, | ||
| 243 | - phone: undefined, | ||
| 244 | - email: undefined, | ||
| 245 | - status: "0" | ||
| 246 | - }; | ||
| 247 | - this.resetForm("form"); | ||
| 248 | - }, | ||
| 249 | - /** 搜索按钮操作 */ | ||
| 250 | - handleQuery() { | ||
| 251 | - this.getList(); | ||
| 252 | - }, | ||
| 253 | - /** 重置按钮操作 */ | ||
| 254 | - resetQuery() { | ||
| 255 | - this.resetForm("queryForm"); | ||
| 256 | - this.handleQuery(); | ||
| 257 | - }, | ||
| 258 | - /** 新增按钮操作 */ | ||
| 259 | - handleAdd(row) { | ||
| 260 | - this.reset(); | ||
| 261 | - if (row != undefined) { | ||
| 262 | - this.form.parentId = row.deptId; | ||
| 263 | - } | ||
| 264 | - this.open = true; | ||
| 265 | - this.title = "添加部门"; | ||
| 266 | - listDept().then(response => { | ||
| 267 | - this.deptOptions = this.handleTree(response.data, "deptId"); | ||
| 268 | - }); | ||
| 269 | - }, | ||
| 270 | - /** 修改按钮操作 */ | ||
| 271 | - handleUpdate(row) { | ||
| 272 | - this.reset(); | ||
| 273 | - getDept(row.deptId).then(response => { | ||
| 274 | - this.form = response.data; | ||
| 275 | - this.open = true; | ||
| 276 | - this.title = "修改部门"; | ||
| 277 | - }); | ||
| 278 | - listDeptExcludeChild(row.deptId).then(response => { | ||
| 279 | - this.deptOptions = this.handleTree(response.data, "deptId"); | ||
| 280 | - }); | ||
| 281 | - }, | ||
| 282 | - /** 提交按钮 */ | ||
| 283 | - submitForm: function() { | ||
| 284 | - this.$refs["form"].validate(valid => { | ||
| 285 | - if (valid) { | ||
| 286 | - if (this.form.deptId != undefined) { | ||
| 287 | - updateDept(this.form).then(response => { | ||
| 288 | - this.msgSuccess("修改成功"); | ||
| 289 | - this.open = false; | ||
| 290 | - this.getList(); | ||
| 291 | - }); | ||
| 292 | - } else { | ||
| 293 | - addDept(this.form).then(response => { | ||
| 294 | - this.msgSuccess("新增成功"); | ||
| 295 | - this.open = false; | ||
| 296 | - this.getList(); | ||
| 297 | - }); | ||
| 298 | - } | ||
| 299 | - } | ||
| 300 | - }); | ||
| 301 | - }, | ||
| 302 | - /** 删除按钮操作 */ | ||
| 303 | - handleDelete(row) { | ||
| 304 | - this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", { | ||
| 305 | - confirmButtonText: "确定", | ||
| 306 | - cancelButtonText: "取消", | ||
| 307 | - type: "warning" | ||
| 308 | - }).then(function() { | ||
| 309 | - return delDept(row.deptId); | ||
| 310 | - }).then(() => { | ||
| 311 | - this.getList(); | ||
| 312 | - this.msgSuccess("删除成功"); | ||
| 313 | - }).catch(() => {}); | ||
| 314 | - } | ||
| 315 | - } | ||
| 316 | -}; | ||
| 317 | -</script> | ||
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> | ||
| 4 | + <el-form-item label="部门名称" prop="deptName"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.deptName" | ||
| 7 | + placeholder="请输入部门名称" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + @keyup.enter.native="handleQuery" | ||
| 11 | + /> | ||
| 12 | + </el-form-item> | ||
| 13 | + <el-form-item label="状态" prop="status"> | ||
| 14 | + <el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small"> | ||
| 15 | + <el-option | ||
| 16 | + v-for="dict in statusOptions" | ||
| 17 | + :key="dict.dictValue" | ||
| 18 | + :label="dict.dictLabel" | ||
| 19 | + :value="dict.dictValue" | ||
| 20 | + /> | ||
| 21 | + </el-select> | ||
| 22 | + </el-form-item> | ||
| 23 | + <el-form-item> | ||
| 24 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 25 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 26 | + </el-form-item> | ||
| 27 | + </el-form> | ||
| 28 | + | ||
| 29 | + <el-row :gutter="10" class="mb8"> | ||
| 30 | + <el-col :span="1.5"> | ||
| 31 | + <el-button | ||
| 32 | + type="primary" | ||
| 33 | + plain | ||
| 34 | + icon="el-icon-plus" | ||
| 35 | + size="mini" | ||
| 36 | + @click="handleAdd" | ||
| 37 | + v-hasPermi="['system:dept:add']" | ||
| 38 | + >新增</el-button> | ||
| 39 | + </el-col> | ||
| 40 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 41 | + </el-row> | ||
| 42 | + | ||
| 43 | + <el-table | ||
| 44 | + v-loading="loading" | ||
| 45 | + :data="deptList" | ||
| 46 | + row-key="deptId" | ||
| 47 | + default-expand-all | ||
| 48 | + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" | ||
| 49 | + > | ||
| 50 | + <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> | ||
| 51 | + <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> | ||
| 52 | + <el-table-column prop="status" label="状态" width="100"> | ||
| 53 | + <template slot-scope="scope"> | ||
| 54 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 55 | + </template> | ||
| 56 | + </el-table-column> | ||
| 57 | + <el-table-column label="创建时间" align="center" prop="createTime" width="200"> | ||
| 58 | + <template slot-scope="scope"> | ||
| 59 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 60 | + </template> | ||
| 61 | + </el-table-column> | ||
| 62 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 63 | + <template slot-scope="scope"> | ||
| 64 | + <el-button | ||
| 65 | + size="mini" | ||
| 66 | + type="text" | ||
| 67 | + icon="el-icon-edit" | ||
| 68 | + @click="handleUpdate(scope.row)" | ||
| 69 | + v-hasPermi="['system:dept:edit']" | ||
| 70 | + >修改</el-button> | ||
| 71 | + <el-button | ||
| 72 | + size="mini" | ||
| 73 | + type="text" | ||
| 74 | + icon="el-icon-plus" | ||
| 75 | + @click="handleAdd(scope.row)" | ||
| 76 | + v-hasPermi="['system:dept:add']" | ||
| 77 | + >新增</el-button> | ||
| 78 | + <el-button | ||
| 79 | + v-if="scope.row.parentId != 0" | ||
| 80 | + size="mini" | ||
| 81 | + type="text" | ||
| 82 | + icon="el-icon-delete" | ||
| 83 | + @click="handleDelete(scope.row)" | ||
| 84 | + v-hasPermi="['system:dept:remove']" | ||
| 85 | + >删除</el-button> | ||
| 86 | + </template> | ||
| 87 | + </el-table-column> | ||
| 88 | + </el-table> | ||
| 89 | + | ||
| 90 | + <!-- 添加或修改部门对话框 --> | ||
| 91 | + <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> | ||
| 92 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 93 | + <el-row> | ||
| 94 | + <el-col :span="24" v-if="form.parentId !== 0"> | ||
| 95 | + <el-form-item label="上级部门" prop="parentId"> | ||
| 96 | + <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" /> | ||
| 97 | + </el-form-item> | ||
| 98 | + </el-col> | ||
| 99 | + <el-col :span="12"> | ||
| 100 | + <el-form-item label="部门名称" prop="deptName"> | ||
| 101 | + <el-input v-model="form.deptName" placeholder="请输入部门名称" /> | ||
| 102 | + </el-form-item> | ||
| 103 | + </el-col> | ||
| 104 | + <el-col :span="12"> | ||
| 105 | + <el-form-item label="显示排序" prop="orderNum"> | ||
| 106 | + <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> | ||
| 107 | + </el-form-item> | ||
| 108 | + </el-col> | ||
| 109 | + <el-col :span="12"> | ||
| 110 | + <el-form-item label="负责人" prop="leader"> | ||
| 111 | + <el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> | ||
| 112 | + </el-form-item> | ||
| 113 | + </el-col> | ||
| 114 | + <el-col :span="12"> | ||
| 115 | + <el-form-item label="联系电话" prop="phone"> | ||
| 116 | + <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" /> | ||
| 117 | + </el-form-item> | ||
| 118 | + </el-col> | ||
| 119 | + <el-col :span="12"> | ||
| 120 | + <el-form-item label="邮箱" prop="email"> | ||
| 121 | + <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> | ||
| 122 | + </el-form-item> | ||
| 123 | + </el-col> | ||
| 124 | + <el-col :span="12"> | ||
| 125 | + <el-form-item label="部门状态"> | ||
| 126 | + <el-radio-group v-model="form.status"> | ||
| 127 | + <el-radio | ||
| 128 | + v-for="dict in statusOptions" | ||
| 129 | + :key="dict.dictValue" | ||
| 130 | + :label="dict.dictValue" | ||
| 131 | + >{{dict.dictLabel}}</el-radio> | ||
| 132 | + </el-radio-group> | ||
| 133 | + </el-form-item> | ||
| 134 | + </el-col> | ||
| 135 | + </el-row> | ||
| 136 | + </el-form> | ||
| 137 | + <div slot="footer" class="dialog-footer"> | ||
| 138 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 139 | + <el-button @click="cancel">取 消</el-button> | ||
| 140 | + </div> | ||
| 141 | + </el-dialog> | ||
| 142 | + </div> | ||
| 143 | +</template> | ||
| 144 | + | ||
| 145 | +<script> | ||
| 146 | +import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; | ||
| 147 | +import Treeselect from "@riophae/vue-treeselect"; | ||
| 148 | +import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||
| 149 | + | ||
| 150 | +export default { | ||
| 151 | + name: "Dept", | ||
| 152 | + components: { Treeselect }, | ||
| 153 | + data() { | ||
| 154 | + return { | ||
| 155 | + // 遮罩层 | ||
| 156 | + loading: true, | ||
| 157 | + // 显示搜索条件 | ||
| 158 | + showSearch: true, | ||
| 159 | + // 表格树数据 | ||
| 160 | + deptList: [], | ||
| 161 | + // 部门树选项 | ||
| 162 | + deptOptions: [], | ||
| 163 | + // 弹出层标题 | ||
| 164 | + title: "", | ||
| 165 | + // 是否显示弹出层 | ||
| 166 | + open: false, | ||
| 167 | + // 状态数据字典 | ||
| 168 | + statusOptions: [], | ||
| 169 | + // 查询参数 | ||
| 170 | + queryParams: { | ||
| 171 | + deptName: undefined, | ||
| 172 | + status: undefined | ||
| 173 | + }, | ||
| 174 | + // 表单参数 | ||
| 175 | + form: {}, | ||
| 176 | + // 表单校验 | ||
| 177 | + rules: { | ||
| 178 | + parentId: [ | ||
| 179 | + { required: true, message: "上级部门不能为空", trigger: "blur" } | ||
| 180 | + ], | ||
| 181 | + deptName: [ | ||
| 182 | + { required: true, message: "部门名称不能为空", trigger: "blur" } | ||
| 183 | + ], | ||
| 184 | + orderNum: [ | ||
| 185 | + { required: true, message: "显示排序不能为空", trigger: "blur" } | ||
| 186 | + ], | ||
| 187 | + email: [ | ||
| 188 | + { | ||
| 189 | + type: "email", | ||
| 190 | + message: "'请输入正确的邮箱地址", | ||
| 191 | + trigger: ["blur", "change"] | ||
| 192 | + } | ||
| 193 | + ], | ||
| 194 | + phone: [ | ||
| 195 | + { | ||
| 196 | + pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, | ||
| 197 | + message: "请输入正确的手机号码", | ||
| 198 | + trigger: "blur" | ||
| 199 | + } | ||
| 200 | + ] | ||
| 201 | + } | ||
| 202 | + }; | ||
| 203 | + }, | ||
| 204 | + created() { | ||
| 205 | + this.getList(); | ||
| 206 | + this.getDicts("sys_normal_disable").then(response => { | ||
| 207 | + this.statusOptions = response.data; | ||
| 208 | + }); | ||
| 209 | + }, | ||
| 210 | + methods: { | ||
| 211 | + /** 查询部门列表 */ | ||
| 212 | + getList() { | ||
| 213 | + this.loading = true; | ||
| 214 | + listDept(this.queryParams).then(response => { | ||
| 215 | + this.deptList = this.handleTree(response.data, "deptId"); | ||
| 216 | + this.loading = false; | ||
| 217 | + }); | ||
| 218 | + }, | ||
| 219 | + /** 转换部门数据结构 */ | ||
| 220 | + normalizer(node) { | ||
| 221 | + if (node.children && !node.children.length) { | ||
| 222 | + delete node.children; | ||
| 223 | + } | ||
| 224 | + return { | ||
| 225 | + id: node.deptId, | ||
| 226 | + label: node.deptName, | ||
| 227 | + children: node.children | ||
| 228 | + }; | ||
| 229 | + }, | ||
| 230 | + // 取消按钮 | ||
| 231 | + cancel() { | ||
| 232 | + this.open = false; | ||
| 233 | + this.reset(); | ||
| 234 | + }, | ||
| 235 | + // 表单重置 | ||
| 236 | + reset() { | ||
| 237 | + this.form = { | ||
| 238 | + deptId: undefined, | ||
| 239 | + parentId: undefined, | ||
| 240 | + deptName: undefined, | ||
| 241 | + orderNum: undefined, | ||
| 242 | + leader: undefined, | ||
| 243 | + phone: undefined, | ||
| 244 | + email: undefined, | ||
| 245 | + status: "0" | ||
| 246 | + }; | ||
| 247 | + this.resetForm("form"); | ||
| 248 | + }, | ||
| 249 | + /** 搜索按钮操作 */ | ||
| 250 | + handleQuery() { | ||
| 251 | + this.getList(); | ||
| 252 | + }, | ||
| 253 | + /** 重置按钮操作 */ | ||
| 254 | + resetQuery() { | ||
| 255 | + this.resetForm("queryForm"); | ||
| 256 | + this.handleQuery(); | ||
| 257 | + }, | ||
| 258 | + /** 新增按钮操作 */ | ||
| 259 | + handleAdd(row) { | ||
| 260 | + this.reset(); | ||
| 261 | + if (row != undefined) { | ||
| 262 | + this.form.parentId = row.deptId; | ||
| 263 | + } | ||
| 264 | + this.open = true; | ||
| 265 | + this.title = "添加部门"; | ||
| 266 | + listDept().then(response => { | ||
| 267 | + this.deptOptions = this.handleTree(response.data, "deptId"); | ||
| 268 | + }); | ||
| 269 | + }, | ||
| 270 | + /** 修改按钮操作 */ | ||
| 271 | + handleUpdate(row) { | ||
| 272 | + this.reset(); | ||
| 273 | + getDept(row.deptId).then(response => { | ||
| 274 | + this.form = response.data; | ||
| 275 | + this.open = true; | ||
| 276 | + this.title = "修改部门"; | ||
| 277 | + }); | ||
| 278 | + listDeptExcludeChild(row.deptId).then(response => { | ||
| 279 | + this.deptOptions = this.handleTree(response.data, "deptId"); | ||
| 280 | + }); | ||
| 281 | + }, | ||
| 282 | + /** 提交按钮 */ | ||
| 283 | + submitForm: function() { | ||
| 284 | + this.$refs["form"].validate(valid => { | ||
| 285 | + if (valid) { | ||
| 286 | + if (this.form.deptId != undefined) { | ||
| 287 | + updateDept(this.form).then(response => { | ||
| 288 | + this.msgSuccess("修改成功"); | ||
| 289 | + this.open = false; | ||
| 290 | + this.getList(); | ||
| 291 | + }); | ||
| 292 | + } else { | ||
| 293 | + addDept(this.form).then(response => { | ||
| 294 | + this.msgSuccess("新增成功"); | ||
| 295 | + this.open = false; | ||
| 296 | + this.getList(); | ||
| 297 | + }); | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + }); | ||
| 301 | + }, | ||
| 302 | + /** 删除按钮操作 */ | ||
| 303 | + handleDelete(row) { | ||
| 304 | + this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", { | ||
| 305 | + confirmButtonText: "确定", | ||
| 306 | + cancelButtonText: "取消", | ||
| 307 | + type: "warning" | ||
| 308 | + }).then(function() { | ||
| 309 | + return delDept(row.deptId); | ||
| 310 | + }).then(() => { | ||
| 311 | + this.getList(); | ||
| 312 | + this.msgSuccess("删除成功"); | ||
| 313 | + }).catch(() => {}); | ||
| 314 | + } | ||
| 315 | + } | ||
| 316 | +}; | ||
| 317 | +</script> |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> | ||
| 4 | - <el-form-item label="菜单名称" prop="menuName"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.menuName" | ||
| 7 | - placeholder="请输入菜单名称" | ||
| 8 | - clearable | ||
| 9 | - size="small" | ||
| 10 | - @keyup.enter.native="handleQuery" | ||
| 11 | - /> | ||
| 12 | - </el-form-item> | ||
| 13 | - <el-form-item label="状态" prop="status"> | ||
| 14 | - <el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small"> | ||
| 15 | - <el-option | ||
| 16 | - v-for="dict in statusOptions" | ||
| 17 | - :key="dict.dictValue" | ||
| 18 | - :label="dict.dictLabel" | ||
| 19 | - :value="dict.dictValue" | ||
| 20 | - /> | ||
| 21 | - </el-select> | ||
| 22 | - </el-form-item> | ||
| 23 | - <el-form-item> | ||
| 24 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 25 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 26 | - </el-form-item> | ||
| 27 | - </el-form> | ||
| 28 | - | ||
| 29 | - <el-row :gutter="10" class="mb8"> | ||
| 30 | - <el-col :span="1.5"> | ||
| 31 | - <el-button | ||
| 32 | - type="primary" | ||
| 33 | - plain | ||
| 34 | - icon="el-icon-plus" | ||
| 35 | - size="mini" | ||
| 36 | - @click="handleAdd" | ||
| 37 | - v-hasPermi="['system:menu:add']" | ||
| 38 | - >新增</el-button> | ||
| 39 | - </el-col> | ||
| 40 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 41 | - </el-row> | ||
| 42 | - | ||
| 43 | - <el-table | ||
| 44 | - v-loading="loading" | ||
| 45 | - :data="menuList" | ||
| 46 | - row-key="menuId" | ||
| 47 | - :tree-props="{children: 'children', hasChildren: 'hasChildren'}" | ||
| 48 | - > | ||
| 49 | - <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column> | ||
| 50 | - <el-table-column prop="icon" label="图标" align="center" width="100"> | ||
| 51 | - <template slot-scope="scope"> | ||
| 52 | - <svg-icon :icon-class="scope.row.icon" /> | ||
| 53 | - </template> | ||
| 54 | - </el-table-column> | ||
| 55 | - <el-table-column prop="orderNum" label="排序" width="60"></el-table-column> | ||
| 56 | - <el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column> | ||
| 57 | - <el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column> | ||
| 58 | - <el-table-column prop="status" label="状态" :formatter="statusFormat" width="80"></el-table-column> | ||
| 59 | - <el-table-column label="创建时间" align="center" prop="createTime"> | ||
| 60 | - <template slot-scope="scope"> | ||
| 61 | - <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 62 | - </template> | ||
| 63 | - </el-table-column> | ||
| 64 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 65 | - <template slot-scope="scope"> | ||
| 66 | - <el-button size="mini" | ||
| 67 | - type="text" | ||
| 68 | - icon="el-icon-edit" | ||
| 69 | - @click="handleUpdate(scope.row)" | ||
| 70 | - v-hasPermi="['system:menu:edit']" | ||
| 71 | - >修改</el-button> | ||
| 72 | - <el-button | ||
| 73 | - size="mini" | ||
| 74 | - type="text" | ||
| 75 | - icon="el-icon-plus" | ||
| 76 | - @click="handleAdd(scope.row)" | ||
| 77 | - v-hasPermi="['system:menu:add']" | ||
| 78 | - >新增</el-button> | ||
| 79 | - <el-button | ||
| 80 | - size="mini" | ||
| 81 | - type="text" | ||
| 82 | - icon="el-icon-delete" | ||
| 83 | - @click="handleDelete(scope.row)" | ||
| 84 | - v-hasPermi="['system:menu:remove']" | ||
| 85 | - >删除</el-button> | ||
| 86 | - </template> | ||
| 87 | - </el-table-column> | ||
| 88 | - </el-table> | ||
| 89 | - | ||
| 90 | - <!-- 添加或修改菜单对话框 --> | ||
| 91 | - <el-dialog :title="title" :visible.sync="open" width="680px" append-to-body> | ||
| 92 | - <el-form ref="form" :model="form" :rules="rules" label-width="100px"> | ||
| 93 | - <el-row> | ||
| 94 | - <el-col :span="24"> | ||
| 95 | - <el-form-item label="上级菜单"> | ||
| 96 | - <treeselect | ||
| 97 | - v-model="form.parentId" | ||
| 98 | - :options="menuOptions" | ||
| 99 | - :normalizer="normalizer" | ||
| 100 | - :show-count="true" | ||
| 101 | - placeholder="选择上级菜单" | ||
| 102 | - /> | ||
| 103 | - </el-form-item> | ||
| 104 | - </el-col> | ||
| 105 | - <el-col :span="24"> | ||
| 106 | - <el-form-item label="菜单类型" prop="menuType"> | ||
| 107 | - <el-radio-group v-model="form.menuType"> | ||
| 108 | - <el-radio label="M">目录</el-radio> | ||
| 109 | - <el-radio label="C">菜单</el-radio> | ||
| 110 | - <el-radio label="F">按钮</el-radio> | ||
| 111 | - </el-radio-group> | ||
| 112 | - </el-form-item> | ||
| 113 | - </el-col> | ||
| 114 | - <el-col :span="24"> | ||
| 115 | - <el-form-item v-if="form.menuType != 'F'" label="菜单图标"> | ||
| 116 | - <el-popover | ||
| 117 | - placement="bottom-start" | ||
| 118 | - width="460" | ||
| 119 | - trigger="click" | ||
| 120 | - @show="$refs['iconSelect'].reset()" | ||
| 121 | - > | ||
| 122 | - <IconSelect ref="iconSelect" @selected="selected" /> | ||
| 123 | - <el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly> | ||
| 124 | - <svg-icon | ||
| 125 | - v-if="form.icon" | ||
| 126 | - slot="prefix" | ||
| 127 | - :icon-class="form.icon" | ||
| 128 | - class="el-input__icon" | ||
| 129 | - style="height: 32px;width: 16px;" | ||
| 130 | - /> | ||
| 131 | - <i v-else slot="prefix" class="el-icon-search el-input__icon" /> | ||
| 132 | - </el-input> | ||
| 133 | - </el-popover> | ||
| 134 | - </el-form-item> | ||
| 135 | - </el-col> | ||
| 136 | - <el-col :span="12"> | ||
| 137 | - <el-form-item label="菜单名称" prop="menuName"> | ||
| 138 | - <el-input v-model="form.menuName" placeholder="请输入菜单名称" /> | ||
| 139 | - </el-form-item> | ||
| 140 | - </el-col> | ||
| 141 | - <el-col :span="12"> | ||
| 142 | - <el-form-item label="显示排序" prop="orderNum"> | ||
| 143 | - <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> | ||
| 144 | - </el-form-item> | ||
| 145 | - </el-col> | ||
| 146 | - <el-col :span="12"> | ||
| 147 | - <el-form-item v-if="form.menuType != 'F'"> | ||
| 148 | - <span slot="label"> | ||
| 149 | - <el-tooltip content="选择是外链则路由地址需要以`http(s)://`开头" placement="top"> | ||
| 150 | - <i class="el-icon-question"></i> | ||
| 151 | - </el-tooltip> | ||
| 152 | - 是否外链 | ||
| 153 | - </span> | ||
| 154 | - <el-radio-group v-model="form.isFrame"> | ||
| 155 | - <el-radio label="0">是</el-radio> | ||
| 156 | - <el-radio label="1">否</el-radio> | ||
| 157 | - </el-radio-group> | ||
| 158 | - </el-form-item> | ||
| 159 | - </el-col> | ||
| 160 | - <el-col :span="12"> | ||
| 161 | - <el-form-item v-if="form.menuType != 'F'" prop="path"> | ||
| 162 | - <span slot="label"> | ||
| 163 | - <el-tooltip content="访问的路由地址,如:`user`,如外网地址需内链访问则以`http(s)://`开头" placement="top"> | ||
| 164 | - <i class="el-icon-question"></i> | ||
| 165 | - </el-tooltip> | ||
| 166 | - 路由地址 | ||
| 167 | - </span> | ||
| 168 | - <el-input v-model="form.path" placeholder="请输入路由地址" /> | ||
| 169 | - </el-form-item> | ||
| 170 | - </el-col> | ||
| 171 | - <el-col :span="12" v-if="form.menuType == 'C'"> | ||
| 172 | - <el-form-item prop="component"> | ||
| 173 | - <span slot="label"> | ||
| 174 | - <el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top"> | ||
| 175 | - <i class="el-icon-question"></i> | ||
| 176 | - </el-tooltip> | ||
| 177 | - 组件路径 | ||
| 178 | - </span> | ||
| 179 | - <el-input v-model="form.component" placeholder="请输入组件路径" /> | ||
| 180 | - </el-form-item> | ||
| 181 | - </el-col> | ||
| 182 | - <el-col :span="12"> | ||
| 183 | - <el-form-item v-if="form.menuType != 'M'"> | ||
| 184 | - <el-input v-model="form.perms" placeholder="请输入权限标识" maxlength="100" /> | ||
| 185 | - <span slot="label"> | ||
| 186 | - <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top"> | ||
| 187 | - <i class="el-icon-question"></i> | ||
| 188 | - </el-tooltip> | ||
| 189 | - 权限字符 | ||
| 190 | - </span> | ||
| 191 | - </el-form-item> | ||
| 192 | - </el-col> | ||
| 193 | - <el-col :span="12"> | ||
| 194 | - <el-form-item v-if="form.menuType != 'F'"> | ||
| 195 | - <span slot="label"> | ||
| 196 | - <el-tooltip content="选择隐藏则路由将不会出现在侧边栏,但仍然可以访问" placement="top"> | ||
| 197 | - <i class="el-icon-question"></i> | ||
| 198 | - </el-tooltip> | ||
| 199 | - 显示状态 | ||
| 200 | - </span> | ||
| 201 | - <el-radio-group v-model="form.visible"> | ||
| 202 | - <el-radio | ||
| 203 | - v-for="dict in visibleOptions" | ||
| 204 | - :key="dict.dictValue" | ||
| 205 | - :label="dict.dictValue" | ||
| 206 | - >{{dict.dictLabel}}</el-radio> | ||
| 207 | - </el-radio-group> | ||
| 208 | - </el-form-item> | ||
| 209 | - </el-col> | ||
| 210 | - <el-col :span="12"> | ||
| 211 | - <el-form-item v-if="form.menuType != 'F'"> | ||
| 212 | - <span slot="label"> | ||
| 213 | - <el-tooltip content="选择停用则路由将不会出现在侧边栏,也不能被访问" placement="top"> | ||
| 214 | - <i class="el-icon-question"></i> | ||
| 215 | - </el-tooltip> | ||
| 216 | - 菜单状态 | ||
| 217 | - </span> | ||
| 218 | - <el-radio-group v-model="form.status"> | ||
| 219 | - <el-radio | ||
| 220 | - v-for="dict in statusOptions" | ||
| 221 | - :key="dict.dictValue" | ||
| 222 | - :label="dict.dictValue" | ||
| 223 | - >{{dict.dictLabel}}</el-radio> | ||
| 224 | - </el-radio-group> | ||
| 225 | - </el-form-item> | ||
| 226 | - </el-col> | ||
| 227 | - <el-col :span="12"> | ||
| 228 | - <el-form-item v-if="form.menuType == 'C'"> | ||
| 229 | - <span slot="label"> | ||
| 230 | - <el-tooltip content="选择是则会被`keep-alive`缓存,需要匹配组件的`name`和地址保持一致" placement="top"> | ||
| 231 | - <i class="el-icon-question"></i> | ||
| 232 | - </el-tooltip> | ||
| 233 | - 是否缓存 | ||
| 234 | - </span> | ||
| 235 | - <el-radio-group v-model="form.isCache"> | ||
| 236 | - <el-radio label="0">缓存</el-radio> | ||
| 237 | - <el-radio label="1">不缓存</el-radio> | ||
| 238 | - </el-radio-group> | ||
| 239 | - </el-form-item> | ||
| 240 | - </el-col> | ||
| 241 | - </el-row> | ||
| 242 | - </el-form> | ||
| 243 | - <div slot="footer" class="dialog-footer"> | ||
| 244 | - <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 245 | - <el-button @click="cancel">取 消</el-button> | ||
| 246 | - </div> | ||
| 247 | - </el-dialog> | ||
| 248 | - </div> | ||
| 249 | -</template> | ||
| 250 | - | ||
| 251 | -<script> | ||
| 252 | -import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu"; | ||
| 253 | -import Treeselect from "@riophae/vue-treeselect"; | ||
| 254 | -import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||
| 255 | -import IconSelect from "@/components/IconSelect"; | ||
| 256 | - | ||
| 257 | -export default { | ||
| 258 | - name: "Menu", | ||
| 259 | - components: { Treeselect, IconSelect }, | ||
| 260 | - data() { | ||
| 261 | - return { | ||
| 262 | - // 遮罩层 | ||
| 263 | - loading: true, | ||
| 264 | - // 显示搜索条件 | ||
| 265 | - showSearch: true, | ||
| 266 | - // 菜单表格树数据 | ||
| 267 | - menuList: [], | ||
| 268 | - // 菜单树选项 | ||
| 269 | - menuOptions: [], | ||
| 270 | - // 弹出层标题 | ||
| 271 | - title: "", | ||
| 272 | - // 是否显示弹出层 | ||
| 273 | - open: false, | ||
| 274 | - // 显示状态数据字典 | ||
| 275 | - visibleOptions: [], | ||
| 276 | - // 菜单状态数据字典 | ||
| 277 | - statusOptions: [], | ||
| 278 | - // 查询参数 | ||
| 279 | - queryParams: { | ||
| 280 | - menuName: undefined, | ||
| 281 | - visible: undefined | ||
| 282 | - }, | ||
| 283 | - // 表单参数 | ||
| 284 | - form: {}, | ||
| 285 | - // 表单校验 | ||
| 286 | - rules: { | ||
| 287 | - menuName: [ | ||
| 288 | - { required: true, message: "菜单名称不能为空", trigger: "blur" } | ||
| 289 | - ], | ||
| 290 | - orderNum: [ | ||
| 291 | - { required: true, message: "菜单顺序不能为空", trigger: "blur" } | ||
| 292 | - ], | ||
| 293 | - path: [ | ||
| 294 | - { required: true, message: "路由地址不能为空", trigger: "blur" } | ||
| 295 | - ] | ||
| 296 | - } | ||
| 297 | - }; | ||
| 298 | - }, | ||
| 299 | - created() { | ||
| 300 | - this.getList(); | ||
| 301 | - this.getDicts("sys_show_hide").then(response => { | ||
| 302 | - this.visibleOptions = response.data; | ||
| 303 | - }); | ||
| 304 | - this.getDicts("sys_normal_disable").then(response => { | ||
| 305 | - this.statusOptions = response.data; | ||
| 306 | - }); | ||
| 307 | - }, | ||
| 308 | - methods: { | ||
| 309 | - // 选择图标 | ||
| 310 | - selected(name) { | ||
| 311 | - this.form.icon = name; | ||
| 312 | - }, | ||
| 313 | - /** 查询菜单列表 */ | ||
| 314 | - getList() { | ||
| 315 | - this.loading = true; | ||
| 316 | - listMenu(this.queryParams).then(response => { | ||
| 317 | - this.menuList = this.handleTree(response.data, "menuId"); | ||
| 318 | - this.loading = false; | ||
| 319 | - }); | ||
| 320 | - }, | ||
| 321 | - /** 转换菜单数据结构 */ | ||
| 322 | - normalizer(node) { | ||
| 323 | - if (node.children && !node.children.length) { | ||
| 324 | - delete node.children; | ||
| 325 | - } | ||
| 326 | - return { | ||
| 327 | - id: node.menuId, | ||
| 328 | - label: node.menuName, | ||
| 329 | - children: node.children | ||
| 330 | - }; | ||
| 331 | - }, | ||
| 332 | - /** 查询菜单下拉树结构 */ | ||
| 333 | - getTreeselect() { | ||
| 334 | - listMenu().then(response => { | ||
| 335 | - this.menuOptions = []; | ||
| 336 | - const menu = { menuId: 0, menuName: '主类目', children: [] }; | ||
| 337 | - menu.children = this.handleTree(response.data, "menuId"); | ||
| 338 | - this.menuOptions.push(menu); | ||
| 339 | - }); | ||
| 340 | - }, | ||
| 341 | - // 显示状态字典翻译 | ||
| 342 | - visibleFormat(row, column) { | ||
| 343 | - if (row.menuType == "F") { | ||
| 344 | - return ""; | ||
| 345 | - } | ||
| 346 | - return this.selectDictLabel(this.visibleOptions, row.visible); | ||
| 347 | - }, | ||
| 348 | - // 菜单状态字典翻译 | ||
| 349 | - statusFormat(row, column) { | ||
| 350 | - if (row.menuType == "F") { | ||
| 351 | - return ""; | ||
| 352 | - } | ||
| 353 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 354 | - }, | ||
| 355 | - // 取消按钮 | ||
| 356 | - cancel() { | ||
| 357 | - this.open = false; | ||
| 358 | - this.reset(); | ||
| 359 | - }, | ||
| 360 | - // 表单重置 | ||
| 361 | - reset() { | ||
| 362 | - this.form = { | ||
| 363 | - menuId: undefined, | ||
| 364 | - parentId: 0, | ||
| 365 | - menuName: undefined, | ||
| 366 | - icon: undefined, | ||
| 367 | - menuType: "M", | ||
| 368 | - orderNum: undefined, | ||
| 369 | - isFrame: "1", | ||
| 370 | - isCache: "0", | ||
| 371 | - visible: "0", | ||
| 372 | - status: "0" | ||
| 373 | - }; | ||
| 374 | - this.resetForm("form"); | ||
| 375 | - }, | ||
| 376 | - /** 搜索按钮操作 */ | ||
| 377 | - handleQuery() { | ||
| 378 | - this.getList(); | ||
| 379 | - }, | ||
| 380 | - /** 重置按钮操作 */ | ||
| 381 | - resetQuery() { | ||
| 382 | - this.resetForm("queryForm"); | ||
| 383 | - this.handleQuery(); | ||
| 384 | - }, | ||
| 385 | - /** 新增按钮操作 */ | ||
| 386 | - handleAdd(row) { | ||
| 387 | - this.reset(); | ||
| 388 | - this.getTreeselect(); | ||
| 389 | - if (row != null && row.menuId) { | ||
| 390 | - this.form.parentId = row.menuId; | ||
| 391 | - } else { | ||
| 392 | - this.form.parentId = 0; | ||
| 393 | - } | ||
| 394 | - this.open = true; | ||
| 395 | - this.title = "添加菜单"; | ||
| 396 | - }, | ||
| 397 | - /** 修改按钮操作 */ | ||
| 398 | - handleUpdate(row) { | ||
| 399 | - this.reset(); | ||
| 400 | - this.getTreeselect(); | ||
| 401 | - getMenu(row.menuId).then(response => { | ||
| 402 | - this.form = response.data; | ||
| 403 | - this.open = true; | ||
| 404 | - this.title = "修改菜单"; | ||
| 405 | - }); | ||
| 406 | - }, | ||
| 407 | - /** 提交按钮 */ | ||
| 408 | - submitForm: function() { | ||
| 409 | - this.$refs["form"].validate(valid => { | ||
| 410 | - if (valid) { | ||
| 411 | - if (this.form.menuId != undefined) { | ||
| 412 | - updateMenu(this.form).then(response => { | ||
| 413 | - this.msgSuccess("修改成功"); | ||
| 414 | - this.open = false; | ||
| 415 | - this.getList(); | ||
| 416 | - }); | ||
| 417 | - } else { | ||
| 418 | - addMenu(this.form).then(response => { | ||
| 419 | - this.msgSuccess("新增成功"); | ||
| 420 | - this.open = false; | ||
| 421 | - this.getList(); | ||
| 422 | - }); | ||
| 423 | - } | ||
| 424 | - } | ||
| 425 | - }); | ||
| 426 | - }, | ||
| 427 | - /** 删除按钮操作 */ | ||
| 428 | - handleDelete(row) { | ||
| 429 | - this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', "警告", { | ||
| 430 | - confirmButtonText: "确定", | ||
| 431 | - cancelButtonText: "取消", | ||
| 432 | - type: "warning" | ||
| 433 | - }).then(function() { | ||
| 434 | - return delMenu(row.menuId); | ||
| 435 | - }).then(() => { | ||
| 436 | - this.getList(); | ||
| 437 | - this.msgSuccess("删除成功"); | ||
| 438 | - }).catch(() => {}); | ||
| 439 | - } | ||
| 440 | - } | ||
| 441 | -}; | ||
| 442 | -</script> | ||
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> | ||
| 4 | + <el-form-item label="菜单名称" prop="menuName"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.menuName" | ||
| 7 | + placeholder="请输入菜单名称" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + @keyup.enter.native="handleQuery" | ||
| 11 | + /> | ||
| 12 | + </el-form-item> | ||
| 13 | + <el-form-item label="状态" prop="status"> | ||
| 14 | + <el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small"> | ||
| 15 | + <el-option | ||
| 16 | + v-for="dict in statusOptions" | ||
| 17 | + :key="dict.dictValue" | ||
| 18 | + :label="dict.dictLabel" | ||
| 19 | + :value="dict.dictValue" | ||
| 20 | + /> | ||
| 21 | + </el-select> | ||
| 22 | + </el-form-item> | ||
| 23 | + <el-form-item> | ||
| 24 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 25 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 26 | + </el-form-item> | ||
| 27 | + </el-form> | ||
| 28 | + | ||
| 29 | + <el-row :gutter="10" class="mb8"> | ||
| 30 | + <el-col :span="1.5"> | ||
| 31 | + <el-button | ||
| 32 | + type="primary" | ||
| 33 | + plain | ||
| 34 | + icon="el-icon-plus" | ||
| 35 | + size="mini" | ||
| 36 | + @click="handleAdd" | ||
| 37 | + v-hasPermi="['system:menu:add']" | ||
| 38 | + >新增</el-button> | ||
| 39 | + </el-col> | ||
| 40 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 41 | + </el-row> | ||
| 42 | + | ||
| 43 | + <el-table | ||
| 44 | + v-loading="loading" | ||
| 45 | + :data="menuList" | ||
| 46 | + row-key="menuId" | ||
| 47 | + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" | ||
| 48 | + > | ||
| 49 | + <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column> | ||
| 50 | + <el-table-column prop="icon" label="图标" align="center" width="100"> | ||
| 51 | + <template slot-scope="scope"> | ||
| 52 | + <svg-icon :icon-class="scope.row.icon" /> | ||
| 53 | + </template> | ||
| 54 | + </el-table-column> | ||
| 55 | + <el-table-column prop="orderNum" label="排序" width="60"></el-table-column> | ||
| 56 | + <el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column> | ||
| 57 | + <el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column> | ||
| 58 | + <el-table-column prop="status" label="状态" width="80"> | ||
| 59 | + <template slot-scope="scope"> | ||
| 60 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 61 | + </template> | ||
| 62 | + </el-table-column> | ||
| 63 | + <el-table-column label="创建时间" align="center" prop="createTime"> | ||
| 64 | + <template slot-scope="scope"> | ||
| 65 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 66 | + </template> | ||
| 67 | + </el-table-column> | ||
| 68 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 69 | + <template slot-scope="scope"> | ||
| 70 | + <el-button size="mini" | ||
| 71 | + type="text" | ||
| 72 | + icon="el-icon-edit" | ||
| 73 | + @click="handleUpdate(scope.row)" | ||
| 74 | + v-hasPermi="['system:menu:edit']" | ||
| 75 | + >修改</el-button> | ||
| 76 | + <el-button | ||
| 77 | + size="mini" | ||
| 78 | + type="text" | ||
| 79 | + icon="el-icon-plus" | ||
| 80 | + @click="handleAdd(scope.row)" | ||
| 81 | + v-hasPermi="['system:menu:add']" | ||
| 82 | + >新增</el-button> | ||
| 83 | + <el-button | ||
| 84 | + size="mini" | ||
| 85 | + type="text" | ||
| 86 | + icon="el-icon-delete" | ||
| 87 | + @click="handleDelete(scope.row)" | ||
| 88 | + v-hasPermi="['system:menu:remove']" | ||
| 89 | + >删除</el-button> | ||
| 90 | + </template> | ||
| 91 | + </el-table-column> | ||
| 92 | + </el-table> | ||
| 93 | + | ||
| 94 | + <!-- 添加或修改菜单对话框 --> | ||
| 95 | + <el-dialog :title="title" :visible.sync="open" width="680px" append-to-body> | ||
| 96 | + <el-form ref="form" :model="form" :rules="rules" label-width="100px"> | ||
| 97 | + <el-row> | ||
| 98 | + <el-col :span="24"> | ||
| 99 | + <el-form-item label="上级菜单"> | ||
| 100 | + <treeselect | ||
| 101 | + v-model="form.parentId" | ||
| 102 | + :options="menuOptions" | ||
| 103 | + :normalizer="normalizer" | ||
| 104 | + :show-count="true" | ||
| 105 | + placeholder="选择上级菜单" | ||
| 106 | + /> | ||
| 107 | + </el-form-item> | ||
| 108 | + </el-col> | ||
| 109 | + <el-col :span="24"> | ||
| 110 | + <el-form-item label="菜单类型" prop="menuType"> | ||
| 111 | + <el-radio-group v-model="form.menuType"> | ||
| 112 | + <el-radio label="M">目录</el-radio> | ||
| 113 | + <el-radio label="C">菜单</el-radio> | ||
| 114 | + <el-radio label="F">按钮</el-radio> | ||
| 115 | + </el-radio-group> | ||
| 116 | + </el-form-item> | ||
| 117 | + </el-col> | ||
| 118 | + <el-col :span="24"> | ||
| 119 | + <el-form-item v-if="form.menuType != 'F'" label="菜单图标"> | ||
| 120 | + <el-popover | ||
| 121 | + placement="bottom-start" | ||
| 122 | + width="460" | ||
| 123 | + trigger="click" | ||
| 124 | + @show="$refs['iconSelect'].reset()" | ||
| 125 | + > | ||
| 126 | + <IconSelect ref="iconSelect" @selected="selected" /> | ||
| 127 | + <el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly> | ||
| 128 | + <svg-icon | ||
| 129 | + v-if="form.icon" | ||
| 130 | + slot="prefix" | ||
| 131 | + :icon-class="form.icon" | ||
| 132 | + class="el-input__icon" | ||
| 133 | + style="height: 32px;width: 16px;" | ||
| 134 | + /> | ||
| 135 | + <i v-else slot="prefix" class="el-icon-search el-input__icon" /> | ||
| 136 | + </el-input> | ||
| 137 | + </el-popover> | ||
| 138 | + </el-form-item> | ||
| 139 | + </el-col> | ||
| 140 | + <el-col :span="12"> | ||
| 141 | + <el-form-item label="菜单名称" prop="menuName"> | ||
| 142 | + <el-input v-model="form.menuName" placeholder="请输入菜单名称" /> | ||
| 143 | + </el-form-item> | ||
| 144 | + </el-col> | ||
| 145 | + <el-col :span="12"> | ||
| 146 | + <el-form-item label="显示排序" prop="orderNum"> | ||
| 147 | + <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> | ||
| 148 | + </el-form-item> | ||
| 149 | + </el-col> | ||
| 150 | + <el-col :span="12"> | ||
| 151 | + <el-form-item v-if="form.menuType != 'F'"> | ||
| 152 | + <span slot="label"> | ||
| 153 | + <el-tooltip content="选择是外链则路由地址需要以`http(s)://`开头" placement="top"> | ||
| 154 | + <i class="el-icon-question"></i> | ||
| 155 | + </el-tooltip> | ||
| 156 | + 是否外链 | ||
| 157 | + </span> | ||
| 158 | + <el-radio-group v-model="form.isFrame"> | ||
| 159 | + <el-radio label="0">是</el-radio> | ||
| 160 | + <el-radio label="1">否</el-radio> | ||
| 161 | + </el-radio-group> | ||
| 162 | + </el-form-item> | ||
| 163 | + </el-col> | ||
| 164 | + <el-col :span="12"> | ||
| 165 | + <el-form-item v-if="form.menuType != 'F'" prop="path"> | ||
| 166 | + <span slot="label"> | ||
| 167 | + <el-tooltip content="访问的路由地址,如:`user`,如外网地址需内链访问则以`http(s)://`开头" placement="top"> | ||
| 168 | + <i class="el-icon-question"></i> | ||
| 169 | + </el-tooltip> | ||
| 170 | + 路由地址 | ||
| 171 | + </span> | ||
| 172 | + <el-input v-model="form.path" placeholder="请输入路由地址" /> | ||
| 173 | + </el-form-item> | ||
| 174 | + </el-col> | ||
| 175 | + <el-col :span="12" v-if="form.menuType == 'C'"> | ||
| 176 | + <el-form-item prop="component"> | ||
| 177 | + <span slot="label"> | ||
| 178 | + <el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top"> | ||
| 179 | + <i class="el-icon-question"></i> | ||
| 180 | + </el-tooltip> | ||
| 181 | + 组件路径 | ||
| 182 | + </span> | ||
| 183 | + <el-input v-model="form.component" placeholder="请输入组件路径" /> | ||
| 184 | + </el-form-item> | ||
| 185 | + </el-col> | ||
| 186 | + <el-col :span="12"> | ||
| 187 | + <el-form-item v-if="form.menuType != 'M'"> | ||
| 188 | + <el-input v-model="form.perms" placeholder="请输入权限标识" maxlength="100" /> | ||
| 189 | + <span slot="label"> | ||
| 190 | + <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top"> | ||
| 191 | + <i class="el-icon-question"></i> | ||
| 192 | + </el-tooltip> | ||
| 193 | + 权限字符 | ||
| 194 | + </span> | ||
| 195 | + </el-form-item> | ||
| 196 | + </el-col> | ||
| 197 | + <el-col :span="12"> | ||
| 198 | + <el-form-item v-if="form.menuType != 'F'"> | ||
| 199 | + <span slot="label"> | ||
| 200 | + <el-tooltip content="选择隐藏则路由将不会出现在侧边栏,但仍然可以访问" placement="top"> | ||
| 201 | + <i class="el-icon-question"></i> | ||
| 202 | + </el-tooltip> | ||
| 203 | + 显示状态 | ||
| 204 | + </span> | ||
| 205 | + <el-radio-group v-model="form.visible"> | ||
| 206 | + <el-radio | ||
| 207 | + v-for="dict in visibleOptions" | ||
| 208 | + :key="dict.dictValue" | ||
| 209 | + :label="dict.dictValue" | ||
| 210 | + >{{dict.dictLabel}}</el-radio> | ||
| 211 | + </el-radio-group> | ||
| 212 | + </el-form-item> | ||
| 213 | + </el-col> | ||
| 214 | + <el-col :span="12"> | ||
| 215 | + <el-form-item v-if="form.menuType != 'F'"> | ||
| 216 | + <span slot="label"> | ||
| 217 | + <el-tooltip content="选择停用则路由将不会出现在侧边栏,也不能被访问" placement="top"> | ||
| 218 | + <i class="el-icon-question"></i> | ||
| 219 | + </el-tooltip> | ||
| 220 | + 菜单状态 | ||
| 221 | + </span> | ||
| 222 | + <el-radio-group v-model="form.status"> | ||
| 223 | + <el-radio | ||
| 224 | + v-for="dict in statusOptions" | ||
| 225 | + :key="dict.dictValue" | ||
| 226 | + :label="dict.dictValue" | ||
| 227 | + >{{dict.dictLabel}}</el-radio> | ||
| 228 | + </el-radio-group> | ||
| 229 | + </el-form-item> | ||
| 230 | + </el-col> | ||
| 231 | + <el-col :span="12"> | ||
| 232 | + <el-form-item v-if="form.menuType == 'C'"> | ||
| 233 | + <span slot="label"> | ||
| 234 | + <el-tooltip content="选择是则会被`keep-alive`缓存,需要匹配组件的`name`和地址保持一致" placement="top"> | ||
| 235 | + <i class="el-icon-question"></i> | ||
| 236 | + </el-tooltip> | ||
| 237 | + 是否缓存 | ||
| 238 | + </span> | ||
| 239 | + <el-radio-group v-model="form.isCache"> | ||
| 240 | + <el-radio label="0">缓存</el-radio> | ||
| 241 | + <el-radio label="1">不缓存</el-radio> | ||
| 242 | + </el-radio-group> | ||
| 243 | + </el-form-item> | ||
| 244 | + </el-col> | ||
| 245 | + </el-row> | ||
| 246 | + </el-form> | ||
| 247 | + <div slot="footer" class="dialog-footer"> | ||
| 248 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 249 | + <el-button @click="cancel">取 消</el-button> | ||
| 250 | + </div> | ||
| 251 | + </el-dialog> | ||
| 252 | + </div> | ||
| 253 | +</template> | ||
| 254 | + | ||
| 255 | +<script> | ||
| 256 | +import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu"; | ||
| 257 | +import Treeselect from "@riophae/vue-treeselect"; | ||
| 258 | +import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||
| 259 | +import IconSelect from "@/components/IconSelect"; | ||
| 260 | + | ||
| 261 | +export default { | ||
| 262 | + name: "Menu", | ||
| 263 | + components: { Treeselect, IconSelect }, | ||
| 264 | + data() { | ||
| 265 | + return { | ||
| 266 | + // 遮罩层 | ||
| 267 | + loading: true, | ||
| 268 | + // 显示搜索条件 | ||
| 269 | + showSearch: true, | ||
| 270 | + // 菜单表格树数据 | ||
| 271 | + menuList: [], | ||
| 272 | + // 菜单树选项 | ||
| 273 | + menuOptions: [], | ||
| 274 | + // 弹出层标题 | ||
| 275 | + title: "", | ||
| 276 | + // 是否显示弹出层 | ||
| 277 | + open: false, | ||
| 278 | + // 显示状态数据字典 | ||
| 279 | + visibleOptions: [], | ||
| 280 | + // 菜单状态数据字典 | ||
| 281 | + statusOptions: [], | ||
| 282 | + // 查询参数 | ||
| 283 | + queryParams: { | ||
| 284 | + menuName: undefined, | ||
| 285 | + visible: undefined | ||
| 286 | + }, | ||
| 287 | + // 表单参数 | ||
| 288 | + form: {}, | ||
| 289 | + // 表单校验 | ||
| 290 | + rules: { | ||
| 291 | + menuName: [ | ||
| 292 | + { required: true, message: "菜单名称不能为空", trigger: "blur" } | ||
| 293 | + ], | ||
| 294 | + orderNum: [ | ||
| 295 | + { required: true, message: "菜单顺序不能为空", trigger: "blur" } | ||
| 296 | + ], | ||
| 297 | + path: [ | ||
| 298 | + { required: true, message: "路由地址不能为空", trigger: "blur" } | ||
| 299 | + ] | ||
| 300 | + } | ||
| 301 | + }; | ||
| 302 | + }, | ||
| 303 | + created() { | ||
| 304 | + this.getList(); | ||
| 305 | + this.getDicts("sys_show_hide").then(response => { | ||
| 306 | + this.visibleOptions = response.data; | ||
| 307 | + }); | ||
| 308 | + this.getDicts("sys_normal_disable").then(response => { | ||
| 309 | + this.statusOptions = response.data; | ||
| 310 | + }); | ||
| 311 | + }, | ||
| 312 | + methods: { | ||
| 313 | + // 选择图标 | ||
| 314 | + selected(name) { | ||
| 315 | + this.form.icon = name; | ||
| 316 | + }, | ||
| 317 | + /** 查询菜单列表 */ | ||
| 318 | + getList() { | ||
| 319 | + this.loading = true; | ||
| 320 | + listMenu(this.queryParams).then(response => { | ||
| 321 | + this.menuList = this.handleTree(response.data, "menuId"); | ||
| 322 | + this.loading = false; | ||
| 323 | + }); | ||
| 324 | + }, | ||
| 325 | + /** 转换菜单数据结构 */ | ||
| 326 | + normalizer(node) { | ||
| 327 | + if (node.children && !node.children.length) { | ||
| 328 | + delete node.children; | ||
| 329 | + } | ||
| 330 | + return { | ||
| 331 | + id: node.menuId, | ||
| 332 | + label: node.menuName, | ||
| 333 | + children: node.children | ||
| 334 | + }; | ||
| 335 | + }, | ||
| 336 | + /** 查询菜单下拉树结构 */ | ||
| 337 | + getTreeselect() { | ||
| 338 | + listMenu().then(response => { | ||
| 339 | + this.menuOptions = []; | ||
| 340 | + const menu = { menuId: 0, menuName: '主类目', children: [] }; | ||
| 341 | + menu.children = this.handleTree(response.data, "menuId"); | ||
| 342 | + this.menuOptions.push(menu); | ||
| 343 | + }); | ||
| 344 | + }, | ||
| 345 | + // 取消按钮 | ||
| 346 | + cancel() { | ||
| 347 | + this.open = false; | ||
| 348 | + this.reset(); | ||
| 349 | + }, | ||
| 350 | + // 表单重置 | ||
| 351 | + reset() { | ||
| 352 | + this.form = { | ||
| 353 | + menuId: undefined, | ||
| 354 | + parentId: 0, | ||
| 355 | + menuName: undefined, | ||
| 356 | + icon: undefined, | ||
| 357 | + menuType: "M", | ||
| 358 | + orderNum: undefined, | ||
| 359 | + isFrame: "1", | ||
| 360 | + isCache: "0", | ||
| 361 | + visible: "0", | ||
| 362 | + status: "0" | ||
| 363 | + }; | ||
| 364 | + this.resetForm("form"); | ||
| 365 | + }, | ||
| 366 | + /** 搜索按钮操作 */ | ||
| 367 | + handleQuery() { | ||
| 368 | + this.getList(); | ||
| 369 | + }, | ||
| 370 | + /** 重置按钮操作 */ | ||
| 371 | + resetQuery() { | ||
| 372 | + this.resetForm("queryForm"); | ||
| 373 | + this.handleQuery(); | ||
| 374 | + }, | ||
| 375 | + /** 新增按钮操作 */ | ||
| 376 | + handleAdd(row) { | ||
| 377 | + this.reset(); | ||
| 378 | + this.getTreeselect(); | ||
| 379 | + if (row != null && row.menuId) { | ||
| 380 | + this.form.parentId = row.menuId; | ||
| 381 | + } else { | ||
| 382 | + this.form.parentId = 0; | ||
| 383 | + } | ||
| 384 | + this.open = true; | ||
| 385 | + this.title = "添加菜单"; | ||
| 386 | + }, | ||
| 387 | + /** 修改按钮操作 */ | ||
| 388 | + handleUpdate(row) { | ||
| 389 | + this.reset(); | ||
| 390 | + this.getTreeselect(); | ||
| 391 | + getMenu(row.menuId).then(response => { | ||
| 392 | + this.form = response.data; | ||
| 393 | + this.open = true; | ||
| 394 | + this.title = "修改菜单"; | ||
| 395 | + }); | ||
| 396 | + }, | ||
| 397 | + /** 提交按钮 */ | ||
| 398 | + submitForm: function() { | ||
| 399 | + this.$refs["form"].validate(valid => { | ||
| 400 | + if (valid) { | ||
| 401 | + if (this.form.menuId != undefined) { | ||
| 402 | + updateMenu(this.form).then(response => { | ||
| 403 | + this.msgSuccess("修改成功"); | ||
| 404 | + this.open = false; | ||
| 405 | + this.getList(); | ||
| 406 | + }); | ||
| 407 | + } else { | ||
| 408 | + addMenu(this.form).then(response => { | ||
| 409 | + this.msgSuccess("新增成功"); | ||
| 410 | + this.open = false; | ||
| 411 | + this.getList(); | ||
| 412 | + }); | ||
| 413 | + } | ||
| 414 | + } | ||
| 415 | + }); | ||
| 416 | + }, | ||
| 417 | + /** 删除按钮操作 */ | ||
| 418 | + handleDelete(row) { | ||
| 419 | + this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', "警告", { | ||
| 420 | + confirmButtonText: "确定", | ||
| 421 | + cancelButtonText: "取消", | ||
| 422 | + type: "warning" | ||
| 423 | + }).then(function() { | ||
| 424 | + return delMenu(row.menuId); | ||
| 425 | + }).then(() => { | ||
| 426 | + this.getList(); | ||
| 427 | + this.msgSuccess("删除成功"); | ||
| 428 | + }).catch(() => {}); | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | +}; | ||
| 432 | +</script> |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="公告标题" prop="noticeTitle"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.noticeTitle" | ||
| 7 | - placeholder="请输入公告标题" | ||
| 8 | - clearable | ||
| 9 | - size="small" | ||
| 10 | - @keyup.enter.native="handleQuery" | ||
| 11 | - /> | ||
| 12 | - </el-form-item> | ||
| 13 | - <el-form-item label="操作人员" prop="createBy"> | ||
| 14 | - <el-input | ||
| 15 | - v-model="queryParams.createBy" | ||
| 16 | - placeholder="请输入操作人员" | ||
| 17 | - clearable | ||
| 18 | - size="small" | ||
| 19 | - @keyup.enter.native="handleQuery" | ||
| 20 | - /> | ||
| 21 | - </el-form-item> | ||
| 22 | - <el-form-item label="类型" prop="noticeType"> | ||
| 23 | - <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small"> | ||
| 24 | - <el-option | ||
| 25 | - v-for="dict in typeOptions" | ||
| 26 | - :key="dict.dictValue" | ||
| 27 | - :label="dict.dictLabel" | ||
| 28 | - :value="dict.dictValue" | ||
| 29 | - /> | ||
| 30 | - </el-select> | ||
| 31 | - </el-form-item> | ||
| 32 | - <el-form-item> | ||
| 33 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 34 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 35 | - </el-form-item> | ||
| 36 | - </el-form> | ||
| 37 | - | ||
| 38 | - <el-row :gutter="10" class="mb8"> | ||
| 39 | - <el-col :span="1.5"> | ||
| 40 | - <el-button | ||
| 41 | - type="primary" | ||
| 42 | - plain | ||
| 43 | - icon="el-icon-plus" | ||
| 44 | - size="mini" | ||
| 45 | - @click="handleAdd" | ||
| 46 | - v-hasPermi="['system:notice:add']" | ||
| 47 | - >新增</el-button> | ||
| 48 | - </el-col> | ||
| 49 | - <el-col :span="1.5"> | ||
| 50 | - <el-button | ||
| 51 | - type="success" | ||
| 52 | - plain | ||
| 53 | - icon="el-icon-edit" | ||
| 54 | - size="mini" | ||
| 55 | - :disabled="single" | ||
| 56 | - @click="handleUpdate" | ||
| 57 | - v-hasPermi="['system:notice:edit']" | ||
| 58 | - >修改</el-button> | ||
| 59 | - </el-col> | ||
| 60 | - <el-col :span="1.5"> | ||
| 61 | - <el-button | ||
| 62 | - type="danger" | ||
| 63 | - plain | ||
| 64 | - icon="el-icon-delete" | ||
| 65 | - size="mini" | ||
| 66 | - :disabled="multiple" | ||
| 67 | - @click="handleDelete" | ||
| 68 | - v-hasPermi="['system:notice:remove']" | ||
| 69 | - >删除</el-button> | ||
| 70 | - </el-col> | ||
| 71 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 72 | - </el-row> | ||
| 73 | - | ||
| 74 | - <el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange"> | ||
| 75 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 76 | - <el-table-column label="序号" align="center" prop="noticeId" width="100" /> | ||
| 77 | - <el-table-column | ||
| 78 | - label="公告标题" | ||
| 79 | - align="center" | ||
| 80 | - prop="noticeTitle" | ||
| 81 | - :show-overflow-tooltip="true" | ||
| 82 | - /> | ||
| 83 | - <el-table-column | ||
| 84 | - label="公告类型" | ||
| 85 | - align="center" | ||
| 86 | - prop="noticeType" | ||
| 87 | - :formatter="typeFormat" | ||
| 88 | - width="100" | ||
| 89 | - /> | ||
| 90 | - <el-table-column | ||
| 91 | - label="状态" | ||
| 92 | - align="center" | ||
| 93 | - prop="status" | ||
| 94 | - :formatter="statusFormat" | ||
| 95 | - width="100" | ||
| 96 | - /> | ||
| 97 | - <el-table-column label="创建者" align="center" prop="createBy" width="100" /> | ||
| 98 | - <el-table-column label="创建时间" align="center" prop="createTime" width="100"> | ||
| 99 | - <template slot-scope="scope"> | ||
| 100 | - <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> | ||
| 101 | - </template> | ||
| 102 | - </el-table-column> | ||
| 103 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 104 | - <template slot-scope="scope"> | ||
| 105 | - <el-button | ||
| 106 | - size="mini" | ||
| 107 | - type="text" | ||
| 108 | - icon="el-icon-edit" | ||
| 109 | - @click="handleUpdate(scope.row)" | ||
| 110 | - v-hasPermi="['system:notice:edit']" | ||
| 111 | - >修改</el-button> | ||
| 112 | - <el-button | ||
| 113 | - size="mini" | ||
| 114 | - type="text" | ||
| 115 | - icon="el-icon-delete" | ||
| 116 | - @click="handleDelete(scope.row)" | ||
| 117 | - v-hasPermi="['system:notice:remove']" | ||
| 118 | - >删除</el-button> | ||
| 119 | - </template> | ||
| 120 | - </el-table-column> | ||
| 121 | - </el-table> | ||
| 122 | - | ||
| 123 | - <pagination | ||
| 124 | - v-show="total>0" | ||
| 125 | - :total="total" | ||
| 126 | - :page.sync="queryParams.pageNum" | ||
| 127 | - :limit.sync="queryParams.pageSize" | ||
| 128 | - @pagination="getList" | ||
| 129 | - /> | ||
| 130 | - | ||
| 131 | - <!-- 添加或修改公告对话框 --> | ||
| 132 | - <el-dialog :title="title" :visible.sync="open" width="780px" append-to-body> | ||
| 133 | - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 134 | - <el-row> | ||
| 135 | - <el-col :span="12"> | ||
| 136 | - <el-form-item label="公告标题" prop="noticeTitle"> | ||
| 137 | - <el-input v-model="form.noticeTitle" placeholder="请输入公告标题" /> | ||
| 138 | - </el-form-item> | ||
| 139 | - </el-col> | ||
| 140 | - <el-col :span="12"> | ||
| 141 | - <el-form-item label="公告类型" prop="noticeType"> | ||
| 142 | - <el-select v-model="form.noticeType" placeholder="请选择"> | ||
| 143 | - <el-option | ||
| 144 | - v-for="dict in typeOptions" | ||
| 145 | - :key="dict.dictValue" | ||
| 146 | - :label="dict.dictLabel" | ||
| 147 | - :value="dict.dictValue" | ||
| 148 | - ></el-option> | ||
| 149 | - </el-select> | ||
| 150 | - </el-form-item> | ||
| 151 | - </el-col> | ||
| 152 | - <el-col :span="24"> | ||
| 153 | - <el-form-item label="状态"> | ||
| 154 | - <el-radio-group v-model="form.status"> | ||
| 155 | - <el-radio | ||
| 156 | - v-for="dict in statusOptions" | ||
| 157 | - :key="dict.dictValue" | ||
| 158 | - :label="dict.dictValue" | ||
| 159 | - >{{dict.dictLabel}}</el-radio> | ||
| 160 | - </el-radio-group> | ||
| 161 | - </el-form-item> | ||
| 162 | - </el-col> | ||
| 163 | - <el-col :span="24"> | ||
| 164 | - <el-form-item label="内容"> | ||
| 165 | - <editor v-model="form.noticeContent" :min-height="192"/> | ||
| 166 | - </el-form-item> | ||
| 167 | - </el-col> | ||
| 168 | - </el-row> | ||
| 169 | - </el-form> | ||
| 170 | - <div slot="footer" class="dialog-footer"> | ||
| 171 | - <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 172 | - <el-button @click="cancel">取 消</el-button> | ||
| 173 | - </div> | ||
| 174 | - </el-dialog> | ||
| 175 | - </div> | ||
| 176 | -</template> | ||
| 177 | - | ||
| 178 | -<script> | ||
| 179 | -import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"; | ||
| 180 | - | ||
| 181 | -export default { | ||
| 182 | - name: "Notice", | ||
| 183 | - data() { | ||
| 184 | - return { | ||
| 185 | - // 遮罩层 | ||
| 186 | - loading: true, | ||
| 187 | - // 选中数组 | ||
| 188 | - ids: [], | ||
| 189 | - // 非单个禁用 | ||
| 190 | - single: true, | ||
| 191 | - // 非多个禁用 | ||
| 192 | - multiple: true, | ||
| 193 | - // 显示搜索条件 | ||
| 194 | - showSearch: true, | ||
| 195 | - // 总条数 | ||
| 196 | - total: 0, | ||
| 197 | - // 公告表格数据 | ||
| 198 | - noticeList: [], | ||
| 199 | - // 弹出层标题 | ||
| 200 | - title: "", | ||
| 201 | - // 是否显示弹出层 | ||
| 202 | - open: false, | ||
| 203 | - // 类型数据字典 | ||
| 204 | - statusOptions: [], | ||
| 205 | - // 状态数据字典 | ||
| 206 | - typeOptions: [], | ||
| 207 | - // 查询参数 | ||
| 208 | - queryParams: { | ||
| 209 | - pageNum: 1, | ||
| 210 | - pageSize: 10, | ||
| 211 | - noticeTitle: undefined, | ||
| 212 | - createBy: undefined, | ||
| 213 | - status: undefined | ||
| 214 | - }, | ||
| 215 | - // 表单参数 | ||
| 216 | - form: {}, | ||
| 217 | - // 表单校验 | ||
| 218 | - rules: { | ||
| 219 | - noticeTitle: [ | ||
| 220 | - { required: true, message: "公告标题不能为空", trigger: "blur" } | ||
| 221 | - ], | ||
| 222 | - noticeType: [ | ||
| 223 | - { required: true, message: "公告类型不能为空", trigger: "change" } | ||
| 224 | - ] | ||
| 225 | - } | ||
| 226 | - }; | ||
| 227 | - }, | ||
| 228 | - created() { | ||
| 229 | - this.getList(); | ||
| 230 | - this.getDicts("sys_notice_status").then(response => { | ||
| 231 | - this.statusOptions = response.data; | ||
| 232 | - }); | ||
| 233 | - this.getDicts("sys_notice_type").then(response => { | ||
| 234 | - this.typeOptions = response.data; | ||
| 235 | - }); | ||
| 236 | - }, | ||
| 237 | - methods: { | ||
| 238 | - /** 查询公告列表 */ | ||
| 239 | - getList() { | ||
| 240 | - this.loading = true; | ||
| 241 | - listNotice(this.queryParams).then(response => { | ||
| 242 | - this.noticeList = response.rows; | ||
| 243 | - this.total = response.total; | ||
| 244 | - this.loading = false; | ||
| 245 | - }); | ||
| 246 | - }, | ||
| 247 | - // 公告状态字典翻译 | ||
| 248 | - statusFormat(row, column) { | ||
| 249 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 250 | - }, | ||
| 251 | - // 公告状态字典翻译 | ||
| 252 | - typeFormat(row, column) { | ||
| 253 | - return this.selectDictLabel(this.typeOptions, row.noticeType); | ||
| 254 | - }, | ||
| 255 | - // 取消按钮 | ||
| 256 | - cancel() { | ||
| 257 | - this.open = false; | ||
| 258 | - this.reset(); | ||
| 259 | - }, | ||
| 260 | - // 表单重置 | ||
| 261 | - reset() { | ||
| 262 | - this.form = { | ||
| 263 | - noticeId: undefined, | ||
| 264 | - noticeTitle: undefined, | ||
| 265 | - noticeType: undefined, | ||
| 266 | - noticeContent: undefined, | ||
| 267 | - status: "0" | ||
| 268 | - }; | ||
| 269 | - this.resetForm("form"); | ||
| 270 | - }, | ||
| 271 | - /** 搜索按钮操作 */ | ||
| 272 | - handleQuery() { | ||
| 273 | - this.queryParams.pageNum = 1; | ||
| 274 | - this.getList(); | ||
| 275 | - }, | ||
| 276 | - /** 重置按钮操作 */ | ||
| 277 | - resetQuery() { | ||
| 278 | - this.resetForm("queryForm"); | ||
| 279 | - this.handleQuery(); | ||
| 280 | - }, | ||
| 281 | - // 多选框选中数据 | ||
| 282 | - handleSelectionChange(selection) { | ||
| 283 | - this.ids = selection.map(item => item.noticeId) | ||
| 284 | - this.single = selection.length!=1 | ||
| 285 | - this.multiple = !selection.length | ||
| 286 | - }, | ||
| 287 | - /** 新增按钮操作 */ | ||
| 288 | - handleAdd() { | ||
| 289 | - this.reset(); | ||
| 290 | - this.open = true; | ||
| 291 | - this.title = "添加公告"; | ||
| 292 | - }, | ||
| 293 | - /** 修改按钮操作 */ | ||
| 294 | - handleUpdate(row) { | ||
| 295 | - this.reset(); | ||
| 296 | - const noticeId = row.noticeId || this.ids | ||
| 297 | - getNotice(noticeId).then(response => { | ||
| 298 | - this.form = response.data; | ||
| 299 | - this.open = true; | ||
| 300 | - this.title = "修改公告"; | ||
| 301 | - }); | ||
| 302 | - }, | ||
| 303 | - /** 提交按钮 */ | ||
| 304 | - submitForm: function() { | ||
| 305 | - this.$refs["form"].validate(valid => { | ||
| 306 | - if (valid) { | ||
| 307 | - if (this.form.noticeId != undefined) { | ||
| 308 | - updateNotice(this.form).then(response => { | ||
| 309 | - this.msgSuccess("修改成功"); | ||
| 310 | - this.open = false; | ||
| 311 | - this.getList(); | ||
| 312 | - }); | ||
| 313 | - } else { | ||
| 314 | - addNotice(this.form).then(response => { | ||
| 315 | - this.msgSuccess("新增成功"); | ||
| 316 | - this.open = false; | ||
| 317 | - this.getList(); | ||
| 318 | - }); | ||
| 319 | - } | ||
| 320 | - } | ||
| 321 | - }); | ||
| 322 | - }, | ||
| 323 | - /** 删除按钮操作 */ | ||
| 324 | - handleDelete(row) { | ||
| 325 | - const noticeIds = row.noticeId || this.ids | ||
| 326 | - this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", { | ||
| 327 | - confirmButtonText: "确定", | ||
| 328 | - cancelButtonText: "取消", | ||
| 329 | - type: "warning" | ||
| 330 | - }).then(function() { | ||
| 331 | - return delNotice(noticeIds); | ||
| 332 | - }).then(() => { | ||
| 333 | - this.getList(); | ||
| 334 | - this.msgSuccess("删除成功"); | ||
| 335 | - }).catch(() => {}); | ||
| 336 | - } | ||
| 337 | - } | ||
| 338 | -}; | ||
| 339 | -</script> | ||
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="公告标题" prop="noticeTitle"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.noticeTitle" | ||
| 7 | + placeholder="请输入公告标题" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + @keyup.enter.native="handleQuery" | ||
| 11 | + /> | ||
| 12 | + </el-form-item> | ||
| 13 | + <el-form-item label="操作人员" prop="createBy"> | ||
| 14 | + <el-input | ||
| 15 | + v-model="queryParams.createBy" | ||
| 16 | + placeholder="请输入操作人员" | ||
| 17 | + clearable | ||
| 18 | + size="small" | ||
| 19 | + @keyup.enter.native="handleQuery" | ||
| 20 | + /> | ||
| 21 | + </el-form-item> | ||
| 22 | + <el-form-item label="类型" prop="noticeType"> | ||
| 23 | + <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small"> | ||
| 24 | + <el-option | ||
| 25 | + v-for="dict in typeOptions" | ||
| 26 | + :key="dict.dictValue" | ||
| 27 | + :label="dict.dictLabel" | ||
| 28 | + :value="dict.dictValue" | ||
| 29 | + /> | ||
| 30 | + </el-select> | ||
| 31 | + </el-form-item> | ||
| 32 | + <el-form-item> | ||
| 33 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 34 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 35 | + </el-form-item> | ||
| 36 | + </el-form> | ||
| 37 | + | ||
| 38 | + <el-row :gutter="10" class="mb8"> | ||
| 39 | + <el-col :span="1.5"> | ||
| 40 | + <el-button | ||
| 41 | + type="primary" | ||
| 42 | + plain | ||
| 43 | + icon="el-icon-plus" | ||
| 44 | + size="mini" | ||
| 45 | + @click="handleAdd" | ||
| 46 | + v-hasPermi="['system:notice:add']" | ||
| 47 | + >新增</el-button> | ||
| 48 | + </el-col> | ||
| 49 | + <el-col :span="1.5"> | ||
| 50 | + <el-button | ||
| 51 | + type="success" | ||
| 52 | + plain | ||
| 53 | + icon="el-icon-edit" | ||
| 54 | + size="mini" | ||
| 55 | + :disabled="single" | ||
| 56 | + @click="handleUpdate" | ||
| 57 | + v-hasPermi="['system:notice:edit']" | ||
| 58 | + >修改</el-button> | ||
| 59 | + </el-col> | ||
| 60 | + <el-col :span="1.5"> | ||
| 61 | + <el-button | ||
| 62 | + type="danger" | ||
| 63 | + plain | ||
| 64 | + icon="el-icon-delete" | ||
| 65 | + size="mini" | ||
| 66 | + :disabled="multiple" | ||
| 67 | + @click="handleDelete" | ||
| 68 | + v-hasPermi="['system:notice:remove']" | ||
| 69 | + >删除</el-button> | ||
| 70 | + </el-col> | ||
| 71 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 72 | + </el-row> | ||
| 73 | + | ||
| 74 | + <el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange"> | ||
| 75 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 76 | + <el-table-column label="序号" align="center" prop="noticeId" width="100" /> | ||
| 77 | + <el-table-column | ||
| 78 | + label="公告标题" | ||
| 79 | + align="center" | ||
| 80 | + prop="noticeTitle" | ||
| 81 | + :show-overflow-tooltip="true" | ||
| 82 | + /> | ||
| 83 | + <el-table-column label="公告类型" align="center" prop="noticeType" width="100"> | ||
| 84 | + <template slot-scope="scope"> | ||
| 85 | + <dict-tag :options="typeOptions" :value="scope.row.noticeType"/> | ||
| 86 | + </template> | ||
| 87 | + </el-table-column> | ||
| 88 | + <el-table-column label="状态" align="center" prop="status" width="100"> | ||
| 89 | + <template slot-scope="scope"> | ||
| 90 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 91 | + </template> | ||
| 92 | + </el-table-column> | ||
| 93 | + <el-table-column label="创建者" align="center" prop="createBy" width="100" /> | ||
| 94 | + <el-table-column label="创建时间" align="center" prop="createTime" width="100"> | ||
| 95 | + <template slot-scope="scope"> | ||
| 96 | + <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> | ||
| 97 | + </template> | ||
| 98 | + </el-table-column> | ||
| 99 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 100 | + <template slot-scope="scope"> | ||
| 101 | + <el-button | ||
| 102 | + size="mini" | ||
| 103 | + type="text" | ||
| 104 | + icon="el-icon-edit" | ||
| 105 | + @click="handleUpdate(scope.row)" | ||
| 106 | + v-hasPermi="['system:notice:edit']" | ||
| 107 | + >修改</el-button> | ||
| 108 | + <el-button | ||
| 109 | + size="mini" | ||
| 110 | + type="text" | ||
| 111 | + icon="el-icon-delete" | ||
| 112 | + @click="handleDelete(scope.row)" | ||
| 113 | + v-hasPermi="['system:notice:remove']" | ||
| 114 | + >删除</el-button> | ||
| 115 | + </template> | ||
| 116 | + </el-table-column> | ||
| 117 | + </el-table> | ||
| 118 | + | ||
| 119 | + <pagination | ||
| 120 | + v-show="total>0" | ||
| 121 | + :total="total" | ||
| 122 | + :page.sync="queryParams.pageNum" | ||
| 123 | + :limit.sync="queryParams.pageSize" | ||
| 124 | + @pagination="getList" | ||
| 125 | + /> | ||
| 126 | + | ||
| 127 | + <!-- 添加或修改公告对话框 --> | ||
| 128 | + <el-dialog :title="title" :visible.sync="open" width="780px" append-to-body> | ||
| 129 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 130 | + <el-row> | ||
| 131 | + <el-col :span="12"> | ||
| 132 | + <el-form-item label="公告标题" prop="noticeTitle"> | ||
| 133 | + <el-input v-model="form.noticeTitle" placeholder="请输入公告标题" /> | ||
| 134 | + </el-form-item> | ||
| 135 | + </el-col> | ||
| 136 | + <el-col :span="12"> | ||
| 137 | + <el-form-item label="公告类型" prop="noticeType"> | ||
| 138 | + <el-select v-model="form.noticeType" placeholder="请选择"> | ||
| 139 | + <el-option | ||
| 140 | + v-for="dict in typeOptions" | ||
| 141 | + :key="dict.dictValue" | ||
| 142 | + :label="dict.dictLabel" | ||
| 143 | + :value="dict.dictValue" | ||
| 144 | + ></el-option> | ||
| 145 | + </el-select> | ||
| 146 | + </el-form-item> | ||
| 147 | + </el-col> | ||
| 148 | + <el-col :span="24"> | ||
| 149 | + <el-form-item label="状态"> | ||
| 150 | + <el-radio-group v-model="form.status"> | ||
| 151 | + <el-radio | ||
| 152 | + v-for="dict in statusOptions" | ||
| 153 | + :key="dict.dictValue" | ||
| 154 | + :label="dict.dictValue" | ||
| 155 | + >{{dict.dictLabel}}</el-radio> | ||
| 156 | + </el-radio-group> | ||
| 157 | + </el-form-item> | ||
| 158 | + </el-col> | ||
| 159 | + <el-col :span="24"> | ||
| 160 | + <el-form-item label="内容"> | ||
| 161 | + <editor v-model="form.noticeContent" :min-height="192"/> | ||
| 162 | + </el-form-item> | ||
| 163 | + </el-col> | ||
| 164 | + </el-row> | ||
| 165 | + </el-form> | ||
| 166 | + <div slot="footer" class="dialog-footer"> | ||
| 167 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 168 | + <el-button @click="cancel">取 消</el-button> | ||
| 169 | + </div> | ||
| 170 | + </el-dialog> | ||
| 171 | + </div> | ||
| 172 | +</template> | ||
| 173 | + | ||
| 174 | +<script> | ||
| 175 | +import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"; | ||
| 176 | + | ||
| 177 | +export default { | ||
| 178 | + name: "Notice", | ||
| 179 | + data() { | ||
| 180 | + return { | ||
| 181 | + // 遮罩层 | ||
| 182 | + loading: true, | ||
| 183 | + // 选中数组 | ||
| 184 | + ids: [], | ||
| 185 | + // 非单个禁用 | ||
| 186 | + single: true, | ||
| 187 | + // 非多个禁用 | ||
| 188 | + multiple: true, | ||
| 189 | + // 显示搜索条件 | ||
| 190 | + showSearch: true, | ||
| 191 | + // 总条数 | ||
| 192 | + total: 0, | ||
| 193 | + // 公告表格数据 | ||
| 194 | + noticeList: [], | ||
| 195 | + // 弹出层标题 | ||
| 196 | + title: "", | ||
| 197 | + // 是否显示弹出层 | ||
| 198 | + open: false, | ||
| 199 | + // 类型数据字典 | ||
| 200 | + statusOptions: [], | ||
| 201 | + // 状态数据字典 | ||
| 202 | + typeOptions: [], | ||
| 203 | + // 查询参数 | ||
| 204 | + queryParams: { | ||
| 205 | + pageNum: 1, | ||
| 206 | + pageSize: 10, | ||
| 207 | + noticeTitle: undefined, | ||
| 208 | + createBy: undefined, | ||
| 209 | + status: undefined | ||
| 210 | + }, | ||
| 211 | + // 表单参数 | ||
| 212 | + form: {}, | ||
| 213 | + // 表单校验 | ||
| 214 | + rules: { | ||
| 215 | + noticeTitle: [ | ||
| 216 | + { required: true, message: "公告标题不能为空", trigger: "blur" } | ||
| 217 | + ], | ||
| 218 | + noticeType: [ | ||
| 219 | + { required: true, message: "公告类型不能为空", trigger: "change" } | ||
| 220 | + ] | ||
| 221 | + } | ||
| 222 | + }; | ||
| 223 | + }, | ||
| 224 | + created() { | ||
| 225 | + this.getList(); | ||
| 226 | + this.getDicts("sys_notice_status").then(response => { | ||
| 227 | + this.statusOptions = response.data; | ||
| 228 | + }); | ||
| 229 | + this.getDicts("sys_notice_type").then(response => { | ||
| 230 | + this.typeOptions = response.data; | ||
| 231 | + }); | ||
| 232 | + }, | ||
| 233 | + methods: { | ||
| 234 | + /** 查询公告列表 */ | ||
| 235 | + getList() { | ||
| 236 | + this.loading = true; | ||
| 237 | + listNotice(this.queryParams).then(response => { | ||
| 238 | + this.noticeList = response.rows; | ||
| 239 | + this.total = response.total; | ||
| 240 | + this.loading = false; | ||
| 241 | + }); | ||
| 242 | + }, | ||
| 243 | + // 取消按钮 | ||
| 244 | + cancel() { | ||
| 245 | + this.open = false; | ||
| 246 | + this.reset(); | ||
| 247 | + }, | ||
| 248 | + // 表单重置 | ||
| 249 | + reset() { | ||
| 250 | + this.form = { | ||
| 251 | + noticeId: undefined, | ||
| 252 | + noticeTitle: undefined, | ||
| 253 | + noticeType: undefined, | ||
| 254 | + noticeContent: undefined, | ||
| 255 | + status: "0" | ||
| 256 | + }; | ||
| 257 | + this.resetForm("form"); | ||
| 258 | + }, | ||
| 259 | + /** 搜索按钮操作 */ | ||
| 260 | + handleQuery() { | ||
| 261 | + this.queryParams.pageNum = 1; | ||
| 262 | + this.getList(); | ||
| 263 | + }, | ||
| 264 | + /** 重置按钮操作 */ | ||
| 265 | + resetQuery() { | ||
| 266 | + this.resetForm("queryForm"); | ||
| 267 | + this.handleQuery(); | ||
| 268 | + }, | ||
| 269 | + // 多选框选中数据 | ||
| 270 | + handleSelectionChange(selection) { | ||
| 271 | + this.ids = selection.map(item => item.noticeId) | ||
| 272 | + this.single = selection.length!=1 | ||
| 273 | + this.multiple = !selection.length | ||
| 274 | + }, | ||
| 275 | + /** 新增按钮操作 */ | ||
| 276 | + handleAdd() { | ||
| 277 | + this.reset(); | ||
| 278 | + this.open = true; | ||
| 279 | + this.title = "添加公告"; | ||
| 280 | + }, | ||
| 281 | + /** 修改按钮操作 */ | ||
| 282 | + handleUpdate(row) { | ||
| 283 | + this.reset(); | ||
| 284 | + const noticeId = row.noticeId || this.ids | ||
| 285 | + getNotice(noticeId).then(response => { | ||
| 286 | + this.form = response.data; | ||
| 287 | + this.open = true; | ||
| 288 | + this.title = "修改公告"; | ||
| 289 | + }); | ||
| 290 | + }, | ||
| 291 | + /** 提交按钮 */ | ||
| 292 | + submitForm: function() { | ||
| 293 | + this.$refs["form"].validate(valid => { | ||
| 294 | + if (valid) { | ||
| 295 | + if (this.form.noticeId != undefined) { | ||
| 296 | + updateNotice(this.form).then(response => { | ||
| 297 | + this.msgSuccess("修改成功"); | ||
| 298 | + this.open = false; | ||
| 299 | + this.getList(); | ||
| 300 | + }); | ||
| 301 | + } else { | ||
| 302 | + addNotice(this.form).then(response => { | ||
| 303 | + this.msgSuccess("新增成功"); | ||
| 304 | + this.open = false; | ||
| 305 | + this.getList(); | ||
| 306 | + }); | ||
| 307 | + } | ||
| 308 | + } | ||
| 309 | + }); | ||
| 310 | + }, | ||
| 311 | + /** 删除按钮操作 */ | ||
| 312 | + handleDelete(row) { | ||
| 313 | + const noticeIds = row.noticeId || this.ids | ||
| 314 | + this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", { | ||
| 315 | + confirmButtonText: "确定", | ||
| 316 | + cancelButtonText: "取消", | ||
| 317 | + type: "warning" | ||
| 318 | + }).then(function() { | ||
| 319 | + return delNotice(noticeIds); | ||
| 320 | + }).then(() => { | ||
| 321 | + this.getList(); | ||
| 322 | + this.msgSuccess("删除成功"); | ||
| 323 | + }).catch(() => {}); | ||
| 324 | + } | ||
| 325 | + } | ||
| 326 | +}; | ||
| 327 | +</script> |
| 1 | -<template> | ||
| 2 | - <div class="app-container"> | ||
| 3 | - <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | - <el-form-item label="岗位编码" prop="postCode"> | ||
| 5 | - <el-input | ||
| 6 | - v-model="queryParams.postCode" | ||
| 7 | - placeholder="请输入岗位编码" | ||
| 8 | - clearable | ||
| 9 | - size="small" | ||
| 10 | - @keyup.enter.native="handleQuery" | ||
| 11 | - /> | ||
| 12 | - </el-form-item> | ||
| 13 | - <el-form-item label="岗位名称" prop="postName"> | ||
| 14 | - <el-input | ||
| 15 | - v-model="queryParams.postName" | ||
| 16 | - placeholder="请输入岗位名称" | ||
| 17 | - clearable | ||
| 18 | - size="small" | ||
| 19 | - @keyup.enter.native="handleQuery" | ||
| 20 | - /> | ||
| 21 | - </el-form-item> | ||
| 22 | - <el-form-item label="状态" prop="status"> | ||
| 23 | - <el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small"> | ||
| 24 | - <el-option | ||
| 25 | - v-for="dict in statusOptions" | ||
| 26 | - :key="dict.dictValue" | ||
| 27 | - :label="dict.dictLabel" | ||
| 28 | - :value="dict.dictValue" | ||
| 29 | - /> | ||
| 30 | - </el-select> | ||
| 31 | - </el-form-item> | ||
| 32 | - <el-form-item> | ||
| 33 | - <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 34 | - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 35 | - </el-form-item> | ||
| 36 | - </el-form> | ||
| 37 | - | ||
| 38 | - <el-row :gutter="10" class="mb8"> | ||
| 39 | - <el-col :span="1.5"> | ||
| 40 | - <el-button | ||
| 41 | - type="primary" | ||
| 42 | - plain | ||
| 43 | - icon="el-icon-plus" | ||
| 44 | - size="mini" | ||
| 45 | - @click="handleAdd" | ||
| 46 | - v-hasPermi="['system:post:add']" | ||
| 47 | - >新增</el-button> | ||
| 48 | - </el-col> | ||
| 49 | - <el-col :span="1.5"> | ||
| 50 | - <el-button | ||
| 51 | - type="success" | ||
| 52 | - plain | ||
| 53 | - icon="el-icon-edit" | ||
| 54 | - size="mini" | ||
| 55 | - :disabled="single" | ||
| 56 | - @click="handleUpdate" | ||
| 57 | - v-hasPermi="['system:post:edit']" | ||
| 58 | - >修改</el-button> | ||
| 59 | - </el-col> | ||
| 60 | - <el-col :span="1.5"> | ||
| 61 | - <el-button | ||
| 62 | - type="danger" | ||
| 63 | - plain | ||
| 64 | - icon="el-icon-delete" | ||
| 65 | - size="mini" | ||
| 66 | - :disabled="multiple" | ||
| 67 | - @click="handleDelete" | ||
| 68 | - v-hasPermi="['system:post:remove']" | ||
| 69 | - >删除</el-button> | ||
| 70 | - </el-col> | ||
| 71 | - <el-col :span="1.5"> | ||
| 72 | - <el-button | ||
| 73 | - type="warning" | ||
| 74 | - plain | ||
| 75 | - icon="el-icon-download" | ||
| 76 | - size="mini" | ||
| 77 | - :loading="exportLoading" | ||
| 78 | - @click="handleExport" | ||
| 79 | - v-hasPermi="['system:post:export']" | ||
| 80 | - >导出</el-button> | ||
| 81 | - </el-col> | ||
| 82 | - <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 83 | - </el-row> | ||
| 84 | - | ||
| 85 | - <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange"> | ||
| 86 | - <el-table-column type="selection" width="55" align="center" /> | ||
| 87 | - <el-table-column label="岗位编号" align="center" prop="postId" /> | ||
| 88 | - <el-table-column label="岗位编码" align="center" prop="postCode" /> | ||
| 89 | - <el-table-column label="岗位名称" align="center" prop="postName" /> | ||
| 90 | - <el-table-column label="岗位排序" align="center" prop="postSort" /> | ||
| 91 | - <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" /> | ||
| 92 | - <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 93 | - <template slot-scope="scope"> | ||
| 94 | - <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 95 | - </template> | ||
| 96 | - </el-table-column> | ||
| 97 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 98 | - <template slot-scope="scope"> | ||
| 99 | - <el-button | ||
| 100 | - size="mini" | ||
| 101 | - type="text" | ||
| 102 | - icon="el-icon-edit" | ||
| 103 | - @click="handleUpdate(scope.row)" | ||
| 104 | - v-hasPermi="['system:post:edit']" | ||
| 105 | - >修改</el-button> | ||
| 106 | - <el-button | ||
| 107 | - size="mini" | ||
| 108 | - type="text" | ||
| 109 | - icon="el-icon-delete" | ||
| 110 | - @click="handleDelete(scope.row)" | ||
| 111 | - v-hasPermi="['system:post:remove']" | ||
| 112 | - >删除</el-button> | ||
| 113 | - </template> | ||
| 114 | - </el-table-column> | ||
| 115 | - </el-table> | ||
| 116 | - | ||
| 117 | - <pagination | ||
| 118 | - v-show="total>0" | ||
| 119 | - :total="total" | ||
| 120 | - :page.sync="queryParams.pageNum" | ||
| 121 | - :limit.sync="queryParams.pageSize" | ||
| 122 | - @pagination="getList" | ||
| 123 | - /> | ||
| 124 | - | ||
| 125 | - <!-- 添加或修改岗位对话框 --> | ||
| 126 | - <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||
| 127 | - <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 128 | - <el-form-item label="岗位名称" prop="postName"> | ||
| 129 | - <el-input v-model="form.postName" placeholder="请输入岗位名称" /> | ||
| 130 | - </el-form-item> | ||
| 131 | - <el-form-item label="岗位编码" prop="postCode"> | ||
| 132 | - <el-input v-model="form.postCode" placeholder="请输入编码名称" /> | ||
| 133 | - </el-form-item> | ||
| 134 | - <el-form-item label="岗位顺序" prop="postSort"> | ||
| 135 | - <el-input-number v-model="form.postSort" controls-position="right" :min="0" /> | ||
| 136 | - </el-form-item> | ||
| 137 | - <el-form-item label="岗位状态" prop="status"> | ||
| 138 | - <el-radio-group v-model="form.status"> | ||
| 139 | - <el-radio | ||
| 140 | - v-for="dict in statusOptions" | ||
| 141 | - :key="dict.dictValue" | ||
| 142 | - :label="dict.dictValue" | ||
| 143 | - >{{dict.dictLabel}}</el-radio> | ||
| 144 | - </el-radio-group> | ||
| 145 | - </el-form-item> | ||
| 146 | - <el-form-item label="备注" prop="remark"> | ||
| 147 | - <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> | ||
| 148 | - </el-form-item> | ||
| 149 | - </el-form> | ||
| 150 | - <div slot="footer" class="dialog-footer"> | ||
| 151 | - <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 152 | - <el-button @click="cancel">取 消</el-button> | ||
| 153 | - </div> | ||
| 154 | - </el-dialog> | ||
| 155 | - </div> | ||
| 156 | -</template> | ||
| 157 | - | ||
| 158 | -<script> | ||
| 159 | -import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post"; | ||
| 160 | - | ||
| 161 | -export default { | ||
| 162 | - name: "Post", | ||
| 163 | - data() { | ||
| 164 | - return { | ||
| 165 | - // 遮罩层 | ||
| 166 | - loading: true, | ||
| 167 | - // 导出遮罩层 | ||
| 168 | - exportLoading: false, | ||
| 169 | - // 选中数组 | ||
| 170 | - ids: [], | ||
| 171 | - // 非单个禁用 | ||
| 172 | - single: true, | ||
| 173 | - // 非多个禁用 | ||
| 174 | - multiple: true, | ||
| 175 | - // 显示搜索条件 | ||
| 176 | - showSearch: true, | ||
| 177 | - // 总条数 | ||
| 178 | - total: 0, | ||
| 179 | - // 岗位表格数据 | ||
| 180 | - postList: [], | ||
| 181 | - // 弹出层标题 | ||
| 182 | - title: "", | ||
| 183 | - // 是否显示弹出层 | ||
| 184 | - open: false, | ||
| 185 | - // 状态数据字典 | ||
| 186 | - statusOptions: [], | ||
| 187 | - // 查询参数 | ||
| 188 | - queryParams: { | ||
| 189 | - pageNum: 1, | ||
| 190 | - pageSize: 10, | ||
| 191 | - postCode: undefined, | ||
| 192 | - postName: undefined, | ||
| 193 | - status: undefined | ||
| 194 | - }, | ||
| 195 | - // 表单参数 | ||
| 196 | - form: {}, | ||
| 197 | - // 表单校验 | ||
| 198 | - rules: { | ||
| 199 | - postName: [ | ||
| 200 | - { required: true, message: "岗位名称不能为空", trigger: "blur" } | ||
| 201 | - ], | ||
| 202 | - postCode: [ | ||
| 203 | - { required: true, message: "岗位编码不能为空", trigger: "blur" } | ||
| 204 | - ], | ||
| 205 | - postSort: [ | ||
| 206 | - { required: true, message: "岗位顺序不能为空", trigger: "blur" } | ||
| 207 | - ] | ||
| 208 | - } | ||
| 209 | - }; | ||
| 210 | - }, | ||
| 211 | - created() { | ||
| 212 | - this.getList(); | ||
| 213 | - this.getDicts("sys_normal_disable").then(response => { | ||
| 214 | - this.statusOptions = response.data; | ||
| 215 | - }); | ||
| 216 | - }, | ||
| 217 | - methods: { | ||
| 218 | - /** 查询岗位列表 */ | ||
| 219 | - getList() { | ||
| 220 | - this.loading = true; | ||
| 221 | - listPost(this.queryParams).then(response => { | ||
| 222 | - this.postList = response.rows; | ||
| 223 | - this.total = response.total; | ||
| 224 | - this.loading = false; | ||
| 225 | - }); | ||
| 226 | - }, | ||
| 227 | - // 岗位状态字典翻译 | ||
| 228 | - statusFormat(row, column) { | ||
| 229 | - return this.selectDictLabel(this.statusOptions, row.status); | ||
| 230 | - }, | ||
| 231 | - // 取消按钮 | ||
| 232 | - cancel() { | ||
| 233 | - this.open = false; | ||
| 234 | - this.reset(); | ||
| 235 | - }, | ||
| 236 | - // 表单重置 | ||
| 237 | - reset() { | ||
| 238 | - this.form = { | ||
| 239 | - postId: undefined, | ||
| 240 | - postCode: undefined, | ||
| 241 | - postName: undefined, | ||
| 242 | - postSort: 0, | ||
| 243 | - status: "0", | ||
| 244 | - remark: undefined | ||
| 245 | - }; | ||
| 246 | - this.resetForm("form"); | ||
| 247 | - }, | ||
| 248 | - /** 搜索按钮操作 */ | ||
| 249 | - handleQuery() { | ||
| 250 | - this.queryParams.pageNum = 1; | ||
| 251 | - this.getList(); | ||
| 252 | - }, | ||
| 253 | - /** 重置按钮操作 */ | ||
| 254 | - resetQuery() { | ||
| 255 | - this.resetForm("queryForm"); | ||
| 256 | - this.handleQuery(); | ||
| 257 | - }, | ||
| 258 | - // 多选框选中数据 | ||
| 259 | - handleSelectionChange(selection) { | ||
| 260 | - this.ids = selection.map(item => item.postId) | ||
| 261 | - this.single = selection.length!=1 | ||
| 262 | - this.multiple = !selection.length | ||
| 263 | - }, | ||
| 264 | - /** 新增按钮操作 */ | ||
| 265 | - handleAdd() { | ||
| 266 | - this.reset(); | ||
| 267 | - this.open = true; | ||
| 268 | - this.title = "添加岗位"; | ||
| 269 | - }, | ||
| 270 | - /** 修改按钮操作 */ | ||
| 271 | - handleUpdate(row) { | ||
| 272 | - this.reset(); | ||
| 273 | - const postId = row.postId || this.ids | ||
| 274 | - getPost(postId).then(response => { | ||
| 275 | - this.form = response.data; | ||
| 276 | - this.open = true; | ||
| 277 | - this.title = "修改岗位"; | ||
| 278 | - }); | ||
| 279 | - }, | ||
| 280 | - /** 提交按钮 */ | ||
| 281 | - submitForm: function() { | ||
| 282 | - this.$refs["form"].validate(valid => { | ||
| 283 | - if (valid) { | ||
| 284 | - if (this.form.postId != undefined) { | ||
| 285 | - updatePost(this.form).then(response => { | ||
| 286 | - this.msgSuccess("修改成功"); | ||
| 287 | - this.open = false; | ||
| 288 | - this.getList(); | ||
| 289 | - }); | ||
| 290 | - } else { | ||
| 291 | - addPost(this.form).then(response => { | ||
| 292 | - this.msgSuccess("新增成功"); | ||
| 293 | - this.open = false; | ||
| 294 | - this.getList(); | ||
| 295 | - }); | ||
| 296 | - } | ||
| 297 | - } | ||
| 298 | - }); | ||
| 299 | - }, | ||
| 300 | - /** 删除按钮操作 */ | ||
| 301 | - handleDelete(row) { | ||
| 302 | - const postIds = row.postId || this.ids; | ||
| 303 | - this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", { | ||
| 304 | - confirmButtonText: "确定", | ||
| 305 | - cancelButtonText: "取消", | ||
| 306 | - type: "warning" | ||
| 307 | - }).then(function() { | ||
| 308 | - return delPost(postIds); | ||
| 309 | - }).then(() => { | ||
| 310 | - this.getList(); | ||
| 311 | - this.msgSuccess("删除成功"); | ||
| 312 | - }).catch(() => {}); | ||
| 313 | - }, | ||
| 314 | - /** 导出按钮操作 */ | ||
| 315 | - handleExport() { | ||
| 316 | - const queryParams = this.queryParams; | ||
| 317 | - this.$confirm('是否确认导出所有岗位数据项?', "警告", { | ||
| 318 | - confirmButtonText: "确定", | ||
| 319 | - cancelButtonText: "取消", | ||
| 320 | - type: "warning" | ||
| 321 | - }).then(() => { | ||
| 322 | - this.exportLoading = true; | ||
| 323 | - return exportPost(queryParams); | ||
| 324 | - }).then(response => { | ||
| 325 | - this.download(response.msg); | ||
| 326 | - this.exportLoading = false; | ||
| 327 | - }).catch(() => {}); | ||
| 328 | - } | ||
| 329 | - } | ||
| 330 | -}; | ||
| 331 | -</script> | ||
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 4 | + <el-form-item label="岗位编码" prop="postCode"> | ||
| 5 | + <el-input | ||
| 6 | + v-model="queryParams.postCode" | ||
| 7 | + placeholder="请输入岗位编码" | ||
| 8 | + clearable | ||
| 9 | + size="small" | ||
| 10 | + @keyup.enter.native="handleQuery" | ||
| 11 | + /> | ||
| 12 | + </el-form-item> | ||
| 13 | + <el-form-item label="岗位名称" prop="postName"> | ||
| 14 | + <el-input | ||
| 15 | + v-model="queryParams.postName" | ||
| 16 | + placeholder="请输入岗位名称" | ||
| 17 | + clearable | ||
| 18 | + size="small" | ||
| 19 | + @keyup.enter.native="handleQuery" | ||
| 20 | + /> | ||
| 21 | + </el-form-item> | ||
| 22 | + <el-form-item label="状态" prop="status"> | ||
| 23 | + <el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small"> | ||
| 24 | + <el-option | ||
| 25 | + v-for="dict in statusOptions" | ||
| 26 | + :key="dict.dictValue" | ||
| 27 | + :label="dict.dictLabel" | ||
| 28 | + :value="dict.dictValue" | ||
| 29 | + /> | ||
| 30 | + </el-select> | ||
| 31 | + </el-form-item> | ||
| 32 | + <el-form-item> | ||
| 33 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 34 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 35 | + </el-form-item> | ||
| 36 | + </el-form> | ||
| 37 | + | ||
| 38 | + <el-row :gutter="10" class="mb8"> | ||
| 39 | + <el-col :span="1.5"> | ||
| 40 | + <el-button | ||
| 41 | + type="primary" | ||
| 42 | + plain | ||
| 43 | + icon="el-icon-plus" | ||
| 44 | + size="mini" | ||
| 45 | + @click="handleAdd" | ||
| 46 | + v-hasPermi="['system:post:add']" | ||
| 47 | + >新增</el-button> | ||
| 48 | + </el-col> | ||
| 49 | + <el-col :span="1.5"> | ||
| 50 | + <el-button | ||
| 51 | + type="success" | ||
| 52 | + plain | ||
| 53 | + icon="el-icon-edit" | ||
| 54 | + size="mini" | ||
| 55 | + :disabled="single" | ||
| 56 | + @click="handleUpdate" | ||
| 57 | + v-hasPermi="['system:post:edit']" | ||
| 58 | + >修改</el-button> | ||
| 59 | + </el-col> | ||
| 60 | + <el-col :span="1.5"> | ||
| 61 | + <el-button | ||
| 62 | + type="danger" | ||
| 63 | + plain | ||
| 64 | + icon="el-icon-delete" | ||
| 65 | + size="mini" | ||
| 66 | + :disabled="multiple" | ||
| 67 | + @click="handleDelete" | ||
| 68 | + v-hasPermi="['system:post:remove']" | ||
| 69 | + >删除</el-button> | ||
| 70 | + </el-col> | ||
| 71 | + <el-col :span="1.5"> | ||
| 72 | + <el-button | ||
| 73 | + type="warning" | ||
| 74 | + plain | ||
| 75 | + icon="el-icon-download" | ||
| 76 | + size="mini" | ||
| 77 | + :loading="exportLoading" | ||
| 78 | + @click="handleExport" | ||
| 79 | + v-hasPermi="['system:post:export']" | ||
| 80 | + >导出</el-button> | ||
| 81 | + </el-col> | ||
| 82 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 83 | + </el-row> | ||
| 84 | + | ||
| 85 | + <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange"> | ||
| 86 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 87 | + <el-table-column label="岗位编号" align="center" prop="postId" /> | ||
| 88 | + <el-table-column label="岗位编码" align="center" prop="postCode" /> | ||
| 89 | + <el-table-column label="岗位名称" align="center" prop="postName" /> | ||
| 90 | + <el-table-column label="岗位排序" align="center" prop="postSort" /> | ||
| 91 | + <el-table-column label="状态" align="center" prop="status"> | ||
| 92 | + <template slot-scope="scope"> | ||
| 93 | + <dict-tag :options="statusOptions" :value="scope.row.status"/> | ||
| 94 | + </template> | ||
| 95 | + </el-table-column> | ||
| 96 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 97 | + <template slot-scope="scope"> | ||
| 98 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 99 | + </template> | ||
| 100 | + </el-table-column> | ||
| 101 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 102 | + <template slot-scope="scope"> | ||
| 103 | + <el-button | ||
| 104 | + size="mini" | ||
| 105 | + type="text" | ||
| 106 | + icon="el-icon-edit" | ||
| 107 | + @click="handleUpdate(scope.row)" | ||
| 108 | + v-hasPermi="['system:post:edit']" | ||
| 109 | + >修改</el-button> | ||
| 110 | + <el-button | ||
| 111 | + size="mini" | ||
| 112 | + type="text" | ||
| 113 | + icon="el-icon-delete" | ||
| 114 | + @click="handleDelete(scope.row)" | ||
| 115 | + v-hasPermi="['system:post:remove']" | ||
| 116 | + >删除</el-button> | ||
| 117 | + </template> | ||
| 118 | + </el-table-column> | ||
| 119 | + </el-table> | ||
| 120 | + | ||
| 121 | + <pagination | ||
| 122 | + v-show="total>0" | ||
| 123 | + :total="total" | ||
| 124 | + :page.sync="queryParams.pageNum" | ||
| 125 | + :limit.sync="queryParams.pageSize" | ||
| 126 | + @pagination="getList" | ||
| 127 | + /> | ||
| 128 | + | ||
| 129 | + <!-- 添加或修改岗位对话框 --> | ||
| 130 | + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||
| 131 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 132 | + <el-form-item label="岗位名称" prop="postName"> | ||
| 133 | + <el-input v-model="form.postName" placeholder="请输入岗位名称" /> | ||
| 134 | + </el-form-item> | ||
| 135 | + <el-form-item label="岗位编码" prop="postCode"> | ||
| 136 | + <el-input v-model="form.postCode" placeholder="请输入编码名称" /> | ||
| 137 | + </el-form-item> | ||
| 138 | + <el-form-item label="岗位顺序" prop="postSort"> | ||
| 139 | + <el-input-number v-model="form.postSort" controls-position="right" :min="0" /> | ||
| 140 | + </el-form-item> | ||
| 141 | + <el-form-item label="岗位状态" prop="status"> | ||
| 142 | + <el-radio-group v-model="form.status"> | ||
| 143 | + <el-radio | ||
| 144 | + v-for="dict in statusOptions" | ||
| 145 | + :key="dict.dictValue" | ||
| 146 | + :label="dict.dictValue" | ||
| 147 | + >{{dict.dictLabel}}</el-radio> | ||
| 148 | + </el-radio-group> | ||
| 149 | + </el-form-item> | ||
| 150 | + <el-form-item label="备注" prop="remark"> | ||
| 151 | + <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> | ||
| 152 | + </el-form-item> | ||
| 153 | + </el-form> | ||
| 154 | + <div slot="footer" class="dialog-footer"> | ||
| 155 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 156 | + <el-button @click="cancel">取 消</el-button> | ||
| 157 | + </div> | ||
| 158 | + </el-dialog> | ||
| 159 | + </div> | ||
| 160 | +</template> | ||
| 161 | + | ||
| 162 | +<script> | ||
| 163 | +import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post"; | ||
| 164 | + | ||
| 165 | +export default { | ||
| 166 | + name: "Post", | ||
| 167 | + data() { | ||
| 168 | + return { | ||
| 169 | + // 遮罩层 | ||
| 170 | + loading: true, | ||
| 171 | + // 导出遮罩层 | ||
| 172 | + exportLoading: false, | ||
| 173 | + // 选中数组 | ||
| 174 | + ids: [], | ||
| 175 | + // 非单个禁用 | ||
| 176 | + single: true, | ||
| 177 | + // 非多个禁用 | ||
| 178 | + multiple: true, | ||
| 179 | + // 显示搜索条件 | ||
| 180 | + showSearch: true, | ||
| 181 | + // 总条数 | ||
| 182 | + total: 0, | ||
| 183 | + // 岗位表格数据 | ||
| 184 | + postList: [], | ||
| 185 | + // 弹出层标题 | ||
| 186 | + title: "", | ||
| 187 | + // 是否显示弹出层 | ||
| 188 | + open: false, | ||
| 189 | + // 状态数据字典 | ||
| 190 | + statusOptions: [], | ||
| 191 | + // 查询参数 | ||
| 192 | + queryParams: { | ||
| 193 | + pageNum: 1, | ||
| 194 | + pageSize: 10, | ||
| 195 | + postCode: undefined, | ||
| 196 | + postName: undefined, | ||
| 197 | + status: undefined | ||
| 198 | + }, | ||
| 199 | + // 表单参数 | ||
| 200 | + form: {}, | ||
| 201 | + // 表单校验 | ||
| 202 | + rules: { | ||
| 203 | + postName: [ | ||
| 204 | + { required: true, message: "岗位名称不能为空", trigger: "blur" } | ||
| 205 | + ], | ||
| 206 | + postCode: [ | ||
| 207 | + { required: true, message: "岗位编码不能为空", trigger: "blur" } | ||
| 208 | + ], | ||
| 209 | + postSort: [ | ||
| 210 | + { required: true, message: "岗位顺序不能为空", trigger: "blur" } | ||
| 211 | + ] | ||
| 212 | + } | ||
| 213 | + }; | ||
| 214 | + }, | ||
| 215 | + created() { | ||
| 216 | + this.getList(); | ||
| 217 | + this.getDicts("sys_normal_disable").then(response => { | ||
| 218 | + this.statusOptions = response.data; | ||
| 219 | + }); | ||
| 220 | + }, | ||
| 221 | + methods: { | ||
| 222 | + /** 查询岗位列表 */ | ||
| 223 | + getList() { | ||
| 224 | + this.loading = true; | ||
| 225 | + listPost(this.queryParams).then(response => { | ||
| 226 | + this.postList = response.rows; | ||
| 227 | + this.total = response.total; | ||
| 228 | + this.loading = false; | ||
| 229 | + }); | ||
| 230 | + }, | ||
| 231 | + // 取消按钮 | ||
| 232 | + cancel() { | ||
| 233 | + this.open = false; | ||
| 234 | + this.reset(); | ||
| 235 | + }, | ||
| 236 | + // 表单重置 | ||
| 237 | + reset() { | ||
| 238 | + this.form = { | ||
| 239 | + postId: undefined, | ||
| 240 | + postCode: undefined, | ||
| 241 | + postName: undefined, | ||
| 242 | + postSort: 0, | ||
| 243 | + status: "0", | ||
| 244 | + remark: undefined | ||
| 245 | + }; | ||
| 246 | + this.resetForm("form"); | ||
| 247 | + }, | ||
| 248 | + /** 搜索按钮操作 */ | ||
| 249 | + handleQuery() { | ||
| 250 | + this.queryParams.pageNum = 1; | ||
| 251 | + this.getList(); | ||
| 252 | + }, | ||
| 253 | + /** 重置按钮操作 */ | ||
| 254 | + resetQuery() { | ||
| 255 | + this.resetForm("queryForm"); | ||
| 256 | + this.handleQuery(); | ||
| 257 | + }, | ||
| 258 | + // 多选框选中数据 | ||
| 259 | + handleSelectionChange(selection) { | ||
| 260 | + this.ids = selection.map(item => item.postId) | ||
| 261 | + this.single = selection.length!=1 | ||
| 262 | + this.multiple = !selection.length | ||
| 263 | + }, | ||
| 264 | + /** 新增按钮操作 */ | ||
| 265 | + handleAdd() { | ||
| 266 | + this.reset(); | ||
| 267 | + this.open = true; | ||
| 268 | + this.title = "添加岗位"; | ||
| 269 | + }, | ||
| 270 | + /** 修改按钮操作 */ | ||
| 271 | + handleUpdate(row) { | ||
| 272 | + this.reset(); | ||
| 273 | + const postId = row.postId || this.ids | ||
| 274 | + getPost(postId).then(response => { | ||
| 275 | + this.form = response.data; | ||
| 276 | + this.open = true; | ||
| 277 | + this.title = "修改岗位"; | ||
| 278 | + }); | ||
| 279 | + }, | ||
| 280 | + /** 提交按钮 */ | ||
| 281 | + submitForm: function() { | ||
| 282 | + this.$refs["form"].validate(valid => { | ||
| 283 | + if (valid) { | ||
| 284 | + if (this.form.postId != undefined) { | ||
| 285 | + updatePost(this.form).then(response => { | ||
| 286 | + this.msgSuccess("修改成功"); | ||
| 287 | + this.open = false; | ||
| 288 | + this.getList(); | ||
| 289 | + }); | ||
| 290 | + } else { | ||
| 291 | + addPost(this.form).then(response => { | ||
| 292 | + this.msgSuccess("新增成功"); | ||
| 293 | + this.open = false; | ||
| 294 | + this.getList(); | ||
| 295 | + }); | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + }); | ||
| 299 | + }, | ||
| 300 | + /** 删除按钮操作 */ | ||
| 301 | + handleDelete(row) { | ||
| 302 | + const postIds = row.postId || this.ids; | ||
| 303 | + this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", { | ||
| 304 | + confirmButtonText: "确定", | ||
| 305 | + cancelButtonText: "取消", | ||
| 306 | + type: "warning" | ||
| 307 | + }).then(function() { | ||
| 308 | + return delPost(postIds); | ||
| 309 | + }).then(() => { | ||
| 310 | + this.getList(); | ||
| 311 | + this.msgSuccess("删除成功"); | ||
| 312 | + }).catch(() => {}); | ||
| 313 | + }, | ||
| 314 | + /** 导出按钮操作 */ | ||
| 315 | + handleExport() { | ||
| 316 | + const queryParams = this.queryParams; | ||
| 317 | + this.$confirm('是否确认导出所有岗位数据项?', "警告", { | ||
| 318 | + confirmButtonText: "确定", | ||
| 319 | + cancelButtonText: "取消", | ||
| 320 | + type: "warning" | ||
| 321 | + }).then(() => { | ||
| 322 | + this.exportLoading = true; | ||
| 323 | + return exportPost(queryParams); | ||
| 324 | + }).then(response => { | ||
| 325 | + this.download(response.msg); | ||
| 326 | + this.exportLoading = false; | ||
| 327 | + }).catch(() => {}); | ||
| 328 | + } | ||
| 329 | + } | ||
| 330 | +}; | ||
| 331 | +</script> |
-
请 注册 或 登录 后发表评论