部分修改

This commit is contained in:
hezhidong
2024-04-22 17:57:12 +08:00
parent 295117a443
commit 153328dacc
3 changed files with 634 additions and 930 deletions
+563 -588
View File
File diff suppressed because it is too large Load Diff
+42 -49
View File
@@ -65,7 +65,9 @@
<!-- <span class="login-code-img" > --> <!-- <span class="login-code-img" > -->
<!-- <i class="el-icon-position">{{ sendText }}</i> --> <!-- <i class="el-icon-position">{{ sendText }}</i> -->
<!-- </span> --> <!-- </span> -->
<el-button class="el-icon-position" style="width: 100%;">{{ sendText }}</el-button> <el-button class="el-icon-position" style="width: 100%">{{
sendText
}}</el-button>
</div> </div>
</div> </div>
</div> </div>
@@ -110,8 +112,8 @@ import { PrevLoading } from "@/utils/loading.js";
import { quotationsList } from "./mock"; import { quotationsList } from "./mock";
import { useLoginApi } from "@/api/login"; import { useLoginApi } from "@/api/login";
import { Message } from "element-ui"; import { Message } from "element-ui";
import { rulesPhone } from '@/com/index.js' import { rulesPhone } from "@/com/index.js";
import { getSmsCaptcha, login } from './api' import { getSmsCaptcha, login } from "./api";
const LoginApi = useLoginApi(); const LoginApi = useLoginApi();
export default { export default {
@@ -132,7 +134,7 @@ export default {
txt: "", txt: "",
fun: null, fun: null,
}, },
sendText: '发送' sendText: "发送",
}; };
}, },
computed: { computed: {
@@ -147,16 +149,15 @@ export default {
}, },
created() { created() {
const paragraph = "I think Ruth's dog is cuter than your dog! Ruth"; const paragraph = "I think Ruth's dog is cuter than your dog! Ruth";
console.log(paragraph.replace("Ruth", 'my')); console.log(paragraph.replace("Ruth", "my"));
this.initTime(); this.initTime();
}, },
mounted() { mounted() {
this.initRandomQuotations(); this.initRandomQuotations();
// console.log(localStorage.getItem('user')) // console.log(localStorage.getItem('user'))
console.log('this.$store.state.loginConfig') console.log("this.$store.state.loginConfig");
console.log(this.$store.state.loginConfig.loginConfig) console.log(this.$store.state.loginConfig.loginConfig);
}, },
methods: { methods: {
// 随机语录 // 随机语录
@@ -174,71 +175,65 @@ export default {
}, },
// 登录按钮点击 // 登录按钮点击
submitForm() { submitForm() {
this.$router.push('/evaluate') console.log(this.$router);
console.log(this.$router) if (rulesPhone(this.loginForm.phone)) {
// 判断是否存在手机号验证码
if( rulesPhone(this.loginForm.phone) ){ // 判断是否存在手机号验证码
if (this.loginForm.code) { if (this.loginForm.code) {
this.submit.loading = true; this.submit.loading = true;
// 登录发请求获取用户信息 // 登录发请求获取用户信息
let obj = {...this.$store.state.loginConfig.loginConfig, ...this.loginForm} let obj = { ...this.$store.state.loginConfig.loginConfig, ...this.loginForm };
let formData = new FormData() let formData = new FormData();
for (let key in obj) { for (let key in obj) {
formData.append(key, obj[key]) formData.append(key, obj[key]);
} }
this.$store.dispatch('loginIn', formData).then(res =>{ this.$store
this.$message.success('登录成功!') .dispatch("loginIn", formData)
Session.set('token',res.token_type +' ' + res.access_token) .then((res) => {
// this.$router.push('/evaluate') this.$message.success("登录成功!");
Session.set("token", res.token_type + " " + res.access_token);
// 设置用户信息 学校信息 班级信息 // 设置用户信息 学校信息 班级信息
let user = this.$store.state.user let user = this.$store.state.user;
if (user.campusInfo) { if (user.campusInfo) {
if(user.campusInfo.length >= 1){ // 说明只有一个校区 if (user.campusInfo.length >= 1) {
// 说明只有一个校区
if (user.campusInfo[0].classInfo) { if (user.campusInfo[0].classInfo) {
this.$store.commit('setSchool', user.campusInfo[0] ); // 设置默认校区 this.$store.commit("setSchool", user.campusInfo[0]); // 设置默认校区
} }
} }
}else { // 未查到校区信息 } else {
// 未查到校区信息
} }
this.oldSet() this.oldSet();
}).finally(err =>{
this.submit.loading = false;
this.sendText = '发送'
}) })
.finally((err) => {
this.submit.loading = false;
this.sendText = "发送";
});
} else { } else {
this.$message.error('请输入验证码!') this.$message.error("请输入验证码!");
} }
} else { } else {
this.$message.error('请输入正确的手机号!') this.$message.error("请输入正确的手机号!");
} }
}, },
// 点击发送验证码 // 点击发送验证码
onClickSendCode() { onClickSendCode() {
if (rulesPhone(this.loginForm.phone)) { if (rulesPhone(this.loginForm.phone)) {
if(this.sendText == '发送' || this.sendText == '重新发送'){ if (this.sendText == "发送" || this.sendText == "重新发送") {
getSmsCaptcha(this.loginForm.phone).then(res =>{ getSmsCaptcha(this.loginForm.phone)
this.sendText = '发送成功' .then((res) => {
}).catch(err =>{ this.sendText = "发送成功";
this.sendText = '重新发送'
}) })
.catch((err) => {
this.sendText = "重新发送";
});
} }
} else { } else {
this.$message.error('请输入正确的手机号!') this.$message.error("请输入正确的手机号!");
} }
}, },
// 验证表单
rulesForm() {
// if(loginForm.phone){
// }
// this.loginForm.phone
},
oldSet() { oldSet() {
let defaultRoles = []; let defaultRoles = [];
let defaultAuthBtnList = []; let defaultAuthBtnList = [];
@@ -278,13 +273,12 @@ export default {
`${this.currentTime}${this.$t("message.login.signInText")}` `${this.currentTime}${this.$t("message.login.signInText")}`
); );
}, 300); }, 300);
} },
}, },
destroyed() { destroyed() {
clearInterval(this.time.fun); clearInterval(this.time.fun);
}, },
/* /*
setTimeout(() => { setTimeout(() => {
let defaultRoles = []; let defaultRoles = [];
@@ -329,7 +323,6 @@ export default {
}, 300); }, 300);
}, 300); }, 300);
*/ */
}; };
</script> </script>
-264
View File
@@ -1,264 +0,0 @@
<template>
<div>
<div>
<!-- 搜索 -->
<div class="form-adapt-container">
<el-card shadow="hover">
<CommonHead
@search-data="searchForm"
@reset-data="reset"
@newly-data="add"
></CommonHead>
<!-- newly-data删除所选事件 -->
<!-- reset-data重置表单内容 -->
<!-- search-data搜索事件接收被搜索的内容 -->
<el-form>
<el-form-item label="角色范围" style="margin-top: 10px">
<el-select
size="mini"
v-model="firstLevelRoleid"
placeholder="请选择所属范围"
>
<el-option
v-for="(item, index) in firstLevelRoleList"
:label="item.name"
:key="index"
:value="item.id"
@click.native="queryRoleList(item.id)"
></el-option>
</el-select>
</el-form-item>
</el-form>
</el-card>
<CommonTables
v-loading="loading"
:delete-func="deleteData"
:edit-func="editData"
:columns="columns"
:data="RoleList"
></CommonTables>
<!-- <Pagination
:total="total"
:pageNum="query.pageNum"
:pageSize="query.pageSize"
@clickCurrent="onClickCurrent"
@clickSize="onClickSize"
/> -->
</div>
</div>
<!-- 对话框 -->
<el-dialog
title="设置权限"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose"
>
<el-tree
ref="treeOne"
:data="LevelPermissionList"
show-checkbox
node-key="id"
:props="defaultProps"
>
</el-tree>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false" size="mini"> </el-button>
<el-button type="primary" @click="confirmSettingRules" size="mini"
> </el-button
>
</span>
</el-dialog>
</div>
</template>
<script>
import columns from "./columns";
import {
rqGetRoleList,
rqGetPermissionList,
rqQueryPermission,
rqModifyOrAddPermissions,
} from "./api";
export default {
name: "rolePermissions",
data() {
return {
columns,
total: 0,
query: {
pageNum: 1,
pageSize: 10,
},
loading: false,
ruleList: [],
dialogVisible: false,
// 一级角色列表
firstLevelRoleList: [],
// 一级id
firstLevelRoleid: "默认",
//操作角色列表
RoleList: [],
// 一级权限列表
LevelPermissionList: [],
// 一级id
firstLevelPermission: "",
defaultProps: {
children: "authorities",
label: "alias",
},
// 角色的id
formRC: {
roleid: "",
// 点击已经选中的id集合
authorityids: [],
},
// 进来已经选择的
selectedByDefault: [],
};
},
created() {
this.getRoleList();
this.getPermissionList();
this.queryRoleList(592539677);
},
methods: {
// 搜索按钮
searchForm() {
this.$message("正在搜索");
},
// 重置按钮
reset() {
this.bus.$emit("onCurrentContextmenuClick", {
id: 0,
path: this.$route.path,
});
},
// 添加
add() {
this.$message("角色新增请联系钉钉后台管理员");
},
// 删除
async deleteData(row) {
this.$message("该角色暂时无法删除");
},
// 编辑
async editData(item) {
this.formRC.roleid = item.id;
this.dialogVisible = true;
console.log(item);
let res = await rqQueryPermission(item.id);
if (res.code == 200) {
let arr = res.data.map((item, index) => {
return item.id;
});
this.selectedByDefault = arr;
this.$refs.treeOne.setCheckedKeys(arr);
} else {
this.$message.error("网络错误");
}
},
// 点击切换页数
onClickCurrent(val) {
this.query.pageNum = val;
this.getAttendanceFormData();
},
// 点击了每页页数
onClickSize(val) {
this.query.pageSize = val;
this.getAttendanceFormData();
},
handleClose(done) {
this.$confirm("确认关闭?")
.then((_) => {
done();
})
.catch((_) => {});
},
// 获取角色列表分类
async getRoleList() {
try {
this.loading = true;
// let result = await rqGetRuleList(this.query.pageNum, this.query.pageSize);//做了分页
let result = await rqGetRoleList();
if (result.code == 200) {
this.loading = false;
this.firstLevelRoleList = result.data;
// this.total = result.data.total;
} else {
this.loading = false;
this.$message.error("服务器错误");
}
} catch (error) {
this.loading = false;
this.$message.error("网络错误");
}
},
// 查询角色列表
async queryRoleList(id) {
try {
this.loading = true;
// let result = await rqGetRuleList(this.query.pageNum, this.query.pageSize);//做了分页
let result = await rqGetRoleList(id);
if (result.code == 200) {
this.loading = false;
this.RoleList = result.data;
// this.total = result.data.total;
} else {
this.loading = false;
this.$message.error("网络错误");
}
} catch (error) {
this.loading = false;
this.$message.error("网络错误");
}
},
// 获取权限列表
async getPermissionList() {
console.log(111);
try {
this.loading = true;
// let result = await rqGetRuleList(this.query.pageNum, this.query.pageSize);//做了分页
let result = await rqGetPermissionList();
if (result.code == 200) {
this.loading = false;
this.LevelPermissionList = result.data;
// this.total = result.data.total;
} else {
this.loading = false;
this.$message.error("服务器错误");
}
} catch (error) {
this.loading = false;
this.$message.error("网络错误");
}
},
// 确认新增或者修改按钮
async confirmSettingRules() {
const treeInstance = this.$refs.treeOne;
// 调用 getCheckedNodes 方法获取已勾选的节点数组
const checkedNodes = treeInstance.getCheckedNodes();
console.log(checkedNodes);
let arr = checkedNodes.map((ion, index) => {
return ion.id;
});
this.formRC.authorityids = arr;
let res = await rqModifyOrAddPermissions(this.formRC);
if (res.code == 200) {
this.$message.success("设置成功");
this.dialogVisible = false;
} else {
this.dialogVisible = false;
this.$message.success("服务器错误");
}
},
},
};
</script>
<style lang="scss" scoped></style>