|
|
|
|
@ -57,6 +57,7 @@
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
class="mr-5"
|
|
|
|
|
@click="doAdd"
|
|
|
|
|
>新增</el-button
|
|
|
|
|
>
|
|
|
|
|
</el-row>
|
|
|
|
|
@ -69,7 +70,16 @@
|
|
|
|
|
:columns="columns"
|
|
|
|
|
size="large"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
/>
|
|
|
|
|
>
|
|
|
|
|
<template #action="{ row }">
|
|
|
|
|
<el-button
|
|
|
|
|
type="danger"
|
|
|
|
|
link
|
|
|
|
|
@click="handleDeleteItemFN({ id: row.id })"
|
|
|
|
|
>删除</el-button
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
</pure-table>
|
|
|
|
|
<base-footer>
|
|
|
|
|
<el-card>
|
|
|
|
|
<el-pagination
|
|
|
|
|
@ -84,9 +94,12 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="jsx">
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import { h, ref } from 'vue';
|
|
|
|
|
import { useTable } from '@/hooks/useTable';
|
|
|
|
|
import { getTableList } from '@/api/table';
|
|
|
|
|
import { getTableList, addTableItem, deleteTableItem } from '@/api/table';
|
|
|
|
|
import Add from './components/add.vue';
|
|
|
|
|
import { addDialog } from '@/components/ReDialog';
|
|
|
|
|
import { message } from '@/utils/message';
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'TemplateLayout',
|
|
|
|
|
});
|
|
|
|
|
@ -124,11 +137,49 @@ const columns = [
|
|
|
|
|
label: '性别',
|
|
|
|
|
prop: 'sex',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '操作',
|
|
|
|
|
prop: 'action',
|
|
|
|
|
slot: 'action',
|
|
|
|
|
width: 80,
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const { loading, tableData, pagination, handleRequestDataFN, handleSearchFN, handlePaginationChangeFN, handleDeleteItemFN } = useTable({
|
|
|
|
|
searchForm: form.value,
|
|
|
|
|
requestDataFN: getTableList,
|
|
|
|
|
deleteItemFN: deleteTableItem,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const AddRef = ref(null);
|
|
|
|
|
const doAdd = () => {
|
|
|
|
|
addDialog({
|
|
|
|
|
width: '550px',
|
|
|
|
|
title: '新增',
|
|
|
|
|
contentRenderer: () => h(Add, { ref: AddRef }),
|
|
|
|
|
props: {},
|
|
|
|
|
sureBtnLoading: true,
|
|
|
|
|
beforeSure: (done, { options, closeLoading }) => {
|
|
|
|
|
console.log(options);
|
|
|
|
|
const { form, formRef } = AddRef.value;
|
|
|
|
|
formRef.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
addTableItem({ ...form })
|
|
|
|
|
.then(() => {
|
|
|
|
|
message('新增成功', { type: 'success' });
|
|
|
|
|
handleRequestDataFN();
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
closeLoading();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
closeLoading();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|
|
|
|
|
|