denny 3 years ago
parent
commit
1578bf5a55

+ 17 - 0
VinnoManagementSystem/src/api/wing/authentication.js

@@ -44,5 +44,22 @@ export default {
                 "params": [data]
             });
         }
+	},
+    modifyPwdProcess: {
+		method: 'ModifyAdminPassword',
+		name: "修改密码",
+		post: async function (datas = {}) {
+            var data = {
+                'AdminCode': datas.code, 
+                'OldPassword': datas.oldPassword, 
+                'NewPassword': datas.password
+            }
+            return await http.post({
+                "jsonrpc": "2.0",
+                "id": common.guid(),
+                "method": this.method,
+                "params": [data]
+            });
+        }
 	}
 }

+ 32 - 47
VinnoManagementSystem/src/layout/components/userbar.vue

@@ -82,52 +82,28 @@
 				</el-dropdown-menu>
 			</template>
 		</el-dropdown>
+		<save-dialog v-if="dialog.save" ref="saveDialog" @closed="dialog.save=false"></save-dialog>
 	</div>
 </template>
 
 <script>
 	import colorTool from '@/utils/color'
+	import saveDialog from '@/views/login/modifyPwd'
 	export default {
+		components: {
+			saveDialog
+		},
 		data(){
 			return {
+				dialog: {
+					save: false
+				},
 				userName: "",
-				userNameF: "",
-				// msg: false,
-				// msgList: [
-				// 	{
-				// 		id: 1,
-				// 		type: 'user',
-				// 		avatar: "img/avatar.jpg",
-				// 		title: "Skuya",
-				// 		describe: "如果喜欢就点个星星支持一下哦",
-				// 		link: "https://gitee.com/lolicode/scui",
-				// 		time: "5分钟前"
-				// 	},
-				// 	{
-				// 		id: 2,
-				// 		type: 'user',
-				// 		avatar: "img/avatar2.gif",
-				// 		title: "Lolowan",
-				// 		describe: "点进去Gitee获取最新开源版本",
-				// 		link: "https://gitee.com/lolicode/scui",
-				// 		time: "14分钟前"
-				// 	},
-				// 	{
-				// 		id: 3,
-				// 		type: 'system',
-				// 		avatar: "img/logo.png",
-				// 		title: "感谢登录SCUI Admin",
-				// 		describe: "Vue 3.0 + Vue-Router 4.0 + ElementPlus + Axios 后台管理系统。",
-				// 		link: "https://gitee.com/lolicode/scui",
-				// 		time: "2020年7月24日"
-				// 	}
-				// ]
 			}
 		},
 		created() {
 			var userInfo = this.$TOOL.data.get("USER_INFO");
 			this.userName = userInfo.AdminName;
-			//this.userNameF = this.userName.substring(0,1);
 		},
 		watch:{
 			'config.colorPrimary'(val){
@@ -140,7 +116,6 @@
 			}
 		},
 		methods: {
-
 			//个人信息
 			handleUser(command) {
 				if(command == "uc"){
@@ -150,23 +125,33 @@
 					this.$router.push({path: '/cmd'});
 				}
 				if(command == "modifyPwd"){
+					var adminInfo = this.$TOOL.data.get("USER_INFO");
+					var adminCode = ""
+					if (adminInfo)
+					{
+						adminCode = adminInfo.AdminCode
+					}
 					//修改密码
-				}
-				if(command == "clearCache"){
-					this.$confirm('清除缓存会将系统初始化,包括登录状态、主题、语言设置等,是否继续?','提示', {
-						type: 'info',
-					}).then(() => {
-						const loading = this.$loading()
-						this.$TOOL.data.clear()
-						this.$router.replace({path: '/login'})
-						setTimeout(()=>{
-							loading.close()
-							location.reload()
-						},1000)
-					}).catch(() => {
-						//取消
+					this.dialog.save = true
+					this.$nextTick(() => {
+						this.$refs.saveDialog.open('edit').setData(adminCode)
 					})
 				}
+				// if(command == "clearCache"){
+				// 	this.$confirm('清除缓存会将系统初始化,包括登录状态、主题、语言设置等,是否继续?','提示', {
+				// 		type: 'info',
+				// 	}).then(() => {
+				// 		const loading = this.$loading()
+				// 		this.$TOOL.data.clear()
+				// 		this.$router.replace({path: '/login'})
+				// 		setTimeout(()=>{
+				// 			loading.close()
+				// 			location.reload()
+				// 		},1000)
+				// 	}).catch(() => {
+				// 		//取消
+				// 	})
+				// }
 				if(command == "outLogin"){
 					this.$confirm(this.$t('dialogBox.confirmWarningText'),this.$t('dialogBox.confirmWarningTitle'), {
 						type: 'warning',

+ 1 - 1
VinnoManagementSystem/src/views/login/login.vue

@@ -139,7 +139,7 @@
 				this.islogin = true
 				//获取token
 				var token = await this.$API.authentication.login.post(this.ruleForm)
-				if (token) {
+				if (token && token.length > 10) {
 					this.$TOOL.data.set("TOKEN", token)
 					var userInfo = await this.$API.authentication.getInfo.post()
 					if (userInfo) {

+ 120 - 0
VinnoManagementSystem/src/views/login/modifyPwd.vue

@@ -0,0 +1,120 @@
+<template>
+	<el-dialog :title="titleMap[mode]" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
+		<el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="100px" label-position="left">
+			<el-input type="hidden" v-model="form.code"></el-input>
+            <el-form-item label="旧密码" prop="oldPassword">
+                <el-input type="password" v-model="form.oldPassword" clearable show-password></el-input>
+            </el-form-item>
+			<el-form-item label="登录密码" prop="password">
+                <el-input type="password" v-model="form.password" clearable show-password></el-input>
+            </el-form-item>
+            <el-form-item label="确认密码" prop="password2">
+                <el-input type="password" v-model="form.password2" clearable show-password></el-input>
+            </el-form-item>
+		</el-form>
+		<template #footer>
+			<el-button @click="visible=false" >取 消</el-button>
+			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
+		</template>
+	</el-dialog>
+</template>
+
+<script>
+	export default {
+		emits: ['success', 'closed'],
+		data() {
+			return {
+				mode: "add",
+				titleMap: {
+					add: '新增密码',
+					edit: '修改密码'
+				},
+				visible: false,
+				isSaveing: false,
+				//表单数据
+				form: {
+					code:"",
+					oldPassword: "",
+					password: "",
+				},
+				//验证规则
+				rules: {
+					code: [
+						{required: true, message: '请输入用户编码'}
+					],
+                    oldPassword: [
+						{required: true, message: '请输入旧密码'},
+					],
+					password: [
+						{required: true, message: '请输入登录密码'},
+						{validator: (rule, value, callback) => {
+                            let reg= /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{4,20}$/
+                            if(!reg.test(value)){callback(new Error('密码必须是由4-20位字母+数字组合'))
+                            }else{
+                                callback()
+                            }
+							// if (this.form.password2 !== '') {
+							// 	this.$refs.dialogForm.validateField('password2');
+							// }
+							// callback();
+						}, trigger: 'blur'}
+					],
+					password2: [
+						{required: true, message: '请再次输入密码'},
+						{validator: (rule, value, callback) => {
+							if (value !== this.form.password) {
+								callback(new Error('两次输入密码不一致!'));
+							}else{
+								callback();
+							}
+						}}
+					]
+				}
+			}
+		},
+		// mounted() {
+		// 	this.getGroup()
+		// },
+		methods: {
+			//显示
+			open(mode='add'){
+				this.mode = mode;
+				this.visible = true;
+				return this
+			},
+			//表单提交方法
+			submit(){
+				this.$refs.dialogForm.validate(async (valid) => {
+					if (valid) {
+						this.isSaveing = true;
+                        var res = await this.$API.authentication.modifyPwdProcess.post(this.form);
+						//var res = await this.$API.demo.post.post(this.form);
+						this.isSaveing = false;
+						if(res){
+							//this.$emit('success', this.form, this.mode)
+							this.visible = false;
+							this.$message.success("操作成功")
+						}else{
+							this.$alert(res.message, "提示", {type: 'error'})
+						}
+					}else{
+						return false;
+					}
+				})
+			},
+			//表单注入数据
+			setData(data){
+				this.form.code = data
+				// this.form.userName = data.userName
+				// this.form.avatar = data.avatar
+				// this.form.name = data.name
+
+				//可以和上面一样单个注入,也可以像下面一样直接合并进去
+				//Object.assign(this.form, data)
+			}
+		}
+	}
+</script>
+
+<style>
+</style>

+ 1 - 1
VinnoManagementSystem/vue.config.js

@@ -13,7 +13,7 @@ module.exports = {
 		port: 2800, //挂载端口
 		proxy: {
 			'/api': {
-				target: 'http://192.168.6.117/IManagementService',
+				target: 'http://192.168.6.69/IManagementService',
 				ws: true,
 				pathRewrite: {
 					'^/api': '/'