update
init
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" :icon="h(DeleteOutlined)" @click="deteleAll"> 批量删除 </a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<add-modal @register="registerModal" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { h } from 'vue';
|
||||
import { DeleteOutlined } 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, searchFormSchema } from '/@/views/archive/healthCabin/bespeakManage/bespeakManage.data';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import AddModal from '/@/views/archive/healthCabin/bespeakManage/components/addDespeakManageModal.vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { list, batchDelete } from '/@/views/archive/healthCabin/bespeakManage/bespeakManage.api';
|
||||
const { createMessage } = useMessage();
|
||||
const { tableContext } = useListPage({
|
||||
tableProps: {
|
||||
api: list,
|
||||
// dataSource: list,
|
||||
columns,
|
||||
// canResize: false,
|
||||
orderFlag: false,
|
||||
showIndexColumn: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: false,
|
||||
fieldMapToNumber: [],
|
||||
fieldMapToTime: [],
|
||||
},
|
||||
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),
|
||||
},
|
||||
{
|
||||
label: '详情',
|
||||
onClick: onlyread.bind(null, record),
|
||||
},
|
||||
];
|
||||
}
|
||||
function onlyread(record) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: false,
|
||||
title: '查看',
|
||||
onlyRead: true,
|
||||
});
|
||||
}
|
||||
function deteleAll() {
|
||||
if (!selectedRowKeys.value.length) {
|
||||
createMessage.warning('请选择需要删除的数据');
|
||||
} else {
|
||||
batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
}
|
||||
function handleSuccess() {
|
||||
reload();
|
||||
}
|
||||
function handleDelete(record) {
|
||||
batchDelete({ ids: record.id }, handleSuccess);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Reference in New Issue
Block a user