Browse Source

feat: [操作日志] 用户日志

lkf
memorylkf 2 months ago
parent
commit
da97ae8a1c
5 changed files with 96 additions and 16 deletions
  1. +3
    -1
      src/lang/en/system/role.js
  2. +3
    -1
      src/lang/zh/system/role.js
  3. +4
    -0
      src/views/system/menu/index.vue
  4. +45
    -5
      src/views/system/role/index.vue
  5. +41
    -9
      src/views/system/user/index.vue

+ 3
- 1
src/lang/en/system/role.js View File

@ -20,5 +20,7 @@ export default {
filterPlaceholder: 'Name Or Mobile', filterPlaceholder: 'Name Or Mobile',
unauthorized: 'Uauthorized', unauthorized: 'Uauthorized',
authorized: 'Authorized'
authorized: 'Authorized',
fpjs: 'Role Change'
} }

+ 3
- 1
src/lang/zh/system/role.js View File

@ -20,5 +20,7 @@ export default {
filterPlaceholder: '姓名/手机号', filterPlaceholder: '姓名/手机号',
unauthorized: '未授权', unauthorized: '未授权',
authorized: '已授权'
authorized: '已授权',
fpjs: '分配角色'
} }

+ 4
- 0
src/views/system/menu/index.vue View File

@ -435,6 +435,8 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd(row) { handleAdd(row) {
debugger
// this.saveSimpleLog({name:'',nameEn:'',jcmc:'',jcmcEn:'Add Menu'})
this.reset() this.reset()
this.getTreeselect() this.getTreeselect()
if (row != null && row.menuId) { if (row != null && row.menuId) {
@ -455,6 +457,7 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
// this.saveSimpleLog({name:row.menuName,nameEn:row.menuName,jcmc:'',jcmcEn:'Edit Menu'})
this.reset() this.reset()
this.getTreeselect() this.getTreeselect()
getMenu(row.menuId).then(response => { getMenu(row.menuId).then(response => {
@ -485,6 +488,7 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
// this.saveSimpleLog({name:row.menuName,nameEn:row.menuName,jcmc:'',jcmcEn:'Remove Menu'})
this.$modal.confirm(this.$t('form.confirmDelete')).then(function() { this.$modal.confirm(this.$t('form.confirmDelete')).then(function() {
return delMenu(row.menuId) return delMenu(row.menuId)
}).then(() => { }).then(() => {

+ 45
- 5
src/views/system/role/index.vue View File

@ -307,16 +307,20 @@
<el-button @click="transferDialog.visible = false">{{$t('form.cancel')}}</el-button> <el-button @click="transferDialog.visible = false">{{$t('form.cancel')}}</el-button>
</div> </div>
</el-dialog> </el-dialog>
<Sign ref="signRef" @callback="doChangRoleUser" />
</div> </div>
</template> </template>
<script> <script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect,allocatedUserList,authUserSetAll } from "@/api/system/role" import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect,allocatedUserList,authUserSetAll } from "@/api/system/role"
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu" import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"
import Sign from '@/views/business/study/comp/sign.vue'
export default { export default {
name: "Role", name: "Role",
dicts: ['sys_normal_disable'], dicts: ['sys_normal_disable'],
components:{Sign},
data() { data() {
return { return {
// //
@ -407,7 +411,9 @@ export default {
list:[], list:[],
selected:[], selected:[],
roleId:''
roleId:'',
oldIdList:[]
} }
} }
@ -593,6 +599,9 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row,readonly) { handleUpdate(row,readonly) {
this.readonly = readonly this.readonly = readonly
if(readonly){
this.saveSimpleLog({name:row.roleName,nameEn:row.roleName,jcmc:'角色详情',jcmcEn:'Role Detail'})
}
this.reset() this.reset()
const roleId = row.roleId || this.ids const roleId = row.roleId || this.ids
const roleMenu = this.getRoleMenuTreeselect(roleId) const roleMenu = this.getRoleMenuTreeselect(roleId)
@ -642,19 +651,22 @@ export default {
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.$modal.loading()
if (this.form.roleId != undefined) { if (this.form.roleId != undefined) {
this.form.menuIds = this.getMenuAllCheckedKeys() this.form.menuIds = this.getMenuAllCheckedKeys()
updateRole(this.form).then(response => { updateRole(this.form).then(response => {
this.$modal.msgSuccess("修改成功")
this.open = false this.open = false
this.getList() this.getList()
}).finally(()=>{
this.$modal.closeLoading()
}) })
} else { } else {
this.form.menuIds = this.getMenuAllCheckedKeys() this.form.menuIds = this.getMenuAllCheckedKeys()
addRole(this.form).then(response => { addRole(this.form).then(response => {
this.$modal.msgSuccess("新增成功")
this.open = false this.open = false
this.getList() this.getList()
}).finally(()=>{
this.$modal.closeLoading()
}) })
} }
} }
@ -699,6 +711,8 @@ export default {
this.transferDialog.selected = response.selected this.transferDialog.selected = response.selected
this.transferDialog.list = list this.transferDialog.list = list
this.transferDialog.roleId = row.roleId this.transferDialog.roleId = row.roleId
this.transferDialog.oldIdList = _.cloneDeep(response.selected)
this.transferDialog.visible = true this.transferDialog.visible = true
} }
) )
@ -707,9 +721,35 @@ export default {
return item.label.indexOf(query) > -1; return item.label.indexOf(query) > -1;
}, },
changRoleUser(){ changRoleUser(){
authUserSetAll({ roleId: this.transferDialog.roleId, userIdList: this.transferDialog.selected && this.transferDialog.selected.length>0 ? this.transferDialog.selected:[] }).then(res => {
let update = false
let userIdList = this.transferDialog.selected && this.transferDialog.selected.length>0 ? this.transferDialog.selected:[]
if(this.transferDialog.oldIdList.length!==userIdList.length){
update = true
}else{
for(let i=0;i<this.transferDialog.oldIdList.length;i++){
if(_.findIndex(userIdList,o=>{return o===this.transferDialog.oldIdList[i]})==-1){
update = true
break
}
}
}
if(update){
this.$refs.signRef.show(
this.$t('page.system.role.fpjs'),
this.$t('page.system.role.fpjs'),
)
}else{
this.transferDialog.visible = false this.transferDialog.visible = false
})
}
},
doChangRoleUser(sign){
this.$modal.loading()
authUserSetAll({ roleId: this.transferDialog.roleId, userIdList: this.transferDialog.selected && this.transferDialog.selected.length>0 ? this.transferDialog.selected:[] ,sign:sign}).then(res => {
this.$refs.signRef.cancel()
this.transferDialog.visible = false
}).finally(()=>{
this.$modal.closeLoading()
})
} }
} }
} }

+ 41
- 9
src/views/system/user/index.vue View File

@ -114,7 +114,7 @@
<el-button <el-button
type="text" type="text"
@click="handleStatusChange(scope.row)"
@click="showRoleChange(scope.row)"
v-hasPermi="['system:user:edit']" v-hasPermi="['system:user:edit']"
>{{$t('page.system.user.history')}}</el-button> >{{$t('page.system.user.history')}}</el-button>
@ -259,6 +259,8 @@
<el-button @click="upload.open = false"> </el-button> <el-button @click="upload.open = false"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<Sign ref="signRef" @callback="doUpdate" />
</div> </div>
</template> </template>
@ -269,11 +271,12 @@ import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css" import "@riophae/vue-treeselect/dist/vue-treeselect.css"
import { Splitpanes, Pane } from "splitpanes" import { Splitpanes, Pane } from "splitpanes"
import "splitpanes/dist/splitpanes.css" import "splitpanes/dist/splitpanes.css"
import Sign from '@/views/business/study/comp/sign.vue'
export default { export default {
name: "User", name: "User",
dicts: ['sys_normal_disable', 'sys_user_sex'], dicts: ['sys_normal_disable', 'sys_user_sex'],
components: { Treeselect, Splitpanes, Pane },
components: { Treeselect, Splitpanes, Pane,Sign },
data() { data() {
return { return {
// //
@ -389,7 +392,8 @@ export default {
// trigger: "blur" // trigger: "blur"
// } // }
// ] // ]
}
},
oldRoleIdList:[],
} }
}, },
watch: { watch: {
@ -481,6 +485,7 @@ export default {
postIds: [], postIds: [],
roleIds: [] roleIds: []
} }
this.oldRoleIdList = []
this.resetForm("form") this.resetForm("form")
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -532,6 +537,7 @@ export default {
const userId = row.userId || this.ids const userId = row.userId || this.ids
getUser(userId).then(response => { getUser(userId).then(response => {
this.form = response.data this.form = response.data
this.oldRoleIdList = _.cloneDeep(response.roleIds)
this.postOptions = response.posts this.postOptions = response.posts
this.roleOptions = response.roles this.roleOptions = response.roles
this.$set(this.form, "postIds", response.postIds) this.$set(this.form, "postIds", response.postIds)
@ -570,14 +576,27 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.userId != undefined) { if (this.form.userId != undefined) {
updateUser(this.form).then(response => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
let updateRole = false;
if(this.oldRoleIdList.length!==this.form.roleIds.length){
updateRole = true
}else{
for(let i=0;i<this.oldRoleIdList.length;i++){
if(_.findIndex(this.form.roleIds,o=>{return o==this.oldRoleIdList[i]})==-1){
updateRole = true
break
}
}
}
if(updateRole){
this.$refs.signRef.show(
this.$t('page.system.role.fpjs'),
this.$t('page.system.role.fpjs'),
)
}else{
this.doUpdate({})
}
} else { } else {
addUser(this.form).then(response => { addUser(this.form).then(response => {
this.$modal.msgSuccess("新增成功")
this.open = false this.open = false
this.getList() this.getList()
}) })
@ -585,6 +604,16 @@ export default {
} }
}) })
}, },
doUpdate(sign){
this.$modal.loading()
updateUser({user:this.form,sign:sign}).then(response => {
this.$refs.signRef.cancel()
this.open = false
this.getList()
}).finally(()=>{
this.$modal.closeLoading()
})
},
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const userIds = row.userId || this.ids const userIds = row.userId || this.ids
@ -637,6 +666,9 @@ export default {
return _.map(row.roles,'roleName').join(',') return _.map(row.roles,'roleName').join(',')
} }
return '' return ''
},
showRoleChange(row){
this.saveSimpleLog({name:row.nickName,nameEn:row.nickName,jcmc:this.$t('page.system.user.history','zh_CN'),jcmcEn:this.$t('page.system.user.history','en_US')})
} }
} }
} }

Loading…
Cancel
Save