mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-01 18:05:28 +08:00
3.7.1版本发布
This commit is contained in:
38
jeecgboot-vue3/src/utils/areaData/pcaUtils.ts
Normal file
38
jeecgboot-vue3/src/utils/areaData/pcaUtils.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import {areaList} from '@vant/area-data'
|
||||
import {freezeDeep} from "@/utils/common/compUtils";
|
||||
|
||||
// 扁平化的省市区数据
|
||||
export const pcaa = freezeDeep(usePlatPcaaData())
|
||||
|
||||
/**
|
||||
* 获取扁平化的省市区数据
|
||||
*/
|
||||
function usePlatPcaaData() {
|
||||
const {city_list: city, county_list: county, province_list: province} = areaList;
|
||||
const dataMap = new Map<string, Recordable>()
|
||||
const flatData: Recordable = {'86': province}
|
||||
// 省
|
||||
Object.keys(province).forEach((code) => {
|
||||
flatData[code] = {}
|
||||
dataMap.set(code.slice(0, 2), flatData[code])
|
||||
})
|
||||
// 市区
|
||||
Object.keys(city).forEach((code) => {
|
||||
flatData[code] = {}
|
||||
dataMap.set(code.slice(0, 4), flatData[code])
|
||||
// 填充上一级
|
||||
const getProvince = dataMap.get(code.slice(0, 2))
|
||||
if (getProvince) {
|
||||
getProvince[code] = city[code]
|
||||
}
|
||||
});
|
||||
// 县
|
||||
Object.keys(county).forEach((code) => {
|
||||
// 填充上一级
|
||||
const getCity = dataMap.get(code.slice(0, 4))
|
||||
if (getCity) {
|
||||
getCity[code] = county[code]
|
||||
}
|
||||
});
|
||||
return flatData
|
||||
}
|
||||
@ -5,6 +5,7 @@ import { FormSchema } from '/@/components/Form';
|
||||
import { reactive } from "vue";
|
||||
import { getTenantId, getToken } from "/@/utils/auth";
|
||||
import { useUserStoreWithOut } from "/@/store/modules/user";
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { Modal } from "ant-design-vue";
|
||||
import { defHttp } from "@/utils/http/axios";
|
||||
@ -416,6 +417,14 @@ export function getUserInfoByExpression(expression) {
|
||||
if (!expression) {
|
||||
return expression;
|
||||
}
|
||||
// 当前日期
|
||||
if (expression === 'sys_date' || expression === 'sysDate') {
|
||||
return dayjs().format('YYYY-MM-DD');
|
||||
}
|
||||
// 当前时间
|
||||
if (expression === 'sys_time' || expression === 'sysTime') {
|
||||
return dayjs().format('HH:mm:ss');
|
||||
}
|
||||
const userStore = useUserStoreWithOut();
|
||||
let userInfo = userStore.getUserInfo;
|
||||
if (userInfo) {
|
||||
@ -574,4 +583,23 @@ export function translateTitle(data) {
|
||||
});
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 深度冻结对象
|
||||
* @param obj Object or Array
|
||||
*/
|
||||
export function freezeDeep(obj: Recordable | Recordable[]) {
|
||||
if (obj != null) {
|
||||
if (Array.isArray(obj)) {
|
||||
obj.forEach(item => freezeDeep(item))
|
||||
} else if (typeof obj === 'object') {
|
||||
Object.values(obj).forEach(value => {
|
||||
freezeDeep(value)
|
||||
})
|
||||
}
|
||||
Object.freeze(obj)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
@ -30,8 +30,10 @@ export async function validateFormModelAndTables(validate, formData, cases, prop
|
||||
//update-end---author:wangshuai ---date:20220507 for:[VUEN-912]一对多用户组件(所有风格,单表和树没问题)保存报错--------------
|
||||
resolve(formData);
|
||||
})
|
||||
.catch(() => {
|
||||
reject({ error: VALIDATE_FAILED, index: 0 });
|
||||
//update-begin---author:wangshuai---date:2024-06-17---for:【TV360X-1064】非原生提交表单滚动校验没通过的项---
|
||||
.catch(({ errorFields }) => {
|
||||
reject({ error: VALIDATE_FAILED, index: 0, errorFields: errorFields });
|
||||
//update-end---author:wangshuai---date:2024-06-17---for:【TV360X-1064】非原生提交表单滚动校验没通过的项---
|
||||
});
|
||||
});
|
||||
Object.assign(dataMap, { formValue: values });
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router';
|
||||
import type { App, Plugin } from 'vue';
|
||||
import type { FormSchema } from "@/components/Form";
|
||||
|
||||
import { unref } from 'vue';
|
||||
import { isObject } from '/@/utils/is';
|
||||
@ -60,6 +61,7 @@ export function openWindow(url: string, opt?: { target?: TargetContext | string;
|
||||
export function getDynamicProps<T, U>(props: T): Partial<U> {
|
||||
const ret: Recordable = {};
|
||||
|
||||
// @ts-ignore
|
||||
Object.keys(props).map((key) => {
|
||||
ret[key] = unref((props as Recordable)[key]);
|
||||
});
|
||||
@ -78,10 +80,24 @@ export function getValueType(props, field) {
|
||||
let valueType = 'string';
|
||||
if (formSchema) {
|
||||
let schema = formSchema.filter((item) => item.field === field)[0];
|
||||
valueType = schema.componentProps && schema.componentProps.valueType ? schema.componentProps.valueType : valueType;
|
||||
valueType = schema && schema.componentProps && schema.componentProps.valueType ? schema.componentProps.valueType : valueType;
|
||||
}
|
||||
return valueType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单字段值数据类型
|
||||
* @param schema
|
||||
*/
|
||||
export function getValueTypeBySchema(schema: FormSchema) {
|
||||
let valueType = 'string';
|
||||
if (schema) {
|
||||
const componentProps = schema.componentProps as Recordable;
|
||||
valueType = componentProps?.valueType ? componentProps?.valueType : valueType;
|
||||
}
|
||||
return valueType;
|
||||
}
|
||||
|
||||
export function getRawRoute(route: RouteLocationNormalized): RouteLocationNormalized {
|
||||
if (!route) return route;
|
||||
const { matched, ...opt } = route;
|
||||
@ -110,6 +126,7 @@ export const withInstall = <T>(component: T, alias?: string) => {
|
||||
|
||||
const comp = component as any;
|
||||
comp.install = (app: App) => {
|
||||
// @ts-ignore
|
||||
app.component(comp.name || comp.displayName, component);
|
||||
if (alias) {
|
||||
app.config.globalProperties[alias] = component;
|
||||
@ -438,3 +455,98 @@ export const setPopContainer = (node, selector) => {
|
||||
return selector;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 2024-06-14
|
||||
* liaozhiyang
|
||||
* 根据控件显示条件
|
||||
* label、value通用,title、val给权限管理用的
|
||||
*/
|
||||
export function useConditionFilter() {
|
||||
|
||||
// 通用条件
|
||||
const commonConditionOptions = [
|
||||
{label: '为空', value: 'empty', val: 'EMPTY'},
|
||||
{label: '不为空', value: 'not_empty', val: 'NOT_EMPTY'},
|
||||
]
|
||||
|
||||
// 数值、日期
|
||||
const numberConditionOptions = [
|
||||
{ label: '等于', value: 'eq', val: '=' },
|
||||
{ label: '在...中', value: 'in', val: 'IN', title: '包含' },
|
||||
{ label: '不等于', value: 'ne', val: '!=' },
|
||||
{ label: '大于', value: 'gt', val: '>' },
|
||||
{ label: '大于等于', value: 'ge', val: '>=' },
|
||||
{ label: '小于', value: 'lt', val: '<' },
|
||||
{ label: '小于等于', value: 'le', val: '<=' },
|
||||
...commonConditionOptions,
|
||||
];
|
||||
|
||||
// 文本、密码、多行文本、富文本、markdown
|
||||
const inputConditionOptions = [
|
||||
{ label: '等于', value: 'eq', val: '=' },
|
||||
{ label: '模糊', value: 'like', val: 'LIKE' },
|
||||
{ label: '以..开始', value: 'right_like', title: '右模糊', val: 'RIGHT_LIKE' },
|
||||
{ label: '以..结尾', value: 'left_like', title: '左模糊', val: 'LEFT_LIKE' },
|
||||
{ label: '在...中', value: 'in', val: 'IN', title: '包含' },
|
||||
{ label: '不等于', value: 'ne', val: '!=' },
|
||||
...commonConditionOptions,
|
||||
];
|
||||
|
||||
// 下拉、单选、多选、开关、用户、部门、关联记录、省市区、popup、popupDict、下拉多选、下拉搜索、分类字典、自定义树
|
||||
const selectConditionOptions = [
|
||||
{ label: '等于', value: 'eq', val: '=' },
|
||||
{ label: '在...中', value: 'in', val: 'IN', title: '包含' },
|
||||
{ label: '不等于', value: 'ne', val: '!=' },
|
||||
...commonConditionOptions,
|
||||
];
|
||||
|
||||
const def = [
|
||||
{ label: '等于', value: 'eq', val: '=' },
|
||||
{ label: '模糊', value: 'like', val: 'LIKE' },
|
||||
{ label: '以..开始', value: 'right_like', title: '右模糊', val: 'RIGHT_LIKE' },
|
||||
{ label: '以..结尾', value: 'left_like', title: '左模糊', val: 'LEFT_LIKE' },
|
||||
{ label: '在...中', value: 'in', val: 'IN', title: '包含' },
|
||||
{ label: '不等于', value: 'ne', val: '!=' },
|
||||
{ label: '大于', value: 'gt', val: '>' },
|
||||
{ label: '大于等于', value: 'ge', val: '>=' },
|
||||
{ label: '小于', value: 'lt', val: '<' },
|
||||
{ label: '小于等于', value: 'le', val: '<=' },
|
||||
...commonConditionOptions,
|
||||
];
|
||||
|
||||
const filterCondition = (data) => {
|
||||
if (data.view == 'text' && data.fieldType == 'number') {
|
||||
data.view = 'number';
|
||||
}
|
||||
switch (data.view) {
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'umeditor':
|
||||
case 'markdown':
|
||||
case 'pca':
|
||||
case 'popup':
|
||||
return inputConditionOptions;
|
||||
case 'list':
|
||||
case 'radio':
|
||||
case 'checkbox':
|
||||
case 'switch':
|
||||
case 'sel_user':
|
||||
case 'sel_depart':
|
||||
case 'link_table':
|
||||
case 'popup_dict':
|
||||
case 'list_multi':
|
||||
case 'sel_search':
|
||||
case 'cat_tree':
|
||||
case 'sel_tree':
|
||||
return selectConditionOptions;
|
||||
case 'date':
|
||||
// number是虚拟的
|
||||
case 'number':
|
||||
return numberConditionOptions;
|
||||
default:
|
||||
return def;
|
||||
}
|
||||
};
|
||||
return { filterCondition };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user