|
|
@@ -3,6 +3,7 @@ |
|
|
|
<n-card> |
|
|
|
<headSearch :info="data.info" @search="handleSearch" /> |
|
|
|
<data-table |
|
|
|
ref="tableRef" |
|
|
|
:columns="data.columns" |
|
|
|
:row-key="(row) => row.id" |
|
|
|
:request="loadDataTable" |
|
|
@@ -17,9 +18,9 @@ |
|
|
|
@positive-click="deleteUsers('plural')" |
|
|
|
> |
|
|
|
<template #trigger> |
|
|
|
<n-button type="primary" @click="deleteUsers"> 删除 </n-button> |
|
|
|
<n-button type="primary"> 删除 </n-button> |
|
|
|
</template> |
|
|
|
确认要批量删除吗? |
|
|
|
确认要删除选中数据吗? |
|
|
|
</n-popconfirm> |
|
|
|
</template> |
|
|
|
</data-table> |
|
|
@@ -30,7 +31,7 @@ |
|
|
|
v-if="data.modalShow" |
|
|
|
v-model:visible="data.modalShow" |
|
|
|
:row="rowData" |
|
|
|
@done="loadDataTable" |
|
|
|
@done="handleSearch" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
|
|
|
@@ -156,7 +157,7 @@ export default { |
|
|
|
props: { |
|
|
|
negativeText: '取消', |
|
|
|
positiveText: '确认', |
|
|
|
onPositiveClick: deleteSingle.bind(row) |
|
|
|
onPositiveClick: deleteSingle.bind(null, row.id) |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
@@ -175,10 +176,8 @@ export default { |
|
|
|
data.modalShow = true |
|
|
|
} |
|
|
|
|
|
|
|
const params = ref({ |
|
|
|
page: 1, |
|
|
|
limit: 10 |
|
|
|
}) |
|
|
|
const params = ref({}) |
|
|
|
|
|
|
|
const tableRef = ref() |
|
|
|
|
|
|
|
function handleSearch(data) { |
|
|
@@ -195,30 +194,43 @@ export default { |
|
|
|
} |
|
|
|
return await getUserList(_params) |
|
|
|
} |
|
|
|
|
|
|
|
// 新增用户 |
|
|
|
function handleUser() { |
|
|
|
data.rowData = {} |
|
|
|
data.modalShow = true |
|
|
|
} |
|
|
|
|
|
|
|
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) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// 选择表格数据 |
|
|
|
const selectedIds = ref([]) |
|
|
|
function handleCheck(rowKeys) { |
|
|
|
selectedIds.value = rowKeys |
|
|
|
} |
|
|
|
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) { |
|
|
|
checkedRows.value = rowKeys |
|
|
|
console.log(rowKeys) |
|
|
|
// 删除用户接口 |
|
|
|
function deleteData(data) { |
|
|
|
deleteUser(data).then((res) => { |
|
|
|
if (res.code === 0) { |
|
|
|
handleSearch() |
|
|
|
$message.success(res.data.msg) |
|
|
|
} else { |
|
|
|
$message.error(res.data.msg) |
|
|
|
} |
|
|
|
}).catch(e => { |
|
|
|
console.log(e) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
@@ -226,9 +238,12 @@ export default { |
|
|
|
loadDataTable, |
|
|
|
handleUser, |
|
|
|
...toRefs(data), |
|
|
|
tableRef, |
|
|
|
handleSearch, |
|
|
|
deleteUsers, |
|
|
|
handleCheck |
|
|
|
handleCheck, |
|
|
|
selectedIds, |
|
|
|
deleteData |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |