|
|
|
<template>
|
|
|
|
<PageWrapper dense>
|
|
|
|
<a-row>
|
|
|
|
<a-col :span="4" style="margin-top: 1%">
|
|
|
|
<a-tree :show-line="true" :show-icon="true" :tree-data="treeData" @select="onSelect">
|
|
|
|
<template #title="{ dataRef }">
|
|
|
|
<template v-if="dataRef.key === '0-0-0-1'">
|
|
|
|
<div>multiple line title</div>
|
|
|
|
<div>multiple line title</div>
|
|
|
|
</template>
|
|
|
|
<template v-else>{{ dataRef.title }}</template>
|
|
|
|
</template>
|
|
|
|
</a-tree>
|
|
|
|
</a-col>
|
|
|
|
<a-col :span="20">
|
|
|
|
<BasicTable @register="registerTable">
|
|
|
|
<template #toolbar>
|
|
|
|
<a-button type="primary" @click="handleAdd">新增</a-button>
|
|
|
|
<a-button type="primary" @click="handleAdd">导入</a-button>
|
|
|
|
<a-button type="primary" @click="handleAdd">导出</a-button>
|
|
|
|
</template>
|
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
|
<template v-if="column && record && column.key === 'action'">
|
|
|
|
<a-button type="link" @click="handleEdit(record.id)">编辑</a-button>
|
|
|
|
<a-button type="link" @click="handleDelete(record.id)">删除</a-button>
|
|
|
|
<a-button type="link" @click="handleEdit(record.id)">禁用/启用</a-button>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</BasicTable>
|
|
|
|
<addModal ref="addModalRef" />
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</PageWrapper>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { PageWrapper } from '@/components/Page';
|
|
|
|
import { BasicTable, useTable } from '@/components/Table';
|
|
|
|
import { list } from './api';
|
|
|
|
import { formSchemas, columns } from './data';
|
|
|
|
import addModal from './addModal.vue';
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
|
defineOptions({ name: 'Meterial' });
|
|
|
|
|
|
|
|
const [registerTable, { reload }] = useTable({
|
|
|
|
rowSelection: {
|
|
|
|
type: 'checkbox',
|
|
|
|
},
|
|
|
|
title: '材料库',
|
|
|
|
api: list,
|
|
|
|
showIndexColumn: true,
|
|
|
|
rowKey: 'id',
|
|
|
|
useSearchForm: true,
|
|
|
|
formConfig: {
|
|
|
|
schemas: formSchemas,
|
|
|
|
name: 'meterial',
|
|
|
|
baseColProps: {
|
|
|
|
xs: 24,
|
|
|
|
sm: 24,
|
|
|
|
md: 24,
|
|
|
|
lg: 6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
columns: columns,
|
|
|
|
actionColumn: {
|
|
|
|
width: 200,
|
|
|
|
title: '操作',
|
|
|
|
key: 'action',
|
|
|
|
fixed: 'right',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
//新增编辑弹窗
|
|
|
|
const addModalRef = ref();
|
|
|
|
const handleAdd = () => {
|
|
|
|
addModalRef.value.showModal(1);
|
|
|
|
};
|
|
|
|
const handleEdit = (id: any) => {
|
|
|
|
addModalRef.value.showModal(2, id);
|
|
|
|
};
|
|
|
|
const handleDelete = (id: any) => {
|
|
|
|
addModalRef.value.showModal(2, id);
|
|
|
|
};
|
|
|
|
//tree
|
|
|
|
const treeData = ref([
|
|
|
|
{
|
|
|
|
title: 'parent 1',
|
|
|
|
key: '0-0',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'parent 1-0',
|
|
|
|
key: '0-0-0',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'leaf',
|
|
|
|
key: '0-0-0-0',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '0-0-0-1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'leaf',
|
|
|
|
key: '0-0-0-2',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'parent 1-1',
|
|
|
|
key: '0-0-1',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'leaf',
|
|
|
|
key: '0-0-1-0',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'parent 1-2',
|
|
|
|
key: '0-0-2',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'leaf 1',
|
|
|
|
key: '0-0-2-0',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'leaf 2',
|
|
|
|
key: '0-0-2-1',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'parent 2',
|
|
|
|
key: '0-1',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'parent 2-0',
|
|
|
|
key: '0-1-0',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
title: 'leaf',
|
|
|
|
key: '0-1-0-0',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'leaf',
|
|
|
|
key: '0-1-0-1',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
const onSelect = (selectedKeys: any, info: any) => {
|
|
|
|
console.log('selected', selectedKeys, info);
|
|
|
|
reload();
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|