|
@@ -2,16 +2,15 @@
|
|
|
<div class="person-files flex flex-col h-full">
|
|
|
<SearchForm :fields="fields" :params="params"></SearchForm>
|
|
|
<div class="flex-1 page-wrap">
|
|
|
- <div class="btn-group">
|
|
|
- <t-button
|
|
|
- theme="success"
|
|
|
- @click="
|
|
|
- curRow = null;
|
|
|
- showAddPersonFileDialog = true;
|
|
|
- "
|
|
|
- >新增</t-button
|
|
|
- >
|
|
|
- <t-button theme="success" @click="multImport">批量导入</t-button>
|
|
|
+ <t-space size="small">
|
|
|
+ <t-button theme="success" @click="handleAdd">新增</t-button>
|
|
|
+ <upload-button
|
|
|
+ upload-url="/api/upload"
|
|
|
+ :button-props="{
|
|
|
+ content: '批量导入',
|
|
|
+ theme: 'success',
|
|
|
+ }"
|
|
|
+ ></upload-button>
|
|
|
<t-button
|
|
|
theme="success"
|
|
|
@click="multExport"
|
|
@@ -20,11 +19,11 @@
|
|
|
>
|
|
|
<t-button
|
|
|
theme="success"
|
|
|
- @click="cancelIt"
|
|
|
:disabled="!selectedRowKeys.length"
|
|
|
+ @click="handleDestroy"
|
|
|
>作废</t-button
|
|
|
>
|
|
|
- </div>
|
|
|
+ </t-space>
|
|
|
<t-table
|
|
|
size="small"
|
|
|
row-key="id"
|
|
@@ -36,6 +35,7 @@
|
|
|
defaultPageSize: 10,
|
|
|
onChange,
|
|
|
total: pagination.total,
|
|
|
+ current: pagination.page,
|
|
|
}"
|
|
|
:selected-row-keys="selectedRowKeys"
|
|
|
select-on-row-click
|
|
@@ -47,24 +47,25 @@
|
|
|
<AddPersonFileDialog
|
|
|
v-model:visible="showAddPersonFileDialog"
|
|
|
:curRow="curRow"
|
|
|
+ @success="fetchData"
|
|
|
></AddPersonFileDialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="jsx" name="PersonFiles">
|
|
|
import { ref, reactive } from 'vue';
|
|
|
-import { getTableData } from '@/api/test';
|
|
|
+import { DialogPlugin, MessagePlugin } from 'tdesign-vue-next';
|
|
|
import useFetchTable from '@/hooks/useFetchTable';
|
|
|
import AddPersonFileDialog from './add-person-file-dialog';
|
|
|
+import {
|
|
|
+ personFilesListApi,
|
|
|
+ personFilesDestroyApi,
|
|
|
+ personFilesExportApi,
|
|
|
+} from '@/api/resource-guard';
|
|
|
+
|
|
|
const curRow = ref(null);
|
|
|
const showAddPersonFileDialog = ref(false);
|
|
|
-const selectedRowKeys = ref([]);
|
|
|
-const selectChange = (value, { selectedRowData }) => {
|
|
|
- selectedRowKeys.value = value;
|
|
|
-};
|
|
|
-const multImport = () => {};
|
|
|
-const multExport = () => {};
|
|
|
-const cancelIt = () => {};
|
|
|
+
|
|
|
const columns = [
|
|
|
{
|
|
|
colKey: 'row-select',
|
|
@@ -96,7 +97,8 @@ const columns = [
|
|
|
title: '操作',
|
|
|
colKey: 'operate',
|
|
|
fixed: 'right',
|
|
|
- width: 150,
|
|
|
+ width: 80,
|
|
|
+ align: 'center',
|
|
|
cell: (h, { row }) => {
|
|
|
return (
|
|
|
<div class="table-operations">
|
|
@@ -105,8 +107,7 @@ const columns = [
|
|
|
hover="color"
|
|
|
onClick={(e) => {
|
|
|
e.stopPropagation();
|
|
|
- curRow.value = row;
|
|
|
- showAddPersonFileDialog.value = true;
|
|
|
+ handleEdit(row);
|
|
|
}}
|
|
|
>
|
|
|
修改
|
|
@@ -116,14 +117,19 @@ const columns = [
|
|
|
},
|
|
|
},
|
|
|
];
|
|
|
-const {
|
|
|
- loading: tableLoading,
|
|
|
- pagination,
|
|
|
- tableData,
|
|
|
- fetchData,
|
|
|
- onChange,
|
|
|
-} = useFetchTable(getTableData);
|
|
|
-const refresh = async () => {};
|
|
|
+const { pagination, tableData, fetchData, search, onChange } = useFetchTable(
|
|
|
+ personFilesListApi,
|
|
|
+ {
|
|
|
+ fetchDataHandle: () => {
|
|
|
+ selectedRowKeys.value = [];
|
|
|
+ },
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+const selectedRowKeys = ref([]);
|
|
|
+const selectChange = (value, { selectedRowData }) => {
|
|
|
+ selectedRowKeys.value = value;
|
|
|
+};
|
|
|
|
|
|
const fields = ref([
|
|
|
{
|
|
@@ -161,6 +167,9 @@ const fields = ref([
|
|
|
{
|
|
|
type: 'button',
|
|
|
text: '查询',
|
|
|
+ onClick: () => {
|
|
|
+ search();
|
|
|
+ },
|
|
|
},
|
|
|
],
|
|
|
},
|
|
@@ -194,6 +203,55 @@ const params = reactive({
|
|
|
f: [],
|
|
|
g: '',
|
|
|
});
|
|
|
-</script>
|
|
|
|
|
|
-<style></style>
|
|
|
+const handleAdd = () => {
|
|
|
+ curRow.value = null;
|
|
|
+ showAddPersonFileDialog.value = true;
|
|
|
+};
|
|
|
+const handleEdit = (row) => {
|
|
|
+ curRow.value = row;
|
|
|
+ showAddPersonFileDialog.value = true;
|
|
|
+};
|
|
|
+const handleDestroy = () => {
|
|
|
+ if (!selectedRowKeys.value.length) {
|
|
|
+ MessagePlugin.error('请选择要作废的记录');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const confirmDia = DialogPlugin({
|
|
|
+ header: '操作提示',
|
|
|
+ body: `确定要作废当前选择的所有记录吗`,
|
|
|
+ confirmBtn: '确定',
|
|
|
+ cancelBtn: '取消',
|
|
|
+ onConfirm: async () => {
|
|
|
+ confirmDia.hide();
|
|
|
+ const res = await personFilesDestroyApi(selectedRowKeys.value).catch(
|
|
|
+ () => {}
|
|
|
+ );
|
|
|
+ if (!res) return;
|
|
|
+ MessagePlugin.success('操作成功');
|
|
|
+ fetchData();
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+const multExport = () => {
|
|
|
+ if (!selectedRowKeys.value.length) {
|
|
|
+ MessagePlugin.error('请选择要作废的记录');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const confirmDia = DialogPlugin({
|
|
|
+ header: '操作提示',
|
|
|
+ body: `确定要导出选择的所有记录吗?`,
|
|
|
+ confirmBtn: '确定',
|
|
|
+ cancelBtn: '取消',
|
|
|
+ onConfirm: async () => {
|
|
|
+ confirmDia.hide();
|
|
|
+ const res = await personFilesExportApi(selectedRowKeys.value).catch(
|
|
|
+ () => {}
|
|
|
+ );
|
|
|
+ if (!res) return;
|
|
|
+ MessagePlugin.success('开始下载');
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+</script>
|