User enable/disable

This commit is contained in:
shiziyuan9527 2020-02-12 19:16:00 +08:00
parent baeea268f7
commit a3de4322ff
3 changed files with 33 additions and 10 deletions

View File

@ -22,7 +22,7 @@ public class OrganizationService {
organization.setCreateTime(currentTimeMillis);
organization.setUpdateTime(currentTimeMillis);
organizationMapper.insertSelective(organization);
return organization;
return organization;
}
public List<Organization> getOrganizationList() {

View File

@ -49,7 +49,8 @@ public class UserService {
BeanUtils.copyProperties(userRequest, user);
user.setCreateTime(System.currentTimeMillis());
user.setUpdateTime(System.currentTimeMillis());
user.setStatus("0");
// 默认1:启用状态
user.setStatus("1");
UserExample userExample = new UserExample();
UserExample.Criteria criteria = userExample.createCriteria();

View File

@ -15,8 +15,18 @@
<el-table-column prop="name" label="用户名"/>
<el-table-column prop="email" label="邮箱"/>
<el-table-column prop="phone" label="电话"/>
<el-table-column prop="status" label="状态"/>
<el-table-column prop="createTime" label="创建时间"/>
<el-table-column prop="status" label="启用/禁用">
<template slot-scope="scope">
<el-switch v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-value="1"
inactive-value="0"
@change="changeSwitch(scope.row)"
/>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" :formatter="formatDate"/>
<el-table-column>
<template slot-scope="scope">
<el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
@ -41,9 +51,6 @@
<el-form-item label="电话" prop="phone">
<el-input v-model="form.phone" autocomplete="off"/>
</el-form-item>
<el-form-item label="启用">
<el-switch v-model="form.enable"/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="createUser('createUserForm')" size="medium">创建</el-button>
@ -64,9 +71,6 @@
<el-form-item label="电话" prop="phone">
<el-input v-model="form.phone" autocomplete="off"/>
</el-form-item>
<el-form-item label="启用">
<el-switch v-model="form.enable"/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="updateUser('updateUserForm')" size="medium">修改</el-button>
@ -170,6 +174,24 @@
},
closeFunc() {
this.form = {};
},
changeSwitch(row) {
this.$post('/user/update', row).then(() =>{
this.$message({
type: 'success',
message: '状态修改成功!'
});
})
},
formatDate(row) {
let date = new Date(parseInt(row.createTime));
let Y = date.getFullYear() + '-';
let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
// let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
// let m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
// let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
return Y + M + D;
}
},
data() {