Compare commits

...

2 Commits

Author SHA1 Message Date
刘妍 645b9ff57c Merge branch 'main' of http://123.132.248.154:10000/gitY/LinYeFangHuo 2025-04-11 14:55:20 +08:00
刘妍 23b8298d86 部分接口对接 2025-04-11 14:52:27 +08:00
6 changed files with 247 additions and 208 deletions

View File

@ -0,0 +1,60 @@
import { defHttp } from '@/utils/http/axios';
import {
AddApplicationParams,
GetApplicationListParams,
DeleteApplicationParams,
GetGeomTableListParams,
} from './model/index';
enum Api {
GetApplicationList = '/api/ApplicationData/GetApplicationList',
AddApplication = '/api/ApplicationData/AddApplication',
UpdateApplication = '/api/ApplicationData/UpdateApplication',
DeleteApplication = '/api/ApplicationData/DeleteApplication',
GetGeomTableList = '/api/ApplicationData/GetGeomTableList',
}
/**
* @description:
*/
export function getApplicationList(params: GetApplicationListParams) {
return defHttp.get({ url: Api.GetApplicationList, params });
}
/**
* @description:
*/
export function addApplication(params: AddApplicationParams) {
return defHttp.post({
url: Api.AddApplication,
params,
});
}
/**
* @description:
*/
export function deleteApplication(params: DeleteApplicationParams) {
return defHttp.post({
url: Api.DeleteApplication + '?id=' + params.id,
params,
});
}
/**
* @description:
*/
export function updateApplication(params: AddApplicationParams) {
return defHttp.post({
url: Api.UpdateApplication,
params,
});
}
/**
* @description:
*/
export function getGeomTableList(params: GetGeomTableListParams) {
return defHttp.post({
url: Api.GetGeomTableList,
params,
});
}

View File

@ -0,0 +1,23 @@
export interface AddApplicationParams {
id?: number;
lng: string;
lat: string;
pointName: string;
userId: any;
areaId: any;
}
export interface GetApplicationListParams {
name?: string;
isCatalogue?: boolean;
}
export interface DeleteApplicationParams {
id: number;
}
export interface GetGeomTableListParams {
page: number;
limit: number;
key?: string;
}

View File

@ -7,10 +7,10 @@
import { ref, computed, unref } from 'vue';
import { BasicForm, useForm } from '@/components/Form';
import { formSchema } from './data';
import { getMenuList, addMenu, editMenu, addButton, editButton } from '@/api/demo/system';
import { useMessage } from '@/hooks/web/useMessage';
import { cloneDeep } from 'lodash-es';
import { BasicModal, useModalInner } from '@/components/Modal';
import { addApplication, updateApplication } from '@/api/application/index';
const { createMessage } = useMessage();
defineOptions({ name: 'MenuDrawer' });
@ -35,27 +35,24 @@
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
const { record } = data;
if (record.type == '2') {
record.status = record.status ? 1 : 0;
const { node } = data;
if (node.pid == 0) {
node.type = 1;
} else {
node.type = 2;
}
setFieldsValue({
...record,
...node,
});
}
// const treeData = await getMenuList();
const treeData = cloneDeep(props.treeData);
treeData.unshift({
id: '0',
key: '0',
name: '根节点',
applicationName: '根节点',
});
updateSchema({
field: 'parentId',
componentProps: { treeData },
});
updateSchema({
field: 'moduleId',
field: 'pid',
componentProps: { treeData },
});
});
@ -66,56 +63,29 @@
try {
const values = await validate();
values.sortNo = Number(values.sortNo);
setDrawerProps({ confirmLoading: true });
// TODO custom api
if (values.type == '1') {
delete values.type;
//
if (!unref(isUpdate)) {
const data = await addMenu(values);
if (data) {
closeDrawer();
emit('success');
return createMessage.success('新增成功');
} else {
return createMessage.error('新增失败');
}
delete values.type;
//
if (!unref(isUpdate)) {
const data = await addApplication(values);
if (data) {
closeModal();
emit('success');
return createMessage.success('新增成功');
} else {
const data = await editMenu(values);
if (data) {
closeDrawer();
emit('success');
return createMessage.success('编辑成功');
} else {
return createMessage.error('编辑失败');
}
return createMessage.error('新增失败');
}
} else {
//
delete values.type;
values.status = values.status == 1 ? true : false;
if (!unref(isUpdate)) {
const data = await addButton(values);
if (data) {
closeDrawer();
emit('success');
return createMessage.info('创建成功');
} else {
return createMessage.error('创建失败');
}
const data = await updateApplication(values);
if (data) {
closeModal();
emit('success');
return createMessage.success('编辑成功');
} else {
const data = await editButton(values);
if (data) {
closeDrawer();
emit('success');
return createMessage.success('编辑成功');
} else {
return createMessage.error('编辑失败');
}
return createMessage.error('编辑失败');
}
}
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>

View File

@ -1,16 +1,20 @@
<template>
<div class="m-4 mr-0 overflow-hidden bg-white">
<div class="button-list">
<a-button type="primary" @click="emit('add')"></a-button>
<a-button type="primary" @click="emit('edit', selectItem)">编辑</a-button>
<a-button type="primary" danger @click="delLayer()"></a-button>
</div>
<BasicTree
ref="asyncExpandTreeRef"
title="图层列表"
toolbar
search
treeWrapperClassName="h-[calc(100%-35px)] overflow-auto"
:actionList="actionList"
:renderIcon="createIcon"
:clickRowToExpand="false"
:treeData="treeData"
:fieldNames="{ key: 'id', title: 'name' }"
:fieldNames="{ key: 'id', title: 'applicationName', children: 'child' }"
:defaultExpandAll="true"
@select="handleSelect"
/>
@ -20,19 +24,21 @@
import { onMounted, ref, h, nextTick, unref } from 'vue';
import { BasicTree, TreeItem, TreeActionItem, TreeActionType } from '@/components/Tree';
import { getMenuList, deleteMenu, getAllModuleDetail } from '@/api/demo/system';
import { getApplicationList, deleteApplication } from '@/api/application/index';
import { FormOutlined, DeleteOutlined, PlusOutlined } from '@ant-design/icons-vue';
import { router } from '@/router';
import { useMessage } from '@/hooks/web/useMessage';
import { deleteLayer } from '@/api/sys/layerManagement';
const { createMessage, createConfirm } = useMessage();
const emit = defineEmits(['select', 'edit', 'add']);
const emit = defineEmits(['select', 'edit', 'add', 'remove']);
defineOptions({ name: 'DeptTree' });
const treeData = ref<TreeItem[]>([]);
let selectItemId = ref('');
let selectItem = ref();
const asyncExpandTreeRef = ref<Nullable<TreeActionType>>(null);
async function fetch() {
treeData.value = (await getMenuList()) as unknown as TreeItem[];
treeData.value = (await getApplicationList()) as unknown as TreeItem[];
setTimeout(() => {
treeData.value.forEach((item, index) => {
let moduleDetail = allModuleDetail.value?.find((detail) => {
@ -48,96 +54,53 @@
function handleSelect(keys) {
emit('select', keys[0]);
selectItem.value = treeFindById(treeData.value, keys[0]);
}
const btnList = router.currentRoute.value.meta.elements;
const actionList: TreeActionItem[] = [
{
render: (node) => {
return h(PlusOutlined, {
class: 'ml-2',
onClick: () => {
emit('add', node);
},
});
},
},
{
render: (node) => {
return h(FormOutlined, {
class: 'ml-2',
onClick: () => {
emit('edit', node);
},
});
},
},
{
render: (node) => {
return h(DeleteOutlined, {
class: 'ml-2',
onClick: () => {
selectItemId.value = node.id;
createConfirm({
iconType: 'warning',
title: '删除',
content: '确认要删除菜单吗?',
onOk: async () => {
var query = [selectItemId.value];
const data = await deleteMenu(query);
if (data) {
fetch();
createMessage.success('删除成功');
} else {
createMessage.info('删除失败');
}
},
});
},
});
},
},
];
// btnList.forEach((element) => {
// if (element.domId == 'btnEdit') {
// actionList.push({
// render: (node) => {
// return h(FormOutlined, {
// class: 'ml-2',
// onClick: () => {
// emit('edit', node);
// },
// });
// },
// });
// } else if (element.domId == 'btnDelete') {
// actionList.push({
// render: (node) => {
// return h(DeleteOutlined, {
// class: 'ml-2',
// onClick: () => {
// selectItemId.value = node.id;
// createConfirm({
// iconType: 'warning',
// title: '',
// content: '?',
// onOk: async () => {
// var query = [selectItemId.value];
// const data = await deleteMenu(query);
// if (data) {
// fetch();
// createMessage.success('');
// } else {
// createMessage.info('');
// }
// },
// });
// },
// });
// },
// });
// }
// });
/**
* 根据id值或某个属性的值从树结构中查询数据
* @param {Array} treeArray 树结构数据
* @param {String|Number|Boolean|null} id 对比的id的值
* @param {String} childrenKey 子集的key名, 默认 children
* @returns 返回存在的数据不存在返回null
*/
function treeFindById(treeArray, id, childrenKey = 'child') {
for (let node of treeArray) {
// id
if (node.id === id) {
return node;
}
if (node[childrenKey] && node[childrenKey].length > 0) {
const foundElement = treeFindById(node[childrenKey], id);
if (foundElement) {
return foundElement;
}
}
}
return null;
}
const delLayer = () => {
createConfirm({
iconType: 'warning',
title: '删除',
content: '确认要删除吗?',
onOk: async () => {
var query = {
id: selectItem.value.id,
};
const data = await deleteApplication(query);
if (data) {
fetch();
emit('remove');
createMessage.success('删除成功');
} else {
createMessage.info('删除失败');
}
},
});
};
function createIcon({ level }) {
if (level === 1) {
return 'ion:git-compare-outline';
@ -165,3 +128,11 @@
treeData,
});
</script>
<style lang="less" scoped>
.button-list {
padding-top: 10px;
button {
margin-left: 10px;
}
}
</style>

View File

@ -1,5 +1,6 @@
import { FormSchema } from '@/components/Table';
import { loadTableRecordInfo } from '@/api/database/index';
import { getGeomTableList } from '@/api/application/index';
export const columns: BasicColumn[] = [
{
@ -20,17 +21,17 @@ export const searchFormSchema: FormSchema[] = [
colProps: { span: 8 },
},
];
const isLayer = (type: string) => type === '2';
const isLayer = (type: string) => type === 2;
export const formSchema: FormSchema[] = [
{
field: 'type',
label: '类型',
component: 'RadioButtonGroup',
defaultValue: '1',
defaultValue: 1,
componentProps: {
options: [
{ label: '分组', value: '1' },
{ label: '图层', value: '2' },
{ label: '分组', value: 1 },
{ label: '图层', value: 2 },
],
},
colProps: { lg: 24, md: 24 },
@ -42,37 +43,39 @@ export const formSchema: FormSchema[] = [
ifShow: false,
},
{
field: 'name',
field: 'applicationName',
label: '名称',
component: 'Input',
required: true,
},
{
field: 'parentId',
field: 'pid',
label: '上级',
component: 'TreeSelect',
required: true,
componentProps: {
fieldNames: {
label: 'name',
label: 'applicationName',
key: 'id',
value: 'id',
children: 'child',
},
getPopupContainer: () => document.body,
},
},
{
field: 'tableId',
field: 'serverId',
component: 'ApiSelect',
label: '空间数据表',
required: true,
componentProps: ({ formActionType, formModel }) => {
componentProps: ({ formModel }) => {
return {
api: loadTableRecordInfo, // 接口
api: getGeomTableList,
params: { page: 1, limit: 9999 },
// 接口参数
resultField: 'items',
labelField: 'tableName',
valueField: 'tableName',
resultField: 'result',
labelField: 'table_comment',
valueField: 'table_name',
};
},
ifShow: ({ values }) => isLayer(values.type),

View File

@ -6,11 +6,12 @@
@select="handleSelect"
@edit="editLayer"
@add="addLayer"
@remove="tableVisible = false"
/>
<div class="map-container w-3/4 xl:w-4/5">
<Map />
<!-- 数据列表 -->
<div class="table-constainer" v-if="tableVisible">
<div class="table-constainer" v-show="tableVisible">
<div class="drawer-title-box">
<a-input
v-model:value="keyWord"
@ -25,33 +26,35 @@
<div class="close-icon" @click="tableVisible = false">
<CloseOutlined />
</div>
<BasicTable @register="registerTable">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: '定位',
onClick: posData.bind(null, record),
},
{
label: '编辑',
onClick: editData.bind(null, record),
},
{
label: '查看',
onClick: viewData.bind(null, record),
},
{
label: '删除',
color: 'error',
onClick: delData.bind(null, record),
},
]"
/>
<div class="table-content">
<BasicTable @register="registerTable" @change="handleTableChange">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: '定位',
onClick: posData.bind(null, record),
},
{
label: '编辑',
onClick: editData.bind(null, record),
},
{
label: '查看',
onClick: viewData.bind(null, record),
},
{
label: '删除',
color: 'error',
onClick: delData.bind(null, record),
},
]"
/>
</template>
</template>
</template>
</BasicTable>
</BasicTable>
</div>
</div>
<!-- 详情 -->
<div class="data-detail" v-if="showTable == 'detail'">
@ -157,13 +160,13 @@
:destroyOnClose="true"
style="top: 50px"
>
<BatchProcessingModal @changeBatchProcessingModal="changeBatchProcessingModal"/>
<BatchProcessingModal @changeBatchProcessingModal="changeBatchProcessingModal" />
</a-modal>
</PageWrapper>
</template>
<script setup lang="ts">
import { LayerTree, AddModel, Map, EditorModel } from './page';
import { ref, UnwrapRef, reactive } from 'vue';
import { ref, UnwrapRef, reactive, onMounted } from 'vue';
import { PageWrapper } from '@/components/Page';
import { useModal } from '@/components/Modal';
import { CloseOutlined, InboxOutlined } from '@ant-design/icons-vue';
@ -183,16 +186,16 @@
const selectVal = ref();
const columnVal = ref(1);
const fileList = ref([]);
const batchProcessingModalOpen = ref(false)
const batchProcessingModalOpen = ref(false);
const [registerAddModal, { openModal: openAddModal }] = useModal();
const [registerEditorModal, { openModal: openEditorModal }] = useModal();
const keyWord = ref('');
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys, setTableData }] = useTable({
//
title: '数据列表',
//
api: getRoleListByPage,
dataSource: [],
// BasicColumn[]
columns,
rowKey: 'id',
@ -220,6 +223,7 @@
fixed: undefined,
},
});
const treeRef = ref();
const treeData = ref();
const formRef = ref();
@ -273,11 +277,9 @@
};
const handleSelect = (record) => {
console.log(record);
tableVisible.value = true;
};
const editLayer = (node) => {
console.log(node);
treeData.value = treeRef.value.treeData;
openAddModal(true, {
node,
@ -290,14 +292,14 @@
isUpdate: false,
});
};
const handleSuccess = () => {};
const handleSuccess = () => {
treeRef.value.fetch();
};
const editData = (record) => {
console.log(record);
selectVal.value = record;
showTable.value = 'edit';
};
const viewData = (record) => {
console.log(record);
selectVal.value = record;
showTable.value = 'detail';
};
@ -322,14 +324,12 @@
showTable.value = 'style';
};
const handleChange = (info) => {
console.log(info);
fileList.value = info.fileList;
};
const fileUrl = ref('');
const fileUrlView: any = ref({});
//
const handleCustomRequest = (options) => {
console.log(options);
fileList.value = [];
const formData = new FormData();
formData.append('files', options.file);
@ -357,7 +357,6 @@
content: '取消会删除当前文件',
onOk: async () => {
fun_Delete(params).then((res) => {
console.log(res);
createMessage.success('删除成功!');
showTable.value = '';
});
@ -373,8 +372,27 @@
});
};
const changeBatchProcessingModal = (type: boolean) => {
batchProcessingModalOpen.value = type
}
batchProcessingModalOpen.value = type;
};
const searchData = reactive({
page: 1,
limit: 10,
});
const handleTableChange = (values: any) => {
console.log(values);
searchData.page = values.current;
searchData.limit = values.pageSize;
getList();
};
const getList = () => {
getRoleListByPage(searchData).then((res) => {
console.log(res);
setTableData(res.items);
});
};
onMounted(() => {
getList();
});
</script>
<style lang="less" scoped>
@ -459,9 +477,3 @@
}
}
</style>
<style>
.batch-modal-wrap .ant-modal {
transform: scale(0.75) !important;
transform-origin: center !important;
}
</style>