2021-04-12 13:00:59 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<nz-data-list
|
|
|
|
|
ref="dataList"
|
|
|
|
|
:api="url"
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
:from="fromRoute.user"
|
|
|
|
|
:layout="['searchInput', 'elementSet']"
|
2021-04-22 15:12:12 +08:00
|
|
|
:search-msg="searchMsg"
|
|
|
|
|
@search="search"
|
|
|
|
|
>
|
2021-04-12 13:00:59 +08:00
|
|
|
<template v-slot:top-tool-right>
|
2021-04-13 20:33:12 +08:00
|
|
|
<button id="account-add" v-has="'user_add'" :title="$t('overall.createUser')" class="top-tool-btn margin-r-10"
|
2021-04-12 13:00:59 +08:00
|
|
|
type="button" @click="add">
|
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
</button>
|
2021-04-13 20:33:12 +08:00
|
|
|
<delete-button id="account-list-batch-delete" v-has="'user_delete'" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button>
|
2021-04-12 13:00:59 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-slot="slotProps">
|
|
|
|
|
<user-table
|
|
|
|
|
ref="dataTable"
|
2021-05-18 19:18:14 +08:00
|
|
|
v-loading="tools.loading"
|
2021-04-12 13:00:59 +08:00
|
|
|
:api="url"
|
|
|
|
|
:custom-table-title="tools.customTableTitle"
|
|
|
|
|
:height="mainTableHeight"
|
|
|
|
|
:table-data="tableData"
|
|
|
|
|
@del="del"
|
|
|
|
|
@edit="edit"
|
|
|
|
|
@orderBy="tableDataSort"
|
|
|
|
|
@reload="getTableData"
|
2021-04-13 10:00:48 +08:00
|
|
|
@selectionChange="selectionChange"
|
2021-04-12 13:00:59 +08:00
|
|
|
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></user-table>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:pagination>
|
|
|
|
|
<Pagination ref="Pagination" :page-obj="pageObj" :table-id="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
|
|
|
|
|
</template>
|
|
|
|
|
</nz-data-list>
|
|
|
|
|
<transition name="right-box">
|
2021-04-22 17:43:13 +08:00
|
|
|
<user-box v-if="rightBox.show" :obj="object" @close="closeRightBox"></user-box>
|
2021-04-12 13:00:59 +08:00
|
|
|
</transition>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import deleteButton from '@/components/common/deleteButton'
|
2021-04-22 17:43:13 +08:00
|
|
|
import userBox from '@/components/common/rightBox/administration/userBox'
|
2021-04-12 13:00:59 +08:00
|
|
|
import nzDataList from '@/components/common/table/nzDataList'
|
|
|
|
|
import dataListMixin from '@/components/common/mixin/dataList'
|
|
|
|
|
import userTable from '@/components/common/table/settings/userTable'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'user',
|
|
|
|
|
components: {
|
|
|
|
|
nzDataList,
|
|
|
|
|
userBox,
|
|
|
|
|
deleteButton,
|
|
|
|
|
userTable
|
|
|
|
|
},
|
|
|
|
|
mixins: [dataListMixin],
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
url: 'sys/user',
|
|
|
|
|
blankObject: { // 空白对象
|
|
|
|
|
id: '',
|
|
|
|
|
name: '',
|
|
|
|
|
username: '',
|
|
|
|
|
email: '',
|
2021-05-12 17:45:48 +08:00
|
|
|
pin: '',
|
|
|
|
|
pinChange: '',
|
2021-04-12 13:00:59 +08:00
|
|
|
status: '1',
|
|
|
|
|
createTime: '',
|
|
|
|
|
receiver: [],
|
2021-05-12 17:45:48 +08:00
|
|
|
roleIds: '',
|
2021-04-12 13:00:59 +08:00
|
|
|
roles: [],
|
|
|
|
|
lang: '',
|
|
|
|
|
notifications: []
|
|
|
|
|
},
|
|
|
|
|
tableId: 'userTable',
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
id: 10,
|
|
|
|
|
name: this.$t('config.user.user'),
|
|
|
|
|
type: 'input',
|
2021-04-22 17:43:13 +08:00
|
|
|
label: 'name',
|
2021-04-12 13:00:59 +08:00
|
|
|
disabled: false
|
|
|
|
|
}]
|
2021-04-13 10:00:48 +08:00
|
|
|
}
|
2021-04-12 13:00:59 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
statusChange (user) {
|
|
|
|
|
if (user.roles) {
|
|
|
|
|
user.roleIds = user.roles.map(t => t.id)
|
|
|
|
|
}
|
|
|
|
|
this.$put('sys/user', user).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.rightBox.show = false
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
this.getTableData()
|
|
|
|
|
})
|
2021-05-12 17:45:48 +08:00
|
|
|
},
|
|
|
|
|
edit (u) {
|
|
|
|
|
this.$get(`${this.url}/${u.id}`).then(response => {
|
|
|
|
|
const user = response.user
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.object = {
|
|
|
|
|
id: user.id,
|
|
|
|
|
name: user.name,
|
|
|
|
|
username: user.username,
|
|
|
|
|
email: user.email,
|
|
|
|
|
status: user.status + '',
|
|
|
|
|
createAt: this.utcTimeToTimezoneStr(user.createAt),
|
|
|
|
|
receiver: user.receiver,
|
|
|
|
|
roleIds: Number(user.roles.map(item => item.id).join(',')),
|
|
|
|
|
roles: user.roles,
|
|
|
|
|
lang: user.lang,
|
|
|
|
|
notifications: user.notifications,
|
|
|
|
|
pin: '',
|
|
|
|
|
pinChange: ''
|
|
|
|
|
}
|
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-04-12 13:00:59 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
isCurrentUser () {
|
|
|
|
|
return function (username) {
|
|
|
|
|
return localStorage.getItem('nz-username') === username
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|