代码批量prettier格式化
parent
38db7196c7
commit
6995e5e280
|
@ -30,12 +30,7 @@ export function getThemeColors(color?: string) {
|
||||||
return [...lightColors, ...modeColors];
|
return [...lightColors, ...modeColors];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateColors({
|
export function generateColors({ color = primaryColor, mixLighten, mixDarken, tinycolor }: GenerateColorsParams) {
|
||||||
color = primaryColor,
|
|
||||||
mixLighten,
|
|
||||||
mixDarken,
|
|
||||||
tinycolor,
|
|
||||||
}: GenerateColorsParams) {
|
|
||||||
const arr = new Array(19).fill(0);
|
const arr = new Array(19).fill(0);
|
||||||
const lightens = arr.map((_t, i) => {
|
const lightens = arr.map((_t, i) => {
|
||||||
return mixLighten(color, i / 5);
|
return mixLighten(color, i / 5);
|
||||||
|
@ -68,12 +63,5 @@ export function generateColors({
|
||||||
.toHexString();
|
.toHexString();
|
||||||
})
|
})
|
||||||
.filter((item) => item !== '#000000');
|
.filter((item) => item !== '#000000');
|
||||||
return [
|
return [...lightens, ...darkens, ...alphaColors, ...shortAlphaColors, ...tinycolorDarkens, ...tinycolorLightens].filter((item) => !item.includes('-'));
|
||||||
...lightens,
|
|
||||||
...darkens,
|
|
||||||
...alphaColors,
|
|
||||||
...shortAlphaColors,
|
|
||||||
...tinycolorDarkens,
|
|
||||||
...tinycolorLightens,
|
|
||||||
].filter((item) => !item.includes('-'));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,21 +51,14 @@ async function generateIcon() {
|
||||||
if (data) {
|
if (data) {
|
||||||
const { prefix } = data;
|
const { prefix } = data;
|
||||||
const isLocal = useType === 'local';
|
const isLocal = useType === 'local';
|
||||||
const icons = Object.keys(data.icons).map(
|
const icons = Object.keys(data.icons).map((item) => `${isLocal ? prefix + ':' : ''}${item}`);
|
||||||
(item) => `${isLocal ? prefix + ':' : ''}${item}`
|
|
||||||
);
|
|
||||||
|
|
||||||
await fs.writeFileSync(
|
await fs.writeFileSync(path.join(output, `icons.data.ts`), `export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`);
|
||||||
path.join(output, `icons.data.ts`),
|
|
||||||
`export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`
|
|
||||||
);
|
|
||||||
prefixSet.push(prefix);
|
prefixSet.push(prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'));
|
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'));
|
||||||
console.log(
|
console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`);
|
||||||
`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,5 @@
|
||||||
* @param env
|
* @param env
|
||||||
*/
|
*/
|
||||||
export const getConfigFileName = (env: Record<string, any>) => {
|
export const getConfigFileName = (env: Record<string, any>) => {
|
||||||
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`
|
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '');
|
||||||
.toUpperCase()
|
|
||||||
.replace(/\s/g, '');
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,10 +5,7 @@
|
||||||
import type { Plugin } from 'vite';
|
import type { Plugin } from 'vite';
|
||||||
import compressPlugin from 'vite-plugin-compression';
|
import compressPlugin from 'vite-plugin-compression';
|
||||||
|
|
||||||
export function configCompressPlugin(
|
export function configCompressPlugin(compress: 'gzip' | 'brotli' | 'none', deleteOriginFile = false): Plugin | Plugin[] {
|
||||||
compress: 'gzip' | 'brotli' | 'none',
|
|
||||||
deleteOriginFile = false
|
|
||||||
): Plugin | Plugin[] {
|
|
||||||
const compressList = compress.split(',');
|
const compressList = compress.split(',');
|
||||||
|
|
||||||
const plugins: Plugin[] = [];
|
const plugins: Plugin[] = [];
|
||||||
|
|
|
@ -15,17 +15,11 @@ import { configThemePlugin } from './theme';
|
||||||
import { configImageminPlugin } from './imagemin';
|
import { configImageminPlugin } from './imagemin';
|
||||||
import { configSvgIconsPlugin } from './svgSprite';
|
import { configSvgIconsPlugin } from './svgSprite';
|
||||||
import { configHmrPlugin } from './hmr';
|
import { configHmrPlugin } from './hmr';
|
||||||
import OptimizationPersist from 'vite-plugin-optimize-persist'
|
import OptimizationPersist from 'vite-plugin-optimize-persist';
|
||||||
import PkgConfig from 'vite-plugin-package-config'
|
import PkgConfig from 'vite-plugin-package-config';
|
||||||
|
|
||||||
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||||
const {
|
const { VITE_USE_IMAGEMIN, VITE_USE_MOCK, VITE_LEGACY, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
|
||||||
VITE_USE_IMAGEMIN,
|
|
||||||
VITE_USE_MOCK,
|
|
||||||
VITE_LEGACY,
|
|
||||||
VITE_BUILD_COMPRESS,
|
|
||||||
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE,
|
|
||||||
} = viteEnv;
|
|
||||||
|
|
||||||
const vitePlugins: (Plugin | Plugin[])[] = [
|
const vitePlugins: (Plugin | Plugin[])[] = [
|
||||||
// have to
|
// have to
|
||||||
|
@ -72,9 +66,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||||
VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
|
VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
|
||||||
|
|
||||||
// rollup-plugin-gzip
|
// rollup-plugin-gzip
|
||||||
vitePlugins.push(
|
vitePlugins.push(configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE));
|
||||||
configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE),
|
|
||||||
);
|
|
||||||
|
|
||||||
// vite-plugin-pwa
|
// vite-plugin-pwa
|
||||||
vitePlugins.push(configPwaConfig(viteEnv));
|
vitePlugins.push(configPwaConfig(viteEnv));
|
||||||
|
|
|
@ -4,13 +4,7 @@
|
||||||
*/
|
*/
|
||||||
import type { Plugin } from 'vite';
|
import type { Plugin } from 'vite';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {
|
import { viteThemePlugin, antdDarkThemePlugin, mixLighten, mixDarken, tinycolor } from 'vite-plugin-theme';
|
||||||
viteThemePlugin,
|
|
||||||
antdDarkThemePlugin,
|
|
||||||
mixLighten,
|
|
||||||
mixDarken,
|
|
||||||
tinycolor,
|
|
||||||
} from 'vite-plugin-theme';
|
|
||||||
import { getThemeColors, generateColors } from '../../config/themeConfig';
|
import { getThemeColors, generateColors } from '../../config/themeConfig';
|
||||||
import { generateModifyVars } from '../../generate/generateModifyVars';
|
import { generateModifyVars } from '../../generate/generateModifyVars';
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,7 @@ export function resultSuccess<T = Recordable>(result: T, { message = 'ok' } = {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resultPageSuccess<T = any>(
|
export function resultPageSuccess<T = any>(pageNo: number, pageSize: number, list: T[], { message = 'ok' } = {}) {
|
||||||
pageNo: number,
|
|
||||||
pageSize: number,
|
|
||||||
list: T[],
|
|
||||||
{ message = 'ok' } = {}
|
|
||||||
) {
|
|
||||||
const pageData = pagination(pageNo, pageSize, list);
|
const pageData = pagination(pageNo, pageSize, list);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -37,10 +32,7 @@ export function resultError(message = 'Request failed', { code = -1, result = nu
|
||||||
|
|
||||||
export function pagination<T = any>(pageNo: number, pageSize: number, array: T[]): T[] {
|
export function pagination<T = any>(pageNo: number, pageSize: number, array: T[]): T[] {
|
||||||
const offset = (pageNo - 1) * Number(pageSize);
|
const offset = (pageNo - 1) * Number(pageSize);
|
||||||
const ret =
|
const ret = offset + Number(pageSize) >= array.length ? array.slice(offset, array.length) : array.slice(offset, offset + Number(pageSize));
|
||||||
offset + Number(pageSize) >= array.length
|
|
||||||
? array.slice(offset, array.length)
|
|
||||||
: array.slice(offset, offset + Number(pageSize));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const userList = (() => {
|
||||||
realname: '@cname()',
|
realname: '@cname()',
|
||||||
createTime: '@datetime',
|
createTime: '@datetime',
|
||||||
remark: '@cword(10,20)',
|
remark: '@cword(10,20)',
|
||||||
avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640'
|
avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -60,7 +60,7 @@ const newRoleList = (() => {
|
||||||
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
|
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
|
||||||
roleCode: '@first',
|
roleCode: '@first',
|
||||||
createTime: '@datetime',
|
createTime: '@datetime',
|
||||||
remark: '@cword(10,20)'
|
remark: '@cword(10,20)',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -74,7 +74,7 @@ const testList = (() => {
|
||||||
orderNo: `${index + 1}`,
|
orderNo: `${index + 1}`,
|
||||||
testName: ['数据1', '数据2', '数据3', '数据4'][index],
|
testName: ['数据1', '数据2', '数据3', '数据4'][index],
|
||||||
testValue: '@first',
|
testValue: '@first',
|
||||||
createTime: '@datetime'
|
createTime: '@datetime',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -89,7 +89,7 @@ const tableDemoList = (() => {
|
||||||
orderMoney: '@natural(1000,3000)',
|
orderMoney: '@natural(1000,3000)',
|
||||||
ctype: '@natural(1,2)',
|
ctype: '@natural(1,2)',
|
||||||
content: '@cword(10,20)',
|
content: '@cword(10,20)',
|
||||||
orderDate: '@datetime'
|
orderDate: '@datetime',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -148,12 +148,7 @@ const menuList = (() => {
|
||||||
menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
|
menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
|
||||||
icon: 'ion:document',
|
icon: 'ion:document',
|
||||||
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
|
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
|
||||||
component: [
|
component: ['/dashboard/welcome/index', '/dashboard/Analysis/index', '/dashboard/workbench/index', '/dashboard/test/index'][j],
|
||||||
'/dashboard/welcome/index',
|
|
||||||
'/dashboard/Analysis/index',
|
|
||||||
'/dashboard/workbench/index',
|
|
||||||
'/dashboard/test/index',
|
|
||||||
][j],
|
|
||||||
orderNo: j + 1,
|
orderNo: j + 1,
|
||||||
createTime: '@datetime',
|
createTime: '@datetime',
|
||||||
'status|1': ['0', '1'],
|
'status|1': ['0', '1'],
|
||||||
|
@ -166,16 +161,8 @@ const menuList = (() => {
|
||||||
type: '2',
|
type: '2',
|
||||||
menuName: '按钮' + (j + 1) + '-' + (k + 1),
|
menuName: '按钮' + (j + 1) + '-' + (k + 1),
|
||||||
icon: '',
|
icon: '',
|
||||||
permission:
|
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] + ':btn' + (k + 1),
|
||||||
['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] +
|
component: ['/dashboard/welcome/index', '/dashboard/Analysis/index', '/dashboard/workbench/index', '/dashboard/test/index'][j],
|
||||||
':btn' +
|
|
||||||
(k + 1),
|
|
||||||
component: [
|
|
||||||
'/dashboard/welcome/index',
|
|
||||||
'/dashboard/Analysis/index',
|
|
||||||
'/dashboard/workbench/index',
|
|
||||||
'/dashboard/test/index',
|
|
||||||
][j],
|
|
||||||
orderNo: j + 1,
|
orderNo: j + 1,
|
||||||
createTime: '@datetime',
|
createTime: '@datetime',
|
||||||
'status|1': ['0', '1'],
|
'status|1': ['0', '1'],
|
||||||
|
|
|
@ -51,9 +51,7 @@ export default [
|
||||||
method: 'post',
|
method: 'post',
|
||||||
response: ({ body }) => {
|
response: ({ body }) => {
|
||||||
const { username, password } = body;
|
const { username, password } = body;
|
||||||
const checkUser = createFakeUserList().find(
|
const checkUser = createFakeUserList().find((item) => item.username === username && password === item.password);
|
||||||
(item) => item.username === username && password === item.password
|
|
||||||
);
|
|
||||||
if (!checkUser) {
|
if (!checkUser) {
|
||||||
return resultError('Incorrect account or password!');
|
return resultError('Incorrect account or password!');
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,6 @@
|
||||||
"vue-print-nb-jeecg/src/printarea",
|
"vue-print-nb-jeecg/src/printarea",
|
||||||
"vue-router",
|
"vue-router",
|
||||||
"vue-types",
|
"vue-types",
|
||||||
"vuedraggable",
|
|
||||||
"vxe-table",
|
"vxe-table",
|
||||||
"vxe-table-plugin-antd",
|
"vxe-table-plugin-antd",
|
||||||
"xe-utils",
|
"xe-utils",
|
||||||
|
|
|
@ -49,50 +49,49 @@ export const getRoleList = (params) => {
|
||||||
*/
|
*/
|
||||||
export const queryDepartTreeSync = (params?) => {
|
export const queryDepartTreeSync = (params?) => {
|
||||||
return defHttp.get({ url: Api.queryDepartTreeSync, params });
|
return defHttp.get({ url: Api.queryDepartTreeSync, params });
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* 获取部门树列表
|
* 获取部门树列表
|
||||||
*/
|
*/
|
||||||
export const queryTreeList = (params?) => {
|
export const queryTreeList = (params?) => {
|
||||||
return defHttp.get({ url: Api.queryTreeList, params });
|
return defHttp.get({ url: Api.queryTreeList, params });
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分类字典树控件 加载节点
|
* 分类字典树控件 加载节点
|
||||||
*/
|
*/
|
||||||
export const loadTreeData = (params?) => {
|
export const loadTreeData = (params?) => {
|
||||||
return defHttp.get({ url: Api.loadTreeData, params });
|
return defHttp.get({ url: Api.loadTreeData, params });
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字典code加载字典text
|
* 根据字典code加载字典text
|
||||||
*/
|
*/
|
||||||
export const loadDictItem = (params?) => {
|
export const loadDictItem = (params?) => {
|
||||||
return defHttp.get({ url: Api.loadDictItem, params });
|
return defHttp.get({ url: Api.loadDictItem, params });
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字典code加载字典text
|
* 根据字典code加载字典text
|
||||||
*/
|
*/
|
||||||
export const getDictItems = (dictCode) => {
|
export const getDictItems = (dictCode) => {
|
||||||
return defHttp.get({ url: Api.getDictItems + dictCode }, { joinTime: false });
|
return defHttp.get({ url: Api.getDictItems + dictCode }, { joinTime: false });
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* 部门用户modal选择列表加载list
|
* 部门用户modal选择列表加载list
|
||||||
*/
|
*/
|
||||||
export const getTableList = (params) => {
|
export const getTableList = (params) => {
|
||||||
return defHttp.get({url:Api.getTableList,params})
|
return defHttp.get({ url: Api.getTableList, params });
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* 加载全部分类字典数据
|
* 加载全部分类字典数据
|
||||||
*/
|
*/
|
||||||
export const loadCategoryData = (params) => {
|
export const loadCategoryData = (params) => {
|
||||||
return defHttp.get({url:Api.getCategoryData,params})
|
return defHttp.get({ url: Api.getCategoryData, params });
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* 文件上传
|
* 文件上传
|
||||||
*/
|
*/
|
||||||
export const uploadFile = (params, success) => {
|
export const uploadFile = (params, success) => {
|
||||||
return defHttp.uploadFile({url:uploadUrl}, params,{success})
|
return defHttp.uploadFile({ url: uploadUrl }, params, { success });
|
||||||
}
|
};
|
||||||
|
|
|
@ -7,5 +7,4 @@ enum Api {
|
||||||
/**
|
/**
|
||||||
* @description: Get sample options value
|
* @description: Get sample options value
|
||||||
*/
|
*/
|
||||||
export const optionsListApi = (params?: selectParams) =>
|
export const optionsListApi = (params?: selectParams) => defHttp.get<DemoOptionsItem[]>({ url: Api.OPTIONS_LIST, params });
|
||||||
defHttp.get<DemoOptionsItem[]>({ url: Api.OPTIONS_LIST, params });
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
AccountListGetResultModel,
|
AccountListGetResultModel,
|
||||||
RolePageListGetResultModel,
|
RolePageListGetResultModel,
|
||||||
RoleListGetResultModel,
|
RoleListGetResultModel,
|
||||||
TestListGetResultModel
|
TestListGetResultModel,
|
||||||
} from './model/systemModel';
|
} from './model/systemModel';
|
||||||
import { defHttp } from '/@/utils/http/axios';
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
|
||||||
|
@ -26,29 +26,20 @@ enum Api {
|
||||||
GetAllRoleList = '/mock/system/getAllRoleList',
|
GetAllRoleList = '/mock/system/getAllRoleList',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getAccountList = (params: AccountParams) =>
|
export const getAccountList = (params: AccountParams) => defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });
|
||||||
defHttp.get<AccountListGetResultModel>({url: Api.AccountList, params});
|
|
||||||
|
|
||||||
export const getDeptList = (params?: DeptListItem) =>
|
export const getDeptList = (params?: DeptListItem) => defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });
|
||||||
defHttp.get<DeptListGetResultModel>({url: Api.DeptList, params});
|
|
||||||
|
|
||||||
export const getMenuList = (params?: MenuParams) =>
|
export const getMenuList = (params?: MenuParams) => defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });
|
||||||
defHttp.get<MenuListGetResultModel>({url: Api.MenuList, params});
|
|
||||||
|
|
||||||
export const getRoleListByPage = (params?: RolePageParams) =>
|
export const getRoleListByPage = (params?: RolePageParams) => defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
|
||||||
defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params});
|
|
||||||
|
|
||||||
export const getAllRoleList = (params?: RoleParams) =>
|
export const getAllRoleList = (params?: RoleParams) => defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
|
||||||
defHttp.get<RoleListGetResultModel>({url: Api.GetAllRoleList, params});
|
|
||||||
|
|
||||||
export const setRoleStatus = (id: number, status: string) =>
|
export const setRoleStatus = (id: number, status: string) => defHttp.post({ url: Api.setRoleStatus, params: { id, status } });
|
||||||
defHttp.post({url: Api.setRoleStatus, params: {id, status}});
|
|
||||||
|
|
||||||
export const getTestListByPage = (params?: TestPageParams) =>
|
export const getTestListByPage = (params?: TestPageParams) => defHttp.get<TestListGetResultModel>({ url: Api.TestPageList, params });
|
||||||
defHttp.get<TestListGetResultModel>({url: Api.TestPageList, params});
|
|
||||||
|
|
||||||
export const getDemoTableListByPage = (params) =>
|
export const getDemoTableListByPage = (params) => defHttp.get({ url: Api.DemoTableList, params });
|
||||||
defHttp.get({url: Api.DemoTableList, params});
|
|
||||||
|
|
||||||
export const isAccountExist = (account: string) =>
|
export const isAccountExist = (account: string) => defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });
|
||||||
defHttp.post({url: Api.IsAccountExist, params: {account}}, {errorMessageMode: 'none'});
|
|
||||||
|
|
|
@ -7,5 +7,4 @@ enum Api {
|
||||||
/**
|
/**
|
||||||
* @description: Get sample options value
|
* @description: Get sample options value
|
||||||
*/
|
*/
|
||||||
export const treeOptionsListApi = (params?: Recordable) =>
|
export const treeOptionsListApi = (params?: Recordable) => defHttp.get<Recordable[]>({ url: Api.TREE_OPTIONS_LIST, params });
|
||||||
defHttp.get<Recordable[]>({ url: Api.TREE_OPTIONS_LIST, params });
|
|
||||||
|
|
|
@ -12,12 +12,12 @@ enum Api {
|
||||||
export const getMenuList = () => {
|
export const getMenuList = () => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
//为了兼容mock和接口数据
|
//为了兼容mock和接口数据
|
||||||
defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList }).then(res=>{
|
defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList }).then((res) => {
|
||||||
if (Array.isArray(res)) {
|
if (Array.isArray(res)) {
|
||||||
resolve(res)
|
resolve(res);
|
||||||
} else {
|
} else {
|
||||||
resolve(res['menu'])
|
resolve(res['menu']);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,10 +8,7 @@ const { uploadUrl = '' } = useGlobSetting();
|
||||||
/**
|
/**
|
||||||
* @description: Upload interface
|
* @description: Upload interface
|
||||||
*/
|
*/
|
||||||
export function uploadApi(
|
export function uploadApi(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
|
||||||
params: UploadFileParams,
|
|
||||||
onUploadProgress: (progressEvent: ProgressEvent) => void
|
|
||||||
) {
|
|
||||||
return defHttp.uploadFile<UploadApiResult>(
|
return defHttp.uploadFile<UploadApiResult>(
|
||||||
{
|
{
|
||||||
url: uploadUrl,
|
url: uploadUrl,
|
||||||
|
@ -23,15 +20,13 @@ export function uploadApi(
|
||||||
/**
|
/**
|
||||||
* @description: Upload interface
|
* @description: Upload interface
|
||||||
*/
|
*/
|
||||||
export function uploadImg(
|
export function uploadImg(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
|
||||||
params: UploadFileParams,
|
|
||||||
onUploadProgress: (progressEvent: ProgressEvent) => void
|
|
||||||
) {
|
|
||||||
return defHttp.uploadFile<UploadApiResult>(
|
return defHttp.uploadFile<UploadApiResult>(
|
||||||
{
|
{
|
||||||
url: `${uploadUrl}/sys/common/upload`,
|
url: `${uploadUrl}/sys/common/upload`,
|
||||||
onUploadProgress,
|
onUploadProgress,
|
||||||
},
|
},
|
||||||
params, {isReturnResponse:true}
|
params,
|
||||||
|
{ isReturnResponse: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,15 @@ import { defHttp } from '/@/utils/http/axios';
|
||||||
import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userModel';
|
import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userModel';
|
||||||
|
|
||||||
import { ErrorMessageMode } from '/#/axios';
|
import { ErrorMessageMode } from '/#/axios';
|
||||||
import {useMessage} from "/@/hooks/web/useMessage";
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import {useUserStoreWithOut} from "/@/store/modules/user";
|
import { useUserStoreWithOut } from '/@/store/modules/user';
|
||||||
import {setAuthCache} from "/@/utils/auth";
|
import { setAuthCache } from '/@/utils/auth';
|
||||||
import {TOKEN_KEY} from "/@/enums/cacheEnum";
|
import { TOKEN_KEY } from '/@/enums/cacheEnum';
|
||||||
import {router} from "/@/router";
|
import { router } from '/@/router';
|
||||||
import {PageEnum} from "/@/enums/pageEnum";
|
import { PageEnum } from '/@/enums/pageEnum';
|
||||||
|
|
||||||
const { createErrorModal } = useMessage();
|
const { createErrorModal } = useMessage();
|
||||||
enum Api {
|
enum Api {
|
||||||
|
|
||||||
Login = '/sys/login',
|
Login = '/sys/login',
|
||||||
phoneLogin = '/sys/phoneLogin',
|
phoneLogin = '/sys/phoneLogin',
|
||||||
Logout = '/sys/logout',
|
Logout = '/sys/logout',
|
||||||
|
@ -101,7 +100,7 @@ export function doLogout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCodeInfo(currdatetime) {
|
export function getCodeInfo(currdatetime) {
|
||||||
let url = Api.getInputCode+`/${currdatetime}`
|
let url = Api.getInputCode + `/${currdatetime}`;
|
||||||
return defHttp.get({ url: url });
|
return defHttp.get({ url: url });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -109,43 +108,40 @@ export function getCodeInfo(currdatetime) {
|
||||||
*/
|
*/
|
||||||
export function getCaptcha(params) {
|
export function getCaptcha(params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
defHttp.post({url:Api.getCaptcha,params},{isTransformResponse: false}).then(res=>{
|
defHttp.post({ url: Api.getCaptcha, params }, { isTransformResponse: false }).then((res) => {
|
||||||
console.log(res)
|
console.log(res);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
resolve(true)
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
|
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
|
||||||
reject()
|
reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 注册接口
|
* @description: 注册接口
|
||||||
*/
|
*/
|
||||||
export function register(params) {
|
export function register(params) {
|
||||||
return defHttp.post({url: Api.registerApi,params},{isReturnNativeResponse: true})
|
return defHttp.post({ url: Api.registerApi, params }, { isReturnNativeResponse: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*校验用户是否存在
|
*校验用户是否存在
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const checkOnlyUser = (params) =>
|
export const checkOnlyUser = (params) => defHttp.get({ url: Api.checkOnlyUser, params }, { isTransformResponse: false });
|
||||||
defHttp.get({url: Api.checkOnlyUser, params},{isTransformResponse:false});
|
|
||||||
/**
|
/**
|
||||||
*校验手机号码
|
*校验手机号码
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const phoneVerify = (params) =>
|
export const phoneVerify = (params) => defHttp.post({ url: Api.phoneVerify, params }, { isTransformResponse: false });
|
||||||
defHttp.post({url: Api.phoneVerify, params},{isTransformResponse:false});
|
|
||||||
/**
|
/**
|
||||||
*密码修改
|
*密码修改
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
export const passwordChange = (params) =>
|
export const passwordChange = (params) => defHttp.get({ url: Api.passwordChange, params }, { isTransformResponse: false });
|
||||||
defHttp.get({url: Api.passwordChange, params},{isTransformResponse:false});
|
|
||||||
/**
|
/**
|
||||||
* @description: 第三方登录
|
* @description: 第三方登录
|
||||||
*/
|
*/
|
||||||
|
@ -164,23 +160,23 @@ export function thirdLogin(params, mode: ErrorMessageMode = 'modal') {
|
||||||
*/
|
*/
|
||||||
export function setThirdCaptcha(params) {
|
export function setThirdCaptcha(params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
defHttp.post({url:Api.getThirdCaptcha,params},{isTransformResponse: false}).then(res=>{
|
defHttp.post({ url: Api.getThirdCaptcha, params }, { isTransformResponse: false }).then((res) => {
|
||||||
console.log(res)
|
console.log(res);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
resolve(true)
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
|
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
|
||||||
reject()
|
reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录二维码信息
|
* 获取登录二维码信息
|
||||||
*/
|
*/
|
||||||
export function getLoginQrcode() {
|
export function getLoginQrcode() {
|
||||||
let url = Api.getLoginQrcode
|
let url = Api.getLoginQrcode;
|
||||||
return defHttp.get({ url: url });
|
return defHttp.get({ url: url });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +184,7 @@ export function getLoginQrcode() {
|
||||||
* 监控扫码状态
|
* 监控扫码状态
|
||||||
*/
|
*/
|
||||||
export function getQrcodeToken(params) {
|
export function getQrcodeToken(params) {
|
||||||
let url = Api.getQrcodeToken
|
let url = Api.getQrcodeToken;
|
||||||
return defHttp.get({ url: url, params });
|
return defHttp.get({ url: url, params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +192,6 @@ export function getQrcodeToken(params) {
|
||||||
* SSO登录校验
|
* SSO登录校验
|
||||||
*/
|
*/
|
||||||
export async function validateCasLogin(params) {
|
export async function validateCasLogin(params) {
|
||||||
let url = Api.validateCasLogin
|
let url = Api.validateCasLogin;
|
||||||
return defHttp.get({ url: url, params });
|
return defHttp.get({ url: url, params });
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.area-select:active {
|
.area-select:active {
|
||||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||||
}
|
}
|
||||||
|
@ -96,12 +95,12 @@
|
||||||
top: 50%;
|
top: 50%;
|
||||||
margin-top: -2px;
|
margin-top: -2px;
|
||||||
right: 6px;
|
right: 6px;
|
||||||
content: "";
|
content: '';
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
border: 6px solid transparent;
|
border: 6px solid transparent;
|
||||||
border-top-color: rgba(0, 0, 0, 0.25);
|
border-top-color: rgba(0, 0, 0, 0.25);
|
||||||
transition: all .3s linear;
|
transition: all 0.3s linear;
|
||||||
transform-origin: center;
|
transform-origin: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +222,7 @@
|
||||||
top: 50%;
|
top: 50%;
|
||||||
margin-top: -4px;
|
margin-top: -4px;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
content: "";
|
content: '';
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
border: 4px solid transparent;
|
border: 4px solid transparent;
|
||||||
|
|
|
@ -3,14 +3,7 @@
|
||||||
* @Description: Multi-language switching component
|
* @Description: Multi-language switching component
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<Dropdown
|
<Dropdown placement="bottomCenter" :trigger="['click']" :dropMenuList="localeList" :selectedKeys="selectedKeys" @menuEvent="handleMenuEvent" overlayClassName="app-locale-picker-overlay">
|
||||||
placement="bottomCenter"
|
|
||||||
:trigger="['click']"
|
|
||||||
:dropMenuList="localeList"
|
|
||||||
:selectedKeys="selectedKeys"
|
|
||||||
@menuEvent="handleMenuEvent"
|
|
||||||
overlayClassName="app-locale-picker-overlay"
|
|
||||||
>
|
|
||||||
<span class="cursor-pointer flex items-center">
|
<span class="cursor-pointer flex items-center">
|
||||||
<Icon icon="ion:language" />
|
<Icon icon="ion:language" />
|
||||||
<span v-if="showText" class="ml-1">{{ getLocaleText }}</span>
|
<span v-if="showText" class="ml-1">{{ getLocaleText }}</span>
|
||||||
|
|
|
@ -40,11 +40,7 @@
|
||||||
const { title } = useGlobSetting();
|
const { title } = useGlobSetting();
|
||||||
const go = useGo();
|
const go = useGo();
|
||||||
|
|
||||||
const getAppLogoClass = computed(() => [
|
const getAppLogoClass = computed(() => [prefixCls, props.theme, { 'collapsed-show-title': unref(getCollapsedShowTitle) }]);
|
||||||
prefixCls,
|
|
||||||
props.theme,
|
|
||||||
{ 'collapsed-show-title': unref(getCollapsedShowTitle) },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const getTitleClass = computed(() => [
|
const getTitleClass = computed(() => [
|
||||||
`${prefixCls}__title`,
|
`${prefixCls}__title`,
|
||||||
|
|
|
@ -45,12 +45,7 @@
|
||||||
if (!unref(isSetState)) {
|
if (!unref(isSetState)) {
|
||||||
isSetState.value = true;
|
isSetState.value = true;
|
||||||
const {
|
const {
|
||||||
menuSetting: {
|
menuSetting: { type: menuType, mode: menuMode, collapsed: menuCollapsed, split: menuSplit },
|
||||||
type: menuType,
|
|
||||||
mode: menuMode,
|
|
||||||
collapsed: menuCollapsed,
|
|
||||||
split: menuSplit,
|
|
||||||
},
|
|
||||||
} = appStore.getProjectConfig;
|
} = appStore.getProjectConfig;
|
||||||
appStore.setProjectConfig({
|
appStore.setProjectConfig({
|
||||||
menuSetting: {
|
menuSetting: {
|
||||||
|
|
|
@ -41,8 +41,7 @@
|
||||||
margin-right: 0.4em;
|
margin-right: 0.4em;
|
||||||
background-color: linear-gradient(-225deg, #d5dbe4, #f8f8f8);
|
background-color: linear-gradient(-225deg, #d5dbe4, #f8f8f8);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
box-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff,
|
box-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff, 0 1px 2px 1px rgba(30, 35, 90, 0.4);
|
||||||
0 1px 2px 1px rgba(30, 35, 90, 0.4);
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,7 @@
|
||||||
<div :class="getClass" @click.stop v-if="visible">
|
<div :class="getClass" @click.stop v-if="visible">
|
||||||
<div :class="`${prefixCls}-content`" v-click-outside="handleClose">
|
<div :class="`${prefixCls}-content`" v-click-outside="handleClose">
|
||||||
<div :class="`${prefixCls}-input__wrapper`">
|
<div :class="`${prefixCls}-input__wrapper`">
|
||||||
<a-input
|
<a-input :class="`${prefixCls}-input`" :placeholder="t('common.searchText')" ref="inputRef" allow-clear @change="handleSearch">
|
||||||
:class="`${prefixCls}-input`"
|
|
||||||
:placeholder="t('common.searchText')"
|
|
||||||
ref="inputRef"
|
|
||||||
allow-clear
|
|
||||||
@change="handleSearch"
|
|
||||||
>
|
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<SearchOutlined />
|
<SearchOutlined />
|
||||||
</template>
|
</template>
|
||||||
|
@ -84,8 +78,7 @@
|
||||||
const [refs, setRefs] = useRefs();
|
const [refs, setRefs] = useRefs();
|
||||||
const { getIsMobile } = useAppInject();
|
const { getIsMobile } = useAppInject();
|
||||||
|
|
||||||
const { handleSearch, searchResult, keyword, activeIndex, handleEnter, handleMouseenter } =
|
const { handleSearch, searchResult, keyword, activeIndex, handleEnter, handleMouseenter } = useMenuSearch(refs, scrollWrap, emit);
|
||||||
useMenuSearch(refs, scrollWrap, emit);
|
|
||||||
|
|
||||||
const getIsNotData = computed(() => !keyword || unref(searchResult).length === 0);
|
const getIsNotData = computed(() => !keyword || unref(searchResult).length === 0);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>,
|
||||||
const filterMenu = filter(menuList, (item) => {
|
const filterMenu = filter(menuList, (item) => {
|
||||||
// 【issues/33】包含子菜单时,不添加到搜索队列
|
// 【issues/33】包含子菜单时,不添加到搜索队列
|
||||||
if (Array.isArray(item.children)) {
|
if (Array.isArray(item.children)) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
return reg.test(item.name) && !item.hideMenu;
|
return reg.test(item.name) && !item.hideMenu;
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,9 +46,7 @@
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const { prefixCls } = useDesign('basic-help');
|
const { prefixCls } = useDesign('basic-help');
|
||||||
|
|
||||||
const getTooltipStyle = computed(
|
const getTooltipStyle = computed((): CSSProperties => ({ color: props.color, fontSize: props.fontSize }));
|
||||||
(): CSSProperties => ({ color: props.color, fontSize: props.fontSize })
|
|
||||||
);
|
|
||||||
|
|
||||||
const getOverlayStyle = computed((): CSSProperties => ({ maxWidth: props.maxWidth }));
|
const getOverlayStyle = computed((): CSSProperties => ({ maxWidth: props.maxWidth }));
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,7 @@
|
||||||
|
|
||||||
const { prefixCls } = useDesign('basic-title');
|
const { prefixCls } = useDesign('basic-title');
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
const getClass = computed(() => [
|
const getClass = computed(() => [prefixCls, { [`${prefixCls}-show-span`]: props.span && slots.default }, { [`${prefixCls}-normal`]: props.normal }]);
|
||||||
prefixCls,
|
|
||||||
{ [`${prefixCls}-show-span`]: props.span && slots.default },
|
|
||||||
{ [`${prefixCls}-normal`]: props.normal },
|
|
||||||
]);
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@prefix-cls: ~'@{namespace}-basic-title';
|
@prefix-cls: ~'@{namespace}-basic-title';
|
||||||
|
|
|
@ -5,23 +5,12 @@
|
||||||
</div>
|
</div>
|
||||||
{{ sliderProp.width }}
|
{{ sliderProp.width }}
|
||||||
<div class="bg-white p-2">
|
<div class="bg-white p-2">
|
||||||
<List
|
<List :grid="{ gutter: 5, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: grid }" :data-source="data" :pagination="paginationProp">
|
||||||
:grid="{ gutter: 5, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: grid }"
|
|
||||||
:data-source="data"
|
|
||||||
:pagination="paginationProp"
|
|
||||||
>
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="flex justify-end space-x-2"
|
<div class="flex justify-end space-x-2"
|
||||||
><slot name="header"></slot>
|
><slot name="header"></slot>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<template #title>
|
<template #title> <div class="w-50">每行显示数量</div><Slider id="slider" v-bind="sliderProp" v-model:value="grid" @change="sliderChange" /></template>
|
||||||
<div class="w-50">每行显示数量</div
|
|
||||||
><Slider
|
|
||||||
id="slider"
|
|
||||||
v-bind="sliderProp"
|
|
||||||
v-model:value="grid"
|
|
||||||
@change="sliderChange"
|
|
||||||
/></template>
|
|
||||||
<Button><TableOutlined /></Button>
|
<Button><TableOutlined /></Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip @click="fetch">
|
<Tooltip @click="fetch">
|
||||||
|
@ -78,12 +67,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import {
|
import { EditOutlined, EllipsisOutlined, RedoOutlined, TableOutlined } from '@ant-design/icons-vue';
|
||||||
EditOutlined,
|
|
||||||
EllipsisOutlined,
|
|
||||||
RedoOutlined,
|
|
||||||
TableOutlined,
|
|
||||||
} from '@ant-design/icons-vue';
|
|
||||||
import { List, Card, Image, Typography, Tooltip, Slider, Avatar } from 'ant-design-vue';
|
import { List, Card, Image, Typography, Tooltip, Slider, Avatar } from 'ant-design-vue';
|
||||||
import { Dropdown } from '/@/components/Dropdown';
|
import { Dropdown } from '/@/components/Dropdown';
|
||||||
import { BasicForm, useForm } from '/@/components/Form';
|
import { BasicForm, useForm } from '/@/components/Form';
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="h-full">
|
<div class="h-full">
|
||||||
<CodeMirrorEditor
|
<CodeMirrorEditor :value="getValue" @change="handleValueChange" :mode="mode" :readonly="readonly" />
|
||||||
:value="getValue"
|
|
||||||
@change="handleValueChange"
|
|
||||||
:mode="mode"
|
|
||||||
:readonly="readonly"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
function setTheme() {
|
function setTheme() {
|
||||||
unref(editor)?.setOption(
|
unref(editor)?.setOption('theme', appStore.getDarkMode === 'light' ? 'idea' : 'material-palenight');
|
||||||
'theme',
|
|
||||||
appStore.getDarkMode === 'light' ? 'idea' : 'material-palenight'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<transition-group
|
<transition-group class="h-full w-full" v-bind="$attrs" ref="elRef" :name="transitionName" :tag="tag" mode="out-in">
|
||||||
class="h-full w-full"
|
|
||||||
v-bind="$attrs"
|
|
||||||
ref="elRef"
|
|
||||||
:name="transitionName"
|
|
||||||
:tag="tag"
|
|
||||||
mode="out-in"
|
|
||||||
>
|
|
||||||
<div key="component" v-if="isInit">
|
<div key="component" v-if="isInit">
|
||||||
<slot :loading="loading"></slot>
|
<slot :loading="loading"></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -31,11 +31,7 @@
|
||||||
const ItemContent: FunctionalComponent<ItemContentProps> = (props) => {
|
const ItemContent: FunctionalComponent<ItemContentProps> = (props) => {
|
||||||
const { item } = props;
|
const { item } = props;
|
||||||
return (
|
return (
|
||||||
<span
|
<span style="display: inline-block; width: 100%; " class="px-4" onClick={props.handler.bind(null, item)}>
|
||||||
style="display: inline-block; width: 100%; "
|
|
||||||
class="px-4"
|
|
||||||
onClick={props.handler.bind(null, item)}
|
|
||||||
>
|
|
||||||
{props.showIcon && item.icon && <Icon class="mr-2" icon={item.icon} />}
|
{props.showIcon && item.icon && <Icon class="mr-2" icon={item.icon} />}
|
||||||
<span>{item.label}</span>
|
<span>{item.label}</span>
|
||||||
</span>
|
</span>
|
||||||
|
@ -124,13 +120,7 @@
|
||||||
}
|
}
|
||||||
const { items } = props;
|
const { items } = props;
|
||||||
return (
|
return (
|
||||||
<Menu
|
<Menu inlineIndent={12} mode="vertical" class={prefixCls} ref={wrapRef} style={unref(getStyle)}>
|
||||||
inlineIndent={12}
|
|
||||||
mode="vertical"
|
|
||||||
class={prefixCls}
|
|
||||||
ref={wrapRef}
|
|
||||||
style={unref(getStyle)}
|
|
||||||
>
|
|
||||||
{renderMenuItem(items)}
|
{renderMenuItem(items)}
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
@ -180,8 +170,7 @@
|
||||||
background-color: @component-background;
|
background-color: @component-background;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.1),
|
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.1), 0 1px 5px 0 rgba(0, 0, 0, 0.06);
|
||||||
0 1px 5px 0 rgba(0, 0, 0, 0.06);
|
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,7 @@
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const getButtonText = computed(() => {
|
const getButtonText = computed(() => {
|
||||||
return !unref(isStart)
|
return !unref(isStart) ? t('component.countdown.normalText') : t('component.countdown.sendText', [unref(currentCount)]);
|
||||||
? t('component.countdown.normalText')
|
|
||||||
: t('component.countdown.sendText', [unref(currentCount)]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
|
|
|
@ -1,24 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<BasicModal
|
<BasicModal v-bind="$attrs" @register="register" :title="t('component.cropper.modalTitle')" width="800px" :canFullscreen="false" @ok="handleOk" :okText="t('component.cropper.okText')">
|
||||||
v-bind="$attrs"
|
|
||||||
@register="register"
|
|
||||||
:title="t('component.cropper.modalTitle')"
|
|
||||||
width="800px"
|
|
||||||
:canFullscreen="false"
|
|
||||||
@ok="handleOk"
|
|
||||||
:okText="t('component.cropper.okText')"
|
|
||||||
>
|
|
||||||
<div :class="prefixCls">
|
<div :class="prefixCls">
|
||||||
<div :class="`${prefixCls}-left`">
|
<div :class="`${prefixCls}-left`">
|
||||||
<div :class="`${prefixCls}-cropper`">
|
<div :class="`${prefixCls}-cropper`">
|
||||||
<CropperImage
|
<CropperImage v-if="src" :src="src" height="300px" :circled="circled" @cropend="handleCropend" @ready="handleReady" />
|
||||||
v-if="src"
|
|
||||||
:src="src"
|
|
||||||
height="300px"
|
|
||||||
:circled="circled"
|
|
||||||
@cropend="handleCropend"
|
|
||||||
@ready="handleReady"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div :class="`${prefixCls}-toolbar`">
|
<div :class="`${prefixCls}-toolbar`">
|
||||||
|
@ -29,67 +14,25 @@
|
||||||
</Upload>
|
</Upload>
|
||||||
<Space>
|
<Space>
|
||||||
<Tooltip :title="t('component.cropper.btn_reset')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_reset')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="ant-design:reload-outlined" size="small" :disabled="!src" @click="handlerToolbar('reset')" />
|
||||||
type="primary"
|
|
||||||
preIcon="ant-design:reload-outlined"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('reset')"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :title="t('component.cropper.btn_rotate_left')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_rotate_left')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="ant-design:rotate-left-outlined" size="small" :disabled="!src" @click="handlerToolbar('rotate', -45)" />
|
||||||
type="primary"
|
|
||||||
preIcon="ant-design:rotate-left-outlined"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('rotate', -45)"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :title="t('component.cropper.btn_rotate_right')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_rotate_right')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="ant-design:rotate-right-outlined" size="small" :disabled="!src" @click="handlerToolbar('rotate', 45)" />
|
||||||
type="primary"
|
|
||||||
preIcon="ant-design:rotate-right-outlined"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('rotate', 45)"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :title="t('component.cropper.btn_scale_x')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_scale_x')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="vaadin:arrows-long-h" size="small" :disabled="!src" @click="handlerToolbar('scaleX')" />
|
||||||
type="primary"
|
|
||||||
preIcon="vaadin:arrows-long-h"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('scaleX')"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :title="t('component.cropper.btn_scale_y')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_scale_y')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="vaadin:arrows-long-v" size="small" :disabled="!src" @click="handlerToolbar('scaleY')" />
|
||||||
type="primary"
|
|
||||||
preIcon="vaadin:arrows-long-v"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('scaleY')"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :title="t('component.cropper.btn_zoom_in')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_zoom_in')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="ant-design:zoom-in-outlined" size="small" :disabled="!src" @click="handlerToolbar('zoom', 0.1)" />
|
||||||
type="primary"
|
|
||||||
preIcon="ant-design:zoom-in-outlined"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('zoom', 0.1)"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :title="t('component.cropper.btn_zoom_out')" placement="bottom">
|
<Tooltip :title="t('component.cropper.btn_zoom_out')" placement="bottom">
|
||||||
<a-button
|
<a-button type="primary" preIcon="ant-design:zoom-out-outlined" size="small" :disabled="!src" @click="handlerToolbar('zoom', -0.1)" />
|
||||||
type="primary"
|
|
||||||
preIcon="ant-design:zoom-out-outlined"
|
|
||||||
size="small"
|
|
||||||
:disabled="!src"
|
|
||||||
@click="handlerToolbar('zoom', -0.1)"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
|
@ -232,20 +175,8 @@
|
||||||
&-cropper {
|
&-cropper {
|
||||||
height: 300px;
|
height: 300px;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.25) 25%, transparent 0, transparent 75%, rgba(0, 0, 0, 0.25) 0),
|
||||||
45deg,
|
linear-gradient(45deg, rgba(0, 0, 0, 0.25) 25%, transparent 0, transparent 75%, rgba(0, 0, 0, 0.25) 0);
|
||||||
rgba(0, 0, 0, 0.25) 25%,
|
|
||||||
transparent 0,
|
|
||||||
transparent 75%,
|
|
||||||
rgba(0, 0, 0, 0.25) 0
|
|
||||||
),
|
|
||||||
linear-gradient(
|
|
||||||
45deg,
|
|
||||||
rgba(0, 0, 0, 0.25) 25%,
|
|
||||||
transparent 0,
|
|
||||||
transparent 75%,
|
|
||||||
rgba(0, 0, 0, 0.25) 0
|
|
||||||
);
|
|
||||||
background-position: 0 0, 12px 12px;
|
background-position: 0 0, 12px 12px;
|
||||||
background-size: 24px 24px;
|
background-size: 24px 24px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="getClass" :style="getWrapperStyle">
|
<div :class="getClass" :style="getWrapperStyle">
|
||||||
<img
|
<img v-show="isReady" ref="imgElRef" :src="src" :alt="alt" :crossorigin="crossorigin" :style="getImageStyle" />
|
||||||
v-show="isReady"
|
|
||||||
ref="imgElRef"
|
|
||||||
:src="src"
|
|
||||||
:alt="alt"
|
|
||||||
:crossorigin="crossorigin"
|
|
||||||
:style="getImageStyle"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
|
@ -2,43 +2,19 @@
|
||||||
<div :class="getClass" :style="getStyle">
|
<div :class="getClass" :style="getStyle">
|
||||||
<div :class="`${prefixCls}-image-wrapper`" :style="getImageWrapperStyle" @click="openModal">
|
<div :class="`${prefixCls}-image-wrapper`" :style="getImageWrapperStyle" @click="openModal">
|
||||||
<div :class="`${prefixCls}-image-mask`" :style="getImageWrapperStyle">
|
<div :class="`${prefixCls}-image-mask`" :style="getImageWrapperStyle">
|
||||||
<Icon
|
<Icon icon="ant-design:cloud-upload-outlined" :size="getIconWidth" :style="getImageWrapperStyle" color="#d6d6d6" />
|
||||||
icon="ant-design:cloud-upload-outlined"
|
|
||||||
:size="getIconWidth"
|
|
||||||
:style="getImageWrapperStyle"
|
|
||||||
color="#d6d6d6"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<img :src="sourceValue" v-if="sourceValue" alt="avatar" />
|
<img :src="sourceValue" v-if="sourceValue" alt="avatar" />
|
||||||
</div>
|
</div>
|
||||||
<a-button
|
<a-button :class="`${prefixCls}-upload-btn`" @click="openModal" v-if="showBtn" v-bind="btnProps">
|
||||||
:class="`${prefixCls}-upload-btn`"
|
|
||||||
@click="openModal"
|
|
||||||
v-if="showBtn"
|
|
||||||
v-bind="btnProps"
|
|
||||||
>
|
|
||||||
{{ btnText ? btnText : t('component.cropper.selectImage') }}
|
{{ btnText ? btnText : t('component.cropper.selectImage') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|
||||||
<CopperModal
|
<CopperModal @register="register" @uploadSuccess="handleUploadSuccess" :uploadApi="uploadApi" :src="sourceValue" />
|
||||||
@register="register"
|
|
||||||
@uploadSuccess="handleUploadSuccess"
|
|
||||||
:uploadApi="uploadApi"
|
|
||||||
:src="sourceValue"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { defineComponent, computed, CSSProperties, unref, ref, watchEffect, watch, PropType } from 'vue';
|
||||||
defineComponent,
|
|
||||||
computed,
|
|
||||||
CSSProperties,
|
|
||||||
unref,
|
|
||||||
ref,
|
|
||||||
watchEffect,
|
|
||||||
watch,
|
|
||||||
PropType,
|
|
||||||
} from 'vue';
|
|
||||||
import CopperModal from './CopperModal.vue';
|
import CopperModal from './CopperModal.vue';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
|
@ -76,9 +52,7 @@
|
||||||
|
|
||||||
const getStyle = computed((): CSSProperties => ({ width: unref(getWidth) }));
|
const getStyle = computed((): CSSProperties => ({ width: unref(getWidth) }));
|
||||||
|
|
||||||
const getImageWrapperStyle = computed(
|
const getImageWrapperStyle = computed((): CSSProperties => ({ width: unref(getWidth), height: unref(getWidth) }));
|
||||||
(): CSSProperties => ({ width: unref(getWidth), height: unref(getWidth) })
|
|
||||||
);
|
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
sourceValue.value = props.value || '';
|
sourceValue.value = props.value || '';
|
||||||
|
|
|
@ -12,10 +12,7 @@ export interface DescItem {
|
||||||
span?: number;
|
span?: number;
|
||||||
show?: (...arg: any) => boolean;
|
show?: (...arg: any) => boolean;
|
||||||
// render
|
// render
|
||||||
render?: (
|
render?: (val: any, data: Recordable) => VNode | undefined | JSX.Element | Element | string | number;
|
||||||
val: any,
|
|
||||||
data: Recordable
|
|
||||||
) => VNode | undefined | JSX.Element | Element | string | number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DescriptionProps extends DescriptionsProps {
|
export interface DescriptionProps extends DescriptionsProps {
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<Drawer :class="prefixCls" @close="onClose" v-bind="getBindValues">
|
<Drawer :class="prefixCls" @close="onClose" v-bind="getBindValues">
|
||||||
<template #title v-if="!$slots.title">
|
<template #title v-if="!$slots.title">
|
||||||
<DrawerHeader
|
<DrawerHeader :title="getMergeProps.title" :isDetail="isDetail" :showDetailBack="showDetailBack" @close="onClose">
|
||||||
:title="getMergeProps.title"
|
|
||||||
:isDetail="isDetail"
|
|
||||||
:showDetailBack="showDetailBack"
|
|
||||||
@close="onClose"
|
|
||||||
>
|
|
||||||
<template #titleToolbar>
|
<template #titleToolbar>
|
||||||
<slot name="titleToolbar"></slot>
|
<slot name="titleToolbar"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
@ -16,11 +11,7 @@
|
||||||
<slot name="title"></slot>
|
<slot name="title"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<ScrollContainer
|
<ScrollContainer :style="getScrollContentStyle" v-loading="getLoading" :loading-tip="loadingText || t('common.loadingText')">
|
||||||
:style="getScrollContentStyle"
|
|
||||||
v-loading="getLoading"
|
|
||||||
:loading-tip="loadingText || t('common.loadingText')"
|
|
||||||
>
|
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</ScrollContainer>
|
</ScrollContainer>
|
||||||
<DrawerFooter v-bind="getProps" @close="onClose" @ok="handleOk" :height="getFooterHeight">
|
<DrawerFooter v-bind="getProps" @close="onClose" @ok="handleOk" :height="getFooterHeight">
|
||||||
|
@ -33,16 +24,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { DrawerInstance, DrawerProps } from './typing';
|
import type { DrawerInstance, DrawerProps } from './typing';
|
||||||
import type { CSSProperties } from 'vue';
|
import type { CSSProperties } from 'vue';
|
||||||
import {
|
import { defineComponent, ref, computed, watch, unref, nextTick, toRaw, getCurrentInstance } from 'vue';
|
||||||
defineComponent,
|
|
||||||
ref,
|
|
||||||
computed,
|
|
||||||
watch,
|
|
||||||
unref,
|
|
||||||
nextTick,
|
|
||||||
toRaw,
|
|
||||||
getCurrentInstance,
|
|
||||||
} from 'vue';
|
|
||||||
import { Drawer } from 'ant-design-vue';
|
import { Drawer } from 'ant-design-vue';
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { isFunction, isNumber } from '/@/utils/is';
|
import { isFunction, isNumber } from '/@/utils/is';
|
||||||
|
@ -115,9 +97,7 @@
|
||||||
const getFooterHeight = computed(() => {
|
const getFooterHeight = computed(() => {
|
||||||
const { footerHeight, showFooter } = unref(getProps);
|
const { footerHeight, showFooter } = unref(getProps);
|
||||||
if (showFooter && footerHeight) {
|
if (showFooter && footerHeight) {
|
||||||
return isNumber(footerHeight)
|
return isNumber(footerHeight) ? `${footerHeight}px` : `${footerHeight.replace('px', '')}px`;
|
||||||
? `${footerHeight}px`
|
|
||||||
: `${footerHeight.replace('px', '')}px`;
|
|
||||||
}
|
}
|
||||||
return `0px`;
|
return `0px`;
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,14 +6,7 @@
|
||||||
{{ cancelText }}
|
{{ cancelText }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<slot name="centerFooter"></slot>
|
<slot name="centerFooter"></slot>
|
||||||
<a-button
|
<a-button :type="okType" @click="handleOk" v-bind="okButtonProps" class="mr-2" :loading="confirmLoading" v-if="showOkBtn">
|
||||||
:type="okType"
|
|
||||||
@click="handleOk"
|
|
||||||
v-bind="okButtonProps"
|
|
||||||
class="mr-2"
|
|
||||||
:loading="confirmLoading"
|
|
||||||
v-if="showOkBtn"
|
|
||||||
>
|
|
||||||
{{ okText }}
|
{{ okText }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<slot name="appendFooter"></slot>
|
<slot name="appendFooter"></slot>
|
||||||
|
|
|
@ -1,20 +1,5 @@
|
||||||
import type {
|
import type { UseDrawerReturnType, DrawerInstance, ReturnMethods, DrawerProps, UseDrawerInnerReturnType } from './typing';
|
||||||
UseDrawerReturnType,
|
import { ref, getCurrentInstance, unref, reactive, watchEffect, nextTick, toRaw, computed } from 'vue';
|
||||||
DrawerInstance,
|
|
||||||
ReturnMethods,
|
|
||||||
DrawerProps,
|
|
||||||
UseDrawerInnerReturnType,
|
|
||||||
} from './typing';
|
|
||||||
import {
|
|
||||||
ref,
|
|
||||||
getCurrentInstance,
|
|
||||||
unref,
|
|
||||||
reactive,
|
|
||||||
watchEffect,
|
|
||||||
nextTick,
|
|
||||||
toRaw,
|
|
||||||
computed,
|
|
||||||
} from 'vue';
|
|
||||||
import { isProdMode } from '/@/utils/env';
|
import { isProdMode } from '/@/utils/env';
|
||||||
import { isFunction } from '/@/utils/is';
|
import { isFunction } from '/@/utils/is';
|
||||||
import { tryOnUnmounted } from '@vueuse/core';
|
import { tryOnUnmounted } from '@vueuse/core';
|
||||||
|
|
|
@ -6,16 +6,8 @@
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<a-menu :class="[`${prefixCls}-menu`]" :selectedKeys="selectedKeys">
|
<a-menu :class="[`${prefixCls}-menu`]" :selectedKeys="selectedKeys">
|
||||||
<template v-for="item in dropMenuList" :key="`${item.event}`">
|
<template v-for="item in dropMenuList" :key="`${item.event}`">
|
||||||
<a-menu-item
|
<a-menu-item v-bind="getAttr(item.event)" @click="handleClickMenu(item)" :disabled="item.disabled" :class="[{ 'is-pop-confirm': item.popConfirm }]">
|
||||||
v-bind="getAttr(item.event)"
|
<a-popconfirm v-if="popconfirm && item.popConfirm" v-bind="getPopConfirmAttrs(item.popConfirm)">
|
||||||
@click="handleClickMenu(item)"
|
|
||||||
:disabled="item.disabled"
|
|
||||||
:class="[{'is-pop-confirm': item.popConfirm}]"
|
|
||||||
>
|
|
||||||
<a-popconfirm
|
|
||||||
v-if="popconfirm && item.popConfirm"
|
|
||||||
v-bind="getPopConfirmAttrs(item.popConfirm)"
|
|
||||||
>
|
|
||||||
<template #icon v-if="item.popConfirm.icon">
|
<template #icon v-if="item.popConfirm.icon">
|
||||||
<Icon :icon="item.popConfirm.icon" />
|
<Icon :icon="item.popConfirm.icon" />
|
||||||
</template>
|
</template>
|
||||||
|
@ -43,7 +35,7 @@
|
||||||
import { Icon } from '/@/components/Icon';
|
import { Icon } from '/@/components/Icon';
|
||||||
import { omit } from 'lodash-es';
|
import { omit } from 'lodash-es';
|
||||||
import { isFunction } from '/@/utils/is';
|
import { isFunction } from '/@/utils/is';
|
||||||
import {useDesign} from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
|
|
||||||
const ADropdown = Dropdown;
|
const ADropdown = Dropdown;
|
||||||
const AMenu = Menu;
|
const AMenu = Menu;
|
||||||
|
@ -87,10 +79,8 @@
|
||||||
const getPopConfirmAttrs = computed(() => {
|
const getPopConfirmAttrs = computed(() => {
|
||||||
return (attrs) => {
|
return (attrs) => {
|
||||||
const originAttrs = omit(attrs, ['confirm', 'cancel', 'icon']);
|
const originAttrs = omit(attrs, ['confirm', 'cancel', 'icon']);
|
||||||
if (!attrs.onConfirm && attrs.confirm && isFunction(attrs.confirm))
|
if (!attrs.onConfirm && attrs.confirm && isFunction(attrs.confirm)) originAttrs['onConfirm'] = attrs.confirm;
|
||||||
originAttrs['onConfirm'] = attrs.confirm;
|
if (!attrs.onCancel && attrs.cancel && isFunction(attrs.cancel)) originAttrs['onCancel'] = attrs.cancel;
|
||||||
if (!attrs.onCancel && attrs.cancel && isFunction(attrs.cancel))
|
|
||||||
originAttrs['onCancel'] = attrs.cancel;
|
|
||||||
return originAttrs;
|
return originAttrs;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -102,7 +92,6 @@
|
||||||
@prefix-cls: ~'@{namespace}-basic-dropdown';
|
@prefix-cls: ~'@{namespace}-basic-dropdown';
|
||||||
|
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
|
|
||||||
// update-begin--author:sunjianlei---date:20220322---for: 【VUEN-180】更多下拉菜单,只有点到字上才有效,点到空白处什么都不会发生,体验不好
|
// update-begin--author:sunjianlei---date:20220322---for: 【VUEN-180】更多下拉菜单,只有点到字上才有效,点到空白处什么都不会发生,体验不好
|
||||||
&-menu .ant-dropdown-menu-item.is-pop-confirm {
|
&-menu .ant-dropdown-menu-item.is-pop-confirm {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -112,6 +101,5 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update-end--author:sunjianlei---date:20220322---for: 【VUEN-180】更多下拉菜单,只有点到字上才有效,点到空白处什么都不会发生,体验不好
|
// update-end--author:sunjianlei---date:20220322---for: 【VUEN-180】更多下拉菜单,只有点到字上才有效,点到空白处什么都不会发生,体验不好
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -6,13 +6,7 @@ const { utils, writeFile } = xlsx;
|
||||||
|
|
||||||
const DEF_FILE_NAME = 'excel-list.xlsx';
|
const DEF_FILE_NAME = 'excel-list.xlsx';
|
||||||
|
|
||||||
export function jsonToSheetXlsx<T = any>({
|
export function jsonToSheetXlsx<T = any>({ data, header, filename = DEF_FILE_NAME, json2sheetOpts = {}, write2excelOpts = { bookType: 'xlsx' } }: JsonToSheet<T>) {
|
||||||
data,
|
|
||||||
header,
|
|
||||||
filename = DEF_FILE_NAME,
|
|
||||||
json2sheetOpts = {},
|
|
||||||
write2excelOpts = { bookType: 'xlsx' },
|
|
||||||
}: JsonToSheet<T>) {
|
|
||||||
const arrData = [...data];
|
const arrData = [...data];
|
||||||
if (header) {
|
if (header) {
|
||||||
arrData.unshift(header);
|
arrData.unshift(header);
|
||||||
|
@ -33,12 +27,7 @@ export function jsonToSheetXlsx<T = any>({
|
||||||
/* at this point, out.xlsb will have been downloaded */
|
/* at this point, out.xlsb will have been downloaded */
|
||||||
}
|
}
|
||||||
|
|
||||||
export function aoaToSheetXlsx<T = any>({
|
export function aoaToSheetXlsx<T = any>({ data, header, filename = DEF_FILE_NAME, write2excelOpts = { bookType: 'xlsx' } }: AoAToSheet<T>) {
|
||||||
data,
|
|
||||||
header,
|
|
||||||
filename = DEF_FILE_NAME,
|
|
||||||
write2excelOpts = { bookType: 'xlsx' },
|
|
||||||
}: AoAToSheet<T>) {
|
|
||||||
const arrData = [...data];
|
const arrData = [...data];
|
||||||
if (header) {
|
if (header) {
|
||||||
arrData.unshift(header);
|
arrData.unshift(header);
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<BasicModal
|
<BasicModal v-bind="$attrs" :title="t('component.excel.exportModalTitle')" @ok="handleOk" @register="registerModal">
|
||||||
v-bind="$attrs"
|
<BasicForm :labelWidth="100" :schemas="schemas" :showActionButtonGroup="false" @register="registerForm" />
|
||||||
:title="t('component.excel.exportModalTitle')"
|
|
||||||
@ok="handleOk"
|
|
||||||
@register="registerModal"
|
|
||||||
>
|
|
||||||
<BasicForm
|
|
||||||
:labelWidth="100"
|
|
||||||
:schemas="schemas"
|
|
||||||
:showActionButtonGroup="false"
|
|
||||||
@register="registerForm"
|
|
||||||
/>
|
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input ref="inputRef" type="file" v-show="false" accept=".xlsx, .xls" @change="handleInputClick" />
|
||||||
ref="inputRef"
|
|
||||||
type="file"
|
|
||||||
v-show="false"
|
|
||||||
accept=".xlsx, .xls"
|
|
||||||
@change="handleInputClick"
|
|
||||||
/>
|
|
||||||
<div @click="handleUpload">
|
<div @click="handleUpload">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,7 +19,7 @@ export { default as JCategorySelect } from './src/jeecg/components/JCategorySele
|
||||||
export { default as JSelectMultiple } from './src/jeecg/components/JSelectMultiple.vue';
|
export { default as JSelectMultiple } from './src/jeecg/components/JSelectMultiple.vue';
|
||||||
export { default as JPopup } from './src/jeecg/components/JPopup.vue';
|
export { default as JPopup } from './src/jeecg/components/JPopup.vue';
|
||||||
export { default as JAreaSelect } from './src/jeecg/components/JAreaSelect.vue';
|
export { default as JAreaSelect } from './src/jeecg/components/JAreaSelect.vue';
|
||||||
export { JEasyCron, JEasyCronInner, JEasyCronModal } from '/@/components/Form/src/jeecg/components/JEasyCron'
|
export { JEasyCron, JEasyCronInner, JEasyCronModal } from '/@/components/Form/src/jeecg/components/JEasyCron';
|
||||||
export { default as JCheckbox } from './src/jeecg/components/JCheckbox.vue';
|
export { default as JCheckbox } from './src/jeecg/components/JCheckbox.vue';
|
||||||
export { default as JInput } from './src/jeecg/components/JInput.vue';
|
export { default as JInput } from './src/jeecg/components/JInput.vue';
|
||||||
export { default as JEllipsis } from './src/jeecg/components/JEllipsis.vue';
|
export { default as JEllipsis } from './src/jeecg/components/JEllipsis.vue';
|
||||||
|
@ -30,6 +30,6 @@ export { default as JSelectUserByDept } from './src/jeecg/components/JSelectUser
|
||||||
export { default as JEditor } from './src/jeecg/components/JEditor.vue';
|
export { default as JEditor } from './src/jeecg/components/JEditor.vue';
|
||||||
export { default as JImageUpload } from './src/jeecg/components/JImageUpload.vue';
|
export { default as JImageUpload } from './src/jeecg/components/JImageUpload.vue';
|
||||||
// Jeecg自定义校验
|
// Jeecg自定义校验
|
||||||
export { JCronValidator } from '/@/components/Form/src/jeecg/components/JEasyCron'
|
export { JCronValidator } from '/@/components/Form/src/jeecg/components/JEasyCron';
|
||||||
|
|
||||||
export { BasicForm };
|
export { BasicForm };
|
||||||
|
|
|
@ -3,7 +3,15 @@
|
||||||
<Row v-bind="getRow">
|
<Row v-bind="getRow">
|
||||||
<slot name="formHeader"></slot>
|
<slot name="formHeader"></slot>
|
||||||
<template v-for="schema in getSchema" :key="schema.field">
|
<template v-for="schema in getSchema" :key="schema.field">
|
||||||
<FormItem :tableAction="tableAction" :formActionType="formActionType" :schema="schema" :formProps="getProps" :allDefaultValues="defaultValueRef" :formModel="formModel" :setFormModel="setFormModel">
|
<FormItem
|
||||||
|
:tableAction="tableAction"
|
||||||
|
:formActionType="formActionType"
|
||||||
|
:schema="schema"
|
||||||
|
:formProps="getProps"
|
||||||
|
:allDefaultValues="defaultValueRef"
|
||||||
|
:formModel="formModel"
|
||||||
|
:setFormModel="setFormModel"
|
||||||
|
>
|
||||||
<template #[item]="data" v-for="item in Object.keys($slots)">
|
<template #[item]="data" v-for="item in Object.keys($slots)">
|
||||||
<slot :name="item" v-bind="data || {}"></slot>
|
<slot :name="item" v-bind="data || {}"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
@ -93,9 +101,7 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const getBindValue = computed(
|
const getBindValue = computed(() => ({ ...attrs, ...props, ...unref(getProps) } as Recordable));
|
||||||
() => ({ ...attrs, ...props, ...unref(getProps) } as Recordable)
|
|
||||||
);
|
|
||||||
|
|
||||||
const getSchema = computed((): FormSchema[] => {
|
const getSchema = computed((): FormSchema[] => {
|
||||||
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
||||||
|
@ -144,20 +150,8 @@
|
||||||
formElRef: formElRef as Ref<FormActionType>,
|
formElRef: formElRef as Ref<FormActionType>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const { handleSubmit, setFieldsValue, clearValidate, validate, validateFields, getFieldsValue, updateSchema, resetSchema, appendSchemaByField, removeSchemaByFiled, resetFields, scrollToField } =
|
||||||
handleSubmit,
|
useFormEvents({
|
||||||
setFieldsValue,
|
|
||||||
clearValidate,
|
|
||||||
validate,
|
|
||||||
validateFields,
|
|
||||||
getFieldsValue,
|
|
||||||
updateSchema,
|
|
||||||
resetSchema,
|
|
||||||
appendSchemaByField,
|
|
||||||
removeSchemaByFiled,
|
|
||||||
resetFields,
|
|
||||||
scrollToField,
|
|
||||||
} = useFormEvents({
|
|
||||||
emit,
|
emit,
|
||||||
getProps,
|
getProps,
|
||||||
formModel,
|
formModel,
|
||||||
|
@ -267,9 +261,7 @@
|
||||||
formActionType: formActionType as any,
|
formActionType: formActionType as any,
|
||||||
setFormModel,
|
setFormModel,
|
||||||
getFormClass,
|
getFormClass,
|
||||||
getFormActionBindProps: computed(
|
getFormActionBindProps: computed((): Recordable => ({ ...getProps.value, ...advanceState })),
|
||||||
(): Recordable => ({ ...getProps.value, ...advanceState })
|
|
||||||
),
|
|
||||||
...formActionType,
|
...formActionType,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,22 +4,7 @@ import type { ComponentType } from './types/index';
|
||||||
/**
|
/**
|
||||||
* Component list, register here to setting it in the form
|
* Component list, register here to setting it in the form
|
||||||
*/
|
*/
|
||||||
import {
|
import { Input, Select, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, TreeSelect, Slider, Rate, Divider } from 'ant-design-vue';
|
||||||
Input,
|
|
||||||
Select,
|
|
||||||
Radio,
|
|
||||||
Checkbox,
|
|
||||||
AutoComplete,
|
|
||||||
Cascader,
|
|
||||||
DatePicker,
|
|
||||||
InputNumber,
|
|
||||||
Switch,
|
|
||||||
TimePicker,
|
|
||||||
TreeSelect,
|
|
||||||
Slider,
|
|
||||||
Rate,
|
|
||||||
Divider,
|
|
||||||
} from 'ant-design-vue';
|
|
||||||
import ApiRadioGroup from './components/ApiRadioGroup.vue';
|
import ApiRadioGroup from './components/ApiRadioGroup.vue';
|
||||||
import RadioButtonGroup from './components/RadioButtonGroup.vue';
|
import RadioButtonGroup from './components/RadioButtonGroup.vue';
|
||||||
import ApiSelect from './components/ApiSelect.vue';
|
import ApiSelect from './components/ApiSelect.vue';
|
||||||
|
@ -47,18 +32,18 @@ import JPopup from './jeecg/components/JPopup.vue';
|
||||||
import JSwitch from './jeecg/components/JSwitch.vue';
|
import JSwitch from './jeecg/components/JSwitch.vue';
|
||||||
import JTreeDict from './jeecg/components/JTreeDict.vue';
|
import JTreeDict from './jeecg/components/JTreeDict.vue';
|
||||||
import JInputPop from './jeecg/components/JInputPop.vue';
|
import JInputPop from './jeecg/components/JInputPop.vue';
|
||||||
import { JEasyCron } from './jeecg/components/JEasyCron'
|
import { JEasyCron } from './jeecg/components/JEasyCron';
|
||||||
import JCheckbox from './jeecg/components/JCheckbox.vue';
|
import JCheckbox from './jeecg/components/JCheckbox.vue';
|
||||||
import JInput from './jeecg/components/JInput.vue';
|
import JInput from './jeecg/components/JInput.vue';
|
||||||
import JTreeSelect from './jeecg/components/JTreeSelect.vue';
|
import JTreeSelect from './jeecg/components/JTreeSelect.vue';
|
||||||
import JEllipsis from './jeecg/components/JEllipsis.vue';
|
import JEllipsis from './jeecg/components/JEllipsis.vue';
|
||||||
import JSelectUserByDept from './jeecg/components/JSelectUserByDept.vue';
|
import JSelectUserByDept from './jeecg/components/JSelectUserByDept.vue';
|
||||||
import JUpload from './jeecg/components/JUpload/JUpload.vue'
|
import JUpload from './jeecg/components/JUpload/JUpload.vue';
|
||||||
import JSearchSelect from './jeecg/components/JSearchSelect.vue'
|
import JSearchSelect from './jeecg/components/JSearchSelect.vue';
|
||||||
import JAddInput from './jeecg/components/JAddInput.vue'
|
import JAddInput from './jeecg/components/JAddInput.vue';
|
||||||
import { Time } from '/@/components/Time';
|
import { Time } from '/@/components/Time';
|
||||||
import JOnlineSelectCascade from './jeecg/components/JOnlineSelectCascade.vue'
|
import JOnlineSelectCascade from './jeecg/components/JOnlineSelectCascade.vue';
|
||||||
import JRangeNumber from './jeecg/components/JRangeNumber.vue'
|
import JRangeNumber from './jeecg/components/JRangeNumber.vue';
|
||||||
|
|
||||||
const componentMap = new Map<ComponentType, Component>();
|
const componentMap = new Map<ComponentType, Component>();
|
||||||
|
|
||||||
|
@ -125,8 +110,8 @@ componentMap.set('JSelectUserByDept', JSelectUserByDept);
|
||||||
componentMap.set('JUpload', JUpload);
|
componentMap.set('JUpload', JUpload);
|
||||||
componentMap.set('JSearchSelect', JSearchSelect);
|
componentMap.set('JSearchSelect', JSearchSelect);
|
||||||
componentMap.set('JAddInput', JAddInput);
|
componentMap.set('JAddInput', JAddInput);
|
||||||
componentMap.set('JOnlineSelectCascade', JOnlineSelectCascade)
|
componentMap.set('JOnlineSelectCascade', JOnlineSelectCascade);
|
||||||
componentMap.set('JRangeNumber', JRangeNumber)
|
componentMap.set('JRangeNumber', JRangeNumber);
|
||||||
|
|
||||||
export function add(compName: ComponentType, component: Component) {
|
export function add(compName: ComponentType, component: Component) {
|
||||||
componentMap.set(compName, component);
|
componentMap.set(compName, component);
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
() => {
|
() => {
|
||||||
!unref(isFirstLoad) && fetch();
|
!unref(isFirstLoad) && fetch();
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Select
|
<Select @dropdownVisibleChange="handleFetch" v-bind="$attrs" @change="handleChange" :options="getOptions" v-model:value="state">
|
||||||
@dropdownVisibleChange="handleFetch"
|
|
||||||
v-bind="$attrs"
|
|
||||||
@change="handleChange"
|
|
||||||
:options="getOptions"
|
|
||||||
v-model:value="state"
|
|
||||||
>
|
|
||||||
<template #[item]="data" v-for="item in Object.keys($slots)">
|
<template #[item]="data" v-for="item in Object.keys($slots)">
|
||||||
<slot :name="item" v-bind="data || {}"></slot>
|
<slot :name="item" v-bind="data || {}"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
@ -118,7 +112,7 @@
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
//--@updateBy-begin----author:liusq---date:20210914------for:判断选择模式,multiple多选情况下的value值空的情况下需要设置为数组------
|
//--@updateBy-begin----author:liusq---date:20210914------for:判断选择模式,multiple多选情况下的value值空的情况下需要设置为数组------
|
||||||
unref(attrs).mode == 'multiple' && !Array.isArray(unref(state)) && setState([])
|
unref(attrs).mode == 'multiple' && !Array.isArray(unref(state)) && setState([]);
|
||||||
//--@updateBy-end----author:liusq---date:20210914------for:判断选择模式,multiple多选情况下的value值空的情况下需要设置为数组------
|
//--@updateBy-end----author:liusq---date:20210914------for:判断选择模式,multiple多选情况下的value值空的情况下需要设置为数组------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,7 @@
|
||||||
const actionColOpt = computed(() => {
|
const actionColOpt = computed(() => {
|
||||||
const { showAdvancedButton, actionSpan: span, actionColOptions } = props;
|
const { showAdvancedButton, actionSpan: span, actionColOptions } = props;
|
||||||
const actionSpan = 24 - span;
|
const actionSpan = 24 - span;
|
||||||
const advancedSpanObj = showAdvancedButton
|
const advancedSpanObj = showAdvancedButton ? { span: actionSpan < 6 ? 24 : actionSpan } : {};
|
||||||
? { span: actionSpan < 6 ? 24 : actionSpan }
|
|
||||||
: {};
|
|
||||||
const actionColOpt: Partial<ColEx> = {
|
const actionColOpt: Partial<ColEx> = {
|
||||||
style: { textAlign: 'right' },
|
style: { textAlign: 'right' },
|
||||||
span: showAdvancedButton ? 6 : 4,
|
span: showAdvancedButton ? 6 : 4,
|
||||||
|
|
|
@ -103,11 +103,7 @@
|
||||||
function getShow(): { isShow: boolean; isIfShow: boolean } {
|
function getShow(): { isShow: boolean; isIfShow: boolean } {
|
||||||
const { show, ifShow } = props.schema;
|
const { show, ifShow } = props.schema;
|
||||||
const { showAdvancedButton } = props.formProps;
|
const { showAdvancedButton } = props.formProps;
|
||||||
const itemIsAdvanced = showAdvancedButton
|
const itemIsAdvanced = showAdvancedButton ? (isBoolean(props.schema.isAdvanced) ? props.schema.isAdvanced : true) : true;
|
||||||
? isBoolean(props.schema.isAdvanced)
|
|
||||||
? props.schema.isAdvanced
|
|
||||||
: true
|
|
||||||
: true;
|
|
||||||
|
|
||||||
let isShow = true;
|
let isShow = true;
|
||||||
let isIfShow = true;
|
let isIfShow = true;
|
||||||
|
@ -129,14 +125,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRules(): ValidationRule[] {
|
function handleRules(): ValidationRule[] {
|
||||||
const {
|
const { rules: defRules = [], component, rulesMessageJoinLabel, label, dynamicRules, required } = props.schema;
|
||||||
rules: defRules = [],
|
|
||||||
component,
|
|
||||||
rulesMessageJoinLabel,
|
|
||||||
label,
|
|
||||||
dynamicRules,
|
|
||||||
required,
|
|
||||||
} = props.schema;
|
|
||||||
|
|
||||||
if (isFunction(dynamicRules)) {
|
if (isFunction(dynamicRules)) {
|
||||||
return dynamicRules(unref(getValues)) as ValidationRule[];
|
return dynamicRules(unref(getValues)) as ValidationRule[];
|
||||||
|
@ -145,9 +134,7 @@
|
||||||
let rules: ValidationRule[] = cloneDeep(defRules) as ValidationRule[];
|
let rules: ValidationRule[] = cloneDeep(defRules) as ValidationRule[];
|
||||||
const { rulesMessageJoinLabel: globalRulesMessageJoinLabel } = props.formProps;
|
const { rulesMessageJoinLabel: globalRulesMessageJoinLabel } = props.formProps;
|
||||||
|
|
||||||
const joinLabel = Reflect.has(props.schema, 'rulesMessageJoinLabel')
|
const joinLabel = Reflect.has(props.schema, 'rulesMessageJoinLabel') ? rulesMessageJoinLabel : globalRulesMessageJoinLabel;
|
||||||
? rulesMessageJoinLabel
|
|
||||||
: globalRulesMessageJoinLabel;
|
|
||||||
const defaultMsg = createPlaceholderMessage(component) + `${joinLabel ? label : ''}`;
|
const defaultMsg = createPlaceholderMessage(component) + `${joinLabel ? label : ''}`;
|
||||||
|
|
||||||
function validator(rule: any, value: any) {
|
function validator(rule: any, value: any) {
|
||||||
|
@ -182,9 +169,7 @@
|
||||||
rules = [{ required: getRequired, validator }];
|
rules = [{ required: getRequired, validator }];
|
||||||
}
|
}
|
||||||
|
|
||||||
const requiredRuleIndex: number = rules.findIndex(
|
const requiredRuleIndex: number = rules.findIndex((rule) => Reflect.has(rule, 'required') && !Reflect.has(rule, 'validator'));
|
||||||
(rule) => Reflect.has(rule, 'required') && !Reflect.has(rule, 'validator')
|
|
||||||
);
|
|
||||||
|
|
||||||
if (requiredRuleIndex !== -1) {
|
if (requiredRuleIndex !== -1) {
|
||||||
const rule = rules[requiredRuleIndex];
|
const rule = rules[requiredRuleIndex];
|
||||||
|
@ -210,21 +195,13 @@
|
||||||
// Maximum input length rule check
|
// Maximum input length rule check
|
||||||
const characterInx = rules.findIndex((val) => val.max);
|
const characterInx = rules.findIndex((val) => val.max);
|
||||||
if (characterInx !== -1 && !rules[characterInx].validator) {
|
if (characterInx !== -1 && !rules[characterInx].validator) {
|
||||||
rules[characterInx].message =
|
rules[characterInx].message = rules[characterInx].message || t('component.form.maxTip', [rules[characterInx].max] as Recordable);
|
||||||
rules[characterInx].message ||
|
|
||||||
t('component.form.maxTip', [rules[characterInx].max] as Recordable);
|
|
||||||
}
|
}
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderComponent() {
|
function renderComponent() {
|
||||||
const {
|
const { renderComponentContent, component, field, changeEvent = 'change', valueField } = props.schema;
|
||||||
renderComponentContent,
|
|
||||||
component,
|
|
||||||
field,
|
|
||||||
changeEvent = 'change',
|
|
||||||
valueField,
|
|
||||||
} = props.schema;
|
|
||||||
|
|
||||||
const isCheck = component && ['Switch', 'Checkbox'].includes(component);
|
const isCheck = component && ['Switch', 'Checkbox'].includes(component);
|
||||||
|
|
||||||
|
@ -256,9 +233,7 @@
|
||||||
// RangePicker place是一个数组
|
// RangePicker place是一个数组
|
||||||
if (isCreatePlaceholder && component !== 'RangePicker' && component) {
|
if (isCreatePlaceholder && component !== 'RangePicker' && component) {
|
||||||
//自动设置placeholder
|
//自动设置placeholder
|
||||||
propsData.placeholder =
|
propsData.placeholder = unref(getComponentsProps)?.placeholder || createPlaceholderMessage(component) + props.schema.label;
|
||||||
unref(getComponentsProps)?.placeholder ||
|
|
||||||
createPlaceholderMessage(component) + props.schema.label;
|
|
||||||
}
|
}
|
||||||
propsData.codeField = field;
|
propsData.codeField = field;
|
||||||
propsData.formValues = unref(getValues);
|
propsData.formValues = unref(getValues);
|
||||||
|
@ -297,9 +272,7 @@
|
||||||
) : (
|
) : (
|
||||||
label
|
label
|
||||||
);
|
);
|
||||||
const getHelpMessage = isFunction(helpMessage)
|
const getHelpMessage = isFunction(helpMessage) ? helpMessage(unref(getValues)) : helpMessage;
|
||||||
? helpMessage(unref(getValues))
|
|
||||||
: helpMessage;
|
|
||||||
if (!getHelpMessage || (Array.isArray(getHelpMessage) && getHelpMessage.length === 0)) {
|
if (!getHelpMessage || (Array.isArray(getHelpMessage) && getHelpMessage.length === 0)) {
|
||||||
return renderLabel;
|
return renderLabel;
|
||||||
}
|
}
|
||||||
|
@ -324,11 +297,7 @@
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const getContent = () => {
|
const getContent = () => {
|
||||||
return slot
|
return slot ? getSlot(slots, slot, unref(getValues)) : render ? render(unref(getValues)) : renderComponent();
|
||||||
? getSlot(slots, slot, unref(getValues))
|
|
||||||
: render
|
|
||||||
? render(unref(getValues))
|
|
||||||
: renderComponent();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const showSuffix = !!suffix;
|
const showSuffix = !!suffix;
|
||||||
|
@ -367,11 +336,7 @@
|
||||||
const values = unref(getValues);
|
const values = unref(getValues);
|
||||||
|
|
||||||
const getContent = () => {
|
const getContent = () => {
|
||||||
return colSlot
|
return colSlot ? getSlot(slots, colSlot, values) : renderColContent ? renderColContent(values) : renderItem();
|
||||||
? getSlot(slots, colSlot, values)
|
|
||||||
: renderColContent
|
|
||||||
? renderColContent(values)
|
|
||||||
: renderItem();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -16,13 +16,7 @@ export function createPlaceholderMessage(component: ComponentType) {
|
||||||
if (component.includes('Picker')) {
|
if (component.includes('Picker')) {
|
||||||
return t('common.chooseText');
|
return t('common.chooseText');
|
||||||
}
|
}
|
||||||
if (
|
if (component.includes('Select') || component.includes('Cascader') || component.includes('Checkbox') || component.includes('Radio') || component.includes('Switch')) {
|
||||||
component.includes('Select') ||
|
|
||||||
component.includes('Cascader') ||
|
|
||||||
component.includes('Checkbox') ||
|
|
||||||
component.includes('Radio') ||
|
|
||||||
component.includes('Switch')
|
|
||||||
) {
|
|
||||||
// return `请选择${label}`;
|
// return `请选择${label}`;
|
||||||
return t('common.chooseText');
|
return t('common.chooseText');
|
||||||
}
|
}
|
||||||
|
@ -35,11 +29,7 @@ function genType() {
|
||||||
return [...DATE_TYPE, 'RangePicker'];
|
return [...DATE_TYPE, 'RangePicker'];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setComponentRuleType(
|
export function setComponentRuleType(rule: ValidationRule, component: ComponentType, valueFormat: string) {
|
||||||
rule: ValidationRule,
|
|
||||||
component: ComponentType,
|
|
||||||
valueFormat: string
|
|
||||||
) {
|
|
||||||
if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component)) {
|
if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component)) {
|
||||||
rule.type = valueFormat ? 'string' : 'object';
|
rule.type = valueFormat ? 'string' : 'object';
|
||||||
} else if (['RangePicker', 'Upload', 'CheckboxGroup', 'TimePicker'].includes(component)) {
|
} else if (['RangePicker', 'Upload', 'CheckboxGroup', 'TimePicker'].includes(component)) {
|
||||||
|
|
|
@ -18,14 +18,7 @@ interface UseAdvancedContext {
|
||||||
defaultValueRef: Ref<Recordable>;
|
defaultValueRef: Ref<Recordable>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ({
|
export default function ({ advanceState, emit, getProps, getSchema, formModel, defaultValueRef }: UseAdvancedContext) {
|
||||||
advanceState,
|
|
||||||
emit,
|
|
||||||
getProps,
|
|
||||||
getSchema,
|
|
||||||
formModel,
|
|
||||||
defaultValueRef,
|
|
||||||
}: UseAdvancedContext) {
|
|
||||||
const { realWidthRef, screenEnum, screenRef } = useBreakpoint();
|
const { realWidthRef, screenEnum, screenRef } = useBreakpoint();
|
||||||
|
|
||||||
const getEmptySpan = computed((): number => {
|
const getEmptySpan = computed((): number => {
|
||||||
|
@ -64,12 +57,7 @@ export default function ({
|
||||||
function getAdvanced(itemCol: Partial<ColEx>, itemColSum = 0, isLastAction = false, index = 0) {
|
function getAdvanced(itemCol: Partial<ColEx>, itemColSum = 0, isLastAction = false, index = 0) {
|
||||||
const width = unref(realWidthRef);
|
const width = unref(realWidthRef);
|
||||||
|
|
||||||
const mdWidth =
|
const mdWidth = parseInt(itemCol.md as string) || parseInt(itemCol.xs as string) || parseInt(itemCol.sm as string) || (itemCol.span as number) || BASIC_COL_LEN;
|
||||||
parseInt(itemCol.md as string) ||
|
|
||||||
parseInt(itemCol.xs as string) ||
|
|
||||||
parseInt(itemCol.sm as string) ||
|
|
||||||
(itemCol.span as number) ||
|
|
||||||
BASIC_COL_LEN;
|
|
||||||
|
|
||||||
const lgWidth = parseInt(itemCol.lg as string) || mdWidth;
|
const lgWidth = parseInt(itemCol.lg as string) || mdWidth;
|
||||||
const xlWidth = parseInt(itemCol.xl as string) || lgWidth;
|
const xlWidth = parseInt(itemCol.xl as string) || lgWidth;
|
||||||
|
@ -84,7 +72,7 @@ export default function ({
|
||||||
itemColSum += xxlWidth;
|
itemColSum += xxlWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
let autoAdvancedCol = (unref(getProps).autoAdvancedCol ?? 3)
|
let autoAdvancedCol = unref(getProps).autoAdvancedCol ?? 3;
|
||||||
|
|
||||||
if (isLastAction) {
|
if (isLastAction) {
|
||||||
advanceState.hideAdvanceBtn = unref(getSchema).length <= autoAdvancedCol;
|
advanceState.hideAdvanceBtn = unref(getSchema).length <= autoAdvancedCol;
|
||||||
|
@ -95,10 +83,7 @@ export default function ({
|
||||||
advanceState.isAdvanced = true;
|
advanceState.isAdvanced = true;
|
||||||
} else */
|
} else */
|
||||||
// update-end--author:sunjianlei---date:20211108---for: 注释掉该逻辑,使小于等于2行时,也显示展开收起按钮
|
// update-end--author:sunjianlei---date:20211108---for: 注释掉该逻辑,使小于等于2行时,也显示展开收起按钮
|
||||||
if (
|
if (itemColSum > BASIC_COL_LEN * 2 && itemColSum <= BASIC_COL_LEN * (unref(getProps).autoAdvancedLine || 3)) {
|
||||||
itemColSum > BASIC_COL_LEN * 2 &&
|
|
||||||
itemColSum <= BASIC_COL_LEN * (unref(getProps).autoAdvancedLine || 3)
|
|
||||||
) {
|
|
||||||
advanceState.hideAdvanceBtn = false;
|
advanceState.hideAdvanceBtn = false;
|
||||||
|
|
||||||
// 默认超过 3 行折叠
|
// 默认超过 3 行折叠
|
||||||
|
@ -107,8 +92,8 @@ export default function ({
|
||||||
advanceState.isAdvanced = !advanceState.isAdvanced;
|
advanceState.isAdvanced = !advanceState.isAdvanced;
|
||||||
// update-begin--author:sunjianlei---date:20211108---for: 如果总列数大于 autoAdvancedCol,就默认折叠
|
// update-begin--author:sunjianlei---date:20211108---for: 如果总列数大于 autoAdvancedCol,就默认折叠
|
||||||
if (unref(getSchema).length > autoAdvancedCol) {
|
if (unref(getSchema).length > autoAdvancedCol) {
|
||||||
advanceState.hideAdvanceBtn = false
|
advanceState.hideAdvanceBtn = false;
|
||||||
advanceState.isAdvanced = false
|
advanceState.isAdvanced = false;
|
||||||
}
|
}
|
||||||
// update-end--author:sunjianlei---date:20211108---for: 如果总列数大于 autoAdvancedCol,就默认折叠
|
// update-end--author:sunjianlei---date:20211108---for: 如果总列数大于 autoAdvancedCol,就默认折叠
|
||||||
}
|
}
|
||||||
|
@ -116,9 +101,9 @@ export default function ({
|
||||||
}
|
}
|
||||||
if (itemColSum > BASIC_COL_LEN * (unref(getProps).alwaysShowLines || 1)) {
|
if (itemColSum > BASIC_COL_LEN * (unref(getProps).alwaysShowLines || 1)) {
|
||||||
return { isAdvanced: advanceState.isAdvanced, itemColSum };
|
return { isAdvanced: advanceState.isAdvanced, itemColSum };
|
||||||
} else if (!advanceState.isAdvanced && (index + 1) > autoAdvancedCol) {
|
} else if (!advanceState.isAdvanced && index + 1 > autoAdvancedCol) {
|
||||||
// 如果当前是收起状态,并且当前列下标 > autoAdvancedCol,就隐藏
|
// 如果当前是收起状态,并且当前列下标 > autoAdvancedCol,就隐藏
|
||||||
return { isAdvanced: false, itemColSum }
|
return { isAdvanced: false, itemColSum };
|
||||||
} else {
|
} else {
|
||||||
// The first line is always displayed
|
// The first line is always displayed
|
||||||
return { isAdvanced: true, itemColSum };
|
return { isAdvanced: true, itemColSum };
|
||||||
|
@ -130,9 +115,9 @@ export default function ({
|
||||||
let realItemColSum = 0;
|
let realItemColSum = 0;
|
||||||
const { baseColProps = {} } = unref(getProps);
|
const { baseColProps = {} } = unref(getProps);
|
||||||
|
|
||||||
const schemas = unref(getSchema)
|
const schemas = unref(getSchema);
|
||||||
for (let i = 0; i < schemas.length; i++) {
|
for (let i = 0; i < schemas.length; i++) {
|
||||||
const schema = schemas[i]
|
const schema = schemas[i];
|
||||||
const { show, colProps } = schema;
|
const { show, colProps } = schema;
|
||||||
let isShow = true;
|
let isShow = true;
|
||||||
|
|
||||||
|
@ -153,10 +138,7 @@ export default function ({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShow && (colProps || baseColProps)) {
|
if (isShow && (colProps || baseColProps)) {
|
||||||
const { itemColSum: sum, isAdvanced } = getAdvanced(
|
const { itemColSum: sum, isAdvanced } = getAdvanced({ ...baseColProps, ...colProps }, itemColSum, false, i);
|
||||||
{ ...baseColProps, ...colProps },
|
|
||||||
itemColSum, false, i,
|
|
||||||
);
|
|
||||||
|
|
||||||
itemColSum = sum || 0;
|
itemColSum = sum || 0;
|
||||||
if (isAdvanced) {
|
if (isAdvanced) {
|
||||||
|
|
|
@ -9,12 +9,7 @@ interface UseAutoFocusContext {
|
||||||
isInitedDefault: Ref<boolean>;
|
isInitedDefault: Ref<boolean>;
|
||||||
formElRef: Ref<FormActionType>;
|
formElRef: Ref<FormActionType>;
|
||||||
}
|
}
|
||||||
export async function useAutoFocus({
|
export async function useAutoFocus({ getSchema, getProps, formElRef, isInitedDefault }: UseAutoFocusContext) {
|
||||||
getSchema,
|
|
||||||
getProps,
|
|
||||||
formElRef,
|
|
||||||
isInitedDefault,
|
|
||||||
}: UseAutoFocusContext) {
|
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
if (unref(isInitedDefault) || !unref(getProps).autoFocusFirstItem) {
|
if (unref(isInitedDefault) || !unref(getProps).autoFocusFirstItem) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -18,9 +18,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
||||||
async function getForm() {
|
async function getForm() {
|
||||||
const form = unref(formRef);
|
const form = unref(formRef);
|
||||||
if (!form) {
|
if (!form) {
|
||||||
error(
|
error('The form instance has not been obtained, please make sure that the form has been rendered when performing the form operation!');
|
||||||
'The form instance has not been obtained, please make sure that the form has been rendered when performing the form operation!'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await nextTick();
|
await nextTick();
|
||||||
return form as FormActionType;
|
return form as FormActionType;
|
||||||
|
@ -94,11 +92,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
||||||
form.setFieldsValue<T>(values);
|
form.setFieldsValue<T>(values);
|
||||||
},
|
},
|
||||||
|
|
||||||
appendSchemaByField: async (
|
appendSchemaByField: async (schema: FormSchema, prefixField: string | undefined, first: boolean) => {
|
||||||
schema: FormSchema,
|
|
||||||
prefixField: string | undefined,
|
|
||||||
first: boolean
|
|
||||||
) => {
|
|
||||||
const form = await getForm();
|
const form = await getForm();
|
||||||
form.appendSchemaByField(schema, prefixField, first);
|
form.appendSchemaByField(schema, prefixField, first);
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,16 +19,7 @@ interface UseFormActionContext {
|
||||||
schemaRef: Ref<FormSchema[]>;
|
schemaRef: Ref<FormSchema[]>;
|
||||||
handleFormValues: Fn;
|
handleFormValues: Fn;
|
||||||
}
|
}
|
||||||
export function useFormEvents({
|
export function useFormEvents({ emit, getProps, formModel, getSchema, defaultValueRef, formElRef, schemaRef, handleFormValues }: UseFormActionContext) {
|
||||||
emit,
|
|
||||||
getProps,
|
|
||||||
formModel,
|
|
||||||
getSchema,
|
|
||||||
defaultValueRef,
|
|
||||||
formElRef,
|
|
||||||
schemaRef,
|
|
||||||
handleFormValues,
|
|
||||||
}: UseFormActionContext) {
|
|
||||||
async function resetFields(): Promise<void> {
|
async function resetFields(): Promise<void> {
|
||||||
const { resetFunc, submitOnReset } = unref(getProps);
|
const { resetFunc, submitOnReset } = unref(getProps);
|
||||||
resetFunc && isFunction(resetFunc) && (await resetFunc());
|
resetFunc && isFunction(resetFunc) && (await resetFunc());
|
||||||
|
@ -149,14 +140,10 @@ export function useFormEvents({
|
||||||
updateData = [...data];
|
updateData = [...data];
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasField = updateData.every(
|
const hasField = updateData.every((item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field));
|
||||||
(item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!hasField) {
|
if (!hasField) {
|
||||||
error(
|
error('All children of the form Schema array that need to be updated must contain the `field` field');
|
||||||
'All children of the form Schema array that need to be updated must contain the `field` field'
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
schemaRef.value = updateData as FormSchema[];
|
schemaRef.value = updateData as FormSchema[];
|
||||||
|
@ -171,14 +158,10 @@ export function useFormEvents({
|
||||||
updateData = [...data];
|
updateData = [...data];
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasField = updateData.every(
|
const hasField = updateData.every((item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field));
|
||||||
(item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!hasField) {
|
if (!hasField) {
|
||||||
error(
|
error('All children of the form Schema array that need to be updated must contain the `field` field');
|
||||||
'All children of the form Schema array that need to be updated must contain the `field` field'
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const schema: FormSchema[] = [];
|
const schema: FormSchema[] = [];
|
||||||
|
|
|
@ -12,12 +12,7 @@ interface UseFormValuesContext {
|
||||||
getProps: ComputedRef<FormProps>;
|
getProps: ComputedRef<FormProps>;
|
||||||
formModel: Recordable;
|
formModel: Recordable;
|
||||||
}
|
}
|
||||||
export function useFormValues({
|
export function useFormValues({ defaultValueRef, getSchema, formModel, getProps }: UseFormValuesContext) {
|
||||||
defaultValueRef,
|
|
||||||
getSchema,
|
|
||||||
formModel,
|
|
||||||
getProps,
|
|
||||||
}: UseFormValuesContext) {
|
|
||||||
// Processing form values
|
// Processing form values
|
||||||
function handleFormValues(values: Recordable) {
|
function handleFormValues(values: Recordable) {
|
||||||
if (!isObject(values)) {
|
if (!isObject(values)) {
|
||||||
|
@ -46,7 +41,6 @@ export function useFormValues({
|
||||||
return handleRangeValue(getProps, res);
|
return handleRangeValue(getProps, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function initDefault() {
|
function initDefault() {
|
||||||
const schemas = unref(getSchema);
|
const schemas = unref(getSchema);
|
||||||
const obj: Recordable = {};
|
const obj: Recordable = {};
|
||||||
|
|
|
@ -10,20 +10,16 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
|
||||||
const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {};
|
const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {};
|
||||||
const { labelWidth, disabledLabelWidth } = schemaItem;
|
const { labelWidth, disabledLabelWidth } = schemaItem;
|
||||||
|
|
||||||
const {
|
const { labelWidth: globalLabelWidth, labelCol: globalLabelCol, wrapperCol: globWrapperCol } = unref(propsRef);
|
||||||
labelWidth: globalLabelWidth,
|
|
||||||
labelCol: globalLabelCol,
|
|
||||||
wrapperCol: globWrapperCol,
|
|
||||||
} = unref(propsRef);
|
|
||||||
|
|
||||||
// update-begin--author:sunjianlei---date:20211104---for: 禁用全局 labelWidth,不自动设置 textAlign --------
|
// update-begin--author:sunjianlei---date:20211104---for: 禁用全局 labelWidth,不自动设置 textAlign --------
|
||||||
if (disabledLabelWidth) {
|
if (disabledLabelWidth) {
|
||||||
return { labelCol, wrapperCol }
|
return { labelCol, wrapperCol };
|
||||||
}
|
}
|
||||||
// update-begin--author:sunjianlei---date:20211104---for: 禁用全局 labelWidth,不自动设置 textAlign --------
|
// update-begin--author:sunjianlei---date:20211104---for: 禁用全局 labelWidth,不自动设置 textAlign --------
|
||||||
|
|
||||||
// If labelWidth is set globally, all items setting
|
// If labelWidth is set globally, all items setting
|
||||||
if ((!globalLabelWidth && !labelWidth && !globalLabelCol)) {
|
if (!globalLabelWidth && !labelWidth && !globalLabelCol) {
|
||||||
labelCol.style = {
|
labelCol.style = {
|
||||||
textAlign: 'left',
|
textAlign: 'left',
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
<div v-for="(param, index) in dynamicInput.params" :key="index" style="display: flex">
|
<div v-for="(param, index) in dynamicInput.params" :key="index" style="display: flex">
|
||||||
<a-input placeholder="请输入参数key" v-model:value="param.label" style="width: 30%; margin-bottom: 5px" @input="emitChange" />
|
<a-input placeholder="请输入参数key" v-model:value="param.label" style="width: 30%; margin-bottom: 5px" @input="emitChange" />
|
||||||
<a-input placeholder="请输入参数value" v-model:value="param.value" style="width: 30%; margin: 0 0 5px 5px" @input="emitChange" />
|
<a-input placeholder="请输入参数value" v-model:value="param.value" style="width: 30%; margin: 0 0 5px 5px" @input="emitChange" />
|
||||||
<MinusCircleOutlined
|
<MinusCircleOutlined v-if="dynamicInput.params.length > 1" class="dynamic-delete-button" @click="remove(param)" style="width: 50px"></MinusCircleOutlined>
|
||||||
v-if="dynamicInput.params.length > 1"
|
|
||||||
class="dynamic-delete-button"
|
|
||||||
@click="remove(param)"
|
|
||||||
style="width: 50px"
|
|
||||||
></MinusCircleOutlined>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a-button type="dashed" style="width: 60%" @click="add">
|
<a-button type="dashed" style="width: 60%" @click="add">
|
||||||
|
@ -20,7 +15,7 @@
|
||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
||||||
import { defineComponent, reactive, ref, UnwrapRef, watchEffect } from 'vue';
|
import { defineComponent, reactive, ref, UnwrapRef, watchEffect } from 'vue';
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { isEmpty } from '/@/utils/is'
|
import { isEmpty } from '/@/utils/is';
|
||||||
import { tryOnMounted, tryOnUnmounted } from '@vueuse/core';
|
import { tryOnMounted, tryOnUnmounted } from '@vueuse/core';
|
||||||
interface Params {
|
interface Params {
|
||||||
label: string;
|
label: string;
|
||||||
|
@ -30,7 +25,7 @@
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JAddInput',
|
name: 'JAddInput',
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.string.def('')
|
value: propTypes.string.def(''),
|
||||||
},
|
},
|
||||||
emits: ['change', 'update:value'],
|
emits: ['change', 'update:value'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
@ -42,7 +37,7 @@
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
dynamicInput.params.splice(index, 1);
|
dynamicInput.params.splice(index, 1);
|
||||||
}
|
}
|
||||||
emitChange()
|
emitChange();
|
||||||
};
|
};
|
||||||
//新增Input
|
//新增Input
|
||||||
const add = () => {
|
const add = () => {
|
||||||
|
@ -50,7 +45,7 @@
|
||||||
label: '',
|
label: '',
|
||||||
value: '',
|
value: '',
|
||||||
});
|
});
|
||||||
emitChange()
|
emitChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
//监听传入数据value
|
//监听传入数据value
|
||||||
|
@ -62,9 +57,9 @@
|
||||||
* 初始化数值
|
* 初始化数值
|
||||||
*/
|
*/
|
||||||
function initVal() {
|
function initVal() {
|
||||||
console.log("props.value",props.value)
|
console.log('props.value', props.value);
|
||||||
dynamicInput.params = [];
|
dynamicInput.params = [];
|
||||||
if(props.value && props.value.indexOf("{")==0){
|
if (props.value && props.value.indexOf('{') == 0) {
|
||||||
let jsonObj = JSON.parse(props.value);
|
let jsonObj = JSON.parse(props.value);
|
||||||
Object.keys(jsonObj).forEach((key) => {
|
Object.keys(jsonObj).forEach((key) => {
|
||||||
dynamicInput.params.push({ label: key, value: jsonObj[key] });
|
dynamicInput.params.push({ label: key, value: jsonObj[key] });
|
||||||
|
@ -77,12 +72,12 @@
|
||||||
function emitChange() {
|
function emitChange() {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
if (dynamicInput.params.length > 0) {
|
if (dynamicInput.params.length > 0) {
|
||||||
dynamicInput.params.forEach(item => {
|
dynamicInput.params.forEach((item) => {
|
||||||
obj[item['label']] = item['value']
|
obj[item['label']] = item['value'];
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
emit("change", isEmpty(obj)?'': JSON.stringify(obj));
|
emit('change', isEmpty(obj) ? '' : JSON.stringify(obj));
|
||||||
emit("update:value",isEmpty(obj)?'': JSON.stringify(obj))
|
emit('update:value', isEmpty(obj) ? '' : JSON.stringify(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,25 +4,22 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
||||||
import { Cascader } from 'ant-design-vue';
|
import { Cascader } from 'ant-design-vue';
|
||||||
import {provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus} from "../../utils/areaDataUtil";
|
import { provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus } from '../../utils/areaDataUtil';
|
||||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JAreaLinkage',
|
name: 'JAreaLinkage',
|
||||||
components: {
|
components: {
|
||||||
Cascader
|
Cascader,
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.object, propTypes.array]),
|
||||||
propTypes.object,
|
|
||||||
propTypes.array
|
|
||||||
]),
|
|
||||||
//是否显示区县
|
//是否显示区县
|
||||||
showArea: propTypes.bool.def(true),
|
showArea: propTypes.bool.def(true),
|
||||||
//是否是全部
|
//是否是全部
|
||||||
showAll:propTypes.bool.def(false)
|
showAll: propTypes.bool.def(false),
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change'],
|
emits: ['options-change', 'change'],
|
||||||
setup(props, { emit, refs }) {
|
setup(props, { emit, refs }) {
|
||||||
|
@ -31,28 +28,28 @@
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
const getOptions = computed(() => {
|
const getOptions = computed(() => {
|
||||||
if (props.showArea && props.showAll) {
|
if (props.showArea && props.showAll) {
|
||||||
return regionDataPlus
|
return regionDataPlus;
|
||||||
}
|
}
|
||||||
if (props.showArea && !props.showAll) {
|
if (props.showArea && !props.showAll) {
|
||||||
return regionData
|
return regionData;
|
||||||
}
|
}
|
||||||
if (!props.showArea && !props.showAll) {
|
if (!props.showArea && !props.showAll) {
|
||||||
return provinceAndCityData
|
return provinceAndCityData;
|
||||||
}
|
}
|
||||||
if (!props.showArea && props.showAll) {
|
if (!props.showArea && props.showAll) {
|
||||||
return provinceAndCityDataPlus
|
return provinceAndCityDataPlus;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function handleChange(_, ...args) {
|
function handleChange(_, ...args) {
|
||||||
emitData.value = args;
|
emitData.value = args;
|
||||||
console.info(emitData)
|
console.info(emitData);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
attrs,
|
attrs,
|
||||||
regionData,
|
regionData,
|
||||||
getOptions,
|
getOptions,
|
||||||
handleChange
|
handleChange,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted, onUnmounted, toRefs } from 'vue';
|
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted, onUnmounted, toRefs } from 'vue';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import {provinceOptions, getDataByCode, getRealCode} from "../../utils/areaDataUtil";
|
import { provinceOptions, getDataByCode, getRealCode } from '../../utils/areaDataUtil';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JAreaSelect',
|
name: 'JAreaSelect',
|
||||||
|
@ -66,9 +66,9 @@
|
||||||
*/
|
*/
|
||||||
watch(pca, (newVal) => {
|
watch(pca, (newVal) => {
|
||||||
if (!props.value) {
|
if (!props.value) {
|
||||||
emit("update:province",pca.province);
|
emit('update:province', pca.province);
|
||||||
emit("update:city",pca.city);
|
emit('update:city', pca.city);
|
||||||
emit("update:area",pca.area);
|
emit('update:area', pca.area);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
|
@ -102,19 +102,19 @@
|
||||||
* 省份change事件
|
* 省份change事件
|
||||||
*/
|
*/
|
||||||
function proChange(val) {
|
function proChange(val) {
|
||||||
pca.city = (val && getDataByCode(val)[0]?.value);
|
pca.city = val && getDataByCode(val)[0]?.value;
|
||||||
pca.area = (pca.city && getDataByCode(pca.city)[0]?.value);
|
pca.area = pca.city && getDataByCode(pca.city)[0]?.value;
|
||||||
state.value = props.level <= 1 ? val : (props.level <= 2 ? pca.city : pca.area);
|
state.value = props.level <= 1 ? val : props.level <= 2 ? pca.city : pca.area;
|
||||||
emit("update:value",unref(state));
|
emit('update:value', unref(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 城市change事件
|
* 城市change事件
|
||||||
*/
|
*/
|
||||||
function cityChange(val) {
|
function cityChange(val) {
|
||||||
pca.area = (val && getDataByCode(val)[0]?.value);
|
pca.area = val && getDataByCode(val)[0]?.value;
|
||||||
state.value = props.level <= 2 ? val : pca.area;
|
state.value = props.level <= 2 ? val : pca.area;
|
||||||
emit("update:value",unref(state));
|
emit('update:value', unref(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
*/
|
*/
|
||||||
function areaChange(val) {
|
function areaChange(val) {
|
||||||
state.value = val;
|
state.value = val;
|
||||||
emit("update:value",unref(state));
|
emit('update:value', unref(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
areaOptions,
|
areaOptions,
|
||||||
proChange,
|
proChange,
|
||||||
cityChange,
|
cityChange,
|
||||||
areaChange
|
areaChange,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
:value="treeValue"
|
:value="treeValue"
|
||||||
:treeData="treeData"
|
:treeData="treeData"
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
@change="onChange">
|
@change="onChange"
|
||||||
|
>
|
||||||
</a-tree-select>
|
</a-tree-select>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -28,10 +29,7 @@
|
||||||
components: {},
|
components: {},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array,
|
|
||||||
]),
|
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '请选择',
|
default: '请选择',
|
||||||
|
@ -86,14 +84,14 @@
|
||||||
() => {
|
() => {
|
||||||
loadItemByCode();
|
loadItemByCode();
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true }
|
||||||
);
|
);
|
||||||
watch(
|
watch(
|
||||||
() => props.pcode,
|
() => props.pcode,
|
||||||
() => {
|
() => {
|
||||||
loadRoot();
|
loadRoot();
|
||||||
},
|
},
|
||||||
{ deep: true, immediate: true },
|
{ deep: true, immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
function loadRoot() {
|
function loadRoot() {
|
||||||
|
@ -103,7 +101,7 @@
|
||||||
condition: props.condition,
|
condition: props.condition,
|
||||||
};
|
};
|
||||||
console.info(param);
|
console.info(param);
|
||||||
loadTreeData(param).then(res => {
|
loadTreeData(param).then((res) => {
|
||||||
for (let i of res) {
|
for (let i of res) {
|
||||||
i.value = i.key;
|
i.value = i.key;
|
||||||
if (i.leaf == false) {
|
if (i.leaf == false) {
|
||||||
|
@ -114,15 +112,13 @@
|
||||||
}
|
}
|
||||||
treeData.value = res;
|
treeData.value = res;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadItemByCode() {
|
function loadItemByCode() {
|
||||||
if (!props.value || props.value == '0') {
|
if (!props.value || props.value == '0') {
|
||||||
treeValue.value = [];
|
treeValue.value = [];
|
||||||
} else {
|
} else {
|
||||||
loadDictItem({ ids: props.value }).then(res => {
|
loadDictItem({ ids: props.value }).then((res) => {
|
||||||
let values = props.value.split(',');
|
let values = props.value.split(',');
|
||||||
treeValue.value = res.map((item, index) => ({
|
treeValue.value = res.map((item, index) => ({
|
||||||
key: values[index],
|
key: values[index],
|
||||||
|
@ -139,7 +135,6 @@
|
||||||
if (!props.multiple && props.loadTriggleChange) {
|
if (!props.multiple && props.loadTriggleChange) {
|
||||||
backValue(props.value, text);
|
backValue(props.value, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function backValue(value, label) {
|
function backValue(value, label) {
|
||||||
|
@ -163,7 +158,7 @@
|
||||||
pid: pid,
|
pid: pid,
|
||||||
condition: props.condition,
|
condition: props.condition,
|
||||||
};
|
};
|
||||||
loadTreeData(param).then(res => {
|
loadTreeData(param).then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
for (let i of res) {
|
for (let i of res) {
|
||||||
i.value = i.key;
|
i.value = i.key;
|
||||||
|
@ -204,7 +199,7 @@
|
||||||
treeValue.value = '';
|
treeValue.value = '';
|
||||||
} else if (Array.isArray(value)) {
|
} else if (Array.isArray(value)) {
|
||||||
let labels = [];
|
let labels = [];
|
||||||
let values = value.map(item => {
|
let values = value.map((item) => {
|
||||||
labels.push(item.label);
|
labels.push(item.label);
|
||||||
return item.value;
|
return item.value;
|
||||||
});
|
});
|
||||||
|
@ -251,6 +246,5 @@
|
||||||
asyncLoadTreeData,
|
asyncLoadTreeData,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, computed, watch, watchEffect, ref, unref } from 'vue';
|
import { defineComponent, computed, watch, watchEffect, ref, unref } from 'vue';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import {initDictOptions} from "/@/utils/dict/index"
|
import { initDictOptions } from '/@/utils/dict/index';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JCheckbox',
|
name: 'JCheckbox',
|
||||||
|
@ -29,10 +29,10 @@
|
||||||
* 监听value
|
* 监听value
|
||||||
*/
|
*/
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
props.value && (checkboxArray.value = props.value ? props.value.split(",") : []);
|
props.value && (checkboxArray.value = props.value ? props.value.split(',') : []);
|
||||||
//update-begin-author:taoyan date:20220401 for: 调用表单的 resetFields不会清空当前信息,界面显示上一次的数据
|
//update-begin-author:taoyan date:20220401 for: 调用表单的 resetFields不会清空当前信息,界面显示上一次的数据
|
||||||
if (props.value === '' || props.value === undefined) {
|
if (props.value === '' || props.value === undefined) {
|
||||||
checkboxArray.value = []
|
checkboxArray.value = [];
|
||||||
}
|
}
|
||||||
//update-end-author:taoyan date:20220401 for: 调用表单的 resetFields不会清空当前信息,界面显示上一次的数据
|
//update-end-author:taoyan date:20220401 for: 调用表单的 resetFields不会清空当前信息,界面显示上一次的数据
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
// 引入全局实例
|
// 引入全局实例
|
||||||
import _CodeMirror, { EditorFromTextArea } from 'codemirror'
|
import _CodeMirror, { EditorFromTextArea } from 'codemirror';
|
||||||
// 核心样式
|
// 核心样式
|
||||||
import 'codemirror/lib/codemirror.css';
|
import 'codemirror/lib/codemirror.css';
|
||||||
// 引入主题后还需要在 options 中指定主题才会生效
|
// 引入主题后还需要在 options 中指定主题才会生效
|
||||||
|
@ -29,22 +29,22 @@
|
||||||
import 'codemirror/mode/swift/swift.js';
|
import 'codemirror/mode/swift/swift.js';
|
||||||
import 'codemirror/mode/vue/vue.js';
|
import 'codemirror/mode/vue/vue.js';
|
||||||
// 折叠资源引入:开始
|
// 折叠资源引入:开始
|
||||||
import "codemirror/addon/fold/foldgutter.css";
|
import 'codemirror/addon/fold/foldgutter.css';
|
||||||
import "codemirror/addon/fold/foldcode.js";
|
import 'codemirror/addon/fold/foldcode.js';
|
||||||
import "codemirror/addon/fold/brace-fold.js";
|
import 'codemirror/addon/fold/brace-fold.js';
|
||||||
import "codemirror/addon/fold/comment-fold.js";
|
import 'codemirror/addon/fold/comment-fold.js';
|
||||||
import "codemirror/addon/fold/indent-fold.js";
|
import 'codemirror/addon/fold/indent-fold.js';
|
||||||
import "codemirror/addon/fold/foldgutter.js";
|
import 'codemirror/addon/fold/foldgutter.js';
|
||||||
// 折叠资源引入:结束
|
// 折叠资源引入:结束
|
||||||
//光标行背景高亮,配置里面也需要styleActiveLine设置为true
|
//光标行背景高亮,配置里面也需要styleActiveLine设置为true
|
||||||
import "codemirror/addon/selection/active-line.js";
|
import 'codemirror/addon/selection/active-line.js';
|
||||||
// 支持代码自动补全
|
// 支持代码自动补全
|
||||||
import "codemirror/addon/hint/show-hint.css";
|
import 'codemirror/addon/hint/show-hint.css';
|
||||||
import "codemirror/addon/hint/show-hint.js";
|
import 'codemirror/addon/hint/show-hint.js';
|
||||||
import "codemirror/addon/hint/anyword-hint.js";
|
import 'codemirror/addon/hint/anyword-hint.js';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import {useDesign} from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import {isJsonObjectString} from '/@/utils/is.ts'
|
import { isJsonObjectString } from '/@/utils/is.ts';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JCodeEditor',
|
name: 'JCodeEditor',
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
//表单值
|
//表单值
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
const textarea = ref<HTMLTextAreaElement>();
|
const textarea = ref<HTMLTextAreaElement>();
|
||||||
let coder: Nullable<EditorFromTextArea> = null
|
let coder: Nullable<EditorFromTextArea> = null;
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
const height = ref(props.height);
|
const height = ref(props.height);
|
||||||
const options = reactive({
|
const options = reactive({
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
// 启用代码折叠相关功能:开始
|
// 启用代码折叠相关功能:开始
|
||||||
foldGutter: true,
|
foldGutter: true,
|
||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"],
|
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers'],
|
||||||
// 启用代码折叠相关功能:结束
|
// 启用代码折叠相关功能:结束
|
||||||
// 光标行高亮
|
// 光标行高亮
|
||||||
styleActiveLine: true,
|
styleActiveLine: true,
|
||||||
|
@ -92,38 +92,43 @@
|
||||||
Tab: function autoFormat(editor) {
|
Tab: function autoFormat(editor) {
|
||||||
//var totalLines = editor.lineCount();
|
//var totalLines = editor.lineCount();
|
||||||
//editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
|
//editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
|
||||||
setValue(innerValue,false)
|
setValue(innerValue, false);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
let innerValue = ''
|
let innerValue = '';
|
||||||
// 全屏状态
|
// 全屏状态
|
||||||
const isFullScreen = ref(false)
|
const isFullScreen = ref(false);
|
||||||
const fullScreenIcon = computed(() => isFullScreen.value ? 'fullscreen-exit' : 'fullscreen')
|
const fullScreenIcon = computed(() => (isFullScreen.value ? 'fullscreen-exit' : 'fullscreen'));
|
||||||
// 外部盒子参数
|
// 外部盒子参数
|
||||||
const boxBindProps = computed(() => {
|
const boxBindProps = computed(() => {
|
||||||
let _props = {
|
let _props = {
|
||||||
class: [
|
class: [
|
||||||
prefixCls, 'full-screen-parent', 'auto-height',
|
prefixCls,
|
||||||
|
'full-screen-parent',
|
||||||
|
'auto-height',
|
||||||
{
|
{
|
||||||
'full-screen': isFullScreen.value,
|
'full-screen': isFullScreen.value,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
style: {},
|
style: {},
|
||||||
}
|
};
|
||||||
if (isFullScreen.value) {
|
if (isFullScreen.value) {
|
||||||
_props.style['z-index'] = props.zIndex
|
_props.style['z-index'] = props.zIndex;
|
||||||
}
|
}
|
||||||
return _props
|
return _props;
|
||||||
})
|
});
|
||||||
/**
|
/**
|
||||||
* 监听组件值
|
* 监听组件值
|
||||||
*/
|
*/
|
||||||
watch(() => props.value, () => {
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
() => {
|
||||||
if (innerValue != props.value) {
|
if (innerValue != props.value) {
|
||||||
setValue(props.value, false);
|
setValue(props.value, false);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initialize();
|
initialize();
|
||||||
});
|
});
|
||||||
|
@ -137,9 +142,9 @@
|
||||||
if (value && isJsonObjectString(value)) {
|
if (value && isJsonObjectString(value)) {
|
||||||
value = JSON.stringify(JSON.parse(value), null, 2);
|
value = JSON.stringify(JSON.parse(value), null, 2);
|
||||||
}
|
}
|
||||||
coder?.setValue(value ?? '')
|
coder?.setValue(value ?? '');
|
||||||
innerValue = value
|
innerValue = value;
|
||||||
trigger && emitChange(innerValue)
|
trigger && emitChange(innerValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
//编辑器值修改事件
|
//编辑器值修改事件
|
||||||
|
@ -147,7 +152,7 @@
|
||||||
let value = obj.getValue();
|
let value = obj.getValue();
|
||||||
innerValue = value || '';
|
innerValue = value || '';
|
||||||
if (props.value != innerValue) {
|
if (props.value != innerValue) {
|
||||||
emitChange(innerValue)
|
emitChange(innerValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,12 +167,12 @@
|
||||||
//绑定值修改事件
|
//绑定值修改事件
|
||||||
coder.on('change', onChange);
|
coder.on('change', onChange);
|
||||||
// 初始化成功时赋值一次
|
// 初始化成功时赋值一次
|
||||||
setValue(innerValue, false)
|
setValue(innerValue, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换全屏状态
|
// 切换全屏状态
|
||||||
function onToggleFullScreen() {
|
function onToggleFullScreen() {
|
||||||
isFullScreen.value = !isFullScreen.value
|
isFullScreen.value = !isFullScreen.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||||
|
@ -189,7 +194,6 @@
|
||||||
//noinspection LessUnresolvedVariable
|
//noinspection LessUnresolvedVariable
|
||||||
@prefix-cls: ~'@{namespace}-code-editer';
|
@prefix-cls: ~'@{namespace}-code-editer';
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
|
|
||||||
&.auto-height {
|
&.auto-height {
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
height: v-bind(height) !important;
|
height: v-bind(height) !important;
|
||||||
|
@ -253,7 +257,6 @@
|
||||||
.full-screen-child {
|
.full-screen-child {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -36,31 +36,27 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import {initDictOptions} from "/@/utils/dict/index"
|
import { initDictOptions } from '/@/utils/dict/index';
|
||||||
import { get, omit } from 'lodash-es';
|
import { get, omit } from 'lodash-es';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import { CompTypeEnum } from '/@/enums/CompTypeEnum.ts';
|
import { CompTypeEnum } from '/@/enums/CompTypeEnum.ts';
|
||||||
import {LoadingOutlined} from '@ant-design/icons-vue'
|
import { LoadingOutlined } from '@ant-design/icons-vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JDictSelectTag',
|
name: 'JDictSelectTag',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
components: { LoadingOutlined },
|
components: { LoadingOutlined },
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.number,
|
|
||||||
propTypes.array,
|
|
||||||
]),
|
|
||||||
dictCode: propTypes.string,
|
dictCode: propTypes.string,
|
||||||
type: propTypes.string,
|
type: propTypes.string,
|
||||||
placeholder: propTypes.string,
|
placeholder: propTypes.string,
|
||||||
stringToNumber: propTypes.bool,
|
stringToNumber: propTypes.bool,
|
||||||
getPopupContainer: {
|
getPopupContainer: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: (node) => node.parentNode
|
default: (node) => node.parentNode,
|
||||||
},
|
},
|
||||||
// 是否显示【请选择】选项
|
// 是否显示【请选择】选项
|
||||||
showChooseOption: propTypes.bool.def(true),
|
showChooseOption: propTypes.bool.def(true),
|
||||||
|
@ -68,7 +64,7 @@
|
||||||
options: {
|
options: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: [],
|
default: [],
|
||||||
required: false
|
required: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change'],
|
emits: ['options-change', 'change'],
|
||||||
|
@ -79,43 +75,44 @@
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||||
// 是否正在加载回显数据
|
// 是否正在加载回显数据
|
||||||
const loadingEcho = ref<boolean>(false)
|
const loadingEcho = ref<boolean>(false);
|
||||||
// 是否是首次加载回显,只有首次加载,才会显示 loading
|
// 是否是首次加载回显,只有首次加载,才会显示 loading
|
||||||
let isFirstLoadEcho = true
|
let isFirstLoadEcho = true;
|
||||||
|
|
||||||
//组件类型
|
//组件类型
|
||||||
const compType = computed(() => {
|
const compType = computed(() => {
|
||||||
return (!props.type || props.type === "list") ? 'select' : props.type;
|
return !props.type || props.type === 'list' ? 'select' : props.type;
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* 监听字典code
|
* 监听字典code
|
||||||
*/
|
*/
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (props.dictCode) {
|
if (props.dictCode) {
|
||||||
loadingEcho.value = isFirstLoadEcho
|
loadingEcho.value = isFirstLoadEcho;
|
||||||
isFirstLoadEcho = false
|
isFirstLoadEcho = false;
|
||||||
initDictData().finally(() => {
|
initDictData().finally(() => {
|
||||||
loadingEcho.value = isFirstLoadEcho
|
loadingEcho.value = isFirstLoadEcho;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
//update-begin-author:taoyan date: 如果没有提供dictCode 可以走options的配置--
|
//update-begin-author:taoyan date: 如果没有提供dictCode 可以走options的配置--
|
||||||
if (!props.dictCode) {
|
if (!props.dictCode) {
|
||||||
dictOptions.value = props.options
|
dictOptions.value = props.options;
|
||||||
}
|
}
|
||||||
//update-end-author:taoyan date: 如果没有提供dictCode 可以走options的配置--
|
//update-end-author:taoyan date: 如果没有提供dictCode 可以走options的配置--
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//update-begin-author:taoyan date:20220404 for: 使用useRuleFormItem定义的value,会有一个问题,如果不是操作设置的值而是代码设置的控件值而不能触发change事件
|
//update-begin-author:taoyan date:20220404 for: 使用useRuleFormItem定义的value,会有一个问题,如果不是操作设置的值而是代码设置的控件值而不能触发change事件
|
||||||
// 此处添加空值的change事件,即当组件调用地代码设置value为''也能触发change事件
|
// 此处添加空值的change事件,即当组件调用地代码设置value为''也能触发change事件
|
||||||
watch(()=>props.value, ()=>{
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
() => {
|
||||||
if (props.value === '') {
|
if (props.value === '') {
|
||||||
emit('change', '')
|
emit('change', '');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
//update-end-author:taoyan date:20220404 for: 使用useRuleFormItem定义的value,会有一个问题,如果不是操作设置的值而是代码设置的控件值而不能触发change事件
|
//update-end-author:taoyan date:20220404 for: 使用useRuleFormItem定义的value,会有一个问题,如果不是操作设置的值而是代码设置的控件值而不能触发change事件
|
||||||
|
|
||||||
|
|
||||||
async function initDictData() {
|
async function initDictData() {
|
||||||
let { dictCode, stringToNumber } = props;
|
let { dictCode, stringToNumber } = props;
|
||||||
//根据字典Code, 初始化字典数组
|
//根据字典Code, 初始化字典数组
|
||||||
|
@ -140,12 +137,12 @@
|
||||||
/** 用于搜索下拉框中的内容 */
|
/** 用于搜索下拉框中的内容 */
|
||||||
function handleFilterOption(input, option) {
|
function handleFilterOption(input, option) {
|
||||||
// 在 label 中搜索
|
// 在 label 中搜索
|
||||||
let labelIf = option?.children[0]?.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
let labelIf = option?.children[0]?.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||||
if (labelIf) {
|
if (labelIf) {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
// 在 value 中搜索
|
// 在 value 中搜索
|
||||||
return (option.value || '').toString().toLowerCase().indexOf(input.toLowerCase()) >= 0
|
return (option.value || '').toString().toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -27,44 +27,44 @@
|
||||||
<a-divider />
|
<a-divider />
|
||||||
<!-- 执行时间预览 -->
|
<!-- 执行时间预览 -->
|
||||||
<a-row :gutter="8">
|
<a-row :gutter="8">
|
||||||
<a-col :span="18" style="margin-top: 22px;">
|
<a-col :span="18" style="margin-top: 22px">
|
||||||
<a-row :gutter="8">
|
<a-row :gutter="8">
|
||||||
<a-col :span="8" style="margin-bottom: 12px;">
|
<a-col :span="8" style="margin-bottom: 12px">
|
||||||
<a-input v-model:value="inputValues.second" @blur="onInputBlur">
|
<a-input v-model:value="inputValues.second" @blur="onInputBlur">
|
||||||
<template #addonBefore>
|
<template #addonBefore>
|
||||||
<span class="allow-click" @click="activeKey = 'second'">秒</span>
|
<span class="allow-click" @click="activeKey = 'second'">秒</span>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8" style="margin-bottom: 12px;">
|
<a-col :span="8" style="margin-bottom: 12px">
|
||||||
<a-input v-model:value="inputValues.minute" @blur="onInputBlur">
|
<a-input v-model:value="inputValues.minute" @blur="onInputBlur">
|
||||||
<template #addonBefore>
|
<template #addonBefore>
|
||||||
<span class="allow-click" @click="activeKey = 'minute'">分</span>
|
<span class="allow-click" @click="activeKey = 'minute'">分</span>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8" style="margin-bottom: 12px;">
|
<a-col :span="8" style="margin-bottom: 12px">
|
||||||
<a-input v-model:value="inputValues.hour" @blur="onInputBlur">
|
<a-input v-model:value="inputValues.hour" @blur="onInputBlur">
|
||||||
<template #addonBefore>
|
<template #addonBefore>
|
||||||
<span class="allow-click" @click="activeKey = 'hour'">时</span>
|
<span class="allow-click" @click="activeKey = 'hour'">时</span>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8" style="margin-bottom: 12px;">
|
<a-col :span="8" style="margin-bottom: 12px">
|
||||||
<a-input v-model:value="inputValues.day" @blur="onInputBlur">
|
<a-input v-model:value="inputValues.day" @blur="onInputBlur">
|
||||||
<template #addonBefore>
|
<template #addonBefore>
|
||||||
<span class="allow-click" @click="activeKey = 'day'">日</span>
|
<span class="allow-click" @click="activeKey = 'day'">日</span>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8" style="margin-bottom: 12px;">
|
<a-col :span="8" style="margin-bottom: 12px">
|
||||||
<a-input v-model:value="inputValues.month" @blur="onInputBlur">
|
<a-input v-model:value="inputValues.month" @blur="onInputBlur">
|
||||||
<template #addonBefore>
|
<template #addonBefore>
|
||||||
<span class="allow-click" @click="activeKey = 'month'">月</span>
|
<span class="allow-click" @click="activeKey = 'month'">月</span>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="8" style="margin-bottom: 12px;">
|
<a-col :span="8" style="margin-bottom: 12px">
|
||||||
<a-input v-model:value="inputValues.week" @blur="onInputBlur">
|
<a-input v-model:value="inputValues.week" @blur="onInputBlur">
|
||||||
<template #addonBefore>
|
<template #addonBefore>
|
||||||
<span class="allow-click" @click="activeKey = 'week'">周</span>
|
<span class="allow-click" @click="activeKey = 'week'">周</span>
|
||||||
|
@ -97,74 +97,76 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, reactive, ref, watch, provide } from 'vue'
|
import { computed, reactive, ref, watch, provide } from 'vue';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import CronParser from 'cron-parser'
|
import CronParser from 'cron-parser';
|
||||||
import SecondUI from './tabs/SecondUI.vue'
|
import SecondUI from './tabs/SecondUI.vue';
|
||||||
import MinuteUI from './tabs/MinuteUI.vue'
|
import MinuteUI from './tabs/MinuteUI.vue';
|
||||||
import HourUI from './tabs/HourUI.vue'
|
import HourUI from './tabs/HourUI.vue';
|
||||||
import DayUI from './tabs/DayUI.vue'
|
import DayUI from './tabs/DayUI.vue';
|
||||||
import MonthUI from './tabs/MonthUI.vue'
|
import MonthUI from './tabs/MonthUI.vue';
|
||||||
import WeekUI from './tabs/WeekUI.vue'
|
import WeekUI from './tabs/WeekUI.vue';
|
||||||
import YearUI from './tabs/YearUI.vue'
|
import YearUI from './tabs/YearUI.vue';
|
||||||
import { cronEmits, cronProps } from './easy.cron.data'
|
import { cronEmits, cronProps } from './easy.cron.data';
|
||||||
import { dateFormat, simpleDebounce } from '/@/utils/common/compUtils'
|
import { dateFormat, simpleDebounce } from '/@/utils/common/compUtils';
|
||||||
|
|
||||||
const { prefixCls } = useDesign('easy-cron-inner')
|
const { prefixCls } = useDesign('easy-cron-inner');
|
||||||
provide('prefixCls', prefixCls)
|
provide('prefixCls', prefixCls);
|
||||||
const emit = defineEmits([...cronEmits])
|
const emit = defineEmits([...cronEmits]);
|
||||||
const props = defineProps({ ...cronProps })
|
const props = defineProps({ ...cronProps });
|
||||||
const activeKey = ref(props.hideSecond ? 'minute' : 'second')
|
const activeKey = ref(props.hideSecond ? 'minute' : 'second');
|
||||||
const second = ref('*')
|
const second = ref('*');
|
||||||
const minute = ref('*')
|
const minute = ref('*');
|
||||||
const hour = ref('*')
|
const hour = ref('*');
|
||||||
const day = ref('*')
|
const day = ref('*');
|
||||||
const month = ref('*')
|
const month = ref('*');
|
||||||
const week = ref('?')
|
const week = ref('?');
|
||||||
const year = ref('*')
|
const year = ref('*');
|
||||||
const inputValues = reactive({ second: '', minute: '', hour: '', day: '', month: '', week: '', year: '', cron: '' })
|
const inputValues = reactive({ second: '', minute: '', hour: '', day: '', month: '', week: '', year: '', cron: '' });
|
||||||
const preTimeList = ref('执行预览,会忽略年份参数。')
|
const preTimeList = ref('执行预览,会忽略年份参数。');
|
||||||
|
|
||||||
// cron表达式
|
// cron表达式
|
||||||
const cronValueInner = computed(() => {
|
const cronValueInner = computed(() => {
|
||||||
let result: string[] = []
|
let result: string[] = [];
|
||||||
if (!props.hideSecond) {
|
if (!props.hideSecond) {
|
||||||
result.push(second.value ? second.value : '*')
|
result.push(second.value ? second.value : '*');
|
||||||
}
|
}
|
||||||
result.push(minute.value ? minute.value : '*')
|
result.push(minute.value ? minute.value : '*');
|
||||||
result.push(hour.value ? hour.value : '*')
|
result.push(hour.value ? hour.value : '*');
|
||||||
result.push(day.value ? day.value : '*')
|
result.push(day.value ? day.value : '*');
|
||||||
result.push(month.value ? month.value : '*')
|
result.push(month.value ? month.value : '*');
|
||||||
result.push(week.value ? week.value : '?')
|
result.push(week.value ? week.value : '?');
|
||||||
if (!props.hideYear && !props.hideSecond) result.push(year.value ? year.value : '*')
|
if (!props.hideYear && !props.hideSecond) result.push(year.value ? year.value : '*');
|
||||||
return result.join(' ')
|
return result.join(' ');
|
||||||
})
|
});
|
||||||
// 不含年
|
// 不含年
|
||||||
const cronValueNoYear = computed(() => {
|
const cronValueNoYear = computed(() => {
|
||||||
const v = cronValueInner.value
|
const v = cronValueInner.value;
|
||||||
if (props.hideYear || props.hideSecond) return v
|
if (props.hideYear || props.hideSecond) return v;
|
||||||
const vs = v.split(' ')
|
const vs = v.split(' ');
|
||||||
if (vs.length >= 6) {
|
if (vs.length >= 6) {
|
||||||
// 转成 Quartz 的规则
|
// 转成 Quartz 的规则
|
||||||
vs[5] = convertWeekToQuartz(vs[5])
|
vs[5] = convertWeekToQuartz(vs[5]);
|
||||||
}
|
}
|
||||||
return vs.slice(0, vs.length - 1).join(' ')
|
return vs.slice(0, vs.length - 1).join(' ');
|
||||||
})
|
});
|
||||||
const calTriggerList = simpleDebounce(calTriggerListInner, 500)
|
const calTriggerList = simpleDebounce(calTriggerListInner, 500);
|
||||||
|
|
||||||
watch(() => props.value, (newVal) => {
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(newVal) => {
|
||||||
if (newVal === cronValueInner.value) {
|
if (newVal === cronValueInner.value) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
formatValue()
|
formatValue();
|
||||||
})
|
}
|
||||||
|
);
|
||||||
|
|
||||||
watch(cronValueInner, (newValue) => {
|
watch(cronValueInner, (newValue) => {
|
||||||
calTriggerList()
|
calTriggerList();
|
||||||
emitValue(newValue)
|
emitValue(newValue);
|
||||||
assignInput()
|
assignInput();
|
||||||
})
|
});
|
||||||
|
|
||||||
// watch(minute, () => {
|
// watch(minute, () => {
|
||||||
// if (second.value === '*') {
|
// if (second.value === '*') {
|
||||||
|
@ -199,34 +201,34 @@ watch(cronValueInner, (newValue) => {
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
||||||
assignInput()
|
assignInput();
|
||||||
formatValue()
|
formatValue();
|
||||||
calTriggerListInner()
|
calTriggerListInner();
|
||||||
|
|
||||||
function assignInput() {
|
function assignInput() {
|
||||||
inputValues.second = second.value
|
inputValues.second = second.value;
|
||||||
inputValues.minute = minute.value
|
inputValues.minute = minute.value;
|
||||||
inputValues.hour = hour.value
|
inputValues.hour = hour.value;
|
||||||
inputValues.day = day.value
|
inputValues.day = day.value;
|
||||||
inputValues.month = month.value
|
inputValues.month = month.value;
|
||||||
inputValues.week = week.value
|
inputValues.week = week.value;
|
||||||
inputValues.year = year.value
|
inputValues.year = year.value;
|
||||||
inputValues.cron = cronValueInner.value
|
inputValues.cron = cronValueInner.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatValue() {
|
function formatValue() {
|
||||||
if (!props.value) return
|
if (!props.value) return;
|
||||||
const values = props.value.split(' ').filter(item => !!item)
|
const values = props.value.split(' ').filter((item) => !!item);
|
||||||
if (!values || values.length <= 0) return
|
if (!values || values.length <= 0) return;
|
||||||
let i = 0
|
let i = 0;
|
||||||
if (!props.hideSecond) second.value = values[i++]
|
if (!props.hideSecond) second.value = values[i++];
|
||||||
if (values.length > i) minute.value = values[i++]
|
if (values.length > i) minute.value = values[i++];
|
||||||
if (values.length > i) hour.value = values[i++]
|
if (values.length > i) hour.value = values[i++];
|
||||||
if (values.length > i) day.value = values[i++]
|
if (values.length > i) day.value = values[i++];
|
||||||
if (values.length > i) month.value = values[i++]
|
if (values.length > i) month.value = values[i++];
|
||||||
if (values.length > i) week.value = values[i++]
|
if (values.length > i) week.value = values[i++];
|
||||||
if (values.length > i) year.value = values[i]
|
if (values.length > i) year.value = values[i];
|
||||||
assignInput()
|
assignInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quartz 的规则:
|
// Quartz 的规则:
|
||||||
|
@ -234,72 +236,75 @@ function formatValue() {
|
||||||
function convertWeekToQuartz(week: string) {
|
function convertWeekToQuartz(week: string) {
|
||||||
let convert = (v: string) => {
|
let convert = (v: string) => {
|
||||||
if (v === '0') {
|
if (v === '0') {
|
||||||
return '1'
|
return '1';
|
||||||
}
|
}
|
||||||
if (v === '1') {
|
if (v === '1') {
|
||||||
return '0'
|
return '0';
|
||||||
}
|
|
||||||
return (Number.parseInt(v) - 1).toString()
|
|
||||||
}
|
}
|
||||||
|
return (Number.parseInt(v) - 1).toString();
|
||||||
|
};
|
||||||
// 匹配示例 1-7 or 1/7
|
// 匹配示例 1-7 or 1/7
|
||||||
let patten1 = /^([0-7])([-/])([0-7])$/
|
let patten1 = /^([0-7])([-/])([0-7])$/;
|
||||||
// 匹配示例 1,4,7
|
// 匹配示例 1,4,7
|
||||||
let patten2 = /^([0-7])(,[0-7])+$/
|
let patten2 = /^([0-7])(,[0-7])+$/;
|
||||||
if (/^[0-7]$/.test(week)) {
|
if (/^[0-7]$/.test(week)) {
|
||||||
return convert(week)
|
return convert(week);
|
||||||
} else if (patten1.test(week)) {
|
} else if (patten1.test(week)) {
|
||||||
return week.replace(patten1, ($0, before, separator, after) => {
|
return week.replace(patten1, ($0, before, separator, after) => {
|
||||||
if (separator === '/') {
|
if (separator === '/') {
|
||||||
return convert(before) + separator + after
|
return convert(before) + separator + after;
|
||||||
} else {
|
} else {
|
||||||
return convert(before) + separator + convert(after)
|
return convert(before) + separator + convert(after);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
} else if (patten2.test(week)) {
|
} else if (patten2.test(week)) {
|
||||||
return week.split(',').map(v => convert(v)).join(',')
|
|
||||||
}
|
|
||||||
return week
|
return week
|
||||||
|
.split(',')
|
||||||
|
.map((v) => convert(v))
|
||||||
|
.join(',');
|
||||||
|
}
|
||||||
|
return week;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calTriggerListInner() {
|
function calTriggerListInner() {
|
||||||
// 设置了回调函数
|
// 设置了回调函数
|
||||||
if (props.remote) {
|
if (props.remote) {
|
||||||
props.remote(cronValueInner.value, +new Date(), v => {
|
props.remote(cronValueInner.value, +new Date(), (v) => {
|
||||||
preTimeList.value = v
|
preTimeList.value = v;
|
||||||
})
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const format = 'yyyy-MM-dd hh:mm:ss'
|
const format = 'yyyy-MM-dd hh:mm:ss';
|
||||||
const options = {
|
const options = {
|
||||||
currentDate: dateFormat(new Date(), format),
|
currentDate: dateFormat(new Date(), format),
|
||||||
}
|
};
|
||||||
const iter = CronParser.parseExpression(cronValueNoYear.value, options)
|
const iter = CronParser.parseExpression(cronValueNoYear.value, options);
|
||||||
const result: string[] = []
|
const result: string[] = [];
|
||||||
for (let i = 1; i <= 10; i++) {
|
for (let i = 1; i <= 10; i++) {
|
||||||
result.push(dateFormat(new Date(iter.next() as any), format))
|
result.push(dateFormat(new Date(iter.next() as any), format));
|
||||||
}
|
}
|
||||||
preTimeList.value = result.length > 0 ? result.join('\n') : '无执行时间'
|
preTimeList.value = result.length > 0 ? result.join('\n') : '无执行时间';
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInputBlur() {
|
function onInputBlur() {
|
||||||
second.value = inputValues.second
|
second.value = inputValues.second;
|
||||||
minute.value = inputValues.minute
|
minute.value = inputValues.minute;
|
||||||
hour.value = inputValues.hour
|
hour.value = inputValues.hour;
|
||||||
day.value = inputValues.day
|
day.value = inputValues.day;
|
||||||
month.value = inputValues.month
|
month.value = inputValues.month;
|
||||||
week.value = inputValues.week
|
week.value = inputValues.week;
|
||||||
year.value = inputValues.year
|
year.value = inputValues.year;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInputCronBlur(event) {
|
function onInputCronBlur(event) {
|
||||||
emitValue(event.target.value)
|
emitValue(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitValue(value) {
|
function emitValue(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@import "easy.cron.inner";
|
@import 'easy.cron.inner';
|
||||||
</style>
|
</style>
|
|
@ -8,56 +8,49 @@
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
<EasyCronModal
|
<EasyCronModal @register="registerModal" v-model:value="editCronValue" :exeStartTime="exeStartTime" :hideYear="hideYear" :remote="remote" :hideSecond="hideSecond" />
|
||||||
@register="registerModal"
|
|
||||||
v-model:value="editCronValue"
|
|
||||||
:exeStartTime="exeStartTime"
|
|
||||||
:hideYear="hideYear"
|
|
||||||
:remote="remote"
|
|
||||||
:hideSecond="hideSecond"/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useModal } from '/@/components/Modal'
|
import { useModal } from '/@/components/Modal';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import Icon from '/@/components/Icon/src/Icon.vue'
|
import Icon from '/@/components/Icon/src/Icon.vue';
|
||||||
import EasyCronModal from './EasyCronModal.vue'
|
import EasyCronModal from './EasyCronModal.vue';
|
||||||
import { cronEmits, cronProps } from './easy.cron.data'
|
import { cronEmits, cronProps } from './easy.cron.data';
|
||||||
|
|
||||||
const { prefixCls } = useDesign('easy-cron-input')
|
const { prefixCls } = useDesign('easy-cron-input');
|
||||||
const emit = defineEmits([...cronEmits])
|
const emit = defineEmits([...cronEmits]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
...cronProps,
|
...cronProps,
|
||||||
placeholder: propTypes.string.def('请输入cron表达式'),
|
placeholder: propTypes.string.def('请输入cron表达式'),
|
||||||
exeStartTime: propTypes.oneOfType([
|
exeStartTime: propTypes.oneOfType([propTypes.number, propTypes.string, propTypes.object]).def(0),
|
||||||
propTypes.number,
|
});
|
||||||
propTypes.string,
|
const [registerModal, { openModal }] = useModal();
|
||||||
propTypes.object,
|
const editCronValue = ref(props.value);
|
||||||
]).def(0),
|
|
||||||
})
|
|
||||||
const [registerModal, { openModal }] = useModal()
|
|
||||||
const editCronValue = ref(props.value)
|
|
||||||
|
|
||||||
watch(() => props.value, (newVal) => {
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(newVal) => {
|
||||||
if (newVal !== editCronValue.value) {
|
if (newVal !== editCronValue.value) {
|
||||||
editCronValue.value = newVal
|
editCronValue.value = newVal;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
);
|
||||||
watch(editCronValue, (newVal) => {
|
watch(editCronValue, (newVal) => {
|
||||||
emit('change', newVal)
|
emit('change', newVal);
|
||||||
emit('update:value', newVal)
|
emit('update:value', newVal);
|
||||||
})
|
});
|
||||||
|
|
||||||
function showConfigModal() {
|
function showConfigModal() {
|
||||||
if (!props.disabled) {
|
if (!props.disabled) {
|
||||||
openModal()
|
openModal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@import "easy.cron.input";
|
@import 'easy.cron.input';
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -5,24 +5,24 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { BasicModal, useModalInner } from '/@/components/Modal'
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
import EasyCron from './EasyCronInner.vue'
|
import EasyCron from './EasyCronInner.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'EasyCronModal',
|
name: 'EasyCronModal',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
components: { BasicModal, EasyCron },
|
components: { BasicModal, EasyCron },
|
||||||
setup() {
|
setup() {
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs();
|
||||||
const [registerModal, { closeModal }] = useModalInner()
|
const [registerModal, { closeModal }] = useModalInner();
|
||||||
|
|
||||||
function onOk() {
|
function onOk() {
|
||||||
closeModal()
|
closeModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return { attrs, registerModal, onOk }
|
return { attrs, registerModal, onOk };
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -1,10 +1,10 @@
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
export const cronEmits = ['change', 'update:value']
|
export const cronEmits = ['change', 'update:value'];
|
||||||
export const cronProps = {
|
export const cronProps = {
|
||||||
value: propTypes.string.def(''),
|
value: propTypes.string.def(''),
|
||||||
disabled: propTypes.bool.def(false),
|
disabled: propTypes.bool.def(false),
|
||||||
hideSecond: propTypes.bool.def(false),
|
hideSecond: propTypes.bool.def(false),
|
||||||
hideYear: propTypes.bool.def(false),
|
hideYear: propTypes.bool.def(false),
|
||||||
remote: propTypes.func,
|
remote: propTypes.func,
|
||||||
}
|
};
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.tip-info {
|
.tip-info {
|
||||||
color: #999
|
color: #999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// 原开源项目地址:https://gitee.com/toktok/easy-cron
|
// 原开源项目地址:https://gitee.com/toktok/easy-cron
|
||||||
|
|
||||||
export { default as JEasyCron } from './EasyCronInput.vue'
|
export { default as JEasyCron } from './EasyCronInput.vue';
|
||||||
export { default as JEasyCronInner } from './EasyCronInner.vue'
|
export { default as JEasyCronInner } from './EasyCronInner.vue';
|
||||||
export { default as JEasyCronModal } from './EasyCronModal.vue'
|
export { default as JEasyCronModal } from './EasyCronModal.vue';
|
||||||
export { default as JCronValidator } from './validator'
|
export { default as JCronValidator } from './validator';
|
||||||
|
|
|
@ -48,9 +48,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, watch } from 'vue'
|
import { computed, defineComponent, watch } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { TypeEnum, useTabEmits, useTabProps, useTabSetup } from './useTabMixin'
|
import { TypeEnum, useTabEmits, useTabProps, useTabSetup } from './useTabMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'DayUI',
|
name: 'DayUI',
|
||||||
|
@ -64,8 +64,8 @@ export default defineComponent({
|
||||||
emits: useTabEmits(),
|
emits: useTabEmits(),
|
||||||
setup(props, context) {
|
setup(props, context) {
|
||||||
const disabledChoice = computed(() => {
|
const disabledChoice = computed(() => {
|
||||||
return (props.week && props.week !== '?') || props.disabled
|
return (props.week && props.week !== '?') || props.disabled;
|
||||||
})
|
});
|
||||||
const setup = useTabSetup(props, context, {
|
const setup = useTabSetup(props, context, {
|
||||||
defaultValue: '*',
|
defaultValue: '*',
|
||||||
valueWork: 1,
|
valueWork: 1,
|
||||||
|
@ -74,17 +74,20 @@ export default defineComponent({
|
||||||
valueRange: { start: 1, end: 31 },
|
valueRange: { start: 1, end: 31 },
|
||||||
valueLoop: { start: 1, interval: 1 },
|
valueLoop: { start: 1, interval: 1 },
|
||||||
disabled: disabledChoice,
|
disabled: disabledChoice,
|
||||||
})
|
});
|
||||||
const typeWorkAttrs = computed(() => ({
|
const typeWorkAttrs = computed(() => ({
|
||||||
disabled: setup.type.value !== TypeEnum.work || props.disabled || disabledChoice.value,
|
disabled: setup.type.value !== TypeEnum.work || props.disabled || disabledChoice.value,
|
||||||
...setup.inputNumberAttrs.value,
|
...setup.inputNumberAttrs.value,
|
||||||
}))
|
}));
|
||||||
|
|
||||||
watch(() => props.week, () => {
|
watch(
|
||||||
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value)
|
() => props.week,
|
||||||
})
|
() => {
|
||||||
|
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return { ...setup, typeWorkAttrs }
|
return { ...setup, typeWorkAttrs };
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -35,9 +35,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'HourUI',
|
name: 'HourUI',
|
||||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
||||||
maxValue: 23,
|
maxValue: 23,
|
||||||
valueRange: { start: 0, end: 23 },
|
valueRange: { start: 0, end: 23 },
|
||||||
valueLoop: { start: 0, interval: 1 },
|
valueLoop: { start: 0, interval: 1 },
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -35,9 +35,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'MinuteUI',
|
name: 'MinuteUI',
|
||||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
||||||
maxValue: 59,
|
maxValue: 59,
|
||||||
valueRange: { start: 0, end: 59 },
|
valueRange: { start: 0, end: 59 },
|
||||||
valueLoop: { start: 0, interval: 1 },
|
valueLoop: { start: 0, interval: 1 },
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -35,9 +35,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'MonthUI',
|
name: 'MonthUI',
|
||||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
||||||
maxValue: 12,
|
maxValue: 12,
|
||||||
valueRange: { start: 1, end: 12 },
|
valueRange: { start: 1, end: 12 },
|
||||||
valueLoop: { start: 1, interval: 1 },
|
valueLoop: { start: 1, interval: 1 },
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -35,9 +35,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'SecondUI',
|
name: 'SecondUI',
|
||||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
||||||
maxValue: 59,
|
maxValue: 59,
|
||||||
valueRange: { start: 0, end: 59 },
|
valueRange: { start: 0, end: 59 },
|
||||||
valueLoop: { start: 0, interval: 1 },
|
valueLoop: { start: 0, interval: 1 },
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -35,9 +35,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, watch, defineComponent } from 'vue'
|
import { computed, watch, defineComponent } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { useTabProps, useTabEmits, useTabSetup, TypeEnum } from './useTabMixin'
|
import { useTabProps, useTabEmits, useTabSetup, TypeEnum } from './useTabMixin';
|
||||||
|
|
||||||
const WEEK_MAP_EN = {
|
const WEEK_MAP_EN = {
|
||||||
'1': 'SUN',
|
'1': 'SUN',
|
||||||
|
@ -47,7 +47,7 @@ const WEEK_MAP_EN = {
|
||||||
'5': 'THU',
|
'5': 'THU',
|
||||||
'6': 'FRI',
|
'6': 'FRI',
|
||||||
'7': 'SAT',
|
'7': 'SAT',
|
||||||
}
|
};
|
||||||
|
|
||||||
const WEEK_MAP_CN = {
|
const WEEK_MAP_CN = {
|
||||||
'1': '周日',
|
'1': '周日',
|
||||||
|
@ -57,7 +57,7 @@ const WEEK_MAP_CN = {
|
||||||
'5': '周四',
|
'5': '周四',
|
||||||
'6': '周五',
|
'6': '周五',
|
||||||
'7': '周六',
|
'7': '周六',
|
||||||
}
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'WeekUI',
|
name: 'WeekUI',
|
||||||
|
@ -71,8 +71,8 @@ export default defineComponent({
|
||||||
emits: useTabEmits(),
|
emits: useTabEmits(),
|
||||||
setup(props, context) {
|
setup(props, context) {
|
||||||
const disabledChoice = computed(() => {
|
const disabledChoice = computed(() => {
|
||||||
return (props.day && props.day !== '?') || props.disabled
|
return (props.day && props.day !== '?') || props.disabled;
|
||||||
})
|
});
|
||||||
const setup = useTabSetup(props, context, {
|
const setup = useTabSetup(props, context, {
|
||||||
defaultType: TypeEnum.unset,
|
defaultType: TypeEnum.unset,
|
||||||
defaultValue: '?',
|
defaultValue: '?',
|
||||||
|
@ -82,41 +82,44 @@ export default defineComponent({
|
||||||
valueRange: { start: 1, end: 7 },
|
valueRange: { start: 1, end: 7 },
|
||||||
valueLoop: { start: 2, interval: 1 },
|
valueLoop: { start: 2, interval: 1 },
|
||||||
disabled: disabledChoice,
|
disabled: disabledChoice,
|
||||||
})
|
});
|
||||||
const weekOptions = computed(() => {
|
const weekOptions = computed(() => {
|
||||||
let options: { label: string, value: number }[] = []
|
let options: { label: string; value: number }[] = [];
|
||||||
for (let weekKey of Object.keys(WEEK_MAP_CN)) {
|
for (let weekKey of Object.keys(WEEK_MAP_CN)) {
|
||||||
let weekName: string = WEEK_MAP_CN[weekKey]
|
let weekName: string = WEEK_MAP_CN[weekKey];
|
||||||
options.push({
|
options.push({
|
||||||
value: Number.parseInt(weekKey),
|
value: Number.parseInt(weekKey),
|
||||||
label: weekName,
|
label: weekName,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return options
|
return options;
|
||||||
})
|
});
|
||||||
|
|
||||||
const typeRangeSelectAttrs = computed(() => ({
|
const typeRangeSelectAttrs = computed(() => ({
|
||||||
class: ['w80'],
|
class: ['w80'],
|
||||||
disabled: setup.typeRangeAttrs.value.disabled,
|
disabled: setup.typeRangeAttrs.value.disabled,
|
||||||
}))
|
}));
|
||||||
|
|
||||||
const typeLoopSelectAttrs = computed(() => ({
|
const typeLoopSelectAttrs = computed(() => ({
|
||||||
class: ['w80'],
|
class: ['w80'],
|
||||||
disabled: setup.typeLoopAttrs.value.disabled,
|
disabled: setup.typeLoopAttrs.value.disabled,
|
||||||
}))
|
}));
|
||||||
|
|
||||||
watch(() => props.day, () => {
|
watch(
|
||||||
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value)
|
() => props.day,
|
||||||
})
|
() => {
|
||||||
|
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...setup,
|
...setup,
|
||||||
weekOptions,
|
weekOptions,
|
||||||
typeLoopSelectAttrs,
|
typeLoopSelectAttrs,
|
||||||
typeRangeSelectAttrs,
|
typeRangeSelectAttrs,
|
||||||
WEEK_MAP_CN, WEEK_MAP_EN,
|
WEEK_MAP_CN,
|
||||||
}
|
WEEK_MAP_EN,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
});
|
||||||
})
|
|
||||||
</script>
|
</script>
|
|
@ -25,9 +25,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue';
|
||||||
import { InputNumber } from 'ant-design-vue'
|
import { InputNumber } from 'ant-design-vue';
|
||||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'YearUI',
|
name: 'YearUI',
|
||||||
|
@ -37,13 +37,13 @@ export default defineComponent({
|
||||||
}),
|
}),
|
||||||
emits: useTabEmits(),
|
emits: useTabEmits(),
|
||||||
setup(props, context) {
|
setup(props, context) {
|
||||||
const nowYear = (new Date()).getFullYear()
|
const nowYear = new Date().getFullYear();
|
||||||
return useTabSetup(props, context, {
|
return useTabSetup(props, context, {
|
||||||
defaultValue: '*',
|
defaultValue: '*',
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
valueRange: { start: nowYear, end: nowYear + 100 },
|
valueRange: { start: nowYear, end: nowYear + 100 },
|
||||||
valueLoop: { start: nowYear, interval: 1 },
|
valueLoop: { start: nowYear, interval: 1 },
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
|
@ -1,6 +1,6 @@
|
||||||
// 主要用于日和星期的互斥使用
|
// 主要用于日和星期的互斥使用
|
||||||
import { computed, inject, reactive, ref, unref, watch } from 'vue'
|
import { computed, inject, reactive, ref, unref, watch } from 'vue';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
export enum TypeEnum {
|
export enum TypeEnum {
|
||||||
unset = 'UNSET',
|
unset = 'UNSET',
|
||||||
|
@ -14,91 +14,95 @@ export enum TypeEnum {
|
||||||
|
|
||||||
// use 公共 props
|
// use 公共 props
|
||||||
export function useTabProps(options) {
|
export function useTabProps(options) {
|
||||||
const defaultValue = options?.defaultValue ?? '?'
|
const defaultValue = options?.defaultValue ?? '?';
|
||||||
return {
|
return {
|
||||||
value: propTypes.string.def(defaultValue),
|
value: propTypes.string.def(defaultValue),
|
||||||
disabled: propTypes.bool.def(false),
|
disabled: propTypes.bool.def(false),
|
||||||
...options?.props,
|
...options?.props,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// use 公共 emits
|
// use 公共 emits
|
||||||
export function useTabEmits() {
|
export function useTabEmits() {
|
||||||
return ['change', 'update:value']
|
return ['change', 'update:value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// use 公共 setup
|
// use 公共 setup
|
||||||
export function useTabSetup(props, context, options) {
|
export function useTabSetup(props, context, options) {
|
||||||
const { emit } = context
|
const { emit } = context;
|
||||||
const prefixCls = inject('prefixCls')
|
const prefixCls = inject('prefixCls');
|
||||||
const defaultValue = ref(options?.defaultValue ?? '?')
|
const defaultValue = ref(options?.defaultValue ?? '?');
|
||||||
// 类型
|
// 类型
|
||||||
const type = ref(options.defaultType ?? TypeEnum.every)
|
const type = ref(options.defaultType ?? TypeEnum.every);
|
||||||
const valueList = ref<any[]>([])
|
const valueList = ref<any[]>([]);
|
||||||
// 对于不同的类型,所定义的值也有所不同
|
// 对于不同的类型,所定义的值也有所不同
|
||||||
const valueRange = reactive(options.valueRange)
|
const valueRange = reactive(options.valueRange);
|
||||||
const valueLoop = reactive(options.valueLoop)
|
const valueLoop = reactive(options.valueLoop);
|
||||||
const valueWeek = reactive(options.valueWeek)
|
const valueWeek = reactive(options.valueWeek);
|
||||||
const valueWork = ref(options.valueWork)
|
const valueWork = ref(options.valueWork);
|
||||||
const maxValue = ref(options.maxValue)
|
const maxValue = ref(options.maxValue);
|
||||||
const minValue = ref(options.minValue)
|
const minValue = ref(options.minValue);
|
||||||
|
|
||||||
// 根据不同的类型计算出的value
|
// 根据不同的类型计算出的value
|
||||||
const computeValue = computed(() => {
|
const computeValue = computed(() => {
|
||||||
let valueArray: any[] = []
|
let valueArray: any[] = [];
|
||||||
switch (type.value) {
|
switch (type.value) {
|
||||||
case TypeEnum.unset:
|
case TypeEnum.unset:
|
||||||
valueArray.push('?')
|
valueArray.push('?');
|
||||||
break
|
break;
|
||||||
case TypeEnum.every:
|
case TypeEnum.every:
|
||||||
valueArray.push('*')
|
valueArray.push('*');
|
||||||
break
|
break;
|
||||||
case TypeEnum.range:
|
case TypeEnum.range:
|
||||||
valueArray.push(`${valueRange.start}-${valueRange.end}`)
|
valueArray.push(`${valueRange.start}-${valueRange.end}`);
|
||||||
break
|
break;
|
||||||
case TypeEnum.loop:
|
case TypeEnum.loop:
|
||||||
valueArray.push(`${valueLoop.start}/${valueLoop.interval}`)
|
valueArray.push(`${valueLoop.start}/${valueLoop.interval}`);
|
||||||
break
|
break;
|
||||||
case TypeEnum.work:
|
case TypeEnum.work:
|
||||||
valueArray.push(`${valueWork.value}W`)
|
valueArray.push(`${valueWork.value}W`);
|
||||||
break
|
break;
|
||||||
case TypeEnum.last:
|
case TypeEnum.last:
|
||||||
valueArray.push('L')
|
valueArray.push('L');
|
||||||
break
|
break;
|
||||||
case TypeEnum.specify:
|
case TypeEnum.specify:
|
||||||
if (valueList.value.length === 0) {
|
if (valueList.value.length === 0) {
|
||||||
valueList.value.push(minValue.value)
|
valueList.value.push(minValue.value);
|
||||||
}
|
}
|
||||||
valueArray.push(valueList.value.join(','))
|
valueArray.push(valueList.value.join(','));
|
||||||
break
|
break;
|
||||||
default:
|
default:
|
||||||
valueArray.push(defaultValue.value)
|
valueArray.push(defaultValue.value);
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
return valueArray.length > 0 ? valueArray.join('') : defaultValue.value
|
return valueArray.length > 0 ? valueArray.join('') : defaultValue.value;
|
||||||
})
|
});
|
||||||
// 指定值范围区间,介于最小值和最大值之间
|
// 指定值范围区间,介于最小值和最大值之间
|
||||||
const specifyRange = computed(() => {
|
const specifyRange = computed(() => {
|
||||||
let range: number[] = []
|
let range: number[] = [];
|
||||||
if (maxValue.value != null) {
|
if (maxValue.value != null) {
|
||||||
for (let i = minValue.value; i <= maxValue.value; i++) {
|
for (let i = minValue.value; i <= maxValue.value; i++) {
|
||||||
range.push(i)
|
range.push(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return range
|
return range;
|
||||||
})
|
});
|
||||||
|
|
||||||
watch(() => props.value, (val) => {
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(val) => {
|
||||||
if (val !== computeValue.value) {
|
if (val !== computeValue.value) {
|
||||||
parseValue(val)
|
parseValue(val);
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
watch(computeValue, (v) => updateValue(v))
|
watch(computeValue, (v) => updateValue(v));
|
||||||
|
|
||||||
function updateValue(value) {
|
function updateValue(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,71 +111,72 @@ export function useTabSetup(props, context, options) {
|
||||||
*/
|
*/
|
||||||
function parseValue(value) {
|
function parseValue(value) {
|
||||||
if (value === computeValue.value) {
|
if (value === computeValue.value) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!value || value === defaultValue.value) {
|
if (!value || value === defaultValue.value) {
|
||||||
type.value = TypeEnum.every
|
type.value = TypeEnum.every;
|
||||||
} else if (value.indexOf('?') >= 0) {
|
} else if (value.indexOf('?') >= 0) {
|
||||||
type.value = TypeEnum.unset
|
type.value = TypeEnum.unset;
|
||||||
} else if (value.indexOf('-') >= 0) {
|
} else if (value.indexOf('-') >= 0) {
|
||||||
type.value = TypeEnum.range
|
type.value = TypeEnum.range;
|
||||||
const values = value.split('-')
|
const values = value.split('-');
|
||||||
if (values.length >= 2) {
|
if (values.length >= 2) {
|
||||||
valueRange.start = parseInt(values[0])
|
valueRange.start = parseInt(values[0]);
|
||||||
valueRange.end = parseInt(values[1])
|
valueRange.end = parseInt(values[1]);
|
||||||
}
|
}
|
||||||
} else if (value.indexOf('/') >= 0) {
|
} else if (value.indexOf('/') >= 0) {
|
||||||
type.value = TypeEnum.loop
|
type.value = TypeEnum.loop;
|
||||||
const values = value.split('/')
|
const values = value.split('/');
|
||||||
if (values.length >= 2) {
|
if (values.length >= 2) {
|
||||||
valueLoop.start = value[0] === '*' ? 0 : parseInt(values[0])
|
valueLoop.start = value[0] === '*' ? 0 : parseInt(values[0]);
|
||||||
valueLoop.interval = parseInt(values[1])
|
valueLoop.interval = parseInt(values[1]);
|
||||||
}
|
}
|
||||||
} else if (value.indexOf('W') >= 0) {
|
} else if (value.indexOf('W') >= 0) {
|
||||||
type.value = TypeEnum.work
|
type.value = TypeEnum.work;
|
||||||
const values = value.split('W')
|
const values = value.split('W');
|
||||||
if (!values[0] && !isNaN(values[0])) {
|
if (!values[0] && !isNaN(values[0])) {
|
||||||
valueWork.value = parseInt(values[0])
|
valueWork.value = parseInt(values[0]);
|
||||||
}
|
}
|
||||||
} else if (value.indexOf('L') >= 0) {
|
} else if (value.indexOf('L') >= 0) {
|
||||||
type.value = TypeEnum.last
|
type.value = TypeEnum.last;
|
||||||
} else if (value.indexOf(',') >= 0 || !isNaN(value)) {
|
} else if (value.indexOf(',') >= 0 || !isNaN(value)) {
|
||||||
type.value = TypeEnum.specify
|
type.value = TypeEnum.specify;
|
||||||
valueList.value = value.split(',').map(item => parseInt(item))
|
valueList.value = value.split(',').map((item) => parseInt(item));
|
||||||
} else {
|
} else {
|
||||||
type.value = TypeEnum.every
|
type.value = TypeEnum.every;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
type.value = TypeEnum.every
|
type.value = TypeEnum.every;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const beforeRadioAttrs = computed(() => ({
|
const beforeRadioAttrs = computed(() => ({
|
||||||
class: ['choice'],
|
class: ['choice'],
|
||||||
disabled: props.disabled || unref(options.disabled),
|
disabled: props.disabled || unref(options.disabled),
|
||||||
}))
|
}));
|
||||||
const inputNumberAttrs = computed(() => ({
|
const inputNumberAttrs = computed(() => ({
|
||||||
class: ['w60'],
|
class: ['w60'],
|
||||||
max: maxValue.value,
|
max: maxValue.value,
|
||||||
min: minValue.value,
|
min: minValue.value,
|
||||||
precision: 0,
|
precision: 0,
|
||||||
}))
|
}));
|
||||||
const typeRangeAttrs = computed(() => ({
|
const typeRangeAttrs = computed(() => ({
|
||||||
disabled: type.value !== TypeEnum.range || props.disabled || unref(options.disabled),
|
disabled: type.value !== TypeEnum.range || props.disabled || unref(options.disabled),
|
||||||
...inputNumberAttrs.value,
|
...inputNumberAttrs.value,
|
||||||
}))
|
}));
|
||||||
const typeLoopAttrs = computed(() => ({
|
const typeLoopAttrs = computed(() => ({
|
||||||
disabled: type.value !== TypeEnum.loop || props.disabled || unref(options.disabled),
|
disabled: type.value !== TypeEnum.loop || props.disabled || unref(options.disabled),
|
||||||
...inputNumberAttrs.value,
|
...inputNumberAttrs.value,
|
||||||
}))
|
}));
|
||||||
const typeSpecifyAttrs = computed(() => ({
|
const typeSpecifyAttrs = computed(() => ({
|
||||||
disabled: type.value !== TypeEnum.specify || props.disabled || unref(options.disabled),
|
disabled: type.value !== TypeEnum.specify || props.disabled || unref(options.disabled),
|
||||||
class: ['list-check-item'],
|
class: ['list-check-item'],
|
||||||
}))
|
}));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type, TypeEnum,
|
type,
|
||||||
|
TypeEnum,
|
||||||
prefixCls,
|
prefixCls,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
valueRange,
|
valueRange,
|
||||||
|
@ -190,5 +195,5 @@ export function useTabSetup(props, context, options) {
|
||||||
typeRangeAttrs,
|
typeRangeAttrs,
|
||||||
typeLoopAttrs,
|
typeLoopAttrs,
|
||||||
typeSpecifyAttrs,
|
typeSpecifyAttrs,
|
||||||
}
|
};
|
||||||
}
|
}
|
|
@ -1,48 +1,48 @@
|
||||||
import CronParser from 'cron-parser'
|
import CronParser from 'cron-parser';
|
||||||
import type { ValidatorRule } from 'ant-design-vue/lib/form/interface'
|
import type { ValidatorRule } from 'ant-design-vue/lib/form/interface';
|
||||||
|
|
||||||
const cronRule: ValidatorRule = {
|
const cronRule: ValidatorRule = {
|
||||||
validator({}, value) {
|
validator({}, value) {
|
||||||
// 没填写就不校验
|
// 没填写就不校验
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return Promise.resolve()
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
const values: string[] = value.split(' ').filter(item => !!item)
|
const values: string[] = value.split(' ').filter((item) => !!item);
|
||||||
if (values.length > 7) {
|
if (values.length > 7) {
|
||||||
return Promise.reject('Cron表达式最多7项!')
|
return Promise.reject('Cron表达式最多7项!');
|
||||||
}
|
}
|
||||||
// 检查第7项
|
// 检查第7项
|
||||||
let val: string = value
|
let val: string = value;
|
||||||
if (values.length === 7) {
|
if (values.length === 7) {
|
||||||
const year = values[6]
|
const year = values[6];
|
||||||
if (year !== '*' && year !== '?') {
|
if (year !== '*' && year !== '?') {
|
||||||
let yearValues: string[] = []
|
let yearValues: string[] = [];
|
||||||
if (year.indexOf('-') >= 0) {
|
if (year.indexOf('-') >= 0) {
|
||||||
yearValues = year.split('-')
|
yearValues = year.split('-');
|
||||||
} else if (year.indexOf('/')) {
|
} else if (year.indexOf('/')) {
|
||||||
yearValues = year.split('/')
|
yearValues = year.split('/');
|
||||||
} else {
|
} else {
|
||||||
yearValues = [year]
|
yearValues = [year];
|
||||||
}
|
}
|
||||||
// 判断是否都是数字
|
// 判断是否都是数字
|
||||||
const checkYear = yearValues.some(item => isNaN(Number(item)))
|
const checkYear = yearValues.some((item) => isNaN(Number(item)));
|
||||||
if (checkYear) {
|
if (checkYear) {
|
||||||
return Promise.reject('Cron表达式参数[年]错误:' + year)
|
return Promise.reject('Cron表达式参数[年]错误:' + year);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 取其中的前六项
|
// 取其中的前六项
|
||||||
val = values.slice(0, 6).join(' ')
|
val = values.slice(0, 6).join(' ');
|
||||||
}
|
}
|
||||||
// 6位 没有年
|
// 6位 没有年
|
||||||
// 5位没有秒、年
|
// 5位没有秒、年
|
||||||
try {
|
try {
|
||||||
const iter = CronParser.parseExpression(val)
|
const iter = CronParser.parseExpression(val);
|
||||||
iter.next()
|
iter.next();
|
||||||
return Promise.resolve()
|
return Promise.resolve();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject('Cron表达式错误:' + e)
|
return Promise.reject('Cron表达式错误:' + e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export default cronRule.validator
|
export default cronRule.validator;
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent } from 'vue'
|
import { computed, defineComponent } from 'vue';
|
||||||
|
|
||||||
import { Tinymce } from '/@/components/Tinymce'
|
import { Tinymce } from '/@/components/Tinymce';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JEditor',
|
name: 'JEditor',
|
||||||
|
@ -20,21 +20,20 @@ export default defineComponent({
|
||||||
emits: ['change', 'update:value'],
|
emits: ['change', 'update:value'],
|
||||||
setup(props, { emit, attrs }) {
|
setup(props, { emit, attrs }) {
|
||||||
// 合并 props 和 attrs
|
// 合并 props 和 attrs
|
||||||
const bindProps = computed(() => Object.assign({}, props, attrs))
|
const bindProps = computed(() => Object.assign({}, props, attrs));
|
||||||
|
|
||||||
// value change 事件
|
// value change 事件
|
||||||
function onChange(value) {
|
function onChange(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bindProps,
|
bindProps,
|
||||||
onChange,
|
onChange,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped></style>
|
||||||
</style>
|
|
||||||
|
|
|
@ -8,13 +8,12 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: propTypes.string.def(''),
|
value: propTypes.string.def(''),
|
||||||
length: propTypes.number.def(25),
|
length: propTypes.number.def(25),
|
||||||
});
|
});
|
||||||
//显示的文本
|
//显示的文本
|
||||||
const showText = computed(() => props.value ? (props.value.length > props.length ? props.value.slice(0, props.length) + '...' : props.value) : props.value);
|
const showText = computed(() => (props.value ? (props.value.length > props.length ? props.value.slice(0, props.length) + '...' : props.value) : props.value));
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
:beforeUpload="beforeUpload"
|
:beforeUpload="beforeUpload"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
@preview="handlePreview">
|
@preview="handlePreview"
|
||||||
|
>
|
||||||
<div v-if="uploadVisible">
|
<div v-if="uploadVisible">
|
||||||
<div v-if="listType == 'picture-card'">
|
<div v-if="listType == 'picture-card'">
|
||||||
<LoadingOutlined v-if="loading" />
|
<LoadingOutlined v-if="loading" />
|
||||||
|
@ -46,10 +47,7 @@
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
//绑定值
|
//绑定值
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array,
|
|
||||||
]),
|
|
||||||
//按钮文本
|
//按钮文本
|
||||||
listType: {
|
listType: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -114,7 +112,6 @@
|
||||||
return props['fileMax'] > 1;
|
return props['fileMax'] > 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//计算是否可以继续上传
|
//计算是否可以继续上传
|
||||||
const uploadVisible = computed(() => {
|
const uploadVisible = computed(() => {
|
||||||
return uploadFileList.value.length < props['fileMax'];
|
return uploadFileList.value.length < props['fileMax'];
|
||||||
|
@ -132,7 +129,7 @@
|
||||||
if (initTag.value == true) {
|
if (initTag.value == true) {
|
||||||
initFileList(val);
|
initFileList(val);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,7 +191,7 @@
|
||||||
}
|
}
|
||||||
emitData.value = fileUrls.join(',');
|
emitData.value = fileUrls.join(',');
|
||||||
state.value = fileUrls.join(',');
|
state.value = fileUrls.join(',');
|
||||||
emit('update:value',fileUrls.join(','))
|
emit('update:value', fileUrls.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<BasicModal v-bind="$attrs" @register="register" title="导入EXCEL" :width="600" @cancel="handleClose" :confirmLoading="uploading" destroyOnClose>
|
<BasicModal v-bind="$attrs" @register="register" title="导入EXCEL" :width="600" @cancel="handleClose" :confirmLoading="uploading" destroyOnClose>
|
||||||
<!--是否校验-->
|
<!--是否校验-->
|
||||||
<div style="margin: 0 5px 1px" v-if="online">
|
<div style="margin: 0 5px 1px" v-if="online">
|
||||||
<span style="display: inline-block;height: 32px;line-height: 32px;vertical-align: middle;">是否开启校验:</span>
|
<span style="display: inline-block; height: 32px; line-height: 32px; vertical-align: middle">是否开启校验:</span>
|
||||||
<span style="margin-left: 6px">
|
<span style="margin-left: 6px">
|
||||||
<a-switch :checked="validateStatus == 1" @change="handleChangeValidateStatus" checked-children="是" un-checked-children="否" size="small" />
|
<a-switch :checked="validateStatus == 1" @change="handleChangeValidateStatus" checked-children="是" un-checked-children="否" size="small" />
|
||||||
</span>
|
</span>
|
||||||
|
@ -38,19 +38,19 @@
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
required: false
|
required: false,
|
||||||
},
|
},
|
||||||
biz: {
|
biz: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
required: false
|
required: false,
|
||||||
},
|
},
|
||||||
//是否online导入
|
//是否online导入
|
||||||
online: {
|
online: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
required: false
|
required: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
emits: ['ok', 'register'],
|
emits: ['ok', 'register'],
|
||||||
setup(props, { emit, refs }) {
|
setup(props, { emit, refs }) {
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
//关闭方法
|
//关闭方法
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
closeModal() && reset()
|
closeModal() && reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验状态切换
|
//校验状态切换
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
const index = unref(fileList).indexOf(file);
|
const index = unref(fileList).indexOf(file);
|
||||||
const newFileList = unref(fileList).slice();
|
const newFileList = unref(fileList).slice();
|
||||||
newFileList.splice(index, 1);
|
newFileList.splice(index, 1);
|
||||||
fileList.value = newFileList
|
fileList.value = newFileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//上传前处理
|
//上传前处理
|
||||||
|
@ -121,23 +121,23 @@
|
||||||
|
|
||||||
//TODO 请求怎样处理的问题
|
//TODO 请求怎样处理的问题
|
||||||
let headers = {
|
let headers = {
|
||||||
'Content-Type': 'multipart/form-data;boundary = ' + new Date().getTime()
|
'Content-Type': 'multipart/form-data;boundary = ' + new Date().getTime(),
|
||||||
}
|
};
|
||||||
defHttp.post({ url: props.url, params: formData, headers }, { isTransformResponse: false }).then((res) => {
|
defHttp.post({ url: props.url, params: formData, headers }, { isTransformResponse: false }).then((res) => {
|
||||||
uploading.value = false;
|
uploading.value = false;
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
if (res.code == 201) {
|
if (res.code == 201) {
|
||||||
errorTip(res.message, res.result)
|
errorTip(res.message, res.result);
|
||||||
} else {
|
} else {
|
||||||
createMessage.success(res.message)
|
createMessage.success(res.message);
|
||||||
}
|
}
|
||||||
handleClose();
|
handleClose();
|
||||||
reset();
|
reset();
|
||||||
emit('ok')
|
emit('ok');
|
||||||
} else {
|
} else {
|
||||||
createMessage.warning(res.message)
|
createMessage.warning(res.message);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//错误信息提示
|
//错误信息提示
|
||||||
|
@ -149,8 +149,8 @@
|
||||||
content: `<div>
|
content: `<div>
|
||||||
<span>${tipMessage}</span><br/>
|
<span>${tipMessage}</span><br/>
|
||||||
<span>具体详情请<a href = ${href} target="_blank"> 点击下载 </a> </span>
|
<span>具体详情请<a href = ${href} target="_blank"> 点击下载 </a> </span>
|
||||||
</div>`
|
</div>`,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//重置
|
//重置
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
fileList.value = [];
|
fileList.value = [];
|
||||||
uploading.value = false;
|
uploading.value = false;
|
||||||
foreignKeys.value = arg;
|
foreignKeys.value = arg;
|
||||||
validateStatus.value = 0
|
validateStatus.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -45,13 +45,13 @@
|
||||||
*/
|
*/
|
||||||
function initVal() {
|
function initVal() {
|
||||||
if (!props.value) {
|
if (!props.value) {
|
||||||
showText.value = ''
|
showText.value = '';
|
||||||
} else {
|
} else {
|
||||||
let text = props.value;
|
let text = props.value;
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case JInputTypeEnum.JINPUT_QUERY_LIKE:
|
case JInputTypeEnum.JINPUT_QUERY_LIKE:
|
||||||
//修复路由传参的值传送到jinput框被前后各截取了一位 #1336
|
//修复路由传参的值传送到jinput框被前后各截取了一位 #1336
|
||||||
if (text.indexOf("*") != -1) {
|
if (text.indexOf('*') != -1) {
|
||||||
text = text.substring(1, text.length - 1);
|
text = text.substring(1, text.length - 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
showText.value = text
|
showText.value = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,25 +76,25 @@
|
||||||
function backValue(e) {
|
function backValue(e) {
|
||||||
let text = e?.target?.value ?? '';
|
let text = e?.target?.value ?? '';
|
||||||
if (text && !!props.trim) {
|
if (text && !!props.trim) {
|
||||||
text = text.trim()
|
text = text.trim();
|
||||||
}
|
}
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case JInputTypeEnum.JINPUT_QUERY_LIKE:
|
case JInputTypeEnum.JINPUT_QUERY_LIKE:
|
||||||
text = "*" + text + "*";
|
text = '*' + text + '*';
|
||||||
break;
|
break;
|
||||||
case JInputTypeEnum.JINPUT_QUERY_NE:
|
case JInputTypeEnum.JINPUT_QUERY_NE:
|
||||||
text = "!" + text;
|
text = '!' + text;
|
||||||
break;
|
break;
|
||||||
case JInputTypeEnum.JINPUT_QUERY_GE:
|
case JInputTypeEnum.JINPUT_QUERY_GE:
|
||||||
text = ">=" + text;
|
text = '>=' + text;
|
||||||
break;
|
break;
|
||||||
case JInputTypeEnum.JINPUT_QUERY_LE:
|
case JInputTypeEnum.JINPUT_QUERY_LE:
|
||||||
text = "<=" + text;
|
text = '<=' + text;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
emit("change", text)
|
emit('change', text);
|
||||||
emit("update:value", text)
|
emit('update:value', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { showText, attrs, getBindValue, backValue };
|
return { showText, attrs, getBindValue, backValue };
|
||||||
|
@ -102,6 +102,4 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<a-popover
|
<a-popover trigger="contextmenu" v-model:visible="visible" :overlayClassName="`${prefixCls}-popover`" :getPopupContainer="getPopupContainer" :placement="position">
|
||||||
trigger="contextmenu"
|
|
||||||
v-model:visible="visible"
|
|
||||||
:overlayClassName="`${prefixCls}-popover`"
|
|
||||||
:getPopupContainer="getPopupContainer"
|
|
||||||
:placement="position">
|
|
||||||
<template #title>
|
<template #title>
|
||||||
<span>{{ title }}</span>
|
<span>{{ title }}</span>
|
||||||
<span style="float: right" title="关闭">
|
<span style="float: right" title="关闭">
|
||||||
|
@ -12,20 +7,9 @@
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<a-textarea
|
<a-textarea ref="textareaRef" :value="innerValue" :disabled="disabled" :style="textareaStyle" v-bind="attrs" @input="onInputChange" />
|
||||||
ref="textareaRef"
|
|
||||||
:value="innerValue"
|
|
||||||
:disabled="disabled"
|
|
||||||
:style="textareaStyle"
|
|
||||||
v-bind="attrs"
|
|
||||||
@input="onInputChange"/>
|
|
||||||
</template>
|
</template>
|
||||||
<a-input
|
<a-input :class="`${prefixCls}-input`" :value="innerValue" :disabled="disabled" v-bind="attrs" @change="onInputChange">
|
||||||
:class="`${prefixCls}-input`"
|
|
||||||
:value="innerValue"
|
|
||||||
:disabled="disabled"
|
|
||||||
v-bind="attrs"
|
|
||||||
@change="onInputChange">
|
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<Icon icon="ant-design:fullscreen-outlined" @click.stop="onShowPopup" />
|
<Icon icon="ant-design:fullscreen-outlined" @click.stop="onShowPopup" />
|
||||||
</template>
|
</template>
|
||||||
|
@ -34,13 +18,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, nextTick, ref, watch } from 'vue'
|
import { computed, nextTick, ref, watch } from 'vue';
|
||||||
import Icon from '/@/components/Icon/src/Icon.vue'
|
import Icon from '/@/components/Icon/src/Icon.vue';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
|
|
||||||
const { prefixCls } = useDesign('j-input-popup')
|
const { prefixCls } = useDesign('j-input-popup');
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// v-model:value
|
// v-model:value
|
||||||
value: propTypes.string.def(''),
|
value: propTypes.string.def(''),
|
||||||
|
@ -52,50 +36,53 @@ const props = defineProps({
|
||||||
disabled: propTypes.bool.def(false),
|
disabled: propTypes.bool.def(false),
|
||||||
// 弹出框挂载的元素ID
|
// 弹出框挂载的元素ID
|
||||||
popContainer: propTypes.string.def(''),
|
popContainer: propTypes.string.def(''),
|
||||||
})
|
});
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs();
|
||||||
const emit = defineEmits(['change', 'update:value'])
|
const emit = defineEmits(['change', 'update:value']);
|
||||||
|
|
||||||
const visible = ref<boolean>(false)
|
const visible = ref<boolean>(false);
|
||||||
const innerValue = ref<string>('')
|
const innerValue = ref<string>('');
|
||||||
// textarea ref对象
|
// textarea ref对象
|
||||||
const textareaRef = ref()
|
const textareaRef = ref();
|
||||||
// textarea 样式
|
// textarea 样式
|
||||||
const textareaStyle = computed(() => ({
|
const textareaStyle = computed(() => ({
|
||||||
height: `${props.height}px`,
|
height: `${props.height}px`,
|
||||||
width: `${props.width}px`,
|
width: `${props.width}px`,
|
||||||
}))
|
}));
|
||||||
|
|
||||||
watch(() => props.value, (value) => {
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(value) => {
|
||||||
if (value && value.length > 0) {
|
if (value && value.length > 0) {
|
||||||
innerValue.value = value
|
innerValue.value = value;
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
function onInputChange(event) {
|
function onInputChange(event) {
|
||||||
innerValue.value = event.target.value
|
innerValue.value = event.target.value;
|
||||||
emitValue(innerValue.value)
|
emitValue(innerValue.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onShowPopup() {
|
async function onShowPopup() {
|
||||||
visible.value = true
|
visible.value = true;
|
||||||
await nextTick()
|
await nextTick();
|
||||||
textareaRef.value?.focus()
|
textareaRef.value?.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取弹出框挂载的元素
|
// 获取弹出框挂载的元素
|
||||||
function getPopupContainer(node) {
|
function getPopupContainer(node) {
|
||||||
if (!props.popContainer) {
|
if (!props.popContainer) {
|
||||||
return node.parentNode
|
return node.parentNode;
|
||||||
} else {
|
} else {
|
||||||
return document.getElementById(props.popContainer)
|
return document.getElementById(props.popContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitValue(value) {
|
function emitValue(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, watch } from 'vue'
|
import { computed, defineComponent, watch } from 'vue';
|
||||||
import { MarkDown } from '/@/components/Markdown'
|
import { MarkDown } from '/@/components/Markdown';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JMarkdownEditor',
|
name: 'JMarkdownEditor',
|
||||||
|
@ -19,25 +19,29 @@ export default defineComponent({
|
||||||
emits: ['change', 'update:value'],
|
emits: ['change', 'update:value'],
|
||||||
setup(props, { emit, attrs }) {
|
setup(props, { emit, attrs }) {
|
||||||
// markdown 组件实例
|
// markdown 组件实例
|
||||||
let mdRef: any = null
|
let mdRef: any = null;
|
||||||
// vditor 组件实例
|
// vditor 组件实例
|
||||||
let vditorRef: any = null
|
let vditorRef: any = null;
|
||||||
// 合并 props 和 attrs
|
// 合并 props 和 attrs
|
||||||
const bindProps = computed(() => Object.assign({}, props, attrs))
|
const bindProps = computed(() => Object.assign({}, props, attrs));
|
||||||
|
|
||||||
// 相当于 onMounted
|
// 相当于 onMounted
|
||||||
function onGetVditor(instance) {
|
function onGetVditor(instance) {
|
||||||
mdRef = instance
|
mdRef = instance;
|
||||||
vditorRef = mdRef.getVditor()
|
vditorRef = mdRef.getVditor();
|
||||||
|
|
||||||
// 监听禁用,切换编辑器禁用状态
|
// 监听禁用,切换编辑器禁用状态
|
||||||
watch(() => props.disabled, disabled => disabled ? vditorRef.disabled() : vditorRef.enable(), { immediate: true })
|
watch(
|
||||||
|
() => props.disabled,
|
||||||
|
(disabled) => (disabled ? vditorRef.disabled() : vditorRef.enable()),
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// value change 事件
|
// value change 事件
|
||||||
function onChange(value) {
|
function onChange(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -45,10 +49,9 @@ export default defineComponent({
|
||||||
|
|
||||||
onChange,
|
onChange,
|
||||||
onGetVditor,
|
onGetVditor,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped></style>
|
||||||
</style>
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
const SELECT_OPTIONS_URL = '/online/cgform/api/querySelectOptions';
|
const SELECT_OPTIONS_URL = '/online/cgform/api/querySelectOptions';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "JOnlineSelectCascade",
|
name: 'JOnlineSelectCascade',
|
||||||
props: {
|
props: {
|
||||||
table: { type: String, default: '' },
|
table: { type: String, default: '' },
|
||||||
txt: { type: String, default: '' },
|
txt: { type: String, default: '' },
|
||||||
|
@ -32,59 +32,69 @@
|
||||||
},
|
},
|
||||||
emits: ['change', 'next'],
|
emits: ['change', 'next'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const { createMessage: $message } = useMessage()
|
const { createMessage: $message } = useMessage();
|
||||||
// 选中值
|
// 选中值
|
||||||
const selectedValue = ref<any>('');
|
const selectedValue = ref<any>('');
|
||||||
// 选项数组
|
// 选项数组
|
||||||
const dictOptions = ref<any[]>([])
|
const dictOptions = ref<any[]>([]);
|
||||||
const optionsLoad = ref(true)
|
const optionsLoad = ref(true);
|
||||||
// 选项改变事件
|
// 选项改变事件
|
||||||
function handleChange(value) {
|
function handleChange(value) {
|
||||||
console.log('handleChange', value)
|
console.log('handleChange', value);
|
||||||
// 这个value是 存储的值 实际还需要获取id值
|
// 这个value是 存储的值 实际还需要获取id值
|
||||||
let temp = value || ''
|
let temp = value || '';
|
||||||
emit('change', temp)
|
emit('change', temp);
|
||||||
valueChangeThenEmitNext(temp)
|
valueChangeThenEmitNext(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第一个节点 选项加载走condition
|
// 第一个节点 选项加载走condition
|
||||||
watch(()=>props.condition, (val)=>{
|
watch(
|
||||||
|
() => props.condition,
|
||||||
|
(val) => {
|
||||||
optionsLoad.value = true;
|
optionsLoad.value = true;
|
||||||
if (val) {
|
if (val) {
|
||||||
loadOptions();
|
loadOptions();
|
||||||
}
|
}
|
||||||
}, {immediate:true});
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
// 被联动节点 选项加载走pidValue
|
// 被联动节点 选项加载走pidValue
|
||||||
watch(()=>props.pidValue, (val)=>{
|
watch(
|
||||||
|
() => props.pidValue,
|
||||||
|
(val) => {
|
||||||
if (val === '-1') {
|
if (val === '-1') {
|
||||||
dictOptions.value = []
|
dictOptions.value = [];
|
||||||
} else {
|
} else {
|
||||||
loadOptions();
|
loadOptions();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// 值回显
|
// 值回显
|
||||||
watch(()=>props.value, (newVal, oldVal)=>{
|
watch(
|
||||||
console.log('值改变事件', newVal, oldVal)
|
() => props.value,
|
||||||
|
(newVal, oldVal) => {
|
||||||
|
console.log('值改变事件', newVal, oldVal);
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
// value不存在的时候--
|
// value不存在的时候--
|
||||||
selectedValue.value = []
|
selectedValue.value = [];
|
||||||
if (oldVal) {
|
if (oldVal) {
|
||||||
// 如果oldVal存在, 需要往上抛事件
|
// 如果oldVal存在, 需要往上抛事件
|
||||||
emit('change', '')
|
emit('change', '');
|
||||||
emit('next', '-1')
|
emit('next', '-1');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// value存在的时候
|
// value存在的时候
|
||||||
selectedValue.value = newVal
|
selectedValue.value = newVal;
|
||||||
}
|
}
|
||||||
if (newVal && !oldVal) {
|
if (newVal && !oldVal) {
|
||||||
// 有新值没有旧值 表单第一次加载赋值 需要往外抛一个事件 触发下级options的加载
|
// 有新值没有旧值 表单第一次加载赋值 需要往外抛一个事件 触发下级options的加载
|
||||||
handleFirstValueSetting(newVal)
|
handleFirstValueSetting(newVal);
|
||||||
}
|
}
|
||||||
}, {immediate:true});
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第一次加载赋值
|
* 第一次加载赋值
|
||||||
|
@ -92,16 +102,16 @@
|
||||||
async function handleFirstValueSetting(value) {
|
async function handleFirstValueSetting(value) {
|
||||||
if (props.idField === props.store) {
|
if (props.idField === props.store) {
|
||||||
// 如果id字段就是存储字段 那么可以不用调用请求
|
// 如果id字段就是存储字段 那么可以不用调用请求
|
||||||
emit('next', value)
|
emit('next', value);
|
||||||
} else {
|
} else {
|
||||||
if (props.origin === true) {
|
if (props.origin === true) {
|
||||||
// 如果是联动组件的第一个组件,等待options加载完后从options中取值
|
// 如果是联动组件的第一个组件,等待options加载完后从options中取值
|
||||||
await getSelfOptions()
|
await getSelfOptions();
|
||||||
valueChangeThenEmitNext(value)
|
valueChangeThenEmitNext(value);
|
||||||
} else {
|
} else {
|
||||||
// 如果是联动组件的后续组件,根据选中的value加载一遍数据
|
// 如果是联动组件的后续组件,根据选中的value加载一遍数据
|
||||||
let arr = await loadValueText();
|
let arr = await loadValueText();
|
||||||
valueChangeThenEmitNext(value, arr)
|
valueChangeThenEmitNext(value, arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,20 +119,20 @@
|
||||||
function loadOptions() {
|
function loadOptions() {
|
||||||
let params = getQueryParams();
|
let params = getQueryParams();
|
||||||
if (props.origin === true) {
|
if (props.origin === true) {
|
||||||
params['condition'] = props.condition
|
params['condition'] = props.condition;
|
||||||
} else {
|
} else {
|
||||||
params['pidValue'] = props.pidValue
|
params['pidValue'] = props.pidValue;
|
||||||
}
|
}
|
||||||
console.log("请求参数", params)
|
console.log('请求参数', params);
|
||||||
dictOptions.value = []
|
dictOptions.value = [];
|
||||||
defHttp.get({ url: SELECT_OPTIONS_URL, params},{ isTransformResponse: false }).then(res=>{
|
defHttp.get({ url: SELECT_OPTIONS_URL, params }, { isTransformResponse: false }).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
dictOptions.value = [...res.result]
|
dictOptions.value = [...res.result];
|
||||||
console.log("请求结果", res.result, dictOptions)
|
console.log('请求结果', res.result, dictOptions);
|
||||||
} else {
|
} else {
|
||||||
$message.warning('联动组件数据加载失败,请检查配置!')
|
$message.warning('联动组件数据加载失败,请检查配置!');
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueryParams() {
|
function getQueryParams() {
|
||||||
|
@ -131,34 +141,33 @@
|
||||||
txt: props.txt,
|
txt: props.txt,
|
||||||
key: props.store,
|
key: props.store,
|
||||||
idField: props.idField,
|
idField: props.idField,
|
||||||
pidField: props.pidField
|
pidField: props.pidField,
|
||||||
}
|
};
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadValueText() {
|
function loadValueText() {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
if (!props.value) {
|
if (!props.value) {
|
||||||
selectedValue.value = []
|
selectedValue.value = [];
|
||||||
resolve([])
|
resolve([]);
|
||||||
} else {
|
} else {
|
||||||
let params = getQueryParams();
|
let params = getQueryParams();
|
||||||
if (props.isNumber === true) {
|
if (props.isNumber === true) {
|
||||||
params['condition'] = `${props.store} = ${props.value}`
|
params['condition'] = `${props.store} = ${props.value}`;
|
||||||
} else {
|
} else {
|
||||||
params['condition'] = `${props.store} = '${props.value}'`
|
params['condition'] = `${props.store} = '${props.value}'`;
|
||||||
}
|
}
|
||||||
defHttp.get({ url: SELECT_OPTIONS_URL, params},{ isTransformResponse: false }).then(res=>{
|
defHttp.get({ url: SELECT_OPTIONS_URL, params }, { isTransformResponse: false }).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
resolve(res.result)
|
resolve(res.result);
|
||||||
} else {
|
} else {
|
||||||
$message.warning('联动组件数据加载失败,请检查配置!')
|
$message.warning('联动组件数据加载失败,请检查配置!');
|
||||||
resolve([])
|
resolve([]);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,18 +178,18 @@
|
||||||
let index = 0;
|
let index = 0;
|
||||||
(function next(index) {
|
(function next(index) {
|
||||||
if (index > 10) {
|
if (index > 10) {
|
||||||
resolve([])
|
resolve([]);
|
||||||
}
|
}
|
||||||
let arr = dictOptions.value
|
let arr = dictOptions.value;
|
||||||
if (arr && arr.length > 0) {
|
if (arr && arr.length > 0) {
|
||||||
resolve(arr)
|
resolve(arr);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
next(index++)
|
next(index++);
|
||||||
}, 300)
|
}, 300);
|
||||||
}
|
}
|
||||||
})(index)
|
})(index);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -189,12 +198,12 @@
|
||||||
function valueChangeThenEmitNext(value, arr: any = []) {
|
function valueChangeThenEmitNext(value, arr: any = []) {
|
||||||
if (value && value.length > 0) {
|
if (value && value.length > 0) {
|
||||||
if (!arr || arr.length == 0) {
|
if (!arr || arr.length == 0) {
|
||||||
arr = dictOptions.value
|
arr = dictOptions.value;
|
||||||
}
|
}
|
||||||
let selected = arr.filter(item=>item.store===value)
|
let selected = arr.filter((item) => item.store === value);
|
||||||
if (selected && selected.length > 0) {
|
if (selected && selected.length > 0) {
|
||||||
let id = selected[0].id
|
let id = selected[0].id;
|
||||||
emit('next', id)
|
emit('next', id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,12 +211,10 @@
|
||||||
return {
|
return {
|
||||||
selectedValue,
|
selectedValue,
|
||||||
dictOptions,
|
dictOptions,
|
||||||
handleChange
|
handleChange,
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -15,17 +15,17 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import JPopupOnlReportModal from './modal/JPopupOnlReportModal.vue'
|
import JPopupOnlReportModal from './modal/JPopupOnlReportModal.vue';
|
||||||
import { defineComponent, ref, reactive, onMounted, watchEffect, watch, computed, unref } from 'vue';
|
import { defineComponent, ref, reactive, onMounted, watchEffect, watch, computed, unref } from 'vue';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JPopup',
|
name: 'JPopup',
|
||||||
components: {
|
components: {
|
||||||
JPopupOnlReportModal
|
JPopupOnlReportModal,
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
setFieldsValue: propTypes.func,
|
setFieldsValue: propTypes.func,
|
||||||
fieldConfig: {
|
fieldConfig: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['update:value', 'register'],
|
emits: ['update:value', 'register'],
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
//表单值
|
//表单值
|
||||||
let { groupId, code, fieldConfig } = props;
|
let { groupId, code, fieldConfig } = props;
|
||||||
//唯一分组groupId
|
//唯一分组groupId
|
||||||
const uniqGroupId = computed(() => groupId ? `${groupId}_${code}_${fieldConfig[0]['source']}_${fieldConfig[0]['target']}` : '');
|
const uniqGroupId = computed(() => (groupId ? `${groupId}_${code}_${fieldConfig[0]['source']}_${fieldConfig[0]['target']}` : ''));
|
||||||
/**
|
/**
|
||||||
* 判断popup配置项是否正确
|
* 判断popup配置项是否正确
|
||||||
*/
|
*/
|
||||||
|
@ -100,8 +100,8 @@
|
||||||
//匹配popup设置的回调值
|
//匹配popup设置的回调值
|
||||||
let values = {};
|
let values = {};
|
||||||
for (let item of fieldConfig) {
|
for (let item of fieldConfig) {
|
||||||
let val = rows.map(row => row[item.source]).join(',');
|
let val = rows.map((row) => row[item.source]).join(',');
|
||||||
item.target.split(",").forEach(target => {
|
item.target.split(',').forEach((target) => {
|
||||||
values[target] = val;
|
values[target] = val;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,63 +7,63 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询条件用-数值范围查询
|
* 查询条件用-数值范围查询
|
||||||
*/
|
*/
|
||||||
import {ref, watch} from 'vue'
|
import { ref, watch } from 'vue';
|
||||||
export default {
|
export default {
|
||||||
name: "JRangeNumber",
|
name: 'JRangeNumber',
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: ['','']
|
default: ['', ''],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
emits: ['change'],
|
emits: ['change'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const beginValue = ref('')
|
const beginValue = ref('');
|
||||||
const endValue = ref('')
|
const endValue = ref('');
|
||||||
|
|
||||||
function handleChangeBegin(e) {
|
function handleChangeBegin(e) {
|
||||||
beginValue.value = e.target.value
|
beginValue.value = e.target.value;
|
||||||
emitArray()
|
emitArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChangeEnd(e) {
|
function handleChangeEnd(e) {
|
||||||
endValue.value = e.target.value
|
endValue.value = e.target.value;
|
||||||
emitArray()
|
emitArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitArray() {
|
function emitArray() {
|
||||||
let arr = []
|
let arr = [];
|
||||||
let begin = beginValue.value || ''
|
let begin = beginValue.value || '';
|
||||||
let end = endValue.value || ''
|
let end = endValue.value || '';
|
||||||
arr.push(begin)
|
arr.push(begin);
|
||||||
arr.push(end)
|
arr.push(end);
|
||||||
emit('change', arr)
|
emit('change', arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(()=>props.value, (val)=>{
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(val) => {
|
||||||
if (val.length == 2) {
|
if (val.length == 2) {
|
||||||
beginValue.value = val[0]
|
beginValue.value = val[0];
|
||||||
endValue.value = val[1]
|
endValue.value = val[1];
|
||||||
} else {
|
} else {
|
||||||
beginValue.value = ''
|
beginValue.value = '';
|
||||||
endValue.value = ''
|
endValue.value = '';
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
beginValue,
|
beginValue,
|
||||||
endValue,
|
endValue,
|
||||||
handleChangeBegin,
|
handleChangeBegin,
|
||||||
handleChangeEnd
|
handleChangeEnd,
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -29,35 +29,32 @@
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:filterOption="filterOption"
|
:filterOption="filterOption"
|
||||||
:notFoundContent="loading ? undefined : null"
|
:notFoundContent="loading ? undefined : null"
|
||||||
@change="handleChange">
|
@change="handleChange"
|
||||||
|
>
|
||||||
<template #notFoundContent>
|
<template #notFoundContent>
|
||||||
<a-spin v-if="loading" size="small" />
|
<a-spin v-if="loading" size="small" />
|
||||||
</template>
|
</template>
|
||||||
<a-select-option v-for="d in options" :key="d.value" :value="d.value">{{ d.text }}</a-select-option>
|
<a-select-option v-for="d in options" :key="d.value" :value="d.value">{{ d.text }}</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { useDebounceFn } from '@vueuse/core';
|
import { useDebounceFn } from '@vueuse/core';
|
||||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import {initDictOptions} from "/@/utils/dict/index"
|
import { initDictOptions } from '/@/utils/dict/index';
|
||||||
import { defHttp } from '/@/utils/http/axios';
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JSearchSelect',
|
name: 'JSearchSelect',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.number
|
|
||||||
]),
|
|
||||||
dict: propTypes.string,
|
dict: propTypes.string,
|
||||||
dictOptions: {
|
dictOptions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => [],
|
||||||
},
|
},
|
||||||
async: propTypes.bool.def(false),
|
async: propTypes.bool.def(false),
|
||||||
placeholder: propTypes.string,
|
placeholder: propTypes.string,
|
||||||
|
@ -65,8 +62,8 @@
|
||||||
pageSize: propTypes.number.def(10),
|
pageSize: propTypes.number.def(10),
|
||||||
getPopupContainer: {
|
getPopupContainer: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: (node) => node.parentNode
|
default: (node) => node.parentNode,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
emits: ['change', 'update:value'],
|
emits: ['change', 'update:value'],
|
||||||
setup(props, { emit, refs }) {
|
setup(props, { emit, refs }) {
|
||||||
|
@ -91,10 +88,10 @@
|
||||||
() => props.value,
|
() => props.value,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (val || val === 0) {
|
if (val || val === 0) {
|
||||||
initSelectValue()
|
initSelectValue();
|
||||||
} else {
|
} else {
|
||||||
selectedValue.value = []
|
selectedValue.value = [];
|
||||||
selectedAsyncValue.value = []
|
selectedAsyncValue.value = [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
@ -106,7 +103,7 @@
|
||||||
() => props.dictOptions,
|
() => props.dictOptions,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (val && val.length > 0) {
|
if (val && val.length > 0) {
|
||||||
options.value = [...val]
|
options.value = [...val];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
@ -116,19 +113,19 @@
|
||||||
*/
|
*/
|
||||||
async function loadData(value) {
|
async function loadData(value) {
|
||||||
lastLoad.value += 1;
|
lastLoad.value += 1;
|
||||||
const currentLoad = unref(lastLoad)
|
const currentLoad = unref(lastLoad);
|
||||||
options.value = [];
|
options.value = [];
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
// 字典code格式:table,text,code
|
// 字典code格式:table,text,code
|
||||||
defHttp.get({url:`/sys/dict/loadDict/${props.dict}`,params:{keyword: value, pageSize: props.pageSize}}).then(res => {
|
defHttp.get({ url: `/sys/dict/loadDict/${props.dict}`, params: { keyword: value, pageSize: props.pageSize } }).then((res) => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (res && res.length > 0) {
|
if (res && res.length > 0) {
|
||||||
if (currentLoad != unref(lastLoad)) {
|
if (currentLoad != unref(lastLoad)) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
options.value = res
|
options.value = res;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 初始化value
|
* 初始化value
|
||||||
|
@ -136,25 +133,25 @@
|
||||||
function initSelectValue() {
|
function initSelectValue() {
|
||||||
//update-begin-author:taoyan date:2022-4-24 for: 下拉搜索组件每次选中值会触发value的监听事件,触发此方法,但是实际不需要
|
//update-begin-author:taoyan date:2022-4-24 for: 下拉搜索组件每次选中值会触发value的监听事件,触发此方法,但是实际不需要
|
||||||
if (loadSelectText.value === false) {
|
if (loadSelectText.value === false) {
|
||||||
loadSelectText.value = true
|
loadSelectText.value = true;
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
//update-end-author:taoyan date:2022-4-24 for: 下拉搜索组件每次选中值会触发value的监听事件,触发此方法,但是实际不需要
|
//update-end-author:taoyan date:2022-4-24 for: 下拉搜索组件每次选中值会触发value的监听事件,触发此方法,但是实际不需要
|
||||||
let { async, value, dict } = props;
|
let { async, value, dict } = props;
|
||||||
if (async) {
|
if (async) {
|
||||||
if (!selectedAsyncValue || !selectedAsyncValue.key || selectedAsyncValue.key !== value) {
|
if (!selectedAsyncValue || !selectedAsyncValue.key || selectedAsyncValue.key !== value) {
|
||||||
defHttp.get({url: `/sys/dict/loadDictItem/${dict}`, params: {key: value}}).then(res => {
|
defHttp.get({ url: `/sys/dict/loadDictItem/${dict}`, params: { key: value } }).then((res) => {
|
||||||
if (res && res.length > 0) {
|
if (res && res.length > 0) {
|
||||||
let obj = {
|
let obj = {
|
||||||
key: value,
|
key: value,
|
||||||
label: res
|
label: res,
|
||||||
};
|
};
|
||||||
selectedAsyncValue.value = {...obj}
|
selectedAsyncValue.value = { ...obj };
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selectedValue.value = value.toString()
|
selectedValue.value = value.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,35 +163,35 @@
|
||||||
if (!async) {
|
if (!async) {
|
||||||
//如果字典项集合有数据
|
//如果字典项集合有数据
|
||||||
if (dictOptions && dictOptions.length > 0) {
|
if (dictOptions && dictOptions.length > 0) {
|
||||||
options.value = dictOptions
|
options.value = dictOptions;
|
||||||
} else {
|
} else {
|
||||||
//根据字典Code, 初始化字典数组
|
//根据字典Code, 初始化字典数组
|
||||||
let dictStr = ''
|
let dictStr = '';
|
||||||
if (dict) {
|
if (dict) {
|
||||||
let arr = dict.split(',')
|
let arr = dict.split(',');
|
||||||
if (arr[0].indexOf('where') > 0) {
|
if (arr[0].indexOf('where') > 0) {
|
||||||
let tbInfo = arr[0].split('where')
|
let tbInfo = arr[0].split('where');
|
||||||
dictStr = tbInfo[0].trim() + ',' + arr[1] + ',' + arr[2] + ',' + encodeURIComponent(tbInfo[1])
|
dictStr = tbInfo[0].trim() + ',' + arr[1] + ',' + arr[2] + ',' + encodeURIComponent(tbInfo[1]);
|
||||||
} else {
|
} else {
|
||||||
dictStr = dict
|
dictStr = dict;
|
||||||
}
|
}
|
||||||
//根据字典Code, 初始化字典数组
|
//根据字典Code, 初始化字典数组
|
||||||
const dictData = await initDictOptions(dictStr);
|
const dictData = await initDictOptions(dictStr);
|
||||||
options.value = dictData
|
options.value = dictData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!dict) {
|
if (!dict) {
|
||||||
console.error('搜索组件未配置字典项')
|
console.error('搜索组件未配置字典项');
|
||||||
} else {
|
} else {
|
||||||
//异步一开始也加载一点数据
|
//异步一开始也加载一点数据
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
defHttp.get({url: `/sys/dict/loadDict/${dict}`, params: {pageSize: pageSize, keyword: ''}}).then(res => {
|
defHttp.get({ url: `/sys/dict/loadDict/${dict}`, params: { pageSize: pageSize, keyword: '' } }).then((res) => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (res && res.length > 0) {
|
if (res && res.length > 0) {
|
||||||
options.value = res
|
options.value = res;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +200,7 @@
|
||||||
* */
|
* */
|
||||||
function handleChange(value) {
|
function handleChange(value) {
|
||||||
selectedValue.value = value;
|
selectedValue.value = value;
|
||||||
callback()
|
callback();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 异步改变事件
|
* 异步改变事件
|
||||||
|
@ -211,14 +208,14 @@
|
||||||
function handleAsyncChange(selectedObj) {
|
function handleAsyncChange(selectedObj) {
|
||||||
if (selectedObj) {
|
if (selectedObj) {
|
||||||
selectedAsyncValue.value = selectedObj;
|
selectedAsyncValue.value = selectedObj;
|
||||||
selectedValue.value = selectedObj.key
|
selectedValue.value = selectedObj.key;
|
||||||
} else {
|
} else {
|
||||||
selectedAsyncValue.value = null;
|
selectedAsyncValue.value = null;
|
||||||
selectedValue.value = null;
|
selectedValue.value = null;
|
||||||
options.value = null;
|
options.value = null;
|
||||||
loadData("")
|
loadData('');
|
||||||
}
|
}
|
||||||
callback()
|
callback();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*回调方法
|
*回调方法
|
||||||
|
@ -232,18 +229,18 @@
|
||||||
* 过滤选中option
|
* 过滤选中option
|
||||||
*/
|
*/
|
||||||
function filterOption(input, option) {
|
function filterOption(input, option) {
|
||||||
return option?.children[0]?.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
return option?.children[0]?.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParentContainer(node) {
|
function getParentContainer(node) {
|
||||||
// update-begin-author:taoyan date:20220407 for: getPopupContainer一直有值 导致popContainer的逻辑永远走不进去,把它挪到前面判断
|
// update-begin-author:taoyan date:20220407 for: getPopupContainer一直有值 导致popContainer的逻辑永远走不进去,把它挪到前面判断
|
||||||
if (props.popContainer) {
|
if (props.popContainer) {
|
||||||
return document.querySelector(props.popContainer)
|
return document.querySelector(props.popContainer);
|
||||||
} else {
|
} else {
|
||||||
if (typeof props.getPopupContainer === 'function') {
|
if (typeof props.getPopupContainer === 'function') {
|
||||||
return props.getPopupContainer(node)
|
return props.getPopupContainer(node);
|
||||||
} else {
|
} else {
|
||||||
return node.parentNode
|
return node.parentNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update-end-author:taoyan date:20220407 for: getPopupContainer一直有值 导致popContainer的逻辑永远走不进去,把它挪到前面判断
|
// update-end-author:taoyan date:20220407 for: getPopupContainer一直有值 导致popContainer的逻辑永远走不进去,把它挪到前面判断
|
||||||
|
@ -258,12 +255,10 @@
|
||||||
getParentContainer,
|
getParentContainer,
|
||||||
filterOption,
|
filterOption,
|
||||||
handleChange,
|
handleChange,
|
||||||
handleAsyncChange
|
handleAsyncChange,
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -38,10 +38,10 @@
|
||||||
const selectOptions = ref<SelectTypes['options']>([]);
|
const selectOptions = ref<SelectTypes['options']>([]);
|
||||||
//下拉框选中值
|
//下拉框选中值
|
||||||
let selectValues = reactive<object>({
|
let selectValues = reactive<object>({
|
||||||
value: []
|
value: [],
|
||||||
});
|
});
|
||||||
// 是否正在加载回显数据
|
// 是否正在加载回显数据
|
||||||
const loadingEcho = ref<boolean>(false)
|
const loadingEcho = ref<boolean>(false);
|
||||||
//下发 selectOptions,xxxBiz组件接收
|
//下发 selectOptions,xxxBiz组件接收
|
||||||
provide('selectOptions', selectOptions);
|
provide('selectOptions', selectOptions);
|
||||||
//下发 selectValues,xxxBiz组件接收
|
//下发 selectValues,xxxBiz组件接收
|
||||||
|
@ -59,8 +59,8 @@
|
||||||
props.value && initValue();
|
props.value && initValue();
|
||||||
// update-begin-author:taoyan date:20220401 for:调用表单的 resetFields不会清空当前部门信息,界面显示上一次的数据
|
// update-begin-author:taoyan date:20220401 for:调用表单的 resetFields不会清空当前部门信息,界面显示上一次的数据
|
||||||
if (props.value === '' || props.value === undefined) {
|
if (props.value === '' || props.value === undefined) {
|
||||||
state.value = []
|
state.value = [];
|
||||||
selectValues.value = []
|
selectValues.value = [];
|
||||||
}
|
}
|
||||||
// update-end-author:taoyan date:20220401 for:调用表单的 resetFields不会清空当前部门信息,界面显示上一次的数据
|
// update-end-author:taoyan date:20220401 for:调用表单的 resetFields不会清空当前部门信息,界面显示上一次的数据
|
||||||
});
|
});
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
*/
|
*/
|
||||||
watch(selectOptions, () => {
|
watch(selectOptions, () => {
|
||||||
if (selectOptions) {
|
if (selectOptions) {
|
||||||
emit('select',toRaw(unref(selectOptions)),toRaw(unref(selectValues)))
|
emit('select', toRaw(unref(selectOptions)), toRaw(unref(selectValues)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@
|
||||||
state.value = value.split(',');
|
state.value = value.split(',');
|
||||||
selectValues.value = value.split(',');
|
selectValues.value = value.split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +111,7 @@
|
||||||
//emitData.value = values.join(",");
|
//emitData.value = values.join(",");
|
||||||
state.value = values;
|
state.value = values;
|
||||||
selectValues.value = values;
|
selectValues.value = values;
|
||||||
emit('update:value', values.join(','))
|
emit('update:value', values.join(','));
|
||||||
}
|
}
|
||||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { defineComponent, ref, watch, computed } from 'vue'
|
import { defineComponent, ref, watch, computed } from 'vue';
|
||||||
|
|
||||||
// 可以输入的下拉框(此组件暂时没有人用)
|
// 可以输入的下拉框(此组件暂时没有人用)
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
@ -15,53 +15,65 @@ export default defineComponent({
|
||||||
emits: ['change', 'update:value'],
|
emits: ['change', 'update:value'],
|
||||||
setup(props, { emit, attrs }) {
|
setup(props, { emit, attrs }) {
|
||||||
// 内部 options 选项
|
// 内部 options 选项
|
||||||
const options = ref<any[]>([])
|
const options = ref<any[]>([]);
|
||||||
// 监听外部 options 变化,并覆盖内部 options
|
// 监听外部 options 变化,并覆盖内部 options
|
||||||
watch(() => props.options, () => {
|
watch(
|
||||||
options.value = [...props.options]
|
() => props.options,
|
||||||
}, { deep: true, immediate: true })
|
() => {
|
||||||
|
options.value = [...props.options];
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
// 合并 props 和 attrs
|
// 合并 props 和 attrs
|
||||||
const bindProps: any = computed(() => Object.assign({
|
const bindProps: any = computed(() =>
|
||||||
|
Object.assign(
|
||||||
|
{
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
}, props, attrs, {
|
},
|
||||||
|
props,
|
||||||
|
attrs,
|
||||||
|
{
|
||||||
options: options.value,
|
options: options.value,
|
||||||
}))
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
function onChange(...args: any[]) {
|
function onChange(...args: any[]) {
|
||||||
deleteSearchAdd(args[0])
|
deleteSearchAdd(args[0]);
|
||||||
emit('change', ...args)
|
emit('change', ...args);
|
||||||
emit('update:value', args[0])
|
emit('update:value', args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSearch(value) {
|
function onSearch(value) {
|
||||||
// 是否找到了对应的项,找不到则添加这一项
|
// 是否找到了对应的项,找不到则添加这一项
|
||||||
let foundIt = options.value.findIndex(option => {
|
let foundIt =
|
||||||
return option.value.toString() === value.toString()
|
options.value.findIndex((option) => {
|
||||||
}) !== -1
|
return option.value.toString() === value.toString();
|
||||||
|
}) !== -1;
|
||||||
// !!value :不添加空值
|
// !!value :不添加空值
|
||||||
if (!foundIt && !!value) {
|
if (!foundIt && !!value) {
|
||||||
deleteSearchAdd(value)
|
deleteSearchAdd(value);
|
||||||
// searchAdd 是否是通过搜索添加的
|
// searchAdd 是否是通过搜索添加的
|
||||||
options.value.push({ value: value, searchAdd: true })
|
options.value.push({ value: value, searchAdd: true });
|
||||||
//onChange(value,{ value })
|
//onChange(value,{ value })
|
||||||
} else if (foundIt) {
|
} else if (foundIt) {
|
||||||
onChange(value)
|
onChange(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除无用的因搜索(用户输入)而创建的项
|
// 删除无用的因搜索(用户输入)而创建的项
|
||||||
function deleteSearchAdd(value = '') {
|
function deleteSearchAdd(value = '') {
|
||||||
let indexes: any[] = []
|
let indexes: any[] = [];
|
||||||
options.value.forEach((option, index) => {
|
options.value.forEach((option, index) => {
|
||||||
if (option.searchAdd) {
|
if (option.searchAdd) {
|
||||||
if ((option.value ?? '').toString() !== value.toString()) {
|
if ((option.value ?? '').toString() !== value.toString()) {
|
||||||
indexes.push(index)
|
indexes.push(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
// 翻转删除数组中的项
|
// 翻转删除数组中的项
|
||||||
for (let index of indexes.reverse()) {
|
for (let index of indexes.reverse()) {
|
||||||
options.value.splice(index, 1)
|
options.value.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +81,9 @@ export default defineComponent({
|
||||||
bindProps,
|
bindProps,
|
||||||
onChange,
|
onChange,
|
||||||
onSearch,
|
onSearch,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
components: {},
|
components: {},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array,
|
|
||||||
]),
|
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '请选择',
|
default: '请选择',
|
||||||
|
@ -68,7 +65,6 @@
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.dictCode) {
|
if (props.dictCode) {
|
||||||
loadDictOptions();
|
loadDictOptions();
|
||||||
|
@ -77,15 +73,16 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(() => props.value,
|
watch(
|
||||||
|
() => props.value,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
arrayValue.value = [];
|
arrayValue.value = [];
|
||||||
} else {
|
} else {
|
||||||
arrayValue.value = props.value.split(props.spliter);
|
arrayValue.value = props.value.split(props.spliter);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
function onChange(selectedValue) {
|
function onChange(selectedValue) {
|
||||||
if (props.triggerChange) {
|
if (props.triggerChange) {
|
||||||
|
@ -106,9 +103,9 @@
|
||||||
|
|
||||||
// 根据字典code查询字典项
|
// 根据字典code查询字典项
|
||||||
function loadDictOptions() {
|
function loadDictOptions() {
|
||||||
getDictItems(props.dictCode).then(res => {
|
getDictItems(props.dictCode).then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
dictOptions.value = res.map(item => ({ value: item.value, label: item.text }));
|
dictOptions.value = res.map((item) => ({ value: item.value, label: item.text }));
|
||||||
//console.info('res', dictOptions.value);
|
//console.info('res', dictOptions.value);
|
||||||
} else {
|
} else {
|
||||||
console.error('getDictItems error: : ', res);
|
console.error('getDictItems error: : ', res);
|
||||||
|
@ -126,6 +123,5 @@
|
||||||
getParentContainer,
|
getParentContainer,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -6,26 +6,24 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import PositionSelectModal from './modal/PositionSelectModal.vue'
|
import PositionSelectModal from './modal/PositionSelectModal.vue';
|
||||||
import JSelectBiz from './base/JSelectBiz.vue';
|
import JSelectBiz from './base/JSelectBiz.vue';
|
||||||
import { defineComponent, ref, reactive, watchEffect, watch, provide, computed, unref } from 'vue';
|
import { defineComponent, ref, reactive, watchEffect, watch, provide, computed, unref } from 'vue';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JSelectPosition',
|
name: 'JSelectPosition',
|
||||||
components: {
|
components: {
|
||||||
PositionSelectModal, JSelectBiz
|
PositionSelectModal,
|
||||||
|
JSelectBiz,
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array
|
|
||||||
]),
|
|
||||||
labelKey: {
|
labelKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'name',
|
default: 'name',
|
||||||
|
@ -36,8 +34,7 @@
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change'],
|
emits: ['options-change', 'change'],
|
||||||
|
@ -52,10 +49,10 @@
|
||||||
//下拉框选中值
|
//下拉框选中值
|
||||||
let selectValues = reactive<object>({
|
let selectValues = reactive<object>({
|
||||||
value: [],
|
value: [],
|
||||||
change: false
|
change: false,
|
||||||
});
|
});
|
||||||
// 是否正在加载回显数据
|
// 是否正在加载回显数据
|
||||||
const loadingEcho = ref<boolean>(false)
|
const loadingEcho = ref<boolean>(false);
|
||||||
//下发 selectOptions,xxxBiz组件接收
|
//下发 selectOptions,xxxBiz组件接收
|
||||||
provide('selectOptions', selectOptions);
|
provide('selectOptions', selectOptions);
|
||||||
//下发 selectValues,xxxBiz组件接收
|
//下发 selectValues,xxxBiz组件接收
|
||||||
|
@ -66,7 +63,6 @@
|
||||||
const tag = ref(false);
|
const tag = ref(false);
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听组件值
|
* 监听组件值
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +77,7 @@
|
||||||
if (selectValues) {
|
if (selectValues) {
|
||||||
state.value = selectValues.value;
|
state.value = selectValues.value;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡弹出框
|
* 打卡弹出框
|
||||||
|
@ -99,8 +95,8 @@
|
||||||
function initValue() {
|
function initValue() {
|
||||||
let value = props.value ? props.value : [];
|
let value = props.value ? props.value : [];
|
||||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||||
state.value = value.split(",");
|
state.value = value.split(',');
|
||||||
selectValues.value = value.split(",");
|
selectValues.value = value.split(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +104,7 @@
|
||||||
* 设置下拉框的值
|
* 设置下拉框的值
|
||||||
*/
|
*/
|
||||||
function setValue(options, values) {
|
function setValue(options, values) {
|
||||||
selectOptions.value = options
|
selectOptions.value = options;
|
||||||
//emitData.value = values.join(",");
|
//emitData.value = values.join(",");
|
||||||
state.value = values;
|
state.value = values;
|
||||||
selectValues.value = values;
|
selectValues.value = values;
|
||||||
|
@ -125,7 +121,7 @@
|
||||||
tag,
|
tag,
|
||||||
regModal,
|
regModal,
|
||||||
setValue,
|
setValue,
|
||||||
handleOpen
|
handleOpen,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,26 +6,24 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import RoleSelectModal from './modal/RoleSelectModal.vue'
|
import RoleSelectModal from './modal/RoleSelectModal.vue';
|
||||||
import JSelectBiz from './base/JSelectBiz.vue';
|
import JSelectBiz from './base/JSelectBiz.vue';
|
||||||
import { defineComponent, ref, unref, reactive, watchEffect, watch, provide } from 'vue';
|
import { defineComponent, ref, unref, reactive, watchEffect, watch, provide } from 'vue';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JSelectRole',
|
name: 'JSelectRole',
|
||||||
components: {
|
components: {
|
||||||
RoleSelectModal, JSelectBiz
|
RoleSelectModal,
|
||||||
|
JSelectBiz,
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array
|
|
||||||
]),
|
|
||||||
labelKey: {
|
labelKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'roleName',
|
default: 'roleName',
|
||||||
|
@ -36,8 +34,7 @@
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change'],
|
emits: ['options-change', 'change'],
|
||||||
|
@ -52,10 +49,10 @@
|
||||||
//下拉框选中值
|
//下拉框选中值
|
||||||
let selectValues = reactive<object>({
|
let selectValues = reactive<object>({
|
||||||
value: [],
|
value: [],
|
||||||
change: false
|
change: false,
|
||||||
});
|
});
|
||||||
// 是否正在加载回显数据
|
// 是否正在加载回显数据
|
||||||
const loadingEcho = ref<boolean>(false)
|
const loadingEcho = ref<boolean>(false);
|
||||||
//下发 selectOptions,xxxBiz组件接收
|
//下发 selectOptions,xxxBiz组件接收
|
||||||
provide('selectOptions', selectOptions);
|
provide('selectOptions', selectOptions);
|
||||||
//下发 selectValues,xxxBiz组件接收
|
//下发 selectValues,xxxBiz组件接收
|
||||||
|
@ -66,7 +63,6 @@
|
||||||
const tag = ref(false);
|
const tag = ref(false);
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听组件值
|
* 监听组件值
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +77,7 @@
|
||||||
if (selectValues) {
|
if (selectValues) {
|
||||||
state.value = selectValues.value;
|
state.value = selectValues.value;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡弹出框
|
* 打卡弹出框
|
||||||
|
@ -99,8 +95,8 @@
|
||||||
function initValue() {
|
function initValue() {
|
||||||
let value = props.value ? props.value : [];
|
let value = props.value ? props.value : [];
|
||||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||||
state.value = value.split(",");
|
state.value = value.split(',');
|
||||||
selectValues.value = value.split(",");
|
selectValues.value = value.split(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +104,7 @@
|
||||||
* 设置下拉框的值
|
* 设置下拉框的值
|
||||||
*/
|
*/
|
||||||
function setValue(options, values) {
|
function setValue(options, values) {
|
||||||
selectOptions.value = options
|
selectOptions.value = options;
|
||||||
//emitData.value = values.join(",");
|
//emitData.value = values.join(",");
|
||||||
state.value = values;
|
state.value = values;
|
||||||
selectValues.value = values;
|
selectValues.value = values;
|
||||||
|
@ -124,7 +120,7 @@
|
||||||
tag,
|
tag,
|
||||||
regModal,
|
regModal,
|
||||||
setValue,
|
setValue,
|
||||||
handleOpen
|
handleOpen,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,26 +7,24 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { unref } from 'vue';
|
import { unref } from 'vue';
|
||||||
import UserSelectModal from './modal/UserSelectModal.vue'
|
import UserSelectModal from './modal/UserSelectModal.vue';
|
||||||
import JSelectBiz from './base/JSelectBiz.vue';
|
import JSelectBiz from './base/JSelectBiz.vue';
|
||||||
import { defineComponent, ref, reactive, watchEffect, watch, provide } from 'vue';
|
import { defineComponent, ref, reactive, watchEffect, watch, provide } from 'vue';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JSelectUser',
|
name: 'JSelectUser',
|
||||||
components: {
|
components: {
|
||||||
UserSelectModal, JSelectBiz
|
UserSelectModal,
|
||||||
|
JSelectBiz,
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array
|
|
||||||
]),
|
|
||||||
labelKey: {
|
labelKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'realname',
|
default: 'realname',
|
||||||
|
@ -37,8 +35,7 @@
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['options-change', 'change', 'update:value'],
|
emits: ['options-change', 'change', 'update:value'],
|
||||||
|
@ -53,10 +50,10 @@
|
||||||
//下拉框选中值
|
//下拉框选中值
|
||||||
let selectValues = reactive<object>({
|
let selectValues = reactive<object>({
|
||||||
value: [],
|
value: [],
|
||||||
change: false
|
change: false,
|
||||||
});
|
});
|
||||||
// 是否正在加载回显数据
|
// 是否正在加载回显数据
|
||||||
const loadingEcho = ref<boolean>(false)
|
const loadingEcho = ref<boolean>(false);
|
||||||
//下发 selectOptions,xxxBiz组件接收
|
//下发 selectOptions,xxxBiz组件接收
|
||||||
provide('selectOptions', selectOptions);
|
provide('selectOptions', selectOptions);
|
||||||
//下发 selectValues,xxxBiz组件接收
|
//下发 selectValues,xxxBiz组件接收
|
||||||
|
@ -67,7 +64,6 @@
|
||||||
const tag = ref(false);
|
const tag = ref(false);
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听组件值
|
* 监听组件值
|
||||||
*/
|
*/
|
||||||
|
@ -75,7 +71,7 @@
|
||||||
props.value && initValue();
|
props.value && initValue();
|
||||||
// 查询条件重置的时候 界面显示未清空
|
// 查询条件重置的时候 界面显示未清空
|
||||||
if (!props.value) {
|
if (!props.value) {
|
||||||
selectValues.value = []
|
selectValues.value = [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,7 +82,7 @@
|
||||||
if (selectValues) {
|
if (selectValues) {
|
||||||
state.value = selectValues.value;
|
state.value = selectValues.value;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打卡弹出框
|
* 打卡弹出框
|
||||||
|
@ -104,8 +100,8 @@
|
||||||
function initValue() {
|
function initValue() {
|
||||||
let value = props.value ? props.value : [];
|
let value = props.value ? props.value : [];
|
||||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||||
state.value = value.split(",");
|
state.value = value.split(',');
|
||||||
selectValues.value = value.split(",");
|
selectValues.value = value.split(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,11 +109,11 @@
|
||||||
* 设置下拉框的值
|
* 设置下拉框的值
|
||||||
*/
|
*/
|
||||||
function setValue(options, values) {
|
function setValue(options, values) {
|
||||||
selectOptions.value = options
|
selectOptions.value = options;
|
||||||
//emitData.value = values.join(",");
|
//emitData.value = values.join(",");
|
||||||
state.value = values;
|
state.value = values;
|
||||||
selectValues.value = values;
|
selectValues.value = values;
|
||||||
emit('update:value', values.join(','))
|
emit('update:value', values.join(','));
|
||||||
}
|
}
|
||||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||||
return {
|
return {
|
||||||
|
@ -130,7 +126,7 @@
|
||||||
tag,
|
tag,
|
||||||
regModal,
|
regModal,
|
||||||
setValue,
|
setValue,
|
||||||
handleOpen
|
handleOpen,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,25 +7,23 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { unref } from 'vue';
|
import { unref } from 'vue';
|
||||||
import UserSelectByDepModal from './modal/UserSelectByDepModal.vue'
|
import UserSelectByDepModal from './modal/UserSelectByDepModal.vue';
|
||||||
import JSelectBiz from './base/JSelectBiz.vue';
|
import JSelectBiz from './base/JSelectBiz.vue';
|
||||||
import { defineComponent, ref, reactive, watchEffect, watch, provide } from 'vue';
|
import { defineComponent, ref, reactive, watchEffect, watch, provide } from 'vue';
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import {propTypes} from "/@/utils/propTypes";
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'JSelectUserByDept',
|
name: 'JSelectUserByDept',
|
||||||
components: {
|
components: {
|
||||||
UserSelectByDepModal, JSelectBiz
|
UserSelectByDepModal,
|
||||||
|
JSelectBiz,
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.array
|
|
||||||
]),
|
|
||||||
rowKey: {
|
rowKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'username',
|
default: 'username',
|
||||||
|
@ -47,10 +45,10 @@
|
||||||
//下拉框选中值
|
//下拉框选中值
|
||||||
let selectValues = reactive<object>({
|
let selectValues = reactive<object>({
|
||||||
value: [],
|
value: [],
|
||||||
change: false
|
change: false,
|
||||||
});
|
});
|
||||||
// 是否正在加载回显数据
|
// 是否正在加载回显数据
|
||||||
const loadingEcho = ref<boolean>(false)
|
const loadingEcho = ref<boolean>(false);
|
||||||
//下发 selectOptions,xxxBiz组件接收
|
//下发 selectOptions,xxxBiz组件接收
|
||||||
provide('selectOptions', selectOptions);
|
provide('selectOptions', selectOptions);
|
||||||
//下发 selectValues,xxxBiz组件接收
|
//下发 selectValues,xxxBiz组件接收
|
||||||
|
@ -61,7 +59,6 @@
|
||||||
const tag = ref(false);
|
const tag = ref(false);
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听组件值
|
* 监听组件值
|
||||||
*/
|
*/
|
||||||
|
@ -94,8 +91,8 @@
|
||||||
function initValue() {
|
function initValue() {
|
||||||
let value = props.value ? props.value : [];
|
let value = props.value ? props.value : [];
|
||||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||||
state.value = value.split(",");
|
state.value = value.split(',');
|
||||||
selectValues.value = value.split(",");
|
selectValues.value = value.split(',');
|
||||||
} else {
|
} else {
|
||||||
selectValues.value = value;
|
selectValues.value = value;
|
||||||
}
|
}
|
||||||
|
@ -109,11 +106,11 @@
|
||||||
//emitData.value = values.join(",");
|
//emitData.value = values.join(",");
|
||||||
state.value = values;
|
state.value = values;
|
||||||
selectValues.value = values;
|
selectValues.value = values;
|
||||||
emit('update:value', values)
|
emit('update:value', values);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChange(values) {
|
function handleChange(values) {
|
||||||
emit('update:value', values)
|
emit('update:value', values);
|
||||||
}
|
}
|
||||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||||
return {
|
return {
|
||||||
|
@ -127,7 +124,7 @@
|
||||||
regModal,
|
regModal,
|
||||||
setValue,
|
setValue,
|
||||||
handleOpen,
|
handleOpen,
|
||||||
handleChange
|
handleChange,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,34 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="prefixCls">
|
<div :class="prefixCls">
|
||||||
<a-select
|
<a-select v-if="query" :options="selectOptions" :disabled="disabled" style="width: 100%" v-bind="attrs" @change="onSelectChange" />
|
||||||
v-if="query"
|
<a-switch v-else v-model:checked="checked" :disabled="disabled" v-bind="attrs" @change="onSwitchChange" />
|
||||||
:options="selectOptions"
|
|
||||||
:disabled="disabled"
|
|
||||||
style="width: 100%"
|
|
||||||
v-bind="attrs"
|
|
||||||
@change="onSelectChange"/>
|
|
||||||
<a-switch
|
|
||||||
v-else
|
|
||||||
v-model:checked="checked"
|
|
||||||
:disabled="disabled"
|
|
||||||
v-bind="attrs"
|
|
||||||
@change="onSwitchChange"/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
|
|
||||||
const { prefixCls } = useDesign('j-switch')
|
const { prefixCls } = useDesign('j-switch');
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// v-model:value
|
// v-model:value
|
||||||
value: propTypes.oneOfType([
|
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||||
propTypes.string,
|
|
||||||
propTypes.number,
|
|
||||||
]),
|
|
||||||
// 取值 options
|
// 取值 options
|
||||||
options: propTypes.array.def(() => ['Y', 'N']),
|
options: propTypes.array.def(() => ['Y', 'N']),
|
||||||
// 文本 options
|
// 文本 options
|
||||||
|
@ -37,42 +23,46 @@ const props = defineProps({
|
||||||
query: propTypes.bool.def(false),
|
query: propTypes.bool.def(false),
|
||||||
// 是否禁用
|
// 是否禁用
|
||||||
disabled: propTypes.bool.def(false),
|
disabled: propTypes.bool.def(false),
|
||||||
})
|
});
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs();
|
||||||
const emit = defineEmits(['change', 'update:value'])
|
const emit = defineEmits(['change', 'update:value']);
|
||||||
|
|
||||||
const checked = ref<boolean>(false)
|
const checked = ref<boolean>(false);
|
||||||
|
|
||||||
watch(() => props.value, (val) => {
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(val) => {
|
||||||
if (!props.query) {
|
if (!props.query) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
checked.value = false
|
checked.value = false;
|
||||||
emitValue(props.options[1])
|
emitValue(props.options[1]);
|
||||||
} else {
|
} else {
|
||||||
checked.value = props.options[0] == val
|
checked.value = props.options[0] == val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
const selectOptions = computed(() => {
|
const selectOptions = computed(() => {
|
||||||
let options: any[] = []
|
let options: any[] = [];
|
||||||
options.push({ value: props.options[0], label: props.labelOptions[0] })
|
options.push({ value: props.options[0], label: props.labelOptions[0] });
|
||||||
options.push({ value: props.options[1], label: props.labelOptions[1] })
|
options.push({ value: props.options[1], label: props.labelOptions[1] });
|
||||||
return options
|
return options;
|
||||||
})
|
});
|
||||||
|
|
||||||
function onSwitchChange(checked) {
|
function onSwitchChange(checked) {
|
||||||
let flag = checked === false ? props.options[1] : props.options[0]
|
let flag = checked === false ? props.options[1] : props.options[0];
|
||||||
emitValue(flag)
|
emitValue(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelectChange(value) {
|
function onSelectChange(value) {
|
||||||
emitValue(value)
|
emitValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitValue(value) {
|
function emitValue(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -82,5 +72,4 @@ function emitValue(value) {
|
||||||
|
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -9,17 +9,18 @@
|
||||||
:dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
|
:dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
@change="onChange">
|
@change="onChange"
|
||||||
|
>
|
||||||
</TreeSelect>
|
</TreeSelect>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue';
|
||||||
import { defHttp } from '/@/utils/http/axios'
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
import { propTypes } from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign'
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { TreeSelect } from 'ant-design-vue'
|
import { TreeSelect } from 'ant-design-vue';
|
||||||
|
|
||||||
enum Api {
|
enum Api {
|
||||||
view = '/sys/category/loadOne',
|
view = '/sys/category/loadOne',
|
||||||
|
@ -27,33 +28,41 @@ enum Api {
|
||||||
children = '/sys/category/loadTreeChildren',
|
children = '/sys/category/loadTreeChildren',
|
||||||
}
|
}
|
||||||
|
|
||||||
const { prefixCls } = useDesign('j-tree-dict')
|
const { prefixCls } = useDesign('j-tree-dict');
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// v-model:value
|
// v-model:value
|
||||||
value: propTypes.string.def(''),
|
value: propTypes.string.def(''),
|
||||||
field: propTypes.string.def('id'),
|
field: propTypes.string.def('id'),
|
||||||
parentCode: propTypes.string.def(''),
|
parentCode: propTypes.string.def(''),
|
||||||
async: propTypes.bool.def(false),
|
async: propTypes.bool.def(false),
|
||||||
})
|
});
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs();
|
||||||
const emit = defineEmits(['change', 'update:value'])
|
const emit = defineEmits(['change', 'update:value']);
|
||||||
|
|
||||||
const treeData = ref<any[]>([])
|
const treeData = ref<any[]>([]);
|
||||||
const treeValue = ref<any>(null)
|
const treeValue = ref<any>(null);
|
||||||
|
|
||||||
watch(() => props.value, () => loadViewInfo(), { deep: true, immediate: true })
|
watch(
|
||||||
watch(() => props.parentCode, () => loadRoot(), { deep: true, immediate: true })
|
() => props.value,
|
||||||
|
() => loadViewInfo(),
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.parentCode,
|
||||||
|
() => loadRoot(),
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
async function loadViewInfo() {
|
async function loadViewInfo() {
|
||||||
if (!props.value || props.value == '0') {
|
if (!props.value || props.value == '0') {
|
||||||
treeValue.value = null
|
treeValue.value = null;
|
||||||
} else {
|
} else {
|
||||||
let params = { field: props.field, val: props.value }
|
let params = { field: props.field, val: props.value };
|
||||||
let result = await defHttp.get({ url: Api.view, params })
|
let result = await defHttp.get({ url: Api.view, params });
|
||||||
treeValue.value = {
|
treeValue.value = {
|
||||||
value: props.value,
|
value: props.value,
|
||||||
label: result.name,
|
label: result.name,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,23 +70,23 @@ async function loadRoot() {
|
||||||
let params = {
|
let params = {
|
||||||
async: props.async,
|
async: props.async,
|
||||||
pcode: props.parentCode,
|
pcode: props.parentCode,
|
||||||
}
|
};
|
||||||
let result = await defHttp.get({ url: Api.root, params })
|
let result = await defHttp.get({ url: Api.root, params });
|
||||||
treeData.value = [...result]
|
treeData.value = [...result];
|
||||||
handleTreeNodeValue(result)
|
handleTreeNodeValue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function asyncLoadTreeData(treeNode) {
|
async function asyncLoadTreeData(treeNode) {
|
||||||
if (!props.async || treeNode.dataRef.children) {
|
if (!props.async || treeNode.dataRef.children) {
|
||||||
return Promise.resolve()
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
let pid = treeNode.dataRef.key
|
let pid = treeNode.dataRef.key;
|
||||||
let params = { pid: pid }
|
let params = { pid: pid };
|
||||||
let result = await defHttp.get({ url: Api.children, params })
|
let result = await defHttp.get({ url: Api.children, params });
|
||||||
handleTreeNodeValue(result)
|
handleTreeNodeValue(result);
|
||||||
addChildren(pid, result, treeData.value)
|
addChildren(pid, result, treeData.value);
|
||||||
treeData.value = [...treeData.value]
|
treeData.value = [...treeData.value];
|
||||||
return Promise.resolve()
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(pid, children, treeArray) {
|
function addChildren(pid, children, treeArray) {
|
||||||
|
@ -85,43 +94,42 @@ function addChildren(pid, children, treeArray) {
|
||||||
for (let item of treeArray) {
|
for (let item of treeArray) {
|
||||||
if (item.key == pid) {
|
if (item.key == pid) {
|
||||||
if (!children || children.length == 0) {
|
if (!children || children.length == 0) {
|
||||||
item.leaf = true
|
item.leaf = true;
|
||||||
} else {
|
} else {
|
||||||
item.children = children
|
item.children = children;
|
||||||
}
|
}
|
||||||
break
|
break;
|
||||||
} else {
|
} else {
|
||||||
addChildren(pid, children, item.children)
|
addChildren(pid, children, item.children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTreeNodeValue(result) {
|
function handleTreeNodeValue(result) {
|
||||||
let storeField = props.field == 'code' ? 'code' : 'key'
|
let storeField = props.field == 'code' ? 'code' : 'key';
|
||||||
for (let i of result) {
|
for (let i of result) {
|
||||||
i.value = i[storeField]
|
i.value = i[storeField];
|
||||||
i.isLeaf = (i.leaf)
|
i.isLeaf = i.leaf;
|
||||||
if (i.children && i.children.length > 0) {
|
if (i.children && i.children.length > 0) {
|
||||||
handleTreeNodeValue(i.children)
|
handleTreeNodeValue(i.children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(value) {
|
function onChange(value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
emitValue('')
|
emitValue('');
|
||||||
} else {
|
} else {
|
||||||
emitValue(value.value)
|
emitValue(value.value);
|
||||||
}
|
}
|
||||||
treeValue.value = value
|
treeValue.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitValue(value) {
|
function emitValue(value) {
|
||||||
emit('change', value)
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
@ -130,5 +138,4 @@ function emitValue(value) {
|
||||||
|
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -12,7 +12,8 @@
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
@search="onSearch">
|
@search="onSearch"
|
||||||
|
>
|
||||||
</a-tree-select>
|
</a-tree-select>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -20,11 +21,11 @@
|
||||||
* 异步树加载组件 通过传入表名 显示字段 存储字段 加载一个树控件
|
* 异步树加载组件 通过传入表名 显示字段 存储字段 加载一个树控件
|
||||||
* <j-tree-select dict="aa_tree_test,aad,id" pid-field="pid" ></j-tree-select>
|
* <j-tree-select dict="aa_tree_test,aad,id" pid-field="pid" ></j-tree-select>
|
||||||
* */
|
* */
|
||||||
import {ref, watch, unref} from 'vue'
|
import { ref, watch, unref } from 'vue';
|
||||||
import {defHttp} from '/@/utils/http/axios'
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
import {propTypes} from '/@/utils/propTypes'
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import {useAttrs} from '/@/hooks/core/useAttrs'
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import {TreeSelect} from 'ant-design-vue'
|
import { TreeSelect } from 'ant-design-vue';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
enum Api {
|
enum Api {
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
loadTriggleChange: propTypes.bool.def(false),
|
loadTriggleChange: propTypes.bool.def(false),
|
||||||
});
|
});
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
const emit = defineEmits(['change', 'update:value'])
|
const emit = defineEmits(['change', 'update:value']);
|
||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
//树形下拉数据
|
//树形下拉数据
|
||||||
const treeData = ref<any[]>([]);
|
const treeData = ref<any[]>([]);
|
||||||
|
@ -57,11 +58,16 @@
|
||||||
/**
|
/**
|
||||||
* 监听value数据并初始化
|
* 监听value数据并初始化
|
||||||
*/
|
*/
|
||||||
watch(() => props.value, () => loadItemByCode(), {deep: true, immediate: true});
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
() => loadItemByCode(),
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
/**
|
/**
|
||||||
* 监听dict变化
|
* 监听dict变化
|
||||||
*/
|
*/
|
||||||
watch(() => props.dict,
|
watch(
|
||||||
|
() => props.dict,
|
||||||
() => {
|
() => {
|
||||||
initDictInfo();
|
initDictInfo();
|
||||||
loadRoot();
|
loadRoot();
|
||||||
|
@ -73,8 +79,8 @@
|
||||||
* 根据code获取下拉数据并回显
|
* 根据code获取下拉数据并回显
|
||||||
*/
|
*/
|
||||||
async function loadItemByCode() {
|
async function loadItemByCode() {
|
||||||
if (!props.value || props.value == "0") {
|
if (!props.value || props.value == '0') {
|
||||||
treeValue.value = null
|
treeValue.value = null;
|
||||||
} else {
|
} else {
|
||||||
let params = { key: props.value };
|
let params = { key: props.value };
|
||||||
let result = await defHttp.get({ url: `${Api.view}${props.dict}`, params }, { isTransformResponse: false });
|
let result = await defHttp.get({ url: `${Api.view}${props.dict}`, params }, { isTransformResponse: false });
|
||||||
|
@ -83,7 +89,7 @@
|
||||||
treeValue.value = result.result.map((item, index) => ({
|
treeValue.value = result.result.map((item, index) => ({
|
||||||
key: values[index],
|
key: values[index],
|
||||||
value: values[index],
|
value: values[index],
|
||||||
label: item
|
label: item,
|
||||||
}));
|
}));
|
||||||
onLoadTriggleChange(result.result[0]);
|
onLoadTriggleChange(result.result[0]);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +99,7 @@
|
||||||
function onLoadTriggleChange(text) {
|
function onLoadTriggleChange(text) {
|
||||||
//只有单选才会触发
|
//只有单选才会触发
|
||||||
if (!props.multiple && props.loadTriggleChange) {
|
if (!props.multiple && props.loadTriggleChange) {
|
||||||
emit('change', props.value, text)
|
emit('change', props.value, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,10 +107,10 @@
|
||||||
* 初始化数据
|
* 初始化数据
|
||||||
*/
|
*/
|
||||||
function initDictInfo() {
|
function initDictInfo() {
|
||||||
let arr = props.dict?.split(",");
|
let arr = props.dict?.split(',');
|
||||||
tableName.value = arr[0];
|
tableName.value = arr[0];
|
||||||
text.value = arr[1];
|
text.value = arr[1];
|
||||||
code.value = arr[2]
|
code.value = arr[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +124,7 @@
|
||||||
condition: props.condition,
|
condition: props.condition,
|
||||||
tableName: unref(tableName),
|
tableName: unref(tableName),
|
||||||
text: unref(text),
|
text: unref(text),
|
||||||
code: unref(code)
|
code: unref(code),
|
||||||
};
|
};
|
||||||
let res = await defHttp.get({ url: Api.url, params }, { isTransformResponse: false });
|
let res = await defHttp.get({ url: Api.url, params }, { isTransformResponse: false });
|
||||||
if (res.success && res.result) {
|
if (res.success && res.result) {
|
||||||
|
@ -128,7 +134,7 @@
|
||||||
}
|
}
|
||||||
treeData.value = [...res.result];
|
treeData.value = [...res.result];
|
||||||
} else {
|
} else {
|
||||||
console.log("数根节点查询结果异常", res)
|
console.log('数根节点查询结果异常', res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +143,7 @@
|
||||||
*/
|
*/
|
||||||
async function asyncLoadTreeData(treeNode) {
|
async function asyncLoadTreeData(treeNode) {
|
||||||
if (treeNode.dataRef.children) {
|
if (treeNode.dataRef.children) {
|
||||||
return Promise.resolve()
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
let pid = treeNode.dataRef.key;
|
let pid = treeNode.dataRef.key;
|
||||||
let params = {
|
let params = {
|
||||||
|
@ -159,7 +165,7 @@
|
||||||
addChildren(pid, res.result, treeData.value);
|
addChildren(pid, res.result, treeData.value);
|
||||||
treeData.value = [...treeData.value];
|
treeData.value = [...treeData.value];
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,11 +178,11 @@
|
||||||
if (!children || children.length == 0) {
|
if (!children || children.length == 0) {
|
||||||
item.isLeaf = true;
|
item.isLeaf = true;
|
||||||
} else {
|
} else {
|
||||||
item.children = children
|
item.children = children;
|
||||||
}
|
}
|
||||||
break
|
break;
|
||||||
} else {
|
} else {
|
||||||
addChildren(pid, children, item.children)
|
addChildren(pid, children, item.children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,25 +193,25 @@
|
||||||
*/
|
*/
|
||||||
function onChange(value) {
|
function onChange(value) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
emitValue('')
|
emitValue('');
|
||||||
} else if (value instanceof Array) {
|
} else if (value instanceof Array) {
|
||||||
emitValue(value.map(item => item.value).join(','))
|
emitValue(value.map((item) => item.value).join(','));
|
||||||
} else {
|
} else {
|
||||||
emitValue(value.value)
|
emitValue(value.value);
|
||||||
}
|
}
|
||||||
treeValue.value = value
|
treeValue.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitValue(value) {
|
function emitValue(value) {
|
||||||
emit('change', value);
|
emit('change', value);
|
||||||
emit('update:value', value)
|
emit('update:value', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文本框值变化
|
* 文本框值变化
|
||||||
*/
|
*/
|
||||||
function onSearch(value) {
|
function onSearch(value) {
|
||||||
console.log(value)
|
console.log(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,17 +226,17 @@
|
||||||
try {
|
try {
|
||||||
let test = JSON.parse(mycondition);
|
let test = JSON.parse(mycondition);
|
||||||
if (typeof test == 'object' && test) {
|
if (typeof test == 'object' && test) {
|
||||||
resolve()
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
createMessage.error("组件JTreeSelect-condition传值有误,需要一个json字符串!");
|
createMessage.error('组件JTreeSelect-condition传值有误,需要一个json字符串!');
|
||||||
reject()
|
reject();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
createMessage.error("组件JTreeSelect-condition传值有误,需要一个json字符串!");
|
createMessage.error('组件JTreeSelect-condition传值有误,需要一个json字符串!');
|
||||||
reject()
|
reject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// onCreated
|
// onCreated
|
||||||
|
@ -238,8 +244,7 @@
|
||||||
initDictInfo();
|
initDictInfo();
|
||||||
loadRoot();
|
loadRoot();
|
||||||
loadItemByCode();
|
loadItemByCode();
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less"></style>
|
||||||
</style>
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue