src/api/system/user.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/login.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/placement-batch/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/relocatablePersonnel/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/operlog/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/role/authUser.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/role/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/role/selectUser.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/user/authRole.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/user/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/api/system/user.js
@@ -134,3 +134,11 @@ method: 'get' }) } // 角色选择框 export function getRoleOptions() { return request({ url: '/system/role/optionselect', method: 'get' }) } src/main.js
@@ -73,7 +73,7 @@ */ Vue.use(Element, { size: Cookies.get('size') || 'medium' // set element-ui default size size: 'small' // set element-ui default size }) Vue.config.productionTip = false src/views/login.vue
@@ -56,7 +56,7 @@ </el-form> <!-- 底部 --> <div class="el-login-footer"> <span>Copyright © 2018-2025 ruoyi.vip All Rights Reserved.</span> <!-- <span>Copyright © 2018-2025 ruoyi.vip All Rights Reserved.</span> --> </div> </div> </template> src/views/placement-batch/index.vue
@@ -15,7 +15,7 @@ </el-form-item> <el-form-item> <el-button type="primary" size="small" @click="handleQuery">查询</el-button> <el-button type="primary" size="small" @click="handleAdd">添加</el-button> <el-button type="primary" size="small" @click="handleReset">重置</el-button> </el-form-item> </el-form> </div> @@ -124,9 +124,16 @@ this.queryParams.pageNum = 1 this.getList() }, /** 新增按钮操作 */ handleAdd() { /** 重置按钮操作 */ handleReset() { // TODO: 实现新增逻辑 this.queryParams = { pageNum: 1, pageSize: 10, batchNumber: undefined, status: undefined } this.getList() }, /** 导入资金批次 */ handleImportAll() { @@ -146,7 +153,11 @@ /** 导入资金批次 */ importPrice(form) { console.log('//////////////',form) importPlacementBatch(form).then(res => { let formData = new FormData() formData.append('assetFile', form.assetFile) formData.append('householdFile', form.householdFile) formData.append('batchNumber', form.batchNumber) importPlacementBatch(formData).then(res => { if(res.code == 200) { this.$message.success('导入成功') this.dialogVisible = false src/views/relocatablePersonnel/index.vue
@@ -28,19 +28,18 @@ <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" size="small" @click="handleAdd" v-hasPermi="['system:role:add']">新增待安置人员</el-button> v-hasPermi="['RelocatablePersonnel:Add']">新增待安置人员</el-button> </el-col> <el-col :span="1.5"> <el-button type="success" size="small" @click="download" v-hasPermi="['system:role:add']">下载导入模板</el-button> v-hasPermi="['RelocatablePersonnel:download']">下载导入模板</el-button> </el-col> <el-col :span="1.5"> <el-upload :headers="{ ...headers }" action="http://182.140.209.168:8888/api/placement/imports" <el-upload v-hasPermi="['RelocatablePersonnel:import']" :headers="{ ...headers }" action="http://182.140.209.168:8888/api/placement/imports" :show-file-list="false" :on-success="handleImportSuccess" :before-upload="beforeImportUpload"> <el-button type="primary" size="small">批量导入</el-button> </el-upload> </el-col> <right-toolbar @queryTable="getList"></right-toolbar> </el-row> <el-table v-loading="loading" :data="listData"> @@ -77,11 +76,11 @@ <el-table-column label="操作" fixed="right" width="180"> <template slot-scope="{row}"> <el-button size="small" type="text" @click="handleUpdate(row, 'view')" v-hasPermi="['system:role:edit']">详情</el-button> v-hasPermi="['RelocatablePersonnel:Detail']">详情</el-button> <el-button size="small" type="text" @click="handleUpdate(row, 'edit')" v-hasPermi="['system:role:edit']">修改</el-button> v-hasPermi="['RelocatablePersonnel:Edit']">修改</el-button> <el-button size="small" type="text" @click="handleDelete(row)" v-hasPermi="['system:role:remove']">删除</el-button> v-hasPermi="['RelocatablePersonnel:del']">删除</el-button> </template> </el-table-column> </el-table> src/views/system/operlog/index.vue
New file @@ -0,0 +1,323 @@ <template> <div class="app-container"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form-item label="操作地址" prop="operIp"> <el-input v-model="queryParams.operIp" placeholder="请输入操作地址" clearable style="width: 240px;" @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="系统模块" prop="title"> <el-input v-model="queryParams.title" placeholder="请输入系统模块" clearable style="width: 240px;" @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="操作人员" prop="operName"> <el-input v-model="queryParams.operName" placeholder="请输入操作人员" clearable style="width: 240px;" @keyup.enter.native="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 dict.type.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 dict.type.sys_common_status" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> <el-form-item label="操作时间"> <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" ></el-date-picker> </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['monitor:operlog:remove']" >删除</el-button> </el-col> <el-col :span="1.5"> <el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:operlog:remove']" >清空</el-button> </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['monitor:operlog:export']" >导出</el-button> </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> </el-row> <el-table ref="tables" v-loading="loading" :data="list" @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 slot-scope="scope"> <dict-tag :options="dict.type.sys_oper_type" :value="scope.row.businessType"/> </template> </el-table-column> <el-table-column label="操作人员" align="center" prop="operName" width="110" :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="operLocation" :show-overflow-tooltip="true" /> <el-table-column label="操作状态" align="center" prop="status"> <template slot-scope="scope"> <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/> </template> </el-table-column> <el-table-column label="操作日期" align="center" prop="operTime" width="160" sortable="custom" :sort-orders="['descending', 'ascending']"> <template slot-scope="scope"> <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']"> <template slot-scope="scope"> <span>{{ scope.row.costTime }}毫秒</span> </template> </el-table-column> <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <template slot-scope="scope"> <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)" v-hasPermi="['monitor:operlog:query']" >详细</el-button> </template> </el-table-column> </el-table> <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <!-- 操作日志详细 --> <el-dialog title="操作日志详细" :visible.sync="open" width="800px" append-to-body> <el-form ref="form" :model="form" label-width="100px" size="mini"> <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> <div slot="footer" class="dialog-footer"> <el-button @click="open = false">关 闭</el-button> </div> </el-dialog> </div> </template> <script> import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog"; export default { name: "Operlog", dicts: ['sys_oper_type', 'sys_common_status'], data() { return { // 遮罩层 loading: true, // 选中数组 ids: [], // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 表格数据 list: [], // 是否显示弹出层 open: false, // 日期范围 dateRange: [], // 默认排序 defaultSort: { prop: "operTime", order: "descending" }, // 表单参数 form: {}, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, operIp: undefined, title: undefined, operName: undefined, businessType: undefined, status: undefined } }; }, created() { this.getList(); }, methods: { /** 查询登录日志 */ getList() { this.loading = true; list(this.addDateRange(this.queryParams, this.dateRange)).then( response => { this.list = response.rows; this.total = response.total; this.loading = false; } ); }, // 操作日志类型字典翻译 typeFormat(row, column) { return this.selectDictLabel(this.dict.type.sys_oper_type, row.businessType); }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1; this.getList(); }, /** 重置按钮操作 */ resetQuery() { this.dateRange = []; this.resetForm("queryForm"); this.queryParams.pageNum = 1; this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order) }, /** 多选框选中数据 */ handleSelectionChange(selection) { this.ids = selection.map(item => item.operId) this.multiple = !selection.length }, /** 排序触发事件 */ handleSortChange(column, prop, order) { this.queryParams.orderByColumn = column.prop; this.queryParams.isAsc = column.order; this.getList(); }, /** 详细按钮操作 */ handleView(row) { this.open = true; this.form = row; }, /** 删除按钮操作 */ handleDelete(row) { const operIds = row.operId || this.ids; this.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?').then(function() { return delOperlog(operIds); }).then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { this.$modal.confirm('是否确认清空所有操作日志数据项?').then(function() { return cleanOperlog(); }).then(() => { this.getList(); this.$modal.msgSuccess("清空成功"); }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { this.download('monitor/operlog/export', { ...this.queryParams }, `operlog_${new Date().getTime()}.xlsx`) } } }; </script> src/views/system/role/authUser.vue
File was deleted src/views/system/role/index.vue
@@ -1,118 +1,20 @@ <template> <div class="app-container"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"> <el-form-item label="角色名称" prop="roleName"> <el-input v-model="queryParams.roleName" placeholder="请输入角色名称" clearable style="width: 240px" @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="权限字符" prop="roleKey"> <el-input v-model="queryParams.roleKey" placeholder="请输入权限字符" clearable style="width: 240px" @keyup.enter.native="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 dict.type.sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> <el-form-item label="创建时间"> <el-date-picker v-model="dateRange" style="width: 240px" 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="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:role:add']" >新增</el-button> <el-button type="primary" size="mini" @click="handleAdd" v-hasPermi="['system:role:add']">新增角色</el-button> </el-col> <el-col :span="1.5"> <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:role:edit']" >修改</el-button> <el-button type="danger" size="mini" @click="handleDelete" v-hasPermi="['system:role:remove']">批量删除</el-button> </el-col> <el-col :span="1.5"> <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:role:remove']" >删除</el-button> </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:role:export']" >导出</el-button> </el-col> <right-toolbar :showSearch.sync="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 slot-scope="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="角色名称" prop="roleName" width="120" /> <el-table-column label="备注说明" prop="remark" :show-overflow-tooltip="true" width="150" /> <el-table-column label="创建人" prop="createBy" width="100" /> <el-table-column label="创建时间" align="center" prop="createTime" width="180"> <template slot-scope="scope"> <span>{{ parseTime(scope.row.createTime) }}</span> @@ -120,40 +22,14 @@ </el-table-column> <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <template slot-scope="scope" v-if="scope.row.roleId !== 1"> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:role:edit']" >修改</el-button> <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']" >删除</el-button> <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']"> <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button> <el-dropdown-menu slot="dropdown"> <el-dropdown-item command="handleDataScope" icon="el-icon-circle-check" v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item> <el-dropdown-item command="handleAuthUser" icon="el-icon-user" v-hasPermi="['system:role:edit']">分配用户</el-dropdown-item> </el-dropdown-menu> </el-dropdown> <el-button type="text" @click="handleUpdate(scope.row)" v-hasPermi="['system:role:edit']">编辑</el-button> <el-button type="text" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']">删除</el-button> </template> </el-table-column> </el-table> <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <!-- 添加或修改角色配置对话框 --> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> @@ -161,44 +37,16 @@ <el-form-item label="角色名称" prop="roleName"> <el-input v-model="form.roleName" placeholder="请输入角色名称" /> </el-form-item> <el-form-item prop="roleKey"> <span slot="label"> <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top"> <i class="el-icon-question"></i> </el-tooltip> 权限字符 </span> <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 dict.type.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="menu" node-key="id" :check-strictly="!form.menuCheckStrictly" empty-text="加载中,请稍候" :props="defaultProps" ></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-item label="权限配置" required=""> <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="menu" node-key="id" :check-strictly="!form.menuCheckStrictly" empty-text="加载中,请稍候" :props="defaultProps"></el-tree> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> @@ -206,70 +54,21 @@ <el-button @click="cancel">取 消</el-button> </div> </el-dialog> <!-- 分配角色数据权限对话框 --> <el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body> <el-form :model="form" label-width="80px"> <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="dept" node-key="id" :check-strictly="!form.deptCheckStrictly" empty-text="加载中,请稍候" :props="defaultProps" ></el-tree> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitDataScope">确 定</el-button> <el-button @click="cancelDataScope">取 消</el-button> </div> </el-dialog> </div> </template> <script> import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role"; import { listRole, getRole, delRole, addRole, updateRole } from "@/api/system/role"; import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; export default { name: "Role", dicts: ['sys_normal_disable'], data() { return { // 遮罩层 loading: true, // 选中数组 ids: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 角色表格数据 @@ -278,48 +77,14 @@ title: "", // 是否显示弹出层 open: false, // 是否显示弹出层(数据权限) openDataScope: false, menuExpand: false, menuNodeAll: false, deptExpand: true, deptNodeAll: false, // 日期范围 dateRange: [], // 数据范围选项 dataScopeOptions: [ { value: "1", label: "全部数据权限" }, { value: "2", label: "自定数据权限" }, { value: "3", label: "本部门数据权限" }, { value: "4", label: "本部门及以下数据权限" }, { value: "5", label: "仅本人数据权限" } ], // 菜单列表 menuOptions: [], // 部门列表 deptOptions: [], // 查询参数 queryParams: { pageNum: 1, pageSize: 10, roleName: undefined, roleKey: undefined, status: undefined }, // 表单参数 form: {}, @@ -332,12 +97,6 @@ roleName: [ { required: true, message: "角色名称不能为空", trigger: "blur" } ], roleKey: [ { required: true, message: "权限字符不能为空", trigger: "blur" } ], roleSort: [ { required: true, message: "角色顺序不能为空", trigger: "blur" } ] } }; }, @@ -349,10 +108,10 @@ getList() { this.loading = true; listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => { this.roleList = response.rows; this.total = response.total; this.loading = false; } this.roleList = response.rows; this.total = response.total; this.loading = false; } ); }, /** 查询菜单树结构 */ @@ -370,15 +129,6 @@ checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); return checkedKeys; }, // 所有部门节点数据 getDeptAllCheckedKeys() { // 目前被选中的部门节点 let checkedKeys = this.$refs.dept.getCheckedKeys(); // 半选中的部门节点 let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys(); checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); return checkedKeys; }, /** 根据角色ID查询菜单树结构 */ getRoleMenuTreeselect(roleId) { return roleMenuTreeselect(roleId).then(response => { @@ -386,32 +136,9 @@ return response; }); }, /** 根据角色ID查询部门树结构 */ getDeptTree(roleId) { return deptTreeSelect(roleId).then(response => { this.deptOptions = response.depts; return response; }); }, // 角色状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用"; this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function() { return changeRoleStatus(row.roleId, row.status); }).then(() => { this.$modal.msgSuccess(text + "成功"); }).catch(function() { row.status = row.status === "0" ? "1" : "0"; }); }, // 取消按钮 cancel() { this.open = false; this.reset(); }, // 取消按钮(数据权限) cancelDataScope() { this.openDataScope = false; this.reset(); }, // 表单重置 @@ -419,20 +146,14 @@ if (this.$refs.menu != undefined) { this.$refs.menu.setCheckedKeys([]); } this.menuExpand = false, this.menuNodeAll = false, this.deptExpand = true, this.deptNodeAll = false, this.menuExpand = false this.menuNodeAll = false this.form = { roleId: undefined, roleName: undefined, roleKey: undefined, roleSort: 0, status: "0", menuIds: [], deptIds: [], menuCheckStrictly: true, deptCheckStrictly: true, remark: undefined }; this.resetForm("form"); @@ -451,21 +172,6 @@ // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.roleId) this.single = selection.length!=1 this.multiple = !selection.length }, // 更多操作触发 handleCommand(command, row) { switch (command) { case "handleDataScope": this.handleDataScope(row); break; case "handleAuthUser": this.handleAuthUser(row); break; default: break; } }, // 树权限(展开/折叠) handleCheckedTreeExpand(value, type) { @@ -484,17 +190,17 @@ // 树权限(全选/全不选) handleCheckedTreeNodeAll(value, type) { if (type == 'menu') { this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []); this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []); } else if (type == 'dept') { this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []); this.$refs.dept.setCheckedNodes(value ? this.deptOptions : []); } }, // 树权限(父子联动) handleCheckedTreeConnect(value, type) { if (type == 'menu') { this.form.menuCheckStrictly = value ? true: false; this.form.menuCheckStrictly = value ? true : false; } else if (type == 'dept') { this.form.deptCheckStrictly = value ? true: false; this.form.deptCheckStrictly = value ? true : false; } }, /** 新增按钮操作 */ @@ -516,43 +222,22 @@ roleMenu.then(res => { let checkedKeys = res.checkedKeys checkedKeys.forEach((v) => { this.$nextTick(()=>{ this.$refs.menu.setChecked(v, true ,false); }) this.$nextTick(() => { this.$refs.menu.setChecked(v, true, false); }) }) }); }); }); this.title = "修改角色"; }, /** 选择角色权限范围触发 */ dataScopeSelectChange(value) { if(value !== '2') { this.$refs.dept.setCheckedKeys([]); } }, /** 分配数据权限操作 */ handleDataScope(row) { this.reset(); const deptTreeSelect = this.getDeptTree(row.roleId); getRole(row.roleId).then(response => { this.form = response.data; this.openDataScope = true; this.$nextTick(() => { deptTreeSelect.then(res => { this.$refs.dept.setCheckedKeys(res.checkedKeys); }); }); }); this.title = "分配数据权限"; }, /** 分配用户操作 */ handleAuthUser: function(row) { handleAuthUser: function (row) { const roleId = row.roleId; this.$router.push("/system/role-auth/user/" + roleId); }, /** 提交按钮 */ submitForm: function() { submitForm: function () { this.$refs["form"].validate(valid => { if (valid) { if (this.form.roleId != undefined) { @@ -573,26 +258,15 @@ } }); }, /** 提交按钮(数据权限) */ submitDataScope: function() { if (this.form.roleId != undefined) { this.form.deptIds = this.getDeptAllCheckedKeys(); dataScope(this.form).then(response => { this.$modal.msgSuccess("修改成功"); this.openDataScope = false; this.getList(); }); } }, /** 删除按钮操作 */ handleDelete(row) { const roleIds = row.roleId || this.ids; this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function () { return delRole(roleIds); }).then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); }).catch(() => {}); }).catch(() => { }); }, /** 导出按钮操作 */ handleExport() { src/views/system/role/selectUser.vue
File was deleted src/views/system/user/authRole.vue
File was deleted src/views/system/user/index.vue
@@ -1,227 +1,100 @@ <template> <div class="app-container"> <el-row :gutter="20"> <splitpanes :horizontal="this.$store.getters.device === 'mobile'" class="default-theme"> <!--部门数据--> <pane size="16"> <el-col> <div class="head-container"> <el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" /> </div> <div class="head-container"> <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current @node-click="handleNodeClick" /> </div> </el-col> </pane> <!--用户数据--> <pane size="84"> <el-col> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form-item label="用户名称" prop="userName"> <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px" @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="手机号码" prop="phonenumber"> <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable style="width: 240px" @keyup.enter.native="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 dict.type.sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> <el-form-item label="创建时间"> <el-date-picker v-model="dateRange" style="width: 240px" 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="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-col> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"> <el-form-item label="账号名称"> <el-input v-model="queryParams.userName" placeholder="请输入" clearable /> </el-form-item> <el-form-item label="账号"> <el-input v-model="queryParams.nickName" placeholder="请输入" clearable /> </el-form-item> <el-form-item label="所属角色"> <el-select v-model="queryParams.roleId" placeholder="请选择" style="width: 240px"> <el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId" /> </el-select> </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button> <el-button icon="el-icon-refresh" size="small" @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="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:user:add']">新增</el-button> </el-col> <el-col :span="1.5"> <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:user:edit']">修改</el-button> </el-col> <el-col :span="1.5"> <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:user:remove']">删除</el-button> </el-col> <el-col :span="1.5"> <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button> </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出</el-button> </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> </el-row> <div class="mb8"> <el-button v-hasPermi="['system:user:add']" type="primary" size="small" @click="handleAdd">新增账号</el-button> <el-button v-hasPermi="['system:user:remove']" type="danger" size="small" @click="handleDelete">批量删除</el-button> </div> <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 slot-scope="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 slot-scope="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 slot-scope="scope" v-if="scope.row.userId !== 1"> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button> <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除</el-button> <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:user:resetPwd', 'system:user:edit']"> <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button> <el-dropdown-menu slot="dropdown"> <el-dropdown-item command="handleResetPwd" icon="el-icon-key" v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item> <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check" v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item> </el-dropdown-menu> </el-dropdown> </template> </el-table-column> </el-table> <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" :selectable="checkSelectable" /> <el-table-column label="账号名称" prop="userName" /> <el-table-column label="账号" prop="userName" /> <el-table-column label="所属角色" prop="role" /> <el-table-column label="创建时间" prop="createTime" /> <el-table-column label="是否启用" prop="createTime"> <template slot-scope="{row}"> <el-switch v-hasPermi="['system:user:EnableDisable']" :disabled="row.userId == 1" v-model="row.status" active-value="0" inactive-value="1" @change="handleStatusChange(row)" /> </template> </el-table-column> <el-table-column label="操作" width="180" align="center"> <template slot-scope="{row}"> <el-button v-hasPermi="['system:user:detail']" type="text" @click="handleEdit(row, 'detail')">详情</el-button> <el-button v-if="row.userId != 1" v-hasPermi="['system:user:edit']" type="text" @click="handleEdit(row, 'edit')">编辑</el-button> <el-button v-if="row.userId != 1" v-hasPermi="['system:user:remove']" type="text" @click="handleDelete(row)">删除</el-button> </template> </el-table-column> </el-table> <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> </el-col> </pane> </splitpanes> <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> </el-col> </el-row> <!-- 添加或修改用户配置对话框 --> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> <el-form ref="form" :model="form" :rules="rules" label-width="80px"> <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"> <treeselect v-model="form.deptId" :options="enabledDeptOptions" :show-count="true" placeholder="请选择归属部门" /> </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 dict.type.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 dict.type.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-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-form ref="form" :model="form" :rules="rules" label-width="100px"> <el-form-item label="账号名称:" prop="userName"> <el-input v-model="form.userName" placeholder="请输入" :disabled="isDetail" /> </el-form-item> <el-form-item label="账号:" prop="nickName"> <el-input v-model="form.nickName" placeholder="请输入" :disabled="isDetail" /> </el-form-item> <el-form-item label="初始密码:" prop="password"> <el-input v-model="form.password" placeholder="请输入" :disabled="isDetail" /> </el-form-item> <el-form-item label="所属角色:" prop="roleIds"> <el-select v-model="form.roleIds" placeholder="请选择" :disabled="isDetail"> <el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId" /> </el-select> </el-form-item> <el-form-item label="是否启用:" required> <el-switch :disabled="isDetail" v-model="form.status" active-value="0" inactive-value="1" /> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm">确 定</el-button> <el-button v-if="!isDetail" type="primary" @click="submitForm">保存</el-button> <el-button @click="cancel">取 消</el-button> </div> </el-dialog> <!-- 用户导入对话框 --> <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> <el-upload ref="upload" :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> <i class="el-icon-upload"></i> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__tip text-center" slot="tip"> <div class="el-upload__tip" slot="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> </el-upload> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitFileForm">确 定</el-button> <el-button @click="upload.open = false">取 消</el-button> </div> </el-dialog> </div> </template> <script> import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user"; import { getToken } from "@/utils/auth"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import { Splitpanes, Pane } from "splitpanes"; import "splitpanes/dist/splitpanes.css"; import { listUser, getUser, delUser, addUser, updateUser, changeUserStatus, getRoleOptions } from "@/api/system/user"; export default { name: "User", dicts: ['sys_normal_disable', 'sys_user_sex'], components: { Treeselect, Splitpanes, Pane }, data() { return { // 遮罩层 loading: true, // 选中数组 ids: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 @@ -230,154 +103,74 @@ userList: null, // 弹出层标题 title: "", // 所有部门树选项 deptOptions: undefined, // 过滤掉已禁用部门树选项 enabledDeptOptions: undefined, // 是否显示弹出层 open: false, // 部门名称 deptName: undefined, // 默认密码 initPassword: undefined, // 日期范围 dateRange: [], // 岗位选项 postOptions: [], // 角色选项 roleOptions: [], // 表单参数 form: {}, defaultProps: { children: "children", label: "label" }, // 用户导入参数 upload: { // 是否显示弹出层(用户导入) open: false, // 弹出层标题(用户导入) title: "", // 是否禁用上传 isUploading: false, // 是否更新已经存在的用户数据 updateSupport: 0, // 设置上传的请求头部 headers: { Authorization: "Bearer " + getToken() }, // 上传的地址 url: process.env.VUE_APP_BASE_API + "/system/user/importData" form: { userId: undefined, userName: undefined, nickName: undefined, password: undefined, roleIds: undefined, status: "0" }, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, userName: undefined, phonenumber: undefined, status: undefined, deptId: undefined nickName: undefined, roleId: undefined, }, // 列信息 columns: [ { key: 0, label: `用户编号`, visible: true }, { key: 1, label: `用户名称`, visible: true }, { key: 2, label: `用户昵称`, visible: true }, { key: 3, label: `部门`, visible: true }, { key: 4, label: `手机号码`, visible: true }, { key: 5, label: `状态`, visible: true }, { key: 6, label: `创建时间`, visible: true } ], // 表单校验 rules: { userName: [ { required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' } { required: true, message: "账号名称不能为空", trigger: "blur" } ], nickName: [ { required: true, message: "用户昵称不能为空", trigger: "blur" } { required: true, message: "账号不能为空", trigger: "blur" } ], password: [ { required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" } { required: true, 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" } roleIds: [ { required: true, message: "所属角色不能为空", trigger: "change" } ] } }, isDetail: false, // 是否是详情模式 roleOptions: [], }; }, watch: { // 根据名称筛选部门树 deptName(val) { this.$refs.tree.filter(val); } }, created() { this.getList(); this.getDeptTree(); this.getConfigKey("sys.user.initPassword").then(response => { this.initPassword = response.msg; getRoleOptions().then(response => { this.roleOptions = response.data; }); }, methods: { /** 查询用户列表 */ getList() { this.loading = true; listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => { this.userList = response.rows; this.total = response.total; this.loading = false; } ); }, /** 查询部门下拉树结构 */ getDeptTree() { deptTreeSelect().then(response => { this.deptOptions = response.data; this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data))); listUser(this.addDateRange(this.queryParams)).then(response => { this.userList = response.rows; this.total = response.total; this.loading = false; }); }, // 过滤禁用的部门 filterDisabledDept(deptList) { return deptList.filter(dept => { if (dept.disabled) { return false; } if (dept.children && dept.children.length) { dept.children = this.filterDisabledDept(dept.children); } return true; }); }, // 筛选节点 filterNode(value, data) { if (!value) return true; return data.label.indexOf(value) !== -1; }, // 节点单击事件 handleNodeClick(data) { this.queryParams.deptId = data.id; this.handleQuery(); }, // 用户状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用"; this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() { this.$modal.confirm('确认要' + text + '"' + row.userName + '"用户吗?').then(function () { return changeUserStatus(row.userId, row.status); }).then(() => { this.$modal.msgSuccess(text + "成功"); }).catch(function() { }).catch(function () { row.status = row.status === "0" ? "1" : "0"; }); }, @@ -390,18 +183,13 @@ reset() { this.form = { userId: undefined, deptId: undefined, userName: undefined, nickName: undefined, password: undefined, phonenumber: undefined, email: undefined, sex: undefined, status: "0", remark: undefined, postIds: [], roleIds: [] roleIds: undefined, status: "0" }; this.isDetail = false; this.resetForm("form"); }, /** 搜索按钮操作 */ @@ -411,85 +199,47 @@ }, /** 重置按钮操作 */ resetQuery() { this.dateRange = []; this.resetForm("queryForm"); this.queryParams.deptId = undefined; this.$refs.tree.setCurrentKey(null); this.handleQuery(); }, // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.userId); this.single = selection.length != 1; this.multiple = !selection.length; }, // 更多操作触发 handleCommand(command, row) { switch (command) { case "handleResetPwd": this.handleResetPwd(row); break; case "handleAuthRole": this.handleAuthRole(row); break; default: break; } }, /** 新增按钮操作 */ handleAdd() { this.reset(); getUser().then(response => { this.postOptions = response.posts; this.roleOptions = response.roles; this.open = true; this.title = "添加用户"; this.form.password = this.initPassword; }); }, /** 修改按钮操作 */ handleUpdate(row) { /** 编辑/详情按钮操作 */ handleEdit(row, type = 'edit') { this.reset(); const userId = row.userId || this.ids; const userId = row.userId; getUser(userId).then(response => { this.form = response.data; this.postOptions = response.posts; this.form = { userId: response.data.userId, userName: response.data.userName, nickName: response.data.nickName, password: '', // 编辑时不显示密码 roleIds: response.roleIds[0], status: response.data.status }; this.roleOptions = response.roles; this.$set(this.form, "postIds", response.postIds); this.$set(this.form, "roleIds", response.roleIds); this.open = true; this.title = "修改用户"; this.form.password = ""; this.title = type === 'edit' ? "编辑用户" : "用户详情"; this.isDetail = type === 'detail'; // 根据type判断是否为详情模式 }); }, /** 重置密码按钮操作 */ handleResetPwd(row) { this.$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 => { this.$modal.msgSuccess("修改成功,新密码是:" + value); }); }).catch(() => {}); }, /** 分配角色操作 */ handleAuthRole: function(row) { const userId = row.userId; this.$router.push("/system/user-auth/role/" + userId); }, /** 提交按钮 */ submitForm: function() { submitForm: function () { this.$refs["form"].validate(valid => { if (valid) { this.form.roleIds = [this.form.roleIds]; if (this.form.userId != undefined) { updateUser(this.form).then(response => { this.$modal.msgSuccess("修改成功"); @@ -508,46 +258,22 @@ }, /** 删除按钮操作 */ handleDelete(row) { if (this.ids.length == 0 && !row.userId) { this.$modal.msgWarning("请选择要删除的账号"); return; } const userIds = row.userId || this.ids; this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除账号名称为"' + userIds + '"的用户?').then(function () { return delUser(userIds); }).then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); }).catch(() => {}); }).catch(() => { }); }, /** 导出按钮操作 */ handleExport() { this.download('system/user/export', { ...this.queryParams }, `user_${new Date().getTime()}.xlsx`) /** 判断是否可选择 */ checkSelectable(row) { return row.userId !== 1; }, /** 导入按钮操作 */ handleImport() { this.upload.title = "用户导入"; this.upload.open = true; }, /** 下载模板操作 */ importTemplate() { this.download('system/user/importTemplate', { }, `user_template_${new Date().getTime()}.xlsx`) }, // 文件上传中处理 handleFileUploadProgress(event, file, fileList) { this.upload.isUploading = true; }, // 文件上传成功处理 handleFileSuccess(response, file, fileList) { this.upload.open = false; this.upload.isUploading = false; this.$refs.upload.clearFiles(); this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }); this.getList(); }, // 提交上传文件 submitFileForm() { this.$refs.upload.submit(); } } }; </script>