优化
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
@change="handleChangeStatus($event,scope.row.adminId)"
|
||||
>
|
||||
</el-switch>
|
||||
</template>
|
||||
@@ -63,20 +64,33 @@
|
||||
:before-close="closeDialog"
|
||||
>
|
||||
<el-form ref="ruleForm" class="login_container" :model="form" status-icon :rules="rules" label-width="70px">
|
||||
<el-form-item label="adminID">
|
||||
<el-input v-model="form.adminId" placeholder='ID' clearable disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="账 户" prop="username">
|
||||
<el-input v-model="form.adminName" placeholder='请输入用户名' clearable></el-input>
|
||||
<el-input v-model="form.adminName" placeholder='请输入用户名' :disabled="isEdit"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="密 码" prop="password">
|
||||
<el-input type="password" v-model="form.adminPassword"
|
||||
:disabled="isEdit"
|
||||
placeholder='请输入密码'
|
||||
clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="登录时间">
|
||||
<el-input v-model="form.loginTime" placeholder='登录时间' clearable disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否有效">
|
||||
<el-radio-group v-model="form.isValid" :disabled="isEdit">
|
||||
<el-radio :label="1">有效</el-radio>
|
||||
<el-radio :label="0">无效</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<div style="display: flex;flex-direction: row;align-items: center;flex-wrap: nowrap;justify-content: space-between">
|
||||
<el-button @click="resetForm('ruleForm')">重置</el-button>
|
||||
<el-button @click="submit('ruleForm')" type="primary" style=";margin-top:10px">提交</el-button>
|
||||
<el-button @click="editForm()">编辑</el-button>
|
||||
<el-button @click="submit()" type="primary" style=";margin-top:10px">保存</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -94,13 +108,17 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
modalType: 0,
|
||||
isEdit:true,
|
||||
dialogVisible:false,
|
||||
dataTable:null,
|
||||
imageUrl: "http://localhost:8082/helloGithub_war_exploded/VerifycodeServlet?" + new Date().getDate(),
|
||||
// 登陆数据
|
||||
form: {
|
||||
adminId:'',
|
||||
adminName: '',
|
||||
adminPassword: '',
|
||||
isValid:'',
|
||||
loginTime:'',
|
||||
},
|
||||
// 校验规则
|
||||
rules: {
|
||||
@@ -114,6 +132,79 @@ export default {
|
||||
this.getAllAdmin();
|
||||
},
|
||||
methods: {
|
||||
handleChangeStatus($event, id){
|
||||
if ($event === 1) { // 这里判断一下
|
||||
// 启用
|
||||
this.$confirm('确认启用吗?', '操作确认', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(async () => {
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: 'http://localhost:8082/helloGithub_war_exploded/updateisValid_admin',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
adminId:id,
|
||||
isValid:$event
|
||||
}
|
||||
}).then(function (res) {
|
||||
if (res.data.code === 200) {
|
||||
Vue.prototype.$notify({
|
||||
title: '成功',
|
||||
message: ('i', {style: 'color: teal'}, res.data.msg),
|
||||
type: 'success',
|
||||
offset: 50
|
||||
});
|
||||
} else {
|
||||
Vue.prototype.$notify.error({
|
||||
title: '错误',
|
||||
message: res.data.msg,
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
} else {
|
||||
// 禁用
|
||||
this.$confirm('确认禁用吗?', '操作确认', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(async () => {
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: 'http://localhost:8082/helloGithub_war_exploded/updateisValid_admin',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
adminId:id,
|
||||
isValid:$event
|
||||
}
|
||||
}).then(function (res) {
|
||||
if (res.data.code === 200) {
|
||||
Vue.prototype.$notify({
|
||||
title: '成功',
|
||||
message: ('i', {style: 'color: teal'}, res.data.msg),
|
||||
type: 'success',
|
||||
offset: 50
|
||||
});
|
||||
} else {
|
||||
Vue.prototype.$notify.error({
|
||||
title: '错误',
|
||||
message: res.data.msg,
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
},
|
||||
getAllAdmin(){
|
||||
var that=this;
|
||||
axios({
|
||||
@@ -127,76 +218,17 @@ export default {
|
||||
that.dataTable=res.data;
|
||||
})
|
||||
},
|
||||
submit(formName){
|
||||
submit(){
|
||||
var _this=this;
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
//调用方法提交
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: 'http://localhost:8082/helloGithub_war_exploded/adminRegister',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
adminname: this.login.username,
|
||||
password: this.login.password,
|
||||
}
|
||||
}).then(function (res) {
|
||||
if (res.data.code === 200) {
|
||||
Vue.prototype.$notify({
|
||||
title: '成功',
|
||||
message: ('i', {style: 'color: teal'}, res.data.msg),
|
||||
type: 'success',
|
||||
offset: 50
|
||||
});
|
||||
_this.dialogVisible=false;
|
||||
_this.getAllAdmin();
|
||||
} else {
|
||||
Vue.prototype.$notify.error({
|
||||
title: '错误',
|
||||
message: res.data.msg,
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
resetImg() {
|
||||
this.imageUrl = "http://localhost:8082/helloGithub_war_exploded/VerifycodeServlet?" + new Date().getTime();
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
},
|
||||
addAdmin(){
|
||||
this.dialogVisible=true;
|
||||
},
|
||||
handleEdit(index) {
|
||||
console.log(index);
|
||||
this.modalType = 1;
|
||||
|
||||
this.addAdmin();
|
||||
// 深拷贝
|
||||
this.form = index;
|
||||
|
||||
},
|
||||
// 删除按钮
|
||||
handleDelete(index) {
|
||||
this.$confirm('此操作将永久删除该用户, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
if(this.form.adminName!==''|| this.form.adminPassword!==''){
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: 'http://localhost:8082/helloGithub_war_exploded/adminRegister',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
id: index.id,
|
||||
adminname: this.form.adminName,
|
||||
password: this.form.adminPassword,
|
||||
}
|
||||
}).then(function (res) {
|
||||
if (res.data.code === 200) {
|
||||
@@ -206,7 +238,9 @@ export default {
|
||||
type: 'success',
|
||||
offset: 50
|
||||
});
|
||||
|
||||
_this.isEdit=true;
|
||||
_this.dialogVisible=false;
|
||||
_this.getAllAdmin();
|
||||
} else {
|
||||
Vue.prototype.$notify.error({
|
||||
title: '错误',
|
||||
@@ -214,6 +248,66 @@ export default {
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
});
|
||||
}else {
|
||||
Vue.prototype.$notify.error({
|
||||
title: '提示',
|
||||
message: '请填写相关信息',
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
resetImg() {
|
||||
this.imageUrl = "http://localhost:8082/helloGithub_war_exploded/VerifycodeServlet?" + new Date().getTime();
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
},
|
||||
addAdmin(){
|
||||
this.modalType=0;
|
||||
this.dialogVisible=true;
|
||||
},
|
||||
handleEdit(index) {
|
||||
this.modalType = 1;
|
||||
|
||||
this.dialogVisible=true;
|
||||
// 深拷贝
|
||||
this.form = index;
|
||||
|
||||
},
|
||||
// 删除按钮
|
||||
handleDelete(index) {
|
||||
var that=this;
|
||||
this.$confirm('此操作将永久删除该用户, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: 'http://localhost:8082/helloGithub_war_exploded/deleteAdmin',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
adminId: index.adminId,
|
||||
}
|
||||
}).then(function (res) {
|
||||
if (res.data.code === 500) {
|
||||
Vue.prototype.$notify.error({
|
||||
title: '错误',
|
||||
message: res.data.msg,
|
||||
offset: 50
|
||||
});
|
||||
} else {
|
||||
Vue.prototype.$notify({
|
||||
title: '成功',
|
||||
message: ('i', {style: 'color: teal'}, res.data.msg),
|
||||
type: 'success',
|
||||
offset: 50
|
||||
});
|
||||
that.getAllAdmin();
|
||||
}
|
||||
|
||||
});
|
||||
}).catch(() => {
|
||||
@@ -226,9 +320,13 @@ export default {
|
||||
},
|
||||
closeDialog() {
|
||||
// 先重置
|
||||
this.form={}
|
||||
this.getAllAdmin();
|
||||
// 后关闭
|
||||
this.dialogVisible = false
|
||||
this.dialogVisible = false;
|
||||
this.isEdit=true;
|
||||
},
|
||||
editForm(){
|
||||
this.isEdit=false;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user