用户管理模块增删改查接口对接完成
This commit is contained in:
parent
ca23169f8b
commit
f13c7e862f
|
|
@ -39,9 +39,9 @@ export function editUser(data) {
|
||||||
* 删除用户
|
* 删除用户
|
||||||
* params
|
* params
|
||||||
*/
|
*/
|
||||||
export function deleteUser(id) {
|
export function deleteUser(idList) {
|
||||||
return request({
|
return request({
|
||||||
url: `/user/delete${[id]}`,
|
url: `/user/delete/${idList}`,
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export default {
|
||||||
/* 初始化搜索表单信息 */
|
/* 初始化搜索表单信息 */
|
||||||
function initForm() {
|
function initForm() {
|
||||||
data.info.forEach((item) => {
|
data.info.forEach((item) => {
|
||||||
form.value[item.key] = ''
|
form.value[item.key] = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<n-card>
|
<n-card>
|
||||||
<headSearch :info="data.info" @search="handleSearch" />
|
<headSearch :info="data.info" @search="handleSearch" />
|
||||||
<data-table
|
<data-table
|
||||||
|
ref="tableRef"
|
||||||
:columns="data.columns"
|
:columns="data.columns"
|
||||||
:row-key="(row) => row.id"
|
:row-key="(row) => row.id"
|
||||||
:request="loadDataTable"
|
:request="loadDataTable"
|
||||||
|
|
@ -17,9 +18,9 @@
|
||||||
@positive-click="deleteUsers('plural')"
|
@positive-click="deleteUsers('plural')"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<n-button type="primary" @click="deleteUsers"> 删除 </n-button>
|
<n-button type="primary"> 删除 </n-button>
|
||||||
</template>
|
</template>
|
||||||
确认要批量删除吗?
|
确认要删除选中数据吗?
|
||||||
</n-popconfirm>
|
</n-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
</data-table>
|
</data-table>
|
||||||
|
|
@ -30,7 +31,7 @@
|
||||||
v-if="data.modalShow"
|
v-if="data.modalShow"
|
||||||
v-model:visible="data.modalShow"
|
v-model:visible="data.modalShow"
|
||||||
:row="rowData"
|
:row="rowData"
|
||||||
@done="loadDataTable"
|
@done="handleSearch"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -156,7 +157,7 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
negativeText: '取消',
|
negativeText: '取消',
|
||||||
positiveText: '确认',
|
positiveText: '确认',
|
||||||
onPositiveClick: deleteSingle.bind(row)
|
onPositiveClick: deleteSingle.bind(null, row.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -175,10 +176,8 @@ export default {
|
||||||
data.modalShow = true
|
data.modalShow = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = ref({
|
const params = ref({})
|
||||||
page: 1,
|
|
||||||
limit: 10
|
|
||||||
})
|
|
||||||
const tableRef = ref()
|
const tableRef = ref()
|
||||||
|
|
||||||
function handleSearch(data) {
|
function handleSearch(data) {
|
||||||
|
|
@ -195,30 +194,43 @@ export default {
|
||||||
}
|
}
|
||||||
return await getUserList(_params)
|
return await getUserList(_params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增用户
|
||||||
function handleUser() {
|
function handleUser() {
|
||||||
data.rowData = {}
|
data.rowData = {}
|
||||||
data.modalShow = true
|
data.modalShow = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteUsers(type) {
|
// 选择表格数据
|
||||||
console.log(type)
|
const selectedIds = ref([])
|
||||||
// deleteUser({ data: [] }).then((res) => {
|
function handleCheck(rowKeys) {
|
||||||
// if (res.code === 0) {
|
selectedIds.value = rowKeys
|
||||||
// $message.success(res.data.msg)
|
|
||||||
// this.reload()
|
|
||||||
// } else {
|
|
||||||
// $message.error(res.data.msg)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
function deleteSingle(type, row) {
|
// 批量删除用户
|
||||||
console.log(type, row, '++000+++')
|
function deleteUsers() {
|
||||||
|
if (selectedIds.value.length) {
|
||||||
|
deleteData(selectedIds.value)
|
||||||
|
} else {
|
||||||
|
$message.warning('请至少选中一条数据')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 单个删除数据
|
||||||
|
function deleteSingle(id) {
|
||||||
|
deleteData([id])
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkedRows = ref([])
|
// 删除用户接口
|
||||||
function handleCheck(rowKeys) {
|
function deleteData(data) {
|
||||||
checkedRows.value = rowKeys
|
deleteUser(data).then((res) => {
|
||||||
console.log(rowKeys)
|
if (res.code === 0) {
|
||||||
|
handleSearch()
|
||||||
|
$message.success(res.data.msg)
|
||||||
|
} else {
|
||||||
|
$message.error(res.data.msg)
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -226,9 +238,12 @@ export default {
|
||||||
loadDataTable,
|
loadDataTable,
|
||||||
handleUser,
|
handleUser,
|
||||||
...toRefs(data),
|
...toRefs(data),
|
||||||
|
tableRef,
|
||||||
handleSearch,
|
handleSearch,
|
||||||
deleteUsers,
|
deleteUsers,
|
||||||
handleCheck
|
handleCheck,
|
||||||
|
selectedIds,
|
||||||
|
deleteData
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,25 @@
|
||||||
import { getRoleAll } from '@/api/system/role/index'
|
import { getRoleAll } from '@/api/system/role/index'
|
||||||
import { dataToSelect } from '@/utils/handleData.js'
|
import { dataToSelect } from '@/utils/handleData.js'
|
||||||
const res = await getRoleAll()
|
import { ref } from 'vue'
|
||||||
const rolesOptions = dataToSelect(res.data, { label: 'name', value: 'id' })
|
const rolesOptions = ref([])
|
||||||
|
async function getRolesOption() {
|
||||||
|
const res = await getRoleAll()
|
||||||
|
rolesOptions.value = dataToSelect(res.data, { label: 'name', value: 'id' })
|
||||||
|
}
|
||||||
|
getRolesOption()
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
label: '用户姓名',
|
label: '用户账号',
|
||||||
key: 'realname',
|
key: 'username',
|
||||||
props: {
|
props: {
|
||||||
placeholder: '请输入角色名称'
|
placeholder: '请输入用户账号'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '用户姓名',
|
label: '用户姓名',
|
||||||
key: 'realname',
|
key: 'realname',
|
||||||
props: {
|
props: {
|
||||||
placeholder: '请输入角色名称'
|
placeholder: '请输入用户姓名'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +27,7 @@ const data = [
|
||||||
type: 'select',
|
type: 'select',
|
||||||
key: 'roleId',
|
key: 'roleId',
|
||||||
props: {
|
props: {
|
||||||
|
placeholder: '请选择用户角色',
|
||||||
options: rolesOptions
|
options: rolesOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue