From 9eca03d0e7ba487df6cd3c7597af27b1912426f3 Mon Sep 17 00:00:00 2001
From: lizhi <1370025557@qq.com>
Date: Thu, 14 Jul 2022 18:07:46 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E7=AE=A1=E7=90=86=E6=87=92?=
=?UTF-8?q?=E5=8A=A0=E8=BD=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 2 +-
src/api/platform/system/controller/address.ts | 25 ++++++++---------
.../platform/system/entity/addressModel.ts | 11 +++++---
.../institution/address/AddressModal.vue | 17 ++++++++++-
src/views/institution/address/address.data.ts | 28 +++++++++----------
src/views/institution/address/index.vue | 26 ++++++++++++++---
6 files changed, 72 insertions(+), 37 deletions(-)
diff --git a/.env.development b/.env.development
index 09279ca..5be9756 100644
--- a/.env.development
+++ b/.env.development
@@ -4,7 +4,7 @@ VITE_PUBLIC_PATH = /
# 本地开发代理,可以解决跨域及多地址代理
# 如果接口地址匹配到,则会转发到http://localhost:3000,防止本地出现跨域问题
# 可以有多个,注意多个不能换行,否则代理将会失效
-VITE_PROXY = [["/api","http://192.168.3.10:9999"],["/upload","http://192.168.3.10:9999/system_proxy/system/file/upload"]]
+VITE_PROXY = [["/api","http://localhost:9999"],["/upload","http://localhost:9999/system_proxy/system/file/upload"]]
# 是否删除console.log
VITE_DROP_CONSOLE = false
diff --git a/src/api/platform/system/controller/address.ts b/src/api/platform/system/controller/address.ts
index 54754b4..036bffd 100644
--- a/src/api/platform/system/controller/address.ts
+++ b/src/api/platform/system/controller/address.ts
@@ -3,36 +3,35 @@
* Copyright © 2020-2022 entfrm All rights reserved.
* author entfrm开发团队-王翔
*/
-import {AddressParams,AddressItem} from '/@/api/platform/system/entity/addressModel';
+import {AddressParams, AddressItem, AddressItemListResult} from '/@/api/platform/system/entity/addressModel';
import { defHttp } from '/@/utils/http/axios';
-
+import { isEmpty } from '/@/utils/is';
enum Api {
- get = '/system_proxy/system/address',
- QueryById = '/system_proxy/system/address/query',
+
list = '/system_proxy/system/address/list',
- QueryByParentIds = '/system_proxy/system/address/queryByParentIds',
+ lazyList= '/system_proxy/system/address/lazyList',
+ get = '/system_proxy/system/address',
add = '/system_proxy/system/address/add',
edit = '/system_proxy/system/address/update',
del = '/system_proxy/system/address/remove'
}
-export const queryById = (params: { id: String }) =>
- defHttp.get({url: Api.QueryById + `/${params.id}`});
-export const treeList = (params: AddressParams) => defHttp.get({url: Api.list, params});
-export const listAddr = (params?: Partial) =>
- defHttp.get({url: Api.list, params});
+export const listAddr = (params?: Partial) => {
+ if (params?.name || params?.id || !isEmpty(params?.dateRange)) {
+ defHttp.get({url: Api.list, params});
+ } else
+ defHttp.get({url: Api.lazyList, params});
+};
+
/**新增 */
export const addAddr =(params:Partial) =>defHttp.post({url:Api.add,data:params});
/**修改 */
export const editAddr =(params:Partial) =>defHttp.put({url:Api.edit,data:params});
-export const queryByParentIds = (params) =>
- defHttp.get({url: Api.QueryByParentIds + `/${params}`});
-
/**查询详细 */
export const getAddr = (id: string) => defHttp.get({ url: `${Api.get}/${id}` });
diff --git a/src/api/platform/system/entity/addressModel.ts b/src/api/platform/system/entity/addressModel.ts
index e92ae50..b0f1b77 100644
--- a/src/api/platform/system/entity/addressModel.ts
+++ b/src/api/platform/system/entity/addressModel.ts
@@ -8,16 +8,19 @@ export type AddressParams =AddressItem & Page;
export interface AddressItem extends CommonEntity{
id: string;
parentId: string;
- //level?:string;
+ code: string;
sort: number;
name: string;
+
+
+
+ // level: number;
+ // lastLevel: boolean;
+ //level?:string;
// beginTime?: string;
// endTime?: string;
- code: string;
- // level: number;
- // lastLevel: boolean;
[key: string]: any
diff --git a/src/views/institution/address/AddressModal.vue b/src/views/institution/address/AddressModal.vue
index b6d3cf0..953a530 100644
--- a/src/views/institution/address/AddressModal.vue
+++ b/src/views/institution/address/AddressModal.vue
@@ -1,8 +1,10 @@
@@ -20,7 +22,7 @@
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { listAddr, addAddr, editAddr, getAddr} from '/@/api/platform/system/controller/address';
import { listToTree } from '/@/utils/helper/treeHelper';
- import {isEmpty} from '/@/utils/is';
+ import {AddressItem} from '/@/api/platform/system/entity/addressModel';
/** 通用变量统一声明区域 */
const tag = ref>('');
@@ -37,6 +39,8 @@
await resetFields();
await clearValidate();
// 处理设置数据
+
+
tag.value = data._tag;
const topAddr = { id: '0', name: '一级区域', children: [] };
topAddr.children = listToTree(await listAddr());
@@ -66,10 +70,21 @@
await setFieldsValue(await getAddr(addrId));
break;
}
+
+
+
+
+
+
+
+
+
// 尾部:设置处理后的最终配置数据
setModalProps(props);
});
+
+
/** 处理弹出框提交 */
async function handleSubmit() {
try {
diff --git a/src/views/institution/address/address.data.ts b/src/views/institution/address/address.data.ts
index 02d9f73..e166771 100644
--- a/src/views/institution/address/address.data.ts
+++ b/src/views/institution/address/address.data.ts
@@ -7,8 +7,8 @@ import {Tag} from 'ant-design-vue';
export const columns: BasicColumn[] = [
{
- title: '区域编码',
- dataIndex: 'code',
+ title: '区域ID',
+ dataIndex: 'id',
width: 50,
},
{
@@ -40,11 +40,11 @@ export const searchFormSchema: FormSchema[] = [
colProps: { span: 5 },
},
{
- field:'code',
- label:'区域编码',
+ field:'id',
+ label:'区域ID',
component:'Input',
componentProps:{
- placeholder:'请输入区域编码',
+ placeholder:'请输入区域ID',
},
colProps:{span:5}
},
@@ -67,7 +67,7 @@ export const addressFormSchema: FormSchema[] = [
// field: 'parentId',
// label: '地区',
// component: 'ApiTreeSelect',
- // //component: 'TreeSelect',
+ // //component: 'TreeSelect',
// //defaultValue:'一级区域',
// componentProps: {
// api: treeList,
@@ -95,7 +95,7 @@ export const addressFormSchema: FormSchema[] = [
key: 'id',
value: 'id',
},
-
+
getPopupContainer: () => document.body,
}
},
@@ -106,13 +106,13 @@ export const addressFormSchema: FormSchema[] = [
helpMessage: ['区域ID'],
required: true
},
- {
- field: 'code',
- label: '区域编码',
- component: 'Input',
- required: true,
-
- },
+ // {
+ // field: 'code',
+ // label: '区域编码',
+ // component: 'Input',
+ // required: true,
+ //
+ // },
{
field:'sort',
label:'排序',
diff --git a/src/views/institution/address/index.vue b/src/views/institution/address/index.vue
index 2bf70d6..91fbe28 100644
--- a/src/views/institution/address/index.vue
+++ b/src/views/institution/address/index.vue
@@ -1,7 +1,9 @@
-
+
listToTree(result, { id: 'id' })
+ // afterFetch: (result) => listToTree(result, { id: 'id' }),
+ searchInfo: {parentId: '0'}
});
+
+ function onExpandClick(e, info) {
+ let reqObj = {
+ parentId: info.id, // 点击的ID
+ };
+ listAddr(reqObj).then((res) => {
+ getDataSource().forEach((item) =>{ //重点,根据点击的ID相等,将children 赋值给对应的一级菜单
+ if(info.id == item.id){
+ item.children = res;
+ }
+ });
+ });
+ }
+
+
/** 新增按钮操作,行内新增与工具栏局域新增通用 */
function handleAdd(record?: Recordable) {
openModal(true,{ _tag: 'add', record });