修改系统
This commit is contained in:
		
							
								
								
									
										362
									
								
								stdiet-ui/src/views/system/config/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										362
									
								
								stdiet-ui/src/views/system/config/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,362 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|       <el-form-item label="参数名称" prop="configName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.configName" | ||||
|           placeholder="请输入参数名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="参数键名" prop="configKey"> | ||||
|         <el-input | ||||
|           v-model="queryParams.configKey" | ||||
|           placeholder="请输入参数键名" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="系统内置" prop="configType"> | ||||
|         <el-select v-model="queryParams.configType" placeholder="系统内置" clearable size="small"> | ||||
|           <el-option | ||||
|             v-for="dict in typeOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="创建时间"> | ||||
|         <el-date-picker | ||||
|           v-model="dateRange" | ||||
|           size="small" | ||||
|           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="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:config:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="success" | ||||
|           icon="el-icon-edit" | ||||
|           size="mini" | ||||
|           :disabled="single" | ||||
|           @click="handleUpdate" | ||||
|           v-hasPermi="['system:config:edit']" | ||||
|         >修改</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-delete" | ||||
|           size="mini" | ||||
|           :disabled="multiple" | ||||
|           @click="handleDelete" | ||||
|           v-hasPermi="['system:config:remove']" | ||||
|         >删除</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="warning" | ||||
|           icon="el-icon-download" | ||||
|           size="mini" | ||||
|           @click="handleExport" | ||||
|           v-hasPermi="['system:config:export']" | ||||
|         >导出</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-refresh" | ||||
|           size="mini" | ||||
|           @click="handleClearCache" | ||||
|           v-hasPermi="['system:config:remove']" | ||||
|         >清理缓存</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="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" /> | ||||
|       <el-table-column label="系统内置" align="center" prop="configType" :formatter="typeFormat" /> | ||||
|       <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit" | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:config:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-delete" | ||||
|             @click="handleDelete(scope.row)" | ||||
|             v-hasPermi="['system:config: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" | ||||
|     /> | ||||
|  | ||||
|     <!-- 添加或修改参数配置对话框 --> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||||
|       <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||||
|         <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 typeOptions" | ||||
|               :key="dict.dictValue" | ||||
|               :label="dict.dictValue" | ||||
|             >{{dict.dictLabel}}</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> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, clearCache } from "@/api/system/config"; | ||||
|  | ||||
| export default { | ||||
|   name: "Config", | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 参数表格数据 | ||||
|       configList: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 类型数据字典 | ||||
|       typeOptions: [], | ||||
|       // 日期范围 | ||||
|       dateRange: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         configName: undefined, | ||||
|         configKey: undefined, | ||||
|         configType: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         configName: [ | ||||
|           { required: true, message: "参数名称不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         configKey: [ | ||||
|           { required: true, message: "参数键名不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         configValue: [ | ||||
|           { required: true, message: "参数键值不能为空", trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_yes_no").then(response => { | ||||
|       this.typeOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询参数列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||||
|           this.configList = response.rows; | ||||
|           this.total = response.total; | ||||
|           this.loading = false; | ||||
|         } | ||||
|       ); | ||||
|     }, | ||||
|     // 参数系统内置字典翻译 | ||||
|     typeFormat(row, column) { | ||||
|       return this.selectDictLabel(this.typeOptions, row.configType); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         configId: undefined, | ||||
|         configName: undefined, | ||||
|         configKey: undefined, | ||||
|         configValue: undefined, | ||||
|         configType: "Y", | ||||
|         remark: undefined | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.dateRange = []; | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd() { | ||||
|       this.reset(); | ||||
|       this.open = true; | ||||
|       this.title = "添加参数"; | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.configId) | ||||
|       this.single = selection.length!=1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       const configId = row.configId || this.ids | ||||
|       getConfig(configId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改参数"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.configId != undefined) { | ||||
|             updateConfig(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addConfig(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const configIds = row.configId || this.ids; | ||||
|       this.$confirm('是否确认删除参数编号为"' + configIds + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delConfig(configIds); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 导出按钮操作 */ | ||||
|     handleExport() { | ||||
|       const queryParams = this.queryParams; | ||||
|       this.$confirm('是否确认导出所有参数数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return exportConfig(queryParams); | ||||
|         }).then(response => { | ||||
|           this.download(response.msg); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 清理缓存按钮操作 */ | ||||
|     handleClearCache() { | ||||
|       clearCache().then(response => { | ||||
|         if (response.code === 200) { | ||||
|           this.msgSuccess("清理成功"); | ||||
|         } | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										320
									
								
								stdiet-ui/src/views/system/dept/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										320
									
								
								stdiet-ui/src/views/system/dept/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,320 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> | ||||
|       <el-form-item label="部门名称" prop="deptName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.deptName" | ||||
|           placeholder="请输入部门名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small"> | ||||
|           <el-option | ||||
|             v-for="dict in statusOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:dept:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||||
|     </el-row> | ||||
|  | ||||
|     <el-table | ||||
|       v-loading="loading" | ||||
|       :data="deptList" | ||||
|       row-key="deptId" | ||||
|       default-expand-all | ||||
|       :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="状态" :formatter="statusFormat" width="100"></el-table-column> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="200"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit"  | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:dept:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button  | ||||
|             size="mini"  | ||||
|             type="text"  | ||||
|             icon="el-icon-plus"  | ||||
|             @click="handleAdd(scope.row)" | ||||
|             v-hasPermi="['system:dept:add']" | ||||
|           >新增</el-button> | ||||
|           <el-button | ||||
|             v-if="scope.row.parentId != 0" | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-delete" | ||||
|             @click="handleDelete(scope.row)" | ||||
|             v-hasPermi="['system:dept:remove']" | ||||
|           >删除</el-button> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|     </el-table> | ||||
|  | ||||
|     <!-- 添加或修改部门对话框 --> | ||||
|     <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="24" v-if="form.parentId !== 0"> | ||||
|             <el-form-item label="上级部门" prop="parentId"> | ||||
|               <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" /> | ||||
|             </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 statusOptions" | ||||
|                   :key="dict.dictValue" | ||||
|                   :label="dict.dictValue" | ||||
|                 >{{dict.dictLabel}}</el-radio> | ||||
|               </el-radio-group> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
|       </el-form> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; | ||||
| import Treeselect from "@riophae/vue-treeselect"; | ||||
| import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||||
|  | ||||
| export default { | ||||
|   name: "Dept", | ||||
|   components: { Treeselect }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 表格树数据 | ||||
|       deptList: [], | ||||
|       // 部门树选项 | ||||
|       deptOptions: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 状态数据字典 | ||||
|       statusOptions: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         deptName: undefined, | ||||
|         status: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       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" | ||||
|           } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_normal_disable").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询部门列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listDept(this.queryParams).then(response => { | ||||
|         this.deptList = this.handleTree(response.data, "deptId"); | ||||
|         this.loading = false; | ||||
|       }); | ||||
|     }, | ||||
|     /** 转换部门数据结构 */ | ||||
|     normalizer(node) { | ||||
|       if (node.children && !node.children.length) { | ||||
|         delete node.children; | ||||
|       } | ||||
|       return { | ||||
|         id: node.deptId, | ||||
|         label: node.deptName, | ||||
|         children: node.children | ||||
|       }; | ||||
|     }, | ||||
|     // 字典状态字典翻译 | ||||
|     statusFormat(row, column) { | ||||
|       return this.selectDictLabel(this.statusOptions, row.status); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         deptId: undefined, | ||||
|         parentId: undefined, | ||||
|         deptName: undefined, | ||||
|         orderNum: undefined, | ||||
|         leader: undefined, | ||||
|         phone: undefined, | ||||
|         email: undefined, | ||||
|         status: "0" | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd(row) { | ||||
|       this.reset(); | ||||
|       if (row != undefined) { | ||||
|         this.form.parentId = row.deptId; | ||||
|       } | ||||
|       this.open = true; | ||||
|       this.title = "添加部门"; | ||||
|       listDept().then(response => { | ||||
| 	        this.deptOptions = this.handleTree(response.data, "deptId"); | ||||
|       }); | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       getDept(row.deptId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改部门"; | ||||
|       }); | ||||
|       listDeptExcludeChild(row.deptId).then(response => { | ||||
| 	        this.deptOptions = this.handleTree(response.data, "deptId"); | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.deptId != undefined) { | ||||
|             updateDept(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addDept(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delDept(row.deptId); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										354
									
								
								stdiet-ui/src/views/system/dict/data.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										354
									
								
								stdiet-ui/src/views/system/dict/data.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,354 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|       <el-form-item label="字典名称" prop="dictType"> | ||||
|         <el-select v-model="queryParams.dictType" size="small"> | ||||
|           <el-option | ||||
|             v-for="item in typeOptions" | ||||
|             :key="item.dictId" | ||||
|             :label="item.dictName" | ||||
|             :value="item.dictType" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="字典标签" prop="dictLabel"> | ||||
|         <el-input | ||||
|           v-model="queryParams.dictLabel" | ||||
|           placeholder="请输入字典标签" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small"> | ||||
|           <el-option | ||||
|             v-for="dict in statusOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:dict:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="success" | ||||
|           icon="el-icon-edit" | ||||
|           size="mini" | ||||
|           :disabled="single" | ||||
|           @click="handleUpdate" | ||||
|           v-hasPermi="['system:dict:edit']" | ||||
|         >修改</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-delete" | ||||
|           size="mini" | ||||
|           :disabled="multiple" | ||||
|           @click="handleDelete" | ||||
|           v-hasPermi="['system:dict:remove']" | ||||
|         >删除</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="warning" | ||||
|           icon="el-icon-download" | ||||
|           size="mini" | ||||
|           @click="handleExport" | ||||
|           v-hasPermi="['system:dict:export']" | ||||
|         >导出</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||||
|     </el-row> | ||||
|  | ||||
|     <el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange"> | ||||
|       <el-table-column type="selection" width="55" align="center" /> | ||||
|       <el-table-column label="字典编码" align="center" prop="dictCode" /> | ||||
|       <el-table-column label="字典标签" align="center" prop="dictLabel" /> | ||||
|       <el-table-column label="字典键值" align="center" prop="dictValue" /> | ||||
|       <el-table-column label="字典排序" align="center" prop="dictSort" /> | ||||
|       <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" /> | ||||
|       <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit" | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:dict:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-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" | ||||
|       :page.sync="queryParams.pageNum" | ||||
|       :limit.sync="queryParams.pageSize" | ||||
|       @pagination="getList" | ||||
|     /> | ||||
|  | ||||
|     <!-- 添加或修改参数配置对话框 --> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||||
|       <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||||
|         <el-form-item label="字典类型"> | ||||
|           <el-input v-model="form.dictType" :disabled="true" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="数据标签" prop="dictLabel"> | ||||
|           <el-input v-model="form.dictLabel" placeholder="请输入数据标签" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="数据键值" prop="dictValue"> | ||||
|           <el-input v-model="form.dictValue" placeholder="请输入数据键值" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="显示排序" prop="dictSort"> | ||||
|           <el-input-number v-model="form.dictSort" 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 statusOptions" | ||||
|               :key="dict.dictValue" | ||||
|               :label="dict.dictValue" | ||||
|             >{{dict.dictLabel}}</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> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listData, getData, delData, addData, updateData, exportData } from "@/api/system/dict/data"; | ||||
| import { listType, getType } from "@/api/system/dict/type"; | ||||
|  | ||||
| export default { | ||||
|   name: "Data", | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 字典表格数据 | ||||
|       dataList: [], | ||||
|       // 默认字典类型 | ||||
|       defaultDictType: "", | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 状态数据字典 | ||||
|       statusOptions: [], | ||||
|       // 类型数据字典 | ||||
|       typeOptions: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         dictName: undefined, | ||||
|         dictType: undefined, | ||||
|         status: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         dictLabel: [ | ||||
|           { required: true, message: "数据标签不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         dictValue: [ | ||||
|           { required: true, message: "数据键值不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         dictSort: [ | ||||
|           { required: true, message: "数据顺序不能为空", trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     const dictId = this.$route.params && this.$route.params.dictId; | ||||
|     this.getType(dictId); | ||||
|     this.getTypeList(); | ||||
|     this.getDicts("sys_normal_disable").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询字典类型详细 */ | ||||
|     getType(dictId) { | ||||
|       getType(dictId).then(response => { | ||||
|         this.queryParams.dictType = response.data.dictType; | ||||
|         this.defaultDictType = response.data.dictType; | ||||
|         this.getList(); | ||||
|       }); | ||||
|     }, | ||||
|     /** 查询字典类型列表 */ | ||||
|     getTypeList() { | ||||
|       listType().then(response => { | ||||
|         this.typeOptions = response.rows; | ||||
|       }); | ||||
|     }, | ||||
|     /** 查询字典数据列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listData(this.queryParams).then(response => { | ||||
|         this.dataList = response.rows; | ||||
|         this.total = response.total; | ||||
|         this.loading = false; | ||||
|       }); | ||||
|     }, | ||||
|     // 数据状态字典翻译 | ||||
|     statusFormat(row, column) { | ||||
|       return this.selectDictLabel(this.statusOptions, row.status); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         dictCode: undefined, | ||||
|         dictLabel: undefined, | ||||
|         dictValue: undefined, | ||||
|         dictSort: 0, | ||||
|         status: "0", | ||||
|         remark: undefined | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.resetForm("queryForm"); | ||||
|       this.queryParams.dictType = this.defaultDictType; | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd() { | ||||
|       this.reset(); | ||||
|       this.open = true; | ||||
|       this.title = "添加字典数据"; | ||||
|       this.form.dictType = this.queryParams.dictType; | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.dictCode) | ||||
|       this.single = selection.length!=1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       const dictCode = row.dictCode || this.ids | ||||
|       getData(dictCode).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改字典数据"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.dictCode != undefined) { | ||||
|             updateData(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addData(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const dictCodes = row.dictCode || this.ids; | ||||
|       this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delData(dictCodes); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 导出按钮操作 */ | ||||
|     handleExport() { | ||||
|       const queryParams = this.queryParams; | ||||
|       this.$confirm('是否确认导出所有数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return exportData(queryParams); | ||||
|         }).then(response => { | ||||
|           this.download(response.msg); | ||||
|         }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										366
									
								
								stdiet-ui/src/views/system/dict/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										366
									
								
								stdiet-ui/src/views/system/dict/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,366 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|       <el-form-item label="字典名称" prop="dictName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.dictName" | ||||
|           placeholder="请输入字典名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="字典类型" prop="dictType"> | ||||
|         <el-input | ||||
|           v-model="queryParams.dictType" | ||||
|           placeholder="请输入字典类型" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select | ||||
|           v-model="queryParams.status" | ||||
|           placeholder="字典状态" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|         > | ||||
|           <el-option | ||||
|             v-for="dict in statusOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="创建时间"> | ||||
|         <el-date-picker | ||||
|           v-model="dateRange" | ||||
|           size="small" | ||||
|           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="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:dict:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="success" | ||||
|           icon="el-icon-edit" | ||||
|           size="mini" | ||||
|           :disabled="single" | ||||
|           @click="handleUpdate" | ||||
|           v-hasPermi="['system:dict:edit']" | ||||
|         >修改</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-delete" | ||||
|           size="mini" | ||||
|           :disabled="multiple" | ||||
|           @click="handleDelete" | ||||
|           v-hasPermi="['system:dict:remove']" | ||||
|         >删除</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="warning" | ||||
|           icon="el-icon-download" | ||||
|           size="mini" | ||||
|           @click="handleExport" | ||||
|           v-hasPermi="['system:dict:export']" | ||||
|         >导出</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-refresh" | ||||
|           size="mini" | ||||
|           @click="handleClearCache" | ||||
|           v-hasPermi="['system:dict:remove']" | ||||
|         >清理缓存</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="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 slot-scope="scope"> | ||||
|           <router-link :to="'/dict/type/data/' + 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" :formatter="statusFormat" /> | ||||
|       <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit" | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:dict:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-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" | ||||
|       :page.sync="queryParams.pageNum" | ||||
|       :limit.sync="queryParams.pageSize" | ||||
|       @pagination="getList" | ||||
|     /> | ||||
|  | ||||
|     <!-- 添加或修改参数配置对话框 --> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||||
|       <el-form ref="form" :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 statusOptions" | ||||
|               :key="dict.dictValue" | ||||
|               :label="dict.dictValue" | ||||
|             >{{dict.dictLabel}}</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> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listType, getType, delType, addType, updateType, exportType, clearCache } from "@/api/system/dict/type"; | ||||
|  | ||||
| export default { | ||||
|   name: "Dict", | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 字典表格数据 | ||||
|       typeList: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 状态数据字典 | ||||
|       statusOptions: [], | ||||
|       // 日期范围 | ||||
|       dateRange: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         dictName: undefined, | ||||
|         dictType: undefined, | ||||
|         status: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         dictName: [ | ||||
|           { required: true, message: "字典名称不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         dictType: [ | ||||
|           { required: true, message: "字典类型不能为空", trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_normal_disable").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询字典类型列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listType(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||||
|           this.typeList = response.rows; | ||||
|           this.total = response.total; | ||||
|           this.loading = false; | ||||
|         } | ||||
|       ); | ||||
|     }, | ||||
|     // 字典状态字典翻译 | ||||
|     statusFormat(row, column) { | ||||
|       return this.selectDictLabel(this.statusOptions, row.status); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         dictId: undefined, | ||||
|         dictName: undefined, | ||||
|         dictType: undefined, | ||||
|         status: "0", | ||||
|         remark: undefined | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.dateRange = []; | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd() { | ||||
|       this.reset(); | ||||
|       this.open = true; | ||||
|       this.title = "添加字典类型"; | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.dictId) | ||||
|       this.single = selection.length!=1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       const dictId = row.dictId || this.ids | ||||
|       getType(dictId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改字典类型"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.dictId != undefined) { | ||||
|             updateType(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addType(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const dictIds = row.dictId || this.ids; | ||||
|       this.$confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delType(dictIds); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 导出按钮操作 */ | ||||
|     handleExport() { | ||||
|       const queryParams = this.queryParams; | ||||
|       this.$confirm('是否确认导出所有类型数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return exportType(queryParams); | ||||
|         }).then(response => { | ||||
|           this.download(response.msg); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 清理缓存按钮操作 */ | ||||
|     handleClearCache() { | ||||
|       clearCache().then(response => { | ||||
|         if (response.code === 200) { | ||||
|           this.msgSuccess("清理成功"); | ||||
|         } | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										3
									
								
								stdiet-ui/src/views/system/log/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								stdiet-ui/src/views/system/log/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| <template > | ||||
|   <router-view /> | ||||
| </template> | ||||
							
								
								
									
										403
									
								
								stdiet-ui/src/views/system/menu/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										403
									
								
								stdiet-ui/src/views/system/menu/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,403 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> | ||||
|       <el-form-item label="菜单名称" prop="menuName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.menuName" | ||||
|           placeholder="请输入菜单名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small"> | ||||
|           <el-option | ||||
|             v-for="dict in statusOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:menu:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||||
|     </el-row> | ||||
|  | ||||
|     <el-table | ||||
|       v-loading="loading" | ||||
|       :data="menuList" | ||||
|       row-key="menuId" | ||||
|       :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 slot-scope="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="状态" :formatter="statusFormat" width="80"></el-table-column> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit"  | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:menu:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button  | ||||
|             size="mini"  | ||||
|             type="text"  | ||||
|             icon="el-icon-plus"  | ||||
|             @click="handleAdd(scope.row)" | ||||
|             v-hasPermi="['system:menu:add']" | ||||
|           >新增</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-delete" | ||||
|             @click="handleDelete(scope.row)" | ||||
|             v-hasPermi="['system:menu:remove']" | ||||
|           >删除</el-button> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|     </el-table> | ||||
|  | ||||
|     <!-- 添加或修改菜单对话框 --> | ||||
|     <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="24"> | ||||
|             <el-form-item label="上级菜单"> | ||||
|               <treeselect | ||||
|                 v-model="form.parentId" | ||||
|                 :options="menuOptions" | ||||
|                 :normalizer="normalizer" | ||||
|                 :show-count="true" | ||||
|                 placeholder="选择上级菜单" | ||||
|               /> | ||||
|             </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"> | ||||
|             <el-form-item v-if="form.menuType != 'F'" label="菜单图标"> | ||||
|               <el-popover | ||||
|                 placement="bottom-start" | ||||
|                 width="460" | ||||
|                 trigger="click" | ||||
|                 @show="$refs['iconSelect'].reset()" | ||||
|               > | ||||
|                 <IconSelect ref="iconSelect" @selected="selected" /> | ||||
|                 <el-input slot="reference" v-model="form.icon" placeholder="点击选择图标" readonly> | ||||
|                   <svg-icon | ||||
|                     v-if="form.icon" | ||||
|                     slot="prefix" | ||||
|                     :icon-class="form.icon" | ||||
|                     class="el-input__icon" | ||||
|                     style="height: 32px;width: 16px;" | ||||
|                   /> | ||||
|                   <i v-else slot="prefix" class="el-icon-search el-input__icon" /> | ||||
|                 </el-input> | ||||
|               </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"> | ||||
|             <el-form-item v-if="form.menuType != 'F'" label="是否外链"> | ||||
|               <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"> | ||||
|             <el-form-item v-if="form.menuType != 'F'" label="路由地址" prop="path"> | ||||
|               <el-input v-model="form.path" placeholder="请输入路由地址" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12" v-if="form.menuType == 'C'"> | ||||
|             <el-form-item label="组件路径" prop="component"> | ||||
|               <el-input v-model="form.component" placeholder="请输入组件路径" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item v-if="form.menuType != 'M'" label="权限标识"> | ||||
|               <el-input v-model="form.perms" placeholder="请权限标识" maxlength="50" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item v-if="form.menuType != 'F'" label="显示状态"> | ||||
|               <el-radio-group v-model="form.visible"> | ||||
|                 <el-radio | ||||
|                   v-for="dict in visibleOptions" | ||||
|                   :key="dict.dictValue" | ||||
|                   :label="dict.dictValue" | ||||
|                 >{{dict.dictLabel}}</el-radio> | ||||
|               </el-radio-group> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item v-if="form.menuType != 'F'" label="菜单状态"> | ||||
|               <el-radio-group v-model="form.status"> | ||||
|                 <el-radio | ||||
|                   v-for="dict in statusOptions" | ||||
|                   :key="dict.dictValue" | ||||
|                   :label="dict.dictValue" | ||||
|                 >{{dict.dictLabel}}</el-radio> | ||||
|               </el-radio-group> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item v-if="form.menuType == 'C'" label="是否缓存"> | ||||
|               <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-row> | ||||
|       </el-form> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu"; | ||||
| import Treeselect from "@riophae/vue-treeselect"; | ||||
| import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||||
| import IconSelect from "@/components/IconSelect"; | ||||
|  | ||||
| export default { | ||||
|   name: "Menu", | ||||
|   components: { Treeselect, IconSelect }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 菜单表格树数据 | ||||
|       menuList: [], | ||||
|       // 菜单树选项 | ||||
|       menuOptions: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 显示状态数据字典 | ||||
|       visibleOptions: [], | ||||
|       // 菜单状态数据字典 | ||||
|       statusOptions: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         menuName: undefined, | ||||
|         visible: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         menuName: [ | ||||
|           { required: true, message: "菜单名称不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         orderNum: [ | ||||
|           { required: true, message: "菜单顺序不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         path: [ | ||||
|           { required: true, message: "路由地址不能为空", trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_show_hide").then(response => { | ||||
|       this.visibleOptions = response.data; | ||||
|     }); | ||||
|     this.getDicts("sys_normal_disable").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     // 选择图标 | ||||
|     selected(name) { | ||||
|       this.form.icon = name; | ||||
|     }, | ||||
|     /** 查询菜单列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listMenu(this.queryParams).then(response => { | ||||
|         this.menuList = this.handleTree(response.data, "menuId"); | ||||
|         this.loading = false; | ||||
|       }); | ||||
|     }, | ||||
|     /** 转换菜单数据结构 */ | ||||
|     normalizer(node) { | ||||
|       if (node.children && !node.children.length) { | ||||
|         delete node.children; | ||||
|       } | ||||
|       return { | ||||
|         id: node.menuId, | ||||
|         label: node.menuName, | ||||
|         children: node.children | ||||
|       }; | ||||
|     }, | ||||
|     /** 查询菜单下拉树结构 */ | ||||
|     getTreeselect() { | ||||
|       listMenu().then(response => { | ||||
|         this.menuOptions = []; | ||||
|         const menu = { menuId: 0, menuName: '主类目', children: [] }; | ||||
|         menu.children = this.handleTree(response.data, "menuId"); | ||||
|         this.menuOptions.push(menu); | ||||
|       }); | ||||
|     }, | ||||
|     // 显示状态字典翻译 | ||||
|     visibleFormat(row, column) { | ||||
|       if (row.menuType == "F") { | ||||
|         return ""; | ||||
|       } | ||||
|       return this.selectDictLabel(this.visibleOptions, row.visible); | ||||
|     }, | ||||
|     // 菜单状态字典翻译 | ||||
|     statusFormat(row, column) { | ||||
|       if (row.menuType == "F") { | ||||
|         return ""; | ||||
|       } | ||||
|       return this.selectDictLabel(this.statusOptions, row.status); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         menuId: undefined, | ||||
|         parentId: 0, | ||||
|         menuName: undefined, | ||||
|         icon: undefined, | ||||
|         menuType: "M", | ||||
|         orderNum: undefined, | ||||
|         isFrame: "1", | ||||
|         isCache: "0", | ||||
|         visible: "0", | ||||
|         status: "0" | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd(row) { | ||||
|       this.reset(); | ||||
|       this.getTreeselect(); | ||||
|       if (row != null && row.menuId) { | ||||
|         this.form.parentId = row.menuId; | ||||
|       } else { | ||||
|         this.form.parentId = 0; | ||||
|       } | ||||
|       this.open = true; | ||||
|       this.title = "添加菜单"; | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       this.getTreeselect(); | ||||
|       getMenu(row.menuId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改菜单"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.menuId != undefined) { | ||||
|             updateMenu(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addMenu(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delMenu(row.menuId); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										344
									
								
								stdiet-ui/src/views/system/notice/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										344
									
								
								stdiet-ui/src/views/system/notice/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,344 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|       <el-form-item label="公告标题" prop="noticeTitle"> | ||||
|         <el-input | ||||
|           v-model="queryParams.noticeTitle" | ||||
|           placeholder="请输入公告标题" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="操作人员" prop="createBy"> | ||||
|         <el-input | ||||
|           v-model="queryParams.createBy" | ||||
|           placeholder="请输入操作人员" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="类型" prop="noticeType"> | ||||
|         <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small"> | ||||
|           <el-option | ||||
|             v-for="dict in typeOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:notice:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="success" | ||||
|           icon="el-icon-edit" | ||||
|           size="mini" | ||||
|           :disabled="single" | ||||
|           @click="handleUpdate" | ||||
|           v-hasPermi="['system:notice:edit']" | ||||
|         >修改</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-delete" | ||||
|           size="mini" | ||||
|           :disabled="multiple" | ||||
|           @click="handleDelete" | ||||
|           v-hasPermi="['system:notice:remove']" | ||||
|         >删除</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||||
|     </el-row> | ||||
|  | ||||
|     <el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange"> | ||||
|       <el-table-column type="selection" width="55" align="center" /> | ||||
|       <el-table-column label="序号" align="center" prop="noticeId" width="100" /> | ||||
|       <el-table-column | ||||
|         label="公告标题" | ||||
|         align="center" | ||||
|         prop="noticeTitle" | ||||
|         :show-overflow-tooltip="true" | ||||
|       /> | ||||
|       <el-table-column | ||||
|         label="公告类型" | ||||
|         align="center" | ||||
|         prop="noticeType" | ||||
|         :formatter="typeFormat" | ||||
|         width="100" | ||||
|       /> | ||||
|       <el-table-column | ||||
|         label="状态" | ||||
|         align="center" | ||||
|         prop="status" | ||||
|         :formatter="statusFormat" | ||||
|         width="100" | ||||
|       /> | ||||
|       <el-table-column label="创建者" align="center" prop="createBy" width="100" /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="100"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</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-edit" | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:notice:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-delete" | ||||
|             @click="handleDelete(scope.row)" | ||||
|             v-hasPermi="['system:notice: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" | ||||
|     /> | ||||
|  | ||||
|     <!-- 添加或修改公告对话框 --> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="780px" 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="noticeTitle"> | ||||
|               <el-input v-model="form.noticeTitle" placeholder="请输入公告标题" /> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="公告类型" prop="noticeType"> | ||||
|               <el-select v-model="form.noticeType" placeholder="请选择"> | ||||
|                 <el-option | ||||
|                   v-for="dict in typeOptions" | ||||
|                   :key="dict.dictValue" | ||||
|                   :label="dict.dictLabel" | ||||
|                   :value="dict.dictValue" | ||||
|                 ></el-option> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="24"> | ||||
|             <el-form-item label="状态"> | ||||
|               <el-radio-group v-model="form.status"> | ||||
|                 <el-radio | ||||
|                   v-for="dict in statusOptions" | ||||
|                   :key="dict.dictValue" | ||||
|                   :label="dict.dictValue" | ||||
|                 >{{dict.dictLabel}}</el-radio> | ||||
|               </el-radio-group> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="24"> | ||||
|             <el-form-item label="内容"> | ||||
|               <editor v-model="form.noticeContent" :min-height="192"/> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
|       </el-form> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listNotice, getNotice, delNotice, addNotice, updateNotice, exportNotice } from "@/api/system/notice"; | ||||
| import Editor from '@/components/Editor'; | ||||
|  | ||||
| export default { | ||||
|   name: "Notice", | ||||
|   components: { | ||||
|     Editor | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 公告表格数据 | ||||
|       noticeList: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 类型数据字典 | ||||
|       statusOptions: [], | ||||
|       // 状态数据字典 | ||||
|       typeOptions: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         noticeTitle: undefined, | ||||
|         createBy: undefined, | ||||
|         status: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         noticeTitle: [ | ||||
|           { required: true, message: "公告标题不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         noticeType: [ | ||||
|           { required: true, message: "公告类型不能为空", trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_notice_status").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|     this.getDicts("sys_notice_type").then(response => { | ||||
|       this.typeOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询公告列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listNotice(this.queryParams).then(response => { | ||||
|         this.noticeList = response.rows; | ||||
|         this.total = response.total; | ||||
|         this.loading = false; | ||||
|       }); | ||||
|     }, | ||||
|     // 公告状态字典翻译 | ||||
|     statusFormat(row, column) { | ||||
|       return this.selectDictLabel(this.statusOptions, row.status); | ||||
|     }, | ||||
|     // 公告状态字典翻译 | ||||
|     typeFormat(row, column) { | ||||
|       return this.selectDictLabel(this.typeOptions, row.noticeType); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         noticeId: undefined, | ||||
|         noticeTitle: undefined, | ||||
|         noticeType: undefined, | ||||
|         noticeContent: undefined, | ||||
|         status: "0" | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.noticeId) | ||||
|       this.single = selection.length!=1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd() { | ||||
|       this.reset(); | ||||
|       this.open = true; | ||||
|       this.title = "添加公告"; | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       const noticeId = row.noticeId || this.ids | ||||
|       getNotice(noticeId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改公告"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.noticeId != undefined) { | ||||
|             updateNotice(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addNotice(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const noticeIds = row.noticeId || this.ids | ||||
|       this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delNotice(noticeIds); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										326
									
								
								stdiet-ui/src/views/system/post/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										326
									
								
								stdiet-ui/src/views/system/post/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,326 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|       <el-form-item label="岗位编码" prop="postCode"> | ||||
|         <el-input | ||||
|           v-model="queryParams.postCode" | ||||
|           placeholder="请输入岗位编码" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="岗位名称" prop="postName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.postName" | ||||
|           placeholder="请输入岗位名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small"> | ||||
|           <el-option | ||||
|             v-for="dict in statusOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:post:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
| <!--      <el-col :span="1.5">--> | ||||
| <!--        <el-button--> | ||||
| <!--          type="success"--> | ||||
| <!--          icon="el-icon-edit"--> | ||||
| <!--          size="mini"--> | ||||
| <!--          :disabled="single"--> | ||||
| <!--          @click="handleUpdate"--> | ||||
| <!--          v-hasPermi="['system:post:edit']"--> | ||||
| <!--        >修改</el-button>--> | ||||
| <!--      </el-col>--> | ||||
| <!--      <el-col :span="1.5">--> | ||||
| <!--        <el-button--> | ||||
| <!--          type="danger"--> | ||||
| <!--          icon="el-icon-delete"--> | ||||
| <!--          size="mini"--> | ||||
| <!--          :disabled="multiple"--> | ||||
| <!--          @click="handleDelete"--> | ||||
| <!--          v-hasPermi="['system:post:remove']"--> | ||||
| <!--        >删除</el-button>--> | ||||
| <!--      </el-col>--> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="warning" | ||||
|           icon="el-icon-download" | ||||
|           size="mini" | ||||
|           @click="handleExport" | ||||
|           v-hasPermi="['system:post:export']" | ||||
|         >导出</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="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" :formatter="statusFormat" /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit" | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:post:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-delete" | ||||
|             @click="handleDelete(scope.row)" | ||||
|             v-hasPermi="['system:post: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" | ||||
|     /> | ||||
|  | ||||
|     <!-- 添加或修改岗位对话框 --> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||||
|       <el-form ref="form" :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 statusOptions" | ||||
|               :key="dict.dictValue" | ||||
|               :label="dict.dictValue" | ||||
|             >{{dict.dictLabel}}</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> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <el-button @click="cancel">取 消</el-button> | ||||
|       </div> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post"; | ||||
|  | ||||
| export default { | ||||
|   name: "Post", | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 岗位表格数据 | ||||
|       postList: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 状态数据字典 | ||||
|       statusOptions: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         postCode: undefined, | ||||
|         postName: undefined, | ||||
|         status: undefined | ||||
|       }, | ||||
|       // 表单参数 | ||||
|       form: {}, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         postName: [ | ||||
|           { required: true, message: "岗位名称不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         postCode: [ | ||||
|           { required: true, message: "岗位编码不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         // postSort: [ | ||||
|         //   { required: true, message: "岗位顺序不能为空", trigger: "blur" } | ||||
|         // ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_normal_disable").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询岗位列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listPost(this.queryParams).then(response => { | ||||
|         this.postList = response.rows; | ||||
|         this.total = response.total; | ||||
|         this.loading = false; | ||||
|       }); | ||||
|     }, | ||||
|     // 岗位状态字典翻译 | ||||
|     statusFormat(row, column) { | ||||
|       return this.selectDictLabel(this.statusOptions, row.status); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       this.form = { | ||||
|         postId: undefined, | ||||
|         postCode: undefined, | ||||
|         postName: undefined, | ||||
|         postSort: 0, | ||||
|         status: "0", | ||||
|         remark: undefined | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.postId) | ||||
|       this.single = selection.length!=1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd() { | ||||
|       this.reset(); | ||||
|       this.open = true; | ||||
|       this.title = "添加岗位"; | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       const postId = row.postId || this.ids | ||||
|       getPost(postId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.title = "修改岗位"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.postId != undefined) { | ||||
|             updatePost(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             addPost(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const postIds = row.postId || this.ids; | ||||
|       this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delPost(postIds); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 导出按钮操作 */ | ||||
|     handleExport() { | ||||
|       const queryParams = this.queryParams; | ||||
|       this.$confirm('是否确认导出所有岗位数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return exportPost(queryParams); | ||||
|         }).then(response => { | ||||
|           this.download(response.msg); | ||||
|         }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										601
									
								
								stdiet-ui/src/views/system/role/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										601
									
								
								stdiet-ui/src/views/system/role/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,601 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true"> | ||||
|       <el-form-item label="角色名称" prop="roleName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.roleName" | ||||
|           placeholder="请输入角色名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="权限字符" prop="roleKey"> | ||||
|         <el-input | ||||
|           v-model="queryParams.roleKey" | ||||
|           placeholder="请输入权限字符" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select | ||||
|           v-model="queryParams.status" | ||||
|           placeholder="角色状态" | ||||
|           clearable | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|         > | ||||
|           <el-option | ||||
|             v-for="dict in statusOptions" | ||||
|             :key="dict.dictValue" | ||||
|             :label="dict.dictLabel" | ||||
|             :value="dict.dictValue" | ||||
|           /> | ||||
|         </el-select> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="创建时间"> | ||||
|         <el-date-picker | ||||
|           v-model="dateRange" | ||||
|           size="small" | ||||
|           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="cyan" 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" | ||||
|           icon="el-icon-plus" | ||||
|           size="mini" | ||||
|           @click="handleAdd" | ||||
|           v-hasPermi="['system:role:add']" | ||||
|         >新增</el-button> | ||||
|       </el-col> | ||||
| <!--      <el-col :span="1.5">--> | ||||
| <!--        <el-button--> | ||||
| <!--          type="success"--> | ||||
| <!--          icon="el-icon-edit"--> | ||||
| <!--          size="mini"--> | ||||
| <!--          :disabled="single"--> | ||||
| <!--          @click="handleUpdate"--> | ||||
| <!--          v-hasPermi="['system:role:edit']"--> | ||||
| <!--        >修改</el-button>--> | ||||
| <!--      </el-col>--> | ||||
| <!--      <el-col :span="1.5">--> | ||||
| <!--        <el-button--> | ||||
| <!--          type="danger"--> | ||||
| <!--          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" | ||||
|           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="创建时间" align="center" prop="createTime" width="180"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</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-edit" | ||||
|             @click="handleUpdate(scope.row)" | ||||
|             v-hasPermi="['system:role:edit']" | ||||
|           >修改</el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-circle-check" | ||||
|             @click="handleDataScope(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> | ||||
|         </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="title" :visible.sync="open" width="500px" append-to-body> | ||||
|       <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||||
|         <el-form-item label="角色名称" prop="roleName"> | ||||
|           <el-input v-model="form.roleName" placeholder="请输入角色名称" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="权限字符" prop="roleKey"> | ||||
|           <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 statusOptions" | ||||
|               :key="dict.dictValue" | ||||
|               :label="dict.dictValue" | ||||
|             >{{dict.dictLabel}}</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> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button type="primary" @click="submitForm">确 定</el-button> | ||||
|         <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"> | ||||
|             <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, exportRole, dataScope, changeRoleStatus } from "@/api/system/role"; | ||||
| import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; | ||||
| import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept"; | ||||
|  | ||||
| export default { | ||||
|   name: "Role", | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 角色表格数据 | ||||
|       roleList: [], | ||||
|       // 弹出层标题 | ||||
|       title: "", | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 是否显示弹出层(数据权限) | ||||
|       openDataScope: false, | ||||
|       menuExpand: false, | ||||
|       menuNodeAll: false, | ||||
|       deptExpand: true, | ||||
|       deptNodeAll: false, | ||||
|       // 日期范围 | ||||
|       dateRange: [], | ||||
|       // 状态数据字典 | ||||
|       statusOptions: [], | ||||
|       // 数据范围选项 | ||||
|       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: {}, | ||||
|       defaultProps: { | ||||
|         children: "children", | ||||
|         label: "label" | ||||
|       }, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         roleName: [ | ||||
|           { required: true, message: "角色名称不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         roleKey: [ | ||||
|           { required: true, message: "权限字符不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         // roleSort: [ | ||||
|         //   { required: true, message: "角色顺序不能为空", trigger: "blur" } | ||||
|         // ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|     this.getDicts("sys_normal_disable").then(response => { | ||||
|       this.statusOptions = response.data; | ||||
|     }); | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询角色列表 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listRole(this.addDateRange(this.queryParams, this.dateRange)).then( | ||||
|         response => { | ||||
|           this.roleList = response.rows; | ||||
|           this.total = response.total; | ||||
|           this.loading = false; | ||||
|         } | ||||
|       ); | ||||
|     }, | ||||
|     /** 查询菜单树结构 */ | ||||
|     getMenuTreeselect() { | ||||
|       menuTreeselect().then(response => { | ||||
|         this.menuOptions = response.data; | ||||
|       }); | ||||
|     }, | ||||
|     /** 查询部门树结构 */ | ||||
|     getDeptTreeselect() { | ||||
|       deptTreeselect().then(response => { | ||||
|         this.deptOptions = response.data; | ||||
|       }); | ||||
|     }, | ||||
|     // 所有菜单节点数据 | ||||
|     getMenuAllCheckedKeys() { | ||||
|       // 目前被选中的菜单节点 | ||||
|       let checkedKeys = this.$refs.menu.getHalfCheckedKeys(); | ||||
|       // 半选中的菜单节点 | ||||
|       let halfCheckedKeys = this.$refs.menu.getCheckedKeys(); | ||||
|       checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); | ||||
|       return checkedKeys; | ||||
|     }, | ||||
|     // 所有部门节点数据 | ||||
|     getDeptAllCheckedKeys() { | ||||
|       // 目前被选中的部门节点 | ||||
|       let checkedKeys = this.$refs.dept.getHalfCheckedKeys(); | ||||
|       // 半选中的部门节点 | ||||
|       let halfCheckedKeys = this.$refs.dept.getCheckedKeys(); | ||||
|       checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); | ||||
|       return checkedKeys; | ||||
|     }, | ||||
|     /** 根据角色ID查询菜单树结构 */ | ||||
|     getRoleMenuTreeselect(roleId) { | ||||
|       return roleMenuTreeselect(roleId).then(response => { | ||||
|         this.menuOptions = response.menus; | ||||
|         return response; | ||||
|       }); | ||||
|     }, | ||||
|     /** 根据角色ID查询部门树结构 */ | ||||
|     getRoleDeptTreeselect(roleId) { | ||||
|       return roleDeptTreeselect(roleId).then(response => { | ||||
|         this.deptOptions = response.depts; | ||||
|         return response; | ||||
|       }); | ||||
|     }, | ||||
|     // 角色状态修改 | ||||
|     handleStatusChange(row) { | ||||
|       let text = row.status === "0" ? "启用" : "停用"; | ||||
|       this.$confirm('确认要"' + text + '""' + row.roleName + '"角色吗?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return changeRoleStatus(row.roleId, row.status); | ||||
|         }).then(() => { | ||||
|           this.msgSuccess(text + "成功"); | ||||
|         }).catch(function() { | ||||
|           row.status = row.status === "0" ? "1" : "0"; | ||||
|         }); | ||||
|     }, | ||||
|     // 取消按钮 | ||||
|     cancel() { | ||||
|       this.open = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 取消按钮(数据权限) | ||||
|     cancelDataScope() { | ||||
|       this.openDataScope = false; | ||||
|       this.reset(); | ||||
|     }, | ||||
|     // 表单重置 | ||||
|     reset() { | ||||
|       if (this.$refs.menu != undefined) { | ||||
|         this.$refs.menu.setCheckedKeys([]); | ||||
|       } | ||||
|       this.menuExpand = false, | ||||
|       this.menuNodeAll = false, | ||||
|       this.deptExpand = true, | ||||
|       this.deptNodeAll = false, | ||||
|       this.form = { | ||||
|         roleId: undefined, | ||||
|         roleName: undefined, | ||||
|         roleKey: undefined, | ||||
|         roleSort: 0, | ||||
|         status: "0", | ||||
|         menuIds: [], | ||||
|         deptIds: [], | ||||
|         menuCheckStrictly: true, | ||||
| 		deptCheckStrictly: true, | ||||
|         remark: undefined | ||||
|       }; | ||||
|       this.resetForm("form"); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.dateRange = []; | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.roleId) | ||||
|       this.single = selection.length!=1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     // 树权限(展开/折叠) | ||||
|     handleCheckedTreeExpand(value, type) { | ||||
|       if (type == 'menu') { | ||||
|         let treeList = this.menuOptions; | ||||
|         for (let i = 0; i < treeList.length; i++) { | ||||
|           this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value; | ||||
|         } | ||||
|       } else if (type == 'dept') { | ||||
|         let treeList = this.deptOptions; | ||||
|         for (let i = 0; i < treeList.length; i++) { | ||||
|           this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value; | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     // 树权限(全选/全不选) | ||||
|     handleCheckedTreeNodeAll(value, type) { | ||||
|       if (type == 'menu') { | ||||
|         this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []); | ||||
|       } else if (type == 'dept') { | ||||
|         this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []); | ||||
|       } | ||||
|     }, | ||||
|     // 树权限(父子联动) | ||||
|     handleCheckedTreeConnect(value, type) { | ||||
|       if (type == 'menu') { | ||||
|         this.form.menuCheckStrictly = value ? true: false; | ||||
|       } else if (type == 'dept') { | ||||
|         this.form.deptCheckStrictly = value ? true: false; | ||||
|       } | ||||
|     }, | ||||
|     /** 新增按钮操作 */ | ||||
|     handleAdd() { | ||||
|       this.reset(); | ||||
|       this.getMenuTreeselect(); | ||||
|       this.open = true; | ||||
|       this.title = "添加角色"; | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset(); | ||||
|       const roleId = row.roleId || this.ids | ||||
|       const roleMenu = this.getRoleMenuTreeselect(roleId); | ||||
|       getRole(roleId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.open = true; | ||||
|         this.$nextTick(() => { | ||||
|           roleMenu.then(res => { | ||||
|             this.$refs.menu.setCheckedKeys(res.checkedKeys); | ||||
|           }); | ||||
|         }); | ||||
|         this.title = "修改角色"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 分配数据权限操作 */ | ||||
|     handleDataScope(row) { | ||||
|       this.reset(); | ||||
|       const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId); | ||||
|       getRole(row.roleId).then(response => { | ||||
|         this.form = response.data; | ||||
|         this.openDataScope = true; | ||||
|         this.$nextTick(() => { | ||||
|           roleDeptTreeselect.then(res => { | ||||
|             this.$refs.dept.setCheckedKeys(res.checkedKeys); | ||||
|           }); | ||||
|         }); | ||||
|         this.title = "分配数据权限"; | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           if (this.form.roleId != undefined) { | ||||
|             this.form.menuIds = this.getMenuAllCheckedKeys(); | ||||
|             updateRole(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } else { | ||||
|             this.form.menuIds = this.getMenuAllCheckedKeys(); | ||||
|             addRole(this.form).then(response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("新增成功"); | ||||
|                 this.open = false; | ||||
|                 this.getList(); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 提交按钮(数据权限) */ | ||||
|     submitDataScope: function() { | ||||
|       if (this.form.roleId != undefined) { | ||||
|         this.form.deptIds = this.getDeptAllCheckedKeys(); | ||||
|         dataScope(this.form).then(response => { | ||||
|           if (response.code === 200) { | ||||
|             this.msgSuccess("修改成功"); | ||||
|             this.openDataScope = false; | ||||
|             this.getList(); | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const roleIds = row.roleId || this.ids; | ||||
|       this.$confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return delRole(roleIds); | ||||
|         }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|         }).catch(function() {}); | ||||
|     }, | ||||
|     /** 导出按钮操作 */ | ||||
|     handleExport() { | ||||
|       const queryParams = this.queryParams; | ||||
|       this.$confirm('是否确认导出所有角色数据项?', "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning" | ||||
|         }).then(function() { | ||||
|           return exportRole(queryParams); | ||||
|         }).then(response => { | ||||
|           this.download(response.msg); | ||||
|         }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										603
									
								
								stdiet-ui/src/views/system/user/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										603
									
								
								stdiet-ui/src/views/system/user/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,603 @@ | ||||
| <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 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" default-expand-all @node-click="handleNodeClick"/> | ||||
|         </div> | ||||
|       </el-col> | ||||
|       <!--用户数据--> | ||||
|       <el-col :span="20" :xs="24"> | ||||
|         <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|           <el-form-item label="用户账号" prop="userName"> | ||||
|             <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" style="width: 240px" | ||||
|                       @keyup.enter.native="handleQuery"/> | ||||
|           </el-form-item> | ||||
|           <!--          <el-form-item label="手机号码" prop="phonenumber">--> | ||||
|           <!--            <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable size="small"--> | ||||
|           <!--                      style="width: 240px" @keyup.enter.native="handleQuery"/>--> | ||||
|           <!--          </el-form-item>--> | ||||
|           <el-form-item label="状态" prop="status"> | ||||
|             <el-select v-model="queryParams.status" placeholder="用户状态" clearable size="small" style="width: 240px"> | ||||
|               <el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" | ||||
|                          :value="dict.dictValue"/> | ||||
|             </el-select> | ||||
|           </el-form-item> | ||||
|           <el-form-item label="创建时间"> | ||||
|             <el-date-picker v-model="dateRange" size="small" 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="cyan" 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" 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" 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" 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" 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" icon="el-icon-download" size="mini" @click="handleExport" | ||||
|                        v-hasPermi="['system:user:export']">导出 | ||||
|             </el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></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" prop="userId"/> | ||||
|           <el-table-column label="用户账号" align="center" prop="userName" :show-overflow-tooltip="true"/> | ||||
|           <el-table-column label="用户名称" align="center" prop="nickName" :show-overflow-tooltip="true"/> | ||||
|           <el-table-column label="岗位" align="center" prop="postName" :show-overflow-tooltip="true"/> | ||||
|           <!--          <el-table-column label="手机号码" align="center" prop="phonenumber" width="120"/>--> | ||||
|           <el-table-column label="状态" align="center"> | ||||
|             <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" width="170"> | ||||
|             <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"> | ||||
|               <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | ||||
|                          v-hasPermi="['system:user:edit']">修改 | ||||
|               </el-button> | ||||
|               <el-button v-if="scope.row.userId !== 1" size="mini" type="text" icon="el-icon-delete" | ||||
|                          @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除 | ||||
|               </el-button> | ||||
|               <el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" | ||||
|                          v-hasPermi="['system:user:resetPwd']">重置 | ||||
|               </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> | ||||
|     </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="请输入用户名称"/> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="归属部门" prop="deptId"> | ||||
|               <treeselect v-model="form.deptId" :options="deptOptions" :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="请输入用户账号"/> | ||||
|             </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"/> | ||||
|             </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 sexOptions" :key="dict.dictValue" :label="dict.dictLabel" | ||||
|                            :value="dict.dictValue"/> | ||||
|               </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 statusOptions" :key="dict.dictValue" :label="dict.dictValue"> | ||||
|                   {{dict.dictLabel}} | ||||
|                 </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="parseInt(item.postId)" | ||||
|                            :disabled="item.status == 1"/> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="角色"> | ||||
|               <el-select v-model="form.roleId" placeholder="请选择"> | ||||
|                 <el-option v-for="item in roleOptions" | ||||
|                            :key="item.roleId" | ||||
|                            :label="item.roleName" | ||||
|                            :value="parseInt(item.roleId)" | ||||
|                            :disabled="item.status == 1"/> | ||||
|               </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> | ||||
|       <div slot="footer" class="dialog-footer"> | ||||
|         <el-button 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" slot="tip"> | ||||
|           <el-checkbox v-model="upload.updateSupport"/> | ||||
|           是否更新已经存在的用户数据 | ||||
|           <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link> | ||||
|         </div> | ||||
|         <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</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, | ||||
|     exportUser, | ||||
|     resetUserPwd, | ||||
|     changeUserStatus, | ||||
|     importTemplate, | ||||
|   } from "@/api/system/user"; | ||||
|   import {getToken} from "@/utils/auth"; | ||||
|   import {treeselect} from "@/api/system/dept"; | ||||
|   import Treeselect from "@riophae/vue-treeselect"; | ||||
|   import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||||
|  | ||||
|   export default { | ||||
|     name: "User", | ||||
|     components: {Treeselect}, | ||||
|     data() { | ||||
|       return { | ||||
|         // 遮罩层 | ||||
|         loading: true, | ||||
|         // 选中数组 | ||||
|         ids: [], | ||||
|         // 非单个禁用 | ||||
|         single: true, | ||||
|         // 非多个禁用 | ||||
|         multiple: true, | ||||
|         // 显示搜索条件 | ||||
|         showSearch: true, | ||||
|         // 总条数 | ||||
|         total: 0, | ||||
|         // 用户表格数据 | ||||
|         userList: null, | ||||
|         // 弹出层标题 | ||||
|         title: "", | ||||
|         // 部门树选项 | ||||
|         deptOptions: undefined, | ||||
|         // 是否显示弹出层 | ||||
|         open: false, | ||||
|         // 部门名称 | ||||
|         deptName: undefined, | ||||
|         // 默认密码 | ||||
|         initPassword: undefined, | ||||
|         // 日期范围 | ||||
|         dateRange: [], | ||||
|         // 状态数据字典 | ||||
|         statusOptions: [], | ||||
|         // 性别状态字典 | ||||
|         sexOptions: [], | ||||
|         // 岗位选项 | ||||
|         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", | ||||
|         }, | ||||
|         // 查询参数 | ||||
|         queryParams: { | ||||
|           pageNum: 1, | ||||
|           pageSize: 10, | ||||
|           userName: undefined, | ||||
|           phonenumber: undefined, | ||||
|           status: undefined, | ||||
|           deptId: undefined, | ||||
|         }, | ||||
|         // 表单校验 | ||||
|         rules: { | ||||
|           userName: [ | ||||
|             {required: true, message: "用户名称不能为空", trigger: "blur"}, | ||||
|           ], | ||||
|           nickName: [ | ||||
|             {required: true, message: "用户昵称不能为空", trigger: "blur"}, | ||||
|           ], | ||||
|           deptId: [ | ||||
|             {required: true, message: "归属部门不能为空", trigger: "blur"}, | ||||
|           ], | ||||
|           password: [ | ||||
|             {required: true, message: "用户密码不能为空", trigger: "blur"}, | ||||
|           ], | ||||
|           email: [ | ||||
|             {required: true, message: "邮箱地址不能为空", trigger: "blur"}, | ||||
|             { | ||||
|               type: "email", | ||||
|               message: "'请输入正确的邮箱地址", | ||||
|               trigger: ["blur", "change"], | ||||
|             }, | ||||
|           ], | ||||
|           // phonenumber: [ | ||||
|           //   {required: true, message: "手机号码不能为空", trigger: "blur"}, | ||||
|           //   { | ||||
|           //     pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, | ||||
|           //     message: "请输入正确的手机号码", | ||||
|           //     trigger: "blur", | ||||
|           //   }, | ||||
|           // ], | ||||
|         }, | ||||
|       }; | ||||
|     }, | ||||
|     watch: { | ||||
|       // 根据名称筛选部门树 | ||||
|       deptName(val) { | ||||
|         this.$refs.tree.filter(val); | ||||
|       }, | ||||
|     }, | ||||
|     created() { | ||||
|       this.getList(); | ||||
|       this.getTreeselect(); | ||||
|       this.getDicts("sys_normal_disable").then((response) => { | ||||
|         this.statusOptions = response.data; | ||||
|       }); | ||||
|       this.getDicts("sys_user_sex").then((response) => { | ||||
|         this.sexOptions = response.data; | ||||
|       }); | ||||
|       this.getConfigKey("sys.user.initPassword").then((response) => { | ||||
|         this.initPassword = response.msg; | ||||
|       }); | ||||
|     }, | ||||
|     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; | ||||
|           } | ||||
|         ); | ||||
|       }, | ||||
|       /** 查询部门下拉树结构 */ | ||||
|       getTreeselect() { | ||||
|         treeselect().then((response) => { | ||||
|           this.deptOptions = response.data; | ||||
|         }); | ||||
|       }, | ||||
|       // 筛选节点 | ||||
|       filterNode(value, data) { | ||||
|         if (!value) return true; | ||||
|         return data.label.indexOf(value) !== -1; | ||||
|       }, | ||||
|       // 节点单击事件 | ||||
|       handleNodeClick(data) { | ||||
|         this.queryParams.deptId = data.id; | ||||
|         this.getList(); | ||||
|       }, | ||||
|       // 用户状态修改 | ||||
|       handleStatusChange(row) { | ||||
|         let text = row.status === "0" ? "启用" : "停用"; | ||||
|         this.$confirm( | ||||
|           '确认要"' + text + '""' + row.userName + '"用户吗?', | ||||
|           "警告", | ||||
|           { | ||||
|             confirmButtonText: "确定", | ||||
|             cancelButtonText: "取消", | ||||
|             type: "warning", | ||||
|           } | ||||
|         ) | ||||
|           .then(function () { | ||||
|             return changeUserStatus(row.userId, row.status); | ||||
|           }) | ||||
|           .then(() => { | ||||
|             this.msgSuccess(text + "成功"); | ||||
|           }) | ||||
|           .catch(function () { | ||||
|             row.status = row.status === "0" ? "1" : "0"; | ||||
|           }); | ||||
|       }, | ||||
|       // 取消按钮 | ||||
|       cancel() { | ||||
|         this.open = false; | ||||
|         this.reset(); | ||||
|       }, | ||||
|       // 表单重置 | ||||
|       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: [], | ||||
|           postId: undefined, | ||||
|           roleId: undefined | ||||
|         }; | ||||
|         this.resetForm("form"); | ||||
|       }, | ||||
|       /** 搜索按钮操作 */ | ||||
|       handleQuery() { | ||||
|         this.queryParams.page = 1; | ||||
|         this.getList(); | ||||
|       }, | ||||
|       /** 重置按钮操作 */ | ||||
|       resetQuery() { | ||||
|         this.dateRange = []; | ||||
|         this.resetForm("queryForm"); | ||||
|         this.handleQuery(); | ||||
|       }, | ||||
|       // 多选框选中数据 | ||||
|       handleSelectionChange(selection) { | ||||
|         this.ids = selection.map((item) => item.userId); | ||||
|         this.single = selection.length != 1; | ||||
|         this.multiple = !selection.length; | ||||
|       }, | ||||
|       /** 新增按钮操作 */ | ||||
|       handleAdd() { | ||||
|         this.reset(); | ||||
|         this.getTreeselect(); | ||||
|         getUser().then((response) => { | ||||
|           this.postOptions = response.posts; | ||||
|           const defPost = this.postOptions.find(opt => opt.remark === 'default'); | ||||
|           this.form.postId = defPost ? defPost.postId : undefined; | ||||
|           this.roleOptions = response.roles; | ||||
|           const defRole = this.roleOptions.find(opt => opt.remark === 'default'); | ||||
|           this.form.roleId = defRole ? defRole.roleId : undefined; | ||||
|           this.open = true; | ||||
|           this.title = "添加用户"; | ||||
|           this.form.password = this.initPassword; | ||||
|         }); | ||||
|       }, | ||||
|       /** 修改按钮操作 */ | ||||
|       handleUpdate(row) { | ||||
|         this.reset(); | ||||
|         this.getTreeselect(); | ||||
|         const userId = row.userId || this.ids; | ||||
|         getUser(userId).then((response) => { | ||||
|           this.form = { | ||||
|             ...response.data, | ||||
|             roleId: response.data.roles[0].roleId | ||||
|           }; | ||||
|           this.postOptions = response.posts; | ||||
|           this.roleOptions = response.roles; | ||||
|           this.form.postIds = response.postIds; | ||||
|           this.form.roleIds = response.roleIds; | ||||
|           this.open = true; | ||||
|           this.title = "修改用户"; | ||||
|           this.form.password = ""; | ||||
|         }); | ||||
|       }, | ||||
|       /** 重置密码按钮操作 */ | ||||
|       handleResetPwd(row) { | ||||
|         this.$prompt('请输入"' + row.userName + '"的新密码', "提示", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|         }) | ||||
|           .then(({value}) => { | ||||
|             resetUserPwd(row.userId, value).then((response) => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功,新密码是:" + value); | ||||
|               } | ||||
|             }); | ||||
|           }) | ||||
|           .catch(() => { | ||||
|           }); | ||||
|       }, | ||||
|       /** 提交按钮 */ | ||||
|       submitForm: function () { | ||||
|         this.$refs["form"].validate((valid) => { | ||||
|           if (valid) { | ||||
|             // this.form.postId && (this.form.postIds = [this.form.postId]); | ||||
|             this.form.roleId && (this.form.roleIds = [this.form.roleId]); | ||||
|             // console.log(this.form) | ||||
|             if (this.form.userId != undefined) { | ||||
|               updateUser(this.form).then((response) => { | ||||
|                 if (response.code === 200) { | ||||
|                   this.msgSuccess("修改成功"); | ||||
|                   this.open = false; | ||||
|                   this.getList(); | ||||
|                 } | ||||
|               }); | ||||
|             } else { | ||||
|               addUser(this.form).then((response) => { | ||||
|                 if (response.code === 200) { | ||||
|                   this.msgSuccess("新增成功"); | ||||
|                   this.open = false; | ||||
|                   this.getList(); | ||||
|                 } | ||||
|               }); | ||||
|             } | ||||
|           } | ||||
|         }); | ||||
|       }, | ||||
|       /** 删除按钮操作 */ | ||||
|       handleDelete(row) { | ||||
|         const userIds = row.userId || this.ids; | ||||
|         this.$confirm( | ||||
|           '是否确认删除用户编号为"' + userIds + '"的数据项?', | ||||
|           "警告", | ||||
|           { | ||||
|             confirmButtonText: "确定", | ||||
|             cancelButtonText: "取消", | ||||
|             type: "warning", | ||||
|           } | ||||
|         ) | ||||
|           .then(function () { | ||||
|             return delUser(userIds); | ||||
|           }) | ||||
|           .then(() => { | ||||
|             this.getList(); | ||||
|             this.msgSuccess("删除成功"); | ||||
|           }) | ||||
|           .catch(function () { | ||||
|           }); | ||||
|       }, | ||||
|       /** 导出按钮操作 */ | ||||
|       handleExport() { | ||||
|         const queryParams = this.queryParams; | ||||
|         this.$confirm("是否确认导出所有用户数据项?", "警告", { | ||||
|           confirmButtonText: "确定", | ||||
|           cancelButtonText: "取消", | ||||
|           type: "warning", | ||||
|         }) | ||||
|           .then(function () { | ||||
|             return exportUser(queryParams); | ||||
|           }) | ||||
|           .then((response) => { | ||||
|             this.download(response.msg); | ||||
|           }) | ||||
|           .catch(function () { | ||||
|           }); | ||||
|       }, | ||||
|       /** 导入按钮操作 */ | ||||
|       handleImport() { | ||||
|         this.upload.title = "用户导入"; | ||||
|         this.upload.open = true; | ||||
|       }, | ||||
|       /** 下载模板操作 */ | ||||
|       importTemplate() { | ||||
|         importTemplate().then((response) => { | ||||
|           this.download(response.msg); | ||||
|         }); | ||||
|       }, | ||||
|       // 文件上传中处理 | ||||
|       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(response.msg, "导入结果", {dangerouslyUseHTMLString: true}); | ||||
|         this.getList(); | ||||
|       }, | ||||
|       // 提交上传文件 | ||||
|       submitFileForm() { | ||||
|         this.$refs.upload.submit(); | ||||
|       }, | ||||
|     }, | ||||
|   }; | ||||
| </script> | ||||
							
								
								
									
										91
									
								
								stdiet-ui/src/views/system/user/profile/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								stdiet-ui/src/views/system/user/profile/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,91 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-row :gutter="20"> | ||||
|       <el-col :span="6" :xs="24"> | ||||
|         <el-card class="box-card"> | ||||
|           <div slot="header" class="clearfix"> | ||||
|             <span>个人信息</span> | ||||
|           </div> | ||||
|           <div> | ||||
|             <div class="text-center"> | ||||
|               <userAvatar :user="user" /> | ||||
|             </div> | ||||
|             <ul class="list-group list-group-striped"> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="user" />用户名称 | ||||
|                 <div class="pull-right">{{ user.userName }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="phone" />手机号码 | ||||
|                 <div class="pull-right">{{ user.phonenumber }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="email" />用户邮箱 | ||||
|                 <div class="pull-right">{{ user.email }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="tree" />所属部门 | ||||
|                 <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="peoples" />所属角色 | ||||
|                 <div class="pull-right">{{ roleGroup }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="date" />创建日期 | ||||
|                 <div class="pull-right">{{ user.createTime }}</div> | ||||
|               </li> | ||||
|             </ul> | ||||
|           </div> | ||||
|         </el-card> | ||||
|       </el-col> | ||||
|       <el-col :span="18" :xs="24"> | ||||
|         <el-card> | ||||
|           <div slot="header" class="clearfix"> | ||||
|             <span>基本资料</span> | ||||
|           </div> | ||||
|           <el-tabs v-model="activeTab"> | ||||
|             <el-tab-pane label="基本资料" name="userinfo"> | ||||
|               <userInfo :user="user" /> | ||||
|             </el-tab-pane> | ||||
|             <el-tab-pane label="修改密码" name="resetPwd"> | ||||
|               <resetPwd :user="user" /> | ||||
|             </el-tab-pane> | ||||
|           </el-tabs> | ||||
|         </el-card> | ||||
|       </el-col> | ||||
|     </el-row> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import userAvatar from "./userAvatar"; | ||||
| import userInfo from "./userInfo"; | ||||
| import resetPwd from "./resetPwd"; | ||||
| import { getUserProfile } from "@/api/system/user"; | ||||
|  | ||||
| export default { | ||||
|   name: "Profile", | ||||
|   components: { userAvatar, userInfo, resetPwd }, | ||||
|   data() { | ||||
|     return { | ||||
|       user: {}, | ||||
|       roleGroup: {}, | ||||
|       postGroup: {}, | ||||
|       activeTab: "userinfo" | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getUser(); | ||||
|   }, | ||||
|   methods: { | ||||
|     getUser() { | ||||
|       getUserProfile().then(response => { | ||||
|         this.user = response.data; | ||||
|         this.roleGroup = response.roleGroup; | ||||
|         this.postGroup = response.postGroup; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										74
									
								
								stdiet-ui/src/views/system/user/profile/resetPwd.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								stdiet-ui/src/views/system/user/profile/resetPwd.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| <template> | ||||
|   <el-form ref="form" :model="user" :rules="rules" label-width="80px"> | ||||
|     <el-form-item label="旧密码" prop="oldPassword"> | ||||
|       <el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item label="新密码" prop="newPassword"> | ||||
|       <el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item label="确认密码" prop="confirmPassword"> | ||||
|       <el-input v-model="user.confirmPassword" placeholder="请确认密码" type="password" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item> | ||||
|       <el-button type="primary" size="mini" @click="submit">保存</el-button> | ||||
|       <el-button type="danger" size="mini" @click="close">关闭</el-button> | ||||
|     </el-form-item> | ||||
|   </el-form> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { updateUserPwd } from "@/api/system/user"; | ||||
|  | ||||
| export default { | ||||
|   data() { | ||||
|     const equalToPassword = (rule, value, callback) => { | ||||
|       if (this.user.newPassword !== value) { | ||||
|         callback(new Error("两次输入的密码不一致")); | ||||
|       } else { | ||||
|         callback(); | ||||
|       } | ||||
|     }; | ||||
|     return { | ||||
|       test: "1test", | ||||
|       user: { | ||||
|         oldPassword: undefined, | ||||
|         newPassword: undefined, | ||||
|         confirmPassword: undefined | ||||
|       }, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         oldPassword: [ | ||||
|           { required: true, message: "旧密码不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         newPassword: [ | ||||
|           { required: true, message: "新密码不能为空", trigger: "blur" }, | ||||
|           { min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" } | ||||
|         ], | ||||
|         confirmPassword: [ | ||||
|           { required: true, message: "确认密码不能为空", trigger: "blur" }, | ||||
|           { required: true, validator: equalToPassword, trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   methods: { | ||||
|     submit() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           updateUserPwd(this.user.oldPassword, this.user.newPassword).then( | ||||
|             response => { | ||||
|               if (response.code === 200) { | ||||
|                 this.msgSuccess("修改成功"); | ||||
|               } | ||||
|             } | ||||
|           ); | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     close() { | ||||
|       this.$store.dispatch("tagsView/delView", this.$route); | ||||
|       this.$router.push({ path: "/index" }); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										144
									
								
								stdiet-ui/src/views/system/user/profile/userAvatar.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										144
									
								
								stdiet-ui/src/views/system/user/profile/userAvatar.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,144 @@ | ||||
| <template> | ||||
|   <div> | ||||
|     <img v-bind:src="options.img" @click="editCropper()" title="点击上传头像" class="img-circle img-lg" /> | ||||
|     <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened"> | ||||
|       <el-row> | ||||
|         <el-col :xs="24" :md="12" :style="{height: '350px'}"> | ||||
|           <vue-cropper | ||||
|             ref="cropper" | ||||
|             :img="options.img" | ||||
|             :info="true" | ||||
|             :autoCrop="options.autoCrop" | ||||
|             :autoCropWidth="options.autoCropWidth" | ||||
|             :autoCropHeight="options.autoCropHeight" | ||||
|             :fixedBox="options.fixedBox" | ||||
|             @realTime="realTime" | ||||
|             v-if="visible" | ||||
|           /> | ||||
|         </el-col> | ||||
|         <el-col :xs="24" :md="12" :style="{height: '350px'}"> | ||||
|           <div class="avatar-upload-preview"> | ||||
|             <img :src="previews.url" :style="previews.img" /> | ||||
|           </div> | ||||
|         </el-col> | ||||
|       </el-row> | ||||
|       <br /> | ||||
|       <el-row> | ||||
|         <el-col :lg="2" :md="2"> | ||||
|           <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> | ||||
|             <el-button size="small"> | ||||
|               上传 | ||||
|               <i class="el-icon-upload el-icon--right"></i> | ||||
|             </el-button> | ||||
|           </el-upload> | ||||
|         </el-col> | ||||
|         <el-col :lg="{span: 1, offset: 2}" :md="2"> | ||||
|           <el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button> | ||||
|         </el-col> | ||||
|         <el-col :lg="{span: 1, offset: 1}" :md="2"> | ||||
|           <el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button> | ||||
|         </el-col> | ||||
|         <el-col :lg="{span: 1, offset: 1}" :md="2"> | ||||
|           <el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button> | ||||
|         </el-col> | ||||
|         <el-col :lg="{span: 1, offset: 1}" :md="2"> | ||||
|           <el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button> | ||||
|         </el-col> | ||||
|         <el-col :lg="{span: 2, offset: 6}" :md="2"> | ||||
|           <el-button type="primary" size="small" @click="uploadImg()">提 交</el-button> | ||||
|         </el-col> | ||||
|       </el-row> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import store from "@/store"; | ||||
| import { VueCropper } from "vue-cropper"; | ||||
| import { uploadAvatar } from "@/api/system/user"; | ||||
|  | ||||
| export default { | ||||
|   components: { VueCropper }, | ||||
|   props: { | ||||
|     user: { | ||||
|       type: Object | ||||
|     } | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 是否显示弹出层 | ||||
|       open: false, | ||||
|       // 是否显示cropper | ||||
|       visible: false, | ||||
|       // 弹出层标题 | ||||
|       title: "修改头像", | ||||
|       options: { | ||||
|         img: store.getters.avatar, //裁剪图片的地址 | ||||
|         autoCrop: true, // 是否默认生成截图框 | ||||
|         autoCropWidth: 200, // 默认生成截图框宽度 | ||||
|         autoCropHeight: 200, // 默认生成截图框高度 | ||||
|         fixedBox: true // 固定截图框大小 不允许改变 | ||||
|       }, | ||||
|       previews: {} | ||||
|     }; | ||||
|   }, | ||||
|   methods: { | ||||
|     // 编辑头像 | ||||
|     editCropper() { | ||||
|       this.open = true; | ||||
|     }, | ||||
|     // 打开弹出层结束时的回调 | ||||
|     modalOpened() { | ||||
|       this.visible = true; | ||||
|     }, | ||||
|     // 覆盖默认的上传行为 | ||||
|     requestUpload() { | ||||
|     }, | ||||
|     // 向左旋转 | ||||
|     rotateLeft() { | ||||
|       this.$refs.cropper.rotateLeft(); | ||||
|     }, | ||||
|     // 向右旋转 | ||||
|     rotateRight() { | ||||
|       this.$refs.cropper.rotateRight(); | ||||
|     }, | ||||
|     // 图片缩放 | ||||
|     changeScale(num) { | ||||
|       num = num || 1; | ||||
|       this.$refs.cropper.changeScale(num); | ||||
|     }, | ||||
|     // 上传预处理 | ||||
|     beforeUpload(file) { | ||||
|       if (file.type.indexOf("image/") == -1) { | ||||
|         this.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。"); | ||||
|       } else { | ||||
|         const reader = new FileReader(); | ||||
|         reader.readAsDataURL(file); | ||||
|         reader.onload = () => { | ||||
|           this.options.img = reader.result; | ||||
|         }; | ||||
|       } | ||||
|     }, | ||||
|     // 上传图片 | ||||
|     uploadImg() { | ||||
|       this.$refs.cropper.getCropBlob(data => { | ||||
|         let formData = new FormData(); | ||||
|         formData.append("avatarfile", data); | ||||
|         uploadAvatar(formData).then(response => { | ||||
|           if (response.code === 200) { | ||||
|             this.open = false; | ||||
|             this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl; | ||||
|             store.commit('SET_AVATAR', this.options.img); | ||||
|             this.msgSuccess("修改成功"); | ||||
|           } | ||||
|           this.visible = false; | ||||
|         }); | ||||
|       }); | ||||
|     }, | ||||
|     // 实时预览 | ||||
|     realTime(data) { | ||||
|       this.previews = data; | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										78
									
								
								stdiet-ui/src/views/system/user/profile/userInfo.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								stdiet-ui/src/views/system/user/profile/userInfo.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | ||||
| <template> | ||||
|   <el-form ref="form" :model="user" :rules="rules" label-width="80px"> | ||||
|     <el-form-item label="用户昵称" prop="nickName"> | ||||
|       <el-input v-model="user.nickName" /> | ||||
|     </el-form-item>  | ||||
|     <el-form-item label="手机号码" prop="phonenumber"> | ||||
|       <el-input v-model="user.phonenumber" maxlength="11" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item label="邮箱" prop="email"> | ||||
|       <el-input v-model="user.email" maxlength="50" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item label="性别"> | ||||
|       <el-radio-group v-model="user.sex"> | ||||
|         <el-radio label="0">男</el-radio> | ||||
|         <el-radio label="1">女</el-radio> | ||||
|       </el-radio-group> | ||||
|     </el-form-item> | ||||
|     <el-form-item> | ||||
|       <el-button type="primary" size="mini" @click="submit">保存</el-button> | ||||
|       <el-button type="danger" size="mini" @click="close">关闭</el-button> | ||||
|     </el-form-item> | ||||
|   </el-form> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { updateUserProfile } from "@/api/system/user"; | ||||
|  | ||||
| export default { | ||||
|   props: { | ||||
|     user: { | ||||
|       type: Object | ||||
|     } | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         nickName: [ | ||||
|           { required: true, message: "用户昵称不能为空", trigger: "blur" } | ||||
|         ], | ||||
|         email: [ | ||||
|           { required: true, message: "邮箱地址不能为空", trigger: "blur" }, | ||||
|           { | ||||
|             type: "email", | ||||
|             message: "'请输入正确的邮箱地址", | ||||
|             trigger: ["blur", "change"] | ||||
|           } | ||||
|         ], | ||||
|         phonenumber: [ | ||||
|           { required: true, message: "手机号码不能为空", trigger: "blur" }, | ||||
|           { | ||||
|             pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, | ||||
|             message: "请输入正确的手机号码", | ||||
|             trigger: "blur" | ||||
|           } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   methods: { | ||||
|     submit() { | ||||
|       this.$refs["form"].validate(valid => { | ||||
|         if (valid) { | ||||
|           updateUserProfile(this.user).then(response => { | ||||
|             if (response.code === 200) { | ||||
|               this.msgSuccess("修改成功"); | ||||
|             } | ||||
|           }); | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     close() { | ||||
|       this.$store.dispatch("tagsView/delView", this.$route); | ||||
|       this.$router.push({ path: "/index" }); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
		Reference in New Issue
	
	Block a user