update
init
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection" style="margin: 10px 5px">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" :icon="h(PlusOutlined)" @click="handleAdd"> 录入 </a-button>
|
||||
<a-button type="primary" :icon="h(EditOutlined)" @click="handleEdit"> 编辑 </a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<add-modal @register="registerModal" @success="handleSuccess" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { h } from 'vue';
|
||||
import { PlusOutlined, EditOutlined } from '@ant-design/icons-vue';
|
||||
import BasicTable from '/@/components/Table/src/BasicTable.vue';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { TableAction } from '/@/components/Table';
|
||||
import { columns } from '/@/views/archive/healthCabin/bigDataShow/bigDataShow.data';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import AddModal from '/@/views/archive/healthCabin/bigDataShow/components/addDigDataShowModal.vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { deleteOne } from '/@/views/archive/healthCabin/bigDataShow/bigDataShow.api';
|
||||
const { createMessage } = useMessage();
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
const { hasPermission } = usePermission();
|
||||
const list = [{}];
|
||||
const { tableContext } = useListPage({
|
||||
tableProps: {
|
||||
// api: listApi,
|
||||
dataSource: list,
|
||||
columns,
|
||||
canResize: false,
|
||||
orderFlag: false,
|
||||
showIndexColumn: true,
|
||||
useSearchForm: false,
|
||||
beforeFetch: (params) => {
|
||||
return params;
|
||||
},
|
||||
actionColumn: {
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
//注册弹窗
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
function getTableAction(record: any) {
|
||||
return [
|
||||
{
|
||||
label: '删除',
|
||||
onClick: handleDelete.bind(null, record),
|
||||
ifShow: () => hasPermission('housenew:health_house_banner:delete'),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
openModal(true, {
|
||||
record: { sort: getDataSource().length + 1 },
|
||||
isUpdate: false,
|
||||
showFooter: true,
|
||||
type: '新增',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit() {
|
||||
if (!selectedRowKeys.value.length || selectedRowKeys.value.length > 1) {
|
||||
return createMessage.warning('请选择一条数据!');
|
||||
}
|
||||
let id = selectedRowKeys.value[0];
|
||||
let dataSource = getDataSource();
|
||||
let record = dataSource.filter((item) => item.id === id)[0];
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: true,
|
||||
title: '编辑',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Reference in New Issue
Block a user