| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <template>
- <page-wrapper>
- <el-card :bordered="false" class="mb-3 proCard">
- <el-space align="center">
- <el-input
- :style="{ width: '320px' }"
- v-model="params.tenantName"
- clearable
- placeholder="请输入租户名称"
- @keyup.enter="reloadTable"
- />
- <el-button type="primary" @click="reloadTable">
- <template #icon>
- <el-icon>
- <SearchOutlined />
- </el-icon>
- </template>
- 查询
- </el-button>
- </el-space>
- </el-card>
- <el-card :bordered="false" class="proCard">
- <BasicTable
- :columns="columns"
- :dataSource="tenantItems"
- :row-key="(row) => row.id"
- ref="tableRef"
- :actionColumn="actionColumn"
- @update:checked-row-keys="onCheckedRow"
- >
- <template #tableTitle>
- <el-button type="primary" @click="openCreateDrawer">
- <template #icon>
- <el-icon>
- <FileAddOutlined />
- </el-icon>
- </template>
- 添加租户
- </el-button>
- </template>
- <template #action>
- <TableAction />
- </template>
- </BasicTable>
- </el-card>
- <CreateDrawer
- ref="createDrawerRef"
- :title="drawerTitle"
- :permissionList="treeData"
- @change="reloadTable"
- />
- </page-wrapper>
- </template>
- <script lang="ts" setup>
- import { reactive, ref, unref, h, onMounted } from 'vue';
- import { ElMessage } from 'element-plus';
- import { BasicTable, TableAction, BasicColumn } from '@/components/Table';
- import { tenantList, deleteTenant } from '@/api/tenant/index';
- import { columns } from './columns';
- import { FileAddOutlined, SearchOutlined } from '@vicons/antd';
- import CreateDrawer from './CreateDrawer.vue';
- const message = ElMessage;
- const tableRef = ref();
- const createDrawerRef = ref();
- const drawerTitle = ref('添加租户');
- const treeData = ref([]);
- const tenantItems = ref<any[]>([]);
- const params = reactive({
- tenantName: '',
- tenantCode: '',
- });
- const actionColumn: BasicColumn = reactive({
- width: 150,
- title: '操作',
- prop: 'action',
- fixed: 'right',
- render(record) {
- return h(TableAction as any, {
- style: 'button',
- actions: [
- {
- label: '删除',
- isConfirm: true,
- popConfirm: {
- onConfirm: handleDelete.bind(null, record.row),
- title: '您确定要删除吗?',
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- },
- },
- {
- label: '编辑',
- onClick: handleEdit.bind(null, record.row),
- },
- ],
- });
- },
- });
- const loadDataTable = async (res?: any) => {
- let _params = {
- ...unref(params),
- ...res,
- };
- const list = await tenantList(_params);
- tenantItems.value = list;
- };
- function openCreateDrawer() {
- const { openDrawer } = createDrawerRef.value;
- openDrawer();
- }
- function onCheckedRow(rowKeys: any[]) {
- console.log(rowKeys);
- }
- function reloadTable() {
- // tableRef.value.reload();
- loadDataTable();
- }
- function handleEdit(record: Recordable) {
- console.log('点击了编辑', record);
- drawerTitle.value = '编辑租户';
- const { openDrawer } = createDrawerRef.value;
- openDrawer(record.tenantId);
- }
- function handleDelete(record: Recordable) {
- deleteTenant({ id: record.tenantId }).then(() => {
- message.success('删除成功');
- reloadTable();
- });
- }
- onMounted(async () => {
- loadDataTable();
- });
- </script>
- <style lang="scss" scoped></style>
|