Browse Source

查询列表组件

master
陈薪名 11 months ago
parent
commit
101af1c4da
  1. 3
      src/components/SearchTable/index.ts
  2. 101
      src/components/SearchTable/src/SearchTable.vue

3
src/components/SearchTable/index.ts

@ -0,0 +1,3 @@
import SearchTable from './src/SearchTable.vue'
export { SearchTable }

101
src/components/SearchTable/src/SearchTable.vue

@ -0,0 +1,101 @@
<template>
<Dialog :title="dialogTitle" v-model="searchDialogVisible" style="height: 70%;width: 80%;">
<div class="searchHeardClass">
<!-- 搜索工作栏 -->
<Search :schema="searchSchema" @search="setSearchParamsRef" @reset="setSearchParamsRef" />
</div>
<div class="searchTableClass">
<Table
ref="searchTableRef"
:columns="tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:pagination="{
total: tableObjectRef.total
}"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
v-model:sort="tableObjectRef.sort"
:selection="true"
/>
</div>
<template #footer>
<div class="flex items-center">
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="searchDialogVisible = false"> </el-button>
</div>
</template>
</Dialog>
</template>
<script setup lang="ts">
// const { t } = useI18n() //
const message = useMessage() //
const searchDialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
/** 打开弹窗 */
const setSearchParamsRef = ref()
const tableObjectRef = ref()
const getPage:any = ref()
const searchSchema = ref()
const tableColumns = ref()
const open = (type: string, allSchemas: any,getApiPage: any ) => {
searchDialogVisible.value = true
console.log(45,allSchemas )
searchSchema.value = allSchemas.searchSchema
tableColumns.value = allSchemas.tableColumns
getPage.value = getApiPage
// dialogTitle.value = t('action.' + type)
dialogTitle.value = type
formType.value = type
const {tableObject, tableMethods } = useTable({
getListApi: getPage.value //
})
tableObjectRef.value = tableObject
//
const { getList, setSearchParams } = tableMethods
setSearchParamsRef.value = setSearchParams
getList()
}
defineExpose({ open }) // open
// Table ref
const searchTableRef = ref()
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
formLoading.value = true
const selections = searchTableRef.value.selections
if (selections.length > 1 || selections.length == 0) {
message.warning('请选择一条数据!')
return
}
try {
searchDialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
</script>
<style scoped lang="scss">
.searchDialogClass{
height: 60% !important;
width: 80% !important;
}
.searchHeardClass{
height: 200px;
}
.searchTableClass{
height: 300px;
overflow-y: auto;
}
</style>
Loading…
Cancel
Save