|
|
@@ -4,7 +4,7 @@
|
|
|
<a-row justify="end">
|
|
|
<a-col>
|
|
|
<a-space>
|
|
|
- <a-button type="primary" >
|
|
|
+ <a-button type="primary" @click="openModel('add')" >
|
|
|
新增
|
|
|
<template #icon>
|
|
|
<plus-outlined />
|
|
|
@@ -19,10 +19,10 @@
|
|
|
<!-- 小组件 -->
|
|
|
|
|
|
<a-tooltip>
|
|
|
- <template #title>刷新</template>
|
|
|
- <reload-outlined />
|
|
|
+ <template #title >刷新</template>
|
|
|
+ <reload-outlined v-if="!state.loading" @click="reload"/>
|
|
|
+ <loading-outlined v-else />
|
|
|
</a-tooltip>
|
|
|
- <!-- -->
|
|
|
</a-space>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
@@ -59,11 +59,13 @@
|
|
|
</a-row>
|
|
|
|
|
|
<!-- 弹窗 -->
|
|
|
- <model-pro
|
|
|
+ <modal-pro
|
|
|
+ :label="props.modalTitle"
|
|
|
:visible="state.modelVisible"
|
|
|
+ @cancel="closeModel"
|
|
|
>
|
|
|
|
|
|
- </model-pro>
|
|
|
+ </modal-pro>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup >
|
|
|
@@ -71,7 +73,7 @@ import { useCopy } from '@/hooks/dom'
|
|
|
import { ColumnsType } from 'ant-design-vue/lib/vc-table/interface'
|
|
|
import { TableProps } from 'ant-design-vue/lib/vc-table/Table'
|
|
|
import { reactive, watch } from 'vue'
|
|
|
-import { PlusOutlined, DownloadOutlined, ReloadOutlined } from '@ant-design/icons-vue'
|
|
|
+import { PlusOutlined, DownloadOutlined, ReloadOutlined, LoadingOutlined } from '@ant-design/icons-vue'
|
|
|
/**
|
|
|
* formItemProps
|
|
|
* rules 校验
|
|
|
@@ -95,7 +97,8 @@ export interface TablePropPorps extends TableProps {
|
|
|
request: (params: any) => any
|
|
|
del: (id: string) => void
|
|
|
params: any,
|
|
|
- columns: ColumnsType & {children: ColumnsChildren}
|
|
|
+ columns: ColumnsType & {children: ColumnsChildren},
|
|
|
+ modalTitle: string
|
|
|
}
|
|
|
|
|
|
const props = defineProps<TablePropPorps>()
|
|
|
@@ -108,7 +111,8 @@ const state = reactive({
|
|
|
total: 0,
|
|
|
pageSize: 10
|
|
|
},
|
|
|
- modelVisible: false
|
|
|
+ modelVisible: false,
|
|
|
+ opraState: 'add'
|
|
|
})
|
|
|
|
|
|
const handleTableChange = (pag: { pageSize: number; current: number }) => {
|
|
|
@@ -140,6 +144,18 @@ const handleAction = (column: ColumnsChildren, record: any) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// `const reload = () => request()` 正在定义一个名为 `reload` 的函数,该函数调用 `request` 函数。该函数用于在用户点击“刷新”按钮时重新加载表格数据。
|
|
|
+const reload = () => request()
|
|
|
+
|
|
|
+const openModel = (type: 'add' | 'update') => {
|
|
|
+ state.modelVisible = true
|
|
|
+ state.opraState = type
|
|
|
+}
|
|
|
+
|
|
|
+const closeModel = () => {
|
|
|
+ state.modelVisible = false
|
|
|
+}
|
|
|
+
|
|
|
watch(
|
|
|
() => props.request,
|
|
|
() => request(),
|