| | |
| | | |
| | | //main-container全局样式 |
| | | .app-container { |
| | | padding: 20px; |
| | | // padding: 0 12px; |
| | | padding-right: 12px; |
| | | } |
| | | |
| | | .components-container { |
| | |
| | | } |
| | | |
| | | .table-bg-style { |
| | | margin-top: 12px; |
| | | .theme-dark-mt20 { |
| | | margin-top: 20px; |
| | | } |
| | |
| | | } |
| | | |
| | | .table-box { |
| | | margin: 20px; |
| | | margin: 0; |
| | | |
| | | .table-title-box { |
| | | font-weight: bold; |
| | |
| | | } |
| | | |
| | | .table-box { |
| | | margin: 20px; |
| | | margin: 10px 20px; |
| | | |
| | | .table-title-box { |
| | | font-weight: bold; |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div class="table-box"> |
| | | <el-table :data="tableData" v-loading="loading"> |
| | | <el-table-column prop="title" label="文件标题" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="typeName" label="文件类别" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="dept" label="印发部门" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="issuingTime" label="印发时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column label="操作" width="300" align="center"> |
| | | <template #default="scope"> |
| | | <el-button v-if="scope.row.url" link type="primary" icon="Files" @click="handleFile(scope.row.url)"> |
| | | 附件 |
| | | </el-button> |
| | | <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row)"> 修改 </el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDel(scope.row)"> 删除 </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <el-table :data="tableData" v-loading="loading"> |
| | | <el-table-column prop="title" label="文件标题" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="typeName" label="文件类别" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="dept" label="印发部门" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="issuingTime" label="印发时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column label="操作" width="300" align="center"> |
| | | <template #default="scope"> |
| | | <el-button v-if="scope.row.url" link type="primary" icon="Files" @click="handleFile(scope.row.url)"> |
| | | 附件 |
| | | </el-button> |
| | | <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row)"> 修改 </el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDel(scope.row)"> 删除 </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <EditModal ref="editModalRef" @get-list="getList" /> |
| | | </div> |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div class="table-box"> |
| | | <el-table :data="tableData" v-loading="loading"> |
| | | <el-table-column prop="plan" label="总体计划" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="implementationPlan" label="实施计划" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="savingAmount" label="节约量" show-overflow-tooltip align="center" /> |
| | | <!-- <el-table-column prop="value4" label="开始时间" show-overflow-tooltip align="center" /> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <el-table :data="tableData" v-loading="loading"> |
| | | <el-table-column prop="plan" label="总体计划" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="implementationPlan" label="实施计划" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="savingAmount" label="节约量" show-overflow-tooltip align="center" /> |
| | | <!-- <el-table-column prop="value4" label="开始时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="value5" label="结束时间" show-overflow-tooltip align="center" /> --> |
| | | <el-table-column prop="currentWork" label="当前工作" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="liablePerson" label="负责人" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="completionTime" label="完成时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="remark" label="备注" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="currentWork" label="当前工作" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="liablePerson" label="负责人" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="completionTime" label="完成时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip align="center" /> |
| | | <el-table-column prop="remark" label="备注" show-overflow-tooltip align="center" /> |
| | | |
| | | <el-table-column label="操作" width="300" align="center"> |
| | | <template #default="scope"> |
| | | <!-- <el-button link type="primary" icon="Files" @click=""> 附件 </el-button> --> |
| | | <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row)"> 修改 </el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDel(scope.row)"> 删除 </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <el-table-column label="操作" width="300" align="center"> |
| | | <template #default="scope"> |
| | | <!-- <el-button link type="primary" icon="Files" @click=""> 附件 </el-button> --> |
| | | <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row)"> 修改 </el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDel(scope.row)"> 删除 </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <edit-modal ref="EditModalRef" @getList="getList" /> |
| | | </div> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> |
| | | <el-form-item label="任务名称" prop="jobName"> |
| | | <el-input |
| | | v-model="queryParams.jobName" |
| | | placeholder="请输入任务名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="任务组名" prop="jobGroup"> |
| | | <el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable style="width: 200px"> |
| | | <el-option |
| | | <el-form-item label="任务名称" prop="jobName"> |
| | | <el-input |
| | | v-model="queryParams.jobName" |
| | | placeholder="请输入任务名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="任务组名" prop="jobGroup"> |
| | | <el-select v-model="queryParams.jobGroup" placeholder="请选择任务组名" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_job_group" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_job_status" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <div style="margin-bottom: 12px"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['monitor:job:add']" |
| | | >新增</el-button |
| | | > |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['monitor:job:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['monitor:job:remove']" |
| | | >删除</el-button |
| | | > |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['monitor:job:export']" |
| | | >导出</el-button |
| | | > |
| | | <el-button type="info" plain icon="Operation" @click="handleJobLog" v-hasPermi="['monitor:job:query']" |
| | | >日志</el-button |
| | | > |
| | | </div> |
| | | <el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="任务编号" width="100" align="center" prop="jobId" /> |
| | | <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="任务组名" align="center" prop="jobGroup"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_job_group" :value="scope.row.jobGroup" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="cron执行表达式" align="center" prop="cronExpression" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="状态" align="center"> |
| | | <template #default="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['monitor:job:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['monitor:job:remove']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="执行一次" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="CaretRight" |
| | | @click="handleRun(scope.row)" |
| | | v-hasPermi="['monitor:job:changeStatus']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="任务详细" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="View" |
| | | @click="handleView(scope.row)" |
| | | v-hasPermi="['monitor:job:query']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="调度日志" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Operation" |
| | | @click="handleJobLog(scope.row)" |
| | | v-hasPermi="['monitor:job:query']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- 添加或修改定时任务对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="820px" append-to-body> |
| | | <el-form ref="jobRef" :model="form" :rules="rules" label-width="120px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务名称" prop="jobName"> |
| | | <el-input v-model="form.jobName" placeholder="请输入任务名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务分组" prop="jobGroup"> |
| | | <el-select v-model="form.jobGroup" placeholder="请选择"> |
| | | <el-option |
| | | v-for="dict in sys_job_group" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="请选择任务状态" clearable style="width: 200px"> |
| | | <el-option |
| | | v-for="dict in sys_job_status" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item prop="invokeTarget"> |
| | | <template #label> |
| | | <span> |
| | | 调用方法 |
| | | <el-tooltip placement="top"> |
| | | <template #content> |
| | | <div> |
| | | Bean调用示例:ryTask.ryParams('ry') |
| | | <br />Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') |
| | | <br />参数说明:支持字符串,布尔类型,长整型,浮点型,整型 |
| | | </div> |
| | | </template> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.invokeTarget" placeholder="请输入调用目标字符串" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="cron表达式" prop="cronExpression"> |
| | | <el-input v-model="form.cronExpression" placeholder="请输入cron执行表达式"> |
| | | <template #append> |
| | | <el-button type="primary" @click="handleShowCron"> |
| | | 生成表达式 |
| | | <i class="el-icon-time el-icon--right"></i> |
| | | </el-button> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" v-if="form.jobId !== undefined"> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_job_status" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="执行策略" prop="misfirePolicy"> |
| | | <el-radio-group v-model="form.misfirePolicy"> |
| | | <el-radio-button label="1">立即执行</el-radio-button> |
| | | <el-radio-button label="2">执行一次</el-radio-button> |
| | | <el-radio-button label="3">放弃执行</el-radio-button> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否并发" prop="concurrent"> |
| | | <el-radio-group v-model="form.concurrent"> |
| | | <el-radio-button label="0">允许</el-radio-button> |
| | | <el-radio-button label="1">禁止</el-radio-button> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['monitor:job:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['monitor:job:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['monitor:job:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:job:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="Operation" |
| | | @click="handleJobLog" |
| | | v-hasPermi="['monitor:job:query']" |
| | | >日志</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | <el-dialog title="Cron表达式生成器" v-model="openCron" append-to-body destroy-on-close> |
| | | <crontab ref="crontabRef" @hide="openCron = false" @fill="crontabFill" :expression="expression"></crontab> |
| | | </el-dialog> |
| | | |
| | | <el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="任务编号" width="100" align="center" prop="jobId" /> |
| | | <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="任务组名" align="center" prop="jobGroup"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_job_group" :value="scope.row.jobGroup" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="cron执行表达式" align="center" prop="cronExpression" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="状态" align="center"> |
| | | <template #default="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['monitor:job:edit']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top"> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['monitor:job:remove']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="执行一次" placement="top"> |
| | | <el-button link type="primary" icon="CaretRight" @click="handleRun(scope.row)" v-hasPermi="['monitor:job:changeStatus']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="任务详细" placement="top"> |
| | | <el-button link type="primary" icon="View" @click="handleView(scope.row)" v-hasPermi="['monitor:job:query']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="调度日志" placement="top"> |
| | | <el-button link type="primary" icon="Operation" @click="handleJobLog(scope.row)" v-hasPermi="['monitor:job:query']"></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- 添加或修改定时任务对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="820px" append-to-body> |
| | | <el-form ref="jobRef" :model="form" :rules="rules" label-width="120px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务名称" prop="jobName"> |
| | | <el-input v-model="form.jobName" placeholder="请输入任务名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务分组" prop="jobGroup"> |
| | | <el-select v-model="form.jobGroup" placeholder="请选择"> |
| | | <el-option |
| | | v-for="dict in sys_job_group" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item prop="invokeTarget"> |
| | | <template #label> |
| | | <span> |
| | | 调用方法 |
| | | <el-tooltip placement="top"> |
| | | <template #content> |
| | | <div> |
| | | Bean调用示例:ryTask.ryParams('ry') |
| | | <br />Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') |
| | | <br />参数说明:支持字符串,布尔类型,长整型,浮点型,整型 |
| | | </div> |
| | | </template> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.invokeTarget" placeholder="请输入调用目标字符串" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="cron表达式" prop="cronExpression"> |
| | | <el-input v-model="form.cronExpression" placeholder="请输入cron执行表达式"> |
| | | <template #append> |
| | | <el-button type="primary" @click="handleShowCron"> |
| | | 生成表达式 |
| | | <i class="el-icon-time el-icon--right"></i> |
| | | </el-button> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" v-if="form.jobId !== undefined"> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_job_status" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="执行策略" prop="misfirePolicy"> |
| | | <el-radio-group v-model="form.misfirePolicy"> |
| | | <el-radio-button label="1">立即执行</el-radio-button> |
| | | <el-radio-button label="2">执行一次</el-radio-button> |
| | | <el-radio-button label="3">放弃执行</el-radio-button> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否并发" prop="concurrent"> |
| | | <el-radio-group v-model="form.concurrent"> |
| | | <el-radio-button label="0">允许</el-radio-button> |
| | | <el-radio-button label="1">禁止</el-radio-button> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <el-dialog title="Cron表达式生成器" v-model="openCron" append-to-body destroy-on-close> |
| | | <crontab ref="crontabRef" @hide="openCron=false" @fill="crontabFill" :expression="expression"></crontab> |
| | | </el-dialog> |
| | | |
| | | <!-- 任务日志详细 --> |
| | | <el-dialog title="任务详细" v-model="openView" width="700px" append-to-body> |
| | | <el-form :model="form" label-width="120px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务编号:">{{ form.jobId }}</el-form-item> |
| | | <el-form-item label="任务名称:">{{ form.jobName }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务分组:">{{ jobGroupFormat(form) }}</el-form-item> |
| | | <el-form-item label="创建时间:">{{ form.createTime }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="cron表达式:">{{ form.cronExpression }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="下次执行时间:">{{ parseTime(form.nextValidTime) }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="调用目标方法:">{{ form.invokeTarget }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务状态:"> |
| | | <div v-if="form.status == 0">正常</div> |
| | | <div v-else-if="form.status == 1">暂停</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否并发:"> |
| | | <div v-if="form.concurrent == 0">允许</div> |
| | | <div v-else-if="form.concurrent == 1">禁止</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="执行策略:"> |
| | | <div v-if="form.misfirePolicy == 0">默认策略</div> |
| | | <div v-else-if="form.misfirePolicy == 1">立即执行</div> |
| | | <div v-else-if="form.misfirePolicy == 2">执行一次</div> |
| | | <div v-else-if="form.misfirePolicy == 3">放弃执行</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="openView = false">关 闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 任务日志详细 --> |
| | | <el-dialog title="任务详细" v-model="openView" width="700px" append-to-body> |
| | | <el-form :model="form" label-width="120px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务编号:">{{ form.jobId }}</el-form-item> |
| | | <el-form-item label="任务名称:">{{ form.jobName }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务分组:">{{ jobGroupFormat(form) }}</el-form-item> |
| | | <el-form-item label="创建时间:">{{ form.createTime }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="cron表达式:">{{ form.cronExpression }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="下次执行时间:">{{ parseTime(form.nextValidTime) }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="调用目标方法:">{{ form.invokeTarget }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="任务状态:"> |
| | | <div v-if="form.status == 0">正常</div> |
| | | <div v-else-if="form.status == 1">暂停</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否并发:"> |
| | | <div v-if="form.concurrent == 0">允许</div> |
| | | <div v-else-if="form.concurrent == 1">禁止</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="执行策略:"> |
| | | <div v-if="form.misfirePolicy == 0">默认策略</div> |
| | | <div v-else-if="form.misfirePolicy == 1">立即执行</div> |
| | | <div v-else-if="form.misfirePolicy == 2">执行一次</div> |
| | | <div v-else-if="form.misfirePolicy == 3">放弃执行</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="openView = false">关 闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Job"> |
| | | import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job"; |
| | | import Crontab from '@/components/Crontab' |
| | | const router = useRouter(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_job_group, sys_job_status } = proxy.useDict("sys_job_group", "sys_job_status"); |
| | | import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job" |
| | | import Crontab from "@/components/Crontab" |
| | | const router = useRouter() |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_job_group, sys_job_status } = proxy.useDict("sys_job_group", "sys_job_status") |
| | | |
| | | const jobList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const openView = ref(false); |
| | | const openCron = ref(false); |
| | | const expression = ref(""); |
| | | const jobList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | const openView = ref(false) |
| | | const openCron = ref(false) |
| | | const expression = ref("") |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | pageSize: 10, |
| | | jobName: undefined, |
| | | jobGroup: undefined, |
| | | status: undefined |
| | | status: undefined, |
| | | }, |
| | | rules: { |
| | | jobName: [{ required: true, message: "任务名称不能为空", trigger: "blur" }], |
| | | invokeTarget: [{ required: true, message: "调用目标字符串不能为空", trigger: "blur" }], |
| | | cronExpression: [{ required: true, message: "cron执行表达式不能为空", trigger: "change" }] |
| | | } |
| | | }); |
| | | cronExpression: [{ required: true, message: "cron执行表达式不能为空", trigger: "change" }], |
| | | }, |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询定时任务列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listJob(queryParams.value).then(response => { |
| | | jobList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listJob(queryParams.value).then((response) => { |
| | | jobList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 任务组名字典翻译 */ |
| | | function jobGroupFormat(row, column) { |
| | | return proxy.selectDictLabel(sys_job_group.value, row.jobGroup); |
| | | return proxy.selectDictLabel(sys_job_group.value, row.jobGroup) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 表单重置 */ |
| | | function reset() { |
| | |
| | | cronExpression: undefined, |
| | | misfirePolicy: 1, |
| | | concurrent: 1, |
| | | status: "0" |
| | | }; |
| | | proxy.resetForm("jobRef"); |
| | | status: "0", |
| | | } |
| | | proxy.resetForm("jobRef") |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | // 多选框选中数据 |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.jobId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.jobId) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | // 更多操作触发 |
| | | function handleCommand(command, row) { |
| | | switch (command) { |
| | | case "handleRun": |
| | | handleRun(row); |
| | | break; |
| | | handleRun(row) |
| | | break |
| | | case "handleView": |
| | | handleView(row); |
| | | break; |
| | | handleView(row) |
| | | break |
| | | case "handleJobLog": |
| | | handleJobLog(row); |
| | | break; |
| | | handleJobLog(row) |
| | | break |
| | | default: |
| | | break; |
| | | break |
| | | } |
| | | } |
| | | // 任务状态修改 |
| | | function handleStatusChange(row) { |
| | | let text = row.status === "0" ? "启用" : "停用"; |
| | | proxy.$modal.confirm('确认要"' + text + '""' + row.jobName + '"任务吗?').then(function () { |
| | | return changeJobStatus(row.jobId, row.status); |
| | | }).then(() => { |
| | | proxy.$modal.msgSuccess(text + "成功"); |
| | | }).catch(function () { |
| | | row.status = row.status === "0" ? "1" : "0"; |
| | | }); |
| | | let text = row.status === "0" ? "启用" : "停用" |
| | | proxy.$modal |
| | | .confirm('确认要"' + text + '""' + row.jobName + '"任务吗?') |
| | | .then(function () { |
| | | return changeJobStatus(row.jobId, row.status) |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess(text + "成功") |
| | | }) |
| | | .catch(function () { |
| | | row.status = row.status === "0" ? "1" : "0" |
| | | }) |
| | | } |
| | | /* 立即执行一次 */ |
| | | function handleRun(row) { |
| | | proxy.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function () { |
| | | return runJob(row.jobId, row.jobGroup); |
| | | }).then(() => { |
| | | proxy.$modal.msgSuccess("执行成功");}) |
| | | .catch(() => {}); |
| | | proxy.$modal |
| | | .confirm('确认要立即执行一次"' + row.jobName + '"任务吗?') |
| | | .then(function () { |
| | | return runJob(row.jobId, row.jobGroup) |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess("执行成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 任务详细信息 */ |
| | | function handleView(row) { |
| | | getJob(row.jobId).then(response => { |
| | | form.value = response.data; |
| | | openView.value = true; |
| | | }); |
| | | getJob(row.jobId).then((response) => { |
| | | form.value = response.data |
| | | openView.value = true |
| | | }) |
| | | } |
| | | /** cron表达式按钮操作 */ |
| | | function handleShowCron() { |
| | | expression.value = form.value.cronExpression; |
| | | openCron.value = true; |
| | | expression.value = form.value.cronExpression |
| | | openCron.value = true |
| | | } |
| | | /** 确定后回传值 */ |
| | | function crontabFill(value) { |
| | | form.value.cronExpression = value; |
| | | form.value.cronExpression = value |
| | | } |
| | | /** 任务日志列表查询 */ |
| | | function handleJobLog(row) { |
| | | const jobId = row.jobId || 0; |
| | | router.push('/monitor/job-log/index/' + jobId) |
| | | const jobId = row.jobId || 0 |
| | | router.push("/monitor/job-log/index/" + jobId) |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | open.value = true; |
| | | title.value = "添加任务"; |
| | | reset() |
| | | open.value = true |
| | | title.value = "添加任务" |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const jobId = row.jobId || ids.value; |
| | | getJob(jobId).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改任务"; |
| | | }); |
| | | reset() |
| | | const jobId = row.jobId || ids.value |
| | | getJob(jobId).then((response) => { |
| | | form.value = response.data |
| | | open.value = true |
| | | title.value = "修改任务" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["jobRef"].validate(valid => { |
| | | proxy.$refs["jobRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.jobId != undefined) { |
| | | updateJob(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updateJob(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addJob(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addJob(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const jobIds = row.jobId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?').then(function () { |
| | | return delJob(jobIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const jobIds = row.jobId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?') |
| | | .then(function () { |
| | | return delJob(jobIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("monitor/job/export", { |
| | | ...queryParams.value, |
| | | }, `job_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "monitor/job/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `job_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px"> |
| | | <el-form-item label="登录地址" prop="ipaddr"> |
| | | <el-input |
| | | v-model="queryParams.ipaddr" |
| | | placeholder="请输入登录地址" |
| | | clearable |
| | | style="width: 240px;" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input |
| | | v-model="queryParams.userName" |
| | | placeholder="请输入用户名称" |
| | | clearable |
| | | style="width: 240px;" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | placeholder="登录状态" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_common_status" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="登录时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="登录地址" prop="ipaddr"> |
| | | <el-input |
| | | v-model="queryParams.ipaddr" |
| | | placeholder="请输入登录地址" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input |
| | | v-model="queryParams.userName" |
| | | placeholder="请输入用户名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="登录状态" clearable style="width: 240px"> |
| | | <el-option v-for="dict in sys_common_status" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="登录时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box" style="margin-top: 0"> |
| | | <el-row :gutter="10" class="mb8" style="margin-top: 8px"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['monitor:logininfor:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['monitor:logininfor:remove']" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="Delete" @click="handleClean" v-hasPermi="['monitor:logininfor:remove']" |
| | | >清空</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | @click="handleClean" |
| | | v-hasPermi="['monitor:logininfor:remove']" |
| | | >清空</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="primary" |
| | | plain |
| | | icon="Unlock" |
| | | :disabled="single" |
| | | @click="handleUnlock" |
| | | v-hasPermi="['monitor:logininfor:unlock']" |
| | | >解锁</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Unlock" |
| | | :disabled="single" |
| | | @click="handleUnlock" |
| | | v-hasPermi="['monitor:logininfor:unlock']" |
| | | >解锁</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:logininfor:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:logininfor:export']" |
| | | >导出</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table ref="logininforRef" v-loading="loading" :data="logininforList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="访问编号" align="center" prop="infoId" /> |
| | | <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" /> |
| | | <el-table-column label="地址" align="center" prop="ipaddr" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作系统" align="center" prop="os" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录状态" align="center" prop="status"> |
| | | <el-table |
| | | ref="logininforRef" |
| | | v-loading="loading" |
| | | :data="logininforList" |
| | | @selection-change="handleSelectionChange" |
| | | :default-sort="defaultSort" |
| | | @sort-change="handleSortChange" |
| | | > |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="访问编号" align="center" prop="infoId" /> |
| | | <el-table-column |
| | | label="用户名称" |
| | | align="center" |
| | | prop="userName" |
| | | :show-overflow-tooltip="true" |
| | | sortable="custom" |
| | | :sort-orders="['descending', 'ascending']" |
| | | /> |
| | | <el-table-column label="地址" align="center" prop="ipaddr" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作系统" align="center" prop="os" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录状态" align="center" prop="status"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_common_status" :value="scope.row.status" /> |
| | | <dict-tag :options="sys_common_status" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="描述" align="center" prop="msg" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="访问时间" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180"> |
| | | </el-table-column> |
| | | <el-table-column label="描述" align="center" prop="msg" :show-overflow-tooltip="true" /> |
| | | <el-table-column |
| | | label="访问时间" |
| | | align="center" |
| | | prop="loginTime" |
| | | sortable="custom" |
| | | :sort-orders="['descending', 'ascending']" |
| | | width="180" |
| | | > |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.loginTime) }}</span> |
| | | <span>{{ parseTime(scope.row.loginTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Logininfor"> |
| | | import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/monitor/logininfor"; |
| | | import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/monitor/logininfor" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_common_status } = proxy.useDict("sys_common_status"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_common_status } = proxy.useDict("sys_common_status") |
| | | |
| | | const logininforList = ref([]); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const selectName = ref(""); |
| | | const total = ref(0); |
| | | const dateRange = ref([]); |
| | | const defaultSort = ref({ prop: "loginTime", order: "descending" }); |
| | | const logininforList = ref([]) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const selectName = ref("") |
| | | const total = ref(0) |
| | | const dateRange = ref([]) |
| | | const defaultSort = ref({ prop: "loginTime", order: "descending" }) |
| | | |
| | | // 查询参数 |
| | | const queryParams = ref({ |
| | |
| | | userName: undefined, |
| | | status: undefined, |
| | | orderByColumn: undefined, |
| | | isAsc: undefined |
| | | }); |
| | | isAsc: undefined, |
| | | }) |
| | | |
| | | /** 查询登录日志列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | list(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
| | | logininforList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | list(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => { |
| | | logininforList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | queryParams.value.pageNum = 1; |
| | | proxy.$refs["logininforRef"].sort(defaultSort.value.prop, defaultSort.value.order); |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | queryParams.value.pageNum = 1 |
| | | proxy.$refs["logininforRef"].sort(defaultSort.value.prop, defaultSort.value.order) |
| | | } |
| | | /** 多选框选中数据 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.infoId); |
| | | multiple.value = !selection.length; |
| | | single.value = selection.length != 1; |
| | | selectName.value = selection.map(item => item.userName); |
| | | ids.value = selection.map((item) => item.infoId) |
| | | multiple.value = !selection.length |
| | | single.value = selection.length != 1 |
| | | selectName.value = selection.map((item) => item.userName) |
| | | } |
| | | /** 排序触发事件 */ |
| | | function handleSortChange(column, prop, order) { |
| | | queryParams.value.orderByColumn = column.prop; |
| | | queryParams.value.isAsc = column.order; |
| | | getList(); |
| | | queryParams.value.orderByColumn = column.prop |
| | | queryParams.value.isAsc = column.order |
| | | getList() |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const infoIds = row.infoId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function () { |
| | | return delLogininfor(infoIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const infoIds = row.infoId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?') |
| | | .then(function () { |
| | | return delLogininfor(infoIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 清空按钮操作 */ |
| | | function handleClean() { |
| | | proxy.$modal.confirm("是否确认清空所有登录日志数据项?").then(function () { |
| | | return cleanLogininfor(); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("清空成功"); |
| | | }).catch(() => {}); |
| | | proxy.$modal |
| | | .confirm("是否确认清空所有登录日志数据项?") |
| | | .then(function () { |
| | | return cleanLogininfor() |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("清空成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 解锁按钮操作 */ |
| | | function handleUnlock() { |
| | | const username = selectName.value; |
| | | proxy.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function () { |
| | | return unlockLogininfor(username); |
| | | }).then(() => { |
| | | proxy.$modal.msgSuccess("用户" + username + "解锁成功"); |
| | | }).catch(() => {}); |
| | | const username = selectName.value |
| | | proxy.$modal |
| | | .confirm('是否确认解锁用户"' + username + '"数据项?') |
| | | .then(function () { |
| | | return unlockLogininfor(username) |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess("用户" + username + "解锁成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("monitor/logininfor/export", { |
| | | ...queryParams.value, |
| | | }, `config_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "monitor/logininfor/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `config_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true"> |
| | | <el-form-item label="登录地址" prop="ipaddr"> |
| | | <el-input |
| | | v-model="queryParams.ipaddr" |
| | | placeholder="请输入登录地址" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input |
| | | v-model="queryParams.userName" |
| | | placeholder="请输入用户名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="登录地址" prop="ipaddr"> |
| | | <el-input |
| | | v-model="queryParams.ipaddr" |
| | | placeholder="请输入登录地址" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input |
| | | v-model="queryParams.userName" |
| | | placeholder="请输入用户名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table |
| | | v-loading="loading" |
| | | :data="onlineList.slice((pageNum - 1) * pageSize, pageNum * pageSize)" |
| | | style="width: 100%;" |
| | | > |
| | | <el-table-column label="序号" width="50" type="index" align="center"> |
| | | <template #default="scope"> |
| | | <span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="会话编号" align="center" prop="tokenId" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录名称" align="center" prop="userName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="所属部门" align="center" prop="deptName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="主机" align="center" prop="ipaddr" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作系统" align="center" prop="os" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录时间" align="center" prop="loginTime" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.loginTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Delete" @click="handleForceLogout(scope.row)" v-hasPermi="['monitor:online:forceLogout']">强退</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | |
| | | <pagination v-show="total > 0" :total="total" v-model:page="pageNum" v-model:limit="pageSize" /> |
| | | </div> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <el-table |
| | | v-loading="loading" |
| | | :data="onlineList.slice((pageNum - 1) * pageSize, pageNum * pageSize)" |
| | | style="width: 100%" |
| | | > |
| | | <el-table-column label="序号" width="60" type="index" align="center"> |
| | | <template #default="scope"> |
| | | <span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="会话编号" align="center" prop="tokenId" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录名称" align="center" prop="userName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="所属部门" align="center" prop="deptName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="主机" align="center" prop="ipaddr" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作系统" align="center" prop="os" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="登录时间" align="center" prop="loginTime" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.loginTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleForceLogout(scope.row)" |
| | | v-hasPermi="['monitor:online:forceLogout']" |
| | | >强退</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination v-show="total > 0" :total="total" v-model:page="pageNum" v-model:limit="pageSize" /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Online"> |
| | | import { forceLogout, list as initData } from "@/api/monitor/online"; |
| | | import { forceLogout, list as initData } from "@/api/monitor/online" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { proxy } = getCurrentInstance() |
| | | |
| | | const onlineList = ref([]); |
| | | const loading = ref(true); |
| | | const total = ref(0); |
| | | const pageNum = ref(1); |
| | | const pageSize = ref(10); |
| | | const onlineList = ref([]) |
| | | const loading = ref(true) |
| | | const total = ref(0) |
| | | const pageNum = ref(1) |
| | | const pageSize = ref(10) |
| | | |
| | | const queryParams = ref({ |
| | | ipaddr: undefined, |
| | | userName: undefined |
| | | }); |
| | | userName: undefined, |
| | | }) |
| | | |
| | | /** 查询登录日志列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | initData(queryParams.value).then(response => { |
| | | onlineList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | initData(queryParams.value).then((response) => { |
| | | onlineList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | pageNum.value = 1; |
| | | getList(); |
| | | pageNum.value = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 强退按钮操作 */ |
| | | function handleForceLogout(row) { |
| | | proxy.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?').then(function () { |
| | | return forceLogout(row.tokenId); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | proxy.$modal |
| | | .confirm('是否确认强退名称为"' + row.userName + '"的用户?') |
| | | .then(function () { |
| | | return forceLogout(row.tokenId) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px"> |
| | | <el-form-item label="操作地址" prop="operIp"> |
| | | <el-input |
| | | v-model="queryParams.operIp" |
| | | placeholder="请输入操作地址" |
| | | clearable |
| | | style="width: 240px;" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="系统模块" prop="title"> |
| | | <el-input |
| | | v-model="queryParams.title" |
| | | placeholder="请输入系统模块" |
| | | clearable |
| | | style="width: 240px;" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="操作人员" prop="operName"> |
| | | <el-input |
| | | v-model="queryParams.operName" |
| | | placeholder="请输入操作人员" |
| | | clearable |
| | | style="width: 240px;" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="类型" prop="businessType"> |
| | | <el-select |
| | | v-model="queryParams.businessType" |
| | | placeholder="操作类型" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_oper_type" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | placeholder="操作状态" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_common_status" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="操作时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="操作地址" prop="operIp"> |
| | | <el-input |
| | | v-model="queryParams.operIp" |
| | | placeholder="请输入操作地址" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="系统模块" prop="title"> |
| | | <el-input |
| | | v-model="queryParams.title" |
| | | placeholder="请输入系统模块" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="操作人员" prop="operName"> |
| | | <el-input |
| | | v-model="queryParams.operName" |
| | | placeholder="请输入操作人员" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="类型" prop="businessType"> |
| | | <el-select v-model="queryParams.businessType" placeholder="操作类型" clearable style="width: 100%"> |
| | | <el-option v-for="dict in sys_oper_type" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="操作状态" clearable style="width: 100%"> |
| | | <el-option v-for="dict in sys_common_status" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="操作时间" style="width: 320px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box" style="margin-top: 0"> |
| | | <el-row :gutter="10" class="mb8" style="margin-top: 8px"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['monitor:operlog:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['monitor:operlog:remove']" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="Delete" @click="handleClean" v-hasPermi="['monitor:operlog:remove']" |
| | | >清空</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | @click="handleClean" |
| | | v-hasPermi="['monitor:operlog:remove']" |
| | | >清空</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:operlog:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['monitor:operlog:export']" |
| | | >导出</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table ref="operlogRef" v-loading="loading" :data="operlogList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange"> |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column label="日志编号" align="center" prop="operId" /> |
| | | <el-table-column label="系统模块" align="center" prop="title" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作类型" align="center" prop="businessType"> |
| | | <el-table |
| | | ref="operlogRef" |
| | | v-loading="loading" |
| | | :data="operlogList" |
| | | @selection-change="handleSelectionChange" |
| | | :default-sort="defaultSort" |
| | | @sort-change="handleSortChange" |
| | | > |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column label="日志编号" align="center" prop="operId" /> |
| | | <el-table-column label="系统模块" align="center" prop="title" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作类型" align="center" prop="businessType"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_oper_type" :value="scope.row.businessType" /> |
| | | <dict-tag :options="sys_oper_type" :value="scope.row.businessType" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作人员" align="center" width="110" prop="operName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" /> |
| | | <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作状态" align="center" prop="status"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="操作人员" |
| | | align="center" |
| | | width="110" |
| | | prop="operName" |
| | | :show-overflow-tooltip="true" |
| | | sortable="custom" |
| | | :sort-orders="['descending', 'ascending']" |
| | | /> |
| | | <el-table-column label="操作地址" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="操作状态" align="center" prop="status"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_common_status" :value="scope.row.status" /> |
| | | <dict-tag :options="sys_common_status" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作日期" align="center" prop="operTime" width="180" sortable="custom" :sort-orders="['descending', 'ascending']"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="操作日期" |
| | | align="center" |
| | | prop="operTime" |
| | | width="180" |
| | | sortable="custom" |
| | | :sort-orders="['descending', 'ascending']" |
| | | > |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.operTime) }}</span> |
| | | <span>{{ parseTime(scope.row.operTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="消耗时间" align="center" prop="costTime" width="110" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']"> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="消耗时间" |
| | | align="center" |
| | | prop="costTime" |
| | | width="110" |
| | | :show-overflow-tooltip="true" |
| | | sortable="custom" |
| | | :sort-orders="['descending', 'ascending']" |
| | | > |
| | | <template #default="scope"> |
| | | <span>{{ scope.row.costTime }}毫秒</span> |
| | | <span>{{ scope.row.costTime }}毫秒</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="View" @click="handleView(scope.row, scope.index)" v-hasPermi="['monitor:operlog:query']">详细</el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="View" |
| | | @click="handleView(scope.row, scope.index)" |
| | | v-hasPermi="['monitor:operlog:query']" |
| | | >详细</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- 操作日志详细 --> |
| | | <el-dialog title="操作日志详细" v-model="open" width="800px" append-to-body> |
| | | <el-form :model="form" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item> |
| | | <el-form-item |
| | | label="登录信息:" |
| | | >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item> |
| | | <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="操作方法:">{{ form.method }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="操作状态:"> |
| | | <div v-if="form.status === 0">正常</div> |
| | | <div v-else-if="form.status === 1">失败</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="消耗时间:">{{ form.costTime }}毫秒</el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="open = false">关 闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 操作日志详细 --> |
| | | <el-dialog title="操作日志详细" v-model="open" width="800px" append-to-body> |
| | | <el-form :model="form" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item> |
| | | <el-form-item label="登录信息:" |
| | | >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item |
| | | > |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="请求地址:">{{ form.operUrl }}</el-form-item> |
| | | <el-form-item label="请求方式:">{{ form.requestMethod }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="操作方法:">{{ form.method }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="请求参数:">{{ form.operParam }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="返回参数:">{{ form.jsonResult }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="操作状态:"> |
| | | <div v-if="form.status === 0">正常</div> |
| | | <div v-else-if="form.status === 1">失败</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="消耗时间:">{{ form.costTime }}毫秒</el-form-item> |
| | | </el-col> |
| | | <el-col :span="8"> |
| | | <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="open = false">关 闭</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Operlog"> |
| | | import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog"; |
| | | import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_oper_type, sys_common_status } = proxy.useDict("sys_oper_type","sys_common_status"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_oper_type, sys_common_status } = proxy.useDict("sys_oper_type", "sys_common_status") |
| | | |
| | | const operlogList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const dateRange = ref([]); |
| | | const defaultSort = ref({ prop: "operTime", order: "descending" }); |
| | | const operlogList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | const dateRange = ref([]) |
| | | const defaultSort = ref({ prop: "operTime", order: "descending" }) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | title: undefined, |
| | | operName: undefined, |
| | | businessType: undefined, |
| | | status: undefined |
| | | } |
| | | }); |
| | | status: undefined, |
| | | }, |
| | | }) |
| | | |
| | | const { queryParams, form } = toRefs(data); |
| | | const { queryParams, form } = toRefs(data) |
| | | |
| | | /** 查询登录日志 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | list(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
| | | operlogList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | list(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => { |
| | | operlogList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 操作日志类型字典翻译 */ |
| | | function typeFormat(row, column) { |
| | | return proxy.selectDictLabel(sys_oper_type.value, row.businessType); |
| | | return proxy.selectDictLabel(sys_oper_type.value, row.businessType) |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | queryParams.value.pageNum = 1; |
| | | proxy.$refs["operlogRef"].sort(defaultSort.value.prop, defaultSort.value.order); |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | queryParams.value.pageNum = 1 |
| | | proxy.$refs["operlogRef"].sort(defaultSort.value.prop, defaultSort.value.order) |
| | | } |
| | | /** 多选框选中数据 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.operId); |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.operId) |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 排序触发事件 */ |
| | | function handleSortChange(column, prop, order) { |
| | | queryParams.value.orderByColumn = column.prop; |
| | | queryParams.value.isAsc = column.order; |
| | | getList(); |
| | | queryParams.value.orderByColumn = column.prop |
| | | queryParams.value.isAsc = column.order |
| | | getList() |
| | | } |
| | | /** 详细按钮操作 */ |
| | | function handleView(row) { |
| | | open.value = true; |
| | | form.value = row; |
| | | open.value = true |
| | | form.value = row |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const operIds = row.operId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function () { |
| | | return delOperlog(operIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const operIds = row.operId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除日志编号为"' + operIds + '"的数据项?') |
| | | .then(function () { |
| | | return delOperlog(operIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 清空按钮操作 */ |
| | | function handleClean() { |
| | | proxy.$modal.confirm("是否确认清空所有操作日志数据项?").then(function () { |
| | | return cleanOperlog(); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("清空成功"); |
| | | }).catch(() => {}); |
| | | proxy.$modal |
| | | .confirm("是否确认清空所有操作日志数据项?") |
| | | .then(function () { |
| | | return cleanOperlog() |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("清空成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("monitor/operlog/export",{ |
| | | ...queryParams.value, |
| | | }, `config_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "monitor/operlog/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `config_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px"> |
| | | <el-form-item label="参数名称" prop="configName"> |
| | | <el-input |
| | | v-model="queryParams.configName" |
| | | placeholder="请输入参数名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="参数键名" prop="configKey"> |
| | | <el-input |
| | | v-model="queryParams.configKey" |
| | | placeholder="请输入参数键名" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="系统内置" prop="configType"> |
| | | <el-select v-model="queryParams.configType" placeholder="系统内置" clearable> |
| | | <el-option |
| | | v-for="dict in sys_yes_no" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 340px;"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="参数名称" prop="configName"> |
| | | <el-input |
| | | v-model="queryParams.configName" |
| | | placeholder="请输入参数名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="参数键名" prop="configKey"> |
| | | <el-input |
| | | v-model="queryParams.configKey" |
| | | placeholder="请输入参数键名" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="系统内置" prop="configType"> |
| | | <el-select v-model="queryParams.configType" placeholder="系统内置" clearable> |
| | | <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 340px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box" style="margin-top: 0"> |
| | | <el-row :gutter="10" class="mb8" style="margin-top: 8px"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:config:add']" |
| | | >新增</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:config:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:config:edit']" |
| | | >修改</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:config:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:config:remove']" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:config:export']" |
| | | >导出</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:config:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:config:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Refresh" |
| | | @click="handleRefreshCache" |
| | | v-hasPermi="['system:config:remove']" |
| | | >刷新缓存</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="参数主键" align="center" prop="configId" /> |
| | | <el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="参数键值" align="center" prop="configValue" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="系统内置" align="center" prop="configType"> |
| | | type="danger" |
| | | plain |
| | | icon="Refresh" |
| | | @click="handleRefreshCache" |
| | | v-hasPermi="['system:config:remove']" |
| | | >刷新缓存</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="参数主键" align="center" prop="configId" /> |
| | | <el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="参数键值" align="center" prop="configValue" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="系统内置" align="center" prop="configType"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_yes_no" :value="scope.row.configType" /> |
| | | <dict-tag :options="sys_yes_no" :value="scope.row.configType" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | </el-table-column> |
| | | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:config:edit']" >修改</el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:config:remove']">删除</el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:config:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:config:remove']" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- 添加或修改参数配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="configRef" :model="form" :rules="rules" label-width="100px"> |
| | | <el-form-item label="参数名称" prop="configName"> |
| | | <el-input v-model="form.configName" placeholder="请输入参数名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="参数键名" prop="configKey"> |
| | | <el-input v-model="form.configKey" placeholder="请输入参数键名" /> |
| | | </el-form-item> |
| | | <el-form-item label="参数键值" prop="configValue"> |
| | | <el-input v-model="form.configValue" placeholder="请输入参数键值" /> |
| | | </el-form-item> |
| | | <el-form-item label="系统内置" prop="configType"> |
| | | <el-radio-group v-model="form.configType"> |
| | | <el-radio |
| | | v-for="dict in sys_yes_no" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 添加或修改参数配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="configRef" :model="form" :rules="rules" label-width="100px"> |
| | | <el-form-item label="参数名称" prop="configName"> |
| | | <el-input v-model="form.configName" placeholder="请输入参数名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="参数键名" prop="configKey"> |
| | | <el-input v-model="form.configKey" placeholder="请输入参数键名" /> |
| | | </el-form-item> |
| | | <el-form-item label="参数键值" prop="configValue"> |
| | | <el-input v-model="form.configValue" placeholder="请输入参数键值" /> |
| | | </el-form-item> |
| | | <el-form-item label="系统内置" prop="configType"> |
| | | <el-radio-group v-model="form.configType"> |
| | | <el-radio v-for="dict in sys_yes_no" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Config"> |
| | | import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config"; |
| | | import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_yes_no } = proxy.useDict("sys_yes_no"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_yes_no } = proxy.useDict("sys_yes_no") |
| | | |
| | | const configList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const dateRange = ref([]); |
| | | const configList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | const dateRange = ref([]) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | pageSize: 10, |
| | | configName: undefined, |
| | | configKey: undefined, |
| | | configType: undefined |
| | | configType: undefined, |
| | | }, |
| | | rules: { |
| | | configName: [{ required: true, message: "参数名称不能为空", trigger: "blur" }], |
| | | configKey: [{ required: true, message: "参数键名不能为空", trigger: "blur" }], |
| | | configValue: [{ required: true, message: "参数键值不能为空", trigger: "blur" }] |
| | | } |
| | | }); |
| | | configValue: [{ required: true, message: "参数键值不能为空", trigger: "blur" }], |
| | | }, |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询参数列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listConfig(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
| | | configList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listConfig(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => { |
| | | configList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 表单重置 */ |
| | | function reset() { |
| | |
| | | configKey: undefined, |
| | | configValue: undefined, |
| | | configType: "Y", |
| | | remark: undefined |
| | | }; |
| | | proxy.resetForm("configRef"); |
| | | remark: undefined, |
| | | } |
| | | proxy.resetForm("configRef") |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 多选框选中数据 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.configId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.configId) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | open.value = true; |
| | | title.value = "添加参数"; |
| | | reset() |
| | | open.value = true |
| | | title.value = "添加参数" |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const configId = row.configId || ids.value; |
| | | getConfig(configId).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改参数"; |
| | | }); |
| | | reset() |
| | | const configId = row.configId || ids.value |
| | | getConfig(configId).then((response) => { |
| | | form.value = response.data |
| | | open.value = true |
| | | title.value = "修改参数" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["configRef"].validate(valid => { |
| | | proxy.$refs["configRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.configId != undefined) { |
| | | updateConfig(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updateConfig(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addConfig(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addConfig(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const configIds = row.configId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function () { |
| | | return delConfig(configIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const configIds = row.configId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除参数编号为"' + configIds + '"的数据项?') |
| | | .then(function () { |
| | | return delConfig(configIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("system/config/export", { |
| | | ...queryParams.value |
| | | }, `config_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "system/config/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `config_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | /** 刷新缓存按钮操作 */ |
| | | function handleRefreshCache() { |
| | | refreshCache().then(() => { |
| | | proxy.$modal.msgSuccess("刷新缓存成功"); |
| | | }); |
| | | proxy.$modal.msgSuccess("刷新缓存成功") |
| | | }) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> |
| | | <el-form-item label="部门名称" prop="deptName"> |
| | | <el-input |
| | | v-model="queryParams.deptName" |
| | | placeholder="请输入部门名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="部门状态" clearable style="width: 200px"> |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="部门名称" prop="deptName"> |
| | | <el-input |
| | | v-model="queryParams.deptName" |
| | | placeholder="请输入部门名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="部门状态" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item style="float: right"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:dept:add']" |
| | | >新增</el-button |
| | | > |
| | | <el-button type="info" plain icon="Sort" @click="toggleExpandAll">展开/折叠</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:dept:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="Sort" |
| | | @click="toggleExpandAll" |
| | | >展开/折叠</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <el-table |
| | | v-if="refreshTable" |
| | | v-loading="loading" |
| | | :data="deptList" |
| | | row-key="deptId" |
| | | :default-expand-all="isExpandAll" |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | > |
| | | <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> |
| | | <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> |
| | | <el-table-column prop="status" label="状态" width="100"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="200"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:dept:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']" |
| | | >新增</el-button |
| | | > |
| | | <el-button |
| | | v-if="scope.row.parentId != 0" |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:dept:remove']" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | |
| | | <el-table |
| | | v-if="refreshTable" |
| | | v-loading="loading" |
| | | :data="deptList" |
| | | row-key="deptId" |
| | | :default-expand-all="isExpandAll" |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | > |
| | | <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> |
| | | <el-table-column prop="orderNum" label="排序" width="200"></el-table-column> |
| | | <el-table-column prop="status" label="状态" width="100"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="200"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']">修改</el-button> |
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']">新增</el-button> |
| | | <el-button v-if="scope.row.parentId != 0" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <!-- 添加或修改部门对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body> |
| | | <el-form ref="deptRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-row> |
| | | <el-col :span="24" v-if="form.parentId !== 0"> |
| | | <el-form-item label="上级部门" prop="parentId"> |
| | | <el-tree-select |
| | | v-model="form.parentId" |
| | | :data="deptOptions" |
| | | :props="{ value: 'deptId', label: 'deptName', children: 'children' }" |
| | | value-key="deptId" |
| | | placeholder="选择上级部门" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门名称" prop="deptName"> |
| | | <el-input v-model="form.deptName" placeholder="请输入部门名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="显示排序" prop="orderNum"> |
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="负责人" prop="leader"> |
| | | <el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系电话" prop="phone"> |
| | | <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 添加或修改部门对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body> |
| | | <el-form ref="deptRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-row> |
| | | <el-col :span="24" v-if="form.parentId !== 0"> |
| | | <el-form-item label="上级部门" prop="parentId"> |
| | | <el-tree-select |
| | | v-model="form.parentId" |
| | | :data="deptOptions" |
| | | :props="{ value: 'deptId', label: 'deptName', children: 'children' }" |
| | | value-key="deptId" |
| | | placeholder="选择上级部门" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门名称" prop="deptName"> |
| | | <el-input v-model="form.deptName" placeholder="请输入部门名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="显示排序" prop="orderNum"> |
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="负责人" prop="leader"> |
| | | <el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系电话" prop="phone"> |
| | | <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Dept"> |
| | | import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; |
| | | import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable") |
| | | |
| | | const deptList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const title = ref(""); |
| | | const deptOptions = ref([]); |
| | | const isExpandAll = ref(true); |
| | | const refreshTable = ref(true); |
| | | const deptList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const title = ref("") |
| | | const deptOptions = ref([]) |
| | | const isExpandAll = ref(true) |
| | | const refreshTable = ref(true) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | | queryParams: { |
| | | deptName: undefined, |
| | | status: undefined |
| | | status: undefined, |
| | | }, |
| | | rules: { |
| | | parentId: [{ required: true, message: "上级部门不能为空", trigger: "blur" }], |
| | | deptName: [{ required: true, message: "部门名称不能为空", trigger: "blur" }], |
| | | orderNum: [{ required: true, message: "显示排序不能为空", trigger: "blur" }], |
| | | email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }], |
| | | phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }] |
| | | phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询部门列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listDept(queryParams.value).then(response => { |
| | | deptList.value = proxy.handleTree(response.data, "deptId"); |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listDept(queryParams.value).then((response) => { |
| | | deptList.value = proxy.handleTree(response.data, "deptId") |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 表单重置 */ |
| | | function reset() { |
| | |
| | | leader: undefined, |
| | | phone: undefined, |
| | | email: undefined, |
| | | status: "0" |
| | | }; |
| | | proxy.resetForm("deptRef"); |
| | | status: "0", |
| | | } |
| | | proxy.resetForm("deptRef") |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | getList(); |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd(row) { |
| | | reset(); |
| | | listDept().then(response => { |
| | | deptOptions.value = proxy.handleTree(response.data, "deptId"); |
| | | }); |
| | | reset() |
| | | listDept().then((response) => { |
| | | deptOptions.value = proxy.handleTree(response.data, "deptId") |
| | | }) |
| | | if (row != undefined) { |
| | | form.value.parentId = row.deptId; |
| | | form.value.parentId = row.deptId |
| | | } |
| | | open.value = true; |
| | | title.value = "添加部门"; |
| | | open.value = true |
| | | title.value = "添加部门" |
| | | } |
| | | /** 展开/折叠操作 */ |
| | | function toggleExpandAll() { |
| | | refreshTable.value = false; |
| | | isExpandAll.value = !isExpandAll.value; |
| | | refreshTable.value = false |
| | | isExpandAll.value = !isExpandAll.value |
| | | nextTick(() => { |
| | | refreshTable.value = true; |
| | | }); |
| | | refreshTable.value = true |
| | | }) |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | listDeptExcludeChild(row.deptId).then(response => { |
| | | deptOptions.value = proxy.handleTree(response.data, "deptId"); |
| | | }); |
| | | getDept(row.deptId).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改部门"; |
| | | }); |
| | | reset() |
| | | listDeptExcludeChild(row.deptId).then((response) => { |
| | | deptOptions.value = proxy.handleTree(response.data, "deptId") |
| | | }) |
| | | getDept(row.deptId).then((response) => { |
| | | form.value = response.data |
| | | open.value = true |
| | | title.value = "修改部门" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["deptRef"].validate(valid => { |
| | | proxy.$refs["deptRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.deptId != undefined) { |
| | | updateDept(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updateDept(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addDept(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addDept(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | proxy.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() { |
| | | return delDept(row.deptId); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | proxy.$modal |
| | | .confirm('是否确认删除名称为"' + row.deptName + '"的数据项?') |
| | | .then(function () { |
| | | return delDept(row.deptId) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px"> |
| | | <el-form-item label="字典名称" prop="dictName"> |
| | | <el-input |
| | | v-model="queryParams.dictName" |
| | | placeholder="请输入字典名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="字典类型" prop="dictType"> |
| | | <el-input |
| | | v-model="queryParams.dictType" |
| | | placeholder="请输入字典类型" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | placeholder="字典状态" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="字典名称" prop="dictName"> |
| | | <el-input |
| | | v-model="queryParams.dictName" |
| | | placeholder="请输入字典名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="字典类型" prop="dictType"> |
| | | <el-input |
| | | v-model="queryParams.dictType" |
| | | placeholder="请输入字典类型" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="字典状态" clearable style="width: 240px"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box" style="margin-top: 0"> |
| | | <el-row :gutter="10" class="mb8" style="margin-top: 8px"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:dict:add']" |
| | | >新增</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:dict:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:dict:edit']" |
| | | >修改</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:dict:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:dict:remove']" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:dict:export']" |
| | | >导出</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:dict:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:dict:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Refresh" |
| | | @click="handleRefreshCache" |
| | | v-hasPermi="['system:dict:remove']" |
| | | >刷新缓存</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | type="danger" |
| | | plain |
| | | icon="Refresh" |
| | | @click="handleRefreshCache" |
| | | v-hasPermi="['system:dict:remove']" |
| | | >刷新缓存</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | <el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="字典编号" align="center" prop="dictId" /> |
| | | <el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="字典类型" align="center" :show-overflow-tooltip="true"> |
| | | <template #default="scope"> |
| | | <router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type"> |
| | | <span>{{ scope.row.dictType }}</span> |
| | | </router-link> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="状态" align="center" prop="status"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:dict:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:dict:remove']" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="字典编号" align="center" prop="dictId" /> |
| | | <el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true"/> |
| | | <el-table-column label="字典类型" align="center" :show-overflow-tooltip="true"> |
| | | <template #default="scope"> |
| | | <router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type"> |
| | | <span>{{ scope.row.dictType }}</span> |
| | | </router-link> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="状态" align="center" prop="status"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dict:edit']">修改</el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dict:remove']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- 添加或修改参数配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="dictRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form-item label="字典名称" prop="dictName"> |
| | | <el-input v-model="form.dictName" placeholder="请输入字典名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="字典类型" prop="dictType"> |
| | | <el-input v-model="form.dictType" placeholder="请输入字典类型" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 添加或修改参数配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="dictRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form-item label="字典名称" prop="dictName"> |
| | | <el-input v-model="form.dictName" placeholder="请输入字典名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="字典类型" prop="dictType"> |
| | | <el-input v-model="form.dictType" placeholder="请输入字典类型" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Dict"> |
| | | import useDictStore from '@/store/modules/dict' |
| | | import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type"; |
| | | import useDictStore from "@/store/modules/dict" |
| | | import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable") |
| | | |
| | | const typeList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const dateRange = ref([]); |
| | | const typeList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | const dateRange = ref([]) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | pageSize: 10, |
| | | dictName: undefined, |
| | | dictType: undefined, |
| | | status: undefined |
| | | status: undefined, |
| | | }, |
| | | rules: { |
| | | dictName: [{ required: true, message: "字典名称不能为空", trigger: "blur" }], |
| | | dictType: [{ required: true, message: "字典类型不能为空", trigger: "blur" }] |
| | | dictType: [{ required: true, message: "字典类型不能为空", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询字典类型列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listType(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
| | | typeList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listType(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => { |
| | | typeList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 表单重置 */ |
| | | function reset() { |
| | |
| | | dictName: undefined, |
| | | dictType: undefined, |
| | | status: "0", |
| | | remark: undefined |
| | | }; |
| | | proxy.resetForm("dictRef"); |
| | | remark: undefined, |
| | | } |
| | | proxy.resetForm("dictRef") |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | open.value = true; |
| | | title.value = "添加字典类型"; |
| | | reset() |
| | | open.value = true |
| | | title.value = "添加字典类型" |
| | | } |
| | | /** 多选框选中数据 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.dictId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.dictId) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const dictId = row.dictId || ids.value; |
| | | getType(dictId).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改字典类型"; |
| | | }); |
| | | reset() |
| | | const dictId = row.dictId || ids.value |
| | | getType(dictId).then((response) => { |
| | | form.value = response.data |
| | | open.value = true |
| | | title.value = "修改字典类型" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["dictRef"].validate(valid => { |
| | | proxy.$refs["dictRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.dictId != undefined) { |
| | | updateType(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updateType(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addType(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addType(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const dictIds = row.dictId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function() { |
| | | return delType(dictIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const dictIds = row.dictId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?') |
| | | .then(function () { |
| | | return delType(dictIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("system/dict/type/export", { |
| | | ...queryParams.value |
| | | }, `dict_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "system/dict/type/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `dict_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | /** 刷新缓存按钮操作 */ |
| | | function handleRefreshCache() { |
| | | refreshCache().then(() => { |
| | | proxy.$modal.msgSuccess("刷新成功"); |
| | | useDictStore().cleanDict(); |
| | | }); |
| | | proxy.$modal.msgSuccess("刷新成功") |
| | | useDictStore().cleanDict() |
| | | }) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> |
| | | <el-form-item label="菜单名称" prop="menuName"> |
| | | <el-input |
| | | v-model="queryParams.menuName" |
| | | placeholder="请输入菜单名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="菜单状态" clearable style="width: 200px"> |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="菜单名称" prop="menuName"> |
| | | <el-input |
| | | v-model="queryParams.menuName" |
| | | placeholder="请输入菜单名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="菜单状态" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item style="float: right"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:menu:add']" |
| | | >新增</el-button |
| | | > |
| | | <el-button type="info" plain icon="Sort" @click="toggleExpandAll">展开/折叠</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:menu:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="Sort" |
| | | @click="toggleExpandAll" |
| | | >展开/折叠</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <el-table |
| | | v-if="refreshTable" |
| | | v-loading="loading" |
| | | :data="menuList" |
| | | row-key="menuId" |
| | | :default-expand-all="isExpandAll" |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | > |
| | | <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column> |
| | | <el-table-column prop="icon" label="图标" align="center" width="100"> |
| | | <template #default="scope"> |
| | | <svg-icon :icon-class="scope.row.icon" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="orderNum" label="排序" width="60"></el-table-column> |
| | | <el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column> |
| | | <el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column> |
| | | <el-table-column prop="status" label="状态" width="80"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" width="160" prop="createTime"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="210" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:menu:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:menu:add']" |
| | | >新增</el-button |
| | | > |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:menu:remove']" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | |
| | | <el-table |
| | | v-if="refreshTable" |
| | | v-loading="loading" |
| | | :data="menuList" |
| | | row-key="menuId" |
| | | :default-expand-all="isExpandAll" |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | > |
| | | <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column> |
| | | <el-table-column prop="icon" label="图标" align="center" width="100"> |
| | | <template #default="scope"> |
| | | <svg-icon :icon-class="scope.row.icon" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="orderNum" label="排序" width="60"></el-table-column> |
| | | <el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column> |
| | | <el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column> |
| | | <el-table-column prop="status" label="状态" width="80"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" width="160" prop="createTime"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="210" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:menu:edit']">修改</el-button> |
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:menu:add']">新增</el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:menu:remove']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <!-- 添加或修改菜单对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="680px" append-to-body> |
| | | <el-form ref="menuRef" :model="form" :rules="rules" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="上级菜单"> |
| | | <el-tree-select |
| | | v-model="form.parentId" |
| | | :data="menuOptions" |
| | | :props="{ value: 'menuId', label: 'menuName', children: 'children' }" |
| | | value-key="menuId" |
| | | placeholder="选择上级菜单" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="菜单类型" prop="menuType"> |
| | | <el-radio-group v-model="form.menuType"> |
| | | <el-radio label="M">目录</el-radio> |
| | | <el-radio label="C">菜单</el-radio> |
| | | <el-radio label="F">按钮</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" v-if="form.menuType != 'F'"> |
| | | <el-form-item label="菜单图标" prop="icon"> |
| | | <el-popover |
| | | placement="bottom-start" |
| | | :width="540" |
| | | trigger="click" |
| | | > |
| | | <template #reference> |
| | | <el-input v-model="form.icon" placeholder="点击选择图标" @blur="showSelectIcon" readonly> |
| | | <template #prefix> |
| | | <svg-icon |
| | | v-if="form.icon" |
| | | :icon-class="form.icon" |
| | | class="el-input__icon" |
| | | style="height: 32px;width: 16px;" |
| | | /> |
| | | <el-icon v-else style="height: 32px;width: 16px;"><search /></el-icon> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | <icon-select ref="iconSelectRef" @selected="selected" :active-icon="form.icon" /> |
| | | </el-popover> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="菜单名称" prop="menuName"> |
| | | <el-input v-model="form.menuName" placeholder="请输入菜单名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="显示排序" prop="orderNum"> |
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择是外链则路由地址需要以`http(s)://`开头" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip>是否外链 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.isFrame"> |
| | | <el-radio label="0">是</el-radio> |
| | | <el-radio label="1">否</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item prop="path"> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="访问的路由地址,如:`user`,如外网地址需内链访问则以`http(s)://`开头" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 路由地址 |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.path" placeholder="请输入路由地址" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item prop="component"> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 组件路径 |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.component" placeholder="请输入组件路径" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'M'"> |
| | | <el-form-item> |
| | | <el-input v-model="form.perms" placeholder="请输入权限标识" maxlength="100" /> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 权限字符 |
| | | </span> |
| | | </template> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item> |
| | | <el-input v-model="form.query" placeholder="请输入路由参数" maxlength="255" /> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content='访问路由的默认传递参数,如:`{"id": 1, "name": "ry"}`' placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 路由参数 |
| | | </span> |
| | | </template> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择是则会被`keep-alive`缓存,需要匹配组件的`name`和地址保持一致" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 是否缓存 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.isCache"> |
| | | <el-radio label="0">缓存</el-radio> |
| | | <el-radio label="1">不缓存</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择隐藏则路由将不会出现在侧边栏,但仍然可以访问" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 显示状态 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.visible"> |
| | | <el-radio |
| | | v-for="dict in sys_show_hide" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择停用则路由将不会出现在侧边栏,也不能被访问" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 菜单状态 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 添加或修改菜单对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="680px" append-to-body> |
| | | <el-form ref="menuRef" :model="form" :rules="rules" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="上级菜单"> |
| | | <el-tree-select |
| | | v-model="form.parentId" |
| | | :data="menuOptions" |
| | | :props="{ value: 'menuId', label: 'menuName', children: 'children' }" |
| | | value-key="menuId" |
| | | placeholder="选择上级菜单" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="菜单类型" prop="menuType"> |
| | | <el-radio-group v-model="form.menuType"> |
| | | <el-radio label="M">目录</el-radio> |
| | | <el-radio label="C">菜单</el-radio> |
| | | <el-radio label="F">按钮</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24" v-if="form.menuType != 'F'"> |
| | | <el-form-item label="菜单图标" prop="icon"> |
| | | <el-popover placement="bottom-start" :width="540" trigger="click"> |
| | | <template #reference> |
| | | <el-input v-model="form.icon" placeholder="点击选择图标" @blur="showSelectIcon" readonly> |
| | | <template #prefix> |
| | | <svg-icon |
| | | v-if="form.icon" |
| | | :icon-class="form.icon" |
| | | class="el-input__icon" |
| | | style="height: 32px; width: 16px" |
| | | /> |
| | | <el-icon v-else style="height: 32px; width: 16px"><search /></el-icon> |
| | | </template> |
| | | </el-input> |
| | | </template> |
| | | <icon-select ref="iconSelectRef" @selected="selected" :active-icon="form.icon" /> |
| | | </el-popover> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="菜单名称" prop="menuName"> |
| | | <el-input v-model="form.menuName" placeholder="请输入菜单名称" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="显示排序" prop="orderNum"> |
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择是外链则路由地址需要以`http(s)://`开头" placement="top"> |
| | | <el-icon><question-filled /></el-icon> </el-tooltip |
| | | >是否外链 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.isFrame"> |
| | | <el-radio label="0">是</el-radio> |
| | | <el-radio label="1">否</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item prop="path"> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip |
| | | content="访问的路由地址,如:`user`,如外网地址需内链访问则以`http(s)://`开头" |
| | | placement="top" |
| | | > |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 路由地址 |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.path" placeholder="请输入路由地址" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item prop="component"> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 组件路径 |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.component" placeholder="请输入组件路径" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'M'"> |
| | | <el-form-item> |
| | | <el-input v-model="form.perms" placeholder="请输入权限标识" maxlength="100" /> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip |
| | | content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)" |
| | | placement="top" |
| | | > |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 权限字符 |
| | | </span> |
| | | </template> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item> |
| | | <el-input v-model="form.query" placeholder="请输入路由参数" maxlength="255" /> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content='访问路由的默认传递参数,如:`{"id": 1, "name": "ry"}`' placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 路由参数 |
| | | </span> |
| | | </template> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType == 'C'"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip |
| | | content="选择是则会被`keep-alive`缓存,需要匹配组件的`name`和地址保持一致" |
| | | placement="top" |
| | | > |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 是否缓存 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.isCache"> |
| | | <el-radio label="0">缓存</el-radio> |
| | | <el-radio label="1">不缓存</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12" v-if="form.menuType != 'F'"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择隐藏则路由将不会出现在侧边栏,但仍然可以访问" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 显示状态 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.visible"> |
| | | <el-radio v-for="dict in sys_show_hide" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="选择停用则路由将不会出现在侧边栏,也不能被访问" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 菜单状态 |
| | | </span> |
| | | </template> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Menu"> |
| | | import { addMenu, delMenu, getMenu, listMenu, updateMenu } from "@/api/system/menu"; |
| | | import SvgIcon from "@/components/SvgIcon"; |
| | | import IconSelect from "@/components/IconSelect"; |
| | | import { addMenu, delMenu, getMenu, listMenu, updateMenu } from "@/api/system/menu" |
| | | import SvgIcon from "@/components/SvgIcon" |
| | | import IconSelect from "@/components/IconSelect" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_show_hide, sys_normal_disable } = proxy.useDict("sys_show_hide", "sys_normal_disable"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_show_hide, sys_normal_disable } = proxy.useDict("sys_show_hide", "sys_normal_disable") |
| | | |
| | | const menuList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const title = ref(""); |
| | | const menuOptions = ref([]); |
| | | const isExpandAll = ref(false); |
| | | const refreshTable = ref(true); |
| | | const iconSelectRef = ref(null); |
| | | const menuList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const title = ref("") |
| | | const menuOptions = ref([]) |
| | | const isExpandAll = ref(false) |
| | | const refreshTable = ref(true) |
| | | const iconSelectRef = ref(null) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | | queryParams: { |
| | | menuName: undefined, |
| | | visible: undefined |
| | | visible: undefined, |
| | | }, |
| | | rules: { |
| | | menuName: [{ required: true, message: "菜单名称不能为空", trigger: "blur" }], |
| | | orderNum: [{ required: true, message: "菜单顺序不能为空", trigger: "blur" }], |
| | | path: [{ required: true, message: "路由地址不能为空", trigger: "blur" }] |
| | | path: [{ required: true, message: "路由地址不能为空", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询菜单列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listMenu(queryParams.value).then(response => { |
| | | menuList.value = proxy.handleTree(response.data, "menuId"); |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listMenu(queryParams.value).then((response) => { |
| | | menuList.value = proxy.handleTree(response.data, "menuId") |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 查询菜单下拉树结构 */ |
| | | function getTreeselect() { |
| | | menuOptions.value = []; |
| | | listMenu().then(response => { |
| | | const menu = { menuId: 0, menuName: "主类目", children: [] }; |
| | | menu.children = proxy.handleTree(response.data, "menuId"); |
| | | menuOptions.value.push(menu); |
| | | }); |
| | | menuOptions.value = [] |
| | | listMenu().then((response) => { |
| | | const menu = { menuId: 0, menuName: "主类目", children: [] } |
| | | menu.children = proxy.handleTree(response.data, "menuId") |
| | | menuOptions.value.push(menu) |
| | | }) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 表单重置 */ |
| | | function reset() { |
| | |
| | | isFrame: "1", |
| | | isCache: "0", |
| | | visible: "0", |
| | | status: "0" |
| | | }; |
| | | proxy.resetForm("menuRef"); |
| | | status: "0", |
| | | } |
| | | proxy.resetForm("menuRef") |
| | | } |
| | | /** 展示下拉图标 */ |
| | | function showSelectIcon() { |
| | | iconSelectRef.value.reset(); |
| | | iconSelectRef.value.reset() |
| | | } |
| | | /** 选择图标 */ |
| | | function selected(name) { |
| | | form.value.icon = name; |
| | | form.value.icon = name |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | getList(); |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd(row) { |
| | | reset(); |
| | | getTreeselect(); |
| | | reset() |
| | | getTreeselect() |
| | | if (row != null && row.menuId) { |
| | | form.value.parentId = row.menuId; |
| | | form.value.parentId = row.menuId |
| | | } else { |
| | | form.value.parentId = 0; |
| | | form.value.parentId = 0 |
| | | } |
| | | open.value = true; |
| | | title.value = "添加菜单"; |
| | | open.value = true |
| | | title.value = "添加菜单" |
| | | } |
| | | /** 展开/折叠操作 */ |
| | | function toggleExpandAll() { |
| | | refreshTable.value = false; |
| | | isExpandAll.value = !isExpandAll.value; |
| | | refreshTable.value = false |
| | | isExpandAll.value = !isExpandAll.value |
| | | nextTick(() => { |
| | | refreshTable.value = true; |
| | | }); |
| | | refreshTable.value = true |
| | | }) |
| | | } |
| | | /** 修改按钮操作 */ |
| | | async function handleUpdate(row) { |
| | | reset(); |
| | | await getTreeselect(); |
| | | getMenu(row.menuId).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改菜单"; |
| | | }); |
| | | reset() |
| | | await getTreeselect() |
| | | getMenu(row.menuId).then((response) => { |
| | | form.value = response.data |
| | | open.value = true |
| | | title.value = "修改菜单" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["menuRef"].validate(valid => { |
| | | proxy.$refs["menuRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.menuId != undefined) { |
| | | updateMenu(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updateMenu(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addMenu(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addMenu(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | proxy.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?').then(function() { |
| | | return delMenu(row.menuId); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | proxy.$modal |
| | | .confirm('是否确认删除名称为"' + row.menuName + '"的数据项?') |
| | | .then(function () { |
| | | return delMenu(row.menuId) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="form" label-width="80px"> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="系统名称" prop="systemName"> |
| | | <el-input v-model="form.systemName" placeholder="请输入系统名称" maxlength="64" show-word-limit /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="登录logo" prop="homeLogo"> |
| | | <ImageUpload v-model="form.homeLogo" :fileType="['png']" :limit="1" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="后台logo" prop="leftLogo"> |
| | | <ImageUpload v-model="form.leftLogo" :fileType="['png']" :limit="1" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="copyRight" prop="copyRight"> |
| | | <el-input v-model="form.copyRight" placeholder="请输入" type="textarea" maxlength="200" :rows="6" |
| | | show-word-limit /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="2" :span="18"> |
| | | <el-button type="primary" @click="handleSave">保存</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="form" label-width="80px"> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="系统名称" prop="systemName"> |
| | | <el-input v-model="form.systemName" placeholder="请输入系统名称" maxlength="64" show-word-limit /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="登录logo" prop="homeLogo"> |
| | | <ImageUpload v-model="form.homeLogo" :fileType="['png']" :limit="1" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="后台logo" prop="leftLogo"> |
| | | <ImageUpload v-model="form.leftLogo" :fileType="['png']" :limit="1" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20"> |
| | | <el-col :offset="1" :span="18"> |
| | | <el-form-item label="copyRight" prop="copyRight"> |
| | | <el-input |
| | | v-model="form.copyRight" |
| | | placeholder="请输入" |
| | | type="textarea" |
| | | maxlength="200" |
| | | :rows="6" |
| | | show-word-limit |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row class="mb20 mt20" style="padding-bottom: 20px"> |
| | | <el-col :offset="2" :span="18"> |
| | | <el-button type="primary" @click="handleSave">保存</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | import Cookies from 'js-cookie' |
| | | import { systemName, systemNameSave } from '@/api/system/name' |
| | | const baseUrl = import.meta.env.VITE_APP_BASE_API; |
| | | import Cookies from "js-cookie" |
| | | import { systemName, systemNameSave } from "@/api/system/name" |
| | | const baseUrl = import.meta.env.VITE_APP_BASE_API |
| | | const { proxy } = getCurrentInstance() |
| | | let form = ref({ |
| | | systemName: null, |
| | |
| | | }) |
| | | |
| | | function getSystemName() { |
| | | systemName().then(res => { |
| | | systemName().then((res) => { |
| | | if (res.code == 200) { |
| | | form.value = res.data |
| | | sessionStorage.setItem('SystemInfo', JSON.stringify(res.data)) |
| | | sessionStorage.setItem("SystemInfo", JSON.stringify(res.data)) |
| | | } |
| | | }) |
| | | } |
| | | getSystemName() |
| | | function handleSave() { |
| | | |
| | | if (!form.value.leftLogo.includes(baseUrl)) { |
| | | form.value.leftLogo = baseUrl + form.value.leftLogo |
| | | } |
| | |
| | | form.value.homeLogo = baseUrl + form.value.homeLogo |
| | | } |
| | | |
| | | systemNameSave(form.value).then(res => { |
| | | systemNameSave(form.value).then((res) => { |
| | | if (res.code == 200) { |
| | | proxy.$modal.msgSuccess(res.msg); |
| | | proxy.$modal.msgSuccess(res.msg) |
| | | getSystemName() |
| | | } |
| | | }) |
| | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | :deep .avatar-uploader .el-upload { |
| | | border: 1px dashed var(--el-border-color); |
| | | border-radius: 6px; |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> |
| | | <el-form-item label="岗位编码" prop="postCode"> |
| | | <el-input |
| | | v-model="queryParams.postCode" |
| | | placeholder="请输入岗位编码" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位名称" prop="postName"> |
| | | <el-input |
| | | v-model="queryParams.postName" |
| | | placeholder="请输入岗位名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="岗位状态" clearable style="width: 200px"> |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="岗位编码" prop="postCode"> |
| | | <el-input |
| | | v-model="queryParams.postCode" |
| | | placeholder="请输入岗位编码" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位名称" prop="postName"> |
| | | <el-input |
| | | v-model="queryParams.postName" |
| | | placeholder="请输入岗位名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="岗位状态" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:post:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:post:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:post:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:post:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="岗位编号" align="center" prop="postId" /> |
| | | <el-table-column label="岗位编码" align="center" prop="postCode" /> |
| | | <el-table-column label="岗位名称" align="center" prop="postName" /> |
| | | <el-table-column label="岗位排序" align="center" prop="postSort" /> |
| | | <el-table-column label="状态" align="center" prop="status"> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <div style="margin-bottom: 12px"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:post:add']" |
| | | >新增</el-button |
| | | > |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:post:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:post:remove']" |
| | | >删除</el-button |
| | | > |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:post:export']" |
| | | >导出</el-button |
| | | > |
| | | </div> |
| | | <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="岗位编号" align="center" prop="postId" /> |
| | | <el-table-column label="岗位编码" align="center" prop="postCode" /> |
| | | <el-table-column label="岗位名称" align="center" prop="postName" /> |
| | | <el-table-column label="岗位排序" align="center" prop="postSort" /> |
| | | <el-table-column label="状态" align="center" prop="status"> |
| | | <template #default="scope"> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:post:edit']">修改</el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:post:remove']">删除</el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:post:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:post:remove']" |
| | | >删除</el-button |
| | | > |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- 添加或修改岗位对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="postRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form-item label="岗位名称" prop="postName"> |
| | | <el-input v-model="form.postName" placeholder="请输入岗位名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位编码" prop="postCode"> |
| | | <el-input v-model="form.postCode" placeholder="请输入编码名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位顺序" prop="postSort"> |
| | | <el-input-number v-model="form.postSort" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位状态" prop="status"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 添加或修改岗位对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="postRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form-item label="岗位名称" prop="postName"> |
| | | <el-input v-model="form.postName" placeholder="请输入岗位名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位编码" prop="postCode"> |
| | | <el-input v-model="form.postCode" placeholder="请输入编码名称" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位顺序" prop="postSort"> |
| | | <el-input-number v-model="form.postSort" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位状态" prop="status"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="备注" prop="remark"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Post"> |
| | | import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post"; |
| | | import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post" |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable"); |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable") |
| | | |
| | | const postList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const postList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | pageSize: 10, |
| | | postCode: undefined, |
| | | postName: undefined, |
| | | status: undefined |
| | | status: undefined, |
| | | }, |
| | | rules: { |
| | | postName: [{ required: true, message: "岗位名称不能为空", trigger: "blur" }], |
| | | postCode: [{ required: true, message: "岗位编码不能为空", trigger: "blur" }], |
| | | postSort: [{ required: true, message: "岗位顺序不能为空", trigger: "blur" }], |
| | | } |
| | | }); |
| | | }, |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询岗位列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listPost(queryParams.value).then(response => { |
| | | postList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listPost(queryParams.value).then((response) => { |
| | | postList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 表单重置 */ |
| | | function reset() { |
| | |
| | | postName: undefined, |
| | | postSort: 0, |
| | | status: "0", |
| | | remark: undefined |
| | | }; |
| | | proxy.resetForm("postRef"); |
| | | remark: undefined, |
| | | } |
| | | proxy.resetForm("postRef") |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 多选框选中数据 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.postId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.postId) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | open.value = true; |
| | | title.value = "添加岗位"; |
| | | reset() |
| | | open.value = true |
| | | title.value = "添加岗位" |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const postId = row.postId || ids.value; |
| | | getPost(postId).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改岗位"; |
| | | }); |
| | | reset() |
| | | const postId = row.postId || ids.value |
| | | getPost(postId).then((response) => { |
| | | form.value = response.data |
| | | open.value = true |
| | | title.value = "修改岗位" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["postRef"].validate(valid => { |
| | | proxy.$refs["postRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.postId != undefined) { |
| | | updatePost(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updatePost(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addPost(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addPost(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const postIds = row.postId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?').then(function() { |
| | | return delPost(postIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const postIds = row.postId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?') |
| | | .then(function () { |
| | | return delPost(postIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("system/post/export", { |
| | | ...queryParams.value |
| | | }, `post_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "system/post/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `post_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true" label-width="80px"> |
| | | <el-form-item label="角色名称" prop="roleName"> |
| | | <el-input |
| | | v-model="queryParams.roleName" |
| | | placeholder="请输入角色名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="权限字符" prop="roleKey"> |
| | | <el-input |
| | | v-model="queryParams.roleKey" |
| | | placeholder="请输入权限字符" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | placeholder="角色状态" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="角色名称" prop="roleName"> |
| | | <el-input |
| | | v-model="queryParams.roleName" |
| | | placeholder="请输入角色名称" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="权限字符" prop="roleKey"> |
| | | <el-input |
| | | v-model="queryParams.roleKey" |
| | | placeholder="请输入权限字符" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="角色状态" clearable style="width: 100%"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:role:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:role:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:role:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:role:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | </div> |
| | | |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="角色编号" prop="roleId" width="120" /> |
| | | <el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="显示顺序" prop="roleSort" width="100" /> |
| | | <el-table-column label="状态" align="center" width="100"> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box" style="margin-top: 0"> |
| | | <el-row :gutter="10" class="mb8" style="margin-top: 8px"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:role:add']" |
| | | >新增</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:role:edit']" |
| | | >修改</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:role:remove']" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:role:export']" |
| | | >导出</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="角色编号" prop="roleId" width="120" /> |
| | | <el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" /> |
| | | <el-table-column label="显示顺序" prop="roleSort" width="100" /> |
| | | <el-table-column label="状态" align="center" width="100"> |
| | | <template #default="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime"> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top" v-if="scope.row.roleId !== 1"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:role:edit']"></el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:role:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top" v-if="scope.row.roleId !== 1"> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']"></el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:role:remove']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="数据权限" placement="top" v-if="scope.row.roleId !== 1"> |
| | | <el-button link type="primary" icon="CircleCheck" @click="handleDataScope(scope.row)" v-hasPermi="['system:role:edit']"></el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="CircleCheck" |
| | | @click="handleDataScope(scope.row)" |
| | | v-hasPermi="['system:role:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="分配用户" placement="top" v-if="scope.row.roleId !== 1"> |
| | | <el-button link type="primary" icon="User" @click="handleAuthUser(scope.row)" v-hasPermi="['system:role:edit']"></el-button> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="User" |
| | | @click="handleAuthUser(scope.row)" |
| | | v-hasPermi="['system:role:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <!-- 添加或修改角色配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="roleRef" :model="form" :rules="rules" label-width="110px"> |
| | | <el-form-item label="角色名称" prop="roleName"> |
| | | <el-input v-model="form.roleName" placeholder="请输入角色名称" /> |
| | | </el-form-item> |
| | | <el-form-item prop="roleKey"> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 权限字符 |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.roleKey" placeholder="请输入权限字符" /> |
| | | </el-form-item> |
| | | <el-form-item label="角色顺序" prop="roleSort"> |
| | | <el-input-number v-model="form.roleSort" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="菜单权限"> |
| | | <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox> |
| | | <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')" |
| | | >全选/全不选</el-checkbox |
| | | > |
| | | <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')" |
| | | >父子联动</el-checkbox |
| | | > |
| | | <el-tree |
| | | class="tree-border" |
| | | :data="menuOptions" |
| | | show-checkbox |
| | | ref="menuRef" |
| | | node-key="id" |
| | | :check-strictly="!form.menuCheckStrictly" |
| | | empty-text="加载中,请稍候" |
| | | :props="{ label: 'label', children: 'children' }" |
| | | ></el-tree> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 添加或修改角色配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="roleRef" :model="form" :rules="rules" label-width="110px"> |
| | | <el-form-item label="角色名称" prop="roleName"> |
| | | <el-input v-model="form.roleName" placeholder="请输入角色名称" /> |
| | | </el-form-item> |
| | | <el-form-item prop="roleKey"> |
| | | <template #label> |
| | | <span> |
| | | <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top"> |
| | | <el-icon><question-filled /></el-icon> |
| | | </el-tooltip> |
| | | 权限字符 |
| | | </span> |
| | | </template> |
| | | <el-input v-model="form.roleKey" placeholder="请输入权限字符" /> |
| | | </el-form-item> |
| | | <el-form-item label="角色顺序" prop="roleSort"> |
| | | <el-input-number v-model="form.roleSort" controls-position="right" :min="0" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="菜单权限"> |
| | | <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox> |
| | | <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox> |
| | | <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox> |
| | | <el-tree |
| | | class="tree-border" |
| | | :data="menuOptions" |
| | | show-checkbox |
| | | ref="menuRef" |
| | | node-key="id" |
| | | :check-strictly="!form.menuCheckStrictly" |
| | | empty-text="加载中,请稍候" |
| | | :props="{ label: 'label', children: 'children' }" |
| | | ></el-tree> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 分配角色数据权限对话框 --> |
| | | <el-dialog :title="title" v-model="openDataScope" width="500px" append-to-body> |
| | | <el-form :model="form" label-width="100px"> |
| | | <el-form-item label="角色名称"> |
| | | <el-input v-model="form.roleName" :disabled="true" /> |
| | | </el-form-item> |
| | | <el-form-item label="权限字符"> |
| | | <el-input v-model="form.roleKey" :disabled="true" /> |
| | | </el-form-item> |
| | | <el-form-item label="权限范围"> |
| | | <el-select v-model="form.dataScope" @change="dataScopeSelectChange"> |
| | | <el-option |
| | | v-for="item in dataScopeOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="数据权限" v-show="form.dataScope == 2"> |
| | | <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox> |
| | | <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox> |
| | | <el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox> |
| | | <el-tree |
| | | class="tree-border" |
| | | :data="deptOptions" |
| | | show-checkbox |
| | | default-expand-all |
| | | ref="deptRef" |
| | | node-key="id" |
| | | :check-strictly="!form.deptCheckStrictly" |
| | | empty-text="加载中,请稍候" |
| | | :props="{ label: 'label', children: 'children' }" |
| | | ></el-tree> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitDataScope">确 定</el-button> |
| | | <el-button @click="cancelDataScope">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 分配角色数据权限对话框 --> |
| | | <el-dialog :title="title" v-model="openDataScope" width="500px" append-to-body> |
| | | <el-form :model="form" label-width="100px"> |
| | | <el-form-item label="角色名称"> |
| | | <el-input v-model="form.roleName" :disabled="true" /> |
| | | </el-form-item> |
| | | <el-form-item label="权限字符"> |
| | | <el-input v-model="form.roleKey" :disabled="true" /> |
| | | </el-form-item> |
| | | <el-form-item label="权限范围"> |
| | | <el-select v-model="form.dataScope" @change="dataScopeSelectChange"> |
| | | <el-option |
| | | v-for="item in dataScopeOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="数据权限" v-show="form.dataScope == 2"> |
| | | <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox> |
| | | <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')" |
| | | >全选/全不选</el-checkbox |
| | | > |
| | | <el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')" |
| | | >父子联动</el-checkbox |
| | | > |
| | | <el-tree |
| | | class="tree-border" |
| | | :data="deptOptions" |
| | | show-checkbox |
| | | default-expand-all |
| | | ref="deptRef" |
| | | node-key="id" |
| | | :check-strictly="!form.deptCheckStrictly" |
| | | empty-text="加载中,请稍候" |
| | | :props="{ label: 'label', children: 'children' }" |
| | | ></el-tree> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitDataScope">确 定</el-button> |
| | | <el-button @click="cancelDataScope">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="Role"> |
| | | import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updateRole, deptTreeSelect } from "@/api/system/role"; |
| | | import { roleMenuTreeselect, treeselect as menuTreeselect } from "@/api/system/menu"; |
| | | import { |
| | | addRole, |
| | | changeRoleStatus, |
| | | dataScope, |
| | | delRole, |
| | | getRole, |
| | | listRole, |
| | | updateRole, |
| | | deptTreeSelect, |
| | | } from "@/api/system/role" |
| | | import { roleMenuTreeselect, treeselect as menuTreeselect } from "@/api/system/menu" |
| | | |
| | | const router = useRouter(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable"); |
| | | const router = useRouter() |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_normal_disable } = proxy.useDict("sys_normal_disable") |
| | | |
| | | const roleList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const dateRange = ref([]); |
| | | const menuOptions = ref([]); |
| | | const menuExpand = ref(false); |
| | | const menuNodeAll = ref(false); |
| | | const deptExpand = ref(true); |
| | | const deptNodeAll = ref(false); |
| | | const deptOptions = ref([]); |
| | | const openDataScope = ref(false); |
| | | const menuRef = ref(null); |
| | | const deptRef = ref(null); |
| | | const roleList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | const dateRange = ref([]) |
| | | const menuOptions = ref([]) |
| | | const menuExpand = ref(false) |
| | | const menuNodeAll = ref(false) |
| | | const deptExpand = ref(true) |
| | | const deptNodeAll = ref(false) |
| | | const deptOptions = ref([]) |
| | | const openDataScope = ref(false) |
| | | const menuRef = ref(null) |
| | | const deptRef = ref(null) |
| | | |
| | | /** 数据范围选项*/ |
| | | const dataScopeOptions = ref([ |
| | |
| | | { value: "2", label: "自定数据权限" }, |
| | | { value: "3", label: "本部门数据权限" }, |
| | | { value: "4", label: "本部门及以下数据权限" }, |
| | | { value: "5", label: "仅本人数据权限" } |
| | | ]); |
| | | { value: "5", label: "仅本人数据权限" }, |
| | | ]) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | pageSize: 10, |
| | | roleName: undefined, |
| | | roleKey: undefined, |
| | | status: undefined |
| | | status: undefined, |
| | | }, |
| | | rules: { |
| | | roleName: [{ required: true, message: "角色名称不能为空", trigger: "blur" }], |
| | | roleKey: [{ required: true, message: "权限字符不能为空", trigger: "blur" }], |
| | | roleSort: [{ required: true, message: "角色顺序不能为空", trigger: "blur" }] |
| | | roleSort: [{ required: true, message: "角色顺序不能为空", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 查询角色列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listRole(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
| | | roleList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listRole(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => { |
| | | roleList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const roleIds = row.roleId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function () { |
| | | return delRole(roleIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const roleIds = row.roleId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?') |
| | | .then(function () { |
| | | return delRole(roleIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("system/role/export", { |
| | | ...queryParams.value, |
| | | }, `role_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "system/role/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `role_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | /** 多选框选中数据 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.roleId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.roleId) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 角色状态修改 */ |
| | | function handleStatusChange(row) { |
| | | let text = row.status === "0" ? "启用" : "停用"; |
| | | proxy.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function () { |
| | | return changeRoleStatus(row.roleId, row.status); |
| | | }).then(() => { |
| | | proxy.$modal.msgSuccess(text + "成功"); |
| | | }).catch(function () { |
| | | row.status = row.status === "0" ? "1" : "0"; |
| | | }); |
| | | let text = row.status === "0" ? "启用" : "停用" |
| | | proxy.$modal |
| | | .confirm('确认要"' + text + '""' + row.roleName + '"角色吗?') |
| | | .then(function () { |
| | | return changeRoleStatus(row.roleId, row.status) |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess(text + "成功") |
| | | }) |
| | | .catch(function () { |
| | | row.status = row.status === "0" ? "1" : "0" |
| | | }) |
| | | } |
| | | /** 更多操作 */ |
| | | function handleCommand(command, row) { |
| | | switch (command) { |
| | | case "handleDataScope": |
| | | handleDataScope(row); |
| | | break; |
| | | handleDataScope(row) |
| | | break |
| | | case "handleAuthUser": |
| | | handleAuthUser(row); |
| | | break; |
| | | handleAuthUser(row) |
| | | break |
| | | default: |
| | | break; |
| | | break |
| | | } |
| | | } |
| | | /** 分配用户 */ |
| | | function handleAuthUser(row) { |
| | | router.push("/system/role-auth/user/" + row.roleId); |
| | | router.push("/system/role-auth/user/" + row.roleId) |
| | | } |
| | | /** 查询菜单树结构 */ |
| | | function getMenuTreeselect() { |
| | | menuTreeselect().then(response => { |
| | | menuOptions.value = response.data; |
| | | }); |
| | | menuTreeselect().then((response) => { |
| | | menuOptions.value = response.data |
| | | }) |
| | | } |
| | | /** 所有部门节点数据 */ |
| | | function getDeptAllCheckedKeys() { |
| | | // 目前被选中的部门节点 |
| | | let checkedKeys = deptRef.value.getCheckedKeys(); |
| | | let checkedKeys = deptRef.value.getCheckedKeys() |
| | | // 半选中的部门节点 |
| | | let halfCheckedKeys = deptRef.value.getHalfCheckedKeys(); |
| | | checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); |
| | | return checkedKeys; |
| | | let halfCheckedKeys = deptRef.value.getHalfCheckedKeys() |
| | | checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys) |
| | | return checkedKeys |
| | | } |
| | | /** 重置新增的表单以及其他数据 */ |
| | | function reset() { |
| | | if (menuRef.value != undefined) { |
| | | menuRef.value.setCheckedKeys([]); |
| | | menuRef.value.setCheckedKeys([]) |
| | | } |
| | | menuExpand.value = false; |
| | | menuNodeAll.value = false; |
| | | deptExpand.value = true; |
| | | deptNodeAll.value = false; |
| | | menuExpand.value = false |
| | | menuNodeAll.value = false |
| | | deptExpand.value = true |
| | | deptNodeAll.value = false |
| | | form.value = { |
| | | roleId: undefined, |
| | | roleName: undefined, |
| | |
| | | deptIds: [], |
| | | menuCheckStrictly: true, |
| | | deptCheckStrictly: true, |
| | | remark: undefined |
| | | }; |
| | | proxy.resetForm("roleRef"); |
| | | remark: undefined, |
| | | } |
| | | proxy.resetForm("roleRef") |
| | | } |
| | | /** 添加角色 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | getMenuTreeselect(); |
| | | open.value = true; |
| | | title.value = "添加角色"; |
| | | reset() |
| | | getMenuTreeselect() |
| | | open.value = true |
| | | title.value = "添加角色" |
| | | } |
| | | /** 修改角色 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const roleId = row.roleId || ids.value; |
| | | const roleMenu = getRoleMenuTreeselect(roleId); |
| | | getRole(roleId).then(response => { |
| | | form.value = response.data; |
| | | form.value.roleSort = Number(form.value.roleSort); |
| | | open.value = true; |
| | | reset() |
| | | const roleId = row.roleId || ids.value |
| | | const roleMenu = getRoleMenuTreeselect(roleId) |
| | | getRole(roleId).then((response) => { |
| | | form.value = response.data |
| | | form.value.roleSort = Number(form.value.roleSort) |
| | | open.value = true |
| | | nextTick(() => { |
| | | roleMenu.then((res) => { |
| | | let checkedKeys = res.checkedKeys; |
| | | let checkedKeys = res.checkedKeys |
| | | checkedKeys.forEach((v) => { |
| | | nextTick(() => { |
| | | menuRef.value.setChecked(v, true, false); |
| | | }); |
| | | }); |
| | | }); |
| | | }); |
| | | title.value = "修改角色"; |
| | | }); |
| | | menuRef.value.setChecked(v, true, false) |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | | title.value = "修改角色" |
| | | }) |
| | | } |
| | | /** 根据角色ID查询菜单树结构 */ |
| | | function getRoleMenuTreeselect(roleId) { |
| | | return roleMenuTreeselect(roleId).then(response => { |
| | | menuOptions.value = response.menus; |
| | | return response; |
| | | }); |
| | | return roleMenuTreeselect(roleId).then((response) => { |
| | | menuOptions.value = response.menus |
| | | return response |
| | | }) |
| | | } |
| | | /** 根据角色ID查询部门树结构 */ |
| | | function getDeptTree(roleId) { |
| | | return deptTreeSelect(roleId).then(response => { |
| | | deptOptions.value = response.depts; |
| | | return response; |
| | | }); |
| | | return deptTreeSelect(roleId).then((response) => { |
| | | deptOptions.value = response.depts |
| | | return response |
| | | }) |
| | | } |
| | | /** 树权限(展开/折叠)*/ |
| | | function handleCheckedTreeExpand(value, type) { |
| | | if (type == "menu") { |
| | | let treeList = menuOptions.value; |
| | | let treeList = menuOptions.value |
| | | for (let i = 0; i < treeList.length; i++) { |
| | | menuRef.value.store.nodesMap[treeList[i].id].expanded = value; |
| | | menuRef.value.store.nodesMap[treeList[i].id].expanded = value |
| | | } |
| | | } else if (type == "dept") { |
| | | let treeList = deptOptions.value; |
| | | let treeList = deptOptions.value |
| | | for (let i = 0; i < treeList.length; i++) { |
| | | deptRef.value.store.nodesMap[treeList[i].id].expanded = value; |
| | | deptRef.value.store.nodesMap[treeList[i].id].expanded = value |
| | | } |
| | | } |
| | | } |
| | | /** 树权限(全选/全不选) */ |
| | | function handleCheckedTreeNodeAll(value, type) { |
| | | if (type == "menu") { |
| | | menuRef.value.setCheckedNodes(value ? menuOptions.value : []); |
| | | menuRef.value.setCheckedNodes(value ? menuOptions.value : []) |
| | | } else if (type == "dept") { |
| | | deptRef.value.setCheckedNodes(value ? deptOptions.value : []); |
| | | deptRef.value.setCheckedNodes(value ? deptOptions.value : []) |
| | | } |
| | | } |
| | | /** 树权限(父子联动) */ |
| | | function handleCheckedTreeConnect(value, type) { |
| | | if (type == "menu") { |
| | | form.value.menuCheckStrictly = value ? true : false; |
| | | form.value.menuCheckStrictly = value ? true : false |
| | | } else if (type == "dept") { |
| | | form.value.deptCheckStrictly = value ? true : false; |
| | | form.value.deptCheckStrictly = value ? true : false |
| | | } |
| | | } |
| | | /** 所有菜单节点数据 */ |
| | | function getMenuAllCheckedKeys() { |
| | | // 目前被选中的菜单节点 |
| | | let checkedKeys = menuRef.value.getCheckedKeys(); |
| | | let checkedKeys = menuRef.value.getCheckedKeys() |
| | | // 半选中的菜单节点 |
| | | let halfCheckedKeys = menuRef.value.getHalfCheckedKeys(); |
| | | checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); |
| | | return checkedKeys; |
| | | let halfCheckedKeys = menuRef.value.getHalfCheckedKeys() |
| | | checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys) |
| | | return checkedKeys |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["roleRef"].validate(valid => { |
| | | proxy.$refs["roleRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.roleId != undefined) { |
| | | form.value.menuIds = getMenuAllCheckedKeys(); |
| | | updateRole(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | form.value.menuIds = getMenuAllCheckedKeys() |
| | | updateRole(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | form.value.menuIds = getMenuAllCheckedKeys(); |
| | | addRole(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | form.value.menuIds = getMenuAllCheckedKeys() |
| | | addRole(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 选择角色权限范围触发 */ |
| | | function dataScopeSelectChange(value) { |
| | | if (value !== "2") { |
| | | deptRef.value.setCheckedKeys([]); |
| | | deptRef.value.setCheckedKeys([]) |
| | | } |
| | | } |
| | | /** 分配数据权限操作 */ |
| | | function handleDataScope(row) { |
| | | reset(); |
| | | const deptTreeSelect = getDeptTree(row.roleId); |
| | | getRole(row.roleId).then(response => { |
| | | form.value = response.data; |
| | | openDataScope.value = true; |
| | | reset() |
| | | const deptTreeSelect = getDeptTree(row.roleId) |
| | | getRole(row.roleId).then((response) => { |
| | | form.value = response.data |
| | | openDataScope.value = true |
| | | nextTick(() => { |
| | | deptTreeSelect.then(res => { |
| | | deptTreeSelect.then((res) => { |
| | | nextTick(() => { |
| | | if (deptRef.value) { |
| | | deptRef.value.setCheckedKeys(res.checkedKeys); |
| | | deptRef.value.setCheckedKeys(res.checkedKeys) |
| | | } |
| | | }); |
| | | }); |
| | | }); |
| | | title.value = "分配数据权限"; |
| | | }); |
| | | }) |
| | | }) |
| | | }) |
| | | title.value = "分配数据权限" |
| | | }) |
| | | } |
| | | /** 提交按钮(数据权限) */ |
| | | function submitDataScope() { |
| | | if (form.value.roleId != undefined) { |
| | | form.value.deptIds = getDeptAllCheckedKeys(); |
| | | dataScope(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | openDataScope.value = false; |
| | | getList(); |
| | | }); |
| | | form.value.deptIds = getDeptAllCheckedKeys() |
| | | dataScope(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | openDataScope.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | /** 取消按钮(数据权限)*/ |
| | | function cancelDataScope() { |
| | | openDataScope.value = false; |
| | | reset(); |
| | | openDataScope.value = false |
| | | reset() |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-row :gutter="20"> |
| | | <!--部门数据--> |
| | | <el-col :span="4" :xs="24"> |
| | | <div class="head-container"> |
| | | <el-input |
| | | v-model="deptName" |
| | | placeholder="请输入部门名称" |
| | | clearable |
| | | prefix-icon="Search" |
| | | style="margin-bottom: 20px" |
| | | /> |
| | | </div> |
| | | <div class="head-container"> |
| | | <el-tree |
| | | :data="deptOptions" |
| | | :props="{ label: 'label', children: 'children' }" |
| | | :expand-on-click-node="false" |
| | | :filter-node-method="filterNode" |
| | | ref="deptTreeRef" |
| | | node-key="id" |
| | | highlight-current |
| | | default-expand-all |
| | | @node-click="handleNodeClick" |
| | | /> |
| | | </div> |
| | | </el-col> |
| | | <!--用户数据--> |
| | | <el-col :span="20" :xs="24"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px"> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input |
| | | v-model="queryParams.userName" |
| | | placeholder="请输入用户名称" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="手机号码" prop="phoneNumber"> |
| | | <el-input |
| | | v-model="queryParams.phoneNumber" |
| | | placeholder="请输入手机号码" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | placeholder="用户状态" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px;"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="app-container page"> |
| | | <el-row :gutter="20"> |
| | | <!--部门数据--> |
| | | <el-col :span="4" :xs="24"> |
| | | <div class="head-container"> |
| | | <el-input |
| | | v-model="deptName" |
| | | placeholder="请输入部门名称" |
| | | clearable |
| | | prefix-icon="Search" |
| | | style="margin-bottom: 20px" |
| | | /> |
| | | </div> |
| | | <div class="head-container"> |
| | | <el-tree |
| | | :data="deptOptions" |
| | | :props="{ label: 'label', children: 'children' }" |
| | | :expand-on-click-node="false" |
| | | :filter-node-method="filterNode" |
| | | ref="deptTreeRef" |
| | | node-key="id" |
| | | highlight-current |
| | | default-expand-all |
| | | @node-click="handleNodeClick" |
| | | /> |
| | | </div> |
| | | </el-col> |
| | | <!--用户数据--> |
| | | <el-col :span="20" :xs="24"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> |
| | | <el-form-item label="用户名称" prop="userName"> |
| | | <el-input |
| | | v-model="queryParams.userName" |
| | | placeholder="请输入用户名称" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="手机号码" prop="phoneNumber"> |
| | | <el-input |
| | | v-model="queryParams.phoneNumber" |
| | | placeholder="请输入手机号码" |
| | | clearable |
| | | style="width: 100%" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status" label-width="50px"> |
| | | <el-select v-model="queryParams.status" placeholder="用户状态" clearable style="width: 100%"> |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['system:user:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:user:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:user:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="Upload" |
| | | @click="handleImport" |
| | | v-hasPermi="['system:user:import']" |
| | | >导入</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:user:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box" style="margin-top: 0"> |
| | | <el-row :gutter="10" class="mb8" style="margin-top: 8px"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:user:add']" |
| | | >新增</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['system:user:edit']" |
| | | >修改</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['system:user:remove']" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="info" plain icon="Upload" @click="handleImport" v-hasPermi="['system:user:import']" |
| | | >导入</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['system:user:export']" |
| | | >导出</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" /> |
| | | <el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="手机号码" align="center" key="phoneNumber" prop="phoneNumber" v-if="columns[4].visible" width="120" /> |
| | | <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible"> |
| | | <template #default="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="重置密码" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button link type="primary" icon="Key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="分配角色" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button link type="primary" icon="CircleCheck" @click="handleAuthRole(scope.row)" v-hasPermi="['system:user:edit']"></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" /> |
| | | <el-table-column |
| | | label="用户名称" |
| | | align="center" |
| | | key="userName" |
| | | prop="userName" |
| | | v-if="columns[1].visible" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="用户昵称" |
| | | align="center" |
| | | key="nickName" |
| | | prop="nickName" |
| | | v-if="columns[2].visible" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="部门" |
| | | align="center" |
| | | key="deptName" |
| | | prop="dept.deptName" |
| | | v-if="columns[3].visible" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="手机号码" |
| | | align="center" |
| | | key="phoneNumber" |
| | | prop="phoneNumber" |
| | | v-if="columns[4].visible" |
| | | width="120" |
| | | /> |
| | | <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible"> |
| | | <template #default="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160"> |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="修改" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | v-hasPermi="['system:user:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['system:user:remove']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="重置密码" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Key" |
| | | @click="handleResetPwd(scope.row)" |
| | | v-hasPermi="['system:user:resetPwd']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="分配角色" placement="top" v-if="scope.row.userId !== 1"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="CircleCheck" |
| | | @click="handleAuthRole(scope.row)" |
| | | v-hasPermi="['system:user:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <!-- 添加或修改用户配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body> |
| | | <el-form :model="form" :rules="rules" ref="userRef" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户昵称" prop="nickName"> |
| | | <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="归属部门" prop="deptId"> |
| | | <el-tree-select |
| | | v-model="form.deptId" |
| | | :data="deptOptions" |
| | | :props="{ value: 'id', label: 'label', children: 'children' }" |
| | | value-key="id" |
| | | placeholder="请选择归属部门" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="手机号码" prop="phoneNumber"> |
| | | <el-input v-model="form.phoneNumber" placeholder="请输入手机号码" maxlength="11" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName"> |
| | | <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password"> |
| | | <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户性别"> |
| | | <el-select v-model="form.sex" placeholder="请选择"> |
| | | <el-option |
| | | v-for="dict in sys_user_sex" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="岗位"> |
| | | <el-select v-model="form.postIds" multiple placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in postOptions" |
| | | :key="item.postId" |
| | | :label="item.postName" |
| | | :value="item.postId" |
| | | :disabled="item.status == 1" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="角色"> |
| | | <el-select v-model="form.roleIds" multiple placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in roleOptions" |
| | | :key="item.roleId" |
| | | :label="item.roleName" |
| | | :value="item.roleId" |
| | | :disabled="item.status == 1" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <!-- 添加或修改用户配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body> |
| | | <el-form :model="form" :rules="rules" ref="userRef" label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户昵称" prop="nickName"> |
| | | <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="归属部门" prop="deptId"> |
| | | <el-tree-select |
| | | v-model="form.deptId" |
| | | :data="deptOptions" |
| | | :props="{ value: 'id', label: 'label', children: 'children' }" |
| | | value-key="id" |
| | | placeholder="请选择归属部门" |
| | | check-strictly |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="手机号码" prop="phoneNumber"> |
| | | <el-input v-model="form.phoneNumber" placeholder="请输入手机号码" maxlength="11" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName"> |
| | | <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password"> |
| | | <el-input |
| | | v-model="form.password" |
| | | placeholder="请输入用户密码" |
| | | type="password" |
| | | maxlength="20" |
| | | show-password |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户性别"> |
| | | <el-select v-model="form.sex" placeholder="请选择"> |
| | | <el-option |
| | | v-for="dict in sys_user_sex" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.value">{{ |
| | | dict.label |
| | | }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="岗位"> |
| | | <el-select v-model="form.postIds" multiple placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in postOptions" |
| | | :key="item.postId" |
| | | :label="item.postName" |
| | | :value="item.postId" |
| | | :disabled="item.status == 1" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="角色"> |
| | | <el-select v-model="form.roleIds" multiple placeholder="请选择"> |
| | | <el-option |
| | | v-for="item in roleOptions" |
| | | :key="item.roleId" |
| | | :label="item.roleName" |
| | | :value="item.roleId" |
| | | :disabled="item.status == 1" |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <!-- 用户导入对话框 --> |
| | | <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body> |
| | | <el-upload |
| | | ref="uploadRef" |
| | | :limit="1" |
| | | accept=".xlsx, .xls" |
| | | :headers="upload.headers" |
| | | :action="upload.url + '?updateSupport=' + upload.updateSupport" |
| | | :disabled="upload.isUploading" |
| | | :on-progress="handleFileUploadProgress" |
| | | :on-success="handleFileSuccess" |
| | | :auto-upload="false" |
| | | drag |
| | | > |
| | | <el-icon class="el-icon--upload"><upload-filled /></el-icon> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | <template #tip> |
| | | <div class="el-upload__tip text-center"> |
| | | <div class="el-upload__tip"> |
| | | <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据 |
| | | </div> |
| | | <span>仅允许导入xls、xlsx格式文件。</span> |
| | | <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link> |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitFileForm">确 定</el-button> |
| | | <el-button @click="upload.open = false">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- 用户导入对话框 --> |
| | | <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body> |
| | | <el-upload |
| | | ref="uploadRef" |
| | | :limit="1" |
| | | accept=".xlsx, .xls" |
| | | :headers="upload.headers" |
| | | :action="upload.url + '?updateSupport=' + upload.updateSupport" |
| | | :disabled="upload.isUploading" |
| | | :on-progress="handleFileUploadProgress" |
| | | :on-success="handleFileSuccess" |
| | | :auto-upload="false" |
| | | drag |
| | | > |
| | | <el-icon class="el-icon--upload"><upload-filled /></el-icon> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | <template #tip> |
| | | <div class="el-upload__tip text-center"> |
| | | <div class="el-upload__tip"><el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据</div> |
| | | <span>仅允许导入xls、xlsx格式文件。</span> |
| | | <el-link |
| | | type="primary" |
| | | :underline="false" |
| | | style="font-size: 12px; vertical-align: baseline" |
| | | @click="importTemplate" |
| | | >下载模板</el-link |
| | | > |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitFileForm">确 定</el-button> |
| | | <el-button @click="upload.open = false">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="User"> |
| | | import { getToken } from "@/utils/auth"; |
| | | import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user"; |
| | | import { getToken } from "@/utils/auth" |
| | | import { |
| | | changeUserStatus, |
| | | listUser, |
| | | resetUserPwd, |
| | | delUser, |
| | | getUser, |
| | | updateUser, |
| | | addUser, |
| | | deptTreeSelect, |
| | | } from "@/api/system/user" |
| | | |
| | | const router = useRouter(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex"); |
| | | const router = useRouter() |
| | | const { proxy } = getCurrentInstance() |
| | | const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex") |
| | | |
| | | const userList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const dateRange = ref([]); |
| | | const deptName = ref(""); |
| | | const deptOptions = ref(undefined); |
| | | const initPassword = ref(undefined); |
| | | const postOptions = ref([]); |
| | | const roleOptions = ref([]); |
| | | const userList = ref([]) |
| | | const open = ref(false) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const title = ref("") |
| | | const dateRange = ref([]) |
| | | const deptName = ref("") |
| | | const deptOptions = ref(undefined) |
| | | const initPassword = ref(undefined) |
| | | const postOptions = ref([]) |
| | | const roleOptions = ref([]) |
| | | /*** 用户导入参数 */ |
| | | const upload = reactive({ |
| | | // 是否显示弹出层(用户导入) |
| | |
| | | // 设置上传的请求头部 |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | // 上传的地址 |
| | | url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData" |
| | | }); |
| | | url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData", |
| | | }) |
| | | // 列显隐信息 |
| | | const columns = ref([ |
| | | { key: 0, label: `用户编号`, visible: true }, |
| | |
| | | { key: 3, label: `部门`, visible: true }, |
| | | { key: 4, label: `手机号码`, visible: true }, |
| | | { key: 5, label: `状态`, visible: true }, |
| | | { key: 6, label: `创建时间`, visible: true } |
| | | ]); |
| | | { key: 6, label: `创建时间`, visible: true }, |
| | | ]) |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | |
| | | userName: undefined, |
| | | phoneNumber: undefined, |
| | | status: undefined, |
| | | deptId: undefined |
| | | deptId: undefined, |
| | | }, |
| | | rules: { |
| | | userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" }], |
| | | userName: [ |
| | | { required: true, message: "用户名称不能为空", trigger: "blur" }, |
| | | { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" }, |
| | | ], |
| | | nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }], |
| | | password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }], |
| | | password: [ |
| | | { required: true, message: "用户密码不能为空", trigger: "blur" }, |
| | | { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, |
| | | { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }, |
| | | ], |
| | | email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }], |
| | | phoneNumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }] |
| | | } |
| | | }); |
| | | phoneNumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }], |
| | | }, |
| | | }) |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | const { queryParams, form, rules } = toRefs(data) |
| | | |
| | | /** 通过条件过滤节点 */ |
| | | const filterNode = (value, data) => { |
| | | if (!value) return true; |
| | | return data.label.indexOf(value) !== -1; |
| | | }; |
| | | if (!value) return true |
| | | return data.label.indexOf(value) !== -1 |
| | | } |
| | | /** 根据名称筛选部门树 */ |
| | | watch(deptName, val => { |
| | | proxy.$refs["deptTreeRef"].filter(val); |
| | | }); |
| | | watch(deptName, (val) => { |
| | | proxy.$refs["deptTreeRef"].filter(val) |
| | | }) |
| | | /** 查询部门下拉树结构 */ |
| | | function getDeptTree() { |
| | | deptTreeSelect().then(response => { |
| | | deptOptions.value = response.data; |
| | | }); |
| | | }; |
| | | deptTreeSelect().then((response) => { |
| | | deptOptions.value = response.data |
| | | }) |
| | | } |
| | | /** 查询用户列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => { |
| | | loading.value = false; |
| | | userList.value = res.rows; |
| | | total.value = res.total; |
| | | }); |
| | | }; |
| | | loading.value = true |
| | | listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then((res) => { |
| | | loading.value = false |
| | | userList.value = res.rows |
| | | total.value = res.total |
| | | }) |
| | | } |
| | | /** 节点单击事件 */ |
| | | function handleNodeClick(data) { |
| | | queryParams.value.deptId = data.id; |
| | | handleQuery(); |
| | | }; |
| | | queryParams.value.deptId = data.id |
| | | handleQuery() |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | }; |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | queryParams.value.deptId = undefined; |
| | | proxy.$refs.deptTreeRef.setCurrentKey(null); |
| | | handleQuery(); |
| | | }; |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | queryParams.value.deptId = undefined |
| | | proxy.$refs.deptTreeRef.setCurrentKey(null) |
| | | handleQuery() |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const userIds = row.userId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function () { |
| | | return delUser(userIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | }; |
| | | const userIds = row.userId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除用户编号为"' + userIds + '"的数据项?') |
| | | .then(function () { |
| | | return delUser(userIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download("system/user/export", { |
| | | ...queryParams.value, |
| | | },`user_${new Date().getTime()}.xlsx`); |
| | | }; |
| | | proxy.download( |
| | | "system/user/export", |
| | | { |
| | | ...queryParams.value, |
| | | }, |
| | | `user_${new Date().getTime()}.xlsx` |
| | | ) |
| | | } |
| | | /** 用户状态修改 */ |
| | | function handleStatusChange(row) { |
| | | let text = row.status === "0" ? "启用" : "停用"; |
| | | proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () { |
| | | return changeUserStatus(row.userId, row.status); |
| | | }).then(() => { |
| | | proxy.$modal.msgSuccess(text + "成功"); |
| | | }).catch(function () { |
| | | row.status = row.status === "0" ? "1" : "0"; |
| | | }); |
| | | }; |
| | | let text = row.status === "0" ? "启用" : "停用" |
| | | proxy.$modal |
| | | .confirm('确认要"' + text + '""' + row.userName + '"用户吗?') |
| | | .then(function () { |
| | | return changeUserStatus(row.userId, row.status) |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess(text + "成功") |
| | | }) |
| | | .catch(function () { |
| | | row.status = row.status === "0" ? "1" : "0" |
| | | }) |
| | | } |
| | | /** 更多操作 */ |
| | | function handleCommand(command, row) { |
| | | switch (command) { |
| | | case "handleResetPwd": |
| | | handleResetPwd(row); |
| | | break; |
| | | handleResetPwd(row) |
| | | break |
| | | case "handleAuthRole": |
| | | handleAuthRole(row); |
| | | break; |
| | | handleAuthRole(row) |
| | | break |
| | | default: |
| | | break; |
| | | break |
| | | } |
| | | }; |
| | | } |
| | | /** 跳转角色分配 */ |
| | | function handleAuthRole(row) { |
| | | const userId = row.userId; |
| | | router.push("/system/user-auth/role/" + userId); |
| | | }; |
| | | const userId = row.userId |
| | | router.push("/system/user-auth/role/" + userId) |
| | | } |
| | | /** 重置密码按钮操作 */ |
| | | function handleResetPwd(row) { |
| | | proxy.$prompt('请输入"' + row.userName + '"的新密码', "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | closeOnClickModal: false, |
| | | inputPattern: /^.{5,20}$/, |
| | | inputErrorMessage: "用户密码长度必须介于 5 和 20 之间", |
| | | inputValidator: (value) => { |
| | | if (/<|>|"|'|\||\\/.test(value)) { |
| | | return "不能包含非法字符:< > \" ' \\\ |" |
| | | } |
| | | }, |
| | | }).then(({ value }) => { |
| | | resetUserPwd(row.userId, value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功,新密码是:" + value); |
| | | }); |
| | | }).catch(() => {}); |
| | | }; |
| | | proxy |
| | | .$prompt('请输入"' + row.userName + '"的新密码', "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | closeOnClickModal: false, |
| | | inputPattern: /^.{5,20}$/, |
| | | inputErrorMessage: "用户密码长度必须介于 5 和 20 之间", |
| | | inputValidator: (value) => { |
| | | if (/<|>|"|'|\||\\/.test(value)) { |
| | | return "不能包含非法字符:< > \" ' \\\ |" |
| | | } |
| | | }, |
| | | }) |
| | | .then(({ value }) => { |
| | | resetUserPwd(row.userId, value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功,新密码是:" + value) |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 选择条数 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.userId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | }; |
| | | ids.value = selection.map((item) => item.userId) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 导入按钮操作 */ |
| | | function handleImport() { |
| | | upload.title = "用户导入"; |
| | | upload.open = true; |
| | | }; |
| | | upload.title = "用户导入" |
| | | upload.open = true |
| | | } |
| | | /** 下载模板操作 */ |
| | | function importTemplate() { |
| | | proxy.download("system/user/importTemplate", { |
| | | }, `user_template_${new Date().getTime()}.xlsx`); |
| | | }; |
| | | proxy.download("system/user/importTemplate", {}, `user_template_${new Date().getTime()}.xlsx`) |
| | | } |
| | | /**文件上传中处理 */ |
| | | const handleFileUploadProgress = (event, file, fileList) => { |
| | | upload.isUploading = true; |
| | | }; |
| | | upload.isUploading = true |
| | | } |
| | | /** 文件上传成功处理 */ |
| | | const handleFileSuccess = (response, file, fileList) => { |
| | | upload.open = false; |
| | | upload.isUploading = false; |
| | | proxy.$refs["uploadRef"].handleRemove(file); |
| | | proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }); |
| | | getList(); |
| | | }; |
| | | upload.open = false |
| | | upload.isUploading = false |
| | | proxy.$refs["uploadRef"].handleRemove(file) |
| | | proxy.$alert( |
| | | "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", |
| | | "导入结果", |
| | | { dangerouslyUseHTMLString: true } |
| | | ) |
| | | getList() |
| | | } |
| | | /** 提交上传文件 */ |
| | | function submitFileForm() { |
| | | proxy.$refs["uploadRef"].submit(); |
| | | }; |
| | | proxy.$refs["uploadRef"].submit() |
| | | } |
| | | /** 重置操作表单 */ |
| | | function reset() { |
| | | form.value = { |
| | |
| | | status: "0", |
| | | remark: undefined, |
| | | postIds: [], |
| | | roleIds: [] |
| | | }; |
| | | proxy.resetForm("userRef"); |
| | | }; |
| | | roleIds: [], |
| | | } |
| | | proxy.resetForm("userRef") |
| | | } |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | }; |
| | | open.value = false |
| | | reset() |
| | | } |
| | | /** 新增按钮操作 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | getUser().then(response => { |
| | | postOptions.value = response.posts; |
| | | roleOptions.value = response.roles; |
| | | open.value = true; |
| | | title.value = "添加用户"; |
| | | form.value.password = initPassword.value; |
| | | }); |
| | | }; |
| | | reset() |
| | | getUser().then((response) => { |
| | | postOptions.value = response.posts |
| | | roleOptions.value = response.roles |
| | | open.value = true |
| | | title.value = "添加用户" |
| | | form.value.password = initPassword.value |
| | | }) |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const userId = row.userId || ids.value; |
| | | getUser(userId).then(response => { |
| | | form.value = response.data; |
| | | postOptions.value = response.posts; |
| | | roleOptions.value = response.roles; |
| | | form.value.postIds = response.postIds; |
| | | form.value.roleIds = response.roleIds; |
| | | open.value = true; |
| | | title.value = "修改用户"; |
| | | form.password = ""; |
| | | }); |
| | | }; |
| | | reset() |
| | | const userId = row.userId || ids.value |
| | | getUser(userId).then((response) => { |
| | | form.value = response.data |
| | | postOptions.value = response.posts |
| | | roleOptions.value = response.roles |
| | | form.value.postIds = response.postIds |
| | | form.value.roleIds = response.roleIds |
| | | open.value = true |
| | | title.value = "修改用户" |
| | | form.password = "" |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["userRef"].validate(valid => { |
| | | proxy.$refs["userRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (form.value.userId != undefined) { |
| | | updateUser(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | updateUser(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("修改成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } else { |
| | | addUser(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | addUser(form.value).then((response) => { |
| | | proxy.$modal.msgSuccess("新增成功") |
| | | open.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | |
| | | getDeptTree(); |
| | | getList(); |
| | | getDeptTree() |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> |
| | | <el-form-item label="表名称" prop="tableName"> |
| | | <el-input |
| | | v-model="queryParams.tableName" |
| | | placeholder="请输入表名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="表描述" prop="tableComment"> |
| | | <el-input |
| | | v-model="queryParams.tableComment" |
| | | placeholder="请输入表描述" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="app-container page"> |
| | | <div class="form-card"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch"> |
| | | <el-form-item label="表名称" prop="tableName"> |
| | | <el-input |
| | | v-model="queryParams.tableName" |
| | | placeholder="请输入表名称" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="表描述" prop="tableComment"> |
| | | <el-input |
| | | v-model="queryParams.tableComment" |
| | | placeholder="请输入表描述" |
| | | clearable |
| | | style="width: 200px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="创建时间" style="width: 308px"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | value-format="YYYY-MM-DD" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Download" |
| | | :disabled="multiple" |
| | | @click="handleGenTable" |
| | | v-hasPermi="['tool:gen:code']" |
| | | >生成</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="openCreateTable" |
| | | v-hasRole="['admin']" |
| | | >创建</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="Upload" |
| | | @click="openImportTable" |
| | | v-hasPermi="['tool:gen:import']" |
| | | >导入</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleEditTable" |
| | | v-hasPermi="['tool:gen:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['tool:gen:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" align="center" width="55"></el-table-column> |
| | | <el-table-column label="序号" type="index" width="50" align="center"> |
| | | <template #default="scope"> |
| | | <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="表名称" |
| | | align="center" |
| | | prop="tableName" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="表描述" |
| | | align="center" |
| | | prop="tableComment" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="实体" |
| | | align="center" |
| | | prop="className" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="160" /> |
| | | <el-table-column label="更新时间" align="center" prop="updateTime" width="160" /> |
| | | <el-table-column label="操作" align="center" width="330" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="预览" placement="top"> |
| | | <el-button link type="primary" icon="View" @click="handlePreview(scope.row)" v-hasPermi="['tool:gen:preview']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="编辑" placement="top"> |
| | | <el-button link type="primary" icon="Edit" @click="handleEditTable(scope.row)" v-hasPermi="['tool:gen:edit']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top"> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:remove']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="同步" placement="top"> |
| | | <el-button link type="primary" icon="Refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['tool:gen:edit']"></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="生成代码" placement="top"> |
| | | <el-button link type="primary" icon="Download" @click="handleGenTable(scope.row)" v-hasPermi="['tool:gen:code']"></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total>0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | <div class="table-bg-style"> |
| | | <div class="table-box"> |
| | | <div style="margin-bottom: 12px"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Download" |
| | | :disabled="multiple" |
| | | @click="handleGenTable" |
| | | v-hasPermi="['tool:gen:code']" |
| | | >生成</el-button |
| | | > |
| | | <el-button type="primary" plain icon="Plus" @click="openCreateTable" v-hasRole="['admin']">创建</el-button> |
| | | <el-button type="info" plain icon="Upload" @click="openImportTable" v-hasPermi="['tool:gen:import']" |
| | | >导入</el-button |
| | | > |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleEditTable" |
| | | v-hasPermi="['tool:gen:edit']" |
| | | >修改</el-button |
| | | > |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['tool:gen:remove']" |
| | | >删除</el-button |
| | | > |
| | | </div> |
| | | <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" align="center" width="60"></el-table-column> |
| | | <el-table-column label="序号" type="index" width="60" align="center"> |
| | | <template #default="scope"> |
| | | <span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="表名称" align="center" prop="tableName" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="表描述" align="center" prop="tableComment" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="实体" align="center" prop="className" :show-overflow-tooltip="true" /> |
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="160" /> |
| | | <el-table-column label="更新时间" align="center" prop="updateTime" width="160" /> |
| | | <el-table-column label="操作" align="center" width="330" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="预览" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="View" |
| | | @click="handlePreview(scope.row)" |
| | | v-hasPermi="['tool:gen:preview']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="编辑" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleEditTable(scope.row)" |
| | | v-hasPermi="['tool:gen:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="删除" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | v-hasPermi="['tool:gen:remove']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="同步" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Refresh" |
| | | @click="handleSynchDb(scope.row)" |
| | | v-hasPermi="['tool:gen:edit']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip content="生成代码" placement="top"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Download" |
| | | @click="handleGenTable(scope.row)" |
| | | v-hasPermi="['tool:gen:code']" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <!-- 预览界面 --> |
| | | <el-dialog :title="preview.title" v-model="preview.open" width="80%" top="5vh" append-to-body class="scrollbar"> |
| | | <el-tabs v-model="preview.activeName"> |
| | | <el-tab-pane |
| | | v-for="(value, key) in preview.data" |
| | | :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" |
| | | :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" |
| | | :label="key.substring(key.lastIndexOf('/') + 1, key.indexOf('.vm'))" |
| | | :name="key.substring(key.lastIndexOf('/') + 1, key.indexOf('.vm'))" |
| | | :key="value" |
| | | > |
| | | <el-link :underline="false" icon="DocumentCopy" v-copyText="value" v-copyText:callback="copyTextSuccess" style="float:right"> 复制</el-link> |
| | | <el-link |
| | | :underline="false" |
| | | icon="DocumentCopy" |
| | | v-copyText="value" |
| | | v-copyText:callback="copyTextSuccess" |
| | | style="float: right" |
| | | > 复制</el-link |
| | | > |
| | | <pre>{{ value }}</pre> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | |
| | | </template> |
| | | |
| | | <script setup name="Gen"> |
| | | import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; |
| | | import router from "@/router"; |
| | | import importTable from "./importTable"; |
| | | import createTable from "./createTable"; |
| | | import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen" |
| | | import router from "@/router" |
| | | import importTable from "./importTable" |
| | | import createTable from "./createTable" |
| | | |
| | | const route = useRoute(); |
| | | const { proxy } = getCurrentInstance(); |
| | | const route = useRoute() |
| | | const { proxy } = getCurrentInstance() |
| | | |
| | | const tableList = ref([]); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const tableNames = ref([]); |
| | | const dateRange = ref([]); |
| | | const uniqueId = ref(""); |
| | | const tableList = ref([]) |
| | | const loading = ref(true) |
| | | const showSearch = ref(true) |
| | | const ids = ref([]) |
| | | const single = ref(true) |
| | | const multiple = ref(true) |
| | | const total = ref(0) |
| | | const tableNames = ref([]) |
| | | const dateRange = ref([]) |
| | | const uniqueId = ref("") |
| | | |
| | | const data = reactive({ |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | tableName: undefined, |
| | | tableComment: undefined |
| | | tableComment: undefined, |
| | | }, |
| | | preview: { |
| | | open: false, |
| | | title: "代码预览", |
| | | data: {}, |
| | | activeName: "domain.java" |
| | | } |
| | | }); |
| | | activeName: "domain.java", |
| | | }, |
| | | }) |
| | | |
| | | const { queryParams, preview } = toRefs(data); |
| | | const { queryParams, preview } = toRefs(data) |
| | | |
| | | onActivated(() => { |
| | | const time = route.query.t; |
| | | const time = route.query.t |
| | | if (time != null && time != uniqueId.value) { |
| | | uniqueId.value = time; |
| | | queryParams.value.pageNum = Number(route.query.pageNum); |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryForm"); |
| | | getList(); |
| | | uniqueId.value = time |
| | | queryParams.value.pageNum = Number(route.query.pageNum) |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryForm") |
| | | getList() |
| | | } |
| | | }) |
| | | |
| | | /** 查询表集合 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listTable(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => { |
| | | tableList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | loading.value = true |
| | | listTable(proxy.addDateRange(queryParams.value, dateRange.value)).then((response) => { |
| | | tableList.value = response.rows |
| | | total.value = response.total |
| | | loading.value = false |
| | | }) |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1 |
| | | getList() |
| | | } |
| | | /** 生成代码操作 */ |
| | | function handleGenTable(row) { |
| | | const tbNames = row.tableName || tableNames.value; |
| | | const tbNames = row.tableName || tableNames.value |
| | | if (tbNames == "") { |
| | | proxy.$modal.msgError("请选择要生成的数据"); |
| | | return; |
| | | proxy.$modal.msgError("请选择要生成的数据") |
| | | return |
| | | } |
| | | if (row.genType === "1") { |
| | | genCode(row.tableName).then(response => { |
| | | proxy.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath); |
| | | }); |
| | | genCode(row.tableName).then((response) => { |
| | | proxy.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath) |
| | | }) |
| | | } else { |
| | | proxy.$download.zip("/tool/gen/batchGenCode?tables=" + tbNames, "ruoyi.zip"); |
| | | proxy.$download.zip("/tool/gen/batchGenCode?tables=" + tbNames, "ruoyi.zip") |
| | | } |
| | | } |
| | | /** 同步数据库操作 */ |
| | | function handleSynchDb(row) { |
| | | const tableName = row.tableName; |
| | | proxy.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function () { |
| | | return synchDb(tableName); |
| | | }).then(() => { |
| | | proxy.$modal.msgSuccess("同步成功"); |
| | | }).catch(() => {}); |
| | | const tableName = row.tableName |
| | | proxy.$modal |
| | | .confirm('确认要强制同步"' + tableName + '"表结构吗?') |
| | | .then(function () { |
| | | return synchDb(tableName) |
| | | }) |
| | | .then(() => { |
| | | proxy.$modal.msgSuccess("同步成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | /** 打开导入表弹窗 */ |
| | | function openImportTable() { |
| | | proxy.$refs["importRef"].show(); |
| | | proxy.$refs["importRef"].show() |
| | | } |
| | | /** 打开创建表弹窗 */ |
| | | function openCreateTable() { |
| | | proxy.$refs["createRef"].show(); |
| | | proxy.$refs["createRef"].show() |
| | | } |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | dateRange.value = []; |
| | | proxy.resetForm("queryRef"); |
| | | handleQuery(); |
| | | dateRange.value = [] |
| | | proxy.resetForm("queryRef") |
| | | handleQuery() |
| | | } |
| | | /** 预览按钮 */ |
| | | function handlePreview(row) { |
| | | previewTable(row.tableId).then(response => { |
| | | preview.value.data = response.data; |
| | | preview.value.open = true; |
| | | preview.value.activeName = "domain.java"; |
| | | }); |
| | | previewTable(row.tableId).then((response) => { |
| | | preview.value.data = response.data |
| | | preview.value.open = true |
| | | preview.value.activeName = "domain.java" |
| | | }) |
| | | } |
| | | /** 复制代码成功 */ |
| | | function copyTextSuccess() { |
| | | proxy.$modal.msgSuccess("复制成功"); |
| | | proxy.$modal.msgSuccess("复制成功") |
| | | } |
| | | // 多选框选中数据 |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map(item => item.tableId); |
| | | tableNames.value = selection.map(item => item.tableName); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map((item) => item.tableId) |
| | | tableNames.value = selection.map((item) => item.tableName) |
| | | single.value = selection.length != 1 |
| | | multiple.value = !selection.length |
| | | } |
| | | /** 修改按钮操作 */ |
| | | function handleEditTable(row) { |
| | | const tableId = row.tableId || ids.value[0]; |
| | | router.push({ path: "/tool/gen-edit/index/" + tableId, query: { pageNum: queryParams.value.pageNum } }); |
| | | const tableId = row.tableId || ids.value[0] |
| | | router.push({ path: "/tool/gen-edit/index/" + tableId, query: { pageNum: queryParams.value.pageNum } }) |
| | | } |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const tableIds = row.tableId || ids.value; |
| | | proxy.$modal.confirm('是否确认删除表编号为"' + tableIds + '"的数据项?').then(function () { |
| | | return delTable(tableIds); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | const tableIds = row.tableId || ids.value |
| | | proxy.$modal |
| | | .confirm('是否确认删除表编号为"' + tableIds + '"的数据项?') |
| | | .then(function () { |
| | | return delTable(tableIds) |
| | | }) |
| | | .then(() => { |
| | | getList() |
| | | proxy.$modal.msgSuccess("删除成功") |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | |
| | | getList(); |
| | | getList() |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "@/assets/styles/page.scss"; |
| | | </style> |