【新增】增加字典接口 增加字段校验
This commit is contained in:
@@ -60,8 +60,8 @@
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogUser" width="750px" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" modal-append-to-body append-to-body>
|
||||
<div class="user-form">
|
||||
<el-form :model="form" label-width="186px" :disabled="mode === 'view'">
|
||||
<el-form-item label="数据字典编码:" required>
|
||||
<el-form ref="dicRef" :rules="formRule" :model="form" label-width="186px" :disabled="mode === 'view'">
|
||||
<el-form-item label="数据字典编码:" prop="dicCode">
|
||||
<el-input v-model="form.dicCode" :disabled="mode === 'view' || mode === 'modify' " maxlength="20" show-word-limit placeholder="请输入数据字典编码"></el-input>
|
||||
</el-form-item>
|
||||
<!--<el-form-item label="密码:" :required="mode === 'add'" v-if="mode !== 'view'">-->
|
||||
@@ -70,12 +70,12 @@
|
||||
<!--<el-form-item label="确认密码:" :required="mode === 'add'" v-if="mode !== 'view'">-->
|
||||
<!--<el-input v-model="repassword" maxlength="20" type="password" placeholder="请确认密码"></el-input>-->
|
||||
<!--</el-form-item>-->
|
||||
<el-form-item label="数据字典名称:">
|
||||
<el-input v-model="form.dicName" placeholder="请输入数据字典名称"></el-input>
|
||||
<el-form-item label="数据字典名称:" prop="dicName">
|
||||
<el-input v-model="form.dicName" placeholder="请输入数据字典名称" maxlength="20" show-word-limit></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="描述:" required>
|
||||
<el-input v-model="form.description" maxlength="20" show-word-limit placeholder="请输入描述"></el-input>
|
||||
<el-form-item label="描述:" >
|
||||
<el-input type="textarea" v-model="form.description" maxlength="500" show-word-limit placeholder="请输入描述"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="done">
|
||||
@@ -107,6 +107,23 @@ export default {
|
||||
dicName:'',
|
||||
description:''
|
||||
},
|
||||
formRule:{
|
||||
dicCode:[
|
||||
{
|
||||
required:true,
|
||||
message:'数据字典编码不能为空',
|
||||
trigger:'change'
|
||||
}
|
||||
],
|
||||
dicName:[
|
||||
{
|
||||
required:true,
|
||||
message:'数据字典名称不能为空',
|
||||
trigger:'change'
|
||||
}
|
||||
],
|
||||
|
||||
},
|
||||
repassword: '',
|
||||
roleList: []
|
||||
}
|
||||
@@ -148,6 +165,7 @@ export default {
|
||||
},
|
||||
// 新增
|
||||
add () {
|
||||
|
||||
this.mode = 'add'
|
||||
this.form = {
|
||||
dicCode:'',
|
||||
@@ -156,6 +174,10 @@ export default {
|
||||
}
|
||||
this.repassword = ''
|
||||
this.dialogUser = true
|
||||
this.$nextTick(()=>{
|
||||
this.$refs.dicRef.clearValidate()
|
||||
|
||||
})
|
||||
},
|
||||
// // 启用/禁用
|
||||
// sysUserIsUse (val, row) {
|
||||
@@ -174,23 +196,30 @@ export default {
|
||||
// },
|
||||
// 删除
|
||||
deleteRow (row) {
|
||||
this.deleteUser([row.id])
|
||||
this.deleteUser(row.id)
|
||||
},
|
||||
// 新增用户
|
||||
sysUserAddUser () {
|
||||
if(this.mode=='add'){
|
||||
this.$api.dictionary.addDic(this.form).then((res)=>{
|
||||
this.$message.success("新增成功")
|
||||
this.sysUserList()
|
||||
})
|
||||
}else{
|
||||
this.$api.dictionary.editDic(this.form).then((res)=>{
|
||||
this.$message.success("编辑成功")
|
||||
this.sysUserList()
|
||||
})
|
||||
}
|
||||
this.$refs.dicRef.validate(v=>{
|
||||
if(v){
|
||||
if(this.mode=='add'){
|
||||
this.$api.dictionary.addDic(this.form).then((res)=>{
|
||||
this.$message.success("新增成功")
|
||||
this.sysUserList()
|
||||
})
|
||||
}else{
|
||||
this.$api.dictionary.editDic(this.form).then((res)=>{
|
||||
this.$message.success("编辑成功")
|
||||
this.sysUserList()
|
||||
})
|
||||
}
|
||||
|
||||
this.dialogUser = false
|
||||
}else{
|
||||
this.$message.warning("请检查表单")
|
||||
}
|
||||
})
|
||||
|
||||
this.dialogUser = false
|
||||
},
|
||||
// 编辑查看用户
|
||||
openRowData (mode, row) {
|
||||
@@ -200,7 +229,8 @@ export default {
|
||||
path:'/system/dicdeatil',
|
||||
query:{
|
||||
id:this.$route.query.id,
|
||||
pId:row.id
|
||||
pId:row.id,
|
||||
pName: row.dicName
|
||||
}
|
||||
})
|
||||
}else if(mode=='add'){
|
||||
@@ -224,7 +254,7 @@ export default {
|
||||
if (!users.length) {
|
||||
return this.$message.warning('请选择数据后在进行操作')
|
||||
}
|
||||
const ids = users.map(item => item.id)
|
||||
const ids = users.map(item => item.id).join(',')
|
||||
this.deleteUser(ids)
|
||||
},
|
||||
// 删除用户
|
||||
@@ -347,7 +377,7 @@ export default {
|
||||
padding-right: 79px;
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 10px;
|
||||
//margin-bottom: 10px;
|
||||
|
||||
.el-form-item__label {
|
||||
height: 36px;
|
||||
|
||||
Reference in New Issue
Block a user