This commit is contained in:
2023-07-10 22:04:49 +08:00
parent df89d8df5c
commit c7841414db
12 changed files with 484 additions and 167 deletions

View File

@@ -64,6 +64,7 @@
:inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949"
@change="handleChangeStatus($event,scope.row.userId)"
>
</el-switch>
</template>
@@ -84,40 +85,45 @@
<el-dialog title="编辑" :visible.sync="dialogVisible" width="26%"
append-to-body
:close-on-click-modal="false"
:before-close="closeDialog"
>
<el-form ref="ruleForm" class="login_container" :model="form" status-icon label-width="70px">
<el-form-item label="ID" prop="username">
<el-input v-model="form.userId" placeholder='ID' clearable disabled></el-input>
</el-form-item>
<el-form-item label="用户名" prop="username">
<el-input v-model="form.userName" placeholder='用户名' clearable></el-input>
<el-input v-model="form.userName" placeholder='用户名' clearable :disabled="isEdit"></el-input>
</el-form-item>
<el-form-item label="密 码" prop="password">
<el-input type="password" v-model="form.userPassword"
:disabled="isEdit"
placeholder='请输入密码'
clearable></el-input>
</el-form-item>
<el-form-item label="项目数" prop="projectNum">
<el-input v-model="form.projectNum" placeholder='项目数量' clearable></el-input>
<el-input v-model="form.projectNum" placeholder='项目数量' clearable :disabled="isEdit"></el-input>
</el-form-item>
<el-form-item label="贡献值" prop="contributionValue">
<el-input v-model="form.contributionValue" placeholder='贡献值' clearable></el-input>
<el-input v-model="form.contributionValue" placeholder='贡献值' clearable :disabled="isEdit"></el-input>
</el-form-item>
<el-form-item label="等级" prop="userLevel">
<el-input v-model="form.userLevel" placeholder='用户等级' clearable></el-input>
<el-input v-model="form.userLevel" placeholder='用户等级' clearable :disabled="isEdit"></el-input>
</el-form-item>
<el-form-item label="搜索历史" prop="searchHistory">
<el-input v-model="form.searchHistory" placeholder='搜索历史' clearable></el-input>
<el-input v-model="form.searchHistory" placeholder='搜索历史' clearable :disabled="isEdit"></el-input>
</el-form-item>
<el-form-item label="头像" prop="userAvatar">
<el-input v-model="form.userAvatar" placeholder='头像' clearable></el-input>
<el-input v-model="form.userAvatar" placeholder='头像' clearable :disabled="isEdit"></el-input>
<template slot-scope="scope">
<img :src="'http://localhost:8082/helloGithub_war_exploded/retUserAv?username='+scope.row.username" />
</template>
</el-form-item>
<el-form-item label="是否有效" prop="isValid">
<el-radio-group v-model="form.isValid">
<el-radio-group v-model="form.isValid" :disabled="isEdit">
<el-radio :label="1">有效</el-radio>
<el-radio :label="0">无效</el-radio>
</el-radio-group>
@@ -125,8 +131,8 @@
<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('ruleForm')" type="primary" style=";margin-top:10px">保存</el-button>
</div>
</el-form-item>
</el-form>
@@ -145,6 +151,7 @@ export default {
data(){
return {
dataTable:[],
isEdit:true,
dialogVisible:false,
form:{
userId:'',
@@ -164,6 +171,89 @@ export default {
this.getAllUser();
},
methods:{
editForm(){
this.isEdit=false;
},
closeDialog() {
// 先重置
this.getAllUser();
// 后关闭
this.dialogVisible = false;
this.isEdit=true;
},
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_user',
// URL 中的查询参数
params: {
userId: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_user',
// URL 中的查询参数
params: {
userId: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(() => {})
}
},
getAllUser(){
var that=this;
axios({
@@ -212,6 +302,7 @@ export default {
});
} else {
_this.isEdit=true;
_this.dialogVisible = false;
_this.getAllUser();
Vue.prototype.$notify({