From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/components/Table/src/TableSelectForm.vue | 92 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/src/components/Table/src/TableSelectForm.vue b/src/components/Table/src/TableSelectForm.vue
new file mode 100644
index 0000000..5378a1b
--- /dev/null
+++ b/src/components/Table/src/TableSelectForm.vue
@@ -0,0 +1,92 @@
+<!-- 鍒楄〃閫夋嫨閫氱敤缁勪欢锛屽弬鑰� ProductList 缁勪欢浣跨敤 -->
+<!-- TODO 鑺嬭壙锛氬彲鑳戒細绉婚櫎 -->
+<template>
+ <Dialog v-model="dialogVisible" :appendToBody="true" :scroll="true" :title="title" width="60%">
+ <el-table
+ ref="multipleTableRef"
+ v-loading="loading"
+ :data="list"
+ :show-overflow-tooltip="true"
+ :stripe="true"
+ @selection-change="handleSelectionChange"
+ >
+ <el-table-column type="selection" width="55" />
+ <slot></slot>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ v-model:limit="queryParams.pageSize"
+ v-model:page="queryParams.pageNo"
+ :total="total"
+ @pagination="getList"
+ />
+ <template #footer>
+ <el-button :disabled="formLoading" type="primary" @click="submitForm">纭� 瀹�</el-button>
+ <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+ </template>
+ </Dialog>
+</template>
+
+<script lang="ts" setup>
+import { ElTable } from 'element-plus'
+
+defineOptions({ name: 'TableSelectForm' })
+withDefaults(
+ defineProps<{
+ modelValue: any[]
+ title: string
+ }>(),
+ { modelValue: () => [], title: '閫夋嫨' }
+)
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const loading = ref(false) // 鍒楄〃鐨勫姞杞戒腑
+const dialogVisible = ref(false) // 寮圭獥鐨勬槸鍚﹀睍绀�
+const formLoading = ref(false)
+const queryParams = reactive({
+ pageNo: 1,
+ pageSize: 10
+})
+// 纭閫夋嫨鏃剁殑瑙﹀彂浜嬩欢
+const emits = defineEmits<{
+ (e: 'update:modelValue', v: number[]): void
+}>()
+const multipleTableRef = ref<InstanceType<typeof ElTable>>()
+const multipleSelection = ref<any[]>([])
+const handleSelectionChange = (val: any[]) => {
+ multipleSelection.value = val
+}
+/** 瑙﹀彂 */
+const submitForm = () => {
+ formLoading.value = true
+ try {
+ emits('update:modelValue', multipleSelection.value) // 杩斿洖閫夋嫨鐨勫師濮嬫暟鎹敱浣跨敤鏂瑰鐞�
+ } finally {
+ formLoading.value = false
+ // 鍏抽棴寮圭獥
+ dialogVisible.value = false
+ }
+}
+
+const getList = async (getListFunc: Function) => {
+ loading.value = true
+ try {
+ const data = await getListFunc(queryParams)
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎵撳紑寮圭獥 */
+const open = async (getListFunc: Function) => {
+ dialogVisible.value = true
+ await nextTick()
+ if (multipleSelection.value.length > 0) {
+ multipleTableRef.value!.clearSelection()
+ }
+ await getList(getListFunc)
+}
+defineExpose({ open }) // 鎻愪緵 open 鏂规硶锛岀敤浜庢墦寮�寮圭獥
+</script>
--
Gitblit v1.8.0