|
|
@@ -1,43 +1,59 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<n-card> |
|
|
|
<headSearch :info="data.info" @search="handleSearch" /> |
|
|
|
<data-table |
|
|
|
:columns="data.columns" |
|
|
|
:row-key="(row) => row.id" |
|
|
|
:request="loadDataTable" |
|
|
|
size="large" |
|
|
|
@update:checked-row-keys="handleCheck" |
|
|
|
> |
|
|
|
<template #tableTitle> |
|
|
|
<n-button type="primary" @click="handleUser"> 新建 </n-button> |
|
|
|
<n-popconfirm |
|
|
|
@positive-click="handlePositiveClick" |
|
|
|
@negative-click="handleNegativeClick" |
|
|
|
negative-text="取消" |
|
|
|
positive-text="确认" |
|
|
|
@positive-click="deleteUsers('plural')" |
|
|
|
> |
|
|
|
<n-button type="primary" @click="deleteUsers"> 删除 </n-button> |
|
|
|
<template #trigger> |
|
|
|
<n-button type="primary" @click="deleteUsers"> 删除 </n-button> |
|
|
|
</template> |
|
|
|
确认要批量删除吗? |
|
|
|
</n-popconfirm> |
|
|
|
</template> |
|
|
|
</data-table> |
|
|
|
</n-card> |
|
|
|
</div> |
|
|
|
<!-- 新增、编辑弹窗 --> |
|
|
|
<user-modal v-if="data.modalShow" v-model:visible="data.modalShow" :row="rowData" @done="loadDataTable" /> |
|
|
|
<user-modal |
|
|
|
v-if="data.modalShow" |
|
|
|
v-model:visible="data.modalShow" |
|
|
|
:row="rowData" |
|
|
|
@done="loadDataTable" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import headSearch from '@/components/Search/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 { getUserList } from '@/api/system/user/index.js' |
|
|
|
import { h, unref, toRefs } from 'vue' |
|
|
|
import { getUserList, deleteUser } from '@/api/system/user/index.js' |
|
|
|
import { h, unref, toRefs, ref } from 'vue' |
|
|
|
import { reactive } from 'vue' |
|
|
|
import UserModal from './components/UserModal.vue' |
|
|
|
import info from './info.js' |
|
|
|
export default { |
|
|
|
name: 'MenuPage', |
|
|
|
components: { dataTable, UserModal }, |
|
|
|
components: { dataTable, UserModal, headSearch }, |
|
|
|
setup() { |
|
|
|
const data = reactive({ |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
type: 'selection' |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '用户编号', |
|
|
|
key: 'code', |
|
|
@@ -69,21 +85,12 @@ export default { |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '角色', |
|
|
|
key: 'roles', |
|
|
|
key: 'roleList', |
|
|
|
align: 'center', |
|
|
|
render(row) { |
|
|
|
return h(TableTags, { |
|
|
|
data: row.roles, |
|
|
|
data: row.roleList, |
|
|
|
rowKey: 'name' |
|
|
|
// filters: [ |
|
|
|
// { |
|
|
|
// key: '管理员', |
|
|
|
// label: '123', |
|
|
|
// color: { |
|
|
|
// textColor: 'red' |
|
|
|
// } |
|
|
|
// } |
|
|
|
// ] |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
@@ -91,7 +98,22 @@ export default { |
|
|
|
title: '状态', |
|
|
|
key: 'status', |
|
|
|
align: 'center', |
|
|
|
width: 100 |
|
|
|
width: 100, |
|
|
|
render(row) { |
|
|
|
return h(TableTags, { |
|
|
|
data: row.status, |
|
|
|
filters: [ |
|
|
|
{ |
|
|
|
key: 1, |
|
|
|
label: '启用' |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: 2, |
|
|
|
label: '禁用' |
|
|
|
} |
|
|
|
] |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '部门', |
|
|
@@ -130,7 +152,12 @@ export default { |
|
|
|
{ |
|
|
|
label: '删除', |
|
|
|
type: 'popconfirm', |
|
|
|
auth: 'basic_list' |
|
|
|
auth: 'basic_list', |
|
|
|
props: { |
|
|
|
negativeText: '取消', |
|
|
|
positiveText: '确认', |
|
|
|
onPositiveClick: deleteSingle.bind(row) |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
align: 'center' |
|
|
@@ -138,21 +165,28 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
modalShow: false |
|
|
|
}) |
|
|
|
const modalData = reactive({ |
|
|
|
info: ref(info), |
|
|
|
modalShow: false, |
|
|
|
rowData: {} |
|
|
|
}) |
|
|
|
// 打开编辑弹窗 |
|
|
|
function play(row) { |
|
|
|
modalData.rowData = row |
|
|
|
data.rowData = row |
|
|
|
data.modalShow = true |
|
|
|
} |
|
|
|
|
|
|
|
const params = reactive({ |
|
|
|
const params = ref({ |
|
|
|
page: 1, |
|
|
|
limit: 10 |
|
|
|
}) |
|
|
|
const tableRef = ref() |
|
|
|
|
|
|
|
function handleSearch(data) { |
|
|
|
params.value = { |
|
|
|
...data |
|
|
|
} |
|
|
|
tableRef.value.reFetch({ ...unref(params) }) |
|
|
|
} |
|
|
|
|
|
|
|
const loadDataTable = async(res) => { |
|
|
|
const _params = { |
|
|
@@ -162,17 +196,42 @@ export default { |
|
|
|
return await getUserList(_params) |
|
|
|
} |
|
|
|
function handleUser() { |
|
|
|
modalData.rowData = {} |
|
|
|
data.rowData = {} |
|
|
|
data.modalShow = true |
|
|
|
} |
|
|
|
|
|
|
|
return { data, loadDataTable, handleUser, ...toRefs(modalData) } |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 批量删除用户 |
|
|
|
deleteUsers() { |
|
|
|
function deleteUsers(type) { |
|
|
|
console.log(type) |
|
|
|
// deleteUser({ data: [] }).then((res) => { |
|
|
|
// if (res.code === 0) { |
|
|
|
// $message.success(res.data.msg) |
|
|
|
// this.reload() |
|
|
|
// } else { |
|
|
|
// $message.error(res.data.msg) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
} |
|
|
|
function deleteSingle(type, row) { |
|
|
|
console.log(type, row, '++000+++') |
|
|
|
} |
|
|
|
|
|
|
|
const checkedRows = ref([]) |
|
|
|
function handleCheck(rowKeys) { |
|
|
|
checkedRows.value = rowKeys |
|
|
|
console.log(rowKeys) |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
data, |
|
|
|
loadDataTable, |
|
|
|
handleUser, |
|
|
|
...toRefs(data), |
|
|
|
handleSearch, |
|
|
|
deleteUsers, |
|
|
|
handleCheck |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
|
|
|
|
} |
|
|
|
} |