|
|
@@ -5,31 +5,24 @@
|
|
|
UAS-MES可视化平台
|
|
|
</h3>
|
|
|
<el-form-item prop="sob">
|
|
|
- <el-select v-model="loginForm.sob" placeholder="请选择账套" style="width:100%">
|
|
|
- <el-option
|
|
|
- v-for="item in options"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
+ <el-select v-model="loginForm.sob" placeholder="请选择账套" style="width:100%">
|
|
|
+ <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="workshop">
|
|
|
- <el-select v-model="loginForm.workshop" placeholder="请选择车间" style="width:100%">
|
|
|
- <el-option
|
|
|
- v-for="item in workshopoptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
+ <el-select v-model="loginForm.workshop" placeholder="请选择车间" style="width:100%">
|
|
|
+ <el-option v-for="item in workshopoptions" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="username">
|
|
|
- <el-input type="text" v-model="loginForm.username" placeholder="请输入用户名" >
|
|
|
+ <el-input type="text" v-model="loginForm.username" placeholder="请输入用户名">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="password">
|
|
|
- <el-input type="password" v-model="loginForm.password" placeholder="请输入密码" >
|
|
|
+ <el-input type="password" v-model="loginForm.password" placeholder="请输入密码">
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<el-checkbox v-model="checked" class="loginRemember">记住我</el-checkbox>
|
|
|
@@ -39,217 +32,225 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import CryptoJS from "crypto-js";
|
|
|
+import CryptoJS from "crypto-js";
|
|
|
|
|
|
- export default {
|
|
|
- name: "Login",
|
|
|
- data(){
|
|
|
- return{
|
|
|
- captchaUrl: "",
|
|
|
- loginForm:{
|
|
|
- sob:"",
|
|
|
- username:"",
|
|
|
- password:"",
|
|
|
- workshop:"SMT"
|
|
|
- },
|
|
|
- checked: true,
|
|
|
- rules:{
|
|
|
- sob :[{required:true,message:"请选择账套",trigger:"blur"}],
|
|
|
- username:[{required:true,message:"请输入用户名",trigger:"blur"}/*,{ min: 5, max: 14, message: '长度在 5 到 14 个字符', trigger: 'blur' }*/],
|
|
|
- password:[{required:true,message:"请输入密码",trigger:"blur"} /*,{ min: 6, message: '密码长度要大于6', trigger: 'blur' }*/],
|
|
|
- workshop:[{required:true,message:"请选择车间",trigger:"blur"}]
|
|
|
- },
|
|
|
- options: [],
|
|
|
- workshopoptions:[
|
|
|
- {label: '组装', value: '组装'},
|
|
|
- {label: '包装', value: '包装'},
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- //默认数据
|
|
|
- this.getCookies();
|
|
|
- //获取账套信息
|
|
|
- this.getMasters();
|
|
|
- //获取工作中心数据
|
|
|
- // this.getWorkCenter();
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- //监听enter键
|
|
|
- this.$refs.loginForm.$el.addEventListener('keydown',this.handleEnter);
|
|
|
+export default {
|
|
|
+ name: "Login",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ captchaUrl: "",
|
|
|
+ loginForm: {
|
|
|
+ sob: "",
|
|
|
+ username: "",
|
|
|
+ password: "",
|
|
|
+ workshop: "SMT"
|
|
|
+ },
|
|
|
+ checked: true,
|
|
|
+ rules: {
|
|
|
+ sob: [{ required: true, message: "请选择账套", trigger: "blur" }],
|
|
|
+ username: [{ required: true, message: "请输入用户名", trigger: "blur" }/*,{ min: 5, max: 14, message: '长度在 5 到 14 个字符', trigger: 'blur' }*/],
|
|
|
+ password: [{ required: true, message: "请输入密码", trigger: "blur" } /*,{ min: 6, message: '密码长度要大于6', trigger: 'blur' }*/],
|
|
|
+ workshop: [{ required: true, message: "请选择车间", trigger: "blur" }]
|
|
|
+ },
|
|
|
+ options: [],
|
|
|
+ workshopoptions: [
|
|
|
+ { label: '组装', value: '组装' },
|
|
|
+ { label: '包装', value: '包装' },
|
|
|
+ { label: '测试', value: '测试' },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ //默认数据
|
|
|
+ this.getCookies();
|
|
|
+ //获取账套信息
|
|
|
+ this.getMasters();
|
|
|
+ //获取工作中心数据
|
|
|
+ // this.getWorkCenter();
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ //监听enter键
|
|
|
+ this.$refs.loginForm.$el.addEventListener('keydown', this.handleEnter);
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ this.$refs.loginForm.$el.removeEventListener('keydown', this.handleEnter);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //获取账套
|
|
|
+ getMasters() {
|
|
|
+ this.$http.get("kanban/getAllMasters.action").then(
|
|
|
+ (result) => {
|
|
|
+ var res = JSON.parse(JSON.stringify(result.data.masters));
|
|
|
+ for (let i = 0; i < res.length; i++) {
|
|
|
+ this.options.push({ label: res[i].ma_function, value: res[i].ma_user });
|
|
|
+ }
|
|
|
+ //设置默认值
|
|
|
+ if ("" == this.loginForm.sob || !result.data.masters.some(item => item.ma_function === this.loginForm.sob)) {
|
|
|
+ this.loginForm.sob = res[0].ma_user;
|
|
|
+ }
|
|
|
+ }, (result) => {
|
|
|
+ console.error(result)
|
|
|
+ });
|
|
|
},
|
|
|
- beforeDestroy(){
|
|
|
- this.$refs.loginForm.$el.removeEventListener('keydown',this.handleEnter);
|
|
|
+ //获取工作中心
|
|
|
+ getWorkCenter() {
|
|
|
+ this.$http.get("kanban/getAllWorkCenter.action").then(
|
|
|
+ (result) => {
|
|
|
+ var res = JSON.parse(JSON.stringify(result.data.workCenter));
|
|
|
+ for (let i = 0; i < res.length; i++) {
|
|
|
+ this.workshopoptions.push({ label: res[i].wc_code, value: res[i].wc_name });
|
|
|
+ }
|
|
|
+ //设置默认值
|
|
|
+ if ("" == this.loginForm.workshop || !result.data.workCenter.some(item => item.ma_function === this.loginForm.workshop)) {
|
|
|
+ this.loginForm.workshop = res[0].ma_user;
|
|
|
+ }
|
|
|
+ }, (result) => {
|
|
|
+ console.error(result)
|
|
|
+ });
|
|
|
},
|
|
|
- methods:{
|
|
|
- //获取账套
|
|
|
- getMasters(){
|
|
|
- this.$http.get("kanban/getAllMasters.action").then(
|
|
|
- (result)=>{
|
|
|
- var res = JSON.parse(JSON.stringify(result.data.masters));
|
|
|
- for (let i = 0; i < res.length; i++) {
|
|
|
- this.options.push({label: res[i].ma_function, value: res[i].ma_user});
|
|
|
- }
|
|
|
- //设置默认值
|
|
|
- if("" == this.loginForm.sob || !result.data.masters.some(item => item.ma_function === this.loginForm.sob) ){
|
|
|
- this.loginForm.sob = res[0].ma_user;
|
|
|
- }
|
|
|
- },(result)=>{
|
|
|
- console.error(result)
|
|
|
- });
|
|
|
- },
|
|
|
- //获取工作中心
|
|
|
- getWorkCenter(){
|
|
|
- this.$http.get("kanban/getAllWorkCenter.action").then(
|
|
|
- (result)=>{
|
|
|
- var res = JSON.parse(JSON.stringify(result.data.workCenter));
|
|
|
- for (let i = 0; i < res.length; i++) {
|
|
|
- this.workshopoptions.push({label: res[i].wc_code, value: res[i].wc_name});
|
|
|
- }
|
|
|
- //设置默认值
|
|
|
- if("" == this.loginForm.workshop || !result.data.workCenter.some(item => item.ma_function === this.loginForm.workshop) ){
|
|
|
- this.loginForm.workshop = res[0].ma_user;
|
|
|
+ //登录操作
|
|
|
+ submitLogin() {
|
|
|
+ this.$refs.loginForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // console.log('登录',this.loginForm);
|
|
|
+ //?username=zhongyl&password=asd&sob=N_MES_TEST
|
|
|
+ this.$http.get("kanban/login.action", {
|
|
|
+ params: {
|
|
|
+ username: this.loginForm.username,
|
|
|
+ password: this.loginForm.password,
|
|
|
+ sob: this.loginForm.sob,
|
|
|
+ wccode: this.loginForm.workshop
|
|
|
}
|
|
|
- },(result)=>{
|
|
|
- console.error(result)
|
|
|
- });
|
|
|
- },
|
|
|
- //登录操作
|
|
|
- submitLogin(){
|
|
|
- this.$refs.loginForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- // console.log('登录',this.loginForm);
|
|
|
- //?username=zhongyl&password=asd&sob=N_MES_TEST
|
|
|
- this.$http.get("kanban/login.action",{
|
|
|
- params:{
|
|
|
- username:this.loginForm.username,
|
|
|
- password:this.loginForm.password,
|
|
|
- sob:this.loginForm.sob,
|
|
|
- wccode:this.loginForm.workshop
|
|
|
- }}).then(
|
|
|
- (result)=>{
|
|
|
- var res = result.data;
|
|
|
- if(res.success || "检测到您已登录本系统,请不要重复登录、打开空白页!" == res.reason) {
|
|
|
- //登录成功返回session
|
|
|
- sessionStorage.setItem('x-access-token', res.token);
|
|
|
- sessionStorage.setItem('user',res);
|
|
|
- this.$store.commit('setUser',res);
|
|
|
- this.setCookieData();
|
|
|
-
|
|
|
- if(this.loginForm.workshop =='组装'){
|
|
|
- this.$router.push({path: this.redirect || '/assembly'});
|
|
|
+ }).then(
|
|
|
+ (result) => {
|
|
|
+ var res = result.data;
|
|
|
+ if (res.success || "检测到您已登录本系统,请不要重复登录、打开空白页!" == res.reason) {
|
|
|
+ //登录成功返回session
|
|
|
+ sessionStorage.setItem('x-access-token', res.token);
|
|
|
+ sessionStorage.setItem('user', res);
|
|
|
+ this.$store.commit('setUser', res);
|
|
|
+ this.setCookieData();
|
|
|
|
|
|
- }
|
|
|
- if(this.loginForm.workshop =='包装'){
|
|
|
- this.$router.push({path: this.redirect || '/package'});
|
|
|
- }
|
|
|
+ if (this.loginForm.workshop == '组装') {
|
|
|
+ this.$router.push({ path: this.redirect || '/assembly' });
|
|
|
|
|
|
-
|
|
|
- }else{
|
|
|
- this.$message.error(res.reason);
|
|
|
}
|
|
|
- },(result)=>{
|
|
|
- console.error(result)
|
|
|
- });
|
|
|
+ if (this.loginForm.workshop == '包装') {
|
|
|
+ this.$router.push({ path: this.redirect || '/package' });
|
|
|
+ }
|
|
|
+ if (this.loginForm.workshop == '测试') {
|
|
|
+ this.$router.push({ path: this.redirect || '/testShop' });
|
|
|
+ }
|
|
|
|
|
|
- /*this.$store.dispatch('kanban/login.action',this.form).then(() => {
|
|
|
- this.$router.push({ path: this.redirect || '/' })
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false;
|
|
|
- })*/
|
|
|
- } else {
|
|
|
- this.$message.error('登录出错请重新输入');
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.reason);
|
|
|
+ }
|
|
|
+ }, (result) => {
|
|
|
+ console.error(result)
|
|
|
+ });
|
|
|
|
|
|
- },
|
|
|
- handleEnter(event){
|
|
|
- if(event.key === 'Enter'){
|
|
|
- //处理回车键按下时间
|
|
|
- this.submitLogin();
|
|
|
- }
|
|
|
- },
|
|
|
- setCookieData(){
|
|
|
- if (this.checked) {
|
|
|
- this.$cookie.set(
|
|
|
- "password",
|
|
|
- CryptoJS.AES.encrypt(this.loginForm.password, "123456"),
|
|
|
- {
|
|
|
- expires: 30
|
|
|
- }
|
|
|
- );
|
|
|
+ /*this.$store.dispatch('kanban/login.action',this.form).then(() => {
|
|
|
+ this.$router.push({ path: this.redirect || '/' })
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })*/
|
|
|
} else {
|
|
|
- this.$cookie.remove("password");
|
|
|
+ this.$message.error('登录出错请重新输入');
|
|
|
+ return false;
|
|
|
}
|
|
|
- this.$cookie.set("username", this.loginForm.username, {
|
|
|
- expires: 30,
|
|
|
- });
|
|
|
- this.$cookie.set("sob", this.loginForm.sob, {
|
|
|
- expires: 30,
|
|
|
- });
|
|
|
- this.$cookie.set("workshop", this.loginForm.workshop, {
|
|
|
- expires: 30,
|
|
|
- });
|
|
|
- this.$cookie.set("checked", this.checked, {
|
|
|
- expires: 30,
|
|
|
- });
|
|
|
- },
|
|
|
- getCookies(){
|
|
|
- if(this.$cookie.get("sob")) {
|
|
|
- this.loginForm.sob = this.$cookie.get("sob");
|
|
|
- }
|
|
|
- this.loginForm.username = this.$cookie.get("username");
|
|
|
- if (this.$cookie.get("password")) {
|
|
|
- this.loginForm.password = CryptoJS.AES.decrypt(
|
|
|
- this.$cookie.get("password"),
|
|
|
- "123456"
|
|
|
- ).toString(CryptoJS.enc.Utf8);
|
|
|
- }
|
|
|
- if(this.$cookie.get("workshop")) {
|
|
|
- this.loginForm.workshop = this.$cookie.get("workshop");
|
|
|
- }
|
|
|
- if(this.$cookie.get("checked")) {
|
|
|
- if(this.$cookie.get("checked") == 'false') {
|
|
|
- this.checked = false;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ handleEnter(event) {
|
|
|
+ if (event.key === 'Enter') {
|
|
|
+ //处理回车键按下时间
|
|
|
+ this.submitLogin();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setCookieData() {
|
|
|
+ if (this.checked) {
|
|
|
+ this.$cookie.set(
|
|
|
+ "password",
|
|
|
+ CryptoJS.AES.encrypt(this.loginForm.password, "123456"),
|
|
|
+ {
|
|
|
+ expires: 30
|
|
|
}
|
|
|
- }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$cookie.remove("password");
|
|
|
}
|
|
|
+ this.$cookie.set("username", this.loginForm.username, {
|
|
|
+ expires: 30,
|
|
|
+ });
|
|
|
+ this.$cookie.set("sob", this.loginForm.sob, {
|
|
|
+ expires: 30,
|
|
|
+ });
|
|
|
+ this.$cookie.set("workshop", this.loginForm.workshop, {
|
|
|
+ expires: 30,
|
|
|
+ });
|
|
|
+ this.$cookie.set("checked", this.checked, {
|
|
|
+ expires: 30,
|
|
|
+ });
|
|
|
},
|
|
|
- };
|
|
|
+ getCookies() {
|
|
|
+ if (this.$cookie.get("sob")) {
|
|
|
+ this.loginForm.sob = this.$cookie.get("sob");
|
|
|
+ }
|
|
|
+ this.loginForm.username = this.$cookie.get("username");
|
|
|
+ if (this.$cookie.get("password")) {
|
|
|
+ this.loginForm.password = CryptoJS.AES.decrypt(
|
|
|
+ this.$cookie.get("password"),
|
|
|
+ "123456"
|
|
|
+ ).toString(CryptoJS.enc.Utf8);
|
|
|
+ }
|
|
|
+ if (this.$cookie.get("workshop")) {
|
|
|
+ this.loginForm.workshop = this.$cookie.get("workshop");
|
|
|
+ }
|
|
|
+ if (this.$cookie.get("checked")) {
|
|
|
+ if (this.$cookie.get("checked") == 'false') {
|
|
|
+ this.checked = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
- .loginContainer{
|
|
|
- border-radius: 15px;
|
|
|
- background-clip: padding-box;
|
|
|
- margin: 180px auto;
|
|
|
- width: 350px;
|
|
|
- padding: 15px 35px 15px 35px;
|
|
|
- background: aliceblue;
|
|
|
- border:1px solid blueviolet;
|
|
|
- box-shadow: 0 0 25px #f885ff;
|
|
|
- }
|
|
|
- .loginTitle{
|
|
|
- margin: 0px auto 35px auto;
|
|
|
- text-align: center;
|
|
|
- font-size: 24px;
|
|
|
- }
|
|
|
- .loginRemember{
|
|
|
- text-align: left;
|
|
|
- margin: 0px 0px 15px 0px;
|
|
|
- }
|
|
|
- .bg {
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- background-image: url("../assets/pageBg.png");
|
|
|
- background-size: cover;
|
|
|
- background-position: center center;
|
|
|
- }
|
|
|
- /*body{
|
|
|
+.loginContainer {
|
|
|
+ border-radius: 15px;
|
|
|
+ background-clip: padding-box;
|
|
|
+ margin: 180px auto;
|
|
|
+ width: 350px;
|
|
|
+ padding: 15px 35px 15px 35px;
|
|
|
+ background: aliceblue;
|
|
|
+ border: 1px solid blueviolet;
|
|
|
+ box-shadow: 0 0 25px #f885ff;
|
|
|
+}
|
|
|
+
|
|
|
+.loginTitle {
|
|
|
+ margin: 0px auto 35px auto;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.loginRemember {
|
|
|
+ text-align: left;
|
|
|
+ margin: 0px 0px 15px 0px;
|
|
|
+}
|
|
|
+
|
|
|
+.bg {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-image: url("../assets/pageBg.png");
|
|
|
+ background-size: cover;
|
|
|
+ background-position: center center;
|
|
|
+}
|
|
|
+
|
|
|
+/*body{
|
|
|
background-image: url("../assets/pageBg.png");
|
|
|
background-size:100%;
|
|
|
}*/
|
|
|
</style>
|
|
|
-
|