Files
midi-admin/src/views/message/selectUser.vue

55 lines
1.7 KiB
Vue
Raw Normal View History

2025-08-11 11:40:20 +08:00
<script setup lang="ts">
import { ref, onMounted } from "vue";
2025-09-27 15:38:32 +08:00
import SearchForm from "@/components/SearchForm/index.vue";
2025-08-11 11:40:20 +08:00
import { getUserList } from '@/api/modules/message'
const selectUserList = ref([]);
const userList = ref([])
function getRef() {
return selectUserList.value;
}
2025-09-27 15:38:32 +08:00
const searchLabel = ref([
2025-09-27 16:18:50 +08:00
{ label: "用户ID", prop: "user_code", type: "input" }
2025-09-27 15:38:32 +08:00
]);
const searchForm = ref({})
2025-08-11 11:40:20 +08:00
const multipleTable = ref(null)
2025-09-27 15:38:32 +08:00
const onSearch = (formData) => {
2025-09-27 16:18:50 +08:00
userList.value = []
selectUserList.value = []
getAllUserList(formData)
2025-09-27 15:38:32 +08:00
}
2025-08-11 11:40:20 +08:00
const props = defineProps(["userList"]);
2025-09-27 16:18:50 +08:00
const getAllUserList = async (form) => {
const { code, data } = await getUserList({ ...form })
2025-08-11 11:40:20 +08:00
userList.value = code ? data : []
setTimeout(() => {
if (userList.value.length) {
userList.value.forEach(ele => {
const listData = props.userList.map(e => { return Number(e) })
if (listData.includes(ele.id)) {
multipleTable.value.toggleRowSelection(ele, true)
}
})
}
}, 500)
}
function handleSelectionChange(val) {
selectUserList.value = val
}
onMounted(() => {
2025-09-27 16:18:50 +08:00
getAllUserList(searchForm.value)
2025-08-11 11:40:20 +08:00
})
defineExpose({ getRef });
</script>
<template>
<div style="margin-bottom: 20px;">
2025-09-27 15:38:32 +08:00
<SearchForm class="pb-2" :LabelList="searchLabel" :formData="searchForm" @handleSearch="onSearch"></SearchForm>
2025-08-11 11:40:20 +08:00
<el-table ref="multipleTable" :data="userList" row-key="id" border style="width: 100%" max-height="550"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55">
</el-table-column>
<el-table-column prop="nickname" label="用户名">
</el-table-column>
</el-table>
</div>
</template>