jeecg-vue3, BasicTable与抽屉useDrawer()的简单使用

需求:分屏情况下,根据传入参数不同查看申请材料

1.实现效果

点击申请材料弹出,点击取消或点击空白处,抽屉消失

2.代码实现

2.1files.vue实现

<template>
    <div class="container">
        <a-button @click="click('sqcl')" style="margin-left: 5px;">申请材料</a-button>
        <a-button @click="click('jcbz')" style="margin-left: 5px;">检查标准</a-button>
    </div>
    <FormDrawer @register="registerDrawer" @success="reload" :showFooter="showFooter" />

</template>
<script setup>
    import { ref } from 'vue';
    import FormDrawer from './formDrawer.vue';
    import { useDrawer } from '/@/components/Drawer';

    const showFooter = ref(true);

    const [registerDrawer, { openDrawer }] = useDrawer();

    function click(data) {
        showFooter.value = true;
        openDrawer(true, {
            type: data,
        });
    }
</script>
<style scoped>
.card-style{
  margin: 10px 0;
}

.container {
  background-color: white;
  padding: 5px;
  width: 100%;
  max-width: 100%; 
  box-sizing: border-box;
  margin-top: 10px;
  display: flex; /* 使用Flexbox布局 */
  align-items: center; /* 垂直居中对齐 */
  /* justify-content: space-between;  */
}
</style>

2.2formDrawer.vue实现

<template>
    <BasicDrawer v-bind="$attrs" @register="registerDrawer" :title="getTitle" width="500px"
        destroyOnClose>
        <BasicTable @register="registerTable"></BasicTable>
    </BasicDrawer>
</template>
<script lang="ts" setup>
    import { BasicTable } from '/@/components/Table';
    import { useListPage } from '/@/hooks/system/useListPage';
    import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
    import { computed, ref, unref, onMounted } from 'vue';
    import { filesColumns } from '../screen.data';
    import { getMaterialsApi } from '../screen.api';

    const type = ref('');
    const fileList = ref([]);
    const [ registerDrawer ] = useDrawerInner((data)=>{
        type.value = data?.type;
    });
    
    const getTitle = computed(() => (unref(type)==='sqcl' ? '申请材料' : '检查标准'));

    // 列表页面公共参数、方法
    const { tableContext } = useListPage({
        tableProps: {
            dataSource: fileList,
            columns: filesColumns,
            //显示序号
            showIndexColumn: true,
            bordered: true,
            //是否显示操作列
            showActionColumn: false,
            //是否显示刷新、设置等
            showTableSetting: false,
            //是否显示查询、重置
            useSearchForm: false,
            // actionColumn: {
            //   width: 120,
            // },
            pagination: false,
        },
    });

    //BasicTable绑定注册
    const [registerTable] = tableContext;

    async function getMaterials() {
        const result = await getMaterialsApi({type: '1'});
        fileList.value = result;
    }
    onMounted(()=>{
        getMaterials();
    });

</script>
<style scoped>
</style>

2.3screen.api.ts实现

import { defHttp } from '/@/utils/http/axios';

enum Api {
  getMaterials = '/接口',
}

export const getMaterialsApi = (params) => {
  return defHttp.get({url: Api.getMaterials, params}, { joinParamsToUrl: true });
}

2.4screen.data.ts实现

import { BasicColumn } from '/@/components/Table';

export const filesColumns: BasicColumn[] = [
    {
        title: '名称',
        dataIndex: 'wjmc',
    },
    // {
    //     title: '地址',
    //     dataIndex: 'wjdz',
    // },
]

3.总结

 1.ts也可以写到路由里面

 2.很简单,直接拷贝就可以测试了。接口记得改一下就行了。

  • 13
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值