|
|
|
<template>
|
|
|
|
<PageWrapper dense>
|
|
|
|
<a-row>
|
|
|
|
<a-col :span="8" style="margin-top: 1%">
|
|
|
|
<div>
|
|
|
|
<a-button type="primary" @click="handleAdd" size="small" class="treeButton"
|
|
|
|
>新增目录</a-button
|
|
|
|
>
|
|
|
|
<a-button type="primary" @click="handleAdd" size="small" class="treeButton"
|
|
|
|
>编辑目录</a-button
|
|
|
|
>
|
|
|
|
<a-button type="primary" @click="handleAdd" size="small" class="treeButton"
|
|
|
|
>删除目录</a-button
|
|
|
|
>
|
|
|
|
<a-button type="primary" @click="handleAdd" size="small" class="treeButton"
|
|
|
|
>导入</a-button
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<a-tree
|
|
|
|
:show-line="true"
|
|
|
|
:show-icon="true"
|
|
|
|
:tree-data="treeData"
|
|
|
|
v-model:selectedKeys="checkedTree"
|
|
|
|
@select="onSelect"
|
|
|
|
:fieldNames="{
|
|
|
|
children: 'children',
|
|
|
|
title: 'projectName',
|
|
|
|
key: 'id',
|
|
|
|
disabled: 'disabled',
|
|
|
|
}"
|
|
|
|
/>
|
|
|
|
</a-col>
|
|
|
|
<a-col :span="16">
|
|
|
|
<BasicTable @register="registerTable">
|
|
|
|
<template #toolbar>
|
|
|
|
<a-button type="primary" @click="handleAdd">新增协议</a-button>
|
|
|
|
<a-button type="primary" @click="handleTypeAdd">新增类型</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>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</BasicTable>
|
|
|
|
<addModal ref="addModalRef" />
|
|
|
|
<AddTypeModal ref="addTypeModalRef" />
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</PageWrapper>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { PageWrapper } from '@/components/Page';
|
|
|
|
import { BasicTable, useTable } from '@/components/Table';
|
|
|
|
import { list, tree } from './api';
|
|
|
|
import { formSchemas, columns } from './data';
|
|
|
|
import addModal from './addModal.vue';
|
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
|
import AddTypeModal from './addTypeModal.vue';
|
|
|
|
|
|
|
|
defineOptions({ name: 'ServiceManage' });
|
|
|
|
|
|
|
|
const [registerTable, { reload }] = useTable({
|
|
|
|
rowSelection: {
|
|
|
|
type: 'checkbox',
|
|
|
|
},
|
|
|
|
title: '服务管理',
|
|
|
|
api: list,
|
|
|
|
showIndexColumn: true,
|
|
|
|
rowKey: 'id',
|
|
|
|
useSearchForm: true,
|
|
|
|
formConfig: {
|
|
|
|
schemas: formSchemas,
|
|
|
|
name: 'serviceManage',
|
|
|
|
baseColProps: {
|
|
|
|
xs: 24,
|
|
|
|
sm: 24,
|
|
|
|
md: 24,
|
|
|
|
lg: 6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
columns: columns,
|
|
|
|
beforeFetch(params: any) {
|
|
|
|
if (checkedTree.value.length === 1) {
|
|
|
|
params.serviceCategoryId = checkedTree.value[0];
|
|
|
|
}
|
|
|
|
return params;
|
|
|
|
},
|
|
|
|
immediate: false,
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
//新增类型弹窗
|
|
|
|
const addTypeModalRef = ref();
|
|
|
|
const handleTypeAdd = () => {
|
|
|
|
addTypeModalRef.value.showModal(1);
|
|
|
|
};
|
|
|
|
//tree
|
|
|
|
const checkedTree = ref([]);
|
|
|
|
const treeData = ref([]);
|
|
|
|
const getTree = async () => {
|
|
|
|
const res = await tree();
|
|
|
|
treeData.value = res;
|
|
|
|
treeData.value.forEach((i: any) => {
|
|
|
|
i.disabled = true;
|
|
|
|
});
|
|
|
|
console.log(res);
|
|
|
|
};
|
|
|
|
const onSelect = (selectedKeys: any, info: any) => {
|
|
|
|
console.log('selected', selectedKeys, info);
|
|
|
|
console.log(checkedTree.value);
|
|
|
|
reload();
|
|
|
|
};
|
|
|
|
onMounted(() => {
|
|
|
|
getTree();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.treeButton {
|
|
|
|
margin: 0 1% 1%;
|
|
|
|
}
|
|
|
|
</style>
|