代码批量prettier格式化
parent
38db7196c7
commit
6995e5e280
|
@ -30,12 +30,7 @@ export function getThemeColors(color?: string) {
|
|||
return [...lightColors, ...modeColors];
|
||||
}
|
||||
|
||||
export function generateColors({
|
||||
color = primaryColor,
|
||||
mixLighten,
|
||||
mixDarken,
|
||||
tinycolor,
|
||||
}: GenerateColorsParams) {
|
||||
export function generateColors({ color = primaryColor, mixLighten, mixDarken, tinycolor }: GenerateColorsParams) {
|
||||
const arr = new Array(19).fill(0);
|
||||
const lightens = arr.map((_t, i) => {
|
||||
return mixLighten(color, i / 5);
|
||||
|
@ -68,12 +63,5 @@ export function generateColors({
|
|||
.toHexString();
|
||||
})
|
||||
.filter((item) => item !== '#000000');
|
||||
return [
|
||||
...lightens,
|
||||
...darkens,
|
||||
...alphaColors,
|
||||
...shortAlphaColors,
|
||||
...tinycolorDarkens,
|
||||
...tinycolorLightens,
|
||||
].filter((item) => !item.includes('-'));
|
||||
return [...lightens, ...darkens, ...alphaColors, ...shortAlphaColors, ...tinycolorDarkens, ...tinycolorLightens].filter((item) => !item.includes('-'));
|
||||
}
|
||||
|
|
|
@ -51,21 +51,14 @@ async function generateIcon() {
|
|||
if (data) {
|
||||
const { prefix } = data;
|
||||
const isLocal = useType === 'local';
|
||||
const icons = Object.keys(data.icons).map(
|
||||
(item) => `${isLocal ? prefix + ':' : ''}${item}`
|
||||
);
|
||||
const icons = Object.keys(data.icons).map((item) => `${isLocal ? prefix + ':' : ''}${item}`);
|
||||
|
||||
await fs.writeFileSync(
|
||||
path.join(output, `icons.data.ts`),
|
||||
`export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`
|
||||
);
|
||||
await fs.writeFileSync(path.join(output, `icons.data.ts`), `export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`);
|
||||
prefixSet.push(prefix);
|
||||
}
|
||||
}
|
||||
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'));
|
||||
console.log(
|
||||
`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`
|
||||
);
|
||||
console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,5 @@
|
|||
* @param env
|
||||
*/
|
||||
export const getConfigFileName = (env: Record<string, any>) => {
|
||||
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`
|
||||
.toUpperCase()
|
||||
.replace(/\s/g, '');
|
||||
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '');
|
||||
};
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
import type { Plugin } from 'vite';
|
||||
import compressPlugin from 'vite-plugin-compression';
|
||||
|
||||
export function configCompressPlugin(
|
||||
compress: 'gzip' | 'brotli' | 'none',
|
||||
deleteOriginFile = false
|
||||
): Plugin | Plugin[] {
|
||||
export function configCompressPlugin(compress: 'gzip' | 'brotli' | 'none', deleteOriginFile = false): Plugin | Plugin[] {
|
||||
const compressList = compress.split(',');
|
||||
|
||||
const plugins: Plugin[] = [];
|
||||
|
|
|
@ -15,17 +15,11 @@ import { configThemePlugin } from './theme';
|
|||
import { configImageminPlugin } from './imagemin';
|
||||
import { configSvgIconsPlugin } from './svgSprite';
|
||||
import { configHmrPlugin } from './hmr';
|
||||
import OptimizationPersist from 'vite-plugin-optimize-persist'
|
||||
import PkgConfig from 'vite-plugin-package-config'
|
||||
import OptimizationPersist from 'vite-plugin-optimize-persist';
|
||||
import PkgConfig from 'vite-plugin-package-config';
|
||||
|
||||
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||
const {
|
||||
VITE_USE_IMAGEMIN,
|
||||
VITE_USE_MOCK,
|
||||
VITE_LEGACY,
|
||||
VITE_BUILD_COMPRESS,
|
||||
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE,
|
||||
} = viteEnv;
|
||||
const { VITE_USE_IMAGEMIN, VITE_USE_MOCK, VITE_LEGACY, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
|
||||
|
||||
const vitePlugins: (Plugin | Plugin[])[] = [
|
||||
// have to
|
||||
|
@ -72,9 +66,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
|||
VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
|
||||
|
||||
// rollup-plugin-gzip
|
||||
vitePlugins.push(
|
||||
configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE),
|
||||
);
|
||||
vitePlugins.push(configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE));
|
||||
|
||||
// vite-plugin-pwa
|
||||
vitePlugins.push(configPwaConfig(viteEnv));
|
||||
|
|
|
@ -4,13 +4,7 @@
|
|||
*/
|
||||
import type { Plugin } from 'vite';
|
||||
import path from 'path';
|
||||
import {
|
||||
viteThemePlugin,
|
||||
antdDarkThemePlugin,
|
||||
mixLighten,
|
||||
mixDarken,
|
||||
tinycolor,
|
||||
} from 'vite-plugin-theme';
|
||||
import { viteThemePlugin, antdDarkThemePlugin, mixLighten, mixDarken, tinycolor } from 'vite-plugin-theme';
|
||||
import { getThemeColors, generateColors } from '../../config/themeConfig';
|
||||
import { generateModifyVars } from '../../generate/generateModifyVars';
|
||||
|
||||
|
|
|
@ -9,12 +9,7 @@ export function resultSuccess<T = Recordable>(result: T, { message = 'ok' } = {}
|
|||
};
|
||||
}
|
||||
|
||||
export function resultPageSuccess<T = any>(
|
||||
pageNo: number,
|
||||
pageSize: number,
|
||||
list: T[],
|
||||
{ message = 'ok' } = {}
|
||||
) {
|
||||
export function resultPageSuccess<T = any>(pageNo: number, pageSize: number, list: T[], { message = 'ok' } = {}) {
|
||||
const pageData = pagination(pageNo, pageSize, list);
|
||||
|
||||
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[] {
|
||||
const offset = (pageNo - 1) * Number(pageSize);
|
||||
const ret =
|
||||
offset + Number(pageSize) >= array.length
|
||||
? array.slice(offset, array.length)
|
||||
: array.slice(offset, offset + Number(pageSize));
|
||||
const ret = offset + Number(pageSize) >= array.length ? array.slice(offset, array.length) : array.slice(offset, offset + Number(pageSize));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const userList = (() => {
|
|||
realname: '@cname()',
|
||||
createTime: '@datetime',
|
||||
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;
|
||||
|
@ -60,7 +60,7 @@ const newRoleList = (() => {
|
|||
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
|
||||
roleCode: '@first',
|
||||
createTime: '@datetime',
|
||||
remark: '@cword(10,20)'
|
||||
remark: '@cword(10,20)',
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
@ -74,7 +74,7 @@ const testList = (() => {
|
|||
orderNo: `${index + 1}`,
|
||||
testName: ['数据1', '数据2', '数据3', '数据4'][index],
|
||||
testValue: '@first',
|
||||
createTime: '@datetime'
|
||||
createTime: '@datetime',
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
@ -89,7 +89,7 @@ const tableDemoList = (() => {
|
|||
orderMoney: '@natural(1000,3000)',
|
||||
ctype: '@natural(1,2)',
|
||||
content: '@cword(10,20)',
|
||||
orderDate: '@datetime'
|
||||
orderDate: '@datetime',
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
@ -148,12 +148,7 @@ const menuList = (() => {
|
|||
menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
|
||||
icon: 'ion:document',
|
||||
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
|
||||
component: [
|
||||
'/dashboard/welcome/index',
|
||||
'/dashboard/Analysis/index',
|
||||
'/dashboard/workbench/index',
|
||||
'/dashboard/test/index',
|
||||
][j],
|
||||
component: ['/dashboard/welcome/index', '/dashboard/Analysis/index', '/dashboard/workbench/index', '/dashboard/test/index'][j],
|
||||
orderNo: j + 1,
|
||||
createTime: '@datetime',
|
||||
'status|1': ['0', '1'],
|
||||
|
@ -166,16 +161,8 @@ const menuList = (() => {
|
|||
type: '2',
|
||||
menuName: '按钮' + (j + 1) + '-' + (k + 1),
|
||||
icon: '',
|
||||
permission:
|
||||
['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] +
|
||||
':btn' +
|
||||
(k + 1),
|
||||
component: [
|
||||
'/dashboard/welcome/index',
|
||||
'/dashboard/Analysis/index',
|
||||
'/dashboard/workbench/index',
|
||||
'/dashboard/test/index',
|
||||
][j],
|
||||
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] + ':btn' + (k + 1),
|
||||
component: ['/dashboard/welcome/index', '/dashboard/Analysis/index', '/dashboard/workbench/index', '/dashboard/test/index'][j],
|
||||
orderNo: j + 1,
|
||||
createTime: '@datetime',
|
||||
'status|1': ['0', '1'],
|
||||
|
|
|
@ -51,9 +51,7 @@ export default [
|
|||
method: 'post',
|
||||
response: ({ body }) => {
|
||||
const { username, password } = body;
|
||||
const checkUser = createFakeUserList().find(
|
||||
(item) => item.username === username && password === item.password
|
||||
);
|
||||
const checkUser = createFakeUserList().find((item) => item.username === username && password === item.password);
|
||||
if (!checkUser) {
|
||||
return resultError('Incorrect account or password!');
|
||||
}
|
||||
|
|
|
@ -291,7 +291,6 @@
|
|||
"vue-print-nb-jeecg/src/printarea",
|
||||
"vue-router",
|
||||
"vue-types",
|
||||
"vuedraggable",
|
||||
"vxe-table",
|
||||
"vxe-table-plugin-antd",
|
||||
"xe-utils",
|
||||
|
|
|
@ -49,50 +49,49 @@ export const getRoleList = (params) => {
|
|||
*/
|
||||
export const queryDepartTreeSync = (params?) => {
|
||||
return defHttp.get({ url: Api.queryDepartTreeSync, params });
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 获取部门树列表
|
||||
*/
|
||||
export const queryTreeList = (params?) => {
|
||||
return defHttp.get({ url: Api.queryTreeList, params });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 分类字典树控件 加载节点
|
||||
*/
|
||||
export const loadTreeData = (params?) => {
|
||||
return defHttp.get({ url: Api.loadTreeData, params });
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text
|
||||
*/
|
||||
export const loadDictItem = (params?) => {
|
||||
return defHttp.get({ url: Api.loadDictItem, params });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text
|
||||
*/
|
||||
export const getDictItems = (dictCode) => {
|
||||
return defHttp.get({ url: Api.getDictItems + dictCode }, { joinTime: false });
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 部门用户modal选择列表加载list
|
||||
*/
|
||||
export const getTableList = (params) => {
|
||||
return defHttp.get({url:Api.getTableList,params})
|
||||
}
|
||||
return defHttp.get({ url: Api.getTableList, params });
|
||||
};
|
||||
/**
|
||||
* 加载全部分类字典数据
|
||||
*/
|
||||
export const loadCategoryData = (params) => {
|
||||
return defHttp.get({url:Api.getCategoryData,params})
|
||||
}
|
||||
return defHttp.get({ url: Api.getCategoryData, params });
|
||||
};
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
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
|
||||
*/
|
||||
export const optionsListApi = (params?: selectParams) =>
|
||||
defHttp.get<DemoOptionsItem[]>({ url: Api.OPTIONS_LIST, params });
|
||||
export const optionsListApi = (params?: selectParams) => defHttp.get<DemoOptionsItem[]>({ url: Api.OPTIONS_LIST, params });
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
AccountListGetResultModel,
|
||||
RolePageListGetResultModel,
|
||||
RoleListGetResultModel,
|
||||
TestListGetResultModel
|
||||
TestListGetResultModel,
|
||||
} from './model/systemModel';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
|
@ -26,29 +26,20 @@ enum Api {
|
|||
GetAllRoleList = '/mock/system/getAllRoleList',
|
||||
}
|
||||
|
||||
export const getAccountList = (params: AccountParams) =>
|
||||
defHttp.get<AccountListGetResultModel>({url: Api.AccountList, params});
|
||||
export const getAccountList = (params: AccountParams) => defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });
|
||||
|
||||
export const getDeptList = (params?: DeptListItem) =>
|
||||
defHttp.get<DeptListGetResultModel>({url: Api.DeptList, params});
|
||||
export const getDeptList = (params?: DeptListItem) => defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });
|
||||
|
||||
export const getMenuList = (params?: MenuParams) =>
|
||||
defHttp.get<MenuListGetResultModel>({url: Api.MenuList, params});
|
||||
export const getMenuList = (params?: MenuParams) => defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });
|
||||
|
||||
export const getRoleListByPage = (params?: RolePageParams) =>
|
||||
defHttp.get<RolePageListGetResultModel>({url: Api.RolePageList, params});
|
||||
export const getRoleListByPage = (params?: RolePageParams) => defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
|
||||
|
||||
export const getAllRoleList = (params?: RoleParams) =>
|
||||
defHttp.get<RoleListGetResultModel>({url: Api.GetAllRoleList, params});
|
||||
export const getAllRoleList = (params?: RoleParams) => defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
|
||||
|
||||
export const setRoleStatus = (id: number, status: string) =>
|
||||
defHttp.post({url: Api.setRoleStatus, params: {id, status}});
|
||||
export const setRoleStatus = (id: number, status: string) => defHttp.post({ url: Api.setRoleStatus, params: { id, status } });
|
||||
|
||||
export const getTestListByPage = (params?: TestPageParams) =>
|
||||
defHttp.get<TestListGetResultModel>({url: Api.TestPageList, params});
|
||||
export const getTestListByPage = (params?: TestPageParams) => defHttp.get<TestListGetResultModel>({ url: Api.TestPageList, params });
|
||||
|
||||
export const getDemoTableListByPage = (params) =>
|
||||
defHttp.get({url: Api.DemoTableList, params});
|
||||
export const getDemoTableListByPage = (params) => defHttp.get({ url: Api.DemoTableList, params });
|
||||
|
||||
export const isAccountExist = (account: string) =>
|
||||
defHttp.post({url: Api.IsAccountExist, params: {account}}, {errorMessageMode: 'none'});
|
||||
export const isAccountExist = (account: string) => defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });
|
||||
|
|
|
@ -7,5 +7,4 @@ enum Api {
|
|||
/**
|
||||
* @description: Get sample options value
|
||||
*/
|
||||
export const treeOptionsListApi = (params?: Recordable) =>
|
||||
defHttp.get<Recordable[]>({ url: Api.TREE_OPTIONS_LIST, params });
|
||||
export const treeOptionsListApi = (params?: Recordable) => defHttp.get<Recordable[]>({ url: Api.TREE_OPTIONS_LIST, params });
|
||||
|
|
|
@ -12,12 +12,12 @@ enum Api {
|
|||
export const getMenuList = () => {
|
||||
return new Promise((resolve) => {
|
||||
//为了兼容mock和接口数据
|
||||
defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList }).then(res=>{
|
||||
defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList }).then((res) => {
|
||||
if (Array.isArray(res)) {
|
||||
resolve(res)
|
||||
resolve(res);
|
||||
} else {
|
||||
resolve(res['menu'])
|
||||
resolve(res['menu']);
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
};
|
||||
|
|
|
@ -8,10 +8,7 @@ const { uploadUrl = '' } = useGlobSetting();
|
|||
/**
|
||||
* @description: Upload interface
|
||||
*/
|
||||
export function uploadApi(
|
||||
params: UploadFileParams,
|
||||
onUploadProgress: (progressEvent: ProgressEvent) => void
|
||||
) {
|
||||
export function uploadApi(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
|
||||
return defHttp.uploadFile<UploadApiResult>(
|
||||
{
|
||||
url: uploadUrl,
|
||||
|
@ -23,15 +20,13 @@ export function uploadApi(
|
|||
/**
|
||||
* @description: Upload interface
|
||||
*/
|
||||
export function uploadImg(
|
||||
params: UploadFileParams,
|
||||
onUploadProgress: (progressEvent: ProgressEvent) => void
|
||||
) {
|
||||
export function uploadImg(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
|
||||
return defHttp.uploadFile<UploadApiResult>(
|
||||
{
|
||||
url: `${uploadUrl}/sys/common/upload`,
|
||||
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 { ErrorMessageMode } from '/#/axios';
|
||||
import {useMessage} from "/@/hooks/web/useMessage";
|
||||
import {useUserStoreWithOut} from "/@/store/modules/user";
|
||||
import {setAuthCache} from "/@/utils/auth";
|
||||
import {TOKEN_KEY} from "/@/enums/cacheEnum";
|
||||
import {router} from "/@/router";
|
||||
import {PageEnum} from "/@/enums/pageEnum";
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useUserStoreWithOut } from '/@/store/modules/user';
|
||||
import { setAuthCache } from '/@/utils/auth';
|
||||
import { TOKEN_KEY } from '/@/enums/cacheEnum';
|
||||
import { router } from '/@/router';
|
||||
import { PageEnum } from '/@/enums/pageEnum';
|
||||
|
||||
const { createErrorModal } = useMessage();
|
||||
enum Api {
|
||||
|
||||
Login = '/sys/login',
|
||||
phoneLogin = '/sys/phoneLogin',
|
||||
Logout = '/sys/logout',
|
||||
|
@ -101,7 +100,7 @@ export function doLogout() {
|
|||
}
|
||||
|
||||
export function getCodeInfo(currdatetime) {
|
||||
let url = Api.getInputCode+`/${currdatetime}`
|
||||
let url = Api.getInputCode + `/${currdatetime}`;
|
||||
return defHttp.get({ url: url });
|
||||
}
|
||||
/**
|
||||
|
@ -109,43 +108,40 @@ export function getCodeInfo(currdatetime) {
|
|||
*/
|
||||
export function getCaptcha(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
defHttp.post({url:Api.getCaptcha,params},{isTransformResponse: false}).then(res=>{
|
||||
console.log(res)
|
||||
defHttp.post({ url: Api.getCaptcha, params }, { isTransformResponse: false }).then((res) => {
|
||||
console.log(res);
|
||||
if (res.success) {
|
||||
resolve(true)
|
||||
resolve(true);
|
||||
} else {
|
||||
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
|
||||
reject()
|
||||
reject();
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 注册接口
|
||||
*/
|
||||
export function register(params) {
|
||||
return defHttp.post({url: Api.registerApi,params},{isReturnNativeResponse: true})
|
||||
return defHttp.post({ url: Api.registerApi, params }, { isReturnNativeResponse: true });
|
||||
}
|
||||
|
||||
/**
|
||||
*校验用户是否存在
|
||||
* @param params
|
||||
*/
|
||||
export const checkOnlyUser = (params) =>
|
||||
defHttp.get({url: Api.checkOnlyUser, params},{isTransformResponse:false});
|
||||
export const checkOnlyUser = (params) => defHttp.get({ url: Api.checkOnlyUser, params }, { isTransformResponse: false });
|
||||
/**
|
||||
*校验手机号码
|
||||
* @param params
|
||||
*/
|
||||
export const phoneVerify = (params) =>
|
||||
defHttp.post({url: Api.phoneVerify, params},{isTransformResponse:false});
|
||||
export const phoneVerify = (params) => defHttp.post({ url: Api.phoneVerify, params }, { isTransformResponse: false });
|
||||
/**
|
||||
*密码修改
|
||||
* @param params
|
||||
*/
|
||||
export const passwordChange = (params) =>
|
||||
defHttp.get({url: Api.passwordChange, params},{isTransformResponse:false});
|
||||
export const passwordChange = (params) => defHttp.get({ url: Api.passwordChange, params }, { isTransformResponse: false });
|
||||
/**
|
||||
* @description: 第三方登录
|
||||
*/
|
||||
|
@ -164,23 +160,23 @@ export function thirdLogin(params, mode: ErrorMessageMode = 'modal') {
|
|||
*/
|
||||
export function setThirdCaptcha(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
defHttp.post({url:Api.getThirdCaptcha,params},{isTransformResponse: false}).then(res=>{
|
||||
console.log(res)
|
||||
defHttp.post({ url: Api.getThirdCaptcha, params }, { isTransformResponse: false }).then((res) => {
|
||||
console.log(res);
|
||||
if (res.success) {
|
||||
resolve(true)
|
||||
resolve(true);
|
||||
} else {
|
||||
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
|
||||
reject()
|
||||
reject();
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录二维码信息
|
||||
*/
|
||||
export function getLoginQrcode() {
|
||||
let url = Api.getLoginQrcode
|
||||
let url = Api.getLoginQrcode;
|
||||
return defHttp.get({ url: url });
|
||||
}
|
||||
|
||||
|
@ -188,7 +184,7 @@ export function getLoginQrcode() {
|
|||
* 监控扫码状态
|
||||
*/
|
||||
export function getQrcodeToken(params) {
|
||||
let url = Api.getQrcodeToken
|
||||
let url = Api.getQrcodeToken;
|
||||
return defHttp.get({ url: url, params });
|
||||
}
|
||||
|
||||
|
@ -196,6 +192,6 @@ export function getQrcodeToken(params) {
|
|||
* SSO登录校验
|
||||
*/
|
||||
export async function validateCasLogin(params) {
|
||||
let url = Api.validateCasLogin
|
||||
let url = Api.validateCasLogin;
|
||||
return defHttp.get({ url: url, params });
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
outline: 0;
|
||||
}
|
||||
|
||||
|
||||
.area-select:active {
|
||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
|
@ -96,12 +95,12 @@
|
|||
top: 50%;
|
||||
margin-top: -2px;
|
||||
right: 6px;
|
||||
content: "";
|
||||
content: '';
|
||||
width: 0;
|
||||
height: 0;
|
||||
border: 6px solid transparent;
|
||||
border-top-color: rgba(0, 0, 0, 0.25);
|
||||
transition: all .3s linear;
|
||||
transition: all 0.3s linear;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
|
@ -223,7 +222,7 @@
|
|||
top: 50%;
|
||||
margin-top: -4px;
|
||||
right: 5px;
|
||||
content: "";
|
||||
content: '';
|
||||
width: 0;
|
||||
height: 0;
|
||||
border: 4px solid transparent;
|
||||
|
|
|
@ -3,14 +3,7 @@
|
|||
* @Description: Multi-language switching component
|
||||
-->
|
||||
<template>
|
||||
<Dropdown
|
||||
placement="bottomCenter"
|
||||
:trigger="['click']"
|
||||
:dropMenuList="localeList"
|
||||
:selectedKeys="selectedKeys"
|
||||
@menuEvent="handleMenuEvent"
|
||||
overlayClassName="app-locale-picker-overlay"
|
||||
>
|
||||
<Dropdown placement="bottomCenter" :trigger="['click']" :dropMenuList="localeList" :selectedKeys="selectedKeys" @menuEvent="handleMenuEvent" overlayClassName="app-locale-picker-overlay">
|
||||
<span class="cursor-pointer flex items-center">
|
||||
<Icon icon="ion:language" />
|
||||
<span v-if="showText" class="ml-1">{{ getLocaleText }}</span>
|
||||
|
|
|
@ -40,11 +40,7 @@
|
|||
const { title } = useGlobSetting();
|
||||
const go = useGo();
|
||||
|
||||
const getAppLogoClass = computed(() => [
|
||||
prefixCls,
|
||||
props.theme,
|
||||
{ 'collapsed-show-title': unref(getCollapsedShowTitle) },
|
||||
]);
|
||||
const getAppLogoClass = computed(() => [prefixCls, props.theme, { 'collapsed-show-title': unref(getCollapsedShowTitle) }]);
|
||||
|
||||
const getTitleClass = computed(() => [
|
||||
`${prefixCls}__title`,
|
||||
|
|
|
@ -45,12 +45,7 @@
|
|||
if (!unref(isSetState)) {
|
||||
isSetState.value = true;
|
||||
const {
|
||||
menuSetting: {
|
||||
type: menuType,
|
||||
mode: menuMode,
|
||||
collapsed: menuCollapsed,
|
||||
split: menuSplit,
|
||||
},
|
||||
menuSetting: { type: menuType, mode: menuMode, collapsed: menuCollapsed, split: menuSplit },
|
||||
} = appStore.getProjectConfig;
|
||||
appStore.setProjectConfig({
|
||||
menuSetting: {
|
||||
|
|
|
@ -41,8 +41,7 @@
|
|||
margin-right: 0.4em;
|
||||
background-color: linear-gradient(-225deg, #d5dbe4, #f8f8f8);
|
||||
border-radius: 2px;
|
||||
box-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff,
|
||||
0 1px 2px 1px rgba(30, 35, 90, 0.4);
|
||||
box-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff, 0 1px 2px 1px rgba(30, 35, 90, 0.4);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
|
|
|
@ -4,13 +4,7 @@
|
|||
<div :class="getClass" @click.stop v-if="visible">
|
||||
<div :class="`${prefixCls}-content`" v-click-outside="handleClose">
|
||||
<div :class="`${prefixCls}-input__wrapper`">
|
||||
<a-input
|
||||
:class="`${prefixCls}-input`"
|
||||
:placeholder="t('common.searchText')"
|
||||
ref="inputRef"
|
||||
allow-clear
|
||||
@change="handleSearch"
|
||||
>
|
||||
<a-input :class="`${prefixCls}-input`" :placeholder="t('common.searchText')" ref="inputRef" allow-clear @change="handleSearch">
|
||||
<template #prefix>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
|
@ -84,8 +78,7 @@
|
|||
const [refs, setRefs] = useRefs();
|
||||
const { getIsMobile } = useAppInject();
|
||||
|
||||
const { handleSearch, searchResult, keyword, activeIndex, handleEnter, handleMouseenter } =
|
||||
useMenuSearch(refs, scrollWrap, emit);
|
||||
const { handleSearch, searchResult, keyword, activeIndex, handleEnter, handleMouseenter } = useMenuSearch(refs, scrollWrap, emit);
|
||||
|
||||
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) => {
|
||||
// 【issues/33】包含子菜单时,不添加到搜索队列
|
||||
if (Array.isArray(item.children)) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
return reg.test(item.name) && !item.hideMenu;
|
||||
});
|
||||
|
|
|
@ -46,9 +46,7 @@
|
|||
setup(props, { slots }) {
|
||||
const { prefixCls } = useDesign('basic-help');
|
||||
|
||||
const getTooltipStyle = computed(
|
||||
(): CSSProperties => ({ color: props.color, fontSize: props.fontSize })
|
||||
);
|
||||
const getTooltipStyle = computed((): CSSProperties => ({ color: props.color, fontSize: props.fontSize }));
|
||||
|
||||
const getOverlayStyle = computed((): CSSProperties => ({ maxWidth: props.maxWidth }));
|
||||
|
||||
|
|
|
@ -33,11 +33,7 @@
|
|||
|
||||
const { prefixCls } = useDesign('basic-title');
|
||||
const slots = useSlots();
|
||||
const getClass = computed(() => [
|
||||
prefixCls,
|
||||
{ [`${prefixCls}-show-span`]: props.span && slots.default },
|
||||
{ [`${prefixCls}-normal`]: props.normal },
|
||||
]);
|
||||
const getClass = computed(() => [prefixCls, { [`${prefixCls}-show-span`]: props.span && slots.default }, { [`${prefixCls}-normal`]: props.normal }]);
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
@prefix-cls: ~'@{namespace}-basic-title';
|
||||
|
|
|
@ -5,23 +5,12 @@
|
|||
</div>
|
||||
{{ sliderProp.width }}
|
||||
<div class="bg-white p-2">
|
||||
<List
|
||||
:grid="{ gutter: 5, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: grid }"
|
||||
:data-source="data"
|
||||
:pagination="paginationProp"
|
||||
>
|
||||
<List :grid="{ gutter: 5, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: grid }" :data-source="data" :pagination="paginationProp">
|
||||
<template #header>
|
||||
<div class="flex justify-end space-x-2"
|
||||
><slot name="header"></slot>
|
||||
<Tooltip>
|
||||
<template #title>
|
||||
<div class="w-50">每行显示数量</div
|
||||
><Slider
|
||||
id="slider"
|
||||
v-bind="sliderProp"
|
||||
v-model:value="grid"
|
||||
@change="sliderChange"
|
||||
/></template>
|
||||
<template #title> <div class="w-50">每行显示数量</div><Slider id="slider" v-bind="sliderProp" v-model:value="grid" @change="sliderChange" /></template>
|
||||
<Button><TableOutlined /></Button>
|
||||
</Tooltip>
|
||||
<Tooltip @click="fetch">
|
||||
|
@ -78,12 +67,7 @@
|
|||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import {
|
||||
EditOutlined,
|
||||
EllipsisOutlined,
|
||||
RedoOutlined,
|
||||
TableOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { EditOutlined, EllipsisOutlined, RedoOutlined, TableOutlined } from '@ant-design/icons-vue';
|
||||
import { List, Card, Image, Typography, Tooltip, Slider, Avatar } from 'ant-design-vue';
|
||||
import { Dropdown } from '/@/components/Dropdown';
|
||||
import { BasicForm, useForm } from '/@/components/Form';
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<template>
|
||||
<div class="h-full">
|
||||
<CodeMirrorEditor
|
||||
:value="getValue"
|
||||
@change="handleValueChange"
|
||||
:mode="mode"
|
||||
:readonly="readonly"
|
||||
/>
|
||||
<CodeMirrorEditor :value="getValue" @change="handleValueChange" :mode="mode" :readonly="readonly" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -58,10 +58,7 @@
|
|||
);
|
||||
|
||||
function setTheme() {
|
||||
unref(editor)?.setOption(
|
||||
'theme',
|
||||
appStore.getDarkMode === 'light' ? 'idea' : 'material-palenight'
|
||||
);
|
||||
unref(editor)?.setOption('theme', appStore.getDarkMode === 'light' ? 'idea' : 'material-palenight');
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<template>
|
||||
<transition-group
|
||||
class="h-full w-full"
|
||||
v-bind="$attrs"
|
||||
ref="elRef"
|
||||
:name="transitionName"
|
||||
:tag="tag"
|
||||
mode="out-in"
|
||||
>
|
||||
<transition-group class="h-full w-full" v-bind="$attrs" ref="elRef" :name="transitionName" :tag="tag" mode="out-in">
|
||||
<div key="component" v-if="isInit">
|
||||
<slot :loading="loading"></slot>
|
||||
</div>
|
||||
|
|
|
@ -31,11 +31,7 @@
|
|||
const ItemContent: FunctionalComponent<ItemContentProps> = (props) => {
|
||||
const { item } = props;
|
||||
return (
|
||||
<span
|
||||
style="display: inline-block; width: 100%; "
|
||||
class="px-4"
|
||||
onClick={props.handler.bind(null, item)}
|
||||
>
|
||||
<span 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} />}
|
||||
<span>{item.label}</span>
|
||||
</span>
|
||||
|
@ -124,13 +120,7 @@
|
|||
}
|
||||
const { items } = props;
|
||||
return (
|
||||
<Menu
|
||||
inlineIndent={12}
|
||||
mode="vertical"
|
||||
class={prefixCls}
|
||||
ref={wrapRef}
|
||||
style={unref(getStyle)}
|
||||
>
|
||||
<Menu inlineIndent={12} mode="vertical" class={prefixCls} ref={wrapRef} style={unref(getStyle)}>
|
||||
{renderMenuItem(items)}
|
||||
</Menu>
|
||||
);
|
||||
|
@ -180,8 +170,7 @@
|
|||
background-color: @component-background;
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
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),
|
||||
0 1px 5px 0 rgba(0, 0, 0, 0.06);
|
||||
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);
|
||||
background-clip: padding-box;
|
||||
user-select: none;
|
||||
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
const { t } = useI18n();
|
||||
|
||||
const getButtonText = computed(() => {
|
||||
return !unref(isStart)
|
||||
? t('component.countdown.normalText')
|
||||
: t('component.countdown.sendText', [unref(currentCount)]);
|
||||
return !unref(isStart) ? t('component.countdown.normalText') : t('component.countdown.sendText', [unref(currentCount)]);
|
||||
});
|
||||
|
||||
watchEffect(() => {
|
||||
|
|
|
@ -1,24 +1,9 @@
|
|||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
@register="register"
|
||||
:title="t('component.cropper.modalTitle')"
|
||||
width="800px"
|
||||
:canFullscreen="false"
|
||||
@ok="handleOk"
|
||||
:okText="t('component.cropper.okText')"
|
||||
>
|
||||
<BasicModal 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}-left`">
|
||||
<div :class="`${prefixCls}-cropper`">
|
||||
<CropperImage
|
||||
v-if="src"
|
||||
:src="src"
|
||||
height="300px"
|
||||
:circled="circled"
|
||||
@cropend="handleCropend"
|
||||
@ready="handleReady"
|
||||
/>
|
||||
<CropperImage v-if="src" :src="src" height="300px" :circled="circled" @cropend="handleCropend" @ready="handleReady" />
|
||||
</div>
|
||||
|
||||
<div :class="`${prefixCls}-toolbar`">
|
||||
|
@ -29,67 +14,25 @@
|
|||
</Upload>
|
||||
<Space>
|
||||
<Tooltip :title="t('component.cropper.btn_reset')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="ant-design:reload-outlined"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('reset')"
|
||||
/>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" size="small" :disabled="!src" @click="handlerToolbar('reset')" />
|
||||
</Tooltip>
|
||||
<Tooltip :title="t('component.cropper.btn_rotate_left')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="ant-design:rotate-left-outlined"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('rotate', -45)"
|
||||
/>
|
||||
<a-button type="primary" preIcon="ant-design:rotate-left-outlined" size="small" :disabled="!src" @click="handlerToolbar('rotate', -45)" />
|
||||
</Tooltip>
|
||||
<Tooltip :title="t('component.cropper.btn_rotate_right')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="ant-design:rotate-right-outlined"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('rotate', 45)"
|
||||
/>
|
||||
<a-button type="primary" preIcon="ant-design:rotate-right-outlined" size="small" :disabled="!src" @click="handlerToolbar('rotate', 45)" />
|
||||
</Tooltip>
|
||||
<Tooltip :title="t('component.cropper.btn_scale_x')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="vaadin:arrows-long-h"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('scaleX')"
|
||||
/>
|
||||
<a-button type="primary" preIcon="vaadin:arrows-long-h" size="small" :disabled="!src" @click="handlerToolbar('scaleX')" />
|
||||
</Tooltip>
|
||||
<Tooltip :title="t('component.cropper.btn_scale_y')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="vaadin:arrows-long-v"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('scaleY')"
|
||||
/>
|
||||
<a-button type="primary" preIcon="vaadin:arrows-long-v" size="small" :disabled="!src" @click="handlerToolbar('scaleY')" />
|
||||
</Tooltip>
|
||||
<Tooltip :title="t('component.cropper.btn_zoom_in')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="ant-design:zoom-in-outlined"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('zoom', 0.1)"
|
||||
/>
|
||||
<a-button type="primary" preIcon="ant-design:zoom-in-outlined" size="small" :disabled="!src" @click="handlerToolbar('zoom', 0.1)" />
|
||||
</Tooltip>
|
||||
<Tooltip :title="t('component.cropper.btn_zoom_out')" placement="bottom">
|
||||
<a-button
|
||||
type="primary"
|
||||
preIcon="ant-design:zoom-out-outlined"
|
||||
size="small"
|
||||
:disabled="!src"
|
||||
@click="handlerToolbar('zoom', -0.1)"
|
||||
/>
|
||||
<a-button type="primary" preIcon="ant-design:zoom-out-outlined" size="small" :disabled="!src" @click="handlerToolbar('zoom', -0.1)" />
|
||||
</Tooltip>
|
||||
</Space>
|
||||
</div>
|
||||
|
@ -232,20 +175,8 @@
|
|||
&-cropper {
|
||||
height: 300px;
|
||||
background: #eee;
|
||||
background-image: linear-gradient(
|
||||
45deg,
|
||||
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-image: linear-gradient(45deg, 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-size: 24px 24px;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
<template>
|
||||
<div :class="getClass" :style="getWrapperStyle">
|
||||
<img
|
||||
v-show="isReady"
|
||||
ref="imgElRef"
|
||||
:src="src"
|
||||
:alt="alt"
|
||||
:crossorigin="crossorigin"
|
||||
:style="getImageStyle"
|
||||
/>
|
||||
<img v-show="isReady" ref="imgElRef" :src="src" :alt="alt" :crossorigin="crossorigin" :style="getImageStyle" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
|
|
|
@ -2,43 +2,19 @@
|
|||
<div :class="getClass" :style="getStyle">
|
||||
<div :class="`${prefixCls}-image-wrapper`" :style="getImageWrapperStyle" @click="openModal">
|
||||
<div :class="`${prefixCls}-image-mask`" :style="getImageWrapperStyle">
|
||||
<Icon
|
||||
icon="ant-design:cloud-upload-outlined"
|
||||
:size="getIconWidth"
|
||||
:style="getImageWrapperStyle"
|
||||
color="#d6d6d6"
|
||||
/>
|
||||
<Icon icon="ant-design:cloud-upload-outlined" :size="getIconWidth" :style="getImageWrapperStyle" color="#d6d6d6" />
|
||||
</div>
|
||||
<img :src="sourceValue" v-if="sourceValue" alt="avatar" />
|
||||
</div>
|
||||
<a-button
|
||||
:class="`${prefixCls}-upload-btn`"
|
||||
@click="openModal"
|
||||
v-if="showBtn"
|
||||
v-bind="btnProps"
|
||||
>
|
||||
<a-button :class="`${prefixCls}-upload-btn`" @click="openModal" v-if="showBtn" v-bind="btnProps">
|
||||
{{ btnText ? btnText : t('component.cropper.selectImage') }}
|
||||
</a-button>
|
||||
|
||||
<CopperModal
|
||||
@register="register"
|
||||
@uploadSuccess="handleUploadSuccess"
|
||||
:uploadApi="uploadApi"
|
||||
:src="sourceValue"
|
||||
/>
|
||||
<CopperModal @register="register" @uploadSuccess="handleUploadSuccess" :uploadApi="uploadApi" :src="sourceValue" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import {
|
||||
defineComponent,
|
||||
computed,
|
||||
CSSProperties,
|
||||
unref,
|
||||
ref,
|
||||
watchEffect,
|
||||
watch,
|
||||
PropType,
|
||||
} from 'vue';
|
||||
import { defineComponent, computed, CSSProperties, unref, ref, watchEffect, watch, PropType } from 'vue';
|
||||
import CopperModal from './CopperModal.vue';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
|
@ -76,9 +52,7 @@
|
|||
|
||||
const getStyle = computed((): CSSProperties => ({ width: unref(getWidth) }));
|
||||
|
||||
const getImageWrapperStyle = computed(
|
||||
(): CSSProperties => ({ width: unref(getWidth), height: unref(getWidth) })
|
||||
);
|
||||
const getImageWrapperStyle = computed((): CSSProperties => ({ width: unref(getWidth), height: unref(getWidth) }));
|
||||
|
||||
watchEffect(() => {
|
||||
sourceValue.value = props.value || '';
|
||||
|
|
|
@ -12,10 +12,7 @@ export interface DescItem {
|
|||
span?: number;
|
||||
show?: (...arg: any) => boolean;
|
||||
// render
|
||||
render?: (
|
||||
val: any,
|
||||
data: Recordable
|
||||
) => VNode | undefined | JSX.Element | Element | string | number;
|
||||
render?: (val: any, data: Recordable) => VNode | undefined | JSX.Element | Element | string | number;
|
||||
}
|
||||
|
||||
export interface DescriptionProps extends DescriptionsProps {
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
<template>
|
||||
<Drawer :class="prefixCls" @close="onClose" v-bind="getBindValues">
|
||||
<template #title v-if="!$slots.title">
|
||||
<DrawerHeader
|
||||
:title="getMergeProps.title"
|
||||
:isDetail="isDetail"
|
||||
:showDetailBack="showDetailBack"
|
||||
@close="onClose"
|
||||
>
|
||||
<DrawerHeader :title="getMergeProps.title" :isDetail="isDetail" :showDetailBack="showDetailBack" @close="onClose">
|
||||
<template #titleToolbar>
|
||||
<slot name="titleToolbar"></slot>
|
||||
</template>
|
||||
|
@ -16,11 +11,7 @@
|
|||
<slot name="title"></slot>
|
||||
</template>
|
||||
|
||||
<ScrollContainer
|
||||
:style="getScrollContentStyle"
|
||||
v-loading="getLoading"
|
||||
:loading-tip="loadingText || t('common.loadingText')"
|
||||
>
|
||||
<ScrollContainer :style="getScrollContentStyle" v-loading="getLoading" :loading-tip="loadingText || t('common.loadingText')">
|
||||
<slot></slot>
|
||||
</ScrollContainer>
|
||||
<DrawerFooter v-bind="getProps" @close="onClose" @ok="handleOk" :height="getFooterHeight">
|
||||
|
@ -33,16 +24,7 @@
|
|||
<script lang="ts">
|
||||
import type { DrawerInstance, DrawerProps } from './typing';
|
||||
import type { CSSProperties } from 'vue';
|
||||
import {
|
||||
defineComponent,
|
||||
ref,
|
||||
computed,
|
||||
watch,
|
||||
unref,
|
||||
nextTick,
|
||||
toRaw,
|
||||
getCurrentInstance,
|
||||
} from 'vue';
|
||||
import { defineComponent, ref, computed, watch, unref, nextTick, toRaw, getCurrentInstance } from 'vue';
|
||||
import { Drawer } from 'ant-design-vue';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { isFunction, isNumber } from '/@/utils/is';
|
||||
|
@ -115,9 +97,7 @@
|
|||
const getFooterHeight = computed(() => {
|
||||
const { footerHeight, showFooter } = unref(getProps);
|
||||
if (showFooter && footerHeight) {
|
||||
return isNumber(footerHeight)
|
||||
? `${footerHeight}px`
|
||||
: `${footerHeight.replace('px', '')}px`;
|
||||
return isNumber(footerHeight) ? `${footerHeight}px` : `${footerHeight.replace('px', '')}px`;
|
||||
}
|
||||
return `0px`;
|
||||
});
|
||||
|
|
|
@ -6,14 +6,7 @@
|
|||
{{ cancelText }}
|
||||
</a-button>
|
||||
<slot name="centerFooter"></slot>
|
||||
<a-button
|
||||
:type="okType"
|
||||
@click="handleOk"
|
||||
v-bind="okButtonProps"
|
||||
class="mr-2"
|
||||
:loading="confirmLoading"
|
||||
v-if="showOkBtn"
|
||||
>
|
||||
<a-button :type="okType" @click="handleOk" v-bind="okButtonProps" class="mr-2" :loading="confirmLoading" v-if="showOkBtn">
|
||||
{{ okText }}
|
||||
</a-button>
|
||||
<slot name="appendFooter"></slot>
|
||||
|
|
|
@ -1,20 +1,5 @@
|
|||
import type {
|
||||
UseDrawerReturnType,
|
||||
DrawerInstance,
|
||||
ReturnMethods,
|
||||
DrawerProps,
|
||||
UseDrawerInnerReturnType,
|
||||
} from './typing';
|
||||
import {
|
||||
ref,
|
||||
getCurrentInstance,
|
||||
unref,
|
||||
reactive,
|
||||
watchEffect,
|
||||
nextTick,
|
||||
toRaw,
|
||||
computed,
|
||||
} from 'vue';
|
||||
import type { UseDrawerReturnType, DrawerInstance, ReturnMethods, DrawerProps, UseDrawerInnerReturnType } from './typing';
|
||||
import { ref, getCurrentInstance, unref, reactive, watchEffect, nextTick, toRaw, computed } from 'vue';
|
||||
import { isProdMode } from '/@/utils/env';
|
||||
import { isFunction } from '/@/utils/is';
|
||||
import { tryOnUnmounted } from '@vueuse/core';
|
||||
|
|
|
@ -6,16 +6,8 @@
|
|||
<template #overlay>
|
||||
<a-menu :class="[`${prefixCls}-menu`]" :selectedKeys="selectedKeys">
|
||||
<template v-for="item in dropMenuList" :key="`${item.event}`">
|
||||
<a-menu-item
|
||||
v-bind="getAttr(item.event)"
|
||||
@click="handleClickMenu(item)"
|
||||
:disabled="item.disabled"
|
||||
:class="[{'is-pop-confirm': item.popConfirm}]"
|
||||
>
|
||||
<a-popconfirm
|
||||
v-if="popconfirm && item.popConfirm"
|
||||
v-bind="getPopConfirmAttrs(item.popConfirm)"
|
||||
>
|
||||
<a-menu-item v-bind="getAttr(item.event)" @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">
|
||||
<Icon :icon="item.popConfirm.icon" />
|
||||
</template>
|
||||
|
@ -43,7 +35,7 @@
|
|||
import { Icon } from '/@/components/Icon';
|
||||
import { omit } from 'lodash-es';
|
||||
import { isFunction } from '/@/utils/is';
|
||||
import {useDesign} from '/@/hooks/web/useDesign'
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
|
||||
const ADropdown = Dropdown;
|
||||
const AMenu = Menu;
|
||||
|
@ -87,10 +79,8 @@
|
|||
const getPopConfirmAttrs = computed(() => {
|
||||
return (attrs) => {
|
||||
const originAttrs = omit(attrs, ['confirm', 'cancel', 'icon']);
|
||||
if (!attrs.onConfirm && attrs.confirm && isFunction(attrs.confirm))
|
||||
originAttrs['onConfirm'] = attrs.confirm;
|
||||
if (!attrs.onCancel && attrs.cancel && isFunction(attrs.cancel))
|
||||
originAttrs['onCancel'] = attrs.cancel;
|
||||
if (!attrs.onConfirm && attrs.confirm && isFunction(attrs.confirm)) originAttrs['onConfirm'] = attrs.confirm;
|
||||
if (!attrs.onCancel && attrs.cancel && isFunction(attrs.cancel)) originAttrs['onCancel'] = attrs.cancel;
|
||||
return originAttrs;
|
||||
};
|
||||
});
|
||||
|
@ -102,7 +92,6 @@
|
|||
@prefix-cls: ~'@{namespace}-basic-dropdown';
|
||||
|
||||
.@{prefix-cls} {
|
||||
|
||||
// update-begin--author:sunjianlei---date:20220322---for: 【VUEN-180】更多下拉菜单,只有点到字上才有效,点到空白处什么都不会发生,体验不好
|
||||
&-menu .ant-dropdown-menu-item.is-pop-confirm {
|
||||
padding: 0;
|
||||
|
@ -112,6 +101,5 @@
|
|||
}
|
||||
}
|
||||
// update-end--author:sunjianlei---date:20220322---for: 【VUEN-180】更多下拉菜单,只有点到字上才有效,点到空白处什么都不会发生,体验不好
|
||||
|
||||
}
|
||||
</style>
|
|
@ -6,13 +6,7 @@ const { utils, writeFile } = xlsx;
|
|||
|
||||
const DEF_FILE_NAME = 'excel-list.xlsx';
|
||||
|
||||
export function jsonToSheetXlsx<T = any>({
|
||||
data,
|
||||
header,
|
||||
filename = DEF_FILE_NAME,
|
||||
json2sheetOpts = {},
|
||||
write2excelOpts = { bookType: 'xlsx' },
|
||||
}: JsonToSheet<T>) {
|
||||
export function jsonToSheetXlsx<T = any>({ data, header, filename = DEF_FILE_NAME, json2sheetOpts = {}, write2excelOpts = { bookType: 'xlsx' } }: JsonToSheet<T>) {
|
||||
const arrData = [...data];
|
||||
if (header) {
|
||||
arrData.unshift(header);
|
||||
|
@ -33,12 +27,7 @@ export function jsonToSheetXlsx<T = any>({
|
|||
/* at this point, out.xlsb will have been downloaded */
|
||||
}
|
||||
|
||||
export function aoaToSheetXlsx<T = any>({
|
||||
data,
|
||||
header,
|
||||
filename = DEF_FILE_NAME,
|
||||
write2excelOpts = { bookType: 'xlsx' },
|
||||
}: AoAToSheet<T>) {
|
||||
export function aoaToSheetXlsx<T = any>({ data, header, filename = DEF_FILE_NAME, write2excelOpts = { bookType: 'xlsx' } }: AoAToSheet<T>) {
|
||||
const arrData = [...data];
|
||||
if (header) {
|
||||
arrData.unshift(header);
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
:title="t('component.excel.exportModalTitle')"
|
||||
@ok="handleOk"
|
||||
@register="registerModal"
|
||||
>
|
||||
<BasicForm
|
||||
:labelWidth="100"
|
||||
:schemas="schemas"
|
||||
:showActionButtonGroup="false"
|
||||
@register="registerForm"
|
||||
/>
|
||||
<BasicModal v-bind="$attrs" :title="t('component.excel.exportModalTitle')" @ok="handleOk" @register="registerModal">
|
||||
<BasicForm :labelWidth="100" :schemas="schemas" :showActionButtonGroup="false" @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<input
|
||||
ref="inputRef"
|
||||
type="file"
|
||||
v-show="false"
|
||||
accept=".xlsx, .xls"
|
||||
@change="handleInputClick"
|
||||
/>
|
||||
<input ref="inputRef" type="file" v-show="false" accept=".xlsx, .xls" @change="handleInputClick" />
|
||||
<div @click="handleUpload">
|
||||
<slot></slot>
|
||||
</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 JPopup } from './src/jeecg/components/JPopup.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 JInput } from './src/jeecg/components/JInput.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 JImageUpload } from './src/jeecg/components/JImageUpload.vue';
|
||||
// Jeecg自定义校验
|
||||
export { JCronValidator } from '/@/components/Form/src/jeecg/components/JEasyCron'
|
||||
export { JCronValidator } from '/@/components/Form/src/jeecg/components/JEasyCron';
|
||||
|
||||
export { BasicForm };
|
||||
|
|
|
@ -3,7 +3,15 @@
|
|||
<Row v-bind="getRow">
|
||||
<slot name="formHeader"></slot>
|
||||
<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)">
|
||||
<slot :name="item" v-bind="data || {}"></slot>
|
||||
</template>
|
||||
|
@ -93,9 +101,7 @@
|
|||
};
|
||||
});
|
||||
|
||||
const getBindValue = computed(
|
||||
() => ({ ...attrs, ...props, ...unref(getProps) } as Recordable)
|
||||
);
|
||||
const getBindValue = computed(() => ({ ...attrs, ...props, ...unref(getProps) } as Recordable));
|
||||
|
||||
const getSchema = computed((): FormSchema[] => {
|
||||
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
||||
|
@ -144,20 +150,8 @@
|
|||
formElRef: formElRef as Ref<FormActionType>,
|
||||
});
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
setFieldsValue,
|
||||
clearValidate,
|
||||
validate,
|
||||
validateFields,
|
||||
getFieldsValue,
|
||||
updateSchema,
|
||||
resetSchema,
|
||||
appendSchemaByField,
|
||||
removeSchemaByFiled,
|
||||
resetFields,
|
||||
scrollToField,
|
||||
} = useFormEvents({
|
||||
const { handleSubmit, setFieldsValue, clearValidate, validate, validateFields, getFieldsValue, updateSchema, resetSchema, appendSchemaByField, removeSchemaByFiled, resetFields, scrollToField } =
|
||||
useFormEvents({
|
||||
emit,
|
||||
getProps,
|
||||
formModel,
|
||||
|
@ -267,9 +261,7 @@
|
|||
formActionType: formActionType as any,
|
||||
setFormModel,
|
||||
getFormClass,
|
||||
getFormActionBindProps: computed(
|
||||
(): Recordable => ({ ...getProps.value, ...advanceState })
|
||||
),
|
||||
getFormActionBindProps: computed((): Recordable => ({ ...getProps.value, ...advanceState })),
|
||||
...formActionType,
|
||||
};
|
||||
},
|
||||
|
|
|
@ -4,22 +4,7 @@ import type { ComponentType } from './types/index';
|
|||
/**
|
||||
* Component list, register here to setting it in the form
|
||||
*/
|
||||
import {
|
||||
Input,
|
||||
Select,
|
||||
Radio,
|
||||
Checkbox,
|
||||
AutoComplete,
|
||||
Cascader,
|
||||
DatePicker,
|
||||
InputNumber,
|
||||
Switch,
|
||||
TimePicker,
|
||||
TreeSelect,
|
||||
Slider,
|
||||
Rate,
|
||||
Divider,
|
||||
} from 'ant-design-vue';
|
||||
import { 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 RadioButtonGroup from './components/RadioButtonGroup.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 JTreeDict from './jeecg/components/JTreeDict.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 JInput from './jeecg/components/JInput.vue';
|
||||
import JTreeSelect from './jeecg/components/JTreeSelect.vue';
|
||||
import JEllipsis from './jeecg/components/JEllipsis.vue';
|
||||
import JSelectUserByDept from './jeecg/components/JSelectUserByDept.vue';
|
||||
import JUpload from './jeecg/components/JUpload/JUpload.vue'
|
||||
import JSearchSelect from './jeecg/components/JSearchSelect.vue'
|
||||
import JAddInput from './jeecg/components/JAddInput.vue'
|
||||
import JUpload from './jeecg/components/JUpload/JUpload.vue';
|
||||
import JSearchSelect from './jeecg/components/JSearchSelect.vue';
|
||||
import JAddInput from './jeecg/components/JAddInput.vue';
|
||||
import { Time } from '/@/components/Time';
|
||||
import JOnlineSelectCascade from './jeecg/components/JOnlineSelectCascade.vue'
|
||||
import JRangeNumber from './jeecg/components/JRangeNumber.vue'
|
||||
import JOnlineSelectCascade from './jeecg/components/JOnlineSelectCascade.vue';
|
||||
import JRangeNumber from './jeecg/components/JRangeNumber.vue';
|
||||
|
||||
const componentMap = new Map<ComponentType, Component>();
|
||||
|
||||
|
@ -125,8 +110,8 @@ componentMap.set('JSelectUserByDept', JSelectUserByDept);
|
|||
componentMap.set('JUpload', JUpload);
|
||||
componentMap.set('JSearchSelect', JSearchSelect);
|
||||
componentMap.set('JAddInput', JAddInput);
|
||||
componentMap.set('JOnlineSelectCascade', JOnlineSelectCascade)
|
||||
componentMap.set('JRangeNumber', JRangeNumber)
|
||||
componentMap.set('JOnlineSelectCascade', JOnlineSelectCascade);
|
||||
componentMap.set('JRangeNumber', JRangeNumber);
|
||||
|
||||
export function add(compName: ComponentType, component: Component) {
|
||||
componentMap.set(compName, component);
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
() => {
|
||||
!unref(isFirstLoad) && fetch();
|
||||
},
|
||||
{ deep: true },
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
async function fetch() {
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<template>
|
||||
<Select
|
||||
@dropdownVisibleChange="handleFetch"
|
||||
v-bind="$attrs"
|
||||
@change="handleChange"
|
||||
:options="getOptions"
|
||||
v-model:value="state"
|
||||
>
|
||||
<Select @dropdownVisibleChange="handleFetch" v-bind="$attrs" @change="handleChange" :options="getOptions" v-model:value="state">
|
||||
<template #[item]="data" v-for="item in Object.keys($slots)">
|
||||
<slot :name="item" v-bind="data || {}"></slot>
|
||||
</template>
|
||||
|
@ -118,7 +112,7 @@
|
|||
} finally {
|
||||
loading.value = false;
|
||||
//--@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值空的情况下需要设置为数组------
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,9 +75,7 @@
|
|||
const actionColOpt = computed(() => {
|
||||
const { showAdvancedButton, actionSpan: span, actionColOptions } = props;
|
||||
const actionSpan = 24 - span;
|
||||
const advancedSpanObj = showAdvancedButton
|
||||
? { span: actionSpan < 6 ? 24 : actionSpan }
|
||||
: {};
|
||||
const advancedSpanObj = showAdvancedButton ? { span: actionSpan < 6 ? 24 : actionSpan } : {};
|
||||
const actionColOpt: Partial<ColEx> = {
|
||||
style: { textAlign: 'right' },
|
||||
span: showAdvancedButton ? 6 : 4,
|
||||
|
|
|
@ -103,11 +103,7 @@
|
|||
function getShow(): { isShow: boolean; isIfShow: boolean } {
|
||||
const { show, ifShow } = props.schema;
|
||||
const { showAdvancedButton } = props.formProps;
|
||||
const itemIsAdvanced = showAdvancedButton
|
||||
? isBoolean(props.schema.isAdvanced)
|
||||
? props.schema.isAdvanced
|
||||
: true
|
||||
: true;
|
||||
const itemIsAdvanced = showAdvancedButton ? (isBoolean(props.schema.isAdvanced) ? props.schema.isAdvanced : true) : true;
|
||||
|
||||
let isShow = true;
|
||||
let isIfShow = true;
|
||||
|
@ -129,14 +125,7 @@
|
|||
}
|
||||
|
||||
function handleRules(): ValidationRule[] {
|
||||
const {
|
||||
rules: defRules = [],
|
||||
component,
|
||||
rulesMessageJoinLabel,
|
||||
label,
|
||||
dynamicRules,
|
||||
required,
|
||||
} = props.schema;
|
||||
const { rules: defRules = [], component, rulesMessageJoinLabel, label, dynamicRules, required } = props.schema;
|
||||
|
||||
if (isFunction(dynamicRules)) {
|
||||
return dynamicRules(unref(getValues)) as ValidationRule[];
|
||||
|
@ -145,9 +134,7 @@
|
|||
let rules: ValidationRule[] = cloneDeep(defRules) as ValidationRule[];
|
||||
const { rulesMessageJoinLabel: globalRulesMessageJoinLabel } = props.formProps;
|
||||
|
||||
const joinLabel = Reflect.has(props.schema, 'rulesMessageJoinLabel')
|
||||
? rulesMessageJoinLabel
|
||||
: globalRulesMessageJoinLabel;
|
||||
const joinLabel = Reflect.has(props.schema, 'rulesMessageJoinLabel') ? rulesMessageJoinLabel : globalRulesMessageJoinLabel;
|
||||
const defaultMsg = createPlaceholderMessage(component) + `${joinLabel ? label : ''}`;
|
||||
|
||||
function validator(rule: any, value: any) {
|
||||
|
@ -182,9 +169,7 @@
|
|||
rules = [{ required: getRequired, validator }];
|
||||
}
|
||||
|
||||
const requiredRuleIndex: number = rules.findIndex(
|
||||
(rule) => Reflect.has(rule, 'required') && !Reflect.has(rule, 'validator')
|
||||
);
|
||||
const requiredRuleIndex: number = rules.findIndex((rule) => Reflect.has(rule, 'required') && !Reflect.has(rule, 'validator'));
|
||||
|
||||
if (requiredRuleIndex !== -1) {
|
||||
const rule = rules[requiredRuleIndex];
|
||||
|
@ -210,21 +195,13 @@
|
|||
// Maximum input length rule check
|
||||
const characterInx = rules.findIndex((val) => val.max);
|
||||
if (characterInx !== -1 && !rules[characterInx].validator) {
|
||||
rules[characterInx].message =
|
||||
rules[characterInx].message ||
|
||||
t('component.form.maxTip', [rules[characterInx].max] as Recordable);
|
||||
rules[characterInx].message = rules[characterInx].message || t('component.form.maxTip', [rules[characterInx].max] as Recordable);
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
function renderComponent() {
|
||||
const {
|
||||
renderComponentContent,
|
||||
component,
|
||||
field,
|
||||
changeEvent = 'change',
|
||||
valueField,
|
||||
} = props.schema;
|
||||
const { renderComponentContent, component, field, changeEvent = 'change', valueField } = props.schema;
|
||||
|
||||
const isCheck = component && ['Switch', 'Checkbox'].includes(component);
|
||||
|
||||
|
@ -256,9 +233,7 @@
|
|||
// RangePicker place是一个数组
|
||||
if (isCreatePlaceholder && component !== 'RangePicker' && component) {
|
||||
//自动设置placeholder
|
||||
propsData.placeholder =
|
||||
unref(getComponentsProps)?.placeholder ||
|
||||
createPlaceholderMessage(component) + props.schema.label;
|
||||
propsData.placeholder = unref(getComponentsProps)?.placeholder || createPlaceholderMessage(component) + props.schema.label;
|
||||
}
|
||||
propsData.codeField = field;
|
||||
propsData.formValues = unref(getValues);
|
||||
|
@ -297,9 +272,7 @@
|
|||
) : (
|
||||
label
|
||||
);
|
||||
const getHelpMessage = isFunction(helpMessage)
|
||||
? helpMessage(unref(getValues))
|
||||
: helpMessage;
|
||||
const getHelpMessage = isFunction(helpMessage) ? helpMessage(unref(getValues)) : helpMessage;
|
||||
if (!getHelpMessage || (Array.isArray(getHelpMessage) && getHelpMessage.length === 0)) {
|
||||
return renderLabel;
|
||||
}
|
||||
|
@ -324,11 +297,7 @@
|
|||
);
|
||||
} else {
|
||||
const getContent = () => {
|
||||
return slot
|
||||
? getSlot(slots, slot, unref(getValues))
|
||||
: render
|
||||
? render(unref(getValues))
|
||||
: renderComponent();
|
||||
return slot ? getSlot(slots, slot, unref(getValues)) : render ? render(unref(getValues)) : renderComponent();
|
||||
};
|
||||
|
||||
const showSuffix = !!suffix;
|
||||
|
@ -367,11 +336,7 @@
|
|||
const values = unref(getValues);
|
||||
|
||||
const getContent = () => {
|
||||
return colSlot
|
||||
? getSlot(slots, colSlot, values)
|
||||
: renderColContent
|
||||
? renderColContent(values)
|
||||
: renderItem();
|
||||
return colSlot ? getSlot(slots, colSlot, values) : renderColContent ? renderColContent(values) : renderItem();
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -16,13 +16,7 @@ export function createPlaceholderMessage(component: ComponentType) {
|
|||
if (component.includes('Picker')) {
|
||||
return t('common.chooseText');
|
||||
}
|
||||
if (
|
||||
component.includes('Select') ||
|
||||
component.includes('Cascader') ||
|
||||
component.includes('Checkbox') ||
|
||||
component.includes('Radio') ||
|
||||
component.includes('Switch')
|
||||
) {
|
||||
if (component.includes('Select') || component.includes('Cascader') || component.includes('Checkbox') || component.includes('Radio') || component.includes('Switch')) {
|
||||
// return `请选择${label}`;
|
||||
return t('common.chooseText');
|
||||
}
|
||||
|
@ -35,11 +29,7 @@ function genType() {
|
|||
return [...DATE_TYPE, 'RangePicker'];
|
||||
}
|
||||
|
||||
export function setComponentRuleType(
|
||||
rule: ValidationRule,
|
||||
component: ComponentType,
|
||||
valueFormat: string
|
||||
) {
|
||||
export function setComponentRuleType(rule: ValidationRule, component: ComponentType, valueFormat: string) {
|
||||
if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component)) {
|
||||
rule.type = valueFormat ? 'string' : 'object';
|
||||
} else if (['RangePicker', 'Upload', 'CheckboxGroup', 'TimePicker'].includes(component)) {
|
||||
|
|
|
@ -18,14 +18,7 @@ interface UseAdvancedContext {
|
|||
defaultValueRef: Ref<Recordable>;
|
||||
}
|
||||
|
||||
export default function ({
|
||||
advanceState,
|
||||
emit,
|
||||
getProps,
|
||||
getSchema,
|
||||
formModel,
|
||||
defaultValueRef,
|
||||
}: UseAdvancedContext) {
|
||||
export default function ({ advanceState, emit, getProps, getSchema, formModel, defaultValueRef }: UseAdvancedContext) {
|
||||
const { realWidthRef, screenEnum, screenRef } = useBreakpoint();
|
||||
|
||||
const getEmptySpan = computed((): number => {
|
||||
|
@ -64,12 +57,7 @@ export default function ({
|
|||
function getAdvanced(itemCol: Partial<ColEx>, itemColSum = 0, isLastAction = false, index = 0) {
|
||||
const width = unref(realWidthRef);
|
||||
|
||||
const mdWidth =
|
||||
parseInt(itemCol.md as string) ||
|
||||
parseInt(itemCol.xs as string) ||
|
||||
parseInt(itemCol.sm as string) ||
|
||||
(itemCol.span as number) ||
|
||||
BASIC_COL_LEN;
|
||||
const mdWidth = 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 xlWidth = parseInt(itemCol.xl as string) || lgWidth;
|
||||
|
@ -84,7 +72,7 @@ export default function ({
|
|||
itemColSum += xxlWidth;
|
||||
}
|
||||
|
||||
let autoAdvancedCol = (unref(getProps).autoAdvancedCol ?? 3)
|
||||
let autoAdvancedCol = unref(getProps).autoAdvancedCol ?? 3;
|
||||
|
||||
if (isLastAction) {
|
||||
advanceState.hideAdvanceBtn = unref(getSchema).length <= autoAdvancedCol;
|
||||
|
@ -95,10 +83,7 @@ export default function ({
|
|||
advanceState.isAdvanced = true;
|
||||
} else */
|
||||
// update-end--author:sunjianlei---date:20211108---for: 注释掉该逻辑,使小于等于2行时,也显示展开收起按钮
|
||||
if (
|
||||
itemColSum > BASIC_COL_LEN * 2 &&
|
||||
itemColSum <= BASIC_COL_LEN * (unref(getProps).autoAdvancedLine || 3)
|
||||
) {
|
||||
if (itemColSum > BASIC_COL_LEN * 2 && itemColSum <= BASIC_COL_LEN * (unref(getProps).autoAdvancedLine || 3)) {
|
||||
advanceState.hideAdvanceBtn = false;
|
||||
|
||||
// 默认超过 3 行折叠
|
||||
|
@ -107,8 +92,8 @@ export default function ({
|
|||
advanceState.isAdvanced = !advanceState.isAdvanced;
|
||||
// update-begin--author:sunjianlei---date:20211108---for: 如果总列数大于 autoAdvancedCol,就默认折叠
|
||||
if (unref(getSchema).length > autoAdvancedCol) {
|
||||
advanceState.hideAdvanceBtn = false
|
||||
advanceState.isAdvanced = false
|
||||
advanceState.hideAdvanceBtn = false;
|
||||
advanceState.isAdvanced = false;
|
||||
}
|
||||
// update-end--author:sunjianlei---date:20211108---for: 如果总列数大于 autoAdvancedCol,就默认折叠
|
||||
}
|
||||
|
@ -116,9 +101,9 @@ export default function ({
|
|||
}
|
||||
if (itemColSum > BASIC_COL_LEN * (unref(getProps).alwaysShowLines || 1)) {
|
||||
return { isAdvanced: advanceState.isAdvanced, itemColSum };
|
||||
} else if (!advanceState.isAdvanced && (index + 1) > autoAdvancedCol) {
|
||||
} else if (!advanceState.isAdvanced && index + 1 > autoAdvancedCol) {
|
||||
// 如果当前是收起状态,并且当前列下标 > autoAdvancedCol,就隐藏
|
||||
return { isAdvanced: false, itemColSum }
|
||||
return { isAdvanced: false, itemColSum };
|
||||
} else {
|
||||
// The first line is always displayed
|
||||
return { isAdvanced: true, itemColSum };
|
||||
|
@ -130,9 +115,9 @@ export default function ({
|
|||
let realItemColSum = 0;
|
||||
const { baseColProps = {} } = unref(getProps);
|
||||
|
||||
const schemas = unref(getSchema)
|
||||
const schemas = unref(getSchema);
|
||||
for (let i = 0; i < schemas.length; i++) {
|
||||
const schema = schemas[i]
|
||||
const schema = schemas[i];
|
||||
const { show, colProps } = schema;
|
||||
let isShow = true;
|
||||
|
||||
|
@ -153,10 +138,7 @@ export default function ({
|
|||
}
|
||||
|
||||
if (isShow && (colProps || baseColProps)) {
|
||||
const { itemColSum: sum, isAdvanced } = getAdvanced(
|
||||
{ ...baseColProps, ...colProps },
|
||||
itemColSum, false, i,
|
||||
);
|
||||
const { itemColSum: sum, isAdvanced } = getAdvanced({ ...baseColProps, ...colProps }, itemColSum, false, i);
|
||||
|
||||
itemColSum = sum || 0;
|
||||
if (isAdvanced) {
|
||||
|
|
|
@ -9,12 +9,7 @@ interface UseAutoFocusContext {
|
|||
isInitedDefault: Ref<boolean>;
|
||||
formElRef: Ref<FormActionType>;
|
||||
}
|
||||
export async function useAutoFocus({
|
||||
getSchema,
|
||||
getProps,
|
||||
formElRef,
|
||||
isInitedDefault,
|
||||
}: UseAutoFocusContext) {
|
||||
export async function useAutoFocus({ getSchema, getProps, formElRef, isInitedDefault }: UseAutoFocusContext) {
|
||||
watchEffect(async () => {
|
||||
if (unref(isInitedDefault) || !unref(getProps).autoFocusFirstItem) {
|
||||
return;
|
||||
|
|
|
@ -18,9 +18,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
|||
async function getForm() {
|
||||
const form = unref(formRef);
|
||||
if (!form) {
|
||||
error(
|
||||
'The form instance has not been obtained, please make sure that the form has been rendered when performing the form operation!'
|
||||
);
|
||||
error('The form instance has not been obtained, please make sure that the form has been rendered when performing the form operation!');
|
||||
}
|
||||
await nextTick();
|
||||
return form as FormActionType;
|
||||
|
@ -94,11 +92,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
|||
form.setFieldsValue<T>(values);
|
||||
},
|
||||
|
||||
appendSchemaByField: async (
|
||||
schema: FormSchema,
|
||||
prefixField: string | undefined,
|
||||
first: boolean
|
||||
) => {
|
||||
appendSchemaByField: async (schema: FormSchema, prefixField: string | undefined, first: boolean) => {
|
||||
const form = await getForm();
|
||||
form.appendSchemaByField(schema, prefixField, first);
|
||||
},
|
||||
|
|
|
@ -19,16 +19,7 @@ interface UseFormActionContext {
|
|||
schemaRef: Ref<FormSchema[]>;
|
||||
handleFormValues: Fn;
|
||||
}
|
||||
export function useFormEvents({
|
||||
emit,
|
||||
getProps,
|
||||
formModel,
|
||||
getSchema,
|
||||
defaultValueRef,
|
||||
formElRef,
|
||||
schemaRef,
|
||||
handleFormValues,
|
||||
}: UseFormActionContext) {
|
||||
export function useFormEvents({ emit, getProps, formModel, getSchema, defaultValueRef, formElRef, schemaRef, handleFormValues }: UseFormActionContext) {
|
||||
async function resetFields(): Promise<void> {
|
||||
const { resetFunc, submitOnReset } = unref(getProps);
|
||||
resetFunc && isFunction(resetFunc) && (await resetFunc());
|
||||
|
@ -149,14 +140,10 @@ export function useFormEvents({
|
|||
updateData = [...data];
|
||||
}
|
||||
|
||||
const hasField = updateData.every(
|
||||
(item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field)
|
||||
);
|
||||
const hasField = updateData.every((item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field));
|
||||
|
||||
if (!hasField) {
|
||||
error(
|
||||
'All children of the form Schema array that need to be updated must contain the `field` field'
|
||||
);
|
||||
error('All children of the form Schema array that need to be updated must contain the `field` field');
|
||||
return;
|
||||
}
|
||||
schemaRef.value = updateData as FormSchema[];
|
||||
|
@ -171,14 +158,10 @@ export function useFormEvents({
|
|||
updateData = [...data];
|
||||
}
|
||||
|
||||
const hasField = updateData.every(
|
||||
(item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field)
|
||||
);
|
||||
const hasField = updateData.every((item) => item.component === 'Divider' || (Reflect.has(item, 'field') && item.field));
|
||||
|
||||
if (!hasField) {
|
||||
error(
|
||||
'All children of the form Schema array that need to be updated must contain the `field` field'
|
||||
);
|
||||
error('All children of the form Schema array that need to be updated must contain the `field` field');
|
||||
return;
|
||||
}
|
||||
const schema: FormSchema[] = [];
|
||||
|
|
|
@ -12,12 +12,7 @@ interface UseFormValuesContext {
|
|||
getProps: ComputedRef<FormProps>;
|
||||
formModel: Recordable;
|
||||
}
|
||||
export function useFormValues({
|
||||
defaultValueRef,
|
||||
getSchema,
|
||||
formModel,
|
||||
getProps,
|
||||
}: UseFormValuesContext) {
|
||||
export function useFormValues({ defaultValueRef, getSchema, formModel, getProps }: UseFormValuesContext) {
|
||||
// Processing form values
|
||||
function handleFormValues(values: Recordable) {
|
||||
if (!isObject(values)) {
|
||||
|
@ -46,7 +41,6 @@ export function useFormValues({
|
|||
return handleRangeValue(getProps, res);
|
||||
}
|
||||
|
||||
|
||||
function initDefault() {
|
||||
const schemas = unref(getSchema);
|
||||
const obj: Recordable = {};
|
||||
|
|
|
@ -10,20 +10,16 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
|
|||
const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {};
|
||||
const { labelWidth, disabledLabelWidth } = schemaItem;
|
||||
|
||||
const {
|
||||
labelWidth: globalLabelWidth,
|
||||
labelCol: globalLabelCol,
|
||||
wrapperCol: globWrapperCol,
|
||||
} = unref(propsRef);
|
||||
const { labelWidth: globalLabelWidth, labelCol: globalLabelCol, wrapperCol: globWrapperCol } = unref(propsRef);
|
||||
|
||||
// update-begin--author:sunjianlei---date:20211104---for: 禁用全局 labelWidth,不自动设置 textAlign --------
|
||||
if (disabledLabelWidth) {
|
||||
return { labelCol, wrapperCol }
|
||||
return { labelCol, wrapperCol };
|
||||
}
|
||||
// update-begin--author:sunjianlei---date:20211104---for: 禁用全局 labelWidth,不自动设置 textAlign --------
|
||||
|
||||
// If labelWidth is set globally, all items setting
|
||||
if ((!globalLabelWidth && !labelWidth && !globalLabelCol)) {
|
||||
if (!globalLabelWidth && !labelWidth && !globalLabelCol) {
|
||||
labelCol.style = {
|
||||
textAlign: 'left',
|
||||
};
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
<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="请输入参数value" v-model:value="param.value" style="width: 30%; margin: 0 0 5px 5px" @input="emitChange" />
|
||||
<MinusCircleOutlined
|
||||
v-if="dynamicInput.params.length > 1"
|
||||
class="dynamic-delete-button"
|
||||
@click="remove(param)"
|
||||
style="width: 50px"
|
||||
></MinusCircleOutlined>
|
||||
<MinusCircleOutlined v-if="dynamicInput.params.length > 1" class="dynamic-delete-button" @click="remove(param)" style="width: 50px"></MinusCircleOutlined>
|
||||
</div>
|
||||
<div>
|
||||
<a-button type="dashed" style="width: 60%" @click="add">
|
||||
|
@ -20,7 +15,7 @@
|
|||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
||||
import { defineComponent, reactive, ref, UnwrapRef, watchEffect } from 'vue';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { isEmpty } from '/@/utils/is'
|
||||
import { isEmpty } from '/@/utils/is';
|
||||
import { tryOnMounted, tryOnUnmounted } from '@vueuse/core';
|
||||
interface Params {
|
||||
label: string;
|
||||
|
@ -30,7 +25,7 @@
|
|||
export default defineComponent({
|
||||
name: 'JAddInput',
|
||||
props: {
|
||||
value: propTypes.string.def('')
|
||||
value: propTypes.string.def(''),
|
||||
},
|
||||
emits: ['change', 'update:value'],
|
||||
setup(props, { emit }) {
|
||||
|
@ -42,7 +37,7 @@
|
|||
if (index !== -1) {
|
||||
dynamicInput.params.splice(index, 1);
|
||||
}
|
||||
emitChange()
|
||||
emitChange();
|
||||
};
|
||||
//新增Input
|
||||
const add = () => {
|
||||
|
@ -50,7 +45,7 @@
|
|||
label: '',
|
||||
value: '',
|
||||
});
|
||||
emitChange()
|
||||
emitChange();
|
||||
};
|
||||
|
||||
//监听传入数据value
|
||||
|
@ -62,9 +57,9 @@
|
|||
* 初始化数值
|
||||
*/
|
||||
function initVal() {
|
||||
console.log("props.value",props.value)
|
||||
console.log('props.value', props.value);
|
||||
dynamicInput.params = [];
|
||||
if(props.value && props.value.indexOf("{")==0){
|
||||
if (props.value && props.value.indexOf('{') == 0) {
|
||||
let jsonObj = JSON.parse(props.value);
|
||||
Object.keys(jsonObj).forEach((key) => {
|
||||
dynamicInput.params.push({ label: key, value: jsonObj[key] });
|
||||
|
@ -77,12 +72,12 @@
|
|||
function emitChange() {
|
||||
let obj = {};
|
||||
if (dynamicInput.params.length > 0) {
|
||||
dynamicInput.params.forEach(item => {
|
||||
obj[item['label']] = item['value']
|
||||
})
|
||||
dynamicInput.params.forEach((item) => {
|
||||
obj[item['label']] = item['value'];
|
||||
});
|
||||
}
|
||||
emit("change", isEmpty(obj)?'': JSON.stringify(obj));
|
||||
emit("update:value",isEmpty(obj)?'': JSON.stringify(obj))
|
||||
emit('change', isEmpty(obj) ? '' : JSON.stringify(obj));
|
||||
emit('update:value', isEmpty(obj) ? '' : JSON.stringify(obj));
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -4,25 +4,22 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
||||
import { Cascader } from 'ant-design-vue';
|
||||
import {provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus} from "../../utils/areaDataUtil";
|
||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import { provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus } from '../../utils/areaDataUtil';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
export default defineComponent({
|
||||
name: 'JAreaLinkage',
|
||||
components: {
|
||||
Cascader
|
||||
Cascader,
|
||||
},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.object,
|
||||
propTypes.array
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.object, propTypes.array]),
|
||||
//是否显示区县
|
||||
showArea: propTypes.bool.def(true),
|
||||
//是否是全部
|
||||
showAll:propTypes.bool.def(false)
|
||||
showAll: propTypes.bool.def(false),
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
setup(props, { emit, refs }) {
|
||||
|
@ -31,28 +28,28 @@
|
|||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
const getOptions = computed(() => {
|
||||
if (props.showArea && props.showAll) {
|
||||
return regionDataPlus
|
||||
return regionDataPlus;
|
||||
}
|
||||
if (props.showArea && !props.showAll) {
|
||||
return regionData
|
||||
return regionData;
|
||||
}
|
||||
if (!props.showArea && !props.showAll) {
|
||||
return provinceAndCityData
|
||||
return provinceAndCityData;
|
||||
}
|
||||
if (!props.showArea && props.showAll) {
|
||||
return provinceAndCityDataPlus
|
||||
return provinceAndCityDataPlus;
|
||||
}
|
||||
});
|
||||
function handleChange(_, ...args) {
|
||||
emitData.value = args;
|
||||
console.info(emitData)
|
||||
console.info(emitData);
|
||||
}
|
||||
return {
|
||||
state,
|
||||
attrs,
|
||||
regionData,
|
||||
getOptions,
|
||||
handleChange
|
||||
handleChange,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
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 {provinceOptions, getDataByCode, getRealCode} from "../../utils/areaDataUtil";
|
||||
import { provinceOptions, getDataByCode, getRealCode } from '../../utils/areaDataUtil';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JAreaSelect',
|
||||
|
@ -66,9 +66,9 @@
|
|||
*/
|
||||
watch(pca, (newVal) => {
|
||||
if (!props.value) {
|
||||
emit("update:province",pca.province);
|
||||
emit("update:city",pca.city);
|
||||
emit("update:area",pca.area);
|
||||
emit('update:province', pca.province);
|
||||
emit('update:city', pca.city);
|
||||
emit('update:area', pca.area);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -102,19 +102,19 @@
|
|||
* 省份change事件
|
||||
*/
|
||||
function proChange(val) {
|
||||
pca.city = (val && getDataByCode(val)[0]?.value);
|
||||
pca.area = (pca.city && getDataByCode(pca.city)[0]?.value);
|
||||
state.value = props.level <= 1 ? val : (props.level <= 2 ? pca.city : pca.area);
|
||||
emit("update:value",unref(state));
|
||||
pca.city = val && getDataByCode(val)[0]?.value;
|
||||
pca.area = pca.city && getDataByCode(pca.city)[0]?.value;
|
||||
state.value = props.level <= 1 ? val : props.level <= 2 ? pca.city : pca.area;
|
||||
emit('update:value', unref(state));
|
||||
}
|
||||
|
||||
/**
|
||||
* 城市change事件
|
||||
*/
|
||||
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;
|
||||
emit("update:value",unref(state));
|
||||
emit('update:value', unref(state));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@
|
|||
*/
|
||||
function areaChange(val) {
|
||||
state.value = val;
|
||||
emit("update:value",unref(state));
|
||||
emit('update:value', unref(state));
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -132,7 +132,7 @@
|
|||
areaOptions,
|
||||
proChange,
|
||||
cityChange,
|
||||
areaChange
|
||||
areaChange,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
:value="treeValue"
|
||||
:treeData="treeData"
|
||||
:multiple="multiple"
|
||||
@change="onChange">
|
||||
@change="onChange"
|
||||
>
|
||||
</a-tree-select>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
|
@ -28,10 +29,7 @@
|
|||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array,
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择',
|
||||
|
@ -86,14 +84,14 @@
|
|||
() => {
|
||||
loadItemByCode();
|
||||
},
|
||||
{ deep: true },
|
||||
{ deep: true }
|
||||
);
|
||||
watch(
|
||||
() => props.pcode,
|
||||
() => {
|
||||
loadRoot();
|
||||
},
|
||||
{ deep: true, immediate: true },
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
|
||||
function loadRoot() {
|
||||
|
@ -103,7 +101,7 @@
|
|||
condition: props.condition,
|
||||
};
|
||||
console.info(param);
|
||||
loadTreeData(param).then(res => {
|
||||
loadTreeData(param).then((res) => {
|
||||
for (let i of res) {
|
||||
i.value = i.key;
|
||||
if (i.leaf == false) {
|
||||
|
@ -114,15 +112,13 @@
|
|||
}
|
||||
treeData.value = res;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function loadItemByCode() {
|
||||
if (!props.value || props.value == '0') {
|
||||
treeValue.value = [];
|
||||
} else {
|
||||
loadDictItem({ ids: props.value }).then(res => {
|
||||
loadDictItem({ ids: props.value }).then((res) => {
|
||||
let values = props.value.split(',');
|
||||
treeValue.value = res.map((item, index) => ({
|
||||
key: values[index],
|
||||
|
@ -139,7 +135,6 @@
|
|||
if (!props.multiple && props.loadTriggleChange) {
|
||||
backValue(props.value, text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function backValue(value, label) {
|
||||
|
@ -163,7 +158,7 @@
|
|||
pid: pid,
|
||||
condition: props.condition,
|
||||
};
|
||||
loadTreeData(param).then(res => {
|
||||
loadTreeData(param).then((res) => {
|
||||
if (res) {
|
||||
for (let i of res) {
|
||||
i.value = i.key;
|
||||
|
@ -204,7 +199,7 @@
|
|||
treeValue.value = '';
|
||||
} else if (Array.isArray(value)) {
|
||||
let labels = [];
|
||||
let values = value.map(item => {
|
||||
let values = value.map((item) => {
|
||||
labels.push(item.label);
|
||||
return item.value;
|
||||
});
|
||||
|
@ -251,6 +246,5 @@
|
|||
asyncLoadTreeData,
|
||||
};
|
||||
},
|
||||
})
|
||||
;
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
<script lang="ts">
|
||||
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 {initDictOptions} from "/@/utils/dict/index"
|
||||
import { initDictOptions } from '/@/utils/dict/index';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JCheckbox',
|
||||
|
@ -29,10 +29,10 @@
|
|||
* 监听value
|
||||
*/
|
||||
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不会清空当前信息,界面显示上一次的数据
|
||||
if (props.value === '' || props.value === undefined) {
|
||||
checkboxArray.value = []
|
||||
checkboxArray.value = [];
|
||||
}
|
||||
//update-end-author:taoyan date:20220401 for: 调用表单的 resetFields不会清空当前信息,界面显示上一次的数据
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
// 引入全局实例
|
||||
import _CodeMirror, { EditorFromTextArea } from 'codemirror'
|
||||
import _CodeMirror, { EditorFromTextArea } from 'codemirror';
|
||||
// 核心样式
|
||||
import 'codemirror/lib/codemirror.css';
|
||||
// 引入主题后还需要在 options 中指定主题才会生效
|
||||
|
@ -29,22 +29,22 @@
|
|||
import 'codemirror/mode/swift/swift.js';
|
||||
import 'codemirror/mode/vue/vue.js';
|
||||
// 折叠资源引入:开始
|
||||
import "codemirror/addon/fold/foldgutter.css";
|
||||
import "codemirror/addon/fold/foldcode.js";
|
||||
import "codemirror/addon/fold/brace-fold.js";
|
||||
import "codemirror/addon/fold/comment-fold.js";
|
||||
import "codemirror/addon/fold/indent-fold.js";
|
||||
import "codemirror/addon/fold/foldgutter.js";
|
||||
import 'codemirror/addon/fold/foldgutter.css';
|
||||
import 'codemirror/addon/fold/foldcode.js';
|
||||
import 'codemirror/addon/fold/brace-fold.js';
|
||||
import 'codemirror/addon/fold/comment-fold.js';
|
||||
import 'codemirror/addon/fold/indent-fold.js';
|
||||
import 'codemirror/addon/fold/foldgutter.js';
|
||||
// 折叠资源引入:结束
|
||||
//光标行背景高亮,配置里面也需要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.js";
|
||||
import "codemirror/addon/hint/anyword-hint.js";
|
||||
import 'codemirror/addon/hint/show-hint.css';
|
||||
import 'codemirror/addon/hint/show-hint.js';
|
||||
import 'codemirror/addon/hint/anyword-hint.js';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import {useDesign} from '/@/hooks/web/useDesign'
|
||||
import {isJsonObjectString} from '/@/utils/is.ts'
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { isJsonObjectString } from '/@/utils/is.ts';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JCodeEditor',
|
||||
|
@ -68,7 +68,7 @@
|
|||
//表单值
|
||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
const textarea = ref<HTMLTextAreaElement>();
|
||||
let coder: Nullable<EditorFromTextArea> = null
|
||||
let coder: Nullable<EditorFromTextArea> = null;
|
||||
const attrs = useAttrs();
|
||||
const height = ref(props.height);
|
||||
const options = reactive({
|
||||
|
@ -83,7 +83,7 @@
|
|||
// 启用代码折叠相关功能:开始
|
||||
foldGutter: true,
|
||||
lineWrapping: true,
|
||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"],
|
||||
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers'],
|
||||
// 启用代码折叠相关功能:结束
|
||||
// 光标行高亮
|
||||
styleActiveLine: true,
|
||||
|
@ -92,38 +92,43 @@
|
|||
Tab: function autoFormat(editor) {
|
||||
//var totalLines = editor.lineCount();
|
||||
//editor.autoFormatRange({line:0, ch:0}, {line:totalLines});
|
||||
setValue(innerValue,false)
|
||||
}
|
||||
}
|
||||
setValue(innerValue, false);
|
||||
},
|
||||
},
|
||||
});
|
||||
let innerValue = ''
|
||||
let innerValue = '';
|
||||
// 全屏状态
|
||||
const isFullScreen = ref(false)
|
||||
const fullScreenIcon = computed(() => isFullScreen.value ? 'fullscreen-exit' : 'fullscreen')
|
||||
const isFullScreen = ref(false);
|
||||
const fullScreenIcon = computed(() => (isFullScreen.value ? 'fullscreen-exit' : 'fullscreen'));
|
||||
// 外部盒子参数
|
||||
const boxBindProps = computed(() => {
|
||||
let _props = {
|
||||
class: [
|
||||
prefixCls, 'full-screen-parent', 'auto-height',
|
||||
prefixCls,
|
||||
'full-screen-parent',
|
||||
'auto-height',
|
||||
{
|
||||
'full-screen': isFullScreen.value,
|
||||
},
|
||||
],
|
||||
style: {},
|
||||
}
|
||||
};
|
||||
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) {
|
||||
setValue(props.value, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
onMounted(() => {
|
||||
initialize();
|
||||
});
|
||||
|
@ -137,9 +142,9 @@
|
|||
if (value && isJsonObjectString(value)) {
|
||||
value = JSON.stringify(JSON.parse(value), null, 2);
|
||||
}
|
||||
coder?.setValue(value ?? '')
|
||||
innerValue = value
|
||||
trigger && emitChange(innerValue)
|
||||
coder?.setValue(value ?? '');
|
||||
innerValue = value;
|
||||
trigger && emitChange(innerValue);
|
||||
}
|
||||
|
||||
//编辑器值修改事件
|
||||
|
@ -147,7 +152,7 @@
|
|||
let value = obj.getValue();
|
||||
innerValue = value || '';
|
||||
if (props.value != innerValue) {
|
||||
emitChange(innerValue)
|
||||
emitChange(innerValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,12 +167,12 @@
|
|||
//绑定值修改事件
|
||||
coder.on('change', onChange);
|
||||
// 初始化成功时赋值一次
|
||||
setValue(innerValue, false)
|
||||
setValue(innerValue, false);
|
||||
}
|
||||
|
||||
// 切换全屏状态
|
||||
function onToggleFullScreen() {
|
||||
isFullScreen.value = !isFullScreen.value
|
||||
isFullScreen.value = !isFullScreen.value;
|
||||
}
|
||||
|
||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||
|
@ -189,7 +194,6 @@
|
|||
//noinspection LessUnresolvedVariable
|
||||
@prefix-cls: ~'@{namespace}-code-editer';
|
||||
.@{prefix-cls} {
|
||||
|
||||
&.auto-height {
|
||||
.CodeMirror {
|
||||
height: v-bind(height) !important;
|
||||
|
@ -253,7 +257,6 @@
|
|||
.full-screen-child {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -36,31 +36,27 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import {initDictOptions} from "/@/utils/dict/index"
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { initDictOptions } from '/@/utils/dict/index';
|
||||
import { get, omit } from 'lodash-es';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { CompTypeEnum } from '/@/enums/CompTypeEnum.ts';
|
||||
import {LoadingOutlined} from '@ant-design/icons-vue'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JDictSelectTag',
|
||||
inheritAttrs: false,
|
||||
components: { LoadingOutlined },
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.number,
|
||||
propTypes.array,
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.array]),
|
||||
dictCode: propTypes.string,
|
||||
type: propTypes.string,
|
||||
placeholder: propTypes.string,
|
||||
stringToNumber: propTypes.bool,
|
||||
getPopupContainer: {
|
||||
type: Function,
|
||||
default: (node) => node.parentNode
|
||||
default: (node) => node.parentNode,
|
||||
},
|
||||
// 是否显示【请选择】选项
|
||||
showChooseOption: propTypes.bool.def(true),
|
||||
|
@ -68,7 +64,7 @@
|
|||
options: {
|
||||
type: Array,
|
||||
default: [],
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
|
@ -79,43 +75,44 @@
|
|||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||
// 是否正在加载回显数据
|
||||
const loadingEcho = ref<boolean>(false)
|
||||
const loadingEcho = ref<boolean>(false);
|
||||
// 是否是首次加载回显,只有首次加载,才会显示 loading
|
||||
let isFirstLoadEcho = true
|
||||
let isFirstLoadEcho = true;
|
||||
|
||||
//组件类型
|
||||
const compType = computed(() => {
|
||||
return (!props.type || props.type === "list") ? 'select' : props.type;
|
||||
return !props.type || props.type === 'list' ? 'select' : props.type;
|
||||
});
|
||||
/**
|
||||
* 监听字典code
|
||||
*/
|
||||
watchEffect(() => {
|
||||
if (props.dictCode) {
|
||||
loadingEcho.value = isFirstLoadEcho
|
||||
isFirstLoadEcho = false
|
||||
loadingEcho.value = isFirstLoadEcho;
|
||||
isFirstLoadEcho = false;
|
||||
initDictData().finally(() => {
|
||||
loadingEcho.value = isFirstLoadEcho
|
||||
})
|
||||
loadingEcho.value = isFirstLoadEcho;
|
||||
});
|
||||
}
|
||||
//update-begin-author:taoyan date: 如果没有提供dictCode 可以走options的配置--
|
||||
if (!props.dictCode) {
|
||||
dictOptions.value = props.options
|
||||
dictOptions.value = props.options;
|
||||
}
|
||||
//update-end-author:taoyan date: 如果没有提供dictCode 可以走options的配置--
|
||||
|
||||
});
|
||||
|
||||
//update-begin-author:taoyan date:20220404 for: 使用useRuleFormItem定义的value,会有一个问题,如果不是操作设置的值而是代码设置的控件值而不能触发change事件
|
||||
// 此处添加空值的change事件,即当组件调用地代码设置value为''也能触发change事件
|
||||
watch(()=>props.value, ()=>{
|
||||
watch(
|
||||
() => props.value,
|
||||
() => {
|
||||
if (props.value === '') {
|
||||
emit('change', '')
|
||||
emit('change', '');
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
//update-end-author:taoyan date:20220404 for: 使用useRuleFormItem定义的value,会有一个问题,如果不是操作设置的值而是代码设置的控件值而不能触发change事件
|
||||
|
||||
|
||||
async function initDictData() {
|
||||
let { dictCode, stringToNumber } = props;
|
||||
//根据字典Code, 初始化字典数组
|
||||
|
@ -140,12 +137,12 @@
|
|||
/** 用于搜索下拉框中的内容 */
|
||||
function handleFilterOption(input, option) {
|
||||
// 在 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) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
// 在 value 中搜索
|
||||
return (option.value || '').toString().toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
return (option.value || '').toString().toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -27,44 +27,44 @@
|
|||
<a-divider />
|
||||
<!-- 执行时间预览 -->
|
||||
<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-col :span="8" style="margin-bottom: 12px;">
|
||||
<a-col :span="8" style="margin-bottom: 12px">
|
||||
<a-input v-model:value="inputValues.second" @blur="onInputBlur">
|
||||
<template #addonBefore>
|
||||
<span class="allow-click" @click="activeKey = 'second'">秒</span>
|
||||
</template>
|
||||
</a-input>
|
||||
</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">
|
||||
<template #addonBefore>
|
||||
<span class="allow-click" @click="activeKey = 'minute'">分</span>
|
||||
</template>
|
||||
</a-input>
|
||||
</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">
|
||||
<template #addonBefore>
|
||||
<span class="allow-click" @click="activeKey = 'hour'">时</span>
|
||||
</template>
|
||||
</a-input>
|
||||
</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">
|
||||
<template #addonBefore>
|
||||
<span class="allow-click" @click="activeKey = 'day'">日</span>
|
||||
</template>
|
||||
</a-input>
|
||||
</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">
|
||||
<template #addonBefore>
|
||||
<span class="allow-click" @click="activeKey = 'month'">月</span>
|
||||
</template>
|
||||
</a-input>
|
||||
</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">
|
||||
<template #addonBefore>
|
||||
<span class="allow-click" @click="activeKey = 'week'">周</span>
|
||||
|
@ -97,74 +97,76 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, watch, provide } from 'vue'
|
||||
import { useDesign } from '/@/hooks/web/useDesign'
|
||||
import CronParser from 'cron-parser'
|
||||
import SecondUI from './tabs/SecondUI.vue'
|
||||
import MinuteUI from './tabs/MinuteUI.vue'
|
||||
import HourUI from './tabs/HourUI.vue'
|
||||
import DayUI from './tabs/DayUI.vue'
|
||||
import MonthUI from './tabs/MonthUI.vue'
|
||||
import WeekUI from './tabs/WeekUI.vue'
|
||||
import YearUI from './tabs/YearUI.vue'
|
||||
import { cronEmits, cronProps } from './easy.cron.data'
|
||||
import { dateFormat, simpleDebounce } from '/@/utils/common/compUtils'
|
||||
import { computed, reactive, ref, watch, provide } from 'vue';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import CronParser from 'cron-parser';
|
||||
import SecondUI from './tabs/SecondUI.vue';
|
||||
import MinuteUI from './tabs/MinuteUI.vue';
|
||||
import HourUI from './tabs/HourUI.vue';
|
||||
import DayUI from './tabs/DayUI.vue';
|
||||
import MonthUI from './tabs/MonthUI.vue';
|
||||
import WeekUI from './tabs/WeekUI.vue';
|
||||
import YearUI from './tabs/YearUI.vue';
|
||||
import { cronEmits, cronProps } from './easy.cron.data';
|
||||
import { dateFormat, simpleDebounce } from '/@/utils/common/compUtils';
|
||||
|
||||
const { prefixCls } = useDesign('easy-cron-inner')
|
||||
provide('prefixCls', prefixCls)
|
||||
const emit = defineEmits([...cronEmits])
|
||||
const props = defineProps({ ...cronProps })
|
||||
const activeKey = ref(props.hideSecond ? 'minute' : 'second')
|
||||
const second = ref('*')
|
||||
const minute = ref('*')
|
||||
const hour = ref('*')
|
||||
const day = ref('*')
|
||||
const month = ref('*')
|
||||
const week = ref('?')
|
||||
const year = ref('*')
|
||||
const inputValues = reactive({ second: '', minute: '', hour: '', day: '', month: '', week: '', year: '', cron: '' })
|
||||
const preTimeList = ref('执行预览,会忽略年份参数。')
|
||||
const { prefixCls } = useDesign('easy-cron-inner');
|
||||
provide('prefixCls', prefixCls);
|
||||
const emit = defineEmits([...cronEmits]);
|
||||
const props = defineProps({ ...cronProps });
|
||||
const activeKey = ref(props.hideSecond ? 'minute' : 'second');
|
||||
const second = ref('*');
|
||||
const minute = ref('*');
|
||||
const hour = ref('*');
|
||||
const day = ref('*');
|
||||
const month = ref('*');
|
||||
const week = ref('?');
|
||||
const year = ref('*');
|
||||
const inputValues = reactive({ second: '', minute: '', hour: '', day: '', month: '', week: '', year: '', cron: '' });
|
||||
const preTimeList = ref('执行预览,会忽略年份参数。');
|
||||
|
||||
// cron表达式
|
||||
const cronValueInner = computed(() => {
|
||||
let result: string[] = []
|
||||
let result: string[] = [];
|
||||
if (!props.hideSecond) {
|
||||
result.push(second.value ? second.value : '*')
|
||||
result.push(second.value ? second.value : '*');
|
||||
}
|
||||
result.push(minute.value ? minute.value : '*')
|
||||
result.push(hour.value ? hour.value : '*')
|
||||
result.push(day.value ? day.value : '*')
|
||||
result.push(month.value ? month.value : '*')
|
||||
result.push(week.value ? week.value : '?')
|
||||
if (!props.hideYear && !props.hideSecond) result.push(year.value ? year.value : '*')
|
||||
return result.join(' ')
|
||||
})
|
||||
result.push(minute.value ? minute.value : '*');
|
||||
result.push(hour.value ? hour.value : '*');
|
||||
result.push(day.value ? day.value : '*');
|
||||
result.push(month.value ? month.value : '*');
|
||||
result.push(week.value ? week.value : '?');
|
||||
if (!props.hideYear && !props.hideSecond) result.push(year.value ? year.value : '*');
|
||||
return result.join(' ');
|
||||
});
|
||||
// 不含年
|
||||
const cronValueNoYear = computed(() => {
|
||||
const v = cronValueInner.value
|
||||
if (props.hideYear || props.hideSecond) return v
|
||||
const vs = v.split(' ')
|
||||
const v = cronValueInner.value;
|
||||
if (props.hideYear || props.hideSecond) return v;
|
||||
const vs = v.split(' ');
|
||||
if (vs.length >= 6) {
|
||||
// 转成 Quartz 的规则
|
||||
vs[5] = convertWeekToQuartz(vs[5])
|
||||
vs[5] = convertWeekToQuartz(vs[5]);
|
||||
}
|
||||
return vs.slice(0, vs.length - 1).join(' ')
|
||||
})
|
||||
const calTriggerList = simpleDebounce(calTriggerListInner, 500)
|
||||
return vs.slice(0, vs.length - 1).join(' ');
|
||||
});
|
||||
const calTriggerList = simpleDebounce(calTriggerListInner, 500);
|
||||
|
||||
watch(() => props.value, (newVal) => {
|
||||
watch(
|
||||
() => props.value,
|
||||
(newVal) => {
|
||||
if (newVal === cronValueInner.value) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
formatValue()
|
||||
})
|
||||
|
||||
formatValue();
|
||||
}
|
||||
);
|
||||
|
||||
watch(cronValueInner, (newValue) => {
|
||||
calTriggerList()
|
||||
emitValue(newValue)
|
||||
assignInput()
|
||||
})
|
||||
calTriggerList();
|
||||
emitValue(newValue);
|
||||
assignInput();
|
||||
});
|
||||
|
||||
// watch(minute, () => {
|
||||
// if (second.value === '*') {
|
||||
|
@ -199,34 +201,34 @@ watch(cronValueInner, (newValue) => {
|
|||
// }
|
||||
// })
|
||||
|
||||
assignInput()
|
||||
formatValue()
|
||||
calTriggerListInner()
|
||||
assignInput();
|
||||
formatValue();
|
||||
calTriggerListInner();
|
||||
|
||||
function assignInput() {
|
||||
inputValues.second = second.value
|
||||
inputValues.minute = minute.value
|
||||
inputValues.hour = hour.value
|
||||
inputValues.day = day.value
|
||||
inputValues.month = month.value
|
||||
inputValues.week = week.value
|
||||
inputValues.year = year.value
|
||||
inputValues.cron = cronValueInner.value
|
||||
inputValues.second = second.value;
|
||||
inputValues.minute = minute.value;
|
||||
inputValues.hour = hour.value;
|
||||
inputValues.day = day.value;
|
||||
inputValues.month = month.value;
|
||||
inputValues.week = week.value;
|
||||
inputValues.year = year.value;
|
||||
inputValues.cron = cronValueInner.value;
|
||||
}
|
||||
|
||||
function formatValue() {
|
||||
if (!props.value) return
|
||||
const values = props.value.split(' ').filter(item => !!item)
|
||||
if (!values || values.length <= 0) return
|
||||
let i = 0
|
||||
if (!props.hideSecond) second.value = values[i++]
|
||||
if (values.length > i) minute.value = values[i++]
|
||||
if (values.length > i) hour.value = values[i++]
|
||||
if (values.length > i) day.value = values[i++]
|
||||
if (values.length > i) month.value = values[i++]
|
||||
if (values.length > i) week.value = values[i++]
|
||||
if (values.length > i) year.value = values[i]
|
||||
assignInput()
|
||||
if (!props.value) return;
|
||||
const values = props.value.split(' ').filter((item) => !!item);
|
||||
if (!values || values.length <= 0) return;
|
||||
let i = 0;
|
||||
if (!props.hideSecond) second.value = values[i++];
|
||||
if (values.length > i) minute.value = values[i++];
|
||||
if (values.length > i) hour.value = values[i++];
|
||||
if (values.length > i) day.value = values[i++];
|
||||
if (values.length > i) month.value = values[i++];
|
||||
if (values.length > i) week.value = values[i++];
|
||||
if (values.length > i) year.value = values[i];
|
||||
assignInput();
|
||||
}
|
||||
|
||||
// Quartz 的规则:
|
||||
|
@ -234,72 +236,75 @@ function formatValue() {
|
|||
function convertWeekToQuartz(week: string) {
|
||||
let convert = (v: string) => {
|
||||
if (v === '0') {
|
||||
return '1'
|
||||
return '1';
|
||||
}
|
||||
if (v === '1') {
|
||||
return '0'
|
||||
}
|
||||
return (Number.parseInt(v) - 1).toString()
|
||||
return '0';
|
||||
}
|
||||
return (Number.parseInt(v) - 1).toString();
|
||||
};
|
||||
// 匹配示例 1-7 or 1/7
|
||||
let patten1 = /^([0-7])([-/])([0-7])$/
|
||||
let patten1 = /^([0-7])([-/])([0-7])$/;
|
||||
// 匹配示例 1,4,7
|
||||
let patten2 = /^([0-7])(,[0-7])+$/
|
||||
let patten2 = /^([0-7])(,[0-7])+$/;
|
||||
if (/^[0-7]$/.test(week)) {
|
||||
return convert(week)
|
||||
return convert(week);
|
||||
} else if (patten1.test(week)) {
|
||||
return week.replace(patten1, ($0, before, separator, after) => {
|
||||
if (separator === '/') {
|
||||
return convert(before) + separator + after
|
||||
return convert(before) + separator + after;
|
||||
} else {
|
||||
return convert(before) + separator + convert(after)
|
||||
return convert(before) + separator + convert(after);
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if (patten2.test(week)) {
|
||||
return week.split(',').map(v => convert(v)).join(',')
|
||||
}
|
||||
return week
|
||||
.split(',')
|
||||
.map((v) => convert(v))
|
||||
.join(',');
|
||||
}
|
||||
return week;
|
||||
}
|
||||
|
||||
function calTriggerListInner() {
|
||||
// 设置了回调函数
|
||||
if (props.remote) {
|
||||
props.remote(cronValueInner.value, +new Date(), v => {
|
||||
preTimeList.value = v
|
||||
})
|
||||
return
|
||||
props.remote(cronValueInner.value, +new Date(), (v) => {
|
||||
preTimeList.value = v;
|
||||
});
|
||||
return;
|
||||
}
|
||||
const format = 'yyyy-MM-dd hh:mm:ss'
|
||||
const format = 'yyyy-MM-dd hh:mm:ss';
|
||||
const options = {
|
||||
currentDate: dateFormat(new Date(), format),
|
||||
}
|
||||
const iter = CronParser.parseExpression(cronValueNoYear.value, options)
|
||||
const result: string[] = []
|
||||
};
|
||||
const iter = CronParser.parseExpression(cronValueNoYear.value, options);
|
||||
const result: string[] = [];
|
||||
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() {
|
||||
second.value = inputValues.second
|
||||
minute.value = inputValues.minute
|
||||
hour.value = inputValues.hour
|
||||
day.value = inputValues.day
|
||||
month.value = inputValues.month
|
||||
week.value = inputValues.week
|
||||
year.value = inputValues.year
|
||||
second.value = inputValues.second;
|
||||
minute.value = inputValues.minute;
|
||||
hour.value = inputValues.hour;
|
||||
day.value = inputValues.day;
|
||||
month.value = inputValues.month;
|
||||
week.value = inputValues.week;
|
||||
year.value = inputValues.year;
|
||||
}
|
||||
|
||||
function onInputCronBlur(event) {
|
||||
emitValue(event.target.value)
|
||||
emitValue(event.target.value);
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
@import "easy.cron.inner";
|
||||
@import 'easy.cron.inner';
|
||||
</style>
|
|
@ -8,56 +8,49 @@
|
|||
</a>
|
||||
</template>
|
||||
</a-input>
|
||||
<EasyCronModal
|
||||
@register="registerModal"
|
||||
v-model:value="editCronValue"
|
||||
:exeStartTime="exeStartTime"
|
||||
:hideYear="hideYear"
|
||||
:remote="remote"
|
||||
:hideSecond="hideSecond"/>
|
||||
<EasyCronModal @register="registerModal" v-model:value="editCronValue" :exeStartTime="exeStartTime" :hideYear="hideYear" :remote="remote" :hideSecond="hideSecond" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { useDesign } from '/@/hooks/web/useDesign'
|
||||
import { useModal } from '/@/components/Modal'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import Icon from '/@/components/Icon/src/Icon.vue'
|
||||
import EasyCronModal from './EasyCronModal.vue'
|
||||
import { cronEmits, cronProps } from './easy.cron.data'
|
||||
import { ref, watch } from 'vue';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import Icon from '/@/components/Icon/src/Icon.vue';
|
||||
import EasyCronModal from './EasyCronModal.vue';
|
||||
import { cronEmits, cronProps } from './easy.cron.data';
|
||||
|
||||
const { prefixCls } = useDesign('easy-cron-input')
|
||||
const emit = defineEmits([...cronEmits])
|
||||
const { prefixCls } = useDesign('easy-cron-input');
|
||||
const emit = defineEmits([...cronEmits]);
|
||||
const props = defineProps({
|
||||
...cronProps,
|
||||
placeholder: propTypes.string.def('请输入cron表达式'),
|
||||
exeStartTime: propTypes.oneOfType([
|
||||
propTypes.number,
|
||||
propTypes.string,
|
||||
propTypes.object,
|
||||
]).def(0),
|
||||
})
|
||||
const [registerModal, { openModal }] = useModal()
|
||||
const editCronValue = ref(props.value)
|
||||
exeStartTime: propTypes.oneOfType([propTypes.number, propTypes.string, propTypes.object]).def(0),
|
||||
});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const editCronValue = ref(props.value);
|
||||
|
||||
watch(() => props.value, (newVal) => {
|
||||
watch(
|
||||
() => props.value,
|
||||
(newVal) => {
|
||||
if (newVal !== editCronValue.value) {
|
||||
editCronValue.value = newVal
|
||||
editCronValue.value = newVal;
|
||||
}
|
||||
})
|
||||
}
|
||||
);
|
||||
watch(editCronValue, (newVal) => {
|
||||
emit('change', newVal)
|
||||
emit('update:value', newVal)
|
||||
})
|
||||
emit('change', newVal);
|
||||
emit('update:value', newVal);
|
||||
});
|
||||
|
||||
function showConfigModal() {
|
||||
if (!props.disabled) {
|
||||
openModal()
|
||||
openModal();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import "easy.cron.input";
|
||||
@import 'easy.cron.input';
|
||||
</style>
|
||||
|
|
|
@ -5,24 +5,24 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal'
|
||||
import EasyCron from './EasyCronInner.vue'
|
||||
import { defineComponent } from 'vue';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import EasyCron from './EasyCronInner.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EasyCronModal',
|
||||
inheritAttrs: false,
|
||||
components: { BasicModal, EasyCron },
|
||||
setup() {
|
||||
const attrs = useAttrs()
|
||||
const [registerModal, { closeModal }] = useModalInner()
|
||||
const attrs = useAttrs();
|
||||
const [registerModal, { closeModal }] = useModalInner();
|
||||
|
||||
function onOk() {
|
||||
closeModal()
|
||||
closeModal();
|
||||
}
|
||||
|
||||
return { attrs, registerModal, onOk }
|
||||
return { attrs, registerModal, onOk };
|
||||
},
|
||||
})
|
||||
});
|
||||
</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 = {
|
||||
value: propTypes.string.def(''),
|
||||
disabled: propTypes.bool.def(false),
|
||||
hideSecond: propTypes.bool.def(false),
|
||||
hideYear: propTypes.bool.def(false),
|
||||
remote: propTypes.func,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
}
|
||||
|
||||
.tip-info {
|
||||
color: #999
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// 原开源项目地址:https://gitee.com/toktok/easy-cron
|
||||
|
||||
export { default as JEasyCron } from './EasyCronInput.vue'
|
||||
export { default as JEasyCronInner } from './EasyCronInner.vue'
|
||||
export { default as JEasyCronModal } from './EasyCronModal.vue'
|
||||
export { default as JCronValidator } from './validator'
|
||||
export { default as JEasyCron } from './EasyCronInput.vue';
|
||||
export { default as JEasyCronInner } from './EasyCronInner.vue';
|
||||
export { default as JEasyCronModal } from './EasyCronModal.vue';
|
||||
export { default as JCronValidator } from './validator';
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, watch } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { TypeEnum, useTabEmits, useTabProps, useTabSetup } from './useTabMixin'
|
||||
import { computed, defineComponent, watch } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { TypeEnum, useTabEmits, useTabProps, useTabSetup } from './useTabMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DayUI',
|
||||
|
@ -64,8 +64,8 @@ export default defineComponent({
|
|||
emits: useTabEmits(),
|
||||
setup(props, context) {
|
||||
const disabledChoice = computed(() => {
|
||||
return (props.week && props.week !== '?') || props.disabled
|
||||
})
|
||||
return (props.week && props.week !== '?') || props.disabled;
|
||||
});
|
||||
const setup = useTabSetup(props, context, {
|
||||
defaultValue: '*',
|
||||
valueWork: 1,
|
||||
|
@ -74,17 +74,20 @@ export default defineComponent({
|
|||
valueRange: { start: 1, end: 31 },
|
||||
valueLoop: { start: 1, interval: 1 },
|
||||
disabled: disabledChoice,
|
||||
})
|
||||
});
|
||||
const typeWorkAttrs = computed(() => ({
|
||||
disabled: setup.type.value !== TypeEnum.work || props.disabled || disabledChoice.value,
|
||||
...setup.inputNumberAttrs.value,
|
||||
}))
|
||||
}));
|
||||
|
||||
watch(() => props.week, () => {
|
||||
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value)
|
||||
})
|
||||
watch(
|
||||
() => props.week,
|
||||
() => {
|
||||
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value);
|
||||
}
|
||||
);
|
||||
|
||||
return { ...setup, typeWorkAttrs }
|
||||
return { ...setup, typeWorkAttrs };
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -35,9 +35,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
||||
import { defineComponent } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HourUI',
|
||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
|||
maxValue: 23,
|
||||
valueRange: { start: 0, end: 23 },
|
||||
valueLoop: { start: 0, interval: 1 },
|
||||
})
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -35,9 +35,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
||||
import { defineComponent } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MinuteUI',
|
||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
|||
maxValue: 59,
|
||||
valueRange: { start: 0, end: 59 },
|
||||
valueLoop: { start: 0, interval: 1 },
|
||||
})
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -35,9 +35,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
||||
import { defineComponent } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MonthUI',
|
||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
|||
maxValue: 12,
|
||||
valueRange: { start: 1, end: 12 },
|
||||
valueLoop: { start: 1, interval: 1 },
|
||||
})
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -35,9 +35,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
||||
import { defineComponent } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SecondUI',
|
||||
|
@ -53,7 +53,7 @@ export default defineComponent({
|
|||
maxValue: 59,
|
||||
valueRange: { start: 0, end: 59 },
|
||||
valueLoop: { start: 0, interval: 1 },
|
||||
})
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -35,9 +35,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, watch, defineComponent } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { useTabProps, useTabEmits, useTabSetup, TypeEnum } from './useTabMixin'
|
||||
import { computed, watch, defineComponent } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { useTabProps, useTabEmits, useTabSetup, TypeEnum } from './useTabMixin';
|
||||
|
||||
const WEEK_MAP_EN = {
|
||||
'1': 'SUN',
|
||||
|
@ -47,7 +47,7 @@ const WEEK_MAP_EN = {
|
|||
'5': 'THU',
|
||||
'6': 'FRI',
|
||||
'7': 'SAT',
|
||||
}
|
||||
};
|
||||
|
||||
const WEEK_MAP_CN = {
|
||||
'1': '周日',
|
||||
|
@ -57,7 +57,7 @@ const WEEK_MAP_CN = {
|
|||
'5': '周四',
|
||||
'6': '周五',
|
||||
'7': '周六',
|
||||
}
|
||||
};
|
||||
|
||||
export default defineComponent({
|
||||
name: 'WeekUI',
|
||||
|
@ -71,8 +71,8 @@ export default defineComponent({
|
|||
emits: useTabEmits(),
|
||||
setup(props, context) {
|
||||
const disabledChoice = computed(() => {
|
||||
return (props.day && props.day !== '?') || props.disabled
|
||||
})
|
||||
return (props.day && props.day !== '?') || props.disabled;
|
||||
});
|
||||
const setup = useTabSetup(props, context, {
|
||||
defaultType: TypeEnum.unset,
|
||||
defaultValue: '?',
|
||||
|
@ -82,41 +82,44 @@ export default defineComponent({
|
|||
valueRange: { start: 1, end: 7 },
|
||||
valueLoop: { start: 2, interval: 1 },
|
||||
disabled: disabledChoice,
|
||||
})
|
||||
});
|
||||
const weekOptions = computed(() => {
|
||||
let options: { label: string, value: number }[] = []
|
||||
let options: { label: string; value: number }[] = [];
|
||||
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({
|
||||
value: Number.parseInt(weekKey),
|
||||
label: weekName,
|
||||
})
|
||||
});
|
||||
}
|
||||
return options
|
||||
})
|
||||
return options;
|
||||
});
|
||||
|
||||
const typeRangeSelectAttrs = computed(() => ({
|
||||
class: ['w80'],
|
||||
disabled: setup.typeRangeAttrs.value.disabled,
|
||||
}))
|
||||
}));
|
||||
|
||||
const typeLoopSelectAttrs = computed(() => ({
|
||||
class: ['w80'],
|
||||
disabled: setup.typeLoopAttrs.value.disabled,
|
||||
}))
|
||||
}));
|
||||
|
||||
watch(() => props.day, () => {
|
||||
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value)
|
||||
})
|
||||
watch(
|
||||
() => props.day,
|
||||
() => {
|
||||
setup.updateValue(disabledChoice.value ? '?' : setup.computeValue.value);
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
...setup,
|
||||
weekOptions,
|
||||
typeLoopSelectAttrs,
|
||||
typeRangeSelectAttrs,
|
||||
WEEK_MAP_CN, WEEK_MAP_EN,
|
||||
}
|
||||
WEEK_MAP_CN,
|
||||
WEEK_MAP_EN,
|
||||
};
|
||||
},
|
||||
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -25,9 +25,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { InputNumber } from 'ant-design-vue'
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin'
|
||||
import { defineComponent } from 'vue';
|
||||
import { InputNumber } from 'ant-design-vue';
|
||||
import { useTabProps, useTabEmits, useTabSetup } from './useTabMixin';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'YearUI',
|
||||
|
@ -37,13 +37,13 @@ export default defineComponent({
|
|||
}),
|
||||
emits: useTabEmits(),
|
||||
setup(props, context) {
|
||||
const nowYear = (new Date()).getFullYear()
|
||||
const nowYear = new Date().getFullYear();
|
||||
return useTabSetup(props, context, {
|
||||
defaultValue: '*',
|
||||
minValue: 0,
|
||||
valueRange: { start: nowYear, end: nowYear + 100 },
|
||||
valueLoop: { start: nowYear, interval: 1 },
|
||||
})
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -1,6 +1,6 @@
|
|||
// 主要用于日和星期的互斥使用
|
||||
import { computed, inject, reactive, ref, unref, watch } from 'vue'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { computed, inject, reactive, ref, unref, watch } from 'vue';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
|
||||
export enum TypeEnum {
|
||||
unset = 'UNSET',
|
||||
|
@ -14,91 +14,95 @@ export enum TypeEnum {
|
|||
|
||||
// use 公共 props
|
||||
export function useTabProps(options) {
|
||||
const defaultValue = options?.defaultValue ?? '?'
|
||||
const defaultValue = options?.defaultValue ?? '?';
|
||||
return {
|
||||
value: propTypes.string.def(defaultValue),
|
||||
disabled: propTypes.bool.def(false),
|
||||
...options?.props,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// use 公共 emits
|
||||
export function useTabEmits() {
|
||||
return ['change', 'update:value']
|
||||
return ['change', 'update:value'];
|
||||
}
|
||||
|
||||
// use 公共 setup
|
||||
export function useTabSetup(props, context, options) {
|
||||
const { emit } = context
|
||||
const prefixCls = inject('prefixCls')
|
||||
const defaultValue = ref(options?.defaultValue ?? '?')
|
||||
const { emit } = context;
|
||||
const prefixCls = inject('prefixCls');
|
||||
const defaultValue = ref(options?.defaultValue ?? '?');
|
||||
// 类型
|
||||
const type = ref(options.defaultType ?? TypeEnum.every)
|
||||
const valueList = ref<any[]>([])
|
||||
const type = ref(options.defaultType ?? TypeEnum.every);
|
||||
const valueList = ref<any[]>([]);
|
||||
// 对于不同的类型,所定义的值也有所不同
|
||||
const valueRange = reactive(options.valueRange)
|
||||
const valueLoop = reactive(options.valueLoop)
|
||||
const valueWeek = reactive(options.valueWeek)
|
||||
const valueWork = ref(options.valueWork)
|
||||
const maxValue = ref(options.maxValue)
|
||||
const minValue = ref(options.minValue)
|
||||
const valueRange = reactive(options.valueRange);
|
||||
const valueLoop = reactive(options.valueLoop);
|
||||
const valueWeek = reactive(options.valueWeek);
|
||||
const valueWork = ref(options.valueWork);
|
||||
const maxValue = ref(options.maxValue);
|
||||
const minValue = ref(options.minValue);
|
||||
|
||||
// 根据不同的类型计算出的value
|
||||
const computeValue = computed(() => {
|
||||
let valueArray: any[] = []
|
||||
let valueArray: any[] = [];
|
||||
switch (type.value) {
|
||||
case TypeEnum.unset:
|
||||
valueArray.push('?')
|
||||
break
|
||||
valueArray.push('?');
|
||||
break;
|
||||
case TypeEnum.every:
|
||||
valueArray.push('*')
|
||||
break
|
||||
valueArray.push('*');
|
||||
break;
|
||||
case TypeEnum.range:
|
||||
valueArray.push(`${valueRange.start}-${valueRange.end}`)
|
||||
break
|
||||
valueArray.push(`${valueRange.start}-${valueRange.end}`);
|
||||
break;
|
||||
case TypeEnum.loop:
|
||||
valueArray.push(`${valueLoop.start}/${valueLoop.interval}`)
|
||||
break
|
||||
valueArray.push(`${valueLoop.start}/${valueLoop.interval}`);
|
||||
break;
|
||||
case TypeEnum.work:
|
||||
valueArray.push(`${valueWork.value}W`)
|
||||
break
|
||||
valueArray.push(`${valueWork.value}W`);
|
||||
break;
|
||||
case TypeEnum.last:
|
||||
valueArray.push('L')
|
||||
break
|
||||
valueArray.push('L');
|
||||
break;
|
||||
case TypeEnum.specify:
|
||||
if (valueList.value.length === 0) {
|
||||
valueList.value.push(minValue.value)
|
||||
valueList.value.push(minValue.value);
|
||||
}
|
||||
valueArray.push(valueList.value.join(','))
|
||||
break
|
||||
valueArray.push(valueList.value.join(','));
|
||||
break;
|
||||
default:
|
||||
valueArray.push(defaultValue.value)
|
||||
break
|
||||
valueArray.push(defaultValue.value);
|
||||
break;
|
||||
}
|
||||
return valueArray.length > 0 ? valueArray.join('') : defaultValue.value
|
||||
})
|
||||
return valueArray.length > 0 ? valueArray.join('') : defaultValue.value;
|
||||
});
|
||||
// 指定值范围区间,介于最小值和最大值之间
|
||||
const specifyRange = computed(() => {
|
||||
let range: number[] = []
|
||||
let range: number[] = [];
|
||||
if (maxValue.value != null) {
|
||||
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) {
|
||||
parseValue(val)
|
||||
parseValue(val);
|
||||
}
|
||||
}, { immediate: true })
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(computeValue, (v) => updateValue(v))
|
||||
watch(computeValue, (v) => updateValue(v));
|
||||
|
||||
function updateValue(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,71 +111,72 @@ export function useTabSetup(props, context, options) {
|
|||
*/
|
||||
function parseValue(value) {
|
||||
if (value === computeValue.value) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!value || value === defaultValue.value) {
|
||||
type.value = TypeEnum.every
|
||||
type.value = TypeEnum.every;
|
||||
} else if (value.indexOf('?') >= 0) {
|
||||
type.value = TypeEnum.unset
|
||||
type.value = TypeEnum.unset;
|
||||
} else if (value.indexOf('-') >= 0) {
|
||||
type.value = TypeEnum.range
|
||||
const values = value.split('-')
|
||||
type.value = TypeEnum.range;
|
||||
const values = value.split('-');
|
||||
if (values.length >= 2) {
|
||||
valueRange.start = parseInt(values[0])
|
||||
valueRange.end = parseInt(values[1])
|
||||
valueRange.start = parseInt(values[0]);
|
||||
valueRange.end = parseInt(values[1]);
|
||||
}
|
||||
} else if (value.indexOf('/') >= 0) {
|
||||
type.value = TypeEnum.loop
|
||||
const values = value.split('/')
|
||||
type.value = TypeEnum.loop;
|
||||
const values = value.split('/');
|
||||
if (values.length >= 2) {
|
||||
valueLoop.start = value[0] === '*' ? 0 : parseInt(values[0])
|
||||
valueLoop.interval = parseInt(values[1])
|
||||
valueLoop.start = value[0] === '*' ? 0 : parseInt(values[0]);
|
||||
valueLoop.interval = parseInt(values[1]);
|
||||
}
|
||||
} else if (value.indexOf('W') >= 0) {
|
||||
type.value = TypeEnum.work
|
||||
const values = value.split('W')
|
||||
type.value = TypeEnum.work;
|
||||
const values = value.split('W');
|
||||
if (!values[0] && !isNaN(values[0])) {
|
||||
valueWork.value = parseInt(values[0])
|
||||
valueWork.value = parseInt(values[0]);
|
||||
}
|
||||
} else if (value.indexOf('L') >= 0) {
|
||||
type.value = TypeEnum.last
|
||||
type.value = TypeEnum.last;
|
||||
} else if (value.indexOf(',') >= 0 || !isNaN(value)) {
|
||||
type.value = TypeEnum.specify
|
||||
valueList.value = value.split(',').map(item => parseInt(item))
|
||||
type.value = TypeEnum.specify;
|
||||
valueList.value = value.split(',').map((item) => parseInt(item));
|
||||
} else {
|
||||
type.value = TypeEnum.every
|
||||
type.value = TypeEnum.every;
|
||||
}
|
||||
} catch (e) {
|
||||
type.value = TypeEnum.every
|
||||
type.value = TypeEnum.every;
|
||||
}
|
||||
}
|
||||
|
||||
const beforeRadioAttrs = computed(() => ({
|
||||
class: ['choice'],
|
||||
disabled: props.disabled || unref(options.disabled),
|
||||
}))
|
||||
}));
|
||||
const inputNumberAttrs = computed(() => ({
|
||||
class: ['w60'],
|
||||
max: maxValue.value,
|
||||
min: minValue.value,
|
||||
precision: 0,
|
||||
}))
|
||||
}));
|
||||
const typeRangeAttrs = computed(() => ({
|
||||
disabled: type.value !== TypeEnum.range || props.disabled || unref(options.disabled),
|
||||
...inputNumberAttrs.value,
|
||||
}))
|
||||
}));
|
||||
const typeLoopAttrs = computed(() => ({
|
||||
disabled: type.value !== TypeEnum.loop || props.disabled || unref(options.disabled),
|
||||
...inputNumberAttrs.value,
|
||||
}))
|
||||
}));
|
||||
const typeSpecifyAttrs = computed(() => ({
|
||||
disabled: type.value !== TypeEnum.specify || props.disabled || unref(options.disabled),
|
||||
class: ['list-check-item'],
|
||||
}))
|
||||
}));
|
||||
|
||||
return {
|
||||
type, TypeEnum,
|
||||
type,
|
||||
TypeEnum,
|
||||
prefixCls,
|
||||
defaultValue,
|
||||
valueRange,
|
||||
|
@ -190,5 +195,5 @@ export function useTabSetup(props, context, options) {
|
|||
typeRangeAttrs,
|
||||
typeLoopAttrs,
|
||||
typeSpecifyAttrs,
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,48 +1,48 @@
|
|||
import CronParser from 'cron-parser'
|
||||
import type { ValidatorRule } from 'ant-design-vue/lib/form/interface'
|
||||
import CronParser from 'cron-parser';
|
||||
import type { ValidatorRule } from 'ant-design-vue/lib/form/interface';
|
||||
|
||||
const cronRule: ValidatorRule = {
|
||||
validator({}, 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) {
|
||||
return Promise.reject('Cron表达式最多7项!')
|
||||
return Promise.reject('Cron表达式最多7项!');
|
||||
}
|
||||
// 检查第7项
|
||||
let val: string = value
|
||||
let val: string = value;
|
||||
if (values.length === 7) {
|
||||
const year = values[6]
|
||||
const year = values[6];
|
||||
if (year !== '*' && year !== '?') {
|
||||
let yearValues: string[] = []
|
||||
let yearValues: string[] = [];
|
||||
if (year.indexOf('-') >= 0) {
|
||||
yearValues = year.split('-')
|
||||
yearValues = year.split('-');
|
||||
} else if (year.indexOf('/')) {
|
||||
yearValues = year.split('/')
|
||||
yearValues = year.split('/');
|
||||
} else {
|
||||
yearValues = [year]
|
||||
yearValues = [year];
|
||||
}
|
||||
// 判断是否都是数字
|
||||
const checkYear = yearValues.some(item => isNaN(Number(item)))
|
||||
const checkYear = yearValues.some((item) => isNaN(Number(item)));
|
||||
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位 没有年
|
||||
// 5位没有秒、年
|
||||
try {
|
||||
const iter = CronParser.parseExpression(val)
|
||||
iter.next()
|
||||
return Promise.resolve()
|
||||
const iter = CronParser.parseExpression(val);
|
||||
iter.next();
|
||||
return Promise.resolve();
|
||||
} 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>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue'
|
||||
import { computed, defineComponent } from 'vue';
|
||||
|
||||
import { Tinymce } from '/@/components/Tinymce'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { Tinymce } from '/@/components/Tinymce';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JEditor',
|
||||
|
@ -20,21 +20,20 @@ export default defineComponent({
|
|||
emits: ['change', 'update:value'],
|
||||
setup(props, { emit, attrs }) {
|
||||
// 合并 props 和 attrs
|
||||
const bindProps = computed(() => Object.assign({}, props, attrs))
|
||||
const bindProps = computed(() => Object.assign({}, props, attrs));
|
||||
|
||||
// value change 事件
|
||||
function onChange(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
|
||||
return {
|
||||
bindProps,
|
||||
onChange,
|
||||
}
|
||||
};
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
|
|
@ -8,13 +8,12 @@
|
|||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
|
||||
const props = defineProps({
|
||||
value: propTypes.string.def(''),
|
||||
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>
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
:beforeUpload="beforeUpload"
|
||||
:disabled="disabled"
|
||||
@change="handleChange"
|
||||
@preview="handlePreview">
|
||||
@preview="handlePreview"
|
||||
>
|
||||
<div v-if="uploadVisible">
|
||||
<div v-if="listType == 'picture-card'">
|
||||
<LoadingOutlined v-if="loading" />
|
||||
|
@ -46,10 +47,7 @@
|
|||
inheritAttrs: false,
|
||||
props: {
|
||||
//绑定值
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array,
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
//按钮文本
|
||||
listType: {
|
||||
type: String,
|
||||
|
@ -114,7 +112,6 @@
|
|||
return props['fileMax'] > 1;
|
||||
});
|
||||
|
||||
|
||||
//计算是否可以继续上传
|
||||
const uploadVisible = computed(() => {
|
||||
return uploadFileList.value.length < props['fileMax'];
|
||||
|
@ -132,7 +129,7 @@
|
|||
if (initTag.value == true) {
|
||||
initFileList(val);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -194,7 +191,7 @@
|
|||
}
|
||||
emitData.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>
|
||||
<!--是否校验-->
|
||||
<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">
|
||||
<a-switch :checked="validateStatus == 1" @change="handleChangeValidateStatus" checked-children="是" un-checked-children="否" size="small" />
|
||||
</span>
|
||||
|
@ -38,19 +38,19 @@
|
|||
url: {
|
||||
type: String,
|
||||
default: '',
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
biz: {
|
||||
type: String,
|
||||
default: '',
|
||||
required: false
|
||||
required: false,
|
||||
},
|
||||
//是否online导入
|
||||
online: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: false
|
||||
}
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
emits: ['ok', 'register'],
|
||||
setup(props, { emit, refs }) {
|
||||
|
@ -79,7 +79,7 @@
|
|||
|
||||
//关闭方法
|
||||
function handleClose() {
|
||||
closeModal() && reset()
|
||||
closeModal() && reset();
|
||||
}
|
||||
|
||||
//校验状态切换
|
||||
|
@ -92,7 +92,7 @@
|
|||
const index = unref(fileList).indexOf(file);
|
||||
const newFileList = unref(fileList).slice();
|
||||
newFileList.splice(index, 1);
|
||||
fileList.value = newFileList
|
||||
fileList.value = newFileList;
|
||||
}
|
||||
|
||||
//上传前处理
|
||||
|
@ -121,23 +121,23 @@
|
|||
|
||||
//TODO 请求怎样处理的问题
|
||||
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) => {
|
||||
uploading.value = false;
|
||||
if (res.success) {
|
||||
if (res.code == 201) {
|
||||
errorTip(res.message, res.result)
|
||||
errorTip(res.message, res.result);
|
||||
} else {
|
||||
createMessage.success(res.message)
|
||||
createMessage.success(res.message);
|
||||
}
|
||||
handleClose();
|
||||
reset();
|
||||
emit('ok')
|
||||
emit('ok');
|
||||
} else {
|
||||
createMessage.warning(res.message)
|
||||
createMessage.warning(res.message);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
//错误信息提示
|
||||
|
@ -149,8 +149,8 @@
|
|||
content: `<div>
|
||||
<span>${tipMessage}</span><br/>
|
||||
<span>具体详情请<a href = ${href} target="_blank"> 点击下载 </a> </span>
|
||||
</div>`
|
||||
})
|
||||
</div>`,
|
||||
});
|
||||
}
|
||||
|
||||
//重置
|
||||
|
@ -158,7 +158,7 @@
|
|||
fileList.value = [];
|
||||
uploading.value = false;
|
||||
foreignKeys.value = arg;
|
||||
validateStatus.value = 0
|
||||
validateStatus.value = 0;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -45,13 +45,13 @@
|
|||
*/
|
||||
function initVal() {
|
||||
if (!props.value) {
|
||||
showText.value = ''
|
||||
showText.value = '';
|
||||
} else {
|
||||
let text = props.value;
|
||||
switch (props.type) {
|
||||
case JInputTypeEnum.JINPUT_QUERY_LIKE:
|
||||
//修复路由传参的值传送到jinput框被前后各截取了一位 #1336
|
||||
if (text.indexOf("*") != -1) {
|
||||
if (text.indexOf('*') != -1) {
|
||||
text = text.substring(1, text.length - 1);
|
||||
}
|
||||
break;
|
||||
|
@ -66,7 +66,7 @@
|
|||
break;
|
||||
default:
|
||||
}
|
||||
showText.value = text
|
||||
showText.value = text;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,25 +76,25 @@
|
|||
function backValue(e) {
|
||||
let text = e?.target?.value ?? '';
|
||||
if (text && !!props.trim) {
|
||||
text = text.trim()
|
||||
text = text.trim();
|
||||
}
|
||||
switch (props.type) {
|
||||
case JInputTypeEnum.JINPUT_QUERY_LIKE:
|
||||
text = "*" + text + "*";
|
||||
text = '*' + text + '*';
|
||||
break;
|
||||
case JInputTypeEnum.JINPUT_QUERY_NE:
|
||||
text = "!" + text;
|
||||
text = '!' + text;
|
||||
break;
|
||||
case JInputTypeEnum.JINPUT_QUERY_GE:
|
||||
text = ">=" + text;
|
||||
text = '>=' + text;
|
||||
break;
|
||||
case JInputTypeEnum.JINPUT_QUERY_LE:
|
||||
text = "<=" + text;
|
||||
text = '<=' + text;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
emit("change", text)
|
||||
emit("update:value", text)
|
||||
emit('change', text);
|
||||
emit('update:value', text);
|
||||
}
|
||||
|
||||
return { showText, attrs, getBindValue, backValue };
|
||||
|
@ -102,6 +102,4 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<template>
|
||||
<a-popover
|
||||
trigger="contextmenu"
|
||||
v-model:visible="visible"
|
||||
:overlayClassName="`${prefixCls}-popover`"
|
||||
:getPopupContainer="getPopupContainer"
|
||||
:placement="position">
|
||||
<a-popover trigger="contextmenu" v-model:visible="visible" :overlayClassName="`${prefixCls}-popover`" :getPopupContainer="getPopupContainer" :placement="position">
|
||||
<template #title>
|
||||
<span>{{ title }}</span>
|
||||
<span style="float: right" title="关闭">
|
||||
|
@ -12,20 +7,9 @@
|
|||
</span>
|
||||
</template>
|
||||
<template #content>
|
||||
<a-textarea
|
||||
ref="textareaRef"
|
||||
:value="innerValue"
|
||||
:disabled="disabled"
|
||||
:style="textareaStyle"
|
||||
v-bind="attrs"
|
||||
@input="onInputChange"/>
|
||||
<a-textarea ref="textareaRef" :value="innerValue" :disabled="disabled" :style="textareaStyle" v-bind="attrs" @input="onInputChange" />
|
||||
</template>
|
||||
<a-input
|
||||
:class="`${prefixCls}-input`"
|
||||
:value="innerValue"
|
||||
:disabled="disabled"
|
||||
v-bind="attrs"
|
||||
@change="onInputChange">
|
||||
<a-input :class="`${prefixCls}-input`" :value="innerValue" :disabled="disabled" v-bind="attrs" @change="onInputChange">
|
||||
<template #suffix>
|
||||
<Icon icon="ant-design:fullscreen-outlined" @click.stop="onShowPopup" />
|
||||
</template>
|
||||
|
@ -34,13 +18,13 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import Icon from '/@/components/Icon/src/Icon.vue'
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { useDesign } from '/@/hooks/web/useDesign'
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import Icon from '/@/components/Icon/src/Icon.vue';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
|
||||
const { prefixCls } = useDesign('j-input-popup')
|
||||
const { prefixCls } = useDesign('j-input-popup');
|
||||
const props = defineProps({
|
||||
// v-model:value
|
||||
value: propTypes.string.def(''),
|
||||
|
@ -52,50 +36,53 @@ const props = defineProps({
|
|||
disabled: propTypes.bool.def(false),
|
||||
// 弹出框挂载的元素ID
|
||||
popContainer: propTypes.string.def(''),
|
||||
})
|
||||
const attrs = useAttrs()
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
});
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
|
||||
const visible = ref<boolean>(false)
|
||||
const innerValue = ref<string>('')
|
||||
const visible = ref<boolean>(false);
|
||||
const innerValue = ref<string>('');
|
||||
// textarea ref对象
|
||||
const textareaRef = ref()
|
||||
const textareaRef = ref();
|
||||
// textarea 样式
|
||||
const textareaStyle = computed(() => ({
|
||||
height: `${props.height}px`,
|
||||
width: `${props.width}px`,
|
||||
}))
|
||||
}));
|
||||
|
||||
watch(() => props.value, (value) => {
|
||||
watch(
|
||||
() => props.value,
|
||||
(value) => {
|
||||
if (value && value.length > 0) {
|
||||
innerValue.value = value
|
||||
innerValue.value = value;
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
function onInputChange(event) {
|
||||
innerValue.value = event.target.value
|
||||
emitValue(innerValue.value)
|
||||
innerValue.value = event.target.value;
|
||||
emitValue(innerValue.value);
|
||||
}
|
||||
|
||||
async function onShowPopup() {
|
||||
visible.value = true
|
||||
await nextTick()
|
||||
textareaRef.value?.focus()
|
||||
visible.value = true;
|
||||
await nextTick();
|
||||
textareaRef.value?.focus();
|
||||
}
|
||||
|
||||
// 获取弹出框挂载的元素
|
||||
function getPopupContainer(node) {
|
||||
if (!props.popContainer) {
|
||||
return node.parentNode
|
||||
return node.parentNode;
|
||||
} else {
|
||||
return document.getElementById(props.popContainer)
|
||||
return document.getElementById(props.popContainer);
|
||||
}
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, watch } from 'vue'
|
||||
import { MarkDown } from '/@/components/Markdown'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { computed, defineComponent, watch } from 'vue';
|
||||
import { MarkDown } from '/@/components/Markdown';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JMarkdownEditor',
|
||||
|
@ -19,25 +19,29 @@ export default defineComponent({
|
|||
emits: ['change', 'update:value'],
|
||||
setup(props, { emit, attrs }) {
|
||||
// markdown 组件实例
|
||||
let mdRef: any = null
|
||||
let mdRef: any = null;
|
||||
// vditor 组件实例
|
||||
let vditorRef: any = null
|
||||
let vditorRef: any = null;
|
||||
// 合并 props 和 attrs
|
||||
const bindProps = computed(() => Object.assign({}, props, attrs))
|
||||
const bindProps = computed(() => Object.assign({}, props, attrs));
|
||||
|
||||
// 相当于 onMounted
|
||||
function onGetVditor(instance) {
|
||||
mdRef = instance
|
||||
vditorRef = mdRef.getVditor()
|
||||
mdRef = instance;
|
||||
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 事件
|
||||
function onChange(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -45,10 +49,9 @@ export default defineComponent({
|
|||
|
||||
onChange,
|
||||
onGetVditor,
|
||||
}
|
||||
};
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
const SELECT_OPTIONS_URL = '/online/cgform/api/querySelectOptions';
|
||||
|
||||
export default defineComponent({
|
||||
name: "JOnlineSelectCascade",
|
||||
name: 'JOnlineSelectCascade',
|
||||
props: {
|
||||
table: { type: String, default: '' },
|
||||
txt: { type: String, default: '' },
|
||||
|
@ -32,59 +32,69 @@
|
|||
},
|
||||
emits: ['change', 'next'],
|
||||
setup(props, { emit }) {
|
||||
const { createMessage: $message } = useMessage()
|
||||
const { createMessage: $message } = useMessage();
|
||||
// 选中值
|
||||
const selectedValue = ref<any>('');
|
||||
// 选项数组
|
||||
const dictOptions = ref<any[]>([])
|
||||
const optionsLoad = ref(true)
|
||||
const dictOptions = ref<any[]>([]);
|
||||
const optionsLoad = ref(true);
|
||||
// 选项改变事件
|
||||
function handleChange(value) {
|
||||
console.log('handleChange', value)
|
||||
console.log('handleChange', value);
|
||||
// 这个value是 存储的值 实际还需要获取id值
|
||||
let temp = value || ''
|
||||
emit('change', temp)
|
||||
valueChangeThenEmitNext(temp)
|
||||
let temp = value || '';
|
||||
emit('change', temp);
|
||||
valueChangeThenEmitNext(temp);
|
||||
}
|
||||
|
||||
// 第一个节点 选项加载走condition
|
||||
watch(()=>props.condition, (val)=>{
|
||||
watch(
|
||||
() => props.condition,
|
||||
(val) => {
|
||||
optionsLoad.value = true;
|
||||
if (val) {
|
||||
loadOptions();
|
||||
}
|
||||
}, {immediate:true});
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 被联动节点 选项加载走pidValue
|
||||
watch(()=>props.pidValue, (val)=>{
|
||||
watch(
|
||||
() => props.pidValue,
|
||||
(val) => {
|
||||
if (val === '-1') {
|
||||
dictOptions.value = []
|
||||
dictOptions.value = [];
|
||||
} else {
|
||||
loadOptions();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// 值回显
|
||||
watch(()=>props.value, (newVal, oldVal)=>{
|
||||
console.log('值改变事件', newVal, oldVal)
|
||||
watch(
|
||||
() => props.value,
|
||||
(newVal, oldVal) => {
|
||||
console.log('值改变事件', newVal, oldVal);
|
||||
if (!newVal) {
|
||||
// value不存在的时候--
|
||||
selectedValue.value = []
|
||||
selectedValue.value = [];
|
||||
if (oldVal) {
|
||||
// 如果oldVal存在, 需要往上抛事件
|
||||
emit('change', '')
|
||||
emit('next', '-1')
|
||||
emit('change', '');
|
||||
emit('next', '-1');
|
||||
}
|
||||
} else {
|
||||
// value存在的时候
|
||||
selectedValue.value = newVal
|
||||
selectedValue.value = newVal;
|
||||
}
|
||||
if (newVal && !oldVal) {
|
||||
// 有新值没有旧值 表单第一次加载赋值 需要往外抛一个事件 触发下级options的加载
|
||||
handleFirstValueSetting(newVal)
|
||||
handleFirstValueSetting(newVal);
|
||||
}
|
||||
}, {immediate:true});
|
||||
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
/**
|
||||
* 第一次加载赋值
|
||||
|
@ -92,16 +102,16 @@
|
|||
async function handleFirstValueSetting(value) {
|
||||
if (props.idField === props.store) {
|
||||
// 如果id字段就是存储字段 那么可以不用调用请求
|
||||
emit('next', value)
|
||||
emit('next', value);
|
||||
} else {
|
||||
if (props.origin === true) {
|
||||
// 如果是联动组件的第一个组件,等待options加载完后从options中取值
|
||||
await getSelfOptions()
|
||||
valueChangeThenEmitNext(value)
|
||||
await getSelfOptions();
|
||||
valueChangeThenEmitNext(value);
|
||||
} else {
|
||||
// 如果是联动组件的后续组件,根据选中的value加载一遍数据
|
||||
let arr = await loadValueText();
|
||||
valueChangeThenEmitNext(value, arr)
|
||||
valueChangeThenEmitNext(value, arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,20 +119,20 @@
|
|||
function loadOptions() {
|
||||
let params = getQueryParams();
|
||||
if (props.origin === true) {
|
||||
params['condition'] = props.condition
|
||||
params['condition'] = props.condition;
|
||||
} else {
|
||||
params['pidValue'] = props.pidValue
|
||||
params['pidValue'] = props.pidValue;
|
||||
}
|
||||
console.log("请求参数", params)
|
||||
dictOptions.value = []
|
||||
defHttp.get({ url: SELECT_OPTIONS_URL, params},{ isTransformResponse: false }).then(res=>{
|
||||
console.log('请求参数', params);
|
||||
dictOptions.value = [];
|
||||
defHttp.get({ url: SELECT_OPTIONS_URL, params }, { isTransformResponse: false }).then((res) => {
|
||||
if (res.success) {
|
||||
dictOptions.value = [...res.result]
|
||||
console.log("请求结果", res.result, dictOptions)
|
||||
dictOptions.value = [...res.result];
|
||||
console.log('请求结果', res.result, dictOptions);
|
||||
} else {
|
||||
$message.warning('联动组件数据加载失败,请检查配置!')
|
||||
$message.warning('联动组件数据加载失败,请检查配置!');
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function getQueryParams() {
|
||||
|
@ -131,34 +141,33 @@
|
|||
txt: props.txt,
|
||||
key: props.store,
|
||||
idField: props.idField,
|
||||
pidField: props.pidField
|
||||
}
|
||||
pidField: props.pidField,
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
function loadValueText() {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
if (!props.value) {
|
||||
selectedValue.value = []
|
||||
resolve([])
|
||||
selectedValue.value = [];
|
||||
resolve([]);
|
||||
} else {
|
||||
let params = getQueryParams();
|
||||
if (props.isNumber === true) {
|
||||
params['condition'] = `${props.store} = ${props.value}`
|
||||
params['condition'] = `${props.store} = ${props.value}`;
|
||||
} 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) {
|
||||
resolve(res.result)
|
||||
resolve(res.result);
|
||||
} else {
|
||||
$message.warning('联动组件数据加载失败,请检查配置!')
|
||||
resolve([])
|
||||
$message.warning('联动组件数据加载失败,请检查配置!');
|
||||
resolve([]);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,18 +178,18 @@
|
|||
let index = 0;
|
||||
(function next(index) {
|
||||
if (index > 10) {
|
||||
resolve([])
|
||||
resolve([]);
|
||||
}
|
||||
let arr = dictOptions.value
|
||||
let arr = dictOptions.value;
|
||||
if (arr && arr.length > 0) {
|
||||
resolve(arr)
|
||||
resolve(arr);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
next(index++)
|
||||
}, 300)
|
||||
next(index++);
|
||||
}, 300);
|
||||
}
|
||||
})(index)
|
||||
})
|
||||
})(index);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,12 +198,12 @@
|
|||
function valueChangeThenEmitNext(value, arr: any = []) {
|
||||
if (value && value.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) {
|
||||
let id = selected[0].id
|
||||
emit('next', id)
|
||||
let id = selected[0].id;
|
||||
emit('next', id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,12 +211,10 @@
|
|||
return {
|
||||
selectedValue,
|
||||
dictOptions,
|
||||
handleChange
|
||||
}
|
||||
}
|
||||
})
|
||||
handleChange,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -15,17 +15,17 @@
|
|||
</div>
|
||||
</template>
|
||||
<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 { useModal } from '/@/components/Modal';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JPopup',
|
||||
components: {
|
||||
JPopupOnlReportModal
|
||||
JPopupOnlReportModal,
|
||||
},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
|
@ -42,7 +42,7 @@
|
|||
setFieldsValue: propTypes.func,
|
||||
fieldConfig: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
emits: ['update:value', 'register'],
|
||||
|
@ -57,7 +57,7 @@
|
|||
//表单值
|
||||
let { groupId, code, fieldConfig } = props;
|
||||
//唯一分组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配置项是否正确
|
||||
*/
|
||||
|
@ -100,8 +100,8 @@
|
|||
//匹配popup设置的回调值
|
||||
let values = {};
|
||||
for (let item of fieldConfig) {
|
||||
let val = rows.map(row => row[item.source]).join(',');
|
||||
item.target.split(",").forEach(target => {
|
||||
let val = rows.map((row) => row[item.source]).join(',');
|
||||
item.target.split(',').forEach((target) => {
|
||||
values[target] = val;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,63 +7,63 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
/**
|
||||
* 查询条件用-数值范围查询
|
||||
*/
|
||||
import {ref, watch} from 'vue'
|
||||
import { ref, watch } from 'vue';
|
||||
export default {
|
||||
name: "JRangeNumber",
|
||||
name: 'JRangeNumber',
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
default: ['','']
|
||||
}
|
||||
default: ['', ''],
|
||||
},
|
||||
},
|
||||
emits: ['change'],
|
||||
setup(props, { emit }) {
|
||||
const beginValue = ref('')
|
||||
const endValue = ref('')
|
||||
const beginValue = ref('');
|
||||
const endValue = ref('');
|
||||
|
||||
function handleChangeBegin(e) {
|
||||
beginValue.value = e.target.value
|
||||
emitArray()
|
||||
beginValue.value = e.target.value;
|
||||
emitArray();
|
||||
}
|
||||
|
||||
function handleChangeEnd(e) {
|
||||
endValue.value = e.target.value
|
||||
emitArray()
|
||||
endValue.value = e.target.value;
|
||||
emitArray();
|
||||
}
|
||||
|
||||
function emitArray() {
|
||||
let arr = []
|
||||
let begin = beginValue.value || ''
|
||||
let end = endValue.value || ''
|
||||
arr.push(begin)
|
||||
arr.push(end)
|
||||
emit('change', arr)
|
||||
let arr = [];
|
||||
let begin = beginValue.value || '';
|
||||
let end = endValue.value || '';
|
||||
arr.push(begin);
|
||||
arr.push(end);
|
||||
emit('change', arr);
|
||||
}
|
||||
|
||||
watch(()=>props.value, (val)=>{
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (val.length == 2) {
|
||||
beginValue.value = val[0]
|
||||
endValue.value = val[1]
|
||||
beginValue.value = val[0];
|
||||
endValue.value = val[1];
|
||||
} else {
|
||||
beginValue.value = ''
|
||||
endValue.value = ''
|
||||
beginValue.value = '';
|
||||
endValue.value = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
beginValue,
|
||||
endValue,
|
||||
handleChangeBegin,
|
||||
handleChangeEnd
|
||||
}
|
||||
}
|
||||
}
|
||||
handleChangeEnd,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -29,35 +29,32 @@
|
|||
:placeholder="placeholder"
|
||||
:filterOption="filterOption"
|
||||
:notFoundContent="loading ? undefined : null"
|
||||
@change="handleChange">
|
||||
@change="handleChange"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<a-spin v-if="loading" size="small" />
|
||||
</template>
|
||||
<a-select-option v-for="d in options" :key="d.value" :value="d.value">{{ d.text }}</a-select-option>
|
||||
</a-select>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useDebounceFn } from '@vueuse/core';
|
||||
import { defineComponent, PropType, ref, reactive, watchEffect, computed, unref, watch, onMounted } from 'vue';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import {initDictOptions} from "/@/utils/dict/index"
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { initDictOptions } from '/@/utils/dict/index';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JSearchSelect',
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.number
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||
dict: propTypes.string,
|
||||
dictOptions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
default: () => [],
|
||||
},
|
||||
async: propTypes.bool.def(false),
|
||||
placeholder: propTypes.string,
|
||||
|
@ -65,8 +62,8 @@
|
|||
pageSize: propTypes.number.def(10),
|
||||
getPopupContainer: {
|
||||
type: Function,
|
||||
default: (node) => node.parentNode
|
||||
}
|
||||
default: (node) => node.parentNode,
|
||||
},
|
||||
},
|
||||
emits: ['change', 'update:value'],
|
||||
setup(props, { emit, refs }) {
|
||||
|
@ -91,10 +88,10 @@
|
|||
() => props.value,
|
||||
(val) => {
|
||||
if (val || val === 0) {
|
||||
initSelectValue()
|
||||
initSelectValue();
|
||||
} else {
|
||||
selectedValue.value = []
|
||||
selectedAsyncValue.value = []
|
||||
selectedValue.value = [];
|
||||
selectedAsyncValue.value = [];
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
|
@ -106,7 +103,7 @@
|
|||
() => props.dictOptions,
|
||||
(val) => {
|
||||
if (val && val.length > 0) {
|
||||
options.value = [...val]
|
||||
options.value = [...val];
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
|
@ -116,19 +113,19 @@
|
|||
*/
|
||||
async function loadData(value) {
|
||||
lastLoad.value += 1;
|
||||
const currentLoad = unref(lastLoad)
|
||||
const currentLoad = unref(lastLoad);
|
||||
options.value = [];
|
||||
loading.value = true;
|
||||
// 字典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;
|
||||
if (res && res.length > 0) {
|
||||
if (currentLoad != unref(lastLoad)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
options.value = res
|
||||
options.value = res;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 初始化value
|
||||
|
@ -136,25 +133,25 @@
|
|||
function initSelectValue() {
|
||||
//update-begin-author:taoyan date:2022-4-24 for: 下拉搜索组件每次选中值会触发value的监听事件,触发此方法,但是实际不需要
|
||||
if (loadSelectText.value === false) {
|
||||
loadSelectText.value = true
|
||||
return
|
||||
loadSelectText.value = true;
|
||||
return;
|
||||
}
|
||||
//update-end-author:taoyan date:2022-4-24 for: 下拉搜索组件每次选中值会触发value的监听事件,触发此方法,但是实际不需要
|
||||
let { async, value, dict } = props;
|
||||
if (async) {
|
||||
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) {
|
||||
let obj = {
|
||||
key: value,
|
||||
label: res
|
||||
label: res,
|
||||
};
|
||||
selectedAsyncValue.value = {...obj}
|
||||
selectedAsyncValue.value = { ...obj };
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
} else {
|
||||
selectedValue.value = value.toString()
|
||||
selectedValue.value = value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,35 +163,35 @@
|
|||
if (!async) {
|
||||
//如果字典项集合有数据
|
||||
if (dictOptions && dictOptions.length > 0) {
|
||||
options.value = dictOptions
|
||||
options.value = dictOptions;
|
||||
} else {
|
||||
//根据字典Code, 初始化字典数组
|
||||
let dictStr = ''
|
||||
let dictStr = '';
|
||||
if (dict) {
|
||||
let arr = dict.split(',')
|
||||
let arr = dict.split(',');
|
||||
if (arr[0].indexOf('where') > 0) {
|
||||
let tbInfo = arr[0].split('where')
|
||||
dictStr = tbInfo[0].trim() + ',' + arr[1] + ',' + arr[2] + ',' + encodeURIComponent(tbInfo[1])
|
||||
let tbInfo = arr[0].split('where');
|
||||
dictStr = tbInfo[0].trim() + ',' + arr[1] + ',' + arr[2] + ',' + encodeURIComponent(tbInfo[1]);
|
||||
} else {
|
||||
dictStr = dict
|
||||
dictStr = dict;
|
||||
}
|
||||
//根据字典Code, 初始化字典数组
|
||||
const dictData = await initDictOptions(dictStr);
|
||||
options.value = dictData
|
||||
options.value = dictData;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!dict) {
|
||||
console.error('搜索组件未配置字典项')
|
||||
console.error('搜索组件未配置字典项');
|
||||
} else {
|
||||
//异步一开始也加载一点数据
|
||||
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;
|
||||
if (res && res.length > 0) {
|
||||
options.value = res
|
||||
options.value = res;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +200,7 @@
|
|||
* */
|
||||
function handleChange(value) {
|
||||
selectedValue.value = value;
|
||||
callback()
|
||||
callback();
|
||||
}
|
||||
/**
|
||||
* 异步改变事件
|
||||
|
@ -211,14 +208,14 @@
|
|||
function handleAsyncChange(selectedObj) {
|
||||
if (selectedObj) {
|
||||
selectedAsyncValue.value = selectedObj;
|
||||
selectedValue.value = selectedObj.key
|
||||
selectedValue.value = selectedObj.key;
|
||||
} else {
|
||||
selectedAsyncValue.value = null;
|
||||
selectedValue.value = null;
|
||||
options.value = null;
|
||||
loadData("")
|
||||
loadData('');
|
||||
}
|
||||
callback()
|
||||
callback();
|
||||
}
|
||||
/**
|
||||
*回调方法
|
||||
|
@ -232,18 +229,18 @@
|
|||
* 过滤选中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) {
|
||||
// update-begin-author:taoyan date:20220407 for: getPopupContainer一直有值 导致popContainer的逻辑永远走不进去,把它挪到前面判断
|
||||
if (props.popContainer) {
|
||||
return document.querySelector(props.popContainer)
|
||||
return document.querySelector(props.popContainer);
|
||||
} else {
|
||||
if (typeof props.getPopupContainer === 'function') {
|
||||
return props.getPopupContainer(node)
|
||||
return props.getPopupContainer(node);
|
||||
} else {
|
||||
return node.parentNode
|
||||
return node.parentNode;
|
||||
}
|
||||
}
|
||||
// update-end-author:taoyan date:20220407 for: getPopupContainer一直有值 导致popContainer的逻辑永远走不进去,把它挪到前面判断
|
||||
|
@ -258,12 +255,10 @@
|
|||
getParentContainer,
|
||||
filterOption,
|
||||
handleChange,
|
||||
handleAsyncChange
|
||||
}
|
||||
}
|
||||
})
|
||||
handleAsyncChange,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
const selectOptions = ref<SelectTypes['options']>([]);
|
||||
//下拉框选中值
|
||||
let selectValues = reactive<object>({
|
||||
value: []
|
||||
value: [],
|
||||
});
|
||||
// 是否正在加载回显数据
|
||||
const loadingEcho = ref<boolean>(false)
|
||||
const loadingEcho = ref<boolean>(false);
|
||||
//下发 selectOptions,xxxBiz组件接收
|
||||
provide('selectOptions', selectOptions);
|
||||
//下发 selectValues,xxxBiz组件接收
|
||||
|
@ -59,8 +59,8 @@
|
|||
props.value && initValue();
|
||||
// update-begin-author:taoyan date:20220401 for:调用表单的 resetFields不会清空当前部门信息,界面显示上一次的数据
|
||||
if (props.value === '' || props.value === undefined) {
|
||||
state.value = []
|
||||
selectValues.value = []
|
||||
state.value = [];
|
||||
selectValues.value = [];
|
||||
}
|
||||
// update-end-author:taoyan date:20220401 for:调用表单的 resetFields不会清空当前部门信息,界面显示上一次的数据
|
||||
});
|
||||
|
@ -78,7 +78,7 @@
|
|||
*/
|
||||
watch(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(',');
|
||||
selectValues.value = value.split(',');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +111,7 @@
|
|||
//emitData.value = values.join(",");
|
||||
state.value = values;
|
||||
selectValues.value = values;
|
||||
emit('update:value', values.join(','))
|
||||
emit('update:value', values.join(','));
|
||||
}
|
||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||
return {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { defineComponent, ref, watch, computed } from 'vue'
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { defineComponent, ref, watch, computed } from 'vue';
|
||||
|
||||
// 可以输入的下拉框(此组件暂时没有人用)
|
||||
export default defineComponent({
|
||||
|
@ -15,53 +15,65 @@ export default defineComponent({
|
|||
emits: ['change', 'update:value'],
|
||||
setup(props, { emit, attrs }) {
|
||||
// 内部 options 选项
|
||||
const options = ref<any[]>([])
|
||||
const options = ref<any[]>([]);
|
||||
// 监听外部 options 变化,并覆盖内部 options
|
||||
watch(() => props.options, () => {
|
||||
options.value = [...props.options]
|
||||
}, { deep: true, immediate: true })
|
||||
watch(
|
||||
() => props.options,
|
||||
() => {
|
||||
options.value = [...props.options];
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
// 合并 props 和 attrs
|
||||
const bindProps: any = computed(() => Object.assign({
|
||||
const bindProps: any = computed(() =>
|
||||
Object.assign(
|
||||
{
|
||||
showSearch: true,
|
||||
}, props, attrs, {
|
||||
},
|
||||
props,
|
||||
attrs,
|
||||
{
|
||||
options: options.value,
|
||||
}))
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
function onChange(...args: any[]) {
|
||||
deleteSearchAdd(args[0])
|
||||
emit('change', ...args)
|
||||
emit('update:value', args[0])
|
||||
deleteSearchAdd(args[0]);
|
||||
emit('change', ...args);
|
||||
emit('update:value', args[0]);
|
||||
}
|
||||
|
||||
function onSearch(value) {
|
||||
// 是否找到了对应的项,找不到则添加这一项
|
||||
let foundIt = options.value.findIndex(option => {
|
||||
return option.value.toString() === value.toString()
|
||||
}) !== -1
|
||||
let foundIt =
|
||||
options.value.findIndex((option) => {
|
||||
return option.value.toString() === value.toString();
|
||||
}) !== -1;
|
||||
// !!value :不添加空值
|
||||
if (!foundIt && !!value) {
|
||||
deleteSearchAdd(value)
|
||||
deleteSearchAdd(value);
|
||||
// searchAdd 是否是通过搜索添加的
|
||||
options.value.push({ value: value, searchAdd: true })
|
||||
options.value.push({ value: value, searchAdd: true });
|
||||
//onChange(value,{ value })
|
||||
} else if (foundIt) {
|
||||
onChange(value)
|
||||
onChange(value);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除无用的因搜索(用户输入)而创建的项
|
||||
function deleteSearchAdd(value = '') {
|
||||
let indexes: any[] = []
|
||||
let indexes: any[] = [];
|
||||
options.value.forEach((option, index) => {
|
||||
if (option.searchAdd) {
|
||||
if ((option.value ?? '').toString() !== value.toString()) {
|
||||
indexes.push(index)
|
||||
indexes.push(index);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
// 翻转删除数组中的项
|
||||
for (let index of indexes.reverse()) {
|
||||
options.value.splice(index, 1)
|
||||
options.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,11 +81,9 @@ export default defineComponent({
|
|||
bindProps,
|
||||
onChange,
|
||||
onSearch,
|
||||
}
|
||||
};
|
||||
},
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array,
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择',
|
||||
|
@ -68,7 +65,6 @@
|
|||
const attrs = useAttrs();
|
||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (props.dictCode) {
|
||||
loadDictOptions();
|
||||
|
@ -77,15 +73,16 @@
|
|||
}
|
||||
});
|
||||
|
||||
watch(() => props.value,
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (!val) {
|
||||
arrayValue.value = [];
|
||||
} else {
|
||||
arrayValue.value = props.value.split(props.spliter);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
function onChange(selectedValue) {
|
||||
if (props.triggerChange) {
|
||||
|
@ -106,9 +103,9 @@
|
|||
|
||||
// 根据字典code查询字典项
|
||||
function loadDictOptions() {
|
||||
getDictItems(props.dictCode).then(res => {
|
||||
getDictItems(props.dictCode).then((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);
|
||||
} else {
|
||||
console.error('getDictItems error: : ', res);
|
||||
|
@ -126,6 +123,5 @@
|
|||
getParentContainer,
|
||||
};
|
||||
},
|
||||
})
|
||||
;
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -6,26 +6,24 @@
|
|||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import PositionSelectModal from './modal/PositionSelectModal.vue'
|
||||
import PositionSelectModal from './modal/PositionSelectModal.vue';
|
||||
import JSelectBiz from './base/JSelectBiz.vue';
|
||||
import { defineComponent, ref, reactive, watchEffect, watch, provide, computed, unref } from 'vue';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JSelectPosition',
|
||||
components: {
|
||||
PositionSelectModal, JSelectBiz
|
||||
PositionSelectModal,
|
||||
JSelectBiz,
|
||||
},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
labelKey: {
|
||||
type: String,
|
||||
default: 'name',
|
||||
|
@ -36,8 +34,7 @@
|
|||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
}
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
|
@ -52,10 +49,10 @@
|
|||
//下拉框选中值
|
||||
let selectValues = reactive<object>({
|
||||
value: [],
|
||||
change: false
|
||||
change: false,
|
||||
});
|
||||
// 是否正在加载回显数据
|
||||
const loadingEcho = ref<boolean>(false)
|
||||
const loadingEcho = ref<boolean>(false);
|
||||
//下发 selectOptions,xxxBiz组件接收
|
||||
provide('selectOptions', selectOptions);
|
||||
//下发 selectValues,xxxBiz组件接收
|
||||
|
@ -66,7 +63,6 @@
|
|||
const tag = ref(false);
|
||||
const attrs = useAttrs();
|
||||
|
||||
|
||||
/**
|
||||
* 监听组件值
|
||||
*/
|
||||
|
@ -81,7 +77,7 @@
|
|||
if (selectValues) {
|
||||
state.value = selectValues.value;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 打卡弹出框
|
||||
|
@ -99,8 +95,8 @@
|
|||
function initValue() {
|
||||
let value = props.value ? props.value : [];
|
||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||
state.value = value.split(",");
|
||||
selectValues.value = value.split(",");
|
||||
state.value = value.split(',');
|
||||
selectValues.value = value.split(',');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +104,7 @@
|
|||
* 设置下拉框的值
|
||||
*/
|
||||
function setValue(options, values) {
|
||||
selectOptions.value = options
|
||||
selectOptions.value = options;
|
||||
//emitData.value = values.join(",");
|
||||
state.value = values;
|
||||
selectValues.value = values;
|
||||
|
@ -125,7 +121,7 @@
|
|||
tag,
|
||||
regModal,
|
||||
setValue,
|
||||
handleOpen
|
||||
handleOpen,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,26 +6,24 @@
|
|||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import RoleSelectModal from './modal/RoleSelectModal.vue'
|
||||
import RoleSelectModal from './modal/RoleSelectModal.vue';
|
||||
import JSelectBiz from './base/JSelectBiz.vue';
|
||||
import { defineComponent, ref, unref, reactive, watchEffect, watch, provide } from 'vue';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JSelectRole',
|
||||
components: {
|
||||
RoleSelectModal, JSelectBiz
|
||||
RoleSelectModal,
|
||||
JSelectBiz,
|
||||
},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
labelKey: {
|
||||
type: String,
|
||||
default: 'roleName',
|
||||
|
@ -36,8 +34,7 @@
|
|||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
}
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
|
@ -52,10 +49,10 @@
|
|||
//下拉框选中值
|
||||
let selectValues = reactive<object>({
|
||||
value: [],
|
||||
change: false
|
||||
change: false,
|
||||
});
|
||||
// 是否正在加载回显数据
|
||||
const loadingEcho = ref<boolean>(false)
|
||||
const loadingEcho = ref<boolean>(false);
|
||||
//下发 selectOptions,xxxBiz组件接收
|
||||
provide('selectOptions', selectOptions);
|
||||
//下发 selectValues,xxxBiz组件接收
|
||||
|
@ -66,7 +63,6 @@
|
|||
const tag = ref(false);
|
||||
const attrs = useAttrs();
|
||||
|
||||
|
||||
/**
|
||||
* 监听组件值
|
||||
*/
|
||||
|
@ -81,7 +77,7 @@
|
|||
if (selectValues) {
|
||||
state.value = selectValues.value;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 打卡弹出框
|
||||
|
@ -99,8 +95,8 @@
|
|||
function initValue() {
|
||||
let value = props.value ? props.value : [];
|
||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||
state.value = value.split(",");
|
||||
selectValues.value = value.split(",");
|
||||
state.value = value.split(',');
|
||||
selectValues.value = value.split(',');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +104,7 @@
|
|||
* 设置下拉框的值
|
||||
*/
|
||||
function setValue(options, values) {
|
||||
selectOptions.value = options
|
||||
selectOptions.value = options;
|
||||
//emitData.value = values.join(",");
|
||||
state.value = values;
|
||||
selectValues.value = values;
|
||||
|
@ -124,7 +120,7 @@
|
|||
tag,
|
||||
regModal,
|
||||
setValue,
|
||||
handleOpen
|
||||
handleOpen,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -7,26 +7,24 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import { unref } from 'vue';
|
||||
import UserSelectModal from './modal/UserSelectModal.vue'
|
||||
import UserSelectModal from './modal/UserSelectModal.vue';
|
||||
import JSelectBiz from './base/JSelectBiz.vue';
|
||||
import { defineComponent, ref, reactive, watchEffect, watch, provide } from 'vue';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'JSelectUser',
|
||||
components: {
|
||||
UserSelectModal, JSelectBiz
|
||||
UserSelectModal,
|
||||
JSelectBiz,
|
||||
},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
labelKey: {
|
||||
type: String,
|
||||
default: 'realname',
|
||||
|
@ -37,8 +35,7 @@
|
|||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
}
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
emits: ['options-change', 'change', 'update:value'],
|
||||
|
@ -53,10 +50,10 @@
|
|||
//下拉框选中值
|
||||
let selectValues = reactive<object>({
|
||||
value: [],
|
||||
change: false
|
||||
change: false,
|
||||
});
|
||||
// 是否正在加载回显数据
|
||||
const loadingEcho = ref<boolean>(false)
|
||||
const loadingEcho = ref<boolean>(false);
|
||||
//下发 selectOptions,xxxBiz组件接收
|
||||
provide('selectOptions', selectOptions);
|
||||
//下发 selectValues,xxxBiz组件接收
|
||||
|
@ -67,7 +64,6 @@
|
|||
const tag = ref(false);
|
||||
const attrs = useAttrs();
|
||||
|
||||
|
||||
/**
|
||||
* 监听组件值
|
||||
*/
|
||||
|
@ -75,7 +71,7 @@
|
|||
props.value && initValue();
|
||||
// 查询条件重置的时候 界面显示未清空
|
||||
if (!props.value) {
|
||||
selectValues.value = []
|
||||
selectValues.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -86,7 +82,7 @@
|
|||
if (selectValues) {
|
||||
state.value = selectValues.value;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 打卡弹出框
|
||||
|
@ -104,8 +100,8 @@
|
|||
function initValue() {
|
||||
let value = props.value ? props.value : [];
|
||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||
state.value = value.split(",");
|
||||
selectValues.value = value.split(",");
|
||||
state.value = value.split(',');
|
||||
selectValues.value = value.split(',');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,11 +109,11 @@
|
|||
* 设置下拉框的值
|
||||
*/
|
||||
function setValue(options, values) {
|
||||
selectOptions.value = options
|
||||
selectOptions.value = options;
|
||||
//emitData.value = values.join(",");
|
||||
state.value = values;
|
||||
selectValues.value = values;
|
||||
emit('update:value', values.join(','))
|
||||
emit('update:value', values.join(','));
|
||||
}
|
||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||
return {
|
||||
|
@ -130,7 +126,7 @@
|
|||
tag,
|
||||
regModal,
|
||||
setValue,
|
||||
handleOpen
|
||||
handleOpen,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -7,25 +7,23 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import { unref } from 'vue';
|
||||
import UserSelectByDepModal from './modal/UserSelectByDepModal.vue'
|
||||
import UserSelectByDepModal from './modal/UserSelectByDepModal.vue';
|
||||
import JSelectBiz from './base/JSelectBiz.vue';
|
||||
import { defineComponent, ref, reactive, watchEffect, watch, provide } from 'vue';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import {propTypes} from "/@/utils/propTypes";
|
||||
import {useRuleFormItem} from "/@/hooks/component/useFormItem";
|
||||
import {useAttrs} from "/@/hooks/core/useAttrs";
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { SelectTypes } from 'ant-design-vue/es/select';
|
||||
export default defineComponent({
|
||||
name: 'JSelectUserByDept',
|
||||
components: {
|
||||
UserSelectByDepModal, JSelectBiz
|
||||
UserSelectByDepModal,
|
||||
JSelectBiz,
|
||||
},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.array
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array]),
|
||||
rowKey: {
|
||||
type: String,
|
||||
default: 'username',
|
||||
|
@ -47,10 +45,10 @@
|
|||
//下拉框选中值
|
||||
let selectValues = reactive<object>({
|
||||
value: [],
|
||||
change: false
|
||||
change: false,
|
||||
});
|
||||
// 是否正在加载回显数据
|
||||
const loadingEcho = ref<boolean>(false)
|
||||
const loadingEcho = ref<boolean>(false);
|
||||
//下发 selectOptions,xxxBiz组件接收
|
||||
provide('selectOptions', selectOptions);
|
||||
//下发 selectValues,xxxBiz组件接收
|
||||
|
@ -61,7 +59,6 @@
|
|||
const tag = ref(false);
|
||||
const attrs = useAttrs();
|
||||
|
||||
|
||||
/**
|
||||
* 监听组件值
|
||||
*/
|
||||
|
@ -94,8 +91,8 @@
|
|||
function initValue() {
|
||||
let value = props.value ? props.value : [];
|
||||
if (value && typeof value === 'string' && value != 'null' && value != 'undefined') {
|
||||
state.value = value.split(",");
|
||||
selectValues.value = value.split(",");
|
||||
state.value = value.split(',');
|
||||
selectValues.value = value.split(',');
|
||||
} else {
|
||||
selectValues.value = value;
|
||||
}
|
||||
|
@ -109,11 +106,11 @@
|
|||
//emitData.value = values.join(",");
|
||||
state.value = values;
|
||||
selectValues.value = values;
|
||||
emit('update:value', values)
|
||||
emit('update:value', values);
|
||||
}
|
||||
|
||||
function handleChange(values) {
|
||||
emit('update:value', values)
|
||||
emit('update:value', values);
|
||||
}
|
||||
const getBindValue = Object.assign({}, unref(props), unref(attrs));
|
||||
return {
|
||||
|
@ -127,7 +124,7 @@
|
|||
regModal,
|
||||
setValue,
|
||||
handleOpen,
|
||||
handleChange
|
||||
handleChange,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,34 +1,20 @@
|
|||
<template>
|
||||
<div :class="prefixCls">
|
||||
<a-select
|
||||
v-if="query"
|
||||
: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"/>
|
||||
<a-select v-if="query" :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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
||||
import { useDesign } from '/@/hooks/web/useDesign'
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
|
||||
const { prefixCls } = useDesign('j-switch')
|
||||
const { prefixCls } = useDesign('j-switch');
|
||||
const props = defineProps({
|
||||
// v-model:value
|
||||
value: propTypes.oneOfType([
|
||||
propTypes.string,
|
||||
propTypes.number,
|
||||
]),
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||
// 取值 options
|
||||
options: propTypes.array.def(() => ['Y', 'N']),
|
||||
// 文本 options
|
||||
|
@ -37,42 +23,46 @@ const props = defineProps({
|
|||
query: propTypes.bool.def(false),
|
||||
// 是否禁用
|
||||
disabled: propTypes.bool.def(false),
|
||||
})
|
||||
const attrs = useAttrs()
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
});
|
||||
const attrs = useAttrs();
|
||||
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 (!val) {
|
||||
checked.value = false
|
||||
emitValue(props.options[1])
|
||||
checked.value = false;
|
||||
emitValue(props.options[1]);
|
||||
} else {
|
||||
checked.value = props.options[0] == val
|
||||
checked.value = props.options[0] == val;
|
||||
}
|
||||
}
|
||||
}, { immediate: true })
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const selectOptions = computed(() => {
|
||||
let options: any[] = []
|
||||
options.push({ value: props.options[0], label: props.labelOptions[0] })
|
||||
options.push({ value: props.options[1], label: props.labelOptions[1] })
|
||||
return options
|
||||
})
|
||||
let options: any[] = [];
|
||||
options.push({ value: props.options[0], label: props.labelOptions[0] });
|
||||
options.push({ value: props.options[1], label: props.labelOptions[1] });
|
||||
return options;
|
||||
});
|
||||
|
||||
function onSwitchChange(checked) {
|
||||
let flag = checked === false ? props.options[1] : props.options[0]
|
||||
emitValue(flag)
|
||||
let flag = checked === false ? props.options[1] : props.options[0];
|
||||
emitValue(flag);
|
||||
}
|
||||
|
||||
function onSelectChange(value) {
|
||||
emitValue(value)
|
||||
emitValue(value);
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -82,5 +72,4 @@ function emitValue(value) {
|
|||
|
||||
.@{prefix-cls} {
|
||||
}
|
||||
|
||||
</style>
|
|
@ -9,17 +9,18 @@
|
|||
:dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
|
||||
style="width: 100%"
|
||||
v-bind="attrs"
|
||||
@change="onChange">
|
||||
@change="onChange"
|
||||
>
|
||||
</TreeSelect>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { defHttp } from '/@/utils/http/axios'
|
||||
import { propTypes } from '/@/utils/propTypes'
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs'
|
||||
import { useDesign } from '/@/hooks/web/useDesign'
|
||||
import { TreeSelect } from 'ant-design-vue'
|
||||
import { ref, watch } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { TreeSelect } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
view = '/sys/category/loadOne',
|
||||
|
@ -27,33 +28,41 @@ enum Api {
|
|||
children = '/sys/category/loadTreeChildren',
|
||||
}
|
||||
|
||||
const { prefixCls } = useDesign('j-tree-dict')
|
||||
const { prefixCls } = useDesign('j-tree-dict');
|
||||
const props = defineProps({
|
||||
// v-model:value
|
||||
value: propTypes.string.def(''),
|
||||
field: propTypes.string.def('id'),
|
||||
parentCode: propTypes.string.def(''),
|
||||
async: propTypes.bool.def(false),
|
||||
})
|
||||
const attrs = useAttrs()
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
});
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
|
||||
const treeData = ref<any[]>([])
|
||||
const treeValue = ref<any>(null)
|
||||
const treeData = ref<any[]>([]);
|
||||
const treeValue = ref<any>(null);
|
||||
|
||||
watch(() => props.value, () => loadViewInfo(), { deep: true, immediate: true })
|
||||
watch(() => props.parentCode, () => loadRoot(), { deep: true, immediate: true })
|
||||
watch(
|
||||
() => props.value,
|
||||
() => loadViewInfo(),
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
watch(
|
||||
() => props.parentCode,
|
||||
() => loadRoot(),
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
|
||||
async function loadViewInfo() {
|
||||
if (!props.value || props.value == '0') {
|
||||
treeValue.value = null
|
||||
treeValue.value = null;
|
||||
} else {
|
||||
let params = { field: props.field, val: props.value }
|
||||
let result = await defHttp.get({ url: Api.view, params })
|
||||
let params = { field: props.field, val: props.value };
|
||||
let result = await defHttp.get({ url: Api.view, params });
|
||||
treeValue.value = {
|
||||
value: props.value,
|
||||
label: result.name,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,23 +70,23 @@ async function loadRoot() {
|
|||
let params = {
|
||||
async: props.async,
|
||||
pcode: props.parentCode,
|
||||
}
|
||||
let result = await defHttp.get({ url: Api.root, params })
|
||||
treeData.value = [...result]
|
||||
handleTreeNodeValue(result)
|
||||
};
|
||||
let result = await defHttp.get({ url: Api.root, params });
|
||||
treeData.value = [...result];
|
||||
handleTreeNodeValue(result);
|
||||
}
|
||||
|
||||
async function asyncLoadTreeData(treeNode) {
|
||||
if (!props.async || treeNode.dataRef.children) {
|
||||
return Promise.resolve()
|
||||
return Promise.resolve();
|
||||
}
|
||||
let pid = treeNode.dataRef.key
|
||||
let params = { pid: pid }
|
||||
let result = await defHttp.get({ url: Api.children, params })
|
||||
handleTreeNodeValue(result)
|
||||
addChildren(pid, result, treeData.value)
|
||||
treeData.value = [...treeData.value]
|
||||
return Promise.resolve()
|
||||
let pid = treeNode.dataRef.key;
|
||||
let params = { pid: pid };
|
||||
let result = await defHttp.get({ url: Api.children, params });
|
||||
handleTreeNodeValue(result);
|
||||
addChildren(pid, result, treeData.value);
|
||||
treeData.value = [...treeData.value];
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function addChildren(pid, children, treeArray) {
|
||||
|
@ -85,43 +94,42 @@ function addChildren(pid, children, treeArray) {
|
|||
for (let item of treeArray) {
|
||||
if (item.key == pid) {
|
||||
if (!children || children.length == 0) {
|
||||
item.leaf = true
|
||||
item.leaf = true;
|
||||
} else {
|
||||
item.children = children
|
||||
item.children = children;
|
||||
}
|
||||
break
|
||||
break;
|
||||
} else {
|
||||
addChildren(pid, children, item.children)
|
||||
addChildren(pid, children, item.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleTreeNodeValue(result) {
|
||||
let storeField = props.field == 'code' ? 'code' : 'key'
|
||||
let storeField = props.field == 'code' ? 'code' : 'key';
|
||||
for (let i of result) {
|
||||
i.value = i[storeField]
|
||||
i.isLeaf = (i.leaf)
|
||||
i.value = i[storeField];
|
||||
i.isLeaf = i.leaf;
|
||||
if (i.children && i.children.length > 0) {
|
||||
handleTreeNodeValue(i.children)
|
||||
handleTreeNodeValue(i.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onChange(value) {
|
||||
if (!value) {
|
||||
emitValue('')
|
||||
emitValue('');
|
||||
} else {
|
||||
emitValue(value.value)
|
||||
emitValue(value.value);
|
||||
}
|
||||
treeValue.value = value
|
||||
treeValue.value = value;
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
emit('change', value)
|
||||
emit('update:value', value)
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
@ -130,5 +138,4 @@ function emitValue(value) {
|
|||
|
||||
.@{prefix-cls} {
|
||||
}
|
||||
|
||||
</style>
|
|
@ -12,7 +12,8 @@
|
|||
:multiple="multiple"
|
||||
v-bind="attrs"
|
||||
@change="onChange"
|
||||
@search="onSearch">
|
||||
@search="onSearch"
|
||||
>
|
||||
</a-tree-select>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
|
@ -20,11 +21,11 @@
|
|||
* 异步树加载组件 通过传入表名 显示字段 存储字段 加载一个树控件
|
||||
* <j-tree-select dict="aa_tree_test,aad,id" pid-field="pid" ></j-tree-select>
|
||||
* */
|
||||
import {ref, watch, unref} from 'vue'
|
||||
import {defHttp} from '/@/utils/http/axios'
|
||||
import {propTypes} from '/@/utils/propTypes'
|
||||
import {useAttrs} from '/@/hooks/core/useAttrs'
|
||||
import {TreeSelect} from 'ant-design-vue'
|
||||
import { ref, watch, unref } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { TreeSelect } from 'ant-design-vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
enum Api {
|
||||
|
@ -45,7 +46,7 @@
|
|||
loadTriggleChange: propTypes.bool.def(false),
|
||||
});
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
const { createMessage } = useMessage();
|
||||
//树形下拉数据
|
||||
const treeData = ref<any[]>([]);
|
||||
|
@ -57,11 +58,16 @@
|
|||
/**
|
||||
* 监听value数据并初始化
|
||||
*/
|
||||
watch(() => props.value, () => loadItemByCode(), {deep: true, immediate: true});
|
||||
watch(
|
||||
() => props.value,
|
||||
() => loadItemByCode(),
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
/**
|
||||
* 监听dict变化
|
||||
*/
|
||||
watch(() => props.dict,
|
||||
watch(
|
||||
() => props.dict,
|
||||
() => {
|
||||
initDictInfo();
|
||||
loadRoot();
|
||||
|
@ -73,8 +79,8 @@
|
|||
* 根据code获取下拉数据并回显
|
||||
*/
|
||||
async function loadItemByCode() {
|
||||
if (!props.value || props.value == "0") {
|
||||
treeValue.value = null
|
||||
if (!props.value || props.value == '0') {
|
||||
treeValue.value = null;
|
||||
} else {
|
||||
let params = { key: props.value };
|
||||
let result = await defHttp.get({ url: `${Api.view}${props.dict}`, params }, { isTransformResponse: false });
|
||||
|
@ -83,7 +89,7 @@
|
|||
treeValue.value = result.result.map((item, index) => ({
|
||||
key: values[index],
|
||||
value: values[index],
|
||||
label: item
|
||||
label: item,
|
||||
}));
|
||||
onLoadTriggleChange(result.result[0]);
|
||||
}
|
||||
|
@ -93,7 +99,7 @@
|
|||
function onLoadTriggleChange(text) {
|
||||
//只有单选才会触发
|
||||
if (!props.multiple && props.loadTriggleChange) {
|
||||
emit('change', props.value, text)
|
||||
emit('change', props.value, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,10 +107,10 @@
|
|||
* 初始化数据
|
||||
*/
|
||||
function initDictInfo() {
|
||||
let arr = props.dict?.split(",");
|
||||
let arr = props.dict?.split(',');
|
||||
tableName.value = arr[0];
|
||||
text.value = arr[1];
|
||||
code.value = arr[2]
|
||||
code.value = arr[2];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +124,7 @@
|
|||
condition: props.condition,
|
||||
tableName: unref(tableName),
|
||||
text: unref(text),
|
||||
code: unref(code)
|
||||
code: unref(code),
|
||||
};
|
||||
let res = await defHttp.get({ url: Api.url, params }, { isTransformResponse: false });
|
||||
if (res.success && res.result) {
|
||||
|
@ -128,7 +134,7 @@
|
|||
}
|
||||
treeData.value = [...res.result];
|
||||
} else {
|
||||
console.log("数根节点查询结果异常", res)
|
||||
console.log('数根节点查询结果异常', res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +143,7 @@
|
|||
*/
|
||||
async function asyncLoadTreeData(treeNode) {
|
||||
if (treeNode.dataRef.children) {
|
||||
return Promise.resolve()
|
||||
return Promise.resolve();
|
||||
}
|
||||
let pid = treeNode.dataRef.key;
|
||||
let params = {
|
||||
|
@ -159,7 +165,7 @@
|
|||
addChildren(pid, res.result, treeData.value);
|
||||
treeData.value = [...treeData.value];
|
||||
}
|
||||
return Promise.resolve()
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,11 +178,11 @@
|
|||
if (!children || children.length == 0) {
|
||||
item.isLeaf = true;
|
||||
} else {
|
||||
item.children = children
|
||||
item.children = children;
|
||||
}
|
||||
break
|
||||
break;
|
||||
} else {
|
||||
addChildren(pid, children, item.children)
|
||||
addChildren(pid, children, item.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,25 +193,25 @@
|
|||
*/
|
||||
function onChange(value) {
|
||||
if (!value) {
|
||||
emitValue('')
|
||||
emitValue('');
|
||||
} else if (value instanceof Array) {
|
||||
emitValue(value.map(item => item.value).join(','))
|
||||
emitValue(value.map((item) => item.value).join(','));
|
||||
} else {
|
||||
emitValue(value.value)
|
||||
emitValue(value.value);
|
||||
}
|
||||
treeValue.value = value
|
||||
treeValue.value = value;
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
emit('change', value);
|
||||
emit('update:value', value)
|
||||
emit('update:value', value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本框值变化
|
||||
*/
|
||||
function onSearch(value) {
|
||||
console.log(value)
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,17 +226,17 @@
|
|||
try {
|
||||
let test = JSON.parse(mycondition);
|
||||
if (typeof test == 'object' && test) {
|
||||
resolve()
|
||||
resolve();
|
||||
} else {
|
||||
createMessage.error("组件JTreeSelect-condition传值有误,需要一个json字符串!");
|
||||
reject()
|
||||
createMessage.error('组件JTreeSelect-condition传值有误,需要一个json字符串!');
|
||||
reject();
|
||||
}
|
||||
} catch (e) {
|
||||
createMessage.error("组件JTreeSelect-condition传值有误,需要一个json字符串!");
|
||||
reject()
|
||||
createMessage.error('组件JTreeSelect-condition传值有误,需要一个json字符串!');
|
||||
reject();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// onCreated
|
||||
|
@ -238,8 +244,7 @@
|
|||
initDictInfo();
|
||||
loadRoot();
|
||||
loadItemByCode();
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
</style>
|
||||
<style lang="less"></style>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue