Browse Source

完善用户管理模块表格数据组件

develop
余菲 2 years ago
parent
commit
6d3c05d9a0
3 changed files with 74 additions and 67 deletions
  1. +2
    -4
      src/components/ImgUpload/index.vue
  2. +3
    -63
      src/views/system/user/index.vue
  3. +69
    -0
      src/views/system/user/table.js

+ 2
- 4
src/components/ImgUpload/index.vue View File

点击上传 点击上传
</n-upload> </n-upload>
<n-modal <n-modal
v-model:show="showModal"
preset="card" preset="card"
style="width: 600px" style="width: 600px"
> >
} }
} }
}) })
function handleChange(file) {
console.log(222, file)
function handleChange(res) {
console.log('已选择的文件:', res.file.file)
} }
/** /**
* @description: 上传前判断文件是否符合条件 * @description: 上传前判断文件是否符合条件
*/ */
function handleBeforeUpload(options) { function handleBeforeUpload(options) {
const { file, fileList } = options const { file, fileList } = options
console.log(11, file, fileList)
if (props.size) { if (props.size) {
const size = file.file.size const size = file.file.size
if (size < props.size * 1024 * 1024) { if (size < props.size * 1024 * 1024) {

+ 3
- 63
src/views/system/user/index.vue View File

<script> <script>
import headSearch from '@/components/Search/index.vue' import headSearch from '@/components/Search/index.vue'
import dataTable from '@/components/DataTable/index.vue' import dataTable from '@/components/DataTable/index.vue'
import TableAction from '@/components/DataTable/tools/Action.vue'
import TableImage from '@/components/DataTable/tools/Image.vue'
import TableTags from '@/components/DataTable/tools/Tags.vue'
import TableSwitch from '@/components/DataTable/tools/Switch.vue' import TableSwitch from '@/components/DataTable/tools/Switch.vue'
import TableAction from '@/components/DataTable/tools/Action.vue'
import { getUserList, resetPassword, deleteUser, setUserStatus } from '@/api/system/user/index.js' import { getUserList, resetPassword, deleteUser, setUserStatus } from '@/api/system/user/index.js'
import { h, unref, ref, toRefs, reactive } from 'vue' import { h, unref, ref, toRefs, reactive } from 'vue'
import UserModal from './components/UserModal.vue' import UserModal from './components/UserModal.vue'
import info from './info.js' import info from './info.js'
import table from './table.js'
export default { export default {
name: 'MenuPage', name: 'MenuPage',
components: { dataTable, UserModal, headSearch }, components: { dataTable, UserModal, headSearch },
setup() { setup() {
const data = reactive({ const data = reactive({
columns: [ columns: [
{
type: 'selection'
},
{
title: '用户编号',
key: 'code',
align: 'center'
},
{
title: '头像',
key: 'avatar',
align: 'center',
render(row) {
return h(TableImage, {
images: {
width: 36,
height: 36,
src: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQiKrYt-fEfJ4SZhF9KfLLaX9f15KV6Ve1ptA&usqp=CAU'
}
})
}
},
{
title: '用户账号',
key: 'username',
align: 'center'
},
{
title: '用户姓名',
key: 'realname',
align: 'center'
},
{
title: '角色',
key: 'roleList',
align: 'center',
render(row) {
return h(TableTags, {
data: row.roleList,
rowKey: 'name'
})
}
},
...table.columns,
{ {
title: '状态', title: '状态',
key: 'status', key: 'status',
}) })
} }
}, },
{
title: '部门',
key: 'deptName',
align: 'center'
},
{
title: '创建时间',
key: 'createTime',
align: 'center',
width: 160
},
{
title: '更新时间',
key: 'updateTime',
align: 'center',
width: 160
},
{ {
title: '操作', title: '操作',
align: 'center', align: 'center',

+ 69
- 0
src/views/system/user/table.js View File

import { h } from 'vue'
import TableImage from '@/components/DataTable/tools/Image.vue'
import TableTags from '@/components/DataTable/tools/Tags.vue'

const table = {
columns: [
{
type: 'selection'
},
{
title: '用户编号',
key: 'code',
align: 'center'
},
{
title: '头像',
key: 'avatar',
align: 'center',
render(row) {
return h(TableImage, {
images: {
width: 36,
height: 36,
src: row.avatar
}
})
}
},
{
title: '用户账号',
key: 'username',
align: 'center'
},
{
title: '用户姓名',
key: 'realname',
align: 'center'
},
{
title: '角色',
key: 'roleList',
align: 'center',
render(row) {
return h(TableTags, {
data: row.roleList,
rowKey: 'name'
})
}
},
{
title: '部门',
key: 'deptName',
align: 'center'
},
{
title: '创建时间',
key: 'createTime',
align: 'center',
width: 160
},
{
title: '更新时间',
key: 'updateTime',
align: 'center',
width: 160
}
]
}
export default table

Loading…
Cancel
Save