Browse Source

验证码配置参数修改进配置文件,前端角色id不再允许输入英文字符

main
QM303176530 4 years ago
parent
commit
d70599f637
  1. 3
      server/api/v1/sys_captcha.go
  2. 6
      server/config.yaml
  3. 240
      web/src/view/superAdmin/authority/authority.vue

3
server/api/v1/sys_captcha.go

@ -2,6 +2,7 @@ package v1
import ( import (
"fmt" "fmt"
"gin-vue-admin/global"
"gin-vue-admin/global/response" "gin-vue-admin/global/response"
resp "gin-vue-admin/model/response" resp "gin-vue-admin/model/response"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -20,7 +21,7 @@ var store = base64Captcha.DefaultMemStore
func Captcha(c *gin.Context) { func Captcha(c *gin.Context) {
//字符,公式,验证码配置 //字符,公式,验证码配置
// 生成默认数字的driver // 生成默认数字的driver
driver := base64Captcha.NewDriverDigit(80, 240, 5, 0.7, 80)
driver := base64Captcha.NewDriverDigit(global.GVA_CONFIG.Captcha.ImgHeight, global.GVA_CONFIG.Captcha.ImgWidth, global.GVA_CONFIG.Captcha.KeyLong, 0.7, 80)
cp := base64Captcha.NewCaptcha(driver, store) cp := base64Captcha.NewCaptcha(driver, store)
id, b64s, err := cp.Generate() id, b64s, err := cp.Generate()
if err != nil { if err != nil {

6
server/config.yaml

@ -46,9 +46,9 @@ system:
# captcha configuration # captcha configuration
captcha: captcha:
key-long: 4
img-width: 120
img-height: 40
key-long: 6
img-width: 240
img-height: 80
# logger configuration # logger configuration
log: log:

240
web/src/view/superAdmin/authority/authority.vue

@ -57,7 +57,13 @@
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="角色ID" prop="authorityId"> <el-form-item label="角色ID" prop="authorityId">
<el-input :disabled="dialogType=='edit'" autocomplete="off" v-model="form.authorityId"></el-input>
<el-input-number
:disabled="dialogType=='edit'"
step-strictly
:step="1"
autocomplete="off"
v-model="form.authorityId"
></el-input-number>
</el-form-item> </el-form-item>
<el-form-item label="角色姓名" prop="authorityName"> <el-form-item label="角色姓名" prop="authorityName">
<el-input autocomplete="off" v-model="form.authorityName"></el-input> <el-input autocomplete="off" v-model="form.authorityName"></el-input>
@ -94,50 +100,50 @@ import {
createAuthority, createAuthority,
updateAuthority, updateAuthority,
copyAuthority copyAuthority
} from '@/api/authority'
} from "@/api/authority";
import Menus from '@/view/superAdmin/authority/components/menus'
import Apis from '@/view/superAdmin/authority/components/apis'
import Datas from '@/view/superAdmin/authority/components/datas'
import Menus from "@/view/superAdmin/authority/components/menus";
import Apis from "@/view/superAdmin/authority/components/apis";
import Datas from "@/view/superAdmin/authority/components/datas";
import infoList from '@/components/mixins/infoList'
import infoList from "@/components/mixins/infoList";
export default { export default {
name: 'Authority',
name: "Authority",
mixins: [infoList], mixins: [infoList],
data() { data() {
return { return {
AuthorityOption: [ AuthorityOption: [
{ {
authorityId: '0',
authorityName: '根角色'
authorityId: "0",
authorityName: "根角色"
} }
], ],
listApi: getAuthorityList, listApi: getAuthorityList,
drawer: false, drawer: false,
dialogType: 'add',
dialogType: "add",
activeRow: {}, activeRow: {},
activeUserId: 0, activeUserId: 0,
dialogTitle: '新增角色',
dialogTitle: "新增角色",
dialogFormVisible: false, dialogFormVisible: false,
apiDialogFlag: false, apiDialogFlag: false,
copyForm: {}, copyForm: {},
form: { form: {
authorityId: '',
authorityName: '',
parentId: '0'
authorityId: "",
authorityName: "",
parentId: "0"
}, },
rules: { rules: {
authorityId: [ authorityId: [
{ required: true, message: '请输入角色ID', trigger: 'blur' }
{ required: true, message: "请输入角色ID", trigger: "blur" }
], ],
authorityName: [ authorityName: [
{ required: true, message: '请输入角色名', trigger: 'blur' }
{ required: true, message: "请输入角色名", trigger: "blur" }
], ],
parentId: [ parentId: [
{ required: true, message: '请选择请求方式', trigger: 'blur' }
{ required: true, message: "请选择请求方式", trigger: "blur" }
] ]
} }
}
};
}, },
components: { components: {
Menus, Menus,
@ -146,148 +152,148 @@ export default {
}, },
methods: { methods: {
autoEnter(activeName, oldActiveName) { autoEnter(activeName, oldActiveName) {
const paneArr = ['menus', 'apis', 'datas']
const paneArr = ["menus", "apis", "datas"];
if (oldActiveName) { if (oldActiveName) {
if (this.$refs[paneArr[oldActiveName]].needConfirm) { if (this.$refs[paneArr[oldActiveName]].needConfirm) {
this.$refs[paneArr[oldActiveName]].enterAndNext()
this.$refs[paneArr[oldActiveName]].needConfirm = false
this.$refs[paneArr[oldActiveName]].enterAndNext();
this.$refs[paneArr[oldActiveName]].needConfirm = false;
} }
} }
}, },
// //
copyAuthority(row) { copyAuthority(row) {
this.setOptions()
this.dialogTitle = '拷贝角色'
this.dialogType = 'copy'
this.setOptions();
this.dialogTitle = "拷贝角色";
this.dialogType = "copy";
for (let k in this.form) { for (let k in this.form) {
this.form[k] = row[k]
this.form[k] = row[k];
} }
this.copyForm = row
this.dialogFormVisible = true
this.copyForm = row;
this.dialogFormVisible = true;
}, },
opdendrawer(row) { opdendrawer(row) {
this.drawer = true
this.activeRow = row
this.drawer = true;
this.activeRow = row;
}, },
// //
deleteAuth(row) { deleteAuth(row) {
this.$confirm('此操作将永久删除该角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
this.$confirm("此操作将永久删除该角色, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}) })
.then(async () => { .then(async () => {
const res = await deleteAuthority({ authorityId: row.authorityId })
const res = await deleteAuthority({ authorityId: row.authorityId });
if (res.code == 0) { if (res.code == 0) {
this.$message({ this.$message({
type: 'success',
message: '删除成功!'
})
this.getTableData()
type: "success",
message: "删除成功!"
});
this.getTableData();
} }
}) })
.catch(() => { .catch(() => {
this.$message({ this.$message({
type: 'info',
message: '已取消删除'
})
})
type: "info",
message: "已取消删除"
});
});
}, },
// //
initForm() { initForm() {
if (this.$refs.authorityForm) { if (this.$refs.authorityForm) {
this.$refs.authorityForm.resetFields()
this.$refs.authorityForm.resetFields();
} }
this.form = { this.form = {
authorityId: '',
authorityName: '',
parentId: '0'
}
authorityId: "",
authorityName: "",
parentId: "0"
};
}, },
// //
closeDialog() { closeDialog() {
this.initForm()
this.dialogFormVisible = false
this.apiDialogFlag = false
this.initForm();
this.dialogFormVisible = false;
this.apiDialogFlag = false;
}, },
// //
async enterDialog() { async enterDialog() {
if (this.form.authorityId == '0') {
if (this.form.authorityId == "0") {
this.$message({ this.$message({
type: 'error',
message: '角色id不能为0'
})
return false
type: "error",
message: "角色id不能为0"
});
return false;
} }
this.$refs.authorityForm.validate(async valid => { this.$refs.authorityForm.validate(async valid => {
if (valid) { if (valid) {
switch (this.dialogType) { switch (this.dialogType) {
case 'add':
case "add":
{ {
const res = await createAuthority(this.form)
const res = await createAuthority(this.form);
if (res.code == 0) { if (res.code == 0) {
this.$message({ this.$message({
type: 'success',
message: '添加成功!'
})
this.getTableData()
this.closeDialog()
type: "success",
message: "添加成功!"
});
this.getTableData();
this.closeDialog();
} }
} }
break
case 'edit':
break;
case "edit":
{ {
const res = await updateAuthority(this.form)
const res = await updateAuthority(this.form);
if (res.code == 0) { if (res.code == 0) {
this.$message({ this.$message({
type: 'success',
message: '添加成功!'
})
this.getTableData()
this.closeDialog()
type: "success",
message: "添加成功!"
});
this.getTableData();
this.closeDialog();
} }
} }
break
case 'copy': {
break;
case "copy": {
const data = { const data = {
authority: { authority: {
authorityId: 'string',
authorityName: 'string',
authorityId: "string",
authorityName: "string",
datauthorityId: [], datauthorityId: [],
parentId: 'string'
parentId: "string"
}, },
oldAuthorityId: 0 oldAuthorityId: 0
}
data.authority.authorityId = this.form.authorityId
data.authority.authorityName = this.form.authorityName
data.authority.parentId = this.form.parentId
data.authority.dataAuthorityId = this.copyForm.dataAuthorityId
data.oldAuthorityId = this.copyForm.authorityId
const res = await copyAuthority(data)
};
data.authority.authorityId = this.form.authorityId;
data.authority.authorityName = this.form.authorityName;
data.authority.parentId = this.form.parentId;
data.authority.dataAuthorityId = this.copyForm.dataAuthorityId;
data.oldAuthorityId = this.copyForm.authorityId;
const res = await copyAuthority(data);
if (res.code == 0) { if (res.code == 0) {
this.$message({ this.$message({
type: 'success',
message: '复制成功!'
})
this.getTableData()
type: "success",
message: "复制成功!"
});
this.getTableData();
} }
} }
} }
this.initForm()
this.dialogFormVisible = false
this.initForm();
this.dialogFormVisible = false;
} }
})
});
}, },
setOptions() { setOptions() {
this.AuthorityOption = [ this.AuthorityOption = [
{ {
authorityId: '0',
authorityName: '根角色'
authorityId: "0",
authorityName: "根角色"
} }
]
this.setAuthorityOptions(this.tableData, this.AuthorityOption, false)
];
this.setAuthorityOptions(this.tableData, this.AuthorityOption, false);
}, },
setAuthorityOptions(AuthorityData, optionsData, disabled) { setAuthorityOptions(AuthorityData, optionsData, disabled) {
AuthorityData && AuthorityData &&
@ -298,52 +304,58 @@ export default {
authorityName: item.authorityName, authorityName: item.authorityName,
disabled: disabled || item.authorityId == this.form.authorityId, disabled: disabled || item.authorityId == this.form.authorityId,
children: [] children: []
}
};
this.setAuthorityOptions( this.setAuthorityOptions(
item.children, item.children,
option.children, option.children,
disabled || item.authorityId == this.form.authorityId disabled || item.authorityId == this.form.authorityId
)
optionsData.push(option)
);
optionsData.push(option);
} else { } else {
const option = { const option = {
authorityId: item.authorityId, authorityId: item.authorityId,
authorityName: item.authorityName, authorityName: item.authorityName,
disabled: disabled || item.authorityId == this.form.authorityId disabled: disabled || item.authorityId == this.form.authorityId
};
optionsData.push(option);
} }
optionsData.push(option)
}
})
});
}, },
// //
addAuthority(parentId) { addAuthority(parentId) {
this.initForm()
this.dialogTitle = '新增角色'
this.dialogType = 'add'
this.form.parentId = parentId
this.setOptions()
this.dialogFormVisible = true
this.initForm();
this.dialogTitle = "新增角色";
this.dialogType = "add";
this.form.parentId = parentId;
this.setOptions();
this.dialogFormVisible = true;
}, },
// //
editAuthority(row) { editAuthority(row) {
this.setOptions()
this.dialogTitle = '编辑角色'
this.dialogType = 'edit'
this.setOptions();
this.dialogTitle = "编辑角色";
this.dialogType = "edit";
for (let key in this.form) { for (let key in this.form) {
this.form[key] = row[key]
this.form[key] = row[key];
} }
this.setOptions()
this.dialogFormVisible = true
this.setOptions();
this.dialogFormVisible = true;
} }
}, },
async created() { async created() {
this.pageSize = 999
await this.getTableData()
this.pageSize = 999;
await this.getTableData();
} }
}
};
</script> </script>
<style lang="scss"> <style lang="scss">
.authority { .authority {
.el-input-number{
margin-left: 15px;
span{
display: none;
}
}
.button-box { .button-box {
padding: 10px 20px; padding: 10px 20px;
.el-button { .el-button {

Loading…
Cancel
Save