lz 3 tahun lalu
induk
melakukan
4e1a235573
5 mengubah file dengan 337 tambahan dan 277 penghapusan
  1. 27 0
      .prettierrc.js
  2. 8 8
      src/App.vue
  3. 48 39
      src/api/login.js
  4. 12 10
      src/utils/request.js
  5. 242 220
      src/views/login.vue

+ 27 - 0
.prettierrc.js

@@ -0,0 +1,27 @@
+module.exports = {
+    // 最大长度80个字符
+    printWidth: 240,
+    // 行末分号
+    semi: false,
+    // 单引号
+    singleQuote: true,
+    // JSX双引号
+    jsxSingleQuote: false,
+    // 尽可能使用尾随逗号(包括函数参数)
+    trailingComma: 'none',
+    // 在对象文字中打印括号之间的空格。
+    bracketSpacing: true,
+    // > 标签放在最后一行的末尾,而不是单独放在下一行
+    jsxBracketSameLine: false,
+    // 箭头圆括号
+    arrowParens: 'avoid',
+    // 在文件顶部插入一个特殊的 @format 标记,指定文件格式需要被格式化。
+    insertPragma: false,
+    // 缩进
+    tabWidth: 4,
+    // 使用tab还是空格
+    useTabs: true,
+    // 行尾换行格式
+    endOfLine: 'auto',
+    HTMLWhitespaceSensitivity: 'ignore'
+}

+ 8 - 8
src/App.vue

@@ -5,15 +5,15 @@
 </template>
 
 <script>
-	export default {
-		name: 'App',
-		metaInfo() {
-			return {
-				title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
-				titleTemplate: (title) => {
-					return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
-				}
+export default {
+	name: 'App',
+	metaInfo() {
+		return {
+			title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
+			titleTemplate: title => {
+				return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
 			}
 		}
 	}
+}
 </script>

+ 48 - 39
src/api/login.js

@@ -2,58 +2,67 @@ import request from '@/utils/request'
 
 // 登录方法
 export function login(username, password, code, uuid) {
-  const data = {
-    username,
-    password,
-    code,
-    uuid
-  }
-  return request({
-    url: '/login',
-    headers: {
-      isToken: false
-    },
-    method: 'post',
-    data: data
-  })
+	const data = {
+		username,
+		password,
+		code,
+		uuid
+	}
+	return request({
+		url: '/login',
+		headers: {
+			isToken: false
+		},
+		method: 'post',
+		data: data
+	})
 }
 
 // 注册方法
 export function register(data) {
-  return request({
-    url: '/register',
-    headers: {
-      isToken: false
-    },
-    method: 'post',
-    data: data
-  })
+	return request({
+		url: '/register',
+		headers: {
+			isToken: false
+		},
+		method: 'post',
+		data: data
+	})
 }
 
 // 获取用户详细信息
 export function getInfo() {
-  return request({
-    url: '/getInfo',
-    method: 'get'
-  })
+	return request({
+		url: '/getInfo',
+		method: 'get'
+	})
 }
 
 // 退出方法
 export function logout() {
-  return request({
-    url: '/logout',
-    method: 'post'
-  })
+	return request({
+		url: '/logout',
+		method: 'post'
+	})
 }
 
 // 获取验证码
 export function getCodeImg() {
-  return request({
-    url: '/captchaImage',
-    headers: {
-      isToken: false
-    },
-    method: 'get',
-    timeout: 20000
-  })
-}
+	return request({
+		url: '/captchaImage',
+		headers: {
+			isToken: false
+		},
+		method: 'get',
+		timeout: 20000
+	})
+}
+export function getComList() {
+	return request({
+		url: '/system/dept/companyList',
+		headers: {
+			isToken: false
+		},
+		method: 'get'
+	})
+}

+ 12 - 10
src/utils/request.js

@@ -8,7 +8,7 @@ import errorCode from '@/utils/errorCode'
 let downloadLoadingInstance
 let pending = []
 let cancelToken = axios.CancelToken
-let removePending = (config) => {
+let removePending = config => {
 	for (let p in pending) {
 		let key = +p
 		let item = pending[key]
@@ -30,9 +30,9 @@ var instance = axios.create({
 })
 
 instance.interceptors.request.use(
-	(config) => {
+	config => {
 		removePending(config)
-		config.cancelToken = new cancelToken((c) => {
+		config.cancelToken = new cancelToken(c => {
 			pending.push({
 				url: config.url,
 				method: config.method,
@@ -41,7 +41,9 @@ instance.interceptors.request.use(
 				cancel: c
 			})
 		})
-		if (getToken()) {
+		// 是否需要设置 token
+		const isToken = (config.headers || {}).isToken === false
+		if (getToken() && !isToken) {
 			config.headers['Authorization'] = 'Bearer ' + getToken()
 		}
 		// get请求映射params参数
@@ -53,13 +55,13 @@ instance.interceptors.request.use(
 		}
 		return config
 	},
-	(error) => {
+	error => {
 		return Promise.reject(error)
 	}
 )
 
 instance.interceptors.response.use(
-	(response) => {
+	response => {
 		removePending(response.config)
 		const code = response.data.code || 200
 		const message = errorCode[code] || response.data.msg || errorCode['default']
@@ -78,7 +80,7 @@ instance.interceptors.response.use(
 		}
 		return response.data
 	},
-	(error) => {
+	error => {
 		console.log(error)
 		let { message } = error
 		if (message == 'Network Error') {
@@ -124,14 +126,14 @@ export function download(url, params, filename) {
 	return instance
 		.post(url, params, {
 			transformRequest: [
-				(params) => {
+				params => {
 					return tansParams(params)
 				}
 			],
 			headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
 			responseType: 'blob'
 		})
-		.then(async (data) => {
+		.then(async data => {
 			const isLogin = await blobValidate(data)
 			if (isLogin) {
 				const blob = new Blob([data])
@@ -141,7 +143,7 @@ export function download(url, params, filename) {
 			}
 			downloadLoadingInstance.close()
 		})
-		.catch((r) => {
+		.catch(r => {
 			console.error(r)
 			notifi({ message: '下载文件出现错误,请联系管理员!', type: 'error' })
 			downloadLoadingInstance.close()

+ 242 - 220
src/views/login.vue

@@ -9,7 +9,7 @@
 					<div class="header-left-line"></div>
 					<div class="header-left-text">
 						<div style="font-size: 24px">CZO智能分析管理系统</div>
-						<div style="font-size: 12px"> Enterprise management integration platform </div>
+						<div style="font-size: 12px">Enterprise management integration platform</div>
 					</div>
 				</div>
 				<div class="header-right">
@@ -24,7 +24,7 @@
 			<div class="inner">
 				<div class="main-info">
 					<div class="main-info-text">企业智能信息化 高效管理 节能降耗</div>
-					<div class="main-info-text" style="margin-top: 20px"> 实现 标准化、机制化、流程化、责任化、市场化、人性化 </div>
+					<div class="main-info-text" style="margin-top: 20px">实现 标准化、机制化、流程化、责任化、市场化、人性化</div>
 					<div class="main-info-link">
 						<a href="javascript:void(0);">产品视频</a>
 						<a href="javascript:void(0);">企业诊断</a>
@@ -45,10 +45,18 @@
 								<input type="password" auto-complete="off" v-model="formData.password" @keyup.enter="handleLogin" />
 							</label>
 						</div>
+						<div class="main-login-from-com">
+							<label>
+								<span>公司</span>
+								<select v-model="formData.companyId" class="com-select">
+									<option v-for="item in comList" :key="item.companyId" :value="item.companyId">{{ item.companyName }}</option>
+								</select>
+							</label>
+						</div>
 						<div class="main-login-from-pass">
 							<label>
 								<span>验证码</span>
-								<input type="text" auto-complete="off" v-model="formData.code" style="width: 110px" @keyup.enter="handleLogin" />
+								<input type="text" auto-complete="off" v-model="formData.code" style="width: 150px" @keyup.enter="handleLogin" />
 								<img :src="codeUrl" @click="getCode" class="login-code-img" />
 							</label>
 						</div>
@@ -73,258 +81,272 @@
 </template>
 
 <script>
-	import { getCodeImg } from '@/api/login'
-	import Cookies from 'js-cookie'
-	import { encrypt, decrypt } from '@/utils/jsencrypt'
-	export default {
-		data() {
-			return {
-				codeUrl: '',
-				loading: false,
-				formData: {
-					username: 'admin',
-					password: 'admin123',
-					code: '',
-					uuid: ''
-				},
-				redirect: undefined
-			}
-		},
-		watch: {
-			$route: {
-				handler: function (route) {
-					this.redirect = route.query && route.query.redirect
-				},
-				immediate: true
-			}
-		},
-		created() {
-			this.getCode()
-			//this.getCookie();
-		},
-		methods: {
-			getCode() {
-				getCodeImg().then((res) => {
-					this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff
-					if (this.captchaOnOff) {
-						this.codeUrl = 'data:image/gif;base64,' + res.img
-						this.formData.uuid = res.uuid
-					}
-				})
+import { getCodeImg, getComList } from '@/api/login'
+import Cookies from 'js-cookie'
+import { encrypt, decrypt } from '@/utils/jsencrypt'
+export default {
+	data() {
+		return {
+			codeUrl: '',
+			loading: false,
+			formData: {
+				username: 'admin',
+				password: 'admin123',
+				code: '',
+				uuid: '',
+				companyId: 0
 			},
-			handleLogin() {
-				if (this.formData.username.trim() == '') {
-					this.$msg({ type: 'error', message: '账号不能为空' })
-					return
-				}
-				if (this.formData.password.trim() == '') {
-					this.$msg({ type: 'error', message: '密码不能为空' })
-					return
+			redirect: undefined,
+			comList: []
+		}
+	},
+	watch: {
+		$route: {
+			handler: function (route) {
+				this.redirect = route.query && route.query.redirect
+			},
+			immediate: true
+		}
+	},
+	created() {
+		this.getCode()
+		//this.getCookie();
+	},
+	methods: {
+		getCode() {
+			getCodeImg().then(res => {
+				this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff
+				if (this.captchaOnOff) {
+					this.codeUrl = 'data:image/gif;base64,' + res.img
+					this.formData.uuid = res.uuid
 				}
-				if (this.formData.code.trim() == '') {
-					this.$msg({ type: 'error', message: '未输入验证码' })
-					return
+			})
+			getComList().then(res => {
+				if (res.code === 200) {
+					this.comList = res.data
+					res.data.length && (this.formData.companyId = res.data[0].companyId)
 				}
-				this.loading = true
-				this.$store
-					.dispatch('Login', this.formData)
-					.then(() => {
-						this.$router.push({ path: this.redirect || '/' }).catch(() => {})
-					})
-					.catch(() => {
-						this.loading = false
-					})
+			})
+		},
+		handleLogin() {
+			if (this.formData.username.trim() == '') {
+				this.$msg({ type: 'error', message: '账号不能为空' })
+				return
+			}
+			if (this.formData.password.trim() == '') {
+				this.$msg({ type: 'error', message: '密码不能为空' })
+				return
 			}
+			if (this.formData.code.trim() == '') {
+				this.$msg({ type: 'error', message: '未输入验证码' })
+				return
+			}
+			this.loading = true
+			this.$store
+				.dispatch('Login', this.formData)
+				.then(() => {
+					this.$router.push({ path: this.redirect || '/' }).catch(() => {})
+				})
+				.catch(() => {
+					this.loading = false
+				})
 		}
 	}
+}
 </script>
 
 <style scoped lang="scss">
-	.login {
+.login {
+	width: 100%;
+	height: 100vh;
+	.login-code-img {
+		width: 80px;
+		height: 30px;
+	}
+	.header,
+	.footer {
 		width: 100%;
-		height: 100vh;
-		.login-code-img {
-			width: 120px;
-			height: 50px;
-		}
-		.header,
-		.footer {
-			width: 100%;
+		height: 80px;
+		background: url('~@/assets/images/login/line.jpg') 0 0 no-repeat;
+	}
+	.main {
+		width: 100%;
+		height: calc(100vh - 160px);
+		background: url('~@/assets/images/login/main.jpg') 0 0 no-repeat;
+	}
+	.inner {
+		width: 80%;
+		margin: 0 auto;
+		display: flex;
+	}
+	.header {
+		.inner {
 			height: 80px;
-			background: url('~@/assets/images/login/line.jpg') 0 0 no-repeat;
-		}
-		.main {
-			width: 100%;
-			height: calc(100vh - 160px);
-			background: url('~@/assets/images/login/main.jpg') 0 0 no-repeat;
+			justify-content: space-between;
+			align-items: center;
+			.header-left {
+				display: flex;
+				color: #fff;
+				.header-left-logo,
+				.header-left-line,
+				.header-left-text {
+					height: 60px;
+					display: flex;
+					align-items: center;
+				}
+				.header-left-line {
+					width: 2px;
+					background: url('~@/assets/images/login/1.png') 0 0 no-repeat;
+					margin: 0 5px;
+				}
+				.header-left-text {
+					height: 50px;
+					align-items: flex-start;
+					flex-direction: column;
+					justify-content: space-around;
+				}
+			}
+			.header-right {
+				height: 60px;
+				display: flex;
+				align-items: flex-end;
+				span {
+					background-color: #3cc3cc;
+					display: inline-block;
+					border-radius: 5px;
+					padding: 3px 5px;
+					margin-left: 8px;
+				}
+			}
 		}
+	}
+	.footer {
 		.inner {
-			width: 80%;
-			margin: 0 auto;
-			display: flex;
+			height: 80px;
+			align-items: center;
+			a {
+				display: inline-block;
+				background-color: #3cc3cc;
+				border-radius: 5px;
+				-webkit-box-shadow: 0 0 11px 3px #4fcaca inset;
+				box-shadow: inset 0 0 11px 3px #4fcaca;
+				width: 175px;
+				height: 50px;
+				border: 1px solid #000;
+				font-size: 18px;
+				margin-right: 8px;
+				color: #fff;
+				text-align: center;
+				line-height: 50px;
+			}
 		}
-		.header {
-			.inner {
-				height: 80px;
-				justify-content: space-between;
-				align-items: center;
-				.header-left {
-					display: flex;
+	}
+	.main {
+		.inner {
+			height: 100%;
+			align-items: center;
+			justify-content: space-between;
+			.main-info {
+				.main-info-text {
 					color: #fff;
-					.header-left-logo,
-					.header-left-line,
-					.header-left-text {
-						height: 60px;
-						display: flex;
-						align-items: center;
-					}
-					.header-left-line {
-						width: 2px;
-						background: url('~@/assets/images/login/1.png') 0 0 no-repeat;
-						margin: 0 5px;
-					}
-					.header-left-text {
-						height: 50px;
-						align-items: flex-start;
-						flex-direction: column;
-						justify-content: space-around;
-					}
+					font-size: 28px;
+					font-weight: bolder;
 				}
-				.header-right {
-					height: 60px;
-					display: flex;
-					align-items: flex-end;
-					span {
-						background-color: #3cc3cc;
+				.main-info-link {
+					margin-top: 100px;
+					a {
 						display: inline-block;
+						width: 175px;
+						height: 50px;
+						color: #fff;
 						border-radius: 5px;
-						padding: 3px 5px;
-						margin-left: 8px;
+						text-align: center;
+						line-height: 50px;
+						font-size: 18px;
+						border: 1px solid #000;
+						&:first-child {
+							background: rgba(7, 34, 83, 0.89);
+							-webkit-box-shadow: 0 0 11px 3px rgba(8, 49, 157, 0.8) inset;
+							box-shadow: inset 0 0 11px 3px rgba(8, 49, 157, 0.8);
+						}
+						&:last-child {
+							background: rgba(51, 204, 204, 0.7);
+							-webkit-box-shadow: 0 0 11px 3px #4fcaca inset;
+							box-shadow: inset 0 0 11px 3px #4fcaca;
+							margin-left: 8px;
+						}
 					}
 				}
 			}
-		}
-		.footer {
-			.inner {
-				height: 80px;
-				align-items: center;
-				a {
-					display: inline-block;
-					background-color: #3cc3cc;
-					border-radius: 5px;
-					-webkit-box-shadow: 0 0 11px 3px #4fcaca inset;
-					box-shadow: inset 0 0 11px 3px #4fcaca;
-					width: 175px;
-					height: 50px;
-					border: 1px solid #000;
+			.main-login {
+				width: 360px;
+				.main-login-title {
+					width: 100%;
+					height: 45px;
+					line-height: 45px;
 					font-size: 18px;
-					margin-right: 8px;
+					background: #07276a;
+					border-radius: 5px 5px 0 0;
 					color: #fff;
 					text-align: center;
-					line-height: 50px;
 				}
-			}
-		}
-		.main {
-			.inner {
-				height: 100%;
-				align-items: center;
-				justify-content: space-between;
-				.main-info {
-					.main-info-text {
-						color: #fff;
-						font-size: 28px;
-						font-weight: bolder;
-					}
-					.main-info-link {
-						margin-top: 100px;
-						a {
-							display: inline-block;
-							width: 175px;
-							height: 50px;
-							color: #fff;
-							border-radius: 5px;
-							text-align: center;
-							line-height: 50px;
-							font-size: 18px;
-							border: 1px solid #000;
-							&:first-child {
-								background: rgba(7, 34, 83, 0.89);
-								-webkit-box-shadow: 0 0 11px 3px rgba(8, 49, 157, 0.8) inset;
-								box-shadow: inset 0 0 11px 3px rgba(8, 49, 157, 0.8);
+				.main-login-form {
+					width: 100%;
+					background: #a4a4af;
+					border-radius: 0 0 5px 5px;
+					padding: 40px 30px;
+					box-sizing: border-box;
+					.main-login-from-user,
+					.main-login-from-pass,
+					.main-login-from-com {
+						width: 300px;
+						border: 1px solid #000;
+						height: 30px;
+						border-radius: 5px;
+						margin-bottom: 10px;
+						overflow: hidden;
+						label {
+							display: flex;
+							span {
+								display: inline-block;
+								width: 70px;
+								height: 50px;
+								background-color: #a6a6a6;
+								text-align: center;
+								line-height: 30px;
 							}
-							&:last-child {
-								background: rgba(51, 204, 204, 0.7);
-								-webkit-box-shadow: 0 0 11px 3px #4fcaca inset;
-								box-shadow: inset 0 0 11px 3px #4fcaca;
-								margin-left: 8px;
+							input {
+								display: block;
+								width: 230px;
+								height: 30px;
+								padding: 0;
+								margin: 0;
+								border: none;
+								background-color: #fff;
+								outline: none;
+								line-height: 30px;
+								padding-left: 5px;
 							}
 						}
+						.com-select {
+							width: 235px;
+							height: 30px;
+							outline: none;
+						}
 					}
-				}
-				.main-login {
-					width: 360px;
-					.main-login-title {
-						width: 100%;
-						height: 45px;
-						line-height: 45px;
-						font-size: 18px;
-						background: #07276a;
-						border-radius: 5px 5px 0 0;
-						color: #fff;
-						text-align: center;
-					}
-					.main-login-form {
-						width: 100%;
-						background: #a4a4af;
-						border-radius: 0 0 5px 5px;
-						padding: 40px 30px;
-						box-sizing: border-box;
-						.main-login-from-user,
-						.main-login-from-pass {
-							width: 300px;
-							border: 1px solid #000;
+					.main-login-from-btn {
+						button {
+							width: 100%;
+							color: #fff;
+							background-color: #07276a;
 							height: 50px;
 							border-radius: 5px;
-							margin-bottom: 20px;
-							overflow: hidden;
-							label {
-								display: flex;
-								span {
-									display: inline-block;
-									width: 70px;
-									height: 50px;
-									background-color: #a6a6a6;
-									text-align: center;
-									line-height: 50px;
-								}
-								input {
-									display: block;
-									width: 230px;
-									height: 50px;
-									padding: 0;
-									margin: 0;
-									border: none;
-									background-color: #fff;
-									outline: none;
-									line-height: 30px;
-									padding-left: 5px;
-								}
-							}
-						}
-						.main-login-from-btn {
-							button {
-								width: 100%;
-								color: #fff;
-								background-color: #07276a;
-								height: 50px;
-								border-radius: 5px;
-								outline: none;
-							}
+							outline: none;
 						}
 					}
 				}
 			}
 		}
 	}
+}
 </style>