diff --git a/build/config/themeConfig.ts b/build/config/themeConfig.ts index 8dbe118..5ab671a 100644 --- a/build/config/themeConfig.ts +++ b/build/config/themeConfig.ts @@ -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('-')); } diff --git a/build/generate/icon/index.ts b/build/generate/icon/index.ts index a9bac80..fb9819a 100644 --- a/build/generate/icon/index.ts +++ b/build/generate/icon/index.ts @@ -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}]`); }); } diff --git a/build/getConfigFileName.ts b/build/getConfigFileName.ts index d61cd41..46cb902 100644 --- a/build/getConfigFileName.ts +++ b/build/getConfigFileName.ts @@ -3,7 +3,5 @@ * @param env */ export const getConfigFileName = (env: Record) => { - 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, ''); }; diff --git a/build/script/postBuild.ts b/build/script/postBuild.ts index f2a9971..e1554bf 100644 --- a/build/script/postBuild.ts +++ b/build/script/postBuild.ts @@ -11,7 +11,7 @@ export const runBuild = async () => { // Generate configuration file if (!argvList.includes('disabled-config')) { - runBuildConfig(); + runBuildConfig(); } console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!'); diff --git a/build/utils.ts b/build/utils.ts index 989d1b4..c201514 100644 --- a/build/utils.ts +++ b/build/utils.ts @@ -3,60 +3,60 @@ import path from 'path'; import dotenv from 'dotenv'; export function isDevFn(mode: string): boolean { - return mode === 'development'; + return mode === 'development'; } export function isProdFn(mode: string): boolean { - return mode === 'production'; + return mode === 'production'; } /** * Whether to generate package preview */ export function isReportMode(): boolean { - return process.env.REPORT === 'true'; + return process.env.REPORT === 'true'; } // Read all environment variable configuration files to process.env export function wrapperEnv(envConf: Recordable): ViteEnv { - const ret: any = {}; + const ret: any = {}; - for (const envName of Object.keys(envConf)) { - let realName = envConf[envName].replace(/\\n/g, '\n'); - realName = realName === 'true' ? true : realName === 'false' ? false : realName; + for (const envName of Object.keys(envConf)) { + let realName = envConf[envName].replace(/\\n/g, '\n'); + realName = realName === 'true' ? true : realName === 'false' ? false : realName; - if (envName === 'VITE_PORT') { - realName = Number(realName); - } - if (envName === 'VITE_PROXY' && realName) { - try { - realName = JSON.parse(realName.replace(/'/g, '"')); - } catch (error) { - realName = ''; - } - } - ret[envName] = realName; - if (typeof realName === 'string') { - process.env[envName] = realName; - } else if (typeof realName === 'object') { - process.env[envName] = JSON.stringify(realName); - } + if (envName === 'VITE_PORT') { + realName = Number(realName); } - return ret; + if (envName === 'VITE_PROXY' && realName) { + try { + realName = JSON.parse(realName.replace(/'/g, '"')); + } catch (error) { + realName = ''; + } + } + ret[envName] = realName; + if (typeof realName === 'string') { + process.env[envName] = realName; + } else if (typeof realName === 'object') { + process.env[envName] = JSON.stringify(realName); + } + } + return ret; } /** * 获取当前环境下生效的配置文件名 */ function getConfFiles() { - const script = process.env.npm_lifecycle_script; - const reg = new RegExp('--mode ([a-z_\\d]+)'); - const result = reg.exec(script as string) as any; - if (result) { - const mode = result[1] as string; - return ['.env', `.env.${mode}`]; - } - return ['.env', '.env.production']; + const script = process.env.npm_lifecycle_script; + const reg = new RegExp('--mode ([a-z_\\d]+)'); + const result = reg.exec(script as string) as any; + if (result) { + const mode = result[1] as string; + return ['.env', `.env.${mode}`]; + } + return ['.env', '.env.production']; } /** @@ -65,22 +65,22 @@ function getConfFiles() { * @param confFiles ext */ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = getConfFiles()) { - let envConfig = {}; - confFiles.forEach((item) => { - try { - const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item))); - envConfig = {...envConfig, ...env}; - } catch (e) { - console.error(`Error in parsing ${item}`, e); - } - }); - const reg = new RegExp(`^(${match})`); - Object.keys(envConfig).forEach((key) => { - if (!reg.test(key)) { - Reflect.deleteProperty(envConfig, key); - } - }); - return envConfig; + let envConfig = {}; + confFiles.forEach((item) => { + try { + const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item))); + envConfig = { ...envConfig, ...env }; + } catch (e) { + console.error(`Error in parsing ${item}`, e); + } + }); + const reg = new RegExp(`^(${match})`); + Object.keys(envConfig).forEach((key) => { + if (!reg.test(key)) { + Reflect.deleteProperty(envConfig, key); + } + }); + return envConfig; } /** @@ -88,5 +88,5 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = getConfFiles()) { * @param dir file path */ export function getRootPath(...dir: string[]) { - return path.resolve(process.cwd(), ...dir); + return path.resolve(process.cwd(), ...dir); } diff --git a/build/vite/plugin/compress.ts b/build/vite/plugin/compress.ts index 34787ca..92cb9f8 100644 --- a/build/vite/plugin/compress.ts +++ b/build/vite/plugin/compress.ts @@ -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[] = []; diff --git a/build/vite/plugin/html.ts b/build/vite/plugin/html.ts index 15eee75..848190b 100644 --- a/build/vite/plugin/html.ts +++ b/build/vite/plugin/html.ts @@ -25,7 +25,7 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { }, // Embed the generated app.config.js file tags: isBuild - ? [ + ? [ { tag: 'script', attrs: { @@ -33,7 +33,7 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { }, }, ] - : [], + : [], }, }); return htmlPlugin; diff --git a/build/vite/plugin/index.ts b/build/vite/plugin/index.ts index 9ddbf23..8388ebc 100644 --- a/build/vite/plugin/index.ts +++ b/build/vite/plugin/index.ts @@ -15,74 +15,66 @@ 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 - vue(), - // have to - vueJsx(), - // support name - vueSetupExtend(), - ]; + const vitePlugins: (Plugin | Plugin[])[] = [ + // have to + vue(), + // have to + vueJsx(), + // support name + vueSetupExtend(), + ]; - // vite-plugin-windicss - vitePlugins.push(windiCSS()); + // vite-plugin-windicss + vitePlugins.push(windiCSS()); - // TODO - !isBuild && vitePlugins.push(configHmrPlugin()); + // TODO + !isBuild && vitePlugins.push(configHmrPlugin()); - // @vitejs/plugin-legacy - VITE_LEGACY && isBuild && vitePlugins.push(legacy()); + // @vitejs/plugin-legacy + VITE_LEGACY && isBuild && vitePlugins.push(legacy()); - // vite-plugin-html - vitePlugins.push(configHtmlPlugin(viteEnv, isBuild)); + // vite-plugin-html + vitePlugins.push(configHtmlPlugin(viteEnv, isBuild)); - // vite-plugin-svg-icons - vitePlugins.push(configSvgIconsPlugin(isBuild)); + // vite-plugin-svg-icons + vitePlugins.push(configSvgIconsPlugin(isBuild)); - // vite-plugin-mock - VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild)); + // vite-plugin-mock + VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild)); - // vite-plugin-purge-icons - vitePlugins.push(purgeIcons()); + // vite-plugin-purge-icons + vitePlugins.push(purgeIcons()); - // vite-plugin-style-import - vitePlugins.push(configStyleImportPlugin(isBuild)); + // vite-plugin-style-import + vitePlugins.push(configStyleImportPlugin(isBuild)); - // rollup-plugin-visualizer - vitePlugins.push(configVisualizerConfig()); + // rollup-plugin-visualizer + vitePlugins.push(configVisualizerConfig()); - //vite-plugin-theme - vitePlugins.push(configThemePlugin(isBuild)); + //vite-plugin-theme + vitePlugins.push(configThemePlugin(isBuild)); - // The following plugins only work in the production environment - if (isBuild) { - //vite-plugin-imagemin - VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin()); + // The following plugins only work in the production environment + if (isBuild) { + //vite-plugin-imagemin + VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin()); - // rollup-plugin-gzip - vitePlugins.push( - configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE), - ); + // rollup-plugin-gzip + vitePlugins.push(configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE)); - // vite-plugin-pwa - vitePlugins.push(configPwaConfig(viteEnv)); - } + // vite-plugin-pwa + vitePlugins.push(configPwaConfig(viteEnv)); + } - //vite-plugin-theme【解决vite首次打开界面加载慢问题】 - vitePlugins.push(PkgConfig()); - vitePlugins.push(OptimizationPersist()); + //vite-plugin-theme【解决vite首次打开界面加载慢问题】 + vitePlugins.push(PkgConfig()); + vitePlugins.push(OptimizationPersist()); - return vitePlugins; + return vitePlugins; } diff --git a/build/vite/plugin/theme.ts b/build/vite/plugin/theme.ts index d198d77..772af3c 100644 --- a/build/vite/plugin/theme.ts +++ b/build/vite/plugin/theme.ts @@ -4,86 +4,80 @@ */ 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'; export function configThemePlugin(isBuild: boolean): Plugin[] { - const colors = generateColors({ - mixDarken, - mixLighten, - tinycolor, - }); - const plugin = [ - viteThemePlugin({ - resolveSelector: (s) => { - s = s.trim(); - switch (s) { - case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon': - return '.ant-steps-item-icon > .ant-steps-icon'; - case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled)': - case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover': - case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):active': - return s; - case '.ant-steps-item-icon > .ant-steps-icon': - return s; - case '.ant-select-item-option-selected:not(.ant-select-item-option-disabled)': - return s; - default: - if (s.indexOf('.ant-btn') >= -1) { - // 按钮被重新定制过,需要过滤掉class防止覆盖 - return s; - } - } - return s.startsWith('[data-theme') ? s : `[data-theme] ${s}`; - }, - colorVariables: [...getThemeColors(), ...colors], - }), - antdDarkThemePlugin({ - preloadFiles: [ - path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'), - //path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.dark.less'), - path.resolve(process.cwd(), 'src/design/index.less'), - ], - filter: (id) => (isBuild ? !id.endsWith('antd.less') : true), - // extractCss: false, - darkModifyVars: { - ...generateModifyVars(true), - 'text-color': '#c9d1d9', - 'primary-1': 'rgb(255 255 255 / 8%)', - 'text-color-base': '#c9d1d9', - 'component-background': '#151515', - 'heading-color': 'rgb(255 255 255 / 65%)', - // black: '#0e1117', - // #8b949e - 'text-color-secondary': '#8b949e', - 'border-color-base': '#303030', - // 'border-color-split': '#30363d', - 'item-active-bg': '#111b26', - 'app-content-background': '#1e1e1e', - 'tree-node-selected-bg': '#11263c', + const colors = generateColors({ + mixDarken, + mixLighten, + tinycolor, + }); + const plugin = [ + viteThemePlugin({ + resolveSelector: (s) => { + s = s.trim(); + switch (s) { + case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon': + return '.ant-steps-item-icon > .ant-steps-icon'; + case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled)': + case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover': + case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):active': + return s; + case '.ant-steps-item-icon > .ant-steps-icon': + return s; + case '.ant-select-item-option-selected:not(.ant-select-item-option-disabled)': + return s; + default: + if (s.indexOf('.ant-btn') >= -1) { + // 按钮被重新定制过,需要过滤掉class防止覆盖 + return s; + } + } + return s.startsWith('[data-theme') ? s : `[data-theme] ${s}`; + }, + colorVariables: [...getThemeColors(), ...colors], + }), + antdDarkThemePlugin({ + preloadFiles: [ + path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'), + //path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.dark.less'), + path.resolve(process.cwd(), 'src/design/index.less'), + ], + filter: (id) => (isBuild ? !id.endsWith('antd.less') : true), + // extractCss: false, + darkModifyVars: { + ...generateModifyVars(true), + 'text-color': '#c9d1d9', + 'primary-1': 'rgb(255 255 255 / 8%)', + 'text-color-base': '#c9d1d9', + 'component-background': '#151515', + 'heading-color': 'rgb(255 255 255 / 65%)', + // black: '#0e1117', + // #8b949e + 'text-color-secondary': '#8b949e', + 'border-color-base': '#303030', + // 'border-color-split': '#30363d', + 'item-active-bg': '#111b26', + 'app-content-background': '#1e1e1e', + 'tree-node-selected-bg': '#11263c', - 'alert-success-border-color': '#274916', - 'alert-success-bg-color': '#162312', - 'alert-success-icon-color': '#49aa19', - 'alert-info-border-color': '#153450', - 'alert-info-bg-color': '#111b26', - 'alert-info-icon-color': '#177ddc', - 'alert-warning-border-color': '#594214', - 'alert-warning-bg-color': '#2b2111', - 'alert-warning-icon-color': '#d89614', - 'alert-error-border-color': '#58181c', - 'alert-error-bg-color': '#2a1215', - 'alert-error-icon-color': '#a61d24', - }, - }), - ]; + 'alert-success-border-color': '#274916', + 'alert-success-bg-color': '#162312', + 'alert-success-icon-color': '#49aa19', + 'alert-info-border-color': '#153450', + 'alert-info-bg-color': '#111b26', + 'alert-info-icon-color': '#177ddc', + 'alert-warning-border-color': '#594214', + 'alert-warning-bg-color': '#2b2111', + 'alert-warning-icon-color': '#d89614', + 'alert-error-border-color': '#58181c', + 'alert-error-bg-color': '#2a1215', + 'alert-error-icon-color': '#a61d24', + }, + }), + ]; - return plugin as unknown as Plugin[]; + return plugin as unknown as Plugin[]; } diff --git a/mock/_util.ts b/mock/_util.ts index 6a171d5..aae271d 100644 --- a/mock/_util.ts +++ b/mock/_util.ts @@ -9,12 +9,7 @@ export function resultSuccess(result: T, { message = 'ok' } = {} }; } -export function resultPageSuccess( - pageNo: number, - pageSize: number, - list: T[], - { message = 'ok' } = {} -) { +export function resultPageSuccess(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(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; } diff --git a/mock/demo/select-demo.ts b/mock/demo/select-demo.ts index ca2d949..7105769 100644 --- a/mock/demo/select-demo.ts +++ b/mock/demo/select-demo.ts @@ -20,9 +20,9 @@ export default [ timeout: 1000, method: 'get', response: ({ query }) => { - const { keyword,count} = query; + const { keyword, count } = query; console.log(keyword); - return resultSuccess(demoList(keyword,count)); + return resultSuccess(demoList(keyword, count)); }, }, ] as MockMethod[]; diff --git a/mock/demo/system.ts b/mock/demo/system.ts index 940c04e..e2ed4cc 100644 --- a/mock/demo/system.ts +++ b/mock/demo/system.ts @@ -2,196 +2,183 @@ import { MockMethod } from 'vite-plugin-mock'; import { resultError, resultPageSuccess, resultSuccess, baseUrl } from '../_util'; const accountList = (() => { - const result: any[] = []; - for (let index = 0; index < 20; index++) { - result.push({ - id: `${index}`, - account: '@first', - email: '@email', - nickname: '@cname()', - role: '@first', - createTime: '@datetime', - remark: '@cword(10,20)', - 'status|1': ['0', '1'], - }); - } - return result; + const result: any[] = []; + for (let index = 0; index < 20; index++) { + result.push({ + id: `${index}`, + account: '@first', + email: '@email', + nickname: '@cname()', + role: '@first', + createTime: '@datetime', + remark: '@cword(10,20)', + 'status|1': ['0', '1'], + }); + } + return result; })(); const userList = (() => { - const result: any[] = []; - for (let index = 0; index < 20; index++) { - result.push({ - id: `${index}`, - username: '@first', - email: '@email', - realname: '@cname()', - createTime: '@datetime', - remark: '@cword(10,20)', - avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640' - }); - } - return result; + const result: any[] = []; + for (let index = 0; index < 20; index++) { + result.push({ + id: `${index}`, + username: '@first', + email: '@email', + realname: '@cname()', + createTime: '@datetime', + remark: '@cword(10,20)', + avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640', + }); + } + return result; })(); const roleList = (() => { - const result: any[] = []; - for (let index = 0; index < 4; index++) { - result.push({ - id: index + 1, - orderNo: `${index + 1}`, - roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index], - roleValue: '@first', - createTime: '@datetime', - remark: '@cword(10,20)', - menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index], - 'status|1': ['0', '1'], - }); - } - return result; + const result: any[] = []; + for (let index = 0; index < 4; index++) { + result.push({ + id: index + 1, + orderNo: `${index + 1}`, + roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index], + roleValue: '@first', + createTime: '@datetime', + remark: '@cword(10,20)', + menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index], + 'status|1': ['0', '1'], + }); + } + return result; })(); const newRoleList = (() => { - const result: any[] = []; - for (let index = 0; index < 4; index++) { - result.push({ - id: index + 1, - orderNo: `${index + 1}`, - roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index], - roleCode: '@first', - createTime: '@datetime', - remark: '@cword(10,20)' - }); - } - return result; + const result: any[] = []; + for (let index = 0; index < 4; index++) { + result.push({ + id: index + 1, + orderNo: `${index + 1}`, + roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index], + roleCode: '@first', + createTime: '@datetime', + remark: '@cword(10,20)', + }); + } + return result; })(); const testList = (() => { - const result: any[] = []; - for (let index = 0; index < 4; index++) { - result.push({ - id: index + 1, - orderNo: `${index + 1}`, - testName: ['数据1', '数据2', '数据3', '数据4'][index], - testValue: '@first', - createTime: '@datetime' - }); - } - return result; + const result: any[] = []; + for (let index = 0; index < 4; index++) { + result.push({ + id: index + 1, + orderNo: `${index + 1}`, + testName: ['数据1', '数据2', '数据3', '数据4'][index], + testValue: '@first', + createTime: '@datetime', + }); + } + return result; })(); const tableDemoList = (() => { - const result: any[] = []; - for (let index = 0; index < 4; index++) { - result.push({ - id: index + 1, - orderCode: '2008200' + `${index + 1}`, - orderMoney: '@natural(1000,3000)', - ctype: '@natural(1,2)', - content: '@cword(10,20)', - orderDate: '@datetime' - }); - } - return result; + const result: any[] = []; + for (let index = 0; index < 4; index++) { + result.push({ + id: index + 1, + orderCode: '2008200' + `${index + 1}`, + orderMoney: '@natural(1000,3000)', + ctype: '@natural(1,2)', + content: '@cword(10,20)', + orderDate: '@datetime', + }); + } + return result; })(); const deptList = (() => { - const result: any[] = []; - for (let index = 0; index < 3; index++) { - result.push({ - id: `${index}`, - deptName: ['华东分部', '华南分部', '西北分部'][index], - orderNo: index + 1, + const result: any[] = []; + for (let index = 0; index < 3; index++) { + result.push({ + id: `${index}`, + deptName: ['华东分部', '华南分部', '西北分部'][index], + orderNo: index + 1, + createTime: '@datetime', + remark: '@cword(10,20)', + 'status|1': ['0', '0', '1'], + children: (() => { + const children: any[] = []; + for (let j = 0; j < 4; j++) { + children.push({ + id: `${index}-${j}`, + deptName: ['研发部', '市场部', '商务部', '财务部'][j], + orderNo: j + 1, createTime: '@datetime', remark: '@cword(10,20)', - 'status|1': ['0', '0', '1'], - children: (() => { - const children: any[] = []; - for (let j = 0; j < 4; j++) { - children.push({ - id: `${index}-${j}`, - deptName: ['研发部', '市场部', '商务部', '财务部'][j], - orderNo: j + 1, - createTime: '@datetime', - remark: '@cword(10,20)', - 'status|1': ['0', '1'], - parentDept: `${index}`, - children: undefined, - }); - } - return children; - })(), - }); - } - return result; + 'status|1': ['0', '1'], + parentDept: `${index}`, + children: undefined, + }); + } + return children; + })(), + }); + } + return result; })(); const menuList = (() => { - const result: any[] = []; - for (let index = 0; index < 3; index++) { - result.push({ - id: `${index}`, - icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index], - component: 'LAYOUT', - type: '0', - menuName: ['Dashboard', '权限管理', '功能'][index], - permission: '', - orderNo: index + 1, + const result: any[] = []; + for (let index = 0; index < 3; index++) { + result.push({ + id: `${index}`, + icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index], + component: 'LAYOUT', + type: '0', + menuName: ['Dashboard', '权限管理', '功能'][index], + permission: '', + orderNo: index + 1, + createTime: '@datetime', + 'status|1': ['0', '0', '1'], + children: (() => { + const children: any[] = []; + for (let j = 0; j < 4; j++) { + children.push({ + id: `${index}-${j}`, + type: '1', + 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], + orderNo: j + 1, createTime: '@datetime', - 'status|1': ['0', '0', '1'], + 'status|1': ['0', '1'], + parentMenu: `${index}`, children: (() => { - const children: any[] = []; - for (let j = 0; j < 4; j++) { - children.push({ - id: `${index}-${j}`, - type: '1', - 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], - orderNo: j + 1, - createTime: '@datetime', - 'status|1': ['0', '1'], - parentMenu: `${index}`, - children: (() => { - const children: any[] = []; - for (let k = 0; k < 4; k++) { - children.push({ - id: `${index}-${j}-${k}`, - 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], - orderNo: j + 1, - createTime: '@datetime', - 'status|1': ['0', '1'], - parentMenu: `${index}-${j}`, - children: undefined, - }); - } - return children; - })(), - }); - } - return children; + const children: any[] = []; + for (let k = 0; k < 4; k++) { + children.push({ + id: `${index}-${j}-${k}`, + 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], + orderNo: j + 1, + createTime: '@datetime', + 'status|1': ['0', '1'], + parentMenu: `${index}-${j}`, + children: undefined, + }); + } + return children; })(), - }); - } - return result; + }); + } + return children; + })(), + }); + } + return result; })(); export default [ diff --git a/mock/sys/menu.ts b/mock/sys/menu.ts index 73bda64..45d292b 100644 --- a/mock/sys/menu.ts +++ b/mock/sys/menu.ts @@ -1,4 +1,4 @@ -import { resultSuccess, resultError, getRequestToken, requestParams,baseUrl} from '../_util'; +import { resultSuccess, resultError, getRequestToken, requestParams, baseUrl } from '../_util'; import { MockMethod } from 'vite-plugin-mock'; import { createFakeUserList } from './user'; diff --git a/mock/sys/user.ts b/mock/sys/user.ts index 34175e7..bcbe02b 100644 --- a/mock/sys/user.ts +++ b/mock/sys/user.ts @@ -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!'); } diff --git a/package.json b/package.json index 972745a..3495ec6 100644 --- a/package.json +++ b/package.json @@ -291,7 +291,6 @@ "vue-print-nb-jeecg/src/printarea", "vue-router", "vue-types", - "vuedraggable", "vxe-table", "vxe-table-plugin-antd", "xe-utils", diff --git a/src/api/common/api.ts b/src/api/common/api.ts index d3e5625..5dfebb1 100644 --- a/src/api/common/api.ts +++ b/src/api/common/api.ts @@ -18,7 +18,7 @@ enum Api { /** * 上传父路径 */ -export const uploadUrl=`${baseUploadUrl}/sys/common/upload`; +export const uploadUrl = `${baseUploadUrl}/sys/common/upload`; /** * 职务列表 @@ -47,52 +47,51 @@ export const getRoleList = (params) => { /** * 异步获取部门树列表 */ -export const queryDepartTreeSync = (params?) =>{ +export const queryDepartTreeSync = (params?) => { return defHttp.get({ url: Api.queryDepartTreeSync, params }); -} +}; /** * 获取部门树列表 */ -export const queryTreeList = (params?) =>{ +export const queryTreeList = (params?) => { return defHttp.get({ url: Api.queryTreeList, params }); -} +}; /** * 分类字典树控件 加载节点 */ -export const loadTreeData = (params?) =>{ +export const loadTreeData = (params?) => { return defHttp.get({ url: Api.loadTreeData, params }); -} - +}; /** * 根据字典code加载字典text */ -export const loadDictItem = (params?) =>{ +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}); -} +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}) -} +export const getTableList = (params) => { + return defHttp.get({ url: Api.getTableList, params }); +}; /** * 加载全部分类字典数据 */ -export const loadCategoryData = (params)=>{ - return defHttp.get({url:Api.getCategoryData,params}) -} +export const loadCategoryData = (params) => { + return defHttp.get({ url: Api.getCategoryData, params }); +}; /** * 文件上传 */ -export const uploadFile = (params,success)=>{ - return defHttp.uploadFile({url:uploadUrl}, params,{success}) -} +export const uploadFile = (params, success) => { + return defHttp.uploadFile({ url: uploadUrl }, params, { success }); +}; diff --git a/src/api/demo/select.ts b/src/api/demo/select.ts index 9769f58..9fb5cae 100644 --- a/src/api/demo/select.ts +++ b/src/api/demo/select.ts @@ -7,5 +7,4 @@ enum Api { /** * @description: Get sample options value */ -export const optionsListApi = (params?: selectParams) => - defHttp.get({ url: Api.OPTIONS_LIST, params }); +export const optionsListApi = (params?: selectParams) => defHttp.get({ url: Api.OPTIONS_LIST, params }); diff --git a/src/api/demo/system.ts b/src/api/demo/system.ts index d1c5910..01c1fd5 100644 --- a/src/api/demo/system.ts +++ b/src/api/demo/system.ts @@ -1,54 +1,45 @@ import { - AccountParams, - DeptListItem, - MenuParams, - RoleParams, - TestPageParams, - RolePageParams, - MenuListGetResultModel, - DeptListGetResultModel, - AccountListGetResultModel, - RolePageListGetResultModel, - RoleListGetResultModel, - TestListGetResultModel + AccountParams, + DeptListItem, + MenuParams, + RoleParams, + TestPageParams, + RolePageParams, + MenuListGetResultModel, + DeptListGetResultModel, + AccountListGetResultModel, + RolePageListGetResultModel, + RoleListGetResultModel, + TestListGetResultModel, } from './model/systemModel'; -import {defHttp} from '/@/utils/http/axios'; +import { defHttp } from '/@/utils/http/axios'; enum Api { - AccountList = '/mock/system/getAccountList', - IsAccountExist = '/mock/system/accountExist', - DeptList = '/mock/system/getDeptList', - setRoleStatus = '/mock/system/setRoleStatus', - MenuList = '/mock/system/getMenuList', - RolePageList = '/mock/system/getRoleListByPage', - DemoTableList = '/mock/system/getDemoTableListByPage', - TestPageList = '/mock/system/getTestListByPage', - GetAllRoleList = '/mock/system/getAllRoleList', + AccountList = '/mock/system/getAccountList', + IsAccountExist = '/mock/system/accountExist', + DeptList = '/mock/system/getDeptList', + setRoleStatus = '/mock/system/setRoleStatus', + MenuList = '/mock/system/getMenuList', + RolePageList = '/mock/system/getRoleListByPage', + DemoTableList = '/mock/system/getDemoTableListByPage', + TestPageList = '/mock/system/getTestListByPage', + GetAllRoleList = '/mock/system/getAllRoleList', } -export const getAccountList = (params: AccountParams) => - defHttp.get({url: Api.AccountList, params}); +export const getAccountList = (params: AccountParams) => defHttp.get({ url: Api.AccountList, params }); -export const getDeptList = (params?: DeptListItem) => - defHttp.get({url: Api.DeptList, params}); +export const getDeptList = (params?: DeptListItem) => defHttp.get({ url: Api.DeptList, params }); -export const getMenuList = (params?: MenuParams) => - defHttp.get({url: Api.MenuList, params}); +export const getMenuList = (params?: MenuParams) => defHttp.get({ url: Api.MenuList, params }); -export const getRoleListByPage = (params?: RolePageParams) => - defHttp.get({url: Api.RolePageList, params}); +export const getRoleListByPage = (params?: RolePageParams) => defHttp.get({ url: Api.RolePageList, params }); -export const getAllRoleList = (params?: RoleParams) => - defHttp.get({url: Api.GetAllRoleList, params}); +export const getAllRoleList = (params?: RoleParams) => defHttp.get({ 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({url: Api.TestPageList, params}); +export const getTestListByPage = (params?: TestPageParams) => defHttp.get({ 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' }); diff --git a/src/api/demo/tree.ts b/src/api/demo/tree.ts index b626945..8fe3acf 100644 --- a/src/api/demo/tree.ts +++ b/src/api/demo/tree.ts @@ -7,5 +7,4 @@ enum Api { /** * @description: Get sample options value */ -export const treeOptionsListApi = (params?: Recordable) => - defHttp.get({ url: Api.TREE_OPTIONS_LIST, params }); +export const treeOptionsListApi = (params?: Recordable) => defHttp.get({ url: Api.TREE_OPTIONS_LIST, params }); diff --git a/src/api/sys/menu.ts b/src/api/sys/menu.ts index f0787a8..a4a399c 100644 --- a/src/api/sys/menu.ts +++ b/src/api/sys/menu.ts @@ -12,12 +12,12 @@ enum Api { export const getMenuList = () => { return new Promise((resolve) => { //为了兼容mock和接口数据 - defHttp.get({ url: Api.GetMenuList }).then(res=>{ - if(Array.isArray(res)){ - resolve(res) - }else{ - resolve(res['menu']) + defHttp.get({ url: Api.GetMenuList }).then((res) => { + if (Array.isArray(res)) { + resolve(res); + } else { + resolve(res['menu']); } }); - }) + }); }; diff --git a/src/api/sys/model/userModel.ts b/src/api/sys/model/userModel.ts index b387c3b..add553a 100644 --- a/src/api/sys/model/userModel.ts +++ b/src/api/sys/model/userModel.ts @@ -52,6 +52,6 @@ export interface GetUserInfoModel { export interface GetResultModel { code: number; message: string; - result:object; + result: object; success: Boolean; } diff --git a/src/api/sys/upload.ts b/src/api/sys/upload.ts index b09982c..1a83e93 100644 --- a/src/api/sys/upload.ts +++ b/src/api/sys/upload.ts @@ -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( { 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( { url: `${uploadUrl}/sys/common/upload`, onUploadProgress, }, - params, {isReturnResponse:true} + params, + { isReturnResponse: true } ); } diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts index 2e0e5e3..a152f8d 100644 --- a/src/api/sys/user.ts +++ b/src/api/sys/user.ts @@ -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', @@ -23,7 +22,7 @@ enum Api { GetPermCode = '/sys/permission/getPermCode', //新加的获取图形验证码的接口 getInputCode = '/sys/randomImage', - //获取短信验证码的接口 + //获取短信验证码的接口 getCaptcha = '/sys/sms', //注册接口 registerApi = '/sys/user/register', @@ -78,17 +77,17 @@ export function phoneLoginApi(params: LoginParams, mode: ErrorMessageMode = 'mod /** * @description: getUserInfo */ -export function getUserInfo() { - return defHttp.get({ url: Api.GetUserInfo }, { errorMessageMode: 'none' }).catch((e)=>{ - // update-begin--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面 - if (e && e.message.includes('timeout')) { - //接口不通时跳转到登录界面 - const userStore = useUserStoreWithOut(); - userStore.setToken(''); - setAuthCache(TOKEN_KEY, null); - router.push(PageEnum.BASE_LOGIN); - } - // update-end--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面 +export function getUserInfo() { + return defHttp.get({ url: Api.GetUserInfo }, { errorMessageMode: 'none' }).catch((e) => { + // update-begin--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面 + if (e && e.message.includes('timeout')) { + //接口不通时跳转到登录界面 + const userStore = useUserStoreWithOut(); + userStore.setToken(''); + setAuthCache(TOKEN_KEY, null); + router.push(PageEnum.BASE_LOGIN); + } + // update-end--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面 }); } @@ -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,78 +108,75 @@ 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) - if(res.success){ - resolve(true) - }else{ - createErrorModal({ title: '错误提示', content: res.message||'未知问题' }); - reject() + defHttp.post({ url: Api.getCaptcha, params }, { isTransformResponse: false }).then((res) => { + console.log(res); + if (res.success) { + resolve(true); + } else { + createErrorModal({ title: '错误提示', content: res.message || '未知问题' }); + 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: 第三方登录 */ export function thirdLogin(params, mode: ErrorMessageMode = 'modal') { - return defHttp.get( - { - url: `${Api.thirdLogin}/${params.token}/${params.thirdType}`, - }, - { - errorMessageMode: mode, - } - ); + return defHttp.get( + { + url: `${Api.thirdLogin}/${params.token}/${params.thirdType}`, + }, + { + errorMessageMode: mode, + } + ); } /** * @description: 获取第三方短信验证码 */ export function setThirdCaptcha(params) { - return new Promise((resolve, reject) => { - defHttp.post({url:Api.getThirdCaptcha,params},{isTransformResponse: false}).then(res=>{ - console.log(res) - if(res.success){ - resolve(true) - }else{ - createErrorModal({ title: '错误提示', content: res.message||'未知问题' }); - reject() - } - }); - }) + return new Promise((resolve, reject) => { + defHttp.post({ url: Api.getThirdCaptcha, params }, { isTransformResponse: false }).then((res) => { + console.log(res); + if (res.success) { + resolve(true); + } else { + createErrorModal({ title: '错误提示', content: res.message || '未知问题' }); + reject(); + } + }); + }); } /** * 获取登录二维码信息 */ export function getLoginQrcode() { - let url = Api.getLoginQrcode + let url = Api.getLoginQrcode; return defHttp.get({ url: url }); } @@ -188,14 +184,14 @@ export function getLoginQrcode() { * 监控扫码状态 */ export function getQrcodeToken(params) { - let url = Api.getQrcodeToken - return defHttp.get({ url: url,params}); + let url = Api.getQrcodeToken; + return defHttp.get({ url: url, params }); } /** * SSO登录校验 */ export async function validateCasLogin(params) { - let url = Api.validateCasLogin - return defHttp.get({ url: url,params}); + let url = Api.validateCasLogin; + return defHttp.get({ url: url, params }); } diff --git a/src/assets/less/JAreaLinkage.less b/src/assets/less/JAreaLinkage.less index d367073..4fea722 100644 --- a/src/assets/less/JAreaLinkage.less +++ b/src/assets/less/JAreaLinkage.less @@ -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; @@ -256,4 +255,4 @@ .cascader-menu-list::-webkit-scrollbar-thumb:vertical:hover, .area-selectable-list-wrap::-webkit-scrollbar-thumb:vertical:hover { background-color: #777; -} \ No newline at end of file +} diff --git a/src/components/Application/src/AppLocalePicker.vue b/src/components/Application/src/AppLocalePicker.vue index 0ec7ad9..6fabc66 100644 --- a/src/components/Application/src/AppLocalePicker.vue +++ b/src/components/Application/src/AppLocalePicker.vue @@ -3,14 +3,7 @@ * @Description: Multi-language switching component --> \ No newline at end of file + return { ...setup, typeWorkAttrs }; + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/HourUI.vue b/src/components/Form/src/jeecg/components/JEasyCron/tabs/HourUI.vue index 99d2324..c3c5224 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/HourUI.vue +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/HourUI.vue @@ -7,17 +7,17 @@
区间 - + 时 至 - +
循环 - + 时开始,间隔 - +
@@ -35,25 +35,25 @@ \ No newline at end of file + }), + emits: useTabEmits(), + setup(props, context) { + return useTabSetup(props, context, { + defaultValue: '*', + minValue: 0, + maxValue: 23, + valueRange: { start: 0, end: 23 }, + valueLoop: { start: 0, interval: 1 }, + }); + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/MinuteUI.vue b/src/components/Form/src/jeecg/components/JEasyCron/tabs/MinuteUI.vue index 6ea3da7..34617bf 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/MinuteUI.vue +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/MinuteUI.vue @@ -7,17 +7,17 @@
区间 - + 分 至 - +
循环 - + 分开始,间隔 - +
@@ -35,25 +35,25 @@ \ No newline at end of file + }), + emits: useTabEmits(), + setup(props, context) { + return useTabSetup(props, context, { + defaultValue: '*', + minValue: 0, + maxValue: 59, + valueRange: { start: 0, end: 59 }, + valueLoop: { start: 0, interval: 1 }, + }); + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/MonthUI.vue b/src/components/Form/src/jeecg/components/JEasyCron/tabs/MonthUI.vue index 0674e6f..78f7f4e 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/MonthUI.vue +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/MonthUI.vue @@ -7,17 +7,17 @@
区间 - + 月 至 - +
循环 - + 月开始,间隔 - +
@@ -35,25 +35,25 @@ \ No newline at end of file + }), + emits: useTabEmits(), + setup(props, context) { + return useTabSetup(props, context, { + defaultValue: '*', + minValue: 1, + maxValue: 12, + valueRange: { start: 1, end: 12 }, + valueLoop: { start: 1, interval: 1 }, + }); + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/SecondUI.vue b/src/components/Form/src/jeecg/components/JEasyCron/tabs/SecondUI.vue index d74024c..6b65b85 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/SecondUI.vue +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/SecondUI.vue @@ -7,17 +7,17 @@
区间 - + 秒 至 - +
循环 - + 秒开始,间隔 - +
@@ -35,25 +35,25 @@ \ No newline at end of file + }), + emits: useTabEmits(), + setup(props, context) { + return useTabSetup(props, context, { + defaultValue: '*', + minValue: 0, + maxValue: 59, + valueRange: { start: 0, end: 59 }, + valueLoop: { start: 0, interval: 1 }, + }); + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/WeekUI.vue b/src/components/Form/src/jeecg/components/JEasyCron/tabs/WeekUI.vue index 8b376e8..c3b15dc 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/WeekUI.vue +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/WeekUI.vue @@ -8,16 +8,16 @@
区间 - + - +
循环 - + 开始,间隔 - +
@@ -35,88 +35,91 @@ \ No newline at end of file + return { + ...setup, + weekOptions, + typeLoopSelectAttrs, + typeRangeSelectAttrs, + WEEK_MAP_CN, + WEEK_MAP_EN, + }; + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/YearUI.vue b/src/components/Form/src/jeecg/components/JEasyCron/tabs/YearUI.vue index 206bd80..2be7972 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/YearUI.vue +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/YearUI.vue @@ -7,17 +7,17 @@
区间 - + 年 至 - +
循环 - + 年开始,间隔 - +
@@ -25,25 +25,25 @@ \ No newline at end of file + }), + emits: useTabEmits(), + setup(props, context) { + const nowYear = new Date().getFullYear(); + return useTabSetup(props, context, { + defaultValue: '*', + minValue: 0, + valueRange: { start: nowYear, end: nowYear + 100 }, + valueLoop: { start: nowYear, interval: 1 }, + }); + }, + }); + diff --git a/src/components/Form/src/jeecg/components/JEasyCron/tabs/useTabMixin.ts b/src/components/Form/src/jeecg/components/JEasyCron/tabs/useTabMixin.ts index 63f53b5..291ca19 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/tabs/useTabMixin.ts +++ b/src/components/Form/src/jeecg/components/JEasyCron/tabs/useTabMixin.ts @@ -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([]) + const type = ref(options.defaultType ?? TypeEnum.every); + const valueList = ref([]); // 对于不同的类型,所定义的值也有所不同 - 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) => { - if (val !== computeValue.value) { - parseValue(val) - } - }, { immediate: true }) + watch( + () => props.value, + (val) => { + if (val !== computeValue.value) { + parseValue(val); + } + }, + { 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, - } -} \ No newline at end of file + }; +} diff --git a/src/components/Form/src/jeecg/components/JEasyCron/validator.ts b/src/components/Form/src/jeecg/components/JEasyCron/validator.ts index e72fc00..308f1e8 100644 --- a/src/components/Form/src/jeecg/components/JEasyCron/validator.ts +++ b/src/components/Form/src/jeecg/components/JEasyCron/validator.ts @@ -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 \ No newline at end of file +export default cronRule.validator; diff --git a/src/components/Form/src/jeecg/components/JEditor.vue b/src/components/Form/src/jeecg/components/JEditor.vue index 9b725c3..3928fc9 100644 --- a/src/components/Form/src/jeecg/components/JEditor.vue +++ b/src/components/Form/src/jeecg/components/JEditor.vue @@ -1,40 +1,39 @@ - \ No newline at end of file + diff --git a/src/components/Form/src/jeecg/components/JEllipsis.vue b/src/components/Form/src/jeecg/components/JEllipsis.vue index 18a4d45..f63def4 100644 --- a/src/components/Form/src/jeecg/components/JEllipsis.vue +++ b/src/components/Form/src/jeecg/components/JEllipsis.vue @@ -1,20 +1,19 @@ diff --git a/src/components/Form/src/jeecg/components/JImageUpload.vue b/src/components/Form/src/jeecg/components/JImageUpload.vue index 3adc93f..c15121b 100644 --- a/src/components/Form/src/jeecg/components/JImageUpload.vue +++ b/src/components/Form/src/jeecg/components/JImageUpload.vue @@ -1,32 +1,33 @@ diff --git a/src/components/Form/src/jeecg/components/JImportModal.vue b/src/components/Form/src/jeecg/components/JImportModal.vue index cd5278f..eeae0db 100644 --- a/src/components/Form/src/jeecg/components/JImportModal.vue +++ b/src/components/Form/src/jeecg/components/JImportModal.vue @@ -1,179 +1,179 @@ diff --git a/src/components/Form/src/jeecg/components/JInput.vue b/src/components/Form/src/jeecg/components/JInput.vue index 58bcede..a7e8077 100644 --- a/src/components/Form/src/jeecg/components/JInput.vue +++ b/src/components/Form/src/jeecg/components/JInput.vue @@ -1,107 +1,105 @@ - + diff --git a/src/components/Form/src/jeecg/components/JInputPop.vue b/src/components/Form/src/jeecg/components/JInputPop.vue index 4823e17..9b81b3c 100644 --- a/src/components/Form/src/jeecg/components/JInputPop.vue +++ b/src/components/Form/src/jeecg/components/JInputPop.vue @@ -1,122 +1,109 @@ \ No newline at end of file + diff --git a/src/components/Form/src/jeecg/components/JMarkdownEditor.vue b/src/components/Form/src/jeecg/components/JMarkdownEditor.vue index d9ae41c..b9d2b5c 100644 --- a/src/components/Form/src/jeecg/components/JMarkdownEditor.vue +++ b/src/components/Form/src/jeecg/components/JMarkdownEditor.vue @@ -1,54 +1,57 @@ - \ No newline at end of file + diff --git a/src/components/Form/src/jeecg/components/JOnlineSelectCascade.vue b/src/components/Form/src/jeecg/components/JOnlineSelectCascade.vue index dddbe47..12f233b 100644 --- a/src/components/Form/src/jeecg/components/JOnlineSelectCascade.vue +++ b/src/components/Form/src/jeecg/components/JOnlineSelectCascade.vue @@ -1,24 +1,24 @@ - \ No newline at end of file + diff --git a/src/components/Form/src/jeecg/components/JPopup.vue b/src/components/Form/src/jeecg/components/JPopup.vue index 7569ee5..393275e 100644 --- a/src/components/Form/src/jeecg/components/JPopup.vue +++ b/src/components/Form/src/jeecg/components/JPopup.vue @@ -1,142 +1,142 @@ diff --git a/src/components/Form/src/jeecg/components/JRangeNumber.vue b/src/components/Form/src/jeecg/components/JRangeNumber.vue index daf7177..2e44892 100644 --- a/src/components/Form/src/jeecg/components/JRangeNumber.vue +++ b/src/components/Form/src/jeecg/components/JRangeNumber.vue @@ -1,69 +1,69 @@ - \ No newline at end of file + diff --git a/src/components/Form/src/jeecg/components/JSearchSelect.vue b/src/components/Form/src/jeecg/components/JSearchSelect.vue index 115cf5e..83e0c2b 100644 --- a/src/components/Form/src/jeecg/components/JSearchSelect.vue +++ b/src/components/Form/src/jeecg/components/JSearchSelect.vue @@ -1,269 +1,264 @@ - + diff --git a/src/components/Form/src/jeecg/components/JSelectDept.vue b/src/components/Form/src/jeecg/components/JSelectDept.vue index 926dd3a..15235a2 100644 --- a/src/components/Form/src/jeecg/components/JSelectDept.vue +++ b/src/components/Form/src/jeecg/components/JSelectDept.vue @@ -1,14 +1,14 @@ diff --git a/src/components/Form/src/jeecg/components/JSelectInput.vue b/src/components/Form/src/jeecg/components/JSelectInput.vue index 3afad90..9fa1c65 100644 --- a/src/components/Form/src/jeecg/components/JSelectInput.vue +++ b/src/components/Form/src/jeecg/components/JSelectInput.vue @@ -1,79 +1,89 @@ - + diff --git a/src/components/Form/src/jeecg/components/JSelectMultiple.vue b/src/components/Form/src/jeecg/components/JSelectMultiple.vue index 26cc199..cbdcbc7 100644 --- a/src/components/Form/src/jeecg/components/JSelectMultiple.vue +++ b/src/components/Form/src/jeecg/components/JSelectMultiple.vue @@ -1,10 +1,10 @@ diff --git a/src/components/Form/src/jeecg/components/JSelectPosition.vue b/src/components/Form/src/jeecg/components/JSelectPosition.vue index f4df620..1b54106 100644 --- a/src/components/Form/src/jeecg/components/JSelectPosition.vue +++ b/src/components/Form/src/jeecg/components/JSelectPosition.vue @@ -1,153 +1,149 @@ diff --git a/src/components/Form/src/jeecg/components/JSelectRole.vue b/src/components/Form/src/jeecg/components/JSelectRole.vue index cba46a6..9cabefc 100644 --- a/src/components/Form/src/jeecg/components/JSelectRole.vue +++ b/src/components/Form/src/jeecg/components/JSelectRole.vue @@ -1,152 +1,148 @@ diff --git a/src/components/Form/src/jeecg/components/JSelectUser.vue b/src/components/Form/src/jeecg/components/JSelectUser.vue index 6dfe461..17435c3 100644 --- a/src/components/Form/src/jeecg/components/JSelectUser.vue +++ b/src/components/Form/src/jeecg/components/JSelectUser.vue @@ -1,158 +1,154 @@ diff --git a/src/components/Form/src/jeecg/components/JSelectUserByDept.vue b/src/components/Form/src/jeecg/components/JSelectUserByDept.vue index f5d0d6a..47e150a 100644 --- a/src/components/Form/src/jeecg/components/JSelectUserByDept.vue +++ b/src/components/Form/src/jeecg/components/JSelectUserByDept.vue @@ -1,155 +1,152 @@ diff --git a/src/components/Form/src/jeecg/components/JSwitch.vue b/src/components/Form/src/jeecg/components/JSwitch.vue index a606fa1..baebadf 100644 --- a/src/components/Form/src/jeecg/components/JSwitch.vue +++ b/src/components/Form/src/jeecg/components/JSwitch.vue @@ -1,86 +1,75 @@ \ No newline at end of file + .@{prefix-cls} { + } + diff --git a/src/components/Form/src/jeecg/components/JTreeDict.vue b/src/components/Form/src/jeecg/components/JTreeDict.vue index ddc6128..6439290 100644 --- a/src/components/Form/src/jeecg/components/JTreeDict.vue +++ b/src/components/Form/src/jeecg/components/JTreeDict.vue @@ -1,134 +1,141 @@ \ No newline at end of file + .@{prefix-cls} { + } + diff --git a/src/components/Form/src/jeecg/components/JTreeSelect.vue b/src/components/Form/src/jeecg/components/JTreeSelect.vue index 3e991c6..358a3c7 100644 --- a/src/components/Form/src/jeecg/components/JTreeSelect.vue +++ b/src/components/Form/src/jeecg/components/JTreeSelect.vue @@ -1,245 +1,250 @@ - + diff --git a/src/components/Form/src/jeecg/components/JUpload/JUpload.vue b/src/components/Form/src/jeecg/components/JUpload/JUpload.vue index df7befe..4091065 100644 --- a/src/components/Form/src/jeecg/components/JUpload/JUpload.vue +++ b/src/components/Form/src/jeecg/components/JUpload/JUpload.vue @@ -1,23 +1,24 @@ diff --git a/src/components/Form/src/jeecg/components/JUpload/JUploadModal.vue b/src/components/Form/src/jeecg/components/JUpload/JUploadModal.vue index 9f7cad0..083e1ec 100644 --- a/src/components/Form/src/jeecg/components/JUpload/JUploadModal.vue +++ b/src/components/Form/src/jeecg/components/JUpload/JUploadModal.vue @@ -1,51 +1,45 @@ diff --git a/src/components/Form/src/jeecg/components/JUpload/components/UploadItemActions.vue b/src/components/Form/src/jeecg/components/JUpload/components/UploadItemActions.vue index a1ec797..61586ab 100644 --- a/src/components/Form/src/jeecg/components/JUpload/components/UploadItemActions.vue +++ b/src/components/Form/src/jeecg/components/JUpload/components/UploadItemActions.vue @@ -1,91 +1,90 @@ \ No newline at end of file + function onDownload() { + const url = props.element?.getElementsByTagName('img')[0]?.src; + window.open(url); + } + diff --git a/src/components/Form/src/jeecg/components/JUpload/index.ts b/src/components/Form/src/jeecg/components/JUpload/index.ts index 6408cbe..740bf2d 100644 --- a/src/components/Form/src/jeecg/components/JUpload/index.ts +++ b/src/components/Form/src/jeecg/components/JUpload/index.ts @@ -1,3 +1,3 @@ -export { UploadTypeEnum } from './upload.data' -export { default as JUpload } from './JUpload.vue' -export { default as JUploadModal } from './JUploadModal.vue' +export { UploadTypeEnum } from './upload.data'; +export { default as JUpload } from './JUpload.vue'; +export { default as JUploadModal } from './JUploadModal.vue'; diff --git a/src/components/Form/src/jeecg/components/JUpload/upload.data.ts b/src/components/Form/src/jeecg/components/JUpload/upload.data.ts index 3159988..820146d 100644 --- a/src/components/Form/src/jeecg/components/JUpload/upload.data.ts +++ b/src/components/Form/src/jeecg/components/JUpload/upload.data.ts @@ -2,4 +2,4 @@ export enum UploadTypeEnum { all = 'all', image = 'image', file = 'file', -} \ No newline at end of file +} diff --git a/src/components/Form/src/jeecg/components/base/JSelectBiz.vue b/src/components/Form/src/jeecg/components/base/JSelectBiz.vue index a598385..fba8c66 100644 --- a/src/components/Form/src/jeecg/components/base/JSelectBiz.vue +++ b/src/components/Form/src/jeecg/components/base/JSelectBiz.vue @@ -1,105 +1,115 @@ diff --git a/src/components/Form/src/jeecg/components/base/JTreeBiz.vue b/src/components/Form/src/jeecg/components/base/JTreeBiz.vue index 12284ea..c1119c3 100644 --- a/src/components/Form/src/jeecg/components/base/JTreeBiz.vue +++ b/src/components/Form/src/jeecg/components/base/JTreeBiz.vue @@ -2,7 +2,7 @@
- + 选择 diff --git a/src/components/Form/src/jeecg/components/modal/DeptSelectModal.vue b/src/components/Form/src/jeecg/components/modal/DeptSelectModal.vue index f1778f5..506c559 100644 --- a/src/components/Form/src/jeecg/components/modal/DeptSelectModal.vue +++ b/src/components/Form/src/jeecg/components/modal/DeptSelectModal.vue @@ -1,31 +1,39 @@ diff --git a/src/components/Form/src/jeecg/components/modal/PositionSelectModal.vue b/src/components/Form/src/jeecg/components/modal/PositionSelectModal.vue index 8824cd6..9260342 100644 --- a/src/components/Form/src/jeecg/components/modal/PositionSelectModal.vue +++ b/src/components/Form/src/jeecg/components/modal/PositionSelectModal.vue @@ -1,22 +1,32 @@ - + diff --git a/src/components/Form/src/jeecg/components/modal/UserSelectModal.vue b/src/components/Form/src/jeecg/components/modal/UserSelectModal.vue index 7631f24..7fdc7c7 100644 --- a/src/components/Form/src/jeecg/components/modal/UserSelectModal.vue +++ b/src/components/Form/src/jeecg/components/modal/UserSelectModal.vue @@ -1,25 +1,34 @@ - + diff --git a/src/components/JVxeCustom/src/components/JVxeFileCell.vue b/src/components/JVxeCustom/src/components/JVxeFileCell.vue index 87babbd..c27602e 100644 --- a/src/components/JVxeCustom/src/components/JVxeFileCell.vue +++ b/src/components/JVxeCustom/src/components/JVxeFileCell.vue @@ -1,39 +1,36 @@ - + diff --git a/src/components/JVxeCustom/src/components/JVxeImageCell.vue b/src/components/JVxeCustom/src/components/JVxeImageCell.vue index 96e0305..f026d84 100644 --- a/src/components/JVxeCustom/src/components/JVxeImageCell.vue +++ b/src/components/JVxeCustom/src/components/JVxeImageCell.vue @@ -3,126 +3,117 @@
- + {{ originColumn.btnText || '上传图片' }}
- +
- +
diff --git a/src/components/JVxeCustom/src/components/JVxePopupCell.vue b/src/components/JVxeCustom/src/components/JVxePopupCell.vue index cbdc936..e3144fd 100644 --- a/src/components/JVxeCustom/src/components/JVxePopupCell.vue +++ b/src/components/JVxeCustom/src/components/JVxePopupCell.vue @@ -1,73 +1,67 @@ \ No newline at end of file + // 【组件增强】注释详见:JVxeComponent.Enhanced + enhanced: { + aopEvents: { + editActived({ $event }) { + dispatchEvent({ + $event, + props: this.props, + className: '.ant-input', + isClick: true, + }); + }, + }, + } as JVxeComponent.EnhancedPartial, + }); + diff --git a/src/components/JVxeCustom/src/components/JVxeSelectDictSearchCell.ts b/src/components/JVxeCustom/src/components/JVxeSelectDictSearchCell.ts index 12a7576..a7b62ab 100644 --- a/src/components/JVxeCustom/src/components/JVxeSelectDictSearchCell.ts +++ b/src/components/JVxeCustom/src/components/JVxeSelectDictSearchCell.ts @@ -1,148 +1,148 @@ -import { computed, ref, watch, defineComponent, h } from 'vue' -import { cloneDeep, debounce } from 'lodash-es' -import { defHttp } from '/@/utils/http/axios' -import { filterDictText } from '/@/utils/dict/JDictSelectUtil' -import { ajaxGetDictItems, getDictItemsByCode } from '/@/utils/dict' -import { JVxeComponent } from '/@/components/jeecg/JVxeTable/types' -import { dispatchEvent } from '/@/components/jeecg/JVxeTable/utils' -import { useResolveComponent as rc } from '/@/components/jeecg/JVxeTable/hooks' -import { useJVxeComponent, useJVxeCompProps } from '/@/components/jeecg/JVxeTable/hooks' -import { useMessage } from '/@/hooks/web/useMessage' +import { computed, ref, watch, defineComponent, h } from 'vue'; +import { cloneDeep, debounce } from 'lodash-es'; +import { defHttp } from '/@/utils/http/axios'; +import { filterDictText } from '/@/utils/dict/JDictSelectUtil'; +import { ajaxGetDictItems, getDictItemsByCode } from '/@/utils/dict'; +import { JVxeComponent } from '/@/components/jeecg/JVxeTable/types'; +import { dispatchEvent } from '/@/components/jeecg/JVxeTable/utils'; +import { useResolveComponent as rc } from '/@/components/jeecg/JVxeTable/hooks'; +import { useJVxeComponent, useJVxeCompProps } from '/@/components/jeecg/JVxeTable/hooks'; +import { useMessage } from '/@/hooks/web/useMessage'; /** value - label map,防止重复查询(刷新清空缓存) */ -const LabelMap = new Map() +const LabelMap = new Map(); // 请求id -let requestId = 0 +let requestId = 0; /** 显示组件,自带翻译 */ export const DictSearchSpanCell = defineComponent({ name: 'JVxeSelectSearchSpanCell', props: useJVxeCompProps(), setup(props: JVxeComponent.Props) { - const { innerOptions, innerSelectValue, innerValue } = useSelectDictSearch(props) + const { innerOptions, innerSelectValue, innerValue } = useSelectDictSearch(props); return () => { - return h('span', {}, [ - filterDictText(innerOptions.value, innerSelectValue.value || innerValue.value), - ]) - } + return h('span', {}, [filterDictText(innerOptions.value, innerSelectValue.value || innerValue.value)]); + }; }, -}) +}); // 输入选择组件 export const DictSearchInputCell = defineComponent({ name: 'JVxeSelectSearchInputCell', props: useJVxeCompProps(), setup(props: JVxeComponent.Props) { - const { createMessage } = useMessage() - const { - dict, - loading, - isAsync, - options, - innerOptions, - originColumn, - cellProps, - innerSelectValue, - handleChangeCommon, - } = useSelectDictSearch(props) - const hasRequest = ref(false) + const { createMessage } = useMessage(); + const { dict, loading, isAsync, options, innerOptions, originColumn, cellProps, innerSelectValue, handleChangeCommon } = useSelectDictSearch(props); + const hasRequest = ref(false); // 提示信息 const tipsContent = computed(() => { - return originColumn.value.tipsContent || '请输入搜索内容' - }) + return originColumn.value.tipsContent || '请输入搜索内容'; + }); // 筛选函数 const filterOption = computed(() => { if (isAsync.value) { - return null + return null; } - return (input, option) => option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 - }) + return (input, option) => option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0; + }); /** 加载数据 */ const loadData = debounce((value) => { - const currentRequestId = ++requestId - loading.value = true - innerOptions.value = [] + const currentRequestId = ++requestId; + loading.value = true; + innerOptions.value = []; if (value == null || value.trim() === '') { - loading.value = false - hasRequest.value = false - return + loading.value = false; + hasRequest.value = false; + return; } // 字典code格式:table,text,code - hasRequest.value = true - loadDictByKeyword(dict.value, value).then(res => { - if (currentRequestId !== requestId) { - return - } - let { success, result, message } = res - if (success) { - innerOptions.value = result - result.forEach((item) => { - LabelMap.set(item.value, [item]) - }) - } else { - createMessage.warning(message || '查询失败') - } - }).finally(() => { - loading.value = false - }) - }, 300) + hasRequest.value = true; + loadDictByKeyword(dict.value, value) + .then((res) => { + if (currentRequestId !== requestId) { + return; + } + let { success, result, message } = res; + if (success) { + innerOptions.value = result; + result.forEach((item) => { + LabelMap.set(item.value, [item]); + }); + } else { + createMessage.warning(message || '查询失败'); + } + }) + .finally(() => { + loading.value = false; + }); + }, 300); function handleChange(selectedValue) { - innerSelectValue.value = selectedValue - handleChangeCommon(innerSelectValue.value) + innerSelectValue.value = selectedValue; + handleChangeCommon(innerSelectValue.value); } function handleSearch(value) { if (isAsync.value) { // 在输入时也应该开启加载,因为loadData加了消抖,所以会有800ms的用户主观上认为的卡顿时间 - loading.value = true + loading.value = true; if (innerOptions.value.length > 0) { - innerOptions.value = [] + innerOptions.value = []; } - loadData(value) + loadData(value); } } function renderOptionItem() { - let optionItems: any[] = [] + let optionItems: any[] = []; options.value.forEach(({ value, text, label, title, disabled }) => { - optionItems.push(h(rc('a-select-option'), { - key: value, - value: value, - disabled: disabled, - }, { - default: () => (text || label || title), - })) - }) - return optionItems + optionItems.push( + h( + rc('a-select-option'), + { + key: value, + value: value, + disabled: disabled, + }, + { + default: () => text || label || title, + } + ) + ); + }); + return optionItems; } return () => { - return h(rc('a-select'), { - ...cellProps.value, - value: innerSelectValue.value, - filterOption: filterOption.value, - showSearch: true, - allowClear: true, - autofocus: true, - defaultOpen: true, - style: 'width: 100%', - onSearch: handleSearch, - onChange: handleChange, - }, { - default: () => renderOptionItem(), - notFoundContent: () => { - if (loading.value) { - return h(rc('a-spin'), { size: 'small' }) - } else if (hasRequest.value) { - return h('div', '没有查询到任何数据') - } else { - return h('div', [tipsContent.value]) - } + return h( + rc('a-select'), + { + ...cellProps.value, + value: innerSelectValue.value, + filterOption: filterOption.value, + showSearch: true, + allowClear: true, + autofocus: true, + defaultOpen: true, + style: 'width: 100%', + onSearch: handleSearch, + onChange: handleChange, }, - }) - } + { + default: () => renderOptionItem(), + notFoundContent: () => { + if (loading.value) { + return h(rc('a-spin'), { size: 'small' }); + } else if (hasRequest.value) { + return h('div', '没有查询到任何数据'); + } else { + return h('div', [tipsContent.value]); + } + }, + } + ); + }; }, // 【组件增强】注释详见:JVxeComponent.Enhanced enhanced: { @@ -154,63 +154,67 @@ export const DictSearchInputCell = defineComponent({ className: '.ant-select .ant-select-selection-search-input', isClick: false, handler: (el) => el.focus(), - }) + }); }, }, } as JVxeComponent.EnhancedPartial, -}) +}); function useSelectDictSearch(props) { - const setup = useJVxeComponent(props) - const { innerValue, originColumn } = setup + const setup = useJVxeComponent(props); + const { innerValue, originColumn } = setup; // 加载状态 - const loading = ref(false) + const loading = ref(false); // 内部选择值 - const innerSelectValue = ref(null) + const innerSelectValue = ref(null); // 内部 options - const innerOptions = ref([]) + const innerOptions = ref([]); - const dict = computed(() => originColumn.value.dict) + const dict = computed(() => originColumn.value.dict); // 是否是异步模式 const isAsync = computed(() => { - let isAsync = originColumn.value.async - return (isAsync != null && isAsync !== '') ? !!isAsync : true - }) + let isAsync = originColumn.value.async; + return isAsync != null && isAsync !== '' ? !!isAsync : true; + }); const options = computed(() => { if (isAsync.value) { - return innerOptions.value + return innerOptions.value; } else { - return originColumn.value.options || [] + return originColumn.value.options || []; } - }) + }); /** 公共属性监听 */ - watch(innerValue, (value: string) => { - if (value == null || value === '') { - innerSelectValue.value = null - } else { - loadDataByValue(value) - } - }, { immediate: true }) - watch(dict, () => loadDataByDict()) + watch( + innerValue, + (value: string) => { + if (value == null || value === '') { + innerSelectValue.value = null; + } else { + loadDataByValue(value); + } + }, + { immediate: true } + ); + watch(dict, () => loadDataByDict()); // 根据 value 查询数据,用于回显 async function loadDataByValue(value) { if (isAsync.value) { if (innerSelectValue.value !== value) { if (LabelMap.has(value)) { - innerOptions.value = cloneDeep(LabelMap.get(value)) + innerOptions.value = cloneDeep(LabelMap.get(value)); } else { - let result = await loadDictItem(dict.value, value) + let result = await loadDictItem(dict.value, value); if (result && result.length > 0) { - innerOptions.value = [{ value: value, text: result[0] }] - LabelMap.set(value, cloneDeep(innerOptions.value)) + innerOptions.value = [{ value: value, text: result[0] }]; + LabelMap.set(value, cloneDeep(innerOptions.value)); } } } } - innerSelectValue.value = (value || '').toString() + innerSelectValue.value = (value || '').toString(); } // 初始化字典 @@ -219,26 +223,26 @@ function useSelectDictSearch(props) { // 如果字典项集合有数据 if (!originColumn.value.options || originColumn.value.options.length === 0) { // 根据字典Code, 初始化字典数组 - let dictStr = '' + let dictStr = ''; if (dict.value) { - let arr = dict.value.split(',') + let arr = dict.value.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.value + dictStr = dict.value; } if (dict.value.indexOf(',') === -1) { //优先从缓存中读取字典配置 - let cache = getDictItemsByCode(dict.value) + let cache = getDictItemsByCode(dict.value); if (cache) { - innerOptions.value = cache - return + innerOptions.value = cache; + return; } } - let { success, result } = await ajaxGetDictItems(dictStr, null) + let { success, result } = await ajaxGetDictItems(dictStr, null); if (success) { - innerOptions.value = result + innerOptions.value = result; } } } @@ -247,9 +251,13 @@ function useSelectDictSearch(props) { return { ...setup, - loading, innerOptions, innerSelectValue, - dict, isAsync, options, - } + loading, + innerOptions, + innerSelectValue, + dict, + isAsync, + options, + }; } /** 获取字典项 */ @@ -259,17 +267,20 @@ function loadDictItem(dict: string, key: string) { params: { key: key, }, - }) + }); } /** 根据关键字获取字典项(搜索) */ function loadDictByKeyword(dict: string, keyword: string) { - return defHttp.get({ - url: `/sys/dict/loadDict/${dict}`, - params: { - keyword: keyword, + return defHttp.get( + { + url: `/sys/dict/loadDict/${dict}`, + params: { + keyword: keyword, + }, }, - }, { - isTransformResponse: false, - }) -} \ No newline at end of file + { + isTransformResponse: false, + } + ); +} diff --git a/src/components/JVxeCustom/src/components/JVxeUserSelectCell.vue b/src/components/JVxeCustom/src/components/JVxeUserSelectCell.vue index bd5bfde..18092d4 100644 --- a/src/components/JVxeCustom/src/components/JVxeUserSelectCell.vue +++ b/src/components/JVxeCustom/src/components/JVxeUserSelectCell.vue @@ -1,76 +1,69 @@ - \ No newline at end of file + diff --git a/src/components/JVxeCustom/src/hooks/useFileCell.ts b/src/components/JVxeCustom/src/hooks/useFileCell.ts index 9728452..216721a 100644 --- a/src/components/JVxeCustom/src/hooks/useFileCell.ts +++ b/src/components/JVxeCustom/src/hooks/useFileCell.ts @@ -1,52 +1,52 @@ -import { computed } from 'vue' -import { fileGetValue, fileSetValue, useJVxeUploadCell } from '/@/components/jeecg/JVxeTable/src/hooks/cells/useJVxeUploadCell' -import { uploadUrl } from '/@/api/common/api' -import { JUploadModal, UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload' -import { useModal } from '/@/components/Modal' -import { JVxeComponent } from '/@/components/jeecg/JVxeTable/src/types/JVxeComponent' -import { Icon } from '/@/components/Icon' -import { Dropdown } from 'ant-design-vue' -import { LoadingOutlined } from '@ant-design/icons-vue' +import { computed } from 'vue'; +import { fileGetValue, fileSetValue, useJVxeUploadCell } from '/@/components/jeecg/JVxeTable/src/hooks/cells/useJVxeUploadCell'; +import { uploadUrl } from '/@/api/common/api'; +import { JUploadModal, UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload'; +import { useModal } from '/@/components/Modal'; +import { JVxeComponent } from '/@/components/jeecg/JVxeTable/src/types/JVxeComponent'; +import { Icon } from '/@/components/Icon'; +import { Dropdown } from 'ant-design-vue'; +import { LoadingOutlined } from '@ant-design/icons-vue'; export function useFileCell(props, fileType: UploadTypeEnum, options?) { - const setup = useJVxeUploadCell(props, { token: true, action: uploadUrl, ...options }) + const setup = useJVxeUploadCell(props, { token: true, action: uploadUrl, ...options }); - const { innerFile, handleChangeCommon, originColumn } = setup - const [registerModel, { openModal }] = useModal() + const { innerFile, handleChangeCommon, originColumn } = setup; + const [registerModel, { openModal }] = useModal(); // 截取文件名 const ellipsisFileName = computed(() => { - let length = 5 - let file = innerFile.value + let length = 5; + let file = innerFile.value; if (!file || !file.name) { - return '' + return ''; } if (file.name.length > length) { - return file.name.substr(0, length) + '…' + return file.name.substr(0, length) + '…'; } - return file.name - }) + return file.name; + }); const modalValue = computed(() => { if (innerFile.value) { if (innerFile.value['url']) { - return innerFile.value['url'] + return innerFile.value['url']; } else if (innerFile.value['path']) { - return innerFile.value['path'] + return innerFile.value['path']; } } - return '' - }) + return ''; + }); const maxCount = computed(() => { - let maxCount = originColumn.value.maxCount + let maxCount = originColumn.value.maxCount; // online 扩展JSON if (originColumn.value && originColumn.value.fieldExtendJson) { - let json = JSON.parse(originColumn.value.fieldExtendJson) - maxCount = json.uploadnum ? json.uploadnum : 0 + let json = JSON.parse(originColumn.value.fieldExtendJson); + maxCount = json.uploadnum ? json.uploadnum : 0; } - return maxCount ?? 0 - }) + return maxCount ?? 0; + }); // 点击更多按钮 function handleMoreOperation() { @@ -57,18 +57,17 @@ export function useFileCell(props, fileType: UploadTypeEnum, options?) { ...originColumn.value.props, maxCount: maxCount.value, fileType: fileType, - }) + }); } // 更多上传回调 function onModalChange(path) { if (path) { - innerFile.value.path = path - handleChangeCommon(innerFile.value) + innerFile.value.path = path; + handleChangeCommon(innerFile.value); } } - return { ...setup, modalValue, @@ -77,15 +76,18 @@ export function useFileCell(props, fileType: UploadTypeEnum, options?) { registerModel, onModalChange, handleMoreOperation, - } + }; } export const components = { - Icon, Dropdown, LoadingOutlined, JUploadModal, -} + Icon, + Dropdown, + LoadingOutlined, + JUploadModal, +}; export const enhanced = { switches: { visible: true }, - getValue: value => fileGetValue(value), - setValue: value => fileSetValue(value), -} as JVxeComponent.EnhancedPartial \ No newline at end of file + getValue: (value) => fileGetValue(value), + setValue: (value) => fileSetValue(value), +} as JVxeComponent.EnhancedPartial; diff --git a/src/components/Loading/src/Loading.vue b/src/components/Loading/src/Loading.vue index c729eb0..6f8dbc0 100644 --- a/src/components/Loading/src/Loading.vue +++ b/src/components/Loading/src/Loading.vue @@ -1,10 +1,5 @@ diff --git a/src/components/Loading/src/useLoading.ts b/src/components/Loading/src/useLoading.ts index 0424717..b5f1215 100644 --- a/src/components/Loading/src/useLoading.ts +++ b/src/components/Loading/src/useLoading.ts @@ -4,46 +4,44 @@ import type { LoadingProps } from './typing'; import type { Ref } from 'vue'; export interface UseLoadingOptions { - target?: any; - props?: Partial; + target?: any; + props?: Partial; } interface Fn { - (): void; + (): void; } export function useLoading(props: Partial): [Fn, Fn, (string) => void]; export function useLoading(opt: Partial): [Fn, Fn, (string) => void]; -export function useLoading( - opt: Partial | Partial -): [Fn, Fn, (string) => void] { - let props: Partial; - let target: HTMLElement | Ref = document.body; +export function useLoading(opt: Partial | Partial): [Fn, Fn, (string) => void] { + let props: Partial; + let target: HTMLElement | Ref = document.body; - if (Reflect.has(opt, 'target') || Reflect.has(opt, 'props')) { - const options = opt as Partial; - props = options.props || {}; - target = options.target || document.body; - } else { - props = opt as Partial; - } + if (Reflect.has(opt, 'target') || Reflect.has(opt, 'props')) { + const options = opt as Partial; + props = options.props || {}; + target = options.target || document.body; + } else { + props = opt as Partial; + } - const instance = createLoading(props, undefined, true); + const instance = createLoading(props, undefined, true); - const open = (): void => { - const t = unref(target as Ref); - if (!t) return; - instance.open(t); - }; + const open = (): void => { + const t = unref(target as Ref); + if (!t) return; + instance.open(t); + }; - const close = (): void => { - instance.close(); - }; + const close = (): void => { + instance.close(); + }; - const setTip = (tip: string) => { - instance.setTip(tip); - }; + const setTip = (tip: string) => { + instance.setTip(tip); + }; - return [open, close, setTip]; + return [open, close, setTip]; } diff --git a/src/components/Markdown/src/Markdown.vue b/src/components/Markdown/src/Markdown.vue index cb37b86..4a22412 100644 --- a/src/components/Markdown/src/Markdown.vue +++ b/src/components/Markdown/src/Markdown.vue @@ -3,16 +3,7 @@ diff --git a/src/components/Preview/src/Preview.vue b/src/components/Preview/src/Preview.vue index f6f5d23..3bb0b14 100644 --- a/src/components/Preview/src/Preview.vue +++ b/src/components/Preview/src/Preview.vue @@ -31,12 +31,12 @@ height?: string | number; placeholder?: string | boolean; preview?: - | boolean - | { - visible?: boolean; - onVisibleChange?: (visible: boolean, prevVisible: boolean) => void; - getContainer: string | HTMLElement | (() => HTMLElement); - }; + | boolean + | { + visible?: boolean; + onVisibleChange?: (visible: boolean, prevVisible: boolean) => void; + getContainer: string | HTMLElement | (() => HTMLElement); + }; } type ImageItem = string | ImageProps; diff --git a/src/components/Preview/src/functional.ts b/src/components/Preview/src/functional.ts index bd97cd1..e4b27d6 100644 --- a/src/components/Preview/src/functional.ts +++ b/src/components/Preview/src/functional.ts @@ -1,18 +1,18 @@ -import type {Options, Props} from './typing'; +import type { Options, Props } from './typing'; import ImgPreview from './Functional.vue'; -import {isClient} from '/@/utils/is'; -import {createVNode, render} from 'vue'; +import { isClient } from '/@/utils/is'; +import { createVNode, render } from 'vue'; let instance: ReturnType | null = null; export function createImgPreview(options: Options) { - if (!isClient) return; - const propsData: Partial = {}; - const container = document.createElement('div'); - Object.assign(propsData, {show: true, index: 0, scaleStep: 100}, options); + if (!isClient) return; + const propsData: Partial = {}; + const container = document.createElement('div'); + Object.assign(propsData, { show: true, index: 0, scaleStep: 100 }, options); - instance = createVNode(ImgPreview, propsData); - render(instance, container); - document.body.appendChild(container); - return instance.component?.exposed; + instance = createVNode(ImgPreview, propsData); + render(instance, container); + document.body.appendChild(container); + return instance.component?.exposed; } diff --git a/src/components/Preview/src/typing.ts b/src/components/Preview/src/typing.ts index e0ffd80..bbb8a83 100644 --- a/src/components/Preview/src/typing.ts +++ b/src/components/Preview/src/typing.ts @@ -1,49 +1,49 @@ export interface Options { - show?: boolean; - imageList: string[]; - index?: number; - scaleStep?: number; - defaultWidth?: number; - maskClosable?: boolean; - rememberState?: boolean; - onImgLoad?: ({index: number, url: string, dom: HTMLImageElement}) => void; - onImgError?: ({index: number, url: string, dom: HTMLImageElement}) => void; + show?: boolean; + imageList: string[]; + index?: number; + scaleStep?: number; + defaultWidth?: number; + maskClosable?: boolean; + rememberState?: boolean; + onImgLoad?: ({ index: number, url: string, dom: HTMLImageElement }) => void; + onImgError?: ({ index: number, url: string, dom: HTMLImageElement }) => void; } export interface Props { - show: boolean; - instance: Props; - imageList: string[]; - index: number; - scaleStep: number; - defaultWidth: number; - maskClosable: boolean; - rememberState: boolean; + show: boolean; + instance: Props; + imageList: string[]; + index: number; + scaleStep: number; + defaultWidth: number; + maskClosable: boolean; + rememberState: boolean; } export interface PreviewActions { - resume: () => void; - close: () => void; - prev: () => void; - next: () => void; - setScale: (scale: number) => void; - setRotate: (rotate: number) => void; + resume: () => void; + close: () => void; + prev: () => void; + next: () => void; + setScale: (scale: number) => void; + setRotate: (rotate: number) => void; } export interface ImageProps { - alt?: string; - fallback?: string; - src: string; - width: string | number; - height?: string | number; - placeholder?: string | boolean; - preview?: - | boolean - | { + alt?: string; + fallback?: string; + src: string; + width: string | number; + height?: string | number; + placeholder?: string | boolean; + preview?: + | boolean + | { visible?: boolean; onVisibleChange?: (visible: boolean, prevVisible: boolean) => void; getContainer: string | HTMLElement | (() => HTMLElement); - }; + }; } export type ImageItem = string | ImageProps; diff --git a/src/components/Qrcode/src/Qrcode.vue b/src/components/Qrcode/src/Qrcode.vue index 74eaa6f..a8df59f 100644 --- a/src/components/Qrcode/src/Qrcode.vue +++ b/src/components/Qrcode/src/Qrcode.vue @@ -97,13 +97,13 @@ // 监听参数变化重新生成二维码 watch( - props, - () => { - createQrcode(); - }, - { - deep: true, - } + props, + () => { + createQrcode(); + }, + { + deep: true, + } ); return { wrapRef, download }; diff --git a/src/components/Qrcode/src/drawCanvas.ts b/src/components/Qrcode/src/drawCanvas.ts index 143ec5a..82aee5f 100644 --- a/src/components/Qrcode/src/drawCanvas.ts +++ b/src/components/Qrcode/src/drawCanvas.ts @@ -1,32 +1,32 @@ -import {toCanvas} from 'qrcode'; -import type {QRCodeRenderersOptions} from 'qrcode'; -import {RenderQrCodeParams, ContentType} from './typing'; -import {cloneDeep} from 'lodash-es'; +import { toCanvas } from 'qrcode'; +import type { QRCodeRenderersOptions } from 'qrcode'; +import { RenderQrCodeParams, ContentType } from './typing'; +import { cloneDeep } from 'lodash-es'; -export const renderQrCode = ({canvas, content, width = 0, options: params = {}}: RenderQrCodeParams) => { - const options = cloneDeep(params) - // 容错率,默认对内容少的二维码采用高容错率,内容多的二维码采用低容错率 - options.errorCorrectionLevel = options.errorCorrectionLevel || getErrorCorrectionLevel(content); +export const renderQrCode = ({ canvas, content, width = 0, options: params = {} }: RenderQrCodeParams) => { + const options = cloneDeep(params); + // 容错率,默认对内容少的二维码采用高容错率,内容多的二维码采用低容错率 + options.errorCorrectionLevel = options.errorCorrectionLevel || getErrorCorrectionLevel(content); - return getOriginWidth(content, options).then((_width: number) => { - options.scale = width === 0 ? undefined : (width / _width) * 4; - return toCanvas(canvas, content, options); - }); + return getOriginWidth(content, options).then((_width: number) => { + options.scale = width === 0 ? undefined : (width / _width) * 4; + return toCanvas(canvas, content, options); + }); }; // 得到原QrCode的大小,以便缩放得到正确的QrCode大小 function getOriginWidth(content: ContentType, options: QRCodeRenderersOptions) { - const _canvas = document.createElement('canvas'); - return toCanvas(_canvas, content, options).then(() => _canvas.width); + const _canvas = document.createElement('canvas'); + return toCanvas(_canvas, content, options).then(() => _canvas.width); } // 对于内容少的QrCode,增大容错率 function getErrorCorrectionLevel(content: ContentType) { - if (content.length > 36) { - return 'M'; - } else if (content.length > 16) { - return 'Q'; - } else { - return 'H'; - } + if (content.length > 36) { + return 'M'; + } else if (content.length > 16) { + return 'Q'; + } else { + return 'H'; + } } diff --git a/src/components/Qrcode/src/drawLogo.ts b/src/components/Qrcode/src/drawLogo.ts index 85a160f..dbfe292 100644 --- a/src/components/Qrcode/src/drawLogo.ts +++ b/src/components/Qrcode/src/drawLogo.ts @@ -7,14 +7,7 @@ export const drawLogo = ({ canvas, logo }: RenderQrCodeParams) => { }); } const canvasWidth = (canvas as HTMLCanvasElement).width; - const { - logoSize = 0.15, - bgColor = '#ffffff', - borderSize = 0.05, - crossOrigin, - borderRadius = 8, - logoRadius = 0, - } = logo as LogoType; + const { logoSize = 0.15, bgColor = '#ffffff', borderSize = 0.05, crossOrigin, borderRadius = 8, logoRadius = 0 } = logo as LogoType; const logoSrc: string = isString(logo) ? logo : logo.src; const logoWidth = canvasWidth * logoSize; diff --git a/src/components/Scrollbar/src/Scrollbar.vue b/src/components/Scrollbar/src/Scrollbar.vue index ec56780..3ea4a02 100644 --- a/src/components/Scrollbar/src/Scrollbar.vue +++ b/src/components/Scrollbar/src/Scrollbar.vue @@ -1,11 +1,6 @@ - \ No newline at end of file + diff --git a/src/components/jeecg/ExcelButton.vue b/src/components/jeecg/ExcelButton.vue index 352882f..98d5fec 100644 --- a/src/components/jeecg/ExcelButton.vue +++ b/src/components/jeecg/ExcelButton.vue @@ -1,87 +1,84 @@ - + diff --git a/src/components/jeecg/JVxeTable/hooks.ts b/src/components/jeecg/JVxeTable/hooks.ts index f2dd1d2..54c46fa 100644 --- a/src/components/jeecg/JVxeTable/hooks.ts +++ b/src/components/jeecg/JVxeTable/hooks.ts @@ -1,2 +1,2 @@ -export { useJVxeCompProps, useJVxeComponent } from './src/hooks/useJVxeComponent' -export { useResolveComponent } from './src/hooks/useData' +export { useJVxeCompProps, useJVxeComponent } from './src/hooks/useJVxeComponent'; +export { useResolveComponent } from './src/hooks/useData'; diff --git a/src/components/jeecg/JVxeTable/index.ts b/src/components/jeecg/JVxeTable/index.ts index 032b2ad..b288fbb 100644 --- a/src/components/jeecg/JVxeTable/index.ts +++ b/src/components/jeecg/JVxeTable/index.ts @@ -1,4 +1,4 @@ -export { default as JVxeTable } from './src/JVxeTable' -export { registerJVxeTable } from './src/install' -export { deleteComponent } from './src/componentMap' -export { registerComponent, registerAsyncComponent } from './src/utils/registerUtils' \ No newline at end of file +export { default as JVxeTable } from './src/JVxeTable'; +export { registerJVxeTable } from './src/install'; +export { deleteComponent } from './src/componentMap'; +export { registerComponent, registerAsyncComponent } from './src/utils/registerUtils'; diff --git a/src/components/jeecg/JVxeTable/src/JVxeTable.ts b/src/components/jeecg/JVxeTable/src/JVxeTable.ts index 2f2e755..8894206 100644 --- a/src/components/jeecg/JVxeTable/src/JVxeTable.ts +++ b/src/components/jeecg/JVxeTable/src/JVxeTable.ts @@ -1,14 +1,14 @@ -import { useSlots, defineComponent, getCurrentInstance, h } from 'vue' -import { vxeEmits, vxeProps } from './vxe.data' -import { useData, useRefs, useResolveComponent as rc } from './hooks/useData' -import { useColumns } from './hooks/useColumns' -import { useMethods } from './hooks/useMethods' -import { useDataSource } from './hooks/useDataSource' -import { useDragSort } from './hooks/useDragSort' -import { useRenderComponents } from './hooks/useRenderComponents' -import { useFinallyProps } from './hooks/useFinallyProps' -import { JVxeTableProps } from './types' -import './style/index.less' +import { useSlots, defineComponent, getCurrentInstance, h } from 'vue'; +import { vxeEmits, vxeProps } from './vxe.data'; +import { useData, useRefs, useResolveComponent as rc } from './hooks/useData'; +import { useColumns } from './hooks/useColumns'; +import { useMethods } from './hooks/useMethods'; +import { useDataSource } from './hooks/useDataSource'; +import { useDragSort } from './hooks/useDragSort'; +import { useRenderComponents } from './hooks/useRenderComponents'; +import { useFinallyProps } from './hooks/useFinallyProps'; +import { JVxeTableProps } from './types'; +import './style/index.less'; export default defineComponent({ name: 'JVxeTable', @@ -16,45 +16,57 @@ export default defineComponent({ props: vxeProps(), emits: [...vxeEmits], setup(props: JVxeTableProps, context) { - const instance = getCurrentInstance() - const refs = useRefs() - const slots = useSlots() - const data = useData(props) - const { methods, publicMethods, created } = useMethods(props, context, data, refs, instance) - created() - useColumns(props, data, methods, slots) - useDataSource(props, data, methods, refs) - useDragSort(props, methods) + const instance = getCurrentInstance(); + const refs = useRefs(); + const slots = useSlots(); + const data = useData(props); + const { methods, publicMethods, created } = useMethods(props, context, data, refs, instance); + created(); + useColumns(props, data, methods, slots); + useDataSource(props, data, methods, refs); + useDragSort(props, methods); // 最终传入到 template 里的 props - const finallyProps = useFinallyProps(props, data, methods) + const finallyProps = useFinallyProps(props, data, methods); // 渲染子组件 - const renderComponents = useRenderComponents(props, data, methods, slots) + const renderComponents = useRenderComponents(props, data, methods, slots); return { ...refs, ...publicMethods, ...finallyProps, ...renderComponents, vxeDataSource: data.vxeDataSource, - } + }; }, render() { - return h('div', { - style: this.$attrs.style, - }, h(rc('a-spin'), { - spinning: this.loading, - wrapperClassName: this.prefixCls, - }, { - default: () => [ - this.renderSubPopover(), - this.renderToolbar(), - this.renderToolbarAfterSlot(), - h(rc('vxe-grid'), { - ...this.vxeProps, - data: this.vxeDataSource, - }, this.$slots), - this.renderPagination(), - this.renderDetailsModal(), - ], - })) + return h( + 'div', + { + style: this.$attrs.style, + }, + h( + rc('a-spin'), + { + spinning: this.loading, + wrapperClassName: this.prefixCls, + }, + { + default: () => [ + this.renderSubPopover(), + this.renderToolbar(), + this.renderToolbarAfterSlot(), + h( + rc('vxe-grid'), + { + ...this.vxeProps, + data: this.vxeDataSource, + }, + this.$slots + ), + this.renderPagination(), + this.renderDetailsModal(), + ], + } + ) + ); }, -}) +}); diff --git a/src/components/jeecg/JVxeTable/src/componentMap.ts b/src/components/jeecg/JVxeTable/src/componentMap.ts index 71a22e4..ab2707a 100644 --- a/src/components/jeecg/JVxeTable/src/componentMap.ts +++ b/src/components/jeecg/JVxeTable/src/componentMap.ts @@ -1,36 +1,30 @@ -import type { JVxeVueComponent } from './types' -import { JVxeTypes } from './types/JVxeTypes' +import type { JVxeVueComponent } from './types'; +import { JVxeTypes } from './types/JVxeTypes'; -import JVxeSlotCell from './components/cells/JVxeSlotCell' -import JVxeNormalCell from './components/cells/JVxeNormalCell.vue' -import JVxeDragSortCell from './components/cells/JVxeDragSortCell.vue' +import JVxeSlotCell from './components/cells/JVxeSlotCell'; +import JVxeNormalCell from './components/cells/JVxeNormalCell.vue'; +import JVxeDragSortCell from './components/cells/JVxeDragSortCell.vue'; -import JVxeInputCell from './components/cells/JVxeInputCell.vue' -import JVxeDateCell from './components/cells/JVxeDateCell.vue' -import JVxeTimeCell from './components/cells/JVxeTimeCell.vue' -import JVxeSelectCell from './components/cells/JVxeSelectCell.vue' -import JVxeRadioCell from './components/cells/JVxeRadioCell.vue' -import JVxeCheckboxCell from './components/cells/JVxeCheckboxCell.vue' -import JVxeUploadCell from './components/cells/JVxeUploadCell.vue' +import JVxeInputCell from './components/cells/JVxeInputCell.vue'; +import JVxeDateCell from './components/cells/JVxeDateCell.vue'; +import JVxeTimeCell from './components/cells/JVxeTimeCell.vue'; +import JVxeSelectCell from './components/cells/JVxeSelectCell.vue'; +import JVxeRadioCell from './components/cells/JVxeRadioCell.vue'; +import JVxeCheckboxCell from './components/cells/JVxeCheckboxCell.vue'; +import JVxeUploadCell from './components/cells/JVxeUploadCell.vue'; // import { TagsInputCell, TagsSpanCell } from './components/cells/JVxeTagsCell.vue' -import JVxeProgressCell from './components/cells/JVxeProgressCell.vue' -import JVxeTextareaCell from './components/cells/JVxeTextareaCell.vue' +import JVxeProgressCell from './components/cells/JVxeProgressCell.vue'; +import JVxeTextareaCell from './components/cells/JVxeTextareaCell.vue'; // import JVxeDepartSelectCell from './components/cells/JVxeDepartSelectCell.vue' // import JVxeUserSelectCell from './components/cells/JVxeUserSelectCell.vue' -const componentMap = new Map() +const componentMap = new Map(); /** span 组件结尾 */ -export const spanEnds: string = ':span' +export const spanEnds: string = ':span'; /** 定义不能用于注册的关键字 */ -export const excludeKeywords: Array = [ - JVxeTypes.hidden, - JVxeTypes.rowNumber, - JVxeTypes.rowCheckbox, - JVxeTypes.rowRadio, - JVxeTypes.rowExpand, -] +export const excludeKeywords: Array = [JVxeTypes.hidden, JVxeTypes.rowNumber, JVxeTypes.rowCheckbox, JVxeTypes.rowRadio, JVxeTypes.rowExpand]; /** * 注册组件 @@ -41,47 +35,46 @@ export const excludeKeywords: Array = [ */ export function addComponent(type: JVxeTypes, component: JVxeVueComponent, spanComponent?: JVxeVueComponent) { if (excludeKeywords.includes(type)) { - throw new Error(`【addComponent】不能使用"${type}"作为组件的name,因为这是关键字。`) + throw new Error(`【addComponent】不能使用"${type}"作为组件的name,因为这是关键字。`); } if (componentMap.has(type)) { - throw new Error(`【addComponent】组件"${type}"已存在`) + throw new Error(`【addComponent】组件"${type}"已存在`); } - componentMap.set(type, component) + componentMap.set(type, component); if (spanComponent) { - componentMap.set(type + spanEnds, spanComponent) + componentMap.set(type + spanEnds, spanComponent); } } export function deleteComponent(type: JVxeTypes) { - componentMap.delete(type) - componentMap.delete(type + spanEnds) + componentMap.delete(type); + componentMap.delete(type + spanEnds); } /** 定义内置自定义组件 */ export function definedComponent() { - addComponent(JVxeTypes.slot, JVxeSlotCell) - addComponent(JVxeTypes.normal, JVxeNormalCell) - addComponent(JVxeTypes.rowDragSort, JVxeDragSortCell) + addComponent(JVxeTypes.slot, JVxeSlotCell); + addComponent(JVxeTypes.normal, JVxeNormalCell); + addComponent(JVxeTypes.rowDragSort, JVxeDragSortCell); - addComponent(JVxeTypes.input, JVxeInputCell) - addComponent(JVxeTypes.inputNumber, JVxeInputCell) - addComponent(JVxeTypes.radio, JVxeRadioCell) - addComponent(JVxeTypes.checkbox, JVxeCheckboxCell) - addComponent(JVxeTypes.select, JVxeSelectCell) - addComponent(JVxeTypes.selectSearch, JVxeSelectCell) // 下拉搜索 - addComponent(JVxeTypes.selectMultiple, JVxeSelectCell) // 下拉多选 - addComponent(JVxeTypes.date, JVxeDateCell) - addComponent(JVxeTypes.datetime, JVxeDateCell) - addComponent(JVxeTypes.time, JVxeTimeCell) - addComponent(JVxeTypes.upload, JVxeUploadCell) - addComponent(JVxeTypes.textarea, JVxeTextareaCell) + addComponent(JVxeTypes.input, JVxeInputCell); + addComponent(JVxeTypes.inputNumber, JVxeInputCell); + addComponent(JVxeTypes.radio, JVxeRadioCell); + addComponent(JVxeTypes.checkbox, JVxeCheckboxCell); + addComponent(JVxeTypes.select, JVxeSelectCell); + addComponent(JVxeTypes.selectSearch, JVxeSelectCell); // 下拉搜索 + addComponent(JVxeTypes.selectMultiple, JVxeSelectCell); // 下拉多选 + addComponent(JVxeTypes.date, JVxeDateCell); + addComponent(JVxeTypes.datetime, JVxeDateCell); + addComponent(JVxeTypes.time, JVxeTimeCell); + addComponent(JVxeTypes.upload, JVxeUploadCell); + addComponent(JVxeTypes.textarea, JVxeTextareaCell); // addComponent(JVxeTypes.tags, TagsInputCell, TagsSpanCell) - addComponent(JVxeTypes.progress, JVxeProgressCell) + addComponent(JVxeTypes.progress, JVxeProgressCell); // addComponent(JVxeTypes.departSelect, JVxeDepartSelectCell) // addComponent(JVxeTypes.userSelect, JVxeUserSelectCell) - } -export { componentMap } \ No newline at end of file +export { componentMap }; diff --git a/src/components/jeecg/JVxeTable/src/components/JVxeDetailsModal.vue b/src/components/jeecg/JVxeTable/src/components/JVxeDetailsModal.vue index 1c791eb..99225f4 100644 --- a/src/components/jeecg/JVxeTable/src/components/JVxeDetailsModal.vue +++ b/src/components/jeecg/JVxeTable/src/components/JVxeDetailsModal.vue @@ -1,83 +1,76 @@ \ No newline at end of file + .fade-enter, + .fade-leave-to { + opacity: 0; + } + diff --git a/src/components/jeecg/JVxeTable/src/components/JVxeReloadEffect.ts b/src/components/jeecg/JVxeTable/src/components/JVxeReloadEffect.ts index 3f0d8c4..7dd3276 100644 --- a/src/components/jeecg/JVxeTable/src/components/JVxeReloadEffect.ts +++ b/src/components/jeecg/JVxeTable/src/components/JVxeReloadEffect.ts @@ -1,6 +1,6 @@ -import { defineComponent, h, ref, watch } from 'vue' -import { randomString } from '/@/utils/common/compUtils' -import '../style/reload-effect.less' +import { defineComponent, h, ref, watch } from 'vue'; +import { randomString } from '/@/utils/common/compUtils'; +import '../style/reload-effect.less'; // 修改数据特效 export default defineComponent({ @@ -12,47 +12,54 @@ export default defineComponent({ emits: ['effectBegin', 'effectEnd'], setup(props, { emit }) { // vNode: null, - const innerEffect = ref(props.effect) + const innerEffect = ref(props.effect); // 应付同时多个特效 - const effectIdx = ref(0) - const effectList = ref([]) + const effectIdx = ref(0); + const effectList = ref([]); - watch(() => props.effect, () => innerEffect.value = props.effect) - watch(() => props.vNode, (_vNode, old) => { - if (props.effect && old != null) { - let topLayer = renderSpan(old, 'top') - effectList.value.push(topLayer) - } - }, { deep: true, immediate: true }) + watch( + () => props.effect, + () => (innerEffect.value = props.effect) + ); + watch( + () => props.vNode, + (_vNode, old) => { + if (props.effect && old != null) { + let topLayer = renderSpan(old, 'top'); + effectList.value.push(topLayer); + } + }, + { deep: true, immediate: true } + ); // 条件渲染内容 span function renderVNode() { if (props.vNode == null) { - return null + return null; } - let bottom = renderSpan(props.vNode, 'bottom') + let bottom = renderSpan(props.vNode, 'bottom'); // 启用了特效,并且有旧数据,就渲染特效顶层 if (innerEffect.value && effectList.value.length > 0) { - emit('effectBegin') + emit('effectBegin'); // 1.4s 以后关闭特效 window.setTimeout(() => { - let item = effectList.value[effectIdx.value] + let item = effectList.value[effectIdx.value]; if (item && item.elm) { // 特效结束后,展示先把 display 设为 none,而不是直接删掉该元素, // 目的是为了防止页面重新渲染,导致动画重置 - item.elm.style.display = 'none' + item.elm.style.display = 'none'; } // 当所有的层级动画都结束时,再删掉所有元素 if (++effectIdx.value === effectList.value.length) { - innerEffect.value = false - effectIdx.value = 0 - effectList.value = [] - emit('effectEnd') + innerEffect.value = false; + effectIdx.value = 0; + effectList.value = []; + emit('effectEnd'); } - }, 1400) - return [effectList.value, bottom] + }, 1400); + return [effectList.value, bottom]; } else { - return bottom + return bottom; } } @@ -62,16 +69,21 @@ export default defineComponent({ key: layer + effectIdx.value + randomString(6), class: ['j-vxe-reload-effect-span', `layer-${layer}`], style: {}, - } + }; if (layer === 'top') { // 最新渲染的在下面 - options.style['z-index'] = (9999 - effectIdx.value) + options.style['z-index'] = 9999 - effectIdx.value; } - return h('span', options, [vNode]) + return h('span', options, [vNode]); } - return () => h('div', { - class: ['j-vxe-reload-effect-box'], - }, [renderVNode()]) + return () => + h( + 'div', + { + class: ['j-vxe-reload-effect-box'], + }, + [renderVNode()] + ); }, -}) \ No newline at end of file +}); diff --git a/src/components/jeecg/JVxeTable/src/components/JVxeSubPopover.vue b/src/components/jeecg/JVxeTable/src/components/JVxeSubPopover.vue index c0c9855..b0b5907 100644 --- a/src/components/jeecg/JVxeTable/src/components/JVxeSubPopover.vue +++ b/src/components/jeecg/JVxeTable/src/components/JVxeSubPopover.vue @@ -1,198 +1,197 @@ \ No newline at end of file + .fade-enter, + .fade-leave-to { + opacity: 0; + } + diff --git a/src/components/jeecg/JVxeTable/src/components/JVxeToolbar.vue b/src/components/jeecg/JVxeTable/src/components/JVxeToolbar.vue index d6446a6..c38a266 100644 --- a/src/components/jeecg/JVxeTable/src/components/JVxeToolbar.vue +++ b/src/components/jeecg/JVxeTable/src/components/JVxeToolbar.vue @@ -4,38 +4,25 @@ @@ -44,85 +31,84 @@ \ No newline at end of file + // 切换展开收起 + function toggleCollapse() { + collapsed.value = !collapsed.value; + } + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeCheckboxCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeCheckboxCell.vue index 541e3fb..683abfb 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeCheckboxCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeCheckboxCell.vue @@ -1,125 +1,116 @@ \ No newline at end of file + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeDateCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeDateCell.vue index 3b354a2..658dcb4 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeDateCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeDateCell.vue @@ -1,75 +1,66 @@ \ No newline at end of file + // 【组件增强】注释详见:JVxeComponent.Enhanced + enhanced: { + aopEvents: { + editActived({ $event, row, column }) { + dispatchEvent({ + $event, + row, + column, + props: this.props, + instance: this, + className: '.ant-calendar-picker', + isClick: false, + handler: (el) => el.children[0].click(), + }); + }, + }, + } as JVxeComponent.EnhancedPartial, + }); + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeDragSortCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeDragSortCell.vue index db4366e..c32efe3 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeDragSortCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeDragSortCell.vue @@ -1,14 +1,14 @@ \ No newline at end of file + + .vxe-table--fixed-wrapper { + .j-vxe-drag-box { + .app-iconify { + cursor: pointer; + } + } + } + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeInputCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeInputCell.vue index 78eefca..5f3aa83 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeInputCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeInputCell.vue @@ -1,83 +1,77 @@ \ No newline at end of file + enhanced: { + installOptions: { + autofocus: '.ant-input', + }, + getValue(value, ctx) { + if (ctx?.props?.type === JVxeTypes.inputNumber && isString(value)) { + if (NumberRegExp.test(value)) { + return Number.parseFloat(value); + } + } + return value; + }, + } as JVxeComponent.EnhancedPartial, + }); + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeNormalCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeNormalCell.vue index be84b00..d6107f1 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeNormalCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeNormalCell.vue @@ -1,55 +1,53 @@ - \ No newline at end of file + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeProgressCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeProgressCell.vue index ebc6ca9..135eb97 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeProgressCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeProgressCell.vue @@ -1,57 +1,52 @@ diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeRadioCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeRadioCell.vue index e25f116..2fdd473 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeRadioCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeRadioCell.vue @@ -1,75 +1,58 @@ - \ No newline at end of file + diff --git a/src/components/jeecg/JVxeTable/src/components/cells/JVxeSelectCell.vue b/src/components/jeecg/JVxeTable/src/components/cells/JVxeSelectCell.vue index c90ae67..d8a82f6 100644 --- a/src/components/jeecg/JVxeTable/src/components/cells/JVxeSelectCell.vue +++ b/src/components/jeecg/JVxeTable/src/components/cells/JVxeSelectCell.vue @@ -1,7 +1,7 @@ \ No newline at end of file + export default defineComponent({ + name: 'JVxeUploadCell', + components: { Icon, Dropdown, LoadingOutlined }, + props: useJVxeCompProps(), + setup(props: JVxeComponent.Props) { + const setup = useJVxeUploadCell(props); + return { ...setup }; + }, + // 【组件增强】注释详见::JVxeComponent.Enhanced + enhanced: { + switches: { visible: true }, + getValue: (value) => fileGetValue(value), + setValue: (value) => fileSetValue(value), + } as JVxeComponent.EnhancedPartial, + }); + diff --git a/src/components/jeecg/JVxeTable/src/hooks/cells/useJVxeUploadCell.ts b/src/components/jeecg/JVxeTable/src/hooks/cells/useJVxeUploadCell.ts index e79f570..707d89d 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/cells/useJVxeUploadCell.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/cells/useJVxeUploadCell.ts @@ -1,9 +1,9 @@ -import { ref, computed, watch } from 'vue' +import { ref, computed, watch } from 'vue'; -import { getToken } from '/@/utils/auth' -import { getFileAccessHttpUrl } from '/@/utils/common/compUtils' -import { JVxeComponent } from '../../types/JVxeComponent' -import { useJVxeComponent } from '../useJVxeComponent' +import { getToken } from '/@/utils/auth'; +import { getFileAccessHttpUrl } from '/@/utils/common/compUtils'; +import { JVxeComponent } from '../../types/JVxeComponent'; +import { useJVxeComponent } from '../useJVxeComponent'; /** * use 公共上传组件 @@ -11,41 +11,45 @@ import { useJVxeComponent } from '../useJVxeComponent' * @param options 组件选项,token:默认是否传递token,action:默认上传路径,multiple:是否允许多文件 */ export function useJVxeUploadCell(props: JVxeComponent.Props, options?) { - const setup = useJVxeComponent(props) - const { innerValue, originColumn, handleChangeCommon } = setup + const setup = useJVxeComponent(props); + const { innerValue, originColumn, handleChangeCommon } = setup; - const innerFile = ref(null) + const innerFile = ref(null); /** upload headers */ const uploadHeaders = computed(() => { - let headers = {} - if ((originColumn.value.token ?? (options?.token ?? false)) === true) { - headers['X-Access-Token'] = getToken() + let headers = {}; + if ((originColumn.value.token ?? options?.token ?? false) === true) { + headers['X-Access-Token'] = getToken(); } - return headers - }) + return headers; + }); /** 上传请求地址 */ const uploadAction = computed(() => { if (!originColumn.value.action) { - return options?.action ?? '' + return options?.action ?? ''; } else { - return originColumn.value.action + return originColumn.value.action; } - }) - const hasFile = computed(() => innerFile.value != null) - const responseName = computed(() => originColumn.value.responseName ?? 'message') + }); + const hasFile = computed(() => innerFile.value != null); + const responseName = computed(() => originColumn.value.responseName ?? 'message'); - watch(innerValue, (val) => { - if (val) { - innerFile.value = val - } else { - innerFile.value = null - } - }, { immediate: true }) + watch( + innerValue, + (val) => { + if (val) { + innerFile.value = val; + } else { + innerFile.value = null; + } + }, + { immediate: true } + ); function handleChangeUpload(info) { - let { file } = info + let { file } = info; let value = { name: file.name, type: file.type, @@ -53,50 +57,50 @@ export function useJVxeUploadCell(props: JVxeComponent.Props, options?) { status: file.status, percent: file.percent, path: innerFile.value?.path ?? '', - } + }; if (file.response) { - value['responseName'] = file.response[responseName.value] + value['responseName'] = file.response[responseName.value]; } - let paths: string[] = [] + let paths: string[] = []; if (options?.multiple && innerFile.value && innerFile.value.path) { - paths = innerFile.value.path.split(',') + paths = innerFile.value.path.split(','); } if (file.status === 'done') { if (typeof file.response.success === 'boolean') { if (file.response.success) { - paths.push(file.response[responseName.value]) - value['path'] = paths.join(',') - handleChangeCommon(value) + paths.push(file.response[responseName.value]); + value['path'] = paths.join(','); + handleChangeCommon(value); } else { - value['status'] = 'error' - value['message'] = file.response.message || '未知错误' + value['status'] = 'error'; + value['message'] = file.response.message || '未知错误'; } } else { // 考虑到如果设置action上传路径为非jeecg-boot后台,可能不会返回 success 属性的情况,就默认为成功 - paths.push(file.response[responseName.value]) - value['path'] = paths.join(',') - handleChangeCommon(value) + paths.push(file.response[responseName.value]); + value['path'] = paths.join(','); + handleChangeCommon(value); } } else if (file.status === 'error') { - value['message'] = file.response.message || '未知错误' + value['message'] = file.response.message || '未知错误'; } - innerFile.value = value + innerFile.value = value; } function handleClickDownloadFile() { - let { url, path } = innerFile.value || {} + let { url, path } = innerFile.value || {}; if (!url || url.length === 0) { if (path && path.length > 0) { - url = getFileAccessHttpUrl(path.split(',')[0]) + url = getFileAccessHttpUrl(path.split(',')[0]); } } if (url) { - window.open(url) + window.open(url); } } function handleClickDeleteFile() { - handleChangeCommon(null) + handleChangeCommon(null); } return { @@ -109,25 +113,25 @@ export function useJVxeUploadCell(props: JVxeComponent.Props, options?) { handleChangeUpload, handleClickDownloadFile, handleClickDeleteFile, - } + }; } export function fileGetValue(value) { if (value && value.path) { - return value.path + return value.path; } - return value + return value; } export function fileSetValue(value) { if (value) { - let first = value.split(',')[0] - let name = first.substring(first.lastIndexOf('/') + 1) + let first = value.split(',')[0]; + let name = first.substring(first.lastIndexOf('/') + 1); return { name: name, path: value, status: 'done', - } + }; } - return value -} \ No newline at end of file + return value; +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useColumns.ts b/src/components/jeecg/JVxeTable/src/hooks/useColumns.ts index 1f0638b..f4f9b40 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useColumns.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useColumns.ts @@ -1,58 +1,58 @@ -import type { JVxeColumn, JVxeDataProps, JVxeTableProps } from '../types' -import { computed, nextTick } from 'vue' -import { isArray, isEmpty, isPromise } from '/@/utils/is' -import { cloneDeep } from 'lodash-es' -import { JVxeTypePrefix, JVxeTypes } from '../types/JVxeTypes' -import { initDictOptions } from '/@/utils/dict' -import { pushIfNotExist } from '/@/utils/common/compUtils' -import { getEnhanced } from '../utils/enhancedUtils' -import { isRegistered } from '../utils/registerUtils' -import { JVxeComponent } from '../types/JVxeComponent' -import { useValidateRules } from './useValidateRules' -import { JVxeTableMethods } from '../types' +import type { JVxeColumn, JVxeDataProps, JVxeTableProps } from '../types'; +import { computed, nextTick } from 'vue'; +import { isArray, isEmpty, isPromise } from '/@/utils/is'; +import { cloneDeep } from 'lodash-es'; +import { JVxeTypePrefix, JVxeTypes } from '../types/JVxeTypes'; +import { initDictOptions } from '/@/utils/dict'; +import { pushIfNotExist } from '/@/utils/common/compUtils'; +import { getEnhanced } from '../utils/enhancedUtils'; +import { isRegistered } from '../utils/registerUtils'; +import { JVxeComponent } from '../types/JVxeComponent'; +import { useValidateRules } from './useValidateRules'; +import { JVxeTableMethods } from '../types'; // handle 方法参数 export interface HandleArgs { - props: JVxeTableProps, - slots: any, - data: JVxeDataProps, - methods: JVxeTableMethods, - col?: JVxeColumn, - columns: JVxeColumn[], - renderOptions?: any, - enhanced?: JVxeComponent.Enhanced, + props: JVxeTableProps; + slots: any; + data: JVxeDataProps; + methods: JVxeTableMethods; + col?: JVxeColumn; + columns: JVxeColumn[]; + renderOptions?: any; + enhanced?: JVxeComponent.Enhanced; } export function useColumns(props: JVxeTableProps, data: JVxeDataProps, methods: JVxeTableMethods, slots) { data.vxeColumns = computed(() => { - let columns: JVxeColumn[] = [] + let columns: JVxeColumn[] = []; if (isArray(props.columns)) { // handle 方法参数 - const args: HandleArgs = { props, slots, data, methods, columns } - let seqColumn, selectionColumn, expandColumn, dragSortColumn + const args: HandleArgs = { props, slots, data, methods, columns }; + let seqColumn, selectionColumn, expandColumn, dragSortColumn; props.columns.forEach((column: JVxeColumn) => { // 排除未授权的列 1 = 显示/隐藏; 2 = 禁用 - let auth = methods.getColAuth(column.key) + let auth = methods.getColAuth(column.key); if (auth?.type == '1' && !auth.isAuth) { - return + return; } else if (auth?.type == '2' && !auth.isAuth) { - column.disabled = true + column.disabled = true; } // type 不填,默认为 normal if (column.type == null || isEmpty(column.type)) { - column.type = JVxeTypes.normal + column.type = JVxeTypes.normal; } - let col: JVxeColumn = cloneDeep(column) + let col: JVxeColumn = cloneDeep(column); // 处理隐藏列 if (col.type === JVxeTypes.hidden) { - return handleInnerColumn(args, col, handleHiddenColumn) + return handleInnerColumn(args, col, handleHiddenColumn); } // 组件未注册,自动设置为 normal if (!isRegistered(col.type)) { - col.type = JVxeTypes.normal + col.type = JVxeTypes.normal; } - args.enhanced = getEnhanced(col.type) - args.col = col + args.enhanced = getEnhanced(col.type); + args.col = col; args.renderOptions = { bordered: props.bordered, disabled: props.disabled, @@ -60,59 +60,59 @@ export function useColumns(props: JVxeTableProps, data: JVxeDataProps, methods: isDisabledRow: methods.isDisabledRow, listeners: { trigger: (name, event) => methods.trigger(name, event), - valueChange: event => methods.trigger('valueChange', event), + valueChange: (event) => methods.trigger('valueChange', event), /** 重新排序行 */ - rowResort: event => { - methods.doSort(event.oldIndex, event.newIndex) - methods.trigger('dragged', event) + rowResort: (event) => { + methods.doSort(event.oldIndex, event.newIndex); + methods.trigger('dragged', event); }, /** 在当前行下面插入一行 */ - rowInsertDown: rowIndex => methods.insertRows({}, rowIndex + 1), + rowInsertDown: (rowIndex) => methods.insertRows({}, rowIndex + 1), }, - } + }; if (col.type === JVxeTypes.rowNumber) { - seqColumn = col - columns.push(col) + seqColumn = col; + columns.push(col); } else if (col.type === JVxeTypes.rowRadio || col.type === JVxeTypes.rowCheckbox) { - selectionColumn = col - columns.push(col) + selectionColumn = col; + columns.push(col); } else if (col.type === JVxeTypes.rowExpand) { - expandColumn = col - columns.push(col) + expandColumn = col; + columns.push(col); } else if (col.type === JVxeTypes.rowDragSort) { - dragSortColumn = col - columns.push(col) + dragSortColumn = col; + columns.push(col); } else { - col.params = column - handlerCol(args) + col.params = column; + handlerCol(args); } - }) - handleInnerColumn(args, seqColumn, handleSeqColumn) - handleInnerColumn(args, selectionColumn, handleSelectionColumn) - handleInnerColumn(args, expandColumn, handleExpandColumn) - handleInnerColumn(args, dragSortColumn, handleDragSortColumn, true) + }); + handleInnerColumn(args, seqColumn, handleSeqColumn); + handleInnerColumn(args, selectionColumn, handleSelectionColumn); + handleInnerColumn(args, expandColumn, handleExpandColumn); + handleInnerColumn(args, dragSortColumn, handleDragSortColumn, true); } - return columns - }) + return columns; + }); } /** 处理内置列 */ function handleInnerColumn(args: HandleArgs, col: JVxeColumn, handler: (args: HandleArgs) => void, assign?: boolean) { - let renderOptions = col?.editRender || col?.cellRender + let renderOptions = col?.editRender || col?.cellRender; return handler({ ...args, col: col, renderOptions: assign ? Object.assign({}, args.renderOptions, renderOptions) : renderOptions, - }) + }); } /** * 处理隐藏列 */ function handleHiddenColumn({ col, columns }: HandleArgs) { - delete col!.type - col!.visible = false - columns.push(col!) + delete col!.type; + col!.visible = false; + columns.push(col!); } /** @@ -127,11 +127,11 @@ function handleSeqColumn({ props, col, columns }: HandleArgs) { width: 60, fixed: 'left', align: 'center', - } + }; if (col) { - Object.assign(col, column) + Object.assign(col, column); } else { - columns.unshift(column as any) + columns.unshift(column as any); } } } @@ -142,20 +142,20 @@ function handleSeqColumn({ props, col, columns }: HandleArgs) { function handleSelectionColumn({ props, data, col, columns }: HandleArgs) { // 判断是否开启了可选择行 if (props.rowSelection) { - let width = 40 + let width = 40; if (data.statistics.has && !props.rowExpand && !props.dragSort) { - width = 60 + width = 60; } let column = { type: props.rowSelectionType, width: width, fixed: 'left', align: 'center', - } + }; if (col) { - Object.assign(col, column) + Object.assign(col, column); } else { - columns.unshift(column as any) + columns.unshift(column as any); } } } @@ -166,9 +166,9 @@ function handleSelectionColumn({ props, data, col, columns }: HandleArgs) { function handleExpandColumn({ props, data, col, columns }: HandleArgs) { // 是否可展开行 if (props.rowExpand) { - let width = 40 + let width = 40; if (data.statistics.has && !props.dragSort) { - width = 60 + width = 60; } let column = { type: 'expand', @@ -177,11 +177,11 @@ function handleExpandColumn({ props, data, col, columns }: HandleArgs) { fixed: 'left', align: 'center', slots: { content: 'expandContent' }, - } + }; if (col) { - Object.assign(col, column) + Object.assign(col, column); } else { - columns.unshift(column as any) + columns.unshift(column as any); } } } @@ -190,66 +190,66 @@ function handleExpandColumn({ props, data, col, columns }: HandleArgs) { function handleDragSortColumn({ props, data, col, columns, renderOptions }: HandleArgs) { // 是否可拖动排序 if (props.dragSort) { - let width = 40 + let width = 40; if (data.statistics.has) { - width = 60 + width = 60; } let column: any = { title: '', width: width, fixed: 'left', align: 'center', - } + }; let cellRender = { name: JVxeTypePrefix + JVxeTypes.rowDragSort, sortKey: props.sortKey, - } + }; if (renderOptions) { - column.cellRender = Object.assign(renderOptions, cellRender) + column.cellRender = Object.assign(renderOptions, cellRender); } else { - column.cellRender = cellRender + column.cellRender = cellRender; } if (col) { - Object.assign(col, column) + Object.assign(col, column); } else { - columns.unshift(column) + columns.unshift(column); } } } /** 处理自定义组件列 */ function handlerCol(args: HandleArgs) { - const { props, col, columns, enhanced } = args - if (!col) return - let { type } = col - col.field = col.key - delete col.type - let renderName = 'cellRender' + const { props, col, columns, enhanced } = args; + if (!col) return; + let { type } = col; + col.field = col.key; + delete col.type; + let renderName = 'cellRender'; // 渲染选项 - let $renderOptions: any = { name: JVxeTypePrefix + type } + let $renderOptions: any = { name: JVxeTypePrefix + type }; if (enhanced?.switches.editRender) { if (!(enhanced.switches.visible || props.alwaysEdit)) { - renderName = 'editRender' + renderName = 'editRender'; } // $renderOptions.type = (enhanced.switches.visible || props.alwaysEdit) ? 'visible' : 'default' } - col[renderName] = $renderOptions + col[renderName] = $renderOptions; - handleDict(args) - handleRules(args) - handleStatistics(args) - handleSlots(args) - handleLinkage(args) - handleReloadEffect(args) + handleDict(args); + handleRules(args); + handleStatistics(args); + handleSlots(args); + handleLinkage(args); + handleReloadEffect(args); if (col.editRender) { - Object.assign(col.editRender, args.renderOptions) + Object.assign(col.editRender, args.renderOptions); } if (col.cellRender) { - Object.assign(col.cellRender, args.renderOptions) + Object.assign(col.cellRender, args.renderOptions); } - columns.push(col) + columns.push(col); } /** @@ -261,25 +261,25 @@ async function handleDict({ col, methods }: HandleArgs) { try { // 查询字典 if (!isPromise(col.params.optionsPromise)) { - col.params.optionsPromise = new Promise(async resolve => { - const dictOptions: any = await initDictOptions(col.params.dictCode) - let options = col.params.options ?? [] - dictOptions.forEach(dict => { + col.params.optionsPromise = new Promise(async (resolve) => { + const dictOptions: any = await initDictOptions(col.params.dictCode); + let options = col.params.options ?? []; + dictOptions.forEach((dict) => { // 过滤重复数据 - if (options.findIndex(o => o.value === dict.value) === -1) { - options.push(dict) + if (options.findIndex((o) => o.value === dict.value) === -1) { + options.push(dict); } - }) - resolve(options) - }) + }); + resolve(options); + }); } - col.params.options = await col.params.optionsPromise - await nextTick() - await methods.getXTable().updateData() + col.params.options = await col.params.optionsPromise; + await nextTick(); + await methods.getXTable().updateData(); } catch (e) { - console.group(`[JVxeTable] 查询字典 "${col.params.dictCode}" 时发生异常!`) - console.warn(e) - console.groupEnd() + console.group(`[JVxeTable] 查询字典 "${col.params.dictCode}" 时发生异常!`); + console.warn(e); + console.groupEnd(); } } } @@ -289,7 +289,7 @@ async function handleDict({ col, methods }: HandleArgs) { */ function handleRules(args: HandleArgs) { if (isArray(args.col?.validateRules)) { - useValidateRules(args) + useValidateRules(args); } } @@ -299,15 +299,15 @@ function handleRules(args: HandleArgs) { function handleStatistics({ col, data }: HandleArgs) { // sum = 求和、average = 平均值 if (col && isArray(col.statistics)) { - data.statistics.has = true - col.statistics.forEach(item => { + data.statistics.has = true; + col.statistics.forEach((item) => { if (!isEmpty(item)) { - let arr = data.statistics[(item as string).toLowerCase()] + let arr = data.statistics[(item as string).toLowerCase()]; if (isArray(arr)) { - pushIfNotExist(arr, col.key) + pushIfNotExist(arr, col.key); } } - }) + }); } } @@ -318,7 +318,7 @@ function handleSlots({ slots, col, renderOptions }: HandleArgs) { // slot 组件特殊处理 if (col && col.params.type === JVxeTypes.slot) { if (!isEmpty(col.slotName) && slots.hasOwnProperty(col.slotName)) { - renderOptions.slot = slots[col.slotName] + renderOptions.slot = slots[col.slotName]; } } } @@ -334,7 +334,7 @@ function handleLinkage({ data, col, renderOptions, methods }: HandleArgs) { getLinkageOptionsAsync: methods.getLinkageOptionsAsync, getLinkageOptionsSibling: methods.getLinkageOptionsSibling, handleLinkageSelectChange: methods.handleLinkageSelectChange, - } + }; } } } @@ -343,13 +343,13 @@ function handleReloadEffect({ props, data, renderOptions }: HandleArgs) { renderOptions.reloadEffect = { enabled: props.reloadEffect, getMap() { - return data.reloadEffectRowKeysMap + return data.reloadEffectRowKeysMap; }, isEffect(rowId) { - return data.reloadEffectRowKeysMap[rowId] === true + return data.reloadEffectRowKeysMap[rowId] === true; }, removeEffect(rowId) { - return data.reloadEffectRowKeysMap[rowId] = false + return (data.reloadEffectRowKeysMap[rowId] = false); }, - } + }; } diff --git a/src/components/jeecg/JVxeTable/src/hooks/useData.ts b/src/components/jeecg/JVxeTable/src/hooks/useData.ts index 0e3f10e..a9e666f 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useData.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useData.ts @@ -1,12 +1,12 @@ -import { ref, reactive, provide, resolveComponent } from 'vue' -import { useDesign } from '/@/hooks/web/useDesign' -import { JVxeDataProps, JVxeRefs, JVxeTableProps } from '../types' -import { VxeGridInstance } from 'vxe-table' -import { randomString } from '/@/utils/common/compUtils' +import { ref, reactive, provide, resolveComponent } from 'vue'; +import { useDesign } from '/@/hooks/web/useDesign'; +import { JVxeDataProps, JVxeRefs, JVxeTableProps } from '../types'; +import { VxeGridInstance } from 'vxe-table'; +import { randomString } from '/@/utils/common/compUtils'; export function useData(props: JVxeTableProps): JVxeDataProps { - const { prefixCls } = useDesign('j-vxe-table') - provide('prefixCls', prefixCls) + const { prefixCls } = useDesign('j-vxe-table'); + provide('prefixCls', prefixCls); return { prefixCls: prefixCls, caseId: `j-vxe-${randomString(8)}`, @@ -41,7 +41,7 @@ export function useData(props: JVxeTableProps): JVxeDataProps { // }, radioConfig: { highlight: true }, checkboxConfig: { highlight: true }, - mouseConfig: {selected: false}, + mouseConfig: { selected: false }, keyboardConfig: { // 删除键功能 isDel: false, @@ -71,7 +71,7 @@ export function useData(props: JVxeTableProps): JVxeDataProps { innerEditRules: {}, innerLinkageConfig: new Map(), reloadEffectRowKeysMap: reactive({}), - } + }; } export function useRefs(): JVxeRefs { @@ -79,10 +79,10 @@ export function useRefs(): JVxeRefs { gridRef: ref(), subPopoverRef: ref(), detailsModalRef: ref(), - } + }; } export function useResolveComponent(...t: any[]): any { // @ts-ignore - return resolveComponent(...t) -} \ No newline at end of file + return resolveComponent(...t); +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts b/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts index cf7c92b..59816a8 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useDataSource.ts @@ -1,32 +1,36 @@ -import { nextTick, watch } from 'vue' -import { JVxeDataProps, JVxeRefs, JVxeTableMethods } from '../types' -import { cloneDeep } from 'lodash-es' +import { nextTick, watch } from 'vue'; +import { JVxeDataProps, JVxeRefs, JVxeTableMethods } from '../types'; +import { cloneDeep } from 'lodash-es'; export function useDataSource(props, data: JVxeDataProps, methods: JVxeTableMethods, refs: JVxeRefs) { - watch(() => [props.dataSource, props.disabledRows], async () => { - data.disabledRowIds = [] - data.vxeDataSource.value = cloneDeep(props.dataSource) - data.vxeDataSource.value.forEach(row => { - // 判断是否是禁用行 - if (methods.isDisabledRow(row)) { - data.disabledRowIds.push(row.id) - } - // 处理联动回显数据 - methods.handleLinkageBackData(row) - }) - await waitRef(refs.gridRef) - methods.recalcSortNumber() - }, { immediate: true }) + watch( + () => [props.dataSource, props.disabledRows], + async () => { + data.disabledRowIds = []; + data.vxeDataSource.value = cloneDeep(props.dataSource); + data.vxeDataSource.value.forEach((row) => { + // 判断是否是禁用行 + if (methods.isDisabledRow(row)) { + data.disabledRowIds.push(row.id); + } + // 处理联动回显数据 + methods.handleLinkageBackData(row); + }); + await waitRef(refs.gridRef); + methods.recalcSortNumber(); + }, + { immediate: true } + ); } function waitRef($ref) { return new Promise((resolve) => { (function next() { if ($ref.value) { - resolve($ref) + resolve($ref); } else { - nextTick(() => next()) + nextTick(() => next()); } - })() - }) -} \ No newline at end of file + })(); + }); +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts b/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts index ac5191b..a697100 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useDragSort.ts @@ -1,64 +1,64 @@ -import { onMounted, onUnmounted, nextTick } from 'vue' -import { JVxeTableMethods, JVxeTableProps } from '/@/components/jeecg/JVxeTable/src/types' -import Sortable from 'sortablejs' +import { onMounted, onUnmounted, nextTick } from 'vue'; +import { JVxeTableMethods, JVxeTableProps } from '/@/components/jeecg/JVxeTable/src/types'; +import Sortable from 'sortablejs'; export function useDragSort(props: JVxeTableProps, methods: JVxeTableMethods) { if (props.dragSort) { - let sortable2: Sortable - let initTime: any + let sortable2: Sortable; + let initTime: any; onMounted(() => { // 加载完成之后再绑定拖动事件 - initTime = setTimeout(createSortable, 300) - }) + initTime = setTimeout(createSortable, 300); + }); onUnmounted(() => { - clearTimeout(initTime) + clearTimeout(initTime); if (sortable2) { - sortable2.destroy() + sortable2.destroy(); } - }) + }); function createSortable() { - let xTable = methods.getXTable() + let xTable = methods.getXTable(); // let dom = xTable.$el.querySelector('.vxe-table--fixed-wrapper .vxe-table--body tbody') - let dom = xTable.$el.querySelector('.body--wrapper>.vxe-table--body tbody') - let startChildren = [] + let dom = xTable.$el.querySelector('.body--wrapper>.vxe-table--body tbody'); + let startChildren = []; sortable2 = Sortable.create(dom as HTMLElement, { handle: '.drag-btn', direction: 'vertical', animation: 300, onStart(e) { - let from = e.from + let from = e.from; // @ts-ignore - startChildren = [...from.children] + startChildren = [...from.children]; }, onEnd(e) { - let oldIndex = e.oldIndex as number - let newIndex = e.newIndex as number + let oldIndex = e.oldIndex as number; + let newIndex = e.newIndex as number; if (oldIndex === newIndex) { - return + return; } - let from = e.from - let element = startChildren[oldIndex] - let target = null + let from = e.from; + let element = startChildren[oldIndex]; + let target = null; if (oldIndex > newIndex) { // 向上移动 if (oldIndex + 1 < startChildren.length) { - target = startChildren[oldIndex + 1] + target = startChildren[oldIndex + 1]; } } else { // 向下移动 - target = startChildren[oldIndex + 1] + target = startChildren[oldIndex + 1]; } - from.removeChild(element) - from.insertBefore(element, target) + from.removeChild(element); + from.insertBefore(element, target); nextTick(() => { - methods.doSort(oldIndex, newIndex) - methods.trigger('dragged', { oldIndex, newIndex }) - }) + methods.doSort(oldIndex, newIndex); + methods.trigger('dragged', { oldIndex, newIndex }); + }); }, - }) + }); } } -} \ No newline at end of file +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useFinallyProps.ts b/src/components/jeecg/JVxeTable/src/hooks/useFinallyProps.ts index 0a29e97..11db9f7 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useFinallyProps.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useFinallyProps.ts @@ -1,19 +1,19 @@ -import { unref, computed } from 'vue' -import { merge } from 'lodash-es' -import { isArray } from '/@/utils/is' -import { useAttrs } from '/@/hooks/core/useAttrs' -import {useKeyboardEdit} from '../hooks/useKeyboardEdit' -import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types' +import { unref, computed } from 'vue'; +import { merge } from 'lodash-es'; +import { isArray } from '/@/utils/is'; +import { useAttrs } from '/@/hooks/core/useAttrs'; +import { useKeyboardEdit } from '../hooks/useKeyboardEdit'; +import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types'; export function useFinallyProps(props: JVxeTableProps, data: JVxeDataProps, methods: JVxeTableMethods) { - const attrs = useAttrs() + const attrs = useAttrs(); // vxe 键盘操作配置 - const {keyboardEditConfig} = useKeyboardEdit(props) + const { keyboardEditConfig } = useKeyboardEdit(props); // vxe 最终 editRules - const vxeEditRules = computed(() => merge({}, props.editRules, data.innerEditRules)) + const vxeEditRules = computed(() => merge({}, props.editRules, data.innerEditRules)); // vxe 最终 events const vxeEvents = computed(() => { - let listeners = { ...unref(attrs) } + let listeners = { ...unref(attrs) }; let events = { onScroll: methods.handleVxeScroll, onCellClick: methods.handleCellClick, @@ -22,54 +22,62 @@ export function useFinallyProps(props: JVxeTableProps, data: JVxeDataProps, meth onRadioChange: methods.handleVxeRadioChange, onCheckboxAll: methods.handleVxeCheckboxAll, onCheckboxChange: methods.handleVxeCheckboxChange, - } + }; // 用户传递的事件,进行合并操作 - Object.keys(listeners).forEach(key => { - let listen = listeners[key] + Object.keys(listeners).forEach((key) => { + let listen = listeners[key]; if (events.hasOwnProperty(key)) { if (isArray(listen)) { - listen.push(events[key]) + listen.push(events[key]); } else { - listen = [events[key], listen] + listen = [events[key], listen]; } } - events[key] = listen - }) - return events - }) + events[key] = listen; + }); + return events; + }); // vxe 最终 props const vxeProps = computed(() => { - return merge({}, data.defaultVxeProps, { - showFooter: data.statistics.has, - }, unref(attrs), { - ref: 'gridRef', - size: props.size, - loading: false, - disabled: props.disabled, - columns: unref(data.vxeColumns), - editRules: unref(vxeEditRules), - height: props.height === 'auto' ? null : props.height, - maxHeight: props.maxHeight, - border: props.bordered, - footerMethod: methods.handleFooterMethod, - // 展开行配置 - expandConfig: { - toggleMethod: methods.handleExpandToggleMethod, + return merge( + {}, + data.defaultVxeProps, + { + showFooter: data.statistics.has, }, - // 可编辑配置 - editConfig: { - activeMethod: methods.handleActiveMethod, + unref(attrs), + { + ref: 'gridRef', + size: props.size, + loading: false, + disabled: props.disabled, + columns: unref(data.vxeColumns), + editRules: unref(vxeEditRules), + height: props.height === 'auto' ? null : props.height, + maxHeight: props.maxHeight, + border: props.bordered, + footerMethod: methods.handleFooterMethod, + // 展开行配置 + expandConfig: { + toggleMethod: methods.handleExpandToggleMethod, + }, + // 可编辑配置 + editConfig: { + activeMethod: methods.handleActiveMethod, + }, + radioConfig: { + checkMethod: methods.handleCheckMethod, + }, + checkboxConfig: { + checkMethod: methods.handleCheckMethod, + }, }, - radioConfig: { - checkMethod: methods.handleCheckMethod, - }, - checkboxConfig: { - checkMethod: methods.handleCheckMethod, - }, - }, unref(vxeEvents), unref(keyboardEditConfig)) - }) + unref(vxeEvents), + unref(keyboardEditConfig) + ); + }); return { vxeProps, prefixCls: data.prefixCls, - } -} \ No newline at end of file + }; +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts b/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts index 2cb6c19..f615b21 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useJVxeComponent.ts @@ -1,10 +1,10 @@ -import { computed, nextTick, ref, unref, watch } from 'vue' -import { propTypes } from '/@/utils/propTypes' -import { getEnhanced, replaceProps, vModel } from '../utils/enhancedUtils' -import { JVxeRenderType } from '../types/JVxeTypes' -import { isBoolean, isFunction, isObject, isPromise } from '/@/utils/is' -import { JVxeComponent } from '../types/JVxeComponent' -import { filterDictText } from '/@/utils/dict/JDictSelectUtil' +import { computed, nextTick, ref, unref, watch } from 'vue'; +import { propTypes } from '/@/utils/propTypes'; +import { getEnhanced, replaceProps, vModel } from '../utils/enhancedUtils'; +import { JVxeRenderType } from '../types/JVxeTypes'; +import { isBoolean, isFunction, isObject, isPromise } from '/@/utils/is'; +import { JVxeComponent } from '../types/JVxeComponent'; +import { filterDictText } from '/@/utils/dict/JDictSelectUtil'; export function useJVxeCompProps() { return { @@ -16,66 +16,66 @@ export function useJVxeCompProps() { params: propTypes.object, // 渲染自定义选项 renderOptions: propTypes.object, - } + }; } export function useJVxeComponent(props: JVxeComponent.Props) { - const value = computed(() => props.params.row[props.params.column.property]) - const innerValue = ref(value.value) - const row = computed(() => props.params.row) - const rows = computed(() => props.params.data) - const column = computed(() => props.params.column) + const value = computed(() => props.params.row[props.params.column.property]); + const innerValue = ref(value.value); + const row = computed(() => props.params.row); + const rows = computed(() => props.params.data); + const column = computed(() => props.params.column); // 用户配置的原始 column - const originColumn = computed(() => column.value.params) - const rowIndex = computed(() => props.params.$rowIndex) - const columnIndex = computed(() => props.params.columnIndex) + const originColumn = computed(() => column.value.params); + const rowIndex = computed(() => props.params.$rowIndex); + const columnIndex = computed(() => props.params.columnIndex); // 表格数据长度 - const fullDataLength = computed(() => props.params.$table.internalData.tableFullData.length) + const fullDataLength = computed(() => props.params.$table.internalData.tableFullData.length); // 是否正在滚动中 - const scrolling = computed(() => !!props.renderOptions.scrolling) + const scrolling = computed(() => !!props.renderOptions.scrolling); const cellProps = computed(() => { - let renderOptions = props.renderOptions - let col = originColumn.value + let renderOptions = props.renderOptions; + let col = originColumn.value; - let cellProps = {} + let cellProps = {}; // 输入占位符 - cellProps['placeholder'] = replaceProps(col, col.placeholder) + cellProps['placeholder'] = replaceProps(col, col.placeholder); // 解析props if (isObject(col.props)) { - Object.keys(col.props).forEach(key => { - cellProps[key] = replaceProps(col, col.props[key]) - }) + Object.keys(col.props).forEach((key) => { + cellProps[key] = replaceProps(col, col.props[key]); + }); } // 判断是否是禁用的列 - cellProps['disabled'] = (isBoolean(col['disabled']) ? col['disabled'] : cellProps['disabled']) + cellProps['disabled'] = isBoolean(col['disabled']) ? col['disabled'] : cellProps['disabled']; // 判断是否禁用行 if (renderOptions.isDisabledRow(row.value)) { - cellProps['disabled'] = true + cellProps['disabled'] = true; } // 判断是否禁用所有组件 if (renderOptions.disabled === true) { - cellProps['disabled'] = true + cellProps['disabled'] = true; } - return cellProps - }) + return cellProps; + }); const listeners = computed(() => { - let listeners = Object.assign({}, (props.renderOptions.listeners || {})) + let listeners = Object.assign({}, props.renderOptions.listeners || {}); // 默认change事件 if (!listeners.change) { listeners.change = async (event) => { - vModel(event.value, row, column) - await nextTick() + vModel(event.value, row, column); + await nextTick(); // 处理 change 事件相关逻辑(例如校验) - props.params.$table.updateStatus(props.params) - } + props.params.$table.updateStatus(props.params); + }; } - return listeners - }) + return listeners; + }); const context = { innerValue, row, @@ -89,39 +89,43 @@ export function useJVxeComponent(props: JVxeComponent.Props) { scrolling, handleChangeCommon, handleBlurCommon, - } - const ctx = { props, context } + }; + const ctx = { props, context }; // 获取组件增强 - const enhanced = getEnhanced(props.type) + const enhanced = getEnhanced(props.type); - watch(value, (newValue) => { - // 验证值格式 - let getValue = enhanced.getValue(newValue, ctx) - if (newValue !== getValue) { - // 值格式不正确,重新赋值 - newValue = getValue - vModel(newValue, row, column) - } - innerValue.value = enhanced.setValue(newValue, ctx) - // 判断是否启用翻译 - if (props.renderType === JVxeRenderType.spaner && enhanced.translate.enabled === true) { - if (isFunction(enhanced.translate.handler)) { - let res = enhanced.translate.handler(newValue, ctx) - // 异步翻译,可解决字典查询慢的问题 - if (isPromise(res)) { - res.then(v => innerValue.value = v) - } else { - innerValue.value = res + watch( + value, + (newValue) => { + // 验证值格式 + let getValue = enhanced.getValue(newValue, ctx); + if (newValue !== getValue) { + // 值格式不正确,重新赋值 + newValue = getValue; + vModel(newValue, row, column); + } + innerValue.value = enhanced.setValue(newValue, ctx); + // 判断是否启用翻译 + if (props.renderType === JVxeRenderType.spaner && enhanced.translate.enabled === true) { + if (isFunction(enhanced.translate.handler)) { + let res = enhanced.translate.handler(newValue, ctx); + // 异步翻译,可解决字典查询慢的问题 + if (isPromise(res)) { + res.then((v) => (innerValue.value = v)); + } else { + innerValue.value = res; + } } } - } - }, { immediate: true }) + }, + { immediate: true } + ); /** 通用处理 change 事件 */ function handleChangeCommon($value) { - let getValue = enhanced.getValue($value, ctx) - trigger('change', { value: getValue }) + let getValue = enhanced.getValue($value, ctx); + trigger('change', { value: getValue }); // 触发valueChange事件 parentTrigger('valueChange', { type: props.type, @@ -130,12 +134,12 @@ export function useJVxeComponent(props: JVxeComponent.Props) { col: originColumn.value, rowIndex: rowIndex.value, columnIndex: columnIndex.value, - }) + }); } /** 通用处理 blur 事件 */ function handleBlurCommon(value) { - trigger('blur', { value }) + trigger('blur', { value }); } /** @@ -145,44 +149,44 @@ export function useJVxeComponent(props: JVxeComponent.Props) { * @param args 其他附带参数 */ function trigger(name, event?, args: any[] = []) { - let listener = listeners.value[name] + let listener = listeners.value[name]; if (isFunction(listener)) { if (isObject(event)) { - event = packageEvent(name, event) + event = packageEvent(name, event); } - listener(event, ...args) + listener(event, ...args); } } function parentTrigger(name, event, args: any[] = []) { - args.unshift(packageEvent(name, event)) - trigger('trigger', name, args) + args.unshift(packageEvent(name, event)); + trigger('trigger', name, args); } function packageEvent(name, event: any = {}) { - event.row = row.value - event.column = column.value + event.row = row.value; + event.column = column.value; // online增强参数兼容 - event.column['key'] = column.value['property'] + event.column['key'] = column.value['property']; // event.cellTarget = this if (!event.type) { - event.type = name + event.type = name; } if (!event.cellType) { - event.cellType = props.type + event.cellType = props.type; } // 是否校验表单,默认为true if (isBoolean(event.validate)) { - event.validate = true + event.validate = true; } - return event + return event; } return { ...context, enhanced, trigger, - } + }; } /** @@ -202,10 +206,8 @@ export function useDefaultEnhanced(): JVxeComponent.EnhancedPartial { visible: false, }, aopEvents: { - editActived() { - }, - editClosed() { - }, + editActived() {}, + editClosed() {}, activeMethod: () => true, }, translate: { @@ -213,14 +215,14 @@ export function useDefaultEnhanced(): JVxeComponent.EnhancedPartial { handler(value, ctx) { // 默认翻译方法 if (ctx) { - return filterDictText(unref(ctx.context.column).params.options, value) + return filterDictText(unref(ctx.context.column).params.options, value); } else { - return value + return value; } }, }, - getValue: value => value, - setValue: value => value, + getValue: (value) => value, + setValue: (value) => value, createValue: (defaultValue) => defaultValue, - } as JVxeComponent.Enhanced + } as JVxeComponent.Enhanced; } diff --git a/src/components/jeecg/JVxeTable/src/hooks/useKeyboardEdit.ts b/src/components/jeecg/JVxeTable/src/hooks/useKeyboardEdit.ts index a63e943..a6bb9b9 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useKeyboardEdit.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useKeyboardEdit.ts @@ -1,9 +1,9 @@ /* -* JVxeTable 键盘操作 -*/ -import type {VxeTablePropTypes} from 'vxe-table' -import type {JVxeTableProps} from '../types' -import {computed} from 'vue' + * JVxeTable 键盘操作 + */ +import type { VxeTablePropTypes } from 'vxe-table'; +import type { JVxeTableProps } from '../types'; +import { computed } from 'vue'; /** * JVxeTable 键盘操作 @@ -12,15 +12,15 @@ import {computed} from 'vue' */ export function useKeyboardEdit(props: JVxeTableProps) { // 是否开启了键盘操作 - const enabledKeyboard = computed(() => props.keyboardEdit ?? false) + const enabledKeyboard = computed(() => props.keyboardEdit ?? false); // 重写 keyboardConfig const keyboardConfig: VxeTablePropTypes.KeyboardConfig = { - editMethod({row, column, $table}) { + editMethod({ row, column, $table }) { // 重写默认的覆盖式,改为追加式 - $table.setActiveCell(row, column) - return true + $table.setActiveCell(row, column); + return true; }, - } + }; // 键盘操作配置 const keyboardEditConfig = computed(() => { return { @@ -28,10 +28,10 @@ export function useKeyboardEdit(props: JVxeTableProps) { selected: enabledKeyboard.value, }, keyboardConfig, - } - }) + }; + }); return { keyboardEditConfig, - } + }; } diff --git a/src/components/jeecg/JVxeTable/src/hooks/useLinkage.ts b/src/components/jeecg/JVxeTable/src/hooks/useLinkage.ts index fe349c6..f5916d1 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useLinkage.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useLinkage.ts @@ -1,46 +1,50 @@ -import { watch } from 'vue' -import { isFunction, isPromise, isArray } from '/@/utils/is' -import { JVxeColumn, JVxeDataProps, JVxeTableProps, JVxeLinkageConfig } from '../types' +import { watch } from 'vue'; +import { isFunction, isPromise, isArray } from '/@/utils/is'; +import { JVxeColumn, JVxeDataProps, JVxeTableProps, JVxeLinkageConfig } from '../types'; /** * 多级联动 */ export function useLinkage(props: JVxeTableProps, data: JVxeDataProps, methods) { - // 整理多级联动配置 - watch(() => props.linkageConfig, (linkageConfig: JVxeLinkageConfig[]) => { - data.innerLinkageConfig.clear() - if (isArray(linkageConfig) && linkageConfig.length > 0) { - linkageConfig.forEach(config => { - let keys = getLinkageKeys(config.key, []) - // 多个key共享一个,引用地址 - let configItem = { - ...config, keys, - optionsMap: new Map(), - } - keys.forEach(k => data.innerLinkageConfig.set(k, configItem)) - }) - } - }, { immediate: true }) + watch( + () => props.linkageConfig, + (linkageConfig: JVxeLinkageConfig[]) => { + data.innerLinkageConfig.clear(); + if (isArray(linkageConfig) && linkageConfig.length > 0) { + linkageConfig.forEach((config) => { + let keys = getLinkageKeys(config.key, []); + // 多个key共享一个,引用地址 + let configItem = { + ...config, + keys, + optionsMap: new Map(), + }; + keys.forEach((k) => data.innerLinkageConfig.set(k, configItem)); + }); + } + }, + { immediate: true } + ); // 获取联动的key顺序 function getLinkageKeys(key: string, keys: string[]): string[] { - let col = props.columns?.find((col: JVxeColumn) => col.key === key) as JVxeColumn + let col = props.columns?.find((col: JVxeColumn) => col.key === key) as JVxeColumn; if (col) { - keys.push(col.key) + keys.push(col.key); // 寻找下级 if (col.linkageKey) { - return getLinkageKeys(col.linkageKey, keys) + return getLinkageKeys(col.linkageKey, keys); } } - return keys + return keys; } // 处理联动回显数据 function handleLinkageBackData(row) { if (data.innerLinkageConfig.size > 0) { for (let configItem of data.innerLinkageConfig.values()) { - autoSetLinkageOptionsByData(row, '', configItem, 0) + autoSetLinkageOptionsByData(row, '', configItem, 0); } } } @@ -48,72 +52,72 @@ export function useLinkage(props: JVxeTableProps, data: JVxeDataProps, methods) /** 【多级联动】获取同级联动下拉选项 */ function getLinkageOptionsSibling(row, col, config, request) { // 如果当前列不是顶级列 - let key = '' + let key = ''; if (col.key !== config.key) { // 就找出联动上级列 - let idx = config.keys.findIndex(k => col.key === k) - let parentKey = config.keys[idx - 1] - key = row[parentKey] + let idx = config.keys.findIndex((k) => col.key === k); + let parentKey = config.keys[idx - 1]; + key = row[parentKey]; // 如果联动上级列没有选择数据,就直接返回空数组 if (key === '' || key == null) { - return [] + return []; } } else { - key = 'root' + key = 'root'; } - let options = config.optionsMap.get(key) + let options = config.optionsMap.get(key); if (!Array.isArray(options)) { if (request) { - let parent = key === 'root' ? '' : key - return getLinkageOptionsAsync(config, parent) + let parent = key === 'root' ? '' : key; + return getLinkageOptionsAsync(config, parent); } else { - options = [] + options = []; } } - return options + return options; } /** 【多级联动】获取联动下拉选项(异步) */ function getLinkageOptionsAsync(config, parent) { - return new Promise(resolve => { - let key = parent ? parent : 'root' - let options + return new Promise((resolve) => { + let key = parent ? parent : 'root'; + let options; if (config.optionsMap.has(key)) { - options = config.optionsMap.get(key) + options = config.optionsMap.get(key); if (isPromise(options)) { - options.then(opt => { - config.optionsMap.set(key, opt) - resolve(opt) - }) + options.then((opt) => { + config.optionsMap.set(key, opt); + resolve(opt); + }); } else { - resolve(options) + resolve(options); } } else if (isFunction(config.requestData)) { // 调用requestData方法,通过传入parent来获取子级 // noinspection JSVoidFunctionReturnValueUsed,TypeScriptValidateJSTypes - let promise = config.requestData(parent) - config.optionsMap.set(key, promise) - promise.then(opt => { - config.optionsMap.set(key, opt) - resolve(opt) - }) + let promise = config.requestData(parent); + config.optionsMap.set(key, promise); + promise.then((opt) => { + config.optionsMap.set(key, opt); + resolve(opt); + }); } else { - resolve([]) + resolve([]); } - }) + }); } // 【多级联动】 用于回显数据,自动填充 optionsMap function autoSetLinkageOptionsByData(data, parent, config, level) { if (level === 0) { - getLinkageOptionsAsync(config, '') + getLinkageOptionsAsync(config, ''); } else { - getLinkageOptionsAsync(config, parent) + getLinkageOptionsAsync(config, parent); } if (config.keys.length - 1 > level) { - let value = data[config.keys[level]] + let value = data[config.keys[level]]; if (value) { - autoSetLinkageOptionsByData(data, value, config, level + 1) + autoSetLinkageOptionsByData(data, value, config, level + 1); } } } @@ -121,14 +125,14 @@ export function useLinkage(props: JVxeTableProps, data: JVxeDataProps, methods) // 【多级联动】联动组件change时,清空下级组件 function handleLinkageSelectChange(row, col, config, value) { if (col.linkageKey) { - getLinkageOptionsAsync(config, value) - let idx = config.keys.findIndex(k => k === col.key) - let values = {} + getLinkageOptionsAsync(config, value); + let idx = config.keys.findIndex((k) => k === col.key); + let values = {}; for (let i = idx; i < config.keys.length; i++) { - values[config.keys[i]] = '' + values[config.keys[i]] = ''; } // 清空后几列的数据 - methods.setValues([{ rowKey: row.id, values }]) + methods.setValues([{ rowKey: row.id, values }]); } } @@ -137,5 +141,5 @@ export function useLinkage(props: JVxeTableProps, data: JVxeDataProps, methods) getLinkageOptionsSibling, handleLinkageSelectChange, handleLinkageBackData, - } -} \ No newline at end of file + }; +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useMethods.ts b/src/components/jeecg/JVxeTable/src/hooks/useMethods.ts index 6a7a95a..001c32a 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useMethods.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useMethods.ts @@ -1,23 +1,23 @@ -import XEUtils from 'xe-utils' -import { simpleDebounce } from '/@/utils/common/compUtils' -import { JVxeDataProps, JVxeRefs, JVxeTableProps, JVxeTypes } from '../types' -import { getEnhanced } from '../utils/enhancedUtils' -import { VxeTableInstance, VxeTablePrivateMethods } from 'vxe-table' -import { cloneDeep } from 'lodash-es' -import { isArray, isEmpty, isNull, isString } from '/@/utils/is' -import { useLinkage } from './useLinkage' -import { useWebSocket } from './useWebSocket' -import { getPrefix, getJVxeAuths } from '../utils/authUtils' +import XEUtils from 'xe-utils'; +import { simpleDebounce } from '/@/utils/common/compUtils'; +import { JVxeDataProps, JVxeRefs, JVxeTableProps, JVxeTypes } from '../types'; +import { getEnhanced } from '../utils/enhancedUtils'; +import { VxeTableInstance, VxeTablePrivateMethods } from 'vxe-table'; +import { cloneDeep } from 'lodash-es'; +import { isArray, isEmpty, isNull, isString } from '/@/utils/is'; +import { useLinkage } from './useLinkage'; +import { useWebSocket } from './useWebSocket'; +import { getPrefix, getJVxeAuths } from '../utils/authUtils'; export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, refs: JVxeRefs, instance) { - let xTableTemp: VxeTableInstance & VxeTablePrivateMethods + let xTableTemp: VxeTableInstance & VxeTablePrivateMethods; function getXTable() { if (!xTableTemp) { // !. 为 typescript 的非空断言 - xTableTemp = refs.gridRef.value!.getRefMaps().refTable.value + xTableTemp = refs.gridRef.value!.getRefMaps().refTable.value; } - return xTableTemp + return xTableTemp; } // noinspection JSUnusedGlobalSymbols @@ -47,64 +47,64 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, isDisabledRow, recalcDisableRows, rowResort, - } + }; // 多级联动 - const linkageMethods = useLinkage(props, data, hookMethods) + const linkageMethods = useLinkage(props, data, hookMethods); // WebSocket 无痕刷新 - const socketMethods = useWebSocket(props, data, hookMethods) + const socketMethods = useWebSocket(props, data, hookMethods); // 可显式供外部调用的方法 const publicMethods = { ...hookMethods, ...linkageMethods, ...socketMethods, - } + }; /** 监听vxe滚动条位置 */ function handleVxeScroll(event) { - let { scroll } = data + let { scroll } = data; // 记录滚动条的位置 - scroll.top = event.scrollTop - scroll.left = event.scrollLeft + scroll.top = event.scrollTop; + scroll.left = event.scrollLeft; - refs.subPopoverRef.value?.close() - data.scrolling.value = true - closeScrolling() + refs.subPopoverRef.value?.close(); + data.scrolling.value = true; + closeScrolling(); } // 当手动勾选单选时触发的事件 function handleVxeRadioChange(event) { - let row = event.$table.getRadioRecord() - data.selectedRows.value = row ? [row] : [] - handleSelectChange('radio', data.selectedRows.value, event) + let row = event.$table.getRadioRecord(); + data.selectedRows.value = row ? [row] : []; + handleSelectChange('radio', data.selectedRows.value, event); } // 当手动勾选全选时触发的事件 function handleVxeCheckboxAll(event) { - data.selectedRows.value = event.$table.getCheckboxRecords() - handleSelectChange('checkbox-all', data.selectedRows.value, event) + data.selectedRows.value = event.$table.getCheckboxRecords(); + handleSelectChange('checkbox-all', data.selectedRows.value, event); } // 当手动勾选并且值发生改变时触发的事件 function handleVxeCheckboxChange(event) { - data.selectedRows.value = event.$table.getCheckboxRecords() - handleSelectChange('checkbox', data.selectedRows.value, event) + data.selectedRows.value = event.$table.getCheckboxRecords(); + handleSelectChange('checkbox', data.selectedRows.value, event); } // 行选择change事件 function handleSelectChange(type, selectedRows, $event) { - let action + let action; if (type === 'radio') { - action = 'selected' + action = 'selected'; } else if (type === 'checkbox') { - action = selectedRows.includes($event.row) ? 'selected' : 'unselected' + action = selectedRows.includes($event.row) ? 'selected' : 'unselected'; } else { - action = 'selected-all' + action = 'selected-all'; } - data.selectedRowIds.value = selectedRows.map(row => row.id) + data.selectedRowIds.value = selectedRows.map((row) => row.id); trigger('selectRowChange', { type: type, action: action, @@ -112,45 +112,45 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, row: $event.row, selectedRows: data.selectedRows.value, selectedRowIds: data.selectedRowIds.value, - }) + }); } // 点击单元格时触发的事件 function handleCellClick(event) { - let { row, column, $event, $table } = event + let { row, column, $event, $table } = event; // 点击了可编辑的 if (column.editRender) { - refs.subPopoverRef.value?.close() - return + refs.subPopoverRef.value?.close(); + return; } // 显示详细信息 if (column.params?.showDetails) { - refs.detailsModalRef.value?.open(event) + refs.detailsModalRef.value?.open(event); } else if (refs.subPopoverRef.value) { - refs.subPopoverRef.value.toggle(event) + refs.subPopoverRef.value.toggle(event); } else if (props.clickSelectRow) { - let className = $event.target.className || '' - className = isString(className) ? className : className.toString() + let className = $event.target.className || ''; + className = isString(className) ? className : className.toString(); // 点击的是expand,不做处理 if (className.includes('vxe-table--expand-btn')) { - return + return; } // 点击的是checkbox,不做处理 if (className.includes('vxe-checkbox--icon') || className.includes('vxe-cell--checkbox')) { - return + return; } // 点击的是radio,不做处理 if (className.includes('vxe-radio--icon') || className.includes('vxe-cell--radio')) { - return + return; } if (props.rowSelectionType === 'radio') { - $table.setRadioRow(row) - handleVxeRadioChange(event) + $table.setRadioRow(row); + handleVxeRadioChange(event); } else { - $table.toggleCheckboxRow(row) - handleVxeCheckboxChange(event) + $table.toggleCheckboxRow(row); + handleVxeCheckboxChange(event); } } } @@ -158,42 +158,42 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, // 单元格被激活编辑时会触发该事件 function handleEditActived({ column }) { // 执行增强 - getEnhanced(column.params.type).aopEvents.editActived!.apply(instance, arguments as any) + getEnhanced(column.params.type).aopEvents.editActived!.apply(instance, arguments as any); } // 单元格编辑状态下被关闭时会触发该事件 function handleEditClosed({ column }) { // 执行增强 - getEnhanced(column.params.type).aopEvents.editClosed!.apply(instance, arguments as any) + getEnhanced(column.params.type).aopEvents.editClosed!.apply(instance, arguments as any); } // 返回值决定行是否可选中 function handleCheckMethod({ row }) { if (props.disabled) { - return false + return false; } - return !data.disabledRowIds.includes(row.id) + return !data.disabledRowIds.includes(row.id); } // 返回值决定单元格是否可以编辑 function handleActiveMethod({ row, column }) { let flag = (() => { if (props.disabled) { - return false + return false; } if (data.disabledRowIds.includes(row.id)) { - return false + return false; } if (column.params?.disabled) { - return false + return false; } // 执行增强 - return getEnhanced(column.params.type).aopEvents.activeMethod!.apply(instance, arguments as any) ?? true - })() + return getEnhanced(column.params.type).aopEvents.activeMethod!.apply(instance, arguments as any) ?? true; + })(); if (!flag) { - getXTable().clearActived() + getXTable().clearActived(); } - return flag + return flag; } /** @@ -203,157 +203,161 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, */ function isDisabledRow(row, force = true) { if (!force) { - return !data.disabledRowIds.includes(row.id) + return !data.disabledRowIds.includes(row.id); } if (props.disabledRows == null || isEmpty(props.disabledRows)) { - return false + return false; } - let disabled: boolean = false - let keys: string[] = Object.keys(props.disabledRows) + let disabled: boolean = false; + let keys: string[] = Object.keys(props.disabledRows); for (const key of keys) { // 判断是否有该属性 if (row.hasOwnProperty(key)) { - let temp: any = props.disabledRows![key] + let temp: any = props.disabledRows![key]; // 禁用规则可以是一个数组 if (isArray(temp)) { - disabled = temp.includes(row[key]) + disabled = temp.includes(row[key]); } else { - disabled = (temp === row[key]) + disabled = temp === row[key]; } if (disabled) { - break + break; } } } - return disabled + return disabled; } // 重新计算禁用行 function recalcDisableRows() { - let xTable = getXTable() - data.disabledRowIds = [] - const { tableFullData } = xTable.internalData - tableFullData.forEach(row => { + let xTable = getXTable(); + data.disabledRowIds = []; + const { tableFullData } = xTable.internalData; + tableFullData.forEach((row) => { // 判断是否是禁用行 if (isDisabledRow(row)) { - data.disabledRowIds.push(row.id) + data.disabledRowIds.push(row.id); } - }) - xTable.updateData() + }); + xTable.updateData(); } // 返回值决定是否允许展开、收起行 function handleExpandToggleMethod({ expanded }) { - return !(expanded && props.disabled) + return !(expanded && props.disabled); } // 设置 data.scrolling 防抖模式 const closeScrolling = simpleDebounce(function () { - data.scrolling.value = false - }, 100) + data.scrolling.value = false; + }, 100); /** 表尾数据处理方法,用于显示统计信息 */ function handleFooterMethod({ columns, data: $data }) { - const { statistics } = data - let footers: any[] = [] + const { statistics } = data; + let footers: any[] = []; if (statistics.has) { if (statistics.sum.length > 0) { - footers.push(getFooterStatisticsMap({ - columns: columns, - title: '合计', - checks: statistics.sum, - method: (column) => XEUtils.sum($data, column.property), - })) + footers.push( + getFooterStatisticsMap({ + columns: columns, + title: '合计', + checks: statistics.sum, + method: (column) => XEUtils.sum($data, column.property), + }) + ); } if (statistics.average.length > 0) { - footers.push(getFooterStatisticsMap({ - columns: columns, - title: '平均', - checks: statistics.average, - method: (column) => XEUtils.mean($data, column.property), - })) + footers.push( + getFooterStatisticsMap({ + columns: columns, + title: '平均', + checks: statistics.average, + method: (column) => XEUtils.mean($data, column.property), + }) + ); } } - return footers + return footers; } /** 获取底部统计Map */ function getFooterStatisticsMap({ columns, title, checks, method }) { return columns.map((column, columnIndex) => { if (columnIndex === 0) { - return title + return title; } if (checks.includes(column.property)) { - return method(column, columnIndex) + return method(column, columnIndex); } - return null - }) + return null; + }); } // 创建新行,自动添加默认值 function createRow(record: Recordable = {}) { - let xTable = getXTable() + let xTable = getXTable(); // 添加默认值 - xTable.internalData.tableFullColumn.forEach(column => { - let col = column.params + xTable.internalData.tableFullColumn.forEach((column) => { + let col = column.params; if (col) { if (col.key && (record[col.key] == null || record[col.key] === '')) { // 设置默认值 - let createValue = getEnhanced(col.type).createValue - let defaultValue = col.defaultValue ?? '' - let ctx = { context: { row: record, column, $table: xTable } } - record[col.key] = createValue(defaultValue, ctx) + let createValue = getEnhanced(col.type).createValue; + let defaultValue = col.defaultValue ?? ''; + let ctx = { context: { row: record, column, $table: xTable } }; + record[col.key] = createValue(defaultValue, ctx); } // 处理联动列 if (col.type === JVxeTypes.select && data.innerLinkageConfig.size > 0) { // 判断当前列是否是联动列 if (data.innerLinkageConfig.has(col.key)) { - let configItem = data.innerLinkageConfig.get(col.key) - linkageMethods.getLinkageOptionsAsync(configItem, '') + let configItem = data.innerLinkageConfig.get(col.key); + linkageMethods.getLinkageOptionsAsync(configItem, ''); } } } - }) - return record + }); + return record; } async function addOrInsert(rows: Recordable | Recordable[] = {}, index, triggerName, options?: IAddRowsOptions) { - let xTable = getXTable() - let records + let xTable = getXTable(); + let records; if (isArray(rows)) { - records = rows + records = rows; } else { - records = [rows] + records = [rows]; } // 遍历添加默认值 - records.forEach(record => createRow(record)) - let setActive = (options?.setActive ?? (props.addSetActive ?? true)) - let result = await pushRows(records, { index: index, setActive }) + records.forEach((record) => createRow(record)); + let setActive = options?.setActive ?? props.addSetActive ?? true; + let result = await pushRows(records, { index: index, setActive }); // 遍历插入的行 // online js增强时以传过来值为准,不再赋默认值 if (!(options?.isOnlineJS ?? false)) { if (triggerName != null) { for (let i = 0; i < result.rows.length; i++) { - let row = result.rows[i] + let row = result.rows[i]; trigger(triggerName, { row: row, rows: result.rows, insertIndex: index, $table: xTable, target: instance, - }) + }); } } } - return result + return result; } // 新增、插入一行时的可选参数 interface IAddRowsOptions { // 是否是 onlineJS增强 触发的 - isOnlineJS?: boolean, + isOnlineJS?: boolean; // 是否激活编辑状态 - setActive?: boolean, + setActive?: boolean; } /** @@ -364,7 +368,7 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, * @return */ async function addRows(rows: Recordable | Recordable[] = {}, options?: IAddRowsOptions) { - return addOrInsert(rows, -1, 'added', options) + return addOrInsert(rows, -1, 'added', options); } /** @@ -374,17 +378,17 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, * @param options.setActive 是否激活最后一行的编辑模式 */ async function pushRows(rows: Recordable | Recordable[] = {}, options = { setActive: false, index: -1 }) { - let xTable = getXTable() - let { setActive, index } = options - index = index === -1 ? index : xTable.internalData.tableFullData[index] + let xTable = getXTable(); + let { setActive, index } = options; + index = index === -1 ? index : xTable.internalData.tableFullData[index]; // 插入行 - let result = await xTable.insertAt(rows, index) + let result = await xTable.insertAt(rows, index); if (setActive) { // 激活最后一行的编辑模式 - xTable.setActiveRow(result.rows[result.rows.length - 1]) + xTable.setActiveRow(result.rows[result.rows.length - 1]); } - await recalcSortNumber() - return result + await recalcSortNumber(); + return result; } /** @@ -397,75 +401,76 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, */ function insertRows(rows: Recordable | Recordable[] = {}, index: number, options?: IAddRowsOptions) { if (index < 0) { - console.warn(`【JVxeTable】insertRows:index必须传递数字,且大于-1`) - return + console.warn(`【JVxeTable】insertRows:index必须传递数字,且大于-1`); + return; } - return addOrInsert(rows, index, 'inserted', options) + return addOrInsert(rows, index, 'inserted', options); } /** 获取表格表单里的值 */ function getValues(callback, rowIds) { - let tableData = getTableData({ rowIds: rowIds }) - callback('', tableData) + let tableData = getTableData({ rowIds: rowIds }); + callback('', tableData); } /** 获取表格数据 */ function getTableData(options: any = {}) { - let { rowIds } = options - let tableData + let { rowIds } = options; + let tableData; // 仅查询指定id的行 if (isArray(rowIds) && rowIds.length > 0) { - tableData = [] - rowIds.forEach(rowId => { - let { row } = getIfRowById(rowId) + tableData = []; + rowIds.forEach((rowId) => { + let { row } = getIfRowById(rowId); if (row) { - tableData.push(row) + tableData.push(row); } - }) + }); } else { // 查询所有行 - tableData = getXTable().getTableData().fullData + tableData = getXTable().getTableData().fullData; } - return filterNewRows(tableData, false) + return filterNewRows(tableData, false); } /** 仅获取新增的数据 */ function getNewData() { - let newData = getNewDataWithId() - newData.forEach(row => delete row.id) - return newData + let newData = getNewDataWithId(); + newData.forEach((row) => delete row.id); + return newData; } /** 仅获取新增的数据,带有id */ function getNewDataWithId() { - let xTable = getXTable() - return cloneDeep(xTable.getInsertRecords()) + let xTable = getXTable(); + return cloneDeep(xTable.getInsertRecords()); } /** 根据ID获取行,新增的行也能查出来 */ function getIfRowById(id) { - let xTable = getXTable() - let row = xTable.getRowById(id), isNew = false + let xTable = getXTable(); + let row = xTable.getRowById(id), + isNew = false; if (!row) { - row = getNewRowById(id) + row = getNewRowById(id); if (!row) { - console.warn(`JVxeTable.getIfRowById:没有找到id为"${id}"的行`) - return { row: null } + console.warn(`JVxeTable.getIfRowById:没有找到id为"${id}"的行`); + return { row: null }; } - isNew = true + isNew = true; } - return { row, isNew } + return { row, isNew }; } /** 通过临时ID获取新增的行 */ function getNewRowById(id) { - let records = getXTable().getInsertRecords() + let records = getXTable().getInsertRecords(); for (let record of records) { if (record.id === id) { - return record + return record; } } - return null + return null; } /** @@ -475,20 +480,20 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, * @param handler function */ function filterNewRows(rows, remove = true, handler?: Fn) { - let insertRecords = getXTable().getInsertRecords() - let records: Recordable[] = [] + let insertRecords = getXTable().getInsertRecords(); + let records: Recordable[] = []; for (let row of rows) { - let item = cloneDeep(row) + let item = cloneDeep(row); if (insertRecords.includes(row)) { - handler ? handler({ item, row, insertRecords }) : null + handler ? handler({ item, row, insertRecords }) : null; if (remove) { - continue + continue; } - delete item.id + delete item.id; } - records.push(item) + records.push(item); } - return records + return records; } /** @@ -496,25 +501,25 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, * @param top 新top位置,留空则滚动到上次记录的位置,用于解决切换tab选项卡时导致白屏以及自动将滚动条滚动到顶部的问题 */ function resetScrollTop(top?) { - let xTable = getXTable() - xTable.scrollTo(null, (top == null || top === '') ? data.scroll.top : top) + let xTable = getXTable(); + xTable.scrollTo(null, top == null || top === '' ? data.scroll.top : top); } /** 校验table,失败返回errMap,成功返回null */ async function validateTable(rows?) { - let xTable = getXTable() - const errMap = await xTable.validate(rows ?? true).catch(errMap => errMap) - return errMap ? errMap : null + let xTable = getXTable(); + const errMap = await xTable.validate(rows ?? true).catch((errMap) => errMap); + return errMap ? errMap : null; } /** 完整校验 */ async function fullValidateTable(rows?) { - let xTable = getXTable() - const errMap = await xTable.fullValidate(rows ?? true).catch(errMap => errMap) - return errMap ? errMap : null + let xTable = getXTable(); + const errMap = await xTable.fullValidate(rows ?? true).catch((errMap) => errMap); + return errMap ? errMap : null; } - type setValuesParam = { rowKey: string, values: Recordable } + type setValuesParam = { rowKey: string; values: Recordable }; /** * 设置某行某列的值 @@ -524,24 +529,24 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, */ function setValues(values: setValuesParam[]): number { if (!isArray(values)) { - console.warn(`[JVxeTable] setValues 必须传递数组`) - return 0 + console.warn(`[JVxeTable] setValues 必须传递数组`); + return 0; } - let xTable = getXTable() - let count = 0 + let xTable = getXTable(); + let count = 0; values.forEach((item) => { - let { rowKey, values: record } = item - let { row } = getIfRowById(rowKey) + let { rowKey, values: record } = item; + let { row } = getIfRowById(rowKey); if (!row) { - return + return; } - Object.keys(record).forEach(colKey => { - let column = xTable.getColumnByField(colKey) + Object.keys(record).forEach((colKey) => { + let column = xTable.getColumnByField(colKey); if (column) { - let oldValue = row[colKey] - let newValue = record[colKey] + let oldValue = row[colKey]; + let newValue = record[colKey]; if (newValue !== oldValue) { - row[colKey] = newValue + row[colKey] = newValue; // 触发 valueChange 事件 trigger('valueChange', { type: column.params.type, @@ -550,30 +555,30 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, col: column.params, column: column, isSetValues: true, - }) - count++ + }); + count++; } } else { - console.warn(`[JVxeTable] setValues 没有找到key为"${colKey}"的列`) + console.warn(`[JVxeTable] setValues 没有找到key为"${colKey}"的列`); } - }) - }) + }); + }); if (count > 0) { - xTable.updateData() + xTable.updateData(); } - return count + return count; } /** 清空选择行 */ async function clearSelection() { - const xTable = getXTable() - let event = { $table: xTable, target: instance } + const xTable = getXTable(); + let event = { $table: xTable, target: instance }; if (props.rowSelectionType === JVxeTypes.rowRadio) { - await xTable.clearRadioRow() - handleVxeRadioChange(event) + await xTable.clearRadioRow(); + handleVxeRadioChange(event); } else { - await xTable.clearCheckboxRow() - handleVxeCheckboxChange(event) + await xTable.clearCheckboxRow(); + handleVxeCheckboxChange(event); } } @@ -582,82 +587,84 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, * @param isFull 如果 isFull=true 则获取全表已选中的数据 */ function getSelectionData(isFull?: boolean) { - const xTable = getXTable() + const xTable = getXTable(); if (props.rowSelectionType === JVxeTypes.rowRadio) { - let row = xTable.getRadioRecord(isFull) + let row = xTable.getRadioRecord(isFull); if (isNull(row)) { - return [] + return []; } - return filterNewRows([row], false) + return filterNewRows([row], false); } else { - return filterNewRows(xTable.getCheckboxRecords(isFull), false) + return filterNewRows(xTable.getCheckboxRecords(isFull), false); } } /** 仅获取被删除的数据(新增又被删除的数据不会被获取到) */ function getDeleteData() { - return filterNewRows(getXTable().getRemoveRecords(), false) + return filterNewRows(getXTable().getRemoveRecords(), false); } /** 删除一行或多行数据 */ async function removeRows(rows) { - const xTable = getXTable() - const res = await xTable.remove(rows) - let removeEvent: any = { deleteRows: rows, $table: xTable } - trigger('removed', removeEvent) - await recalcSortNumber() - return res + const xTable = getXTable(); + const res = await xTable.remove(rows); + let removeEvent: any = { deleteRows: rows, $table: xTable }; + trigger('removed', removeEvent); + await recalcSortNumber(); + return res; } /** 根据id删除一行或多行 */ function removeRowsById(rowId) { - let rowIds + let rowIds; if (isArray(rowId)) { - rowIds = rowId + rowIds = rowId; } else { - rowIds = [rowId] + rowIds = [rowId]; } - let rows = rowIds.map((id) => { - let { row } = getIfRowById(id) - if (!row) { - return - } - if (row) { - return row - } else { - console.warn(`【JVxeTable】removeRowsById:${id}不存在`) - return null - } - }).filter((row) => row != null) - return removeRows(rows) + let rows = rowIds + .map((id) => { + let { row } = getIfRowById(id); + if (!row) { + return; + } + if (row) { + return row; + } else { + console.warn(`【JVxeTable】removeRowsById:${id}不存在`); + return null; + } + }) + .filter((row) => row != null); + return removeRows(rows); } // 删除选中的数据 async function removeSelection() { - let xTable = getXTable() - let res + let xTable = getXTable(); + let res; if (props.rowSelectionType === JVxeTypes.rowRadio) { - res = await xTable.removeRadioRow() + res = await xTable.removeRadioRow(); } else { - res = await xTable.removeCheckboxRow() + res = await xTable.removeCheckboxRow(); } - await clearSelection() - await recalcSortNumber() - return res + await clearSelection(); + await recalcSortNumber(); + return res; } /** 重新计算排序字段的数值 */ async function recalcSortNumber(force = false) { if (props.dragSort || force) { - let xTable = getXTable() - let sortKey = props.sortKey ?? 'orderNum' - let sortBegin = props.sortBegin ?? 0 - xTable.internalData.tableFullData.forEach((data) => data[sortKey] = sortBegin++) + let xTable = getXTable(); + let sortKey = props.sortKey ?? 'orderNum'; + let sortBegin = props.sortBegin ?? 0; + xTable.internalData.tableFullData.forEach((data) => (data[sortKey] = sortBegin++)); // 4.1.0 - await xTable.updateCache() + await xTable.updateCache(); // 4.1.1 // await xTable.cacheRowMap() - return await xTable.updateData() + return await xTable.updateData(); } } @@ -669,33 +676,33 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, */ async function doSort(oldIndex: number, newIndex: number, force = false) { if (props.dragSort || force) { - let xTable = getXTable() + let xTable = getXTable(); let sort = (array) => { // 存储old数据,并删除该项 - let row = array.splice(oldIndex, 1)[0] + let row = array.splice(oldIndex, 1)[0]; // 向newIndex处添加old数据 - array.splice(newIndex, 0, row) - } - sort(xTable.internalData.tableFullData) + array.splice(newIndex, 0, row); + }; + sort(xTable.internalData.tableFullData); if (xTable.keepSource) { - sort(xTable.internalData.tableSourceData) + sort(xTable.internalData.tableSourceData); } - return await recalcSortNumber(force) + return await recalcSortNumber(force); } } /** 行重新排序 */ function rowResort(oldIndex: number, newIndex: number) { - return doSort(oldIndex, newIndex, true) + return doSort(oldIndex, newIndex, true); } // ---------------- begin 权限控制 ---------------- // 加载权限 function loadAuthsMap() { if (!props.authPre || props.authPre.length == 0) { - data.authsMap.value = null + data.authsMap.value = null; } else { - data.authsMap.value = getJVxeAuths(props.authPre) + data.authsMap.value = getJVxeAuths(props.authPre); } } @@ -705,20 +712,20 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, */ function getAuth(authCode) { if (data.authsMap.value != null && props.authPre) { - let prefix = getPrefix(props.authPre) - return data.authsMap.value.get(prefix + authCode) + let prefix = getPrefix(props.authPre); + return data.authsMap.value.get(prefix + authCode); } - return null + return null; } // 获取列权限 function getColAuth(key: string) { - return getAuth(key) + return getAuth(key); } // 判断按钮权限 function hasBtnAuth(key: string) { - return getAuth('btn:' + key)?.isAuth ?? true + return getAuth('btn:' + key)?.isAuth ?? true; } // ---------------- end 权限控制 ---------------- @@ -726,16 +733,16 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, /* --- 辅助方法 ---*/ function created() { - loadAuthsMap() + loadAuthsMap(); } // 触发事件 function trigger(name, event: any = {}) { - event.$target = instance - event.$table = getXTable() + event.$target = instance; + event.$table = getXTable(); //online增强参数兼容 - event.target = instance - emit(name, event) + event.target = instance; + emit(name, event); } return { @@ -756,9 +763,10 @@ export function useMethods(props: JVxeTableProps, { emit }, data: JVxeDataProps, handleCheckMethod, handleActiveMethod, handleExpandToggleMethod, - getColAuth, hasBtnAuth, + getColAuth, + hasBtnAuth, }, publicMethods, created, - } + }; } diff --git a/src/components/jeecg/JVxeTable/src/hooks/usePagination.ts b/src/components/jeecg/JVxeTable/src/hooks/usePagination.ts index e26dd26..5bd6546 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/usePagination.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/usePagination.ts @@ -1,63 +1,66 @@ -import { computed, reactive, h } from 'vue' -import { JVxeTableMethods, JVxeTableProps } from '/@/components/jeecg/JVxeTable/src/types' -import { isEmpty } from '/@/utils/is' -import { Pagination } from 'ant-design-vue' +import { computed, reactive, h } from 'vue'; +import { JVxeTableMethods, JVxeTableProps } from '/@/components/jeecg/JVxeTable/src/types'; +import { isEmpty } from '/@/utils/is'; +import { Pagination } from 'ant-design-vue'; export function usePagination(props: JVxeTableProps, methods: JVxeTableMethods) { - const innerPagination = reactive({ current: 1, pageSize: 10, pageSizeOptions: ['10', '20', '30'], showTotal: (total, range) => { - return range[0] + '-' + range[1] + ' 共 ' + total + ' 条' + return range[0] + '-' + range[1] + ' 共 ' + total + ' 条'; }, showQuickJumper: true, showSizeChanger: true, total: 100, - }) + }); const bindProps = computed(() => { return { ...innerPagination, ...props.pagination, size: props.size === 'tiny' ? 'small' : '', - } - }) + }; + }); const boxClass = computed(() => { return { 'j-vxe-pagination': true, 'show-quick-jumper': !!bindProps.value.showQuickJumper, - } - }) + }; + }); function handleChange(current, pageSize) { - innerPagination.current = current - methods.trigger('pageChange', { current, pageSize }) + innerPagination.current = current; + methods.trigger('pageChange', { current, pageSize }); } function handleShowSizeChange(current, pageSize) { - innerPagination.pageSize = pageSize - methods.trigger('pageChange', { current, pageSize }) + innerPagination.pageSize = pageSize; + methods.trigger('pageChange', { current, pageSize }); } /** 渲染分页器 */ function renderPagination() { if (props.pagination && !isEmpty(props.pagination)) { - return h('div', { - class: boxClass.value, - }, [ - h(Pagination, { - ...bindProps.value, - disabled: props.disabled, - onChange: handleChange, - onShowSizeChange: handleShowSizeChange, - }), - ]) + return h( + 'div', + { + class: boxClass.value, + }, + [ + h(Pagination, { + ...bindProps.value, + disabled: props.disabled, + onChange: handleChange, + onShowSizeChange: handleShowSizeChange, + }), + ] + ); } - return null + return null; } - return { renderPagination } -} \ No newline at end of file + return { renderPagination }; +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useRenderComponents.ts b/src/components/jeecg/JVxeTable/src/hooks/useRenderComponents.ts index d04de54..e8ad036 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useRenderComponents.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useRenderComponents.ts @@ -1,46 +1,53 @@ -import { h } from 'vue' -import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types' -import JVxeSubPopover from '../components/JVxeSubPopover.vue' -import JVxeDetailsModal from '../components/JVxeDetailsModal.vue' -import { useToolbar } from '/@/components/jeecg/JVxeTable/src/hooks/useToolbar' -import { usePagination } from '/@/components/jeecg/JVxeTable/src/hooks/usePagination' +import { h } from 'vue'; +import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types'; +import JVxeSubPopover from '../components/JVxeSubPopover.vue'; +import JVxeDetailsModal from '../components/JVxeDetailsModal.vue'; +import { useToolbar } from '/@/components/jeecg/JVxeTable/src/hooks/useToolbar'; +import { usePagination } from '/@/components/jeecg/JVxeTable/src/hooks/usePagination'; export function useRenderComponents(props: JVxeTableProps, data: JVxeDataProps, methods: JVxeTableMethods, slots) { - // 渲染 toolbar - const { renderToolbar } = useToolbar(props, data, methods, slots) + const { renderToolbar } = useToolbar(props, data, methods, slots); // 渲染分页器 - const { renderPagination } = usePagination(props, methods) + const { renderPagination } = usePagination(props, methods); // 渲染 toolbarAfter 插槽 function renderToolbarAfterSlot() { if (slots['toolbarAfter']) { - return slots['toolbarAfter']() + return slots['toolbarAfter'](); } - return null + return null; } // 渲染点击时弹出的子表 function renderSubPopover() { if (props.clickRowShowSubForm && slots.subForm) { - return h(JVxeSubPopover, { - ref: 'subPopoverRef', - }, { - subForm: slots.subForm, - }) + return h( + JVxeSubPopover, + { + ref: 'subPopoverRef', + }, + { + subForm: slots.subForm, + } + ); } - return null + return null; } // 渲染点击时弹出的详细信息 function renderDetailsModal() { if (props.clickRowShowMainForm && slots.mainForm) { - return h(JVxeDetailsModal, { - ref: 'detailsModalRef', - trigger: methods.trigger, - }, { - mainForm: slots.mainForm, - }) + return h( + JVxeDetailsModal, + { + ref: 'detailsModalRef', + trigger: methods.trigger, + }, + { + mainForm: slots.mainForm, + } + ); } } @@ -50,5 +57,5 @@ export function useRenderComponents(props: JVxeTableProps, data: JVxeDataProps, renderSubPopover, renderDetailsModal, renderToolbarAfterSlot, - } -} \ No newline at end of file + }; +} diff --git a/src/components/jeecg/JVxeTable/src/hooks/useToolbar.ts b/src/components/jeecg/JVxeTable/src/hooks/useToolbar.ts index b91d3c7..2a716ca 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useToolbar.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useToolbar.ts @@ -1,51 +1,53 @@ -import { h } from 'vue' -import JVxeToolbar from '../components/JVxeToolbar.vue' -import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types' +import { h } from 'vue'; +import JVxeToolbar from '../components/JVxeToolbar.vue'; +import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types'; export function useToolbar(props: JVxeTableProps, data: JVxeDataProps, methods: JVxeTableMethods, $slots) { - /** 渲染工具栏 */ function renderToolbar() { if (props.toolbar) { - return h(JVxeToolbar, { - size: props.size, - disabled: props.disabled, - toolbarConfig: props.toolbarConfig, - disabledRows: props.disabledRows, - hasBtnAuth: methods.hasBtnAuth, - selectedRowIds: data.selectedRowIds.value, - // 新增事件 - onAdd: () => methods.addRows(), - // 保存事件 - onSave: () => methods.trigger('save'), - onRemove() { - let $table = methods.getXTable() - let deleteRows = methods.filterNewRows(data.selectedRows.value) - // 触发删除事件 - if (deleteRows.length > 0) { - let removeEvent: any = { deleteRows, $table, target: this } - if (props.asyncRemove) { - // 确认删除,只有调用这个方法才会真删除 - removeEvent.confirmRemove = () => methods.removeSelection() + return h( + JVxeToolbar, + { + size: props.size, + disabled: props.disabled, + toolbarConfig: props.toolbarConfig, + disabledRows: props.disabledRows, + hasBtnAuth: methods.hasBtnAuth, + selectedRowIds: data.selectedRowIds.value, + // 新增事件 + onAdd: () => methods.addRows(), + // 保存事件 + onSave: () => methods.trigger('save'), + onRemove() { + let $table = methods.getXTable(); + let deleteRows = methods.filterNewRows(data.selectedRows.value); + // 触发删除事件 + if (deleteRows.length > 0) { + let removeEvent: any = { deleteRows, $table, target: this }; + if (props.asyncRemove) { + // 确认删除,只有调用这个方法才会真删除 + removeEvent.confirmRemove = () => methods.removeSelection(); + } else { + methods.removeSelection(); + } + methods.trigger('removed', removeEvent); } else { - methods.removeSelection() + methods.removeSelection(); } - methods.trigger('removed', removeEvent) - } else { - methods.removeSelection() - } + }, + // 清除选择事件 + onClearSelection: () => methods.clearSelection(), + onRegister: ({ xToolbarRef }) => methods.getXTable().connect(xToolbarRef.value), }, - // 清除选择事件 - onClearSelection: () => methods.clearSelection(), - onRegister: ({ xToolbarRef }) => methods.getXTable().connect(xToolbarRef.value), - }, { - toolbarPrefix: $slots.toolbarPrefix, - toolbarSuffix: $slots.toolbarSuffix, - }) + { + toolbarPrefix: $slots.toolbarPrefix, + toolbarSuffix: $slots.toolbarSuffix, + } + ); } - return null + return null; } - return { renderToolbar } + return { renderToolbar }; } - diff --git a/src/components/jeecg/JVxeTable/src/hooks/useValidateRules.ts b/src/components/jeecg/JVxeTable/src/hooks/useValidateRules.ts index 2bf6e0d..53ffc3d 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useValidateRules.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useValidateRules.ts @@ -1,79 +1,79 @@ -import { VxeTablePropTypes } from 'vxe-table' -import { isArray } from '/@/utils/is' -import { HandleArgs } from './useColumns' -import { replaceProps } from '../utils/enhancedUtils' +import { VxeTablePropTypes } from 'vxe-table'; +import { isArray } from '/@/utils/is'; +import { HandleArgs } from './useColumns'; +import { replaceProps } from '../utils/enhancedUtils'; export function useValidateRules(args: HandleArgs) { - const { data } = args - const col = args.col! - let rules: VxeTablePropTypes.EditRules[] = [] + const { data } = args; + const col = args.col!; + let rules: VxeTablePropTypes.EditRules[] = []; if (isArray(col.validateRules)) { for (let rule of col.validateRules) { let replace = { message: replaceProps(col, rule.message), - } + }; if (rule.unique || rule.pattern === 'only') { // 唯一校验器 - rule.validator = uniqueValidator(args) + rule.validator = uniqueValidator(args); } else if (rule.pattern) { // 非空 if (rule.pattern === fooPatterns[0].value) { - rule.required = true - delete rule.pattern + rule.required = true; + delete rule.pattern; } else { // 兼容Online表单的特殊规则 for (let foo of fooPatterns) { if (foo.value === rule.pattern) { - rule.pattern = foo.pattern - break + rule.pattern = foo.pattern; + break; } } } } else if (typeof rule.handler === 'function') { // 自定义函数校验 - rule.validator = handlerConvertToValidator + rule.validator = handlerConvertToValidator; } - rules.push(Object.assign({}, rule, replace)) + rules.push(Object.assign({}, rule, replace)); } } - data.innerEditRules[col.key] = rules + data.innerEditRules[col.key] = rules; } /** 唯一校验器 */ function uniqueValidator({ methods }: HandleArgs) { return function (event) { - const { cellValue, column, rule } = event - let tableData = methods.getTableData() - let findCount = 0 + const { cellValue, column, rule } = event; + let tableData = methods.getTableData(); + let findCount = 0; for (let rowData of tableData) { if (rowData[column.params.key] === cellValue) { if (++findCount >= 2) { - return Promise.reject(new Error(rule.message)) + return Promise.reject(new Error(rule.message)); } } } - return Promise.resolve() - } + return Promise.resolve(); + }; } /** 旧版handler转为新版Validator */ function handlerConvertToValidator(event) { - const { column, rule } = event + const { column, rule } = event; return new Promise((resolve, reject) => { rule.handler(event, (flag, msg) => { - let message = rule.message + let message = rule.message; if (typeof msg === 'string') { - message = replaceProps(column.params, msg) + message = replaceProps(column.params, msg); } if (flag == null) { - resolve(message) + resolve(message); } else if (!!flag) { - resolve(message) + resolve(message); } else { - reject(new Error(message)) + reject(new Error(message)); } - }) - }) + }); + }); } // 兼容 online 的规则 @@ -90,4 +90,4 @@ const fooPatterns = [ { title: '数字', value: 'n', pattern: /^-?\d+(\.?\d+|\d?)$/ }, { title: '整数', value: 'z', pattern: /^-?\d+$/ }, { title: '金额', value: 'money', pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/ }, -] +]; diff --git a/src/components/jeecg/JVxeTable/src/hooks/useWebSocket.ts b/src/components/jeecg/JVxeTable/src/hooks/useWebSocket.ts index 29020d0..9605a90 100644 --- a/src/components/jeecg/JVxeTable/src/hooks/useWebSocket.ts +++ b/src/components/jeecg/JVxeTable/src/hooks/useWebSocket.ts @@ -1,9 +1,9 @@ -import { watch, onUnmounted } from 'vue' -import { buildUUID } from '/@/utils/uuid' -import { useGlobSetting } from '/@/hooks/setting' -import { useUserStore } from '/@/store/modules/user' -import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types' -import { isArray } from '/@/utils/is' +import { watch, onUnmounted } from 'vue'; +import { buildUUID } from '/@/utils/uuid'; +import { useGlobSetting } from '/@/hooks/setting'; +import { useUserStore } from '/@/store/modules/user'; +import { JVxeDataProps, JVxeTableMethods, JVxeTableProps } from '../types'; +import { isArray } from '/@/utils/is'; import { getToken } from '/@/utils/auth'; // vxe socket @@ -31,54 +31,56 @@ const vs = { timeout: 6000, timeoutTimer: -1, clear() { - clearTimeout(this.timeoutTimer) - return this + clearTimeout(this.timeoutTimer); + return this; }, start() { - vs.sendMessage(vs.constants.TYPE_HB, '') + vs.sendMessage(vs.constants.TYPE_HB, ''); // 如果超过一定时间还没重置,说明后端主动断开了 this.timeoutTimer = window.setTimeout(() => { - vs.reconnect() - }, this.timeout) - return this + vs.reconnect(); + }, this.timeout); + return this; }, // 心跳消息返回 back() { - this.clear() - window.setTimeout(() => this.start(), this.interval) + this.clear(); + window.setTimeout(() => this.start(), this.interval); }, }, /** 初始化 WebSocket */ initialWebSocket() { if (this.ws === null) { - const userId = useUserStore().getUserInfo?.id - const domainURL = useGlobSetting().uploadUrl! - const domain = domainURL.replace('https://', 'wss://').replace('http://', 'ws://') - const url = `${domain}/vxeSocket/${userId}/${this.pageId}` + const userId = useUserStore().getUserInfo?.id; + const domainURL = useGlobSetting().uploadUrl!; + const domain = domainURL.replace('https://', 'wss://').replace('http://', 'ws://'); + const url = `${domain}/vxeSocket/${userId}/${this.pageId}`; //update-begin-author:taoyan date:2022-4-24 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278 - let token = (getToken() || '') as string - this.ws = new WebSocket(url) + let token = (getToken() || '') as string; + this.ws = new WebSocket(url); //update-end-author:taoyan date:2022-4-24 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278 - this.ws.onopen = this.on.open.bind(this) - this.ws.onerror = this.on.error.bind(this) - this.ws.onmessage = this.on.message.bind(this) - this.ws.onclose = this.on.close.bind(this) + this.ws.onopen = this.on.open.bind(this); + this.ws.onerror = this.on.error.bind(this); + this.ws.onmessage = this.on.message.bind(this); + this.ws.onclose = this.on.close.bind(this); } }, // 发送消息 sendMessage(type, message) { try { - let ws = this.ws + let ws = this.ws; if (ws != null && ws.readyState === ws.OPEN) { - ws.send(JSON.stringify({ - type: type, - data: message, - })) + ws.send( + JSON.stringify({ + type: type, + data: message, + }) + ); } } catch (err: any) { - console.warn('【JVxeWebSocket】发送消息失败:(' + err.code + ')') + console.warn('【JVxeWebSocket】发送消息失败:(' + err.code + ')'); } }, @@ -86,92 +88,92 @@ const vs = { tableMap: new Map(), /** 添加绑定 */ addBind(map, key, value: VmArgs) { - let binds = map.get(key) + let binds = map.get(key); if (isArray(binds)) { - binds.push(value) + binds.push(value); } else { - map.set(key, [value]) + map.set(key, [value]); } }, /** 移除绑定 */ removeBind(map, key, value: VmArgs) { - let binds = map.get(key) + let binds = map.get(key); if (isArray(binds)) { for (let i = 0; i < binds.length; i++) { - let bind = binds[i] + let bind = binds[i]; if (bind === value) { - binds.splice(i, 1) - break + binds.splice(i, 1); + break; } } if (binds.length === 0) { - map.delete(key) + map.delete(key); } } else { - map.delete(key) + map.delete(key); } }, // 呼叫绑定的表单 callBind(map, key, callback) { - let binds = map.get(key) + let binds = map.get(key); if (isArray(binds)) { - binds.forEach(callback) + binds.forEach(callback); } }, lockReconnect: false, /** 尝试重连 */ reconnect() { - if (this.lockReconnect) return - this.lockReconnect = true + if (this.lockReconnect) return; + this.lockReconnect = true; setTimeout(() => { if (this.ws && this.ws.close) { - this.ws.close() + this.ws.close(); } - this.ws = null - console.info('【JVxeWebSocket】尝试重连...') - this.initialWebSocket() - this.lockReconnect = false - }, 5000) + this.ws = null; + console.info('【JVxeWebSocket】尝试重连...'); + this.initialWebSocket(); + this.lockReconnect = false; + }, 5000); }, on: { open() { - console.info('【JVxeWebSocket】连接成功') - this.heartCheck.start() + console.info('【JVxeWebSocket】连接成功'); + this.heartCheck.start(); }, error(e) { - console.warn('【JVxeWebSocket】连接发生错误:', e) - this.reconnect() + console.warn('【JVxeWebSocket】连接发生错误:', e); + this.reconnect(); }, message(e) { // 解析消息 - let json + let json; try { - json = JSON.parse(e.data) + json = JSON.parse(e.data); } catch (e: any) { - console.warn('【JVxeWebSocket】收到无法解析的消息:', e.data) - return + console.warn('【JVxeWebSocket】收到无法解析的消息:', e.data); + return; } - let type = json[this.constants.TYPE] - let data = json[this.constants.DATA] + let type = json[this.constants.TYPE]; + let data = json[this.constants.DATA]; switch (type) { // 心跳检测 case this.constants.TYPE_HB: - this.heartCheck.back() - break + this.heartCheck.back(); + break; // 更新form数据 case this.constants.TYPE_UVT: - this.callBind(this.tableMap, data.socketKey, (args) => this.onVM.onUpdateTable(args, ...data.args)) - break + this.callBind(this.tableMap, data.socketKey, (args) => this.onVM.onUpdateTable(args, ...data.args)); + break; default: - console.warn('【JVxeWebSocket】收到不识别的消息类型:' + type) - break + console.warn('【JVxeWebSocket】收到不识别的消息类型:' + type); + break; } }, close(e) { - console.info('【JVxeWebSocket】连接被关闭:', e) - this.reconnect() + console.info('【JVxeWebSocket】连接被关闭:', e); + this.reconnect(); }, }, @@ -179,53 +181,56 @@ const vs = { /** 收到更新表格的消息 */ onUpdateTable({ props, data, methods }: VmArgs, row, caseId) { if (data.caseId !== caseId) { - const tableRow = methods.getIfRowById(row.id).row + const tableRow = methods.getIfRowById(row.id).row; // 局部保更新数据 if (tableRow) { if (props.reloadEffect) { - data.reloadEffectRowKeysMap[row.id] = true + data.reloadEffectRowKeysMap[row.id] = true; } - Object.assign(tableRow, row, { id: tableRow.id }) - methods.getXTable().reloadRow(tableRow) + Object.assign(tableRow, row, { id: tableRow.id }); + methods.getXTable().reloadRow(tableRow); } } }, }, - -} as ({ - ws: Nullable -} & Recordable) +} as { + ws: Nullable; +} & Recordable; type VmArgs = { - props: JVxeTableProps, - data: JVxeDataProps, - methods: JVxeTableMethods -} + props: JVxeTableProps; + data: JVxeDataProps; + methods: JVxeTableMethods; +}; export function useWebSocket(props: JVxeTableProps, data: JVxeDataProps, methods) { - const args: VmArgs = { props, data, methods } - watch(() => props.socketReload, (socketReload: boolean) => { - if (socketReload) { - vs.initialWebSocket() - vs.addBind(vs.tableMap, props.socketKey, args) - } else { - vs.removeBind(vs.tableMap, props.socketKey, args) - } - }, { immediate: true }) + const args: VmArgs = { props, data, methods }; + watch( + () => props.socketReload, + (socketReload: boolean) => { + if (socketReload) { + vs.initialWebSocket(); + vs.addBind(vs.tableMap, props.socketKey, args); + } else { + vs.removeBind(vs.tableMap, props.socketKey, args); + } + }, + { immediate: true } + ); /** 发送socket消息更新行 */ function socketSendUpdateRow(row) { vs.sendMessage(vs.constants.TYPE_UVT, { socketKey: props.socketKey, args: [row, data.caseId], - }) + }); } onUnmounted(() => { - vs.removeBind(vs.tableMap, props.socketKey, args) - }) + vs.removeBind(vs.tableMap, props.socketKey, args); + }); return { socketSendUpdateRow, - } + }; } diff --git a/src/components/jeecg/JVxeTable/src/install.ts b/src/components/jeecg/JVxeTable/src/install.ts index f42832d..34b598b 100644 --- a/src/components/jeecg/JVxeTable/src/install.ts +++ b/src/components/jeecg/JVxeTable/src/install.ts @@ -1,14 +1,14 @@ -import type { App } from 'vue' +import type { App } from 'vue'; // 引入 vxe-table -import 'xe-utils' -import VXETable, { /*Grid*/ } from 'vxe-table' -import VXETablePluginAntd from 'vxe-table-plugin-antd' -import 'vxe-table/lib/style.css' +import 'xe-utils'; +import VXETable /*Grid*/ from 'vxe-table'; +import VXETablePluginAntd from 'vxe-table-plugin-antd'; +import 'vxe-table/lib/style.css'; -import JVxeTable from './JVxeTable' -import { getEventPath } from '/@/utils/common/compUtils' -import { registerAllComponent } from './utils/registerUtils' -import { getEnhanced } from './utils/enhancedUtils' +import JVxeTable from './JVxeTable'; +import { getEventPath } from '/@/utils/common/compUtils'; +import { registerAllComponent } from './utils/registerUtils'; +import { getEnhanced } from './utils/enhancedUtils'; export function registerJVxeTable(app: App) { // VXETable 全局配置 @@ -16,48 +16,48 @@ export function registerJVxeTable(app: App) { // z-index 起始值 zIndex: 1000, table: {}, - } + }; // 添加事件拦截器 event.clearActived // 比如点击了某个组件的弹出层面板之后,此时被激活单元格不应该被自动关闭,通过返回 false 可以阻止默认的行为。 VXETable.interceptor.add('event.clearActived', function (this: any, params) { // 获取组件增强 - let col = params.column.params - let { $event } = params - const interceptor = getEnhanced(col.type).interceptor + let col = params.column.params; + let { $event } = params; + const interceptor = getEnhanced(col.type).interceptor; // 执行增强 - let flag = interceptor['event.clearActived']?.call(this, ...arguments) + let flag = interceptor['event.clearActived']?.call(this, ...arguments); if (flag === false) { - return false + return false; } - let path = getEventPath($event) + let path = getEventPath($event); for (let p of path) { - let className: any = p.className || '' - className = typeof className === 'string' ? className : className.toString() + let className: any = p.className || ''; + className = typeof className === 'string' ? className : className.toString(); /* --- 特殊处理以下组件,点击以下标签时不清空编辑状态 --- */ // 点击的标签是JInputPop if (className.includes('j-input-pop')) { - return false + return false; } // 点击的标签是JPopup的弹出层、部门选择、用户选择 if (className.includes('j-popup-modal') || className.includes('j-depart-select-modal') || className.includes('j-user-select-modal')) { - return false + return false; } // 执行增强 - let flag = interceptor['event.clearActived.className']?.call(this, className, ...arguments) + let flag = interceptor['event.clearActived.className']?.call(this, className, ...arguments); if (flag === false) { - return false + return false; } } - }) + }); // 注册插件 - VXETable.use(VXETablePluginAntd) + VXETable.use(VXETablePluginAntd); // 注册自定义组件 - registerAllComponent() + registerAllComponent(); // 执行注册方法 - app.use(VXETable, VXETableSettings) - app.component('JVxeTable', JVxeTable) -} \ No newline at end of file + app.use(VXETable, VXETableSettings); + app.component('JVxeTable', JVxeTable); +} diff --git a/src/components/jeecg/JVxeTable/src/style/index.less b/src/components/jeecg/JVxeTable/src/style/index.less index 63b0f02..16de74c 100644 --- a/src/components/jeecg/JVxeTable/src/style/index.less +++ b/src/components/jeecg/JVxeTable/src/style/index.less @@ -1,8 +1,7 @@ -@import "vxe.const"; -@import "vxe.dark"; +@import 'vxe.const'; +@import 'vxe.dark'; .@{prefix-cls} { - // 编辑按钮样式 .vxe-cell--edit-icon { border-color: #606266; @@ -14,7 +13,6 @@ // toolbar 样式 &-toolbar { - &-collapsed { [data-collapse] { display: none; @@ -74,5 +72,4 @@ .vxe-body--row.sortable-chosen { background-color: #dfecfb; } - } diff --git a/src/components/jeecg/JVxeTable/src/style/reload-effect.less b/src/components/jeecg/JVxeTable/src/style/reload-effect.less index c794ea7..0333c81 100644 --- a/src/components/jeecg/JVxeTable/src/style/reload-effect.less +++ b/src/components/jeecg/JVxeTable/src/style/reload-effect.less @@ -1,5 +1,4 @@ .j-vxe-reload-effect-box { - &, .j-vxe-reload-effect-span { display: inline; @@ -8,7 +7,6 @@ } .j-vxe-reload-effect-span { - &.layer-top { display: inline-block; width: 100%; @@ -43,4 +41,4 @@ transform: rotateX(180deg); } } -} \ No newline at end of file +} diff --git a/src/components/jeecg/JVxeTable/src/style/vxe.const.less b/src/components/jeecg/JVxeTable/src/style/vxe.const.less index 6baeaf0..49db4e3 100644 --- a/src/components/jeecg/JVxeTable/src/style/vxe.const.less +++ b/src/components/jeecg/JVxeTable/src/style/vxe.const.less @@ -1,2 +1,2 @@ //noinspection LessUnresolvedVariable -@prefix-cls: ~'@{namespace}-j-vxe-table'; \ No newline at end of file +@prefix-cls: ~'@{namespace}-j-vxe-table'; diff --git a/src/components/jeecg/JVxeTable/src/style/vxe.dark.less b/src/components/jeecg/JVxeTable/src/style/vxe.dark.less index fd9fdcf..a33c872 100644 --- a/src/components/jeecg/JVxeTable/src/style/vxe.dark.less +++ b/src/components/jeecg/JVxeTable/src/style/vxe.dark.less @@ -1,11 +1,14 @@ -@import "vxe.const"; +@import 'vxe.const'; [data-theme='dark'] .@{prefix-cls} { @fontColor: #c9d1d9; @bgColor: #151515; @borderColor: #606060; - .vxe-cell--item, .vxe-cell--title, .vxe-cell, .vxe-body--expanded-cell { + .vxe-cell--item, + .vxe-cell--title, + .vxe-cell, + .vxe-body--expanded-cell { color: @fontColor; } @@ -63,7 +66,6 @@ background-color: #1d1d1d; } - .vxe-table--render-default.border--default .vxe-body--column, .vxe-table--render-default.border--default .vxe-footer--column, .vxe-table--render-default.border--default .vxe-header--column, @@ -73,20 +75,18 @@ background-image: linear-gradient(#1d1d1d, #1d1d1d); } - // 列宽拖动 .vxe-header--column .vxe-resizable.is--line:before { background-color: #505050; } - // checkbox .vxe-custom--option .vxe-checkbox--icon:before, .vxe-export--panel-column-option .vxe-checkbox--icon:before, .vxe-table--filter-option .vxe-checkbox--icon:before, .vxe-table--render-default .vxe-cell--checkbox .vxe-checkbox--icon:before { background-color: @bgColor; - border-color: @borderColor + border-color: @borderColor; } .vxe-toolbar .vxe-custom--option-wrapper { @@ -95,7 +95,7 @@ .vxe-button { background-color: @bgColor; - border-color: @borderColor + border-color: @borderColor; } .vxe-button.type--button:not(.is--disabled):active { @@ -109,4 +109,4 @@ .vxe-toolbar .vxe-custom--option-wrapper .vxe-custom--footer button { color: @fontColor; } -} \ No newline at end of file +} diff --git a/src/components/jeecg/JVxeTable/src/types/JVxeComponent.ts b/src/components/jeecg/JVxeTable/src/types/JVxeComponent.ts index 3ca6420..1e7009a 100644 --- a/src/components/jeecg/JVxeTable/src/types/JVxeComponent.ts +++ b/src/components/jeecg/JVxeTable/src/types/JVxeComponent.ts @@ -1,13 +1,12 @@ -import { ComponentInternalInstance, ExtractPropTypes } from 'vue' -import { useJVxeCompProps } from '/@/components/jeecg/JVxeTable/hooks' +import { ComponentInternalInstance, ExtractPropTypes } from 'vue'; +import { useJVxeCompProps } from '/@/components/jeecg/JVxeTable/hooks'; export namespace JVxeComponent { - export type Props = ExtractPropTypes>; interface EnhancedCtx { - props?: JVxeComponent.Props, - context?: any, + props?: JVxeComponent.Props; + context?: any; } /** 组件增强类型 */ @@ -15,60 +14,60 @@ export namespace JVxeComponent { // 注册参数(详见:https://xuliangzhan_admin.gitee.io/vxe-table/v4/table/renderer/edit) installOptions: { // 自动聚焦的 class 类名 - autofocus?: string, - } & Recordable, + autofocus?: string; + } & Recordable; // 事件拦截器(用于兼容) interceptor: { // 已实现:event.clearActived // 说明:比如点击了某个组件的弹出层面板之后,此时被激活单元格不应该被自动关闭,通过返回 false 可以阻止默认的行为。 - 'event.clearActived'?: (params, event, target, ctx?: EnhancedCtx) => boolean, + 'event.clearActived'?: (params, event, target, ctx?: EnhancedCtx) => boolean; // 自定义:event.clearActived.className // 说明:比原生的多了一个参数:className,用于判断点击的元素的样式名(递归到顶层) - 'event.clearActived.className'?: (params, event, target, ctx?: EnhancedCtx) => boolean, - }, + 'event.clearActived.className'?: (params, event, target, ctx?: EnhancedCtx) => boolean; + }; // 【功能开关】 switches: { // 是否使用 editRender 模式(仅当前组件,并非全局) // 如果设为true,则表头上方会出现一个可编辑的图标 - editRender?: boolean, + editRender?: boolean; // false = 组件触发后可视);true = 组件一直可视 - visible?: boolean, - }, + visible?: boolean; + }; // 【切面增强】切面事件处理,一般在某些方法执行后同步执行 aopEvents: { // 单元格被激活编辑时会触发该事件 - editActived?: (this: ComponentInternalInstance, ...args) => any, + editActived?: (this: ComponentInternalInstance, ...args) => any; // 单元格编辑状态下被关闭时会触发该事件 - editClosed?: (this: ComponentInternalInstance, ...args) => any, + editClosed?: (this: ComponentInternalInstance, ...args) => any; // 返回值决定单元格是否可以编辑 - activeMethod?: (this: ComponentInternalInstance, ...args) => boolean, - }, + activeMethod?: (this: ComponentInternalInstance, ...args) => boolean; + }; // 【翻译增强】可以实现例如select组件保存的value,但是span模式下需要显示成text translate: { // 是否启用翻译 - enabled?: boolean, + enabled?: boolean; /** * 【翻译处理方法】如果handler留空,则使用默认的翻译方法 * * @param value 需要翻译的值 * @returns{*} 返回翻译后的数据 */ - handler?: (value, ctx?: EnhancedCtx) => any - }, + handler?: (value, ctx?: EnhancedCtx) => any; + }; /** * 【获取值增强】组件抛出的值 * * @param value 保存到数据库里的值 * @returns{*} 返回处理后的值 */ - getValue: (value, ctx?: EnhancedCtx) => any, + getValue: (value, ctx?: EnhancedCtx) => any; /** * 【设置值增强】设置给组件的值 * * @param value 组件触发的值 * @returns{*} 返回处理后的值 */ - setValue: (value, ctx?: EnhancedCtx) => any, + setValue: (value, ctx?: EnhancedCtx) => any; /** * 【新增行增强】在用户点击新增时触发的事件,返回新行的默认值 * @@ -81,8 +80,8 @@ export namespace JVxeComponent { * * @returns 返回新值 */ - createValue: (defaultValue: any, ctx?: EnhancedCtx) => any, + createValue: (defaultValue: any, ctx?: EnhancedCtx) => any; } - export type EnhancedPartial = Partial -} \ No newline at end of file + export type EnhancedPartial = Partial; +} diff --git a/src/components/jeecg/JVxeTable/src/types/JVxeTypes.ts b/src/components/jeecg/JVxeTable/src/types/JVxeTypes.ts index 617204b..060b62a 100644 --- a/src/components/jeecg/JVxeTable/src/types/JVxeTypes.ts +++ b/src/components/jeecg/JVxeTable/src/types/JVxeTypes.ts @@ -48,11 +48,11 @@ export enum JVxeTypes { // 为了防止和 vxe 内置的类型冲突,所以加上一个前缀 // 前缀是自动加的,代码中直接用就行(JVxeTypes.input) -export const JVxeTypePrefix = 'j-' +export const JVxeTypePrefix = 'j-'; /** VxeTable 渲染类型 */ export enum JVxeRenderType { editer = 'editer', spaner = 'spaner', default = 'default', -} \ No newline at end of file +} diff --git a/src/components/jeecg/JVxeTable/src/types/index.ts b/src/components/jeecg/JVxeTable/src/types/index.ts index b9c5de7..a7dca8e 100644 --- a/src/components/jeecg/JVxeTable/src/types/index.ts +++ b/src/components/jeecg/JVxeTable/src/types/index.ts @@ -1,120 +1,120 @@ -import type { Component, Ref, ComputedRef, ExtractPropTypes } from 'vue' -import type { VxeColumnProps } from 'vxe-table/types/column' -import type { JVxeComponent } from './JVxeComponent' -import type { VxeGridInstance, VxeTablePropTypes } from 'vxe-table' -import { JVxeTypes } from './JVxeTypes' -import { vxeProps } from '../vxe.data' -import { useMethods } from '../hooks/useMethods' -import { getJVxeAuths } from '../utils/authUtils' +import type { Component, Ref, ComputedRef, ExtractPropTypes } from 'vue'; +import type { VxeColumnProps } from 'vxe-table/types/column'; +import type { JVxeComponent } from './JVxeComponent'; +import type { VxeGridInstance, VxeTablePropTypes } from 'vxe-table'; +import { JVxeTypes } from './JVxeTypes'; +import { vxeProps } from '../vxe.data'; +import { useMethods } from '../hooks/useMethods'; +import { getJVxeAuths } from '../utils/authUtils'; export type JVxeTableProps = Partial>>; -export type JVxeTableMethods = ReturnType['methods'] +export type JVxeTableMethods = ReturnType['methods']; export type JVxeVueComponent = { - enhanced?: JVxeComponent.EnhancedPartial -} & Component + enhanced?: JVxeComponent.EnhancedPartial; +} & Component; -type statisticsTypes = 'sum' | 'average' +type statisticsTypes = 'sum' | 'average'; -export type JVxeColumn = IJVxeColumn & Recordable +export type JVxeColumn = IJVxeColumn & Recordable; /** * JVxe 列配置项 */ export interface IJVxeColumn extends VxeColumnProps { - type?: any, + type?: any; // 行唯一标识 - key: string, + key: string; // 表单预期值的提示信息,可以使用${...}变量替换文本 - placeholder?: string, + placeholder?: string; // 默认值 - defaultValue?: any, + defaultValue?: any; // 是否禁用当前列,默认false - disabled?: boolean, + disabled?: boolean; // 校验规则 TODO 类型待定义 - validateRules?: any, + validateRules?: any; // 联动下一级的字段key - linkageKey?: string, + linkageKey?: string; // 自定义传入组件的其他属性 - props?: Recordable, - allowClear?: boolean,// 允许清除 + props?: Recordable; + allowClear?: boolean; // 允许清除 // 【inputNumber】是否是统计列,只有 inputNumber 才能设置统计列。统计列:sum 求和;average 平均值 - statistics?: boolean | [statisticsTypes, statisticsTypes?], + statistics?: boolean | [statisticsTypes, statisticsTypes?]; // 【select】 - dictCode?: string, // 字典 code - options?: ({ title?: string, label?: string, text?: string, value: any, disabled?: boolean })[], // 下拉选项列表 - allowInput?: boolean, // 允许输入 - allowSearch?: boolean, // 允许搜索 + dictCode?: string; // 字典 code + options?: { title?: string; label?: string; text?: string; value: any; disabled?: boolean }[]; // 下拉选项列表 + allowInput?: boolean; // 允许输入 + allowSearch?: boolean; // 允许搜索 // 【slot】 - slotName?: string,// 插槽名 + slotName?: string; // 插槽名 // 【checkbox】 - customValue?: [any, any], // 自定义值 - defaultChecked?: boolean, // 默认选中 + customValue?: [any, any]; // 自定义值 + defaultChecked?: boolean; // 默认选中 // 【upload】 upload - btnText?: string, // 上传按钮文字 - token?: boolean, // 是否传递 token - responseName?: string, // 返回取值名称 - action?: string, // 上传地址 - allowRemove?: boolean, // 是否允许删除 - allowDownload?: boolean, // 是否允许下载 + btnText?: string; // 上传按钮文字 + token?: boolean; // 是否传递 token + responseName?: string; // 返回取值名称 + action?: string; // 上传地址 + allowRemove?: boolean; // 是否允许删除 + allowDownload?: boolean; // 是否允许下载 // 【下拉字典搜索】 - dict?: string,// 字典表配置信息:数据库表名,显示字段名,存储字段名 - async?: boolean, // 是否同步模式 - tipsContent?: string, + dict?: string; // 字典表配置信息:数据库表名,显示字段名,存储字段名 + async?: boolean; // 是否同步模式 + tipsContent?: string; // 【popup】 - popupCode?: string, - field?: string, - orgFields?: string, - destFields?: string, + popupCode?: string; + field?: string; + orgFields?: string; + destFields?: string; } export interface JVxeRefs { - gridRef: Ref - subPopoverRef: Ref - detailsModalRef: Ref + gridRef: Ref; + subPopoverRef: Ref; + detailsModalRef: Ref; } export interface JVxeDataProps { - prefixCls: string, + prefixCls: string; // vxe 实例ID - caseId: string, + caseId: string; // vxe 最终 columns - vxeColumns?: ComputedRef, + vxeColumns?: ComputedRef; // vxe 最终 dataSource - vxeDataSource: Ref, + vxeDataSource: Ref; // 记录滚动条位置 - scroll: { top: number, left: number }, + scroll: { top: number; left: number }; // 当前是否正在滚动 - scrolling: Ref, + scrolling: Ref; // vxe 默认配置 - defaultVxeProps: object, + defaultVxeProps: object; // 绑定左侧选择框 - selectedRows: Ref, + selectedRows: Ref; // 绑定左侧选择框已选择的id - selectedRowIds: Ref, - disabledRowIds: string[], + selectedRowIds: Ref; + disabledRowIds: string[]; // 统计列配置 statistics: { - has: boolean, - sum: string[], - average: string[], - }, + has: boolean; + sum: string[]; + average: string[]; + }; // 所有和当前表格相关的授权信息 - authsMap: Ref>>, + authsMap: Ref>>; // 内置 EditRules - innerEditRules: Recordable, + innerEditRules: Recordable; // 联动下拉选项(用于隔离不同的下拉选项) // 内部联动配置,map - innerLinkageConfig: Map, + innerLinkageConfig: Map; // 开启了数据刷新效果的行 - reloadEffectRowKeysMap: Recordable, + reloadEffectRowKeysMap: Recordable; } export interface JVxeLinkageConfig { // 联动第一级的 key - key: string, + key: string; // 获取数据的方法 - requestData: (parent: string) => Promise, + requestData: (parent: string) => Promise; } -export { JVxeTypes } \ No newline at end of file +export { JVxeTypes }; diff --git a/src/components/jeecg/JVxeTable/src/utils/authUtils.ts b/src/components/jeecg/JVxeTable/src/utils/authUtils.ts index c75a1a4..405f10a 100644 --- a/src/components/jeecg/JVxeTable/src/utils/authUtils.ts +++ b/src/components/jeecg/JVxeTable/src/utils/authUtils.ts @@ -1,33 +1,33 @@ /* JVxeTable 行编辑 权限 */ -import { usePermissionStoreWithOut } from '/@/store/modules/permission' +import { usePermissionStoreWithOut } from '/@/store/modules/permission'; -const permissionStore = usePermissionStoreWithOut() +const permissionStore = usePermissionStoreWithOut(); /** * JVxe 专用,获取权限 * @param prefix */ export function getJVxeAuths(prefix) { - prefix = getPrefix(prefix) - let { authList, allAuthList } = permissionStore - let authsMap = new Map() + prefix = getPrefix(prefix); + let { authList, allAuthList } = permissionStore; + let authsMap = new Map(); if (!prefix || prefix.length == 0) { - return authsMap + return authsMap; } // 将所有vxe用到的权限取出来 for (let auth of allAuthList) { if (auth.status == '1' && auth.action.startsWith(prefix)) { - authsMap.set(auth.action, { ...auth, isAuth: false }) + authsMap.set(auth.action, { ...auth, isAuth: false }); } } // 设置是否已授权 for (let auth of authList) { - let getAuth = authsMap.get(auth.action) + let getAuth = authsMap.get(auth.action); if (getAuth != null) { - getAuth.isAuth = true + getAuth.isAuth = true; } } - return authsMap + return authsMap; } /** @@ -36,7 +36,7 @@ export function getJVxeAuths(prefix) { */ export function getPrefix(prefix: string) { if (prefix && !prefix.endsWith(':')) { - return prefix + ':' + return prefix + ':'; } - return prefix + return prefix; } diff --git a/src/components/jeecg/JVxeTable/src/utils/enhancedUtils.ts b/src/components/jeecg/JVxeTable/src/utils/enhancedUtils.ts index 10f74eb..18b360a 100644 --- a/src/components/jeecg/JVxeTable/src/utils/enhancedUtils.ts +++ b/src/components/jeecg/JVxeTable/src/utils/enhancedUtils.ts @@ -1,154 +1,155 @@ -import type {Ref, ComponentInternalInstance} from 'vue' -import {unref, isRef} from 'vue' -import { useDefaultEnhanced } from '../hooks/useJVxeComponent' -import { isFunction, isObject, isString } from '/@/utils/is' -import { JVxeTypes } from '../types' -import { JVxeComponent } from '../types/JVxeComponent' -import { componentMap } from '../componentMap' +import type { Ref, ComponentInternalInstance } from 'vue'; +import { unref, isRef } from 'vue'; +import { useDefaultEnhanced } from '../hooks/useJVxeComponent'; +import { isFunction, isObject, isString } from '/@/utils/is'; +import { JVxeTypes } from '../types'; +import { JVxeComponent } from '../types/JVxeComponent'; +import { componentMap } from '../componentMap'; // 已注册的组件增强 -const enhancedMap = new Map() +const enhancedMap = new Map(); /** * 获取某个组件的增强 * @param type JVxeTypes */ export function getEnhanced(type: JVxeTypes | string): JVxeComponent.Enhanced { - let $type: JVxeTypes = type + let $type: JVxeTypes = type; if (!enhancedMap.has($type)) { - let defaultEnhanced = useDefaultEnhanced() + let defaultEnhanced = useDefaultEnhanced(); if (componentMap.has($type)) { - let enhanced = componentMap.get($type)?.enhanced ?? {} + let enhanced = componentMap.get($type)?.enhanced ?? {}; if (isObject(enhanced)) { - Object.keys(defaultEnhanced).forEach(key => { - let def = defaultEnhanced[key] + Object.keys(defaultEnhanced).forEach((key) => { + let def = defaultEnhanced[key]; if (enhanced.hasOwnProperty(key)) { // 方法如果存在就不覆盖 if (!isFunction(def) && !isString(def)) { - enhanced[key] = Object.assign({}, def, enhanced[key]) + enhanced[key] = Object.assign({}, def, enhanced[key]); } } else { - enhanced[key] = def + enhanced[key] = def; } - }) - enhancedMap.set($type, enhanced) - return enhanced + }); + enhancedMap.set($type, enhanced); + return enhanced; } } else { - throw new Error(`[JVxeTable] ${$type} 组件尚未注册,获取增强失败`) + throw new Error(`[JVxeTable] ${$type} 组件尚未注册,获取增强失败`); } - enhancedMap.set($type, defaultEnhanced) + enhancedMap.set($type, defaultEnhanced); } - return enhancedMap.get($type) + return enhancedMap.get($type); } /** 辅助方法:替换${...}变量 */ export function replaceProps(col, value) { if (value && typeof value === 'string') { - let text = value - text = text.replace(/\${title}/g, col.title) - text = text.replace(/\${key}/g, col.key) - text = text.replace(/\${defaultValue}/g, col.defaultValue) - return text + let text = value; + text = text.replace(/\${title}/g, col.title); + text = text.replace(/\${key}/g, col.key); + text = text.replace(/\${defaultValue}/g, col.defaultValue); + return text; } - return value + return value; } type dispatchEventOptions = { // JVxeTable 的 props - props, + props; // 触发的 event 事件对象 - $event, + $event; // 行、列 - row?, column?, + row?; + column?; // JVxeTable的vue3实例 - instance?: ComponentInternalInstance, + instance?: ComponentInternalInstance; // 要寻找的className - className: string, + className: string; // 重写找到dom后的处理方法 - handler?: Fn, + handler?: Fn; // 是否直接执行click方法而不是模拟click事件 - isClick?: boolean, -} + isClick?: boolean; +}; /** 模拟触发事件 */ export function dispatchEvent(options: dispatchEventOptions) { - const {props, $event, row, column, instance, className, handler, isClick} = options + const { props, $event, row, column, instance, className, handler, isClick } = options; if ((!$event || !$event.path) && !instance) { - return + return; } // alwaysEdit 下不模拟触发事件,否者会导致触发两次 if (props && props.alwaysEdit) { - return + return; } let getCell = () => { - let paths: HTMLElement[] = [...($event?.path ?? [])] + let paths: HTMLElement[] = [...($event?.path ?? [])]; // 通过 instance 获取 cell dom对象 if (row && column) { - let selector = `table.vxe-table--body tbody tr[rowid='${row.id}'] td[colid='${column.id}']` - let cellDom = instance!.vnode?.el?.querySelector(selector) + let selector = `table.vxe-table--body tbody tr[rowid='${row.id}'] td[colid='${column.id}']`; + let cellDom = instance!.vnode?.el?.querySelector(selector); if (cellDom) { - paths.unshift(cellDom) + paths.unshift(cellDom); } } for (const el of paths) { if (el.classList?.contains('vxe-body--column')) { - return el + return el; } } - return null - } - let cell = getCell() + return null; + }; + let cell = getCell(); if (cell) { window.setTimeout(() => { let getElement = () => { - let classList = className.split(' ') + let classList = className.split(' '); if (classList.length > 0) { const getClassName = (cls: string) => { if (cls.startsWith('.')) { - return cls.substring(1, cls.length) + return cls.substring(1, cls.length); } - return cls - } + return cls; + }; let get = (target, className, idx = 0) => { - let elements = target.getElementsByClassName(getClassName(className)) + let elements = target.getElementsByClassName(getClassName(className)); if (elements && elements.length > 0) { - return elements[idx] + return elements[idx]; } - return null - } - let element: HTMLElement = get(cell, classList[0]) + return null; + }; + let element: HTMLElement = get(cell, classList[0]); for (let i = 1; i < classList.length; i++) { if (!element) { - break + break; } - element = get(element, classList[i]) + element = get(element, classList[i]); } - return element + return element; } - return null - } - let element = getElement() + return null; + }; + let element = getElement(); if (element) { if (isFunction(handler)) { - handler(element) + handler(element); } else { // 模拟触发点击事件 if (isClick) { - element.click() + element.click(); } else { - element.dispatchEvent($event) + element.dispatchEvent($event); } } } - }, 10) + }, 10); } else { - console.warn('【JVxeTable】dispatchEvent 获取 cell 失败') + console.warn('【JVxeTable】dispatchEvent 获取 cell 失败'); } } /** 绑定 VxeTable 数据 */ export function vModel(value, row, column: Ref | string) { - let property = isRef(column) ? column.value.property : column - unref(row)[property] = value -} \ No newline at end of file + let property = isRef(column) ? column.value.property : column; + unref(row)[property] = value; +} diff --git a/src/components/jeecg/JVxeTable/src/utils/registerUtils.ts b/src/components/jeecg/JVxeTable/src/utils/registerUtils.ts index 07dc2da..4a4f9ea 100644 --- a/src/components/jeecg/JVxeTable/src/utils/registerUtils.ts +++ b/src/components/jeecg/JVxeTable/src/utils/registerUtils.ts @@ -1,10 +1,10 @@ -import type { Component } from 'vue' -import { h } from 'vue' -import VXETable from 'vxe-table' -import { definedComponent, addComponent, componentMap, spanEnds, excludeKeywords } from '../componentMap' -import { JVxeRenderType, JVxeTypePrefix, JVxeTypes } from '../types/JVxeTypes' -import { getEnhanced } from './enhancedUtils' -import { isFunction } from '/@/utils/is' +import type { Component } from 'vue'; +import { h } from 'vue'; +import VXETable from 'vxe-table'; +import { definedComponent, addComponent, componentMap, spanEnds, excludeKeywords } from '../componentMap'; +import { JVxeRenderType, JVxeTypePrefix, JVxeTypes } from '../types/JVxeTypes'; +import { getEnhanced } from './enhancedUtils'; +import { isFunction } from '/@/utils/is'; /** * 判断某个组件是否已注册 @@ -12,9 +12,9 @@ import { isFunction } from '/@/utils/is' */ export function isRegistered(type: JVxeTypes | string) { if (excludeKeywords.includes(type)) { - return true + return true; } - return componentMap.has(type) + return componentMap.has(type); } /** @@ -25,8 +25,8 @@ export function isRegistered(type: JVxeTypes | string) { * @param spanComponent */ export function registerComponent(type: JVxeTypes, component: Component, spanComponent?: Component) { - addComponent(type, component, spanComponent) - registerOneComponent(type) + addComponent(type, component, spanComponent); + registerOneComponent(type); } /** @@ -36,15 +36,15 @@ export function registerComponent(type: JVxeTypes, component: Component, spanCom * @param promise */ export async function registerAsyncComponent(type: JVxeTypes, promise: Promise) { - const result = await promise + const result = await promise; if (isFunction(result.installJVxe)) { result.install((component: Component, spanComponent?: Component) => { - addComponent(type, component, spanComponent) - registerOneComponent(type) - }) + addComponent(type, component, spanComponent); + registerOneComponent(type); + }); } else { - addComponent(type, result.default) - registerOneComponent(type) + addComponent(type, result.default); + registerOneComponent(type); } } @@ -52,14 +52,14 @@ export async function registerAsyncComponent(type: JVxeTypes, promise: Promise { + const components = [...componentMap.keys()]; + components.forEach((type) => { if (!type.endsWith(spanEnds)) { - registerOneComponent(type) + registerOneComponent(type); } - }) + }); } /** @@ -68,29 +68,29 @@ export function registerAllComponent() { * @param type 组件 type */ export function registerOneComponent(type: JVxeTypes) { - const component = componentMap.get(type) + const component = componentMap.get(type); if (component) { - const switches = getEnhanced(type).switches + const switches = getEnhanced(type).switches; if (switches.editRender && !switches.visible) { - createEditRender(type, component) + createEditRender(type, component); } else { - createCellRender(type, component) + createCellRender(type, component); } } else { - throw new Error(`【registerOneComponent】"${type}"不存在于componentMap中`) + throw new Error(`【registerOneComponent】"${type}"不存在于componentMap中`); } } /** 注册可编辑组件 */ function createEditRender(type: JVxeTypes, component: Component, spanComponent?: Component) { // 获取当前组件的增强 - const enhanced = getEnhanced(type) + const enhanced = getEnhanced(type); if (!spanComponent) { if (componentMap.has(type + spanEnds)) { - spanComponent = componentMap.get(type + spanEnds) + spanComponent = componentMap.get(type + spanEnds); } else { // 默认的 span 组件为 normal - spanComponent = componentMap.get(JVxeTypes.normal) + spanComponent = componentMap.get(JVxeTypes.normal); } } // 添加渲染 @@ -101,28 +101,30 @@ function createEditRender(type: JVxeTypes, component: Component, spanComponent?: renderCell: createRender(type, spanComponent, JVxeRenderType.spaner), // 增强注册 ...enhanced.installOptions, - }) + }); } /** 注册普通组件 */ function createCellRender(type: JVxeTypes, component: Component = componentMap.get(JVxeTypes.normal)) { // 获取当前组件的增强 - const enhanced = getEnhanced(type) + const enhanced = getEnhanced(type); VXETable.renderer.add(JVxeTypePrefix + type, { // 默认显示模板 renderDefault: createRender(type, component, JVxeRenderType.default), // 增强注册 ...enhanced.installOptions, - }) + }); } function createRender(type, component, renderType) { return function (renderOptions, params) { - return [h(component, { - type: type, - params: params, - renderOptions: renderOptions, - renderType: renderType, - })] - } + return [ + h(component, { + type: type, + params: params, + renderOptions: renderOptions, + renderType: renderType, + }), + ]; + }; } diff --git a/src/components/jeecg/JVxeTable/src/utils/vxeUtils.ts b/src/components/jeecg/JVxeTable/src/utils/vxeUtils.ts index e49acc1..108fd67 100644 --- a/src/components/jeecg/JVxeTable/src/utils/vxeUtils.ts +++ b/src/components/jeecg/JVxeTable/src/utils/vxeUtils.ts @@ -7,15 +7,15 @@ */ export function getParentNodeByTagName(dom: HTMLElement, tagName: string = 'body'): HTMLElement | null { if (tagName === 'body') { - return document.body + return document.body; } if (dom.parentElement) { if (dom.parentElement.tagName.toLowerCase() === tagName.trim().toLowerCase()) { - return dom.parentElement + return dom.parentElement; } else { - return getParentNodeByTagName(dom.parentElement, tagName) + return getParentNodeByTagName(dom.parentElement, tagName); } } else { - return null + return null; } } diff --git a/src/components/jeecg/JVxeTable/src/vxe.data.ts b/src/components/jeecg/JVxeTable/src/vxe.data.ts index 756eea0..8a109c2 100644 --- a/src/components/jeecg/JVxeTable/src/vxe.data.ts +++ b/src/components/jeecg/JVxeTable/src/vxe.data.ts @@ -1,4 +1,4 @@ -import { propTypes } from '/@/utils/propTypes' +import { propTypes } from '/@/utils/propTypes'; export const vxeProps = () => ({ rowKey: propTypes.string.def('id'), @@ -39,10 +39,7 @@ export const vxeProps = () => ({ // 页面是否在加载中 loading: propTypes.bool.def(false), // 表格高度 - height: propTypes.oneOfType([ - propTypes.number, - propTypes.string, - ]).def('auto'), + height: propTypes.oneOfType([propTypes.number, propTypes.string]).def('auto'), // 最大高度 maxHeight: { type: Number, @@ -91,6 +88,6 @@ export const vxeProps = () => ({ addSetActive: propTypes.bool.def(true), // 是否开启键盘编辑 keyboardEdit: propTypes.bool.def(false), -}) +}); -export const vxeEmits = ['save', 'added', 'removed', 'inserted', 'dragged', 'selectRowChange', 'pageChange', 'valueChange'] \ No newline at end of file +export const vxeEmits = ['save', 'added', 'removed', 'inserted', 'dragged', 'selectRowChange', 'pageChange', 'valueChange']; diff --git a/src/components/jeecg/JVxeTable/types.ts b/src/components/jeecg/JVxeTable/types.ts index 0fe3879..7e668f7 100644 --- a/src/components/jeecg/JVxeTable/types.ts +++ b/src/components/jeecg/JVxeTable/types.ts @@ -1,6 +1,6 @@ -import JVxeTable from './src/JVxeTable' +import JVxeTable from './src/JVxeTable'; -export type { JVxeComponent } from './src/types/JVxeComponent' -export type { JVxeColumn, JVxeLinkageConfig } from './src/types' -export { JVxeTypes } from './src/types/JVxeTypes' -export type JVxeTableInstance = InstanceType \ No newline at end of file +export type { JVxeComponent } from './src/types/JVxeComponent'; +export type { JVxeColumn, JVxeLinkageConfig } from './src/types'; +export { JVxeTypes } from './src/types/JVxeTypes'; +export type JVxeTableInstance = InstanceType; diff --git a/src/components/jeecg/JVxeTable/utils.ts b/src/components/jeecg/JVxeTable/utils.ts index af259f8..edd3e2c 100644 --- a/src/components/jeecg/JVxeTable/utils.ts +++ b/src/components/jeecg/JVxeTable/utils.ts @@ -1 +1 @@ -export { dispatchEvent, vModel } from './src/utils/enhancedUtils' \ No newline at end of file +export { dispatchEvent, vModel } from './src/utils/enhancedUtils'; diff --git a/src/components/jeecg/OnLine/JPopupOnlReport.vue b/src/components/jeecg/OnLine/JPopupOnlReport.vue index f7a3df0..df84be3 100644 --- a/src/components/jeecg/OnLine/JPopupOnlReport.vue +++ b/src/components/jeecg/OnLine/JPopupOnlReport.vue @@ -3,48 +3,47 @@
- diff --git a/src/layouts/default/menu/useLayoutMenu.ts b/src/layouts/default/menu/useLayoutMenu.ts index a7bf665..e5792da 100644 --- a/src/layouts/default/menu/useLayoutMenu.ts +++ b/src/layouts/default/menu/useLayoutMenu.ts @@ -19,13 +19,9 @@ export function useSplitMenu(splitType: Ref) { const throttleHandleSplitLeftMenu = useThrottleFn(handleSplitLeftMenu, 50); - const splitNotLeft = computed( - () => unref(splitType) !== MenuSplitTyeEnum.LEFT && !unref(getIsHorizontal) - ); + const splitNotLeft = computed(() => unref(splitType) !== MenuSplitTyeEnum.LEFT && !unref(getIsHorizontal)); - const getSplitLeft = computed( - () => !unref(getSplit) || unref(splitType) !== MenuSplitTyeEnum.LEFT - ); + const getSplitLeft = computed(() => !unref(getSplit) || unref(splitType) !== MenuSplitTyeEnum.LEFT); const getSpiltTop = computed(() => unref(splitType) === MenuSplitTyeEnum.TOP); diff --git a/src/layouts/default/setting/SettingDrawer.tsx b/src/layouts/default/setting/SettingDrawer.tsx index db405f5..68efce5 100644 --- a/src/layouts/default/setting/SettingDrawer.tsx +++ b/src/layouts/default/setting/SettingDrawer.tsx @@ -1,14 +1,7 @@ import { defineComponent, computed, unref } from 'vue'; import { BasicDrawer } from '/@/components/Drawer/index'; import { Divider } from 'ant-design-vue'; -import { - TypePicker, - ThemeColorPicker, - SettingFooter, - SwitchItem, - SelectItem, - InputNumberItem, -} from './components'; +import { TypePicker, ThemeColorPicker, SettingFooter, SwitchItem, SelectItem, InputNumberItem } from './components'; import { AppDarkModeToggle } from '/@/components/Application'; @@ -23,44 +16,19 @@ import { useI18n } from '/@/hooks/web/useI18n'; import { baseHandler } from './handler'; -import { - HandlerEnum, - contentModeOptions, - topMenuAlignOptions, - getMenuTriggerOptions, - routerTransitionOptions, - menuTypeList, - mixSidebarTriggerOptions, - tabsThemeOptions, -} from './enum' +import { HandlerEnum, contentModeOptions, topMenuAlignOptions, getMenuTriggerOptions, routerTransitionOptions, menuTypeList, mixSidebarTriggerOptions, tabsThemeOptions } from './enum'; -import { - HEADER_PRESET_BG_COLOR_LIST, - SIDE_BAR_BG_COLOR_LIST, - APP_PRESET_COLOR_LIST, -} from '/@/settings/designSetting'; +import { HEADER_PRESET_BG_COLOR_LIST, SIDE_BAR_BG_COLOR_LIST, APP_PRESET_COLOR_LIST } from '/@/settings/designSetting'; const { t } = useI18n(); export default defineComponent({ name: 'SettingDrawer', setup(_, { attrs }) { - const { - getContentMode, - getShowFooter, - getShowBreadCrumb, - getShowBreadCrumbIcon, - getShowLogo, - getFullContent, - getColorWeak, - getGrayMode, - getLockTime, - getShowDarkModeToggle, - getThemeColor, - } = useRootSetting(); + const { getContentMode, getShowFooter, getShowBreadCrumb, getShowBreadCrumbIcon, getShowLogo, getFullContent, getColorWeak, getGrayMode, getLockTime, getShowDarkModeToggle, getThemeColor } = + useRootSetting(); - const { getOpenPageLoading, getBasicTransition, getEnableTransition, getOpenNProgress } = - useTransitionSetting(); + const { getOpenPageLoading, getBasicTransition, getEnableTransition, getOpenNProgress } = useTransitionSetting(); const { getIsHorizontal, @@ -83,14 +51,9 @@ export default defineComponent({ getMixSideFixed, } = useMenuSetting(); - const { - getShowHeader, - getFixed: getHeaderFixed, - getHeaderBgColor, - getShowSearch, - } = useHeaderSetting(); + const { getShowHeader, getFixed: getHeaderFixed, getHeaderBgColor, getShowSearch } = useHeaderSetting(); - const { getShowMultipleTab, getShowQuick, getShowRedo, getShowFold, getTabsTheme } = useMultipleTabSetting() + const { getShowMultipleTab, getShowQuick, getShowRedo, getShowFold, getTabsTheme } = useMultipleTabSetting(); const getShowMenuRef = computed(() => { return unref(getShowMenu) && !unref(getIsHorizontal); @@ -115,33 +78,15 @@ export default defineComponent({ } function renderHeaderTheme() { - return ( - - ); + return ; } function renderSiderTheme() { - return ( - - ); + return ; } function renderMainTheme() { - return ( - - ); + return ; } /** @@ -158,12 +103,7 @@ export default defineComponent({ return ( <> - + {/**/} - {/**/} - + - + { - return parseInt(value) === 0 - ? `0(${t('layout.setting.notAutoScreenLock')})` - : `${value}${t('layout.setting.minute')}`; + return parseInt(value) === 0 ? `0(${t('layout.setting.notAutoScreenLock')})` : `${value}${t('layout.setting.minute')}`; }} /> - + - - + + {/**/} - + {/**/} - + - + ); } @@ -374,22 +270,10 @@ export default defineComponent({ function renderTransition() { return ( <> - - + + - + ( - + {unref(getShowDarkModeToggle) && {() => t('layout.setting.darkMode')}} {unref(getShowDarkModeToggle) && } {() => t('layout.setting.navMode')} diff --git a/src/layouts/default/setting/components/InputNumberItem.vue b/src/layouts/default/setting/components/InputNumberItem.vue index 8d679db..7a664ae 100644 --- a/src/layouts/default/setting/components/InputNumberItem.vue +++ b/src/layouts/default/setting/components/InputNumberItem.vue @@ -1,12 +1,7 @@ diff --git a/src/views/dashboard/Analysis/components/ChartGroupCard.vue b/src/views/dashboard/Analysis/components/ChartGroupCard.vue index 6540c75..8b6fd25 100644 --- a/src/views/dashboard/Analysis/components/ChartGroupCard.vue +++ b/src/views/dashboard/Analysis/components/ChartGroupCard.vue @@ -1,96 +1,98 @@ \ No newline at end of file + .ant-upload-select-picture-card .ant-upload-text { + margin-top: 8px; + color: #666; + } + diff --git a/src/views/demo/jeecg/TableTotal.vue b/src/views/demo/jeecg/TableTotal.vue index 389df2f..d95e312 100644 --- a/src/views/demo/jeecg/TableTotal.vue +++ b/src/views/demo/jeecg/TableTotal.vue @@ -1,59 +1,59 @@ \ No newline at end of file + function onSummary(tableData: Recordable[]) { + // 可用工具方法自动计算合计 + const totals = mapTableTotalSummary(tableData, ['point', 'level']); + return [ + totals, + { + _row: '平均', + _index: '平均', + // 计算平均值 + point: (totals.point / tableData.length).toFixed(2), + level: (totals.level / tableData.length).toFixed(0), + }, + ]; + } + diff --git a/src/views/demo/jeecg/erplist/JeecgOrderCustomerList.vue b/src/views/demo/jeecg/erplist/JeecgOrderCustomerList.vue index 544168a..4e5bea3 100644 --- a/src/views/demo/jeecg/erplist/JeecgOrderCustomerList.vue +++ b/src/views/demo/jeecg/erplist/JeecgOrderCustomerList.vue @@ -1,148 +1,147 @@ - + diff --git a/src/views/demo/jeecg/erplist/JeecgOrderTicketList.vue b/src/views/demo/jeecg/erplist/JeecgOrderTicketList.vue index f6f6e3e..8628487 100644 --- a/src/views/demo/jeecg/erplist/JeecgOrderTicketList.vue +++ b/src/views/demo/jeecg/erplist/JeecgOrderTicketList.vue @@ -1,147 +1,146 @@ - + diff --git a/src/views/demo/jeecg/erplist/components/JeecgOrderCustomerModal.vue b/src/views/demo/jeecg/erplist/components/JeecgOrderCustomerModal.vue index e9021e5..3590ea6 100644 --- a/src/views/demo/jeecg/erplist/components/JeecgOrderCustomerModal.vue +++ b/src/views/demo/jeecg/erplist/components/JeecgOrderCustomerModal.vue @@ -1,57 +1,57 @@ diff --git a/src/views/demo/jeecg/erplist/components/JeecgOrderModal.vue b/src/views/demo/jeecg/erplist/components/JeecgOrderModal.vue index f29344e..f5511cf 100644 --- a/src/views/demo/jeecg/erplist/components/JeecgOrderModal.vue +++ b/src/views/demo/jeecg/erplist/components/JeecgOrderModal.vue @@ -1,52 +1,52 @@ diff --git a/src/views/demo/jeecg/erplist/components/JeecgOrderTicketModal.vue b/src/views/demo/jeecg/erplist/components/JeecgOrderTicketModal.vue index 12c72dd..3890222 100644 --- a/src/views/demo/jeecg/erplist/components/JeecgOrderTicketModal.vue +++ b/src/views/demo/jeecg/erplist/components/JeecgOrderTicketModal.vue @@ -1,57 +1,57 @@ diff --git a/src/views/demo/jeecg/erplist/erplist.api.ts b/src/views/demo/jeecg/erplist/erplist.api.ts index f5fa869..ca9509d 100644 --- a/src/views/demo/jeecg/erplist/erplist.api.ts +++ b/src/views/demo/jeecg/erplist/erplist.api.ts @@ -1,144 +1,139 @@ -import {defHttp} from '/@/utils/http/axios'; -import {Modal} from 'ant-design-vue'; +import { defHttp } from '/@/utils/http/axios'; +import { Modal } from 'ant-design-vue'; enum Api { - list = '/test/order/orderList', - save = '/test/order/add', - edit = '/test/order/edit', - deleteOne = '/test/order/delete', - deleteBatch = '/test/order/deleteBatch', - customList = '/test/order/listOrderCustomerByMainId', - saveCustomer = '/test/order/addCustomer', - editCustomer = '/test/order/editCustomer', - deleteCustomer = '/test/order/deleteCustomer', - deleteBatchCustomer = '/test/order/deleteBatchCustomer', - ticketList = '/test/order/listOrderTicketByMainId', - saveTicket = '/test/order/addTicket', - editTicket = '/test/order/editTicket', - deleteTicket = '/test/order/deleteTicket', - deleteBatchTicket = '/test/order/deleteBatchTicket', + list = '/test/order/orderList', + save = '/test/order/add', + edit = '/test/order/edit', + deleteOne = '/test/order/delete', + deleteBatch = '/test/order/deleteBatch', + customList = '/test/order/listOrderCustomerByMainId', + saveCustomer = '/test/order/addCustomer', + editCustomer = '/test/order/editCustomer', + deleteCustomer = '/test/order/deleteCustomer', + deleteBatchCustomer = '/test/order/deleteBatchCustomer', + ticketList = '/test/order/listOrderTicketByMainId', + saveTicket = '/test/order/addTicket', + editTicket = '/test/order/editTicket', + deleteTicket = '/test/order/deleteTicket', + deleteBatchTicket = '/test/order/deleteBatchTicket', } /** * 列表接口 * @param params */ -export const list = (params) => - defHttp.get({url: Api.list, params}); +export const list = (params) => defHttp.get({ url: Api.list, params }); /** * 删除 */ export const deleteOne = (params, handleSuccess) => { - return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); -} + return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; /** * 批量删除 * @param params */ export const batchDelete = (params, handleSuccess) => { - Modal.confirm({ - title: '确认删除', - content: '是否删除选中数据', - okText: '确认', - cancelText: '取消', - onOk: () => { - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); - } - }); -} + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; /** * 保存或者更新 * @param params */ export const saveOrUpdate = (params, isUpdate) => { - let url = isUpdate ? Api.edit : Api.save; - return defHttp.post({url: url, params}); -} + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({ url: url, params }); +}; /** * 列表接口 * @param params */ -export const customList = (params) => - defHttp.get({url: Api.customList, params}); - +export const customList = (params) => defHttp.get({ url: Api.customList, params }); /** * 删除 */ export const deleteCustomer = (params, handleSuccess) => { - return defHttp.delete({url: Api.deleteCustomer, params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); -} + return defHttp.delete({ url: Api.deleteCustomer, params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; /** * 批量删除 * @param params */ export const deleteBatchCustomer = (params, handleSuccess) => { - Modal.confirm({ - title: '确认删除', - content: '是否删除选中数据', - okText: '确认', - cancelText: '取消', - onOk: () => { - return defHttp.delete({url: Api.deleteBatchCustomer, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); - } - }); -} + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatchCustomer, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; /** * 保存或者更新 * @param params */ export const saveOrUpdateCustomer = (params, isUpdate) => { - let url = isUpdate ? Api.editCustomer : Api.saveCustomer; - return defHttp.post({url: url, params}); -} + let url = isUpdate ? Api.editCustomer : Api.saveCustomer; + return defHttp.post({ url: url, params }); +}; /** * 列表接口 * @param params */ -export const ticketList = (params) => - defHttp.get({url: Api.ticketList, params}); - +export const ticketList = (params) => defHttp.get({ url: Api.ticketList, params }); /** * 删除 */ export const deleteTicket = (params, handleSuccess) => { - return defHttp.delete({url: Api.deleteTicket, params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); -} + return defHttp.delete({ url: Api.deleteTicket, params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; /** * 批量删除 * @param params */ export const deleteBatchTicket = (params, handleSuccess) => { - Modal.confirm({ - title: '确认删除', - content: '是否删除选中数据', - okText: '确认', - cancelText: '取消', - onOk: () => { - return defHttp.delete({url: Api.deleteBatchTicket, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); - } - }); -} + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatchTicket, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; /** * 保存或者更新 * @param params */ export const saveOrUpdateTicket = (params, isUpdate) => { - let url = isUpdate ? Api.editTicket : Api.saveTicket; - return defHttp.post({url: url, params}); -} + let url = isUpdate ? Api.editTicket : Api.saveTicket; + return defHttp.post({ url: url, params }); +}; diff --git a/src/views/demo/jeecg/erplist/erplist.data.ts b/src/views/demo/jeecg/erplist/erplist.data.ts index d3ca255..275891b 100644 --- a/src/views/demo/jeecg/erplist/erplist.data.ts +++ b/src/views/demo/jeecg/erplist/erplist.data.ts @@ -1,239 +1,238 @@ -import {BasicColumn} from '/@/components/Table'; -import {FormSchema} from '/@/components/Table'; -import {render} from "/@/utils/common/renderUtils"; +import { BasicColumn } from '/@/components/Table'; +import { FormSchema } from '/@/components/Table'; +import { render } from '/@/utils/common/renderUtils'; export const columns: BasicColumn[] = [ - { - title: '订单号', - dataIndex: 'orderCode', - width: 260, + { + title: '订单号', + dataIndex: 'orderCode', + width: 260, + }, + { + title: '订单类型', + dataIndex: 'ctype', + width: 160, + customRender: ({ text }) => { + return text == '1' ? '国内订单' : text == '2' ? '国际订单' : ''; }, - { - title: '订单类型', - dataIndex: 'ctype', - width: 160, - customRender: ({text}) => { - return text == '1' ? '国内订单' : text == '2' ? "国际订单" : '' - } - }, - { - title: '订单日期', - dataIndex: 'orderDate', - width: 300, - }, - { - title: '订单金额', - width: 200, - dataIndex: 'orderMoney', - }, - { - title: '订单备注', - width: 200, - dataIndex: 'content', - } + }, + { + title: '订单日期', + dataIndex: 'orderDate', + width: 300, + }, + { + title: '订单金额', + width: 200, + dataIndex: 'orderMoney', + }, + { + title: '订单备注', + width: 200, + dataIndex: 'content', + }, ]; - export const searchFormSchema: FormSchema[] = [ - { - label: '订单号', - field: 'orderCode', - component: 'Input', - colProps: {span: 6} - }, - { - label: '订单类型', - field: 'ctype', - component: 'Select', - componentProps: { - options: [ - { - label: '国内订单', - value: '1', - key: '1', - }, - { - label: '国际订单', - value: '2', - key: '2', - }, - ], + { + label: '订单号', + field: 'orderCode', + component: 'Input', + colProps: { span: 6 }, + }, + { + label: '订单类型', + field: 'ctype', + component: 'Select', + componentProps: { + options: [ + { + label: '国内订单', + value: '1', + key: '1', }, - colProps: {span: 6}, - } + { + label: '国际订单', + value: '2', + key: '2', + }, + ], + }, + colProps: { span: 6 }, + }, ]; export const formSchema: FormSchema[] = [ - { - label: '', - field: 'id', - component: 'Input', - show: false - }, - { - label: '订单号', - field: 'orderCode', - component: 'Input', - required: true - }, - { - label: '订单类型', - field: 'ctype', - component: 'Select', - componentProps: { - options: [ - { - label: '国内订单', - value: '1', - key: '1', - }, - { - label: '国际订单', - value: '2', - key: '2', - }, - ], + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + label: '订单号', + field: 'orderCode', + component: 'Input', + required: true, + }, + { + label: '订单类型', + field: 'ctype', + component: 'Select', + componentProps: { + options: [ + { + label: '国内订单', + value: '1', + key: '1', }, - }, - { - label: '订单日期', - field: 'orderDate', - component: 'DatePicker', - componentProps: { - valueFormat: 'YYYY-MM-DD hh:mm:ss', + { + label: '国际订单', + value: '2', + key: '2', }, + ], }, - { - label: '订单金额', - field: 'orderMoney', - component: 'InputNumber', + }, + { + label: '订单日期', + field: 'orderDate', + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD hh:mm:ss', }, - { - label: '订单备注', - field: 'content', - component: 'Input', - } + }, + { + label: '订单金额', + field: 'orderMoney', + component: 'InputNumber', + }, + { + label: '订单备注', + field: 'content', + component: 'Input', + }, ]; export const customColumns: BasicColumn[] = [ - { - title: '客户名', - dataIndex: 'name', - width: 260, + { + title: '客户名', + dataIndex: 'name', + width: 260, + }, + { + title: '性别', + dataIndex: 'sex', + width: 100, + customRender: ({ text }) => { + return render.renderDict(text, 'sex'); }, - { - title: '性别', - dataIndex: 'sex', - width: 100, - customRender: ({text}) => { - return render.renderDict(text, 'sex') - } - }, - { - title: '身份证号', - dataIndex: 'idcard', - width: 300, - }, - { - title: '电话', - width: 200, - dataIndex: 'telphone', - } + }, + { + title: '身份证号', + dataIndex: 'idcard', + width: 300, + }, + { + title: '电话', + width: 200, + dataIndex: 'telphone', + }, ]; export const customerFormSchema: FormSchema[] = [ - { - label: '', - field: 'id', - component: 'Input', - show: false + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + label: '客户姓名', + field: 'name', + component: 'Input', + required: true, + }, + { + label: '性别', + field: 'sex', + component: 'JDictSelectTag', + componentProps: { + dictCode: 'sex', + placeholder: '请选择性别', }, - { - label: '客户姓名', - field: 'name', - component: 'Input', - required: true + }, + { + label: '身份证号码', + field: 'idcard', + component: 'Input', + }, + { + label: '身份证扫描件', + field: 'idcardPic', + component: 'JImageUpload', + componentProps: { + fileMax: 2, }, - { - label: '性别', - field: 'sex', - component: 'JDictSelectTag', - componentProps: { - dictCode: 'sex', - placeholder: '请选择性别', - }, - }, - { - label: '身份证号码', - field: 'idcard', - component: 'Input', - }, - { - label: '身份证扫描件', - field: 'idcardPic', - component: 'JImageUpload', - componentProps: { - fileMax: 2 - }, - }, - { - label: '联系方式', - field: 'telphone', - component: 'Input', - rules: [{required: false, pattern: /^1[3|4|5|7|8|9][0-9]\d{8}$/, message: '手机号码格式有误'}], - }, - { - label: 'orderId', - field: 'orderId', - component: 'Input', - show: false - } + }, + { + label: '联系方式', + field: 'telphone', + component: 'Input', + rules: [{ required: false, pattern: /^1[3|4|5|7|8|9][0-9]\d{8}$/, message: '手机号码格式有误' }], + }, + { + label: 'orderId', + field: 'orderId', + component: 'Input', + show: false, + }, ]; export const ticketColumns: BasicColumn[] = [ - { - title: '航班号', - dataIndex: 'ticketCode', - }, - { - title: '航班时间', - dataIndex: 'tickectDate', - }, - { - title: '创建人', - dataIndex: 'createBy', - }, - { - title: '创建时间', - dataIndex: 'createTime', - } + { + title: '航班号', + dataIndex: 'ticketCode', + }, + { + title: '航班时间', + dataIndex: 'tickectDate', + }, + { + title: '创建人', + dataIndex: 'createBy', + }, + { + title: '创建时间', + dataIndex: 'createTime', + }, ]; export const ticketFormSchema: FormSchema[] = [ - { - label: '', - field: 'id', - component: 'Input', - show: false + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + label: '航班号', + field: 'ticketCode', + component: 'Input', + required: true, + }, + { + label: '航班时间', + field: 'tickectDate', + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD hh:mm:ss', }, - { - label: '航班号', - field: 'ticketCode', - component: 'Input', - required: true - }, - { - label: '航班时间', - field: 'tickectDate', - component: 'DatePicker', - componentProps: { - valueFormat: 'YYYY-MM-DD hh:mm:ss', - }, - }, - { - label: 'orderId', - field: 'orderId', - component: 'Input', - show: false - } + }, + { + label: 'orderId', + field: 'orderId', + component: 'Input', + show: false, + }, ]; diff --git a/src/views/demo/jeecg/erplist/index.vue b/src/views/demo/jeecg/erplist/index.vue index 6a48fd0..b1219d2 100644 --- a/src/views/demo/jeecg/erplist/index.vue +++ b/src/views/demo/jeecg/erplist/index.vue @@ -1,160 +1,160 @@ - + diff --git a/src/views/demo/jeecg/index.vue b/src/views/demo/jeecg/index.vue index b88539b..e0bb1a2 100644 --- a/src/views/demo/jeecg/index.vue +++ b/src/views/demo/jeecg/index.vue @@ -1,6 +1,6 @@ diff --git a/src/views/demo/table/FormTable.vue b/src/views/demo/table/FormTable.vue index 23300aa..f73c59b 100644 --- a/src/views/demo/table/FormTable.vue +++ b/src/views/demo/table/FormTable.vue @@ -1,8 +1,5 @@ - +
diff --git a/src/views/monitor/datasource/DataSourceModal.vue b/src/views/monitor/datasource/DataSourceModal.vue index c1f2834..2839c77 100644 --- a/src/views/monitor/datasource/DataSourceModal.vue +++ b/src/views/monitor/datasource/DataSourceModal.vue @@ -1,18 +1,18 @@ diff --git a/src/views/monitor/disk/DiskInfo.vue b/src/views/monitor/disk/DiskInfo.vue index 873edc7..7154678 100644 --- a/src/views/monitor/disk/DiskInfo.vue +++ b/src/views/monitor/disk/DiskInfo.vue @@ -1,12 +1,12 @@ @@ -20,18 +20,18 @@ const spinning = ref(true); function loadRedisInfo() { - queryDiskInfo().then((res) => { - for (let i = 0; i < res.length; i++) { - // 当前算法算的是磁盘的已使用空间 - res[i].restPPT = 100 - parseInt(String((res[i].rest / res[i].max) * 100)); - } - diskInfo.value = res; - }).finally(() => spinning.value = false); + queryDiskInfo() + .then((res) => { + for (let i = 0; i < res.length; i++) { + // 当前算法算的是磁盘的已使用空间 + res[i].restPPT = 100 - parseInt(String((res[i].rest / res[i].max) * 100)); + } + diskInfo.value = res; + }) + .finally(() => (spinning.value = false)); } onMounted(() => { loadRedisInfo(); }); - - diff --git a/src/views/monitor/disk/disk.api.ts b/src/views/monitor/disk/disk.api.ts index 7e9a318..ce01231 100644 --- a/src/views/monitor/disk/disk.api.ts +++ b/src/views/monitor/disk/disk.api.ts @@ -1,13 +1,12 @@ import { defHttp } from '/@/utils/http/axios'; enum Api { - queryDiskInfo = '/sys/actuator/redis/queryDiskInfo' + queryDiskInfo = '/sys/actuator/redis/queryDiskInfo', } - /** * 详细信息 */ export const queryDiskInfo = () => { - return defHttp.get({url: Api.queryDiskInfo}, {successMessageMode: 'none'}) + return defHttp.get({ url: Api.queryDiskInfo }, { successMessageMode: 'none' }); }; diff --git a/src/views/monitor/disk/gauge.vue b/src/views/monitor/disk/gauge.vue index 3658bf9..89224cf 100644 --- a/src/views/monitor/disk/gauge.vue +++ b/src/views/monitor/disk/gauge.vue @@ -1,7 +1,7 @@ diff --git a/src/views/monitor/log/index.vue b/src/views/monitor/log/index.vue index 9b3e5d0..08a2c74 100644 --- a/src/views/monitor/log/index.vue +++ b/src/views/monitor/log/index.vue @@ -1,22 +1,24 @@ diff --git a/src/views/monitor/log/log.api.ts b/src/views/monitor/log/log.api.ts index dca062a..9676b58 100644 --- a/src/views/monitor/log/log.api.ts +++ b/src/views/monitor/log/log.api.ts @@ -1,7 +1,7 @@ -import {defHttp} from '/@/utils/http/axios'; +import { defHttp } from '/@/utils/http/axios'; enum Api { - list = "/sys/log/list" + list = '/sys/log/list', } /** @@ -9,5 +9,5 @@ enum Api { * @param params */ export const getLogList = (params) => { - return defHttp.get({url: Api.list, params}); -} + return defHttp.get({ url: Api.list, params }); +}; diff --git a/src/views/monitor/mynews/DetailModal.vue b/src/views/monitor/mynews/DetailModal.vue index c903c42..1d6357a 100644 --- a/src/views/monitor/mynews/DetailModal.vue +++ b/src/views/monitor/mynews/DetailModal.vue @@ -1,25 +1,23 @@ diff --git a/src/views/monitor/mynews/DynamicNotice.vue b/src/views/monitor/mynews/DynamicNotice.vue index 7512a7e..e287b71 100644 --- a/src/views/monitor/mynews/DynamicNotice.vue +++ b/src/views/monitor/mynews/DynamicNotice.vue @@ -2,31 +2,31 @@ diff --git a/src/views/monitor/mynews/index.vue b/src/views/monitor/mynews/index.vue index aec306b..5a10bcc 100644 --- a/src/views/monitor/mynews/index.vue +++ b/src/views/monitor/mynews/index.vue @@ -1,21 +1,21 @@ diff --git a/src/views/monitor/mynews/mynews.api.ts b/src/views/monitor/mynews/mynews.api.ts index 822d7ea..2ae9364 100644 --- a/src/views/monitor/mynews/mynews.api.ts +++ b/src/views/monitor/mynews/mynews.api.ts @@ -20,15 +20,15 @@ export const getMyNewsList = (params) => { * 更新用户系统消息阅读状态 * @param params */ -export const editCementSend = (params,) =>{ - return defHttp.put({url: Api.editCementSend,params}); -} +export const editCementSend = (params) => { + return defHttp.put({ url: Api.editCementSend, params }); +}; /** * 一键已读 * @param params */ -export const readAllMsg = (params,handleSuccess) =>{ +export const readAllMsg = (params, handleSuccess) => { Modal.confirm({ title: '确认操作', content: '是否全部标注已读?', @@ -40,8 +40,7 @@ export const readAllMsg = (params,handleSuccess) =>{ }); }, }); -} - +}; /** * 同步消息 diff --git a/src/views/monitor/mynews/mynews.data.ts b/src/views/monitor/mynews/mynews.data.ts index f3080b2..540cee0 100644 --- a/src/views/monitor/mynews/mynews.data.ts +++ b/src/views/monitor/mynews/mynews.data.ts @@ -13,7 +13,14 @@ export const columns: BasicColumn[] = [ dataIndex: 'msgCategory', width: 80, customRender: ({ text }) => { - return render.renderDictNative(text, [{ label: '通知公告', value: '1',color:'blue' }, { label: '系统消息', value: '2' }],true); + return render.renderDictNative( + text, + [ + { label: '通知公告', value: '1', color: 'blue' }, + { label: '系统消息', value: '2' }, + ], + true + ); }, }, { @@ -31,8 +38,8 @@ export const columns: BasicColumn[] = [ dataIndex: 'priority', width: 80, customRender: ({ text }) => { - const color = text=='L'?'blue':text=='M'?'yellow':'red'; - return render.renderTag(render.renderDict(text, 'priority'),color) + const color = text == 'L' ? 'blue' : text == 'M' ? 'yellow' : 'red'; + return render.renderTag(render.renderDict(text, 'priority'), color); }, }, { @@ -40,7 +47,14 @@ export const columns: BasicColumn[] = [ dataIndex: 'readFlag', width: 80, customRender: ({ text }) => { - return render.renderDictNative(text, [{ label: '未读', value: '0',color:'red' }, { label: '已读', value: '1' }],true); + return render.renderDictNative( + text, + [ + { label: '未读', value: '0', color: 'red' }, + { label: '已读', value: '1' }, + ], + true + ); }, }, ]; @@ -58,5 +72,4 @@ export const searchFormSchema: FormSchema[] = [ component: 'Input', colProps: { span: 8 }, }, - ]; diff --git a/src/views/monitor/quartz/QuartzModal.vue b/src/views/monitor/quartz/QuartzModal.vue index 94c0dbd..5d1648c 100644 --- a/src/views/monitor/quartz/QuartzModal.vue +++ b/src/views/monitor/quartz/QuartzModal.vue @@ -1,59 +1,59 @@ diff --git a/src/views/monitor/quartz/index.vue b/src/views/monitor/quartz/index.vue index ff7099b..dcfcc30 100644 --- a/src/views/monitor/quartz/index.vue +++ b/src/views/monitor/quartz/index.vue @@ -1,37 +1,38 @@ diff --git a/src/views/monitor/redis/redis.api.ts b/src/views/monitor/redis/redis.api.ts index d5be37e..09734f3 100644 --- a/src/views/monitor/redis/redis.api.ts +++ b/src/views/monitor/redis/redis.api.ts @@ -3,7 +3,7 @@ import { defHttp } from '/@/utils/http/axios'; enum Api { keysSize = '/sys/actuator/redis/keysSize', memoryInfo = '/sys/actuator/redis/memoryInfo', - info = '/sys/actuator/redis/info' + info = '/sys/actuator/redis/info', } /** @@ -28,8 +28,5 @@ export const getInfo = () => { }; export const getRedisInfo = () => { - return Promise.all([ - getKeysSize(), - getMemoryInfo(), - ]); + return Promise.all([getKeysSize(), getMemoryInfo()]); }; diff --git a/src/views/monitor/redis/redis.data.ts b/src/views/monitor/redis/redis.data.ts index 6f40917..d370f94 100644 --- a/src/views/monitor/redis/redis.data.ts +++ b/src/views/monitor/redis/redis.data.ts @@ -4,7 +4,7 @@ export const columns: BasicColumn[] = [ { title: 'Key', dataIndex: 'key', - width: 100 + width: 100, }, { title: 'Description', @@ -15,5 +15,5 @@ export const columns: BasicColumn[] = [ title: 'Value', dataIndex: 'value', width: 80, - } + }, ]; diff --git a/src/views/monitor/route/RouteModal.vue b/src/views/monitor/route/RouteModal.vue index 498c314..95cb656 100644 --- a/src/views/monitor/route/RouteModal.vue +++ b/src/views/monitor/route/RouteModal.vue @@ -1,115 +1,139 @@ diff --git a/src/views/monitor/server/server.api.ts b/src/views/monitor/server/server.api.ts index 5c8c8ad..41b2f8f 100644 --- a/src/views/monitor/server/server.api.ts +++ b/src/views/monitor/server/server.api.ts @@ -23,12 +23,11 @@ enum Api { jvmGcLiveDataSize = '/actuator/metrics/jvm.gc.live.data.size', jvmGcPause = '/actuator/metrics/jvm.gc.pause', - tomcatSessionsCreated = '/actuator/metrics/tomcat.sessions.created', tomcatSessionsExpired = '/actuator/metrics/tomcat.sessions.expired', tomcatSessionsActiveCurrent = '/actuator/metrics/tomcat.sessions.active.current', tomcatSessionsActiveMax = '/actuator/metrics/tomcat.sessions.active.max', - tomcatSessionsRejected = '/actuator/metrics/tomcat.sessions.rejected' + tomcatSessionsRejected = '/actuator/metrics/tomcat.sessions.rejected', } /** @@ -52,7 +51,6 @@ export const getProcessStartTime = () => { return defHttp.get({ url: Api.processStartTime }, { isTransformResponse: false }); }; - /** * 查询应用已运行时间 */ @@ -81,7 +79,6 @@ export const getJvmMemoryCommitted = () => { return defHttp.get({ url: Api.jvmMemoryCommitted }, { isTransformResponse: false }); }; - /** * JVM 已用内存 */ @@ -89,7 +86,6 @@ export const getJvmMemoryUsed = () => { return defHttp.get({ url: Api.jvmMemoryUsed }, { isTransformResponse: false }); }; - /** * JVM 缓冲区已用内存 */ @@ -97,7 +93,6 @@ export const getJvmBufferMemoryUsed = () => { return defHttp.get({ url: Api.jvmBufferMemoryUsed }, { isTransformResponse: false }); }; - /** *JVM 当前缓冲区数量 */ @@ -112,7 +107,6 @@ export const getJvmThreadsDaemon = () => { return defHttp.get({ url: Api.jvmThreadsDaemon }, { isTransformResponse: false }); }; - /** *JVM 当前活跃线程数量 */ @@ -120,7 +114,6 @@ export const getJvmThreadsLive = () => { return defHttp.get({ url: Api.jvmThreadsLive }, { isTransformResponse: false }); }; - /** *JVM 峰值线程数量 */ @@ -135,7 +128,6 @@ export const getJvmClassesLoaded = () => { return defHttp.get({ url: Api.jvmClassesLoaded }, { isTransformResponse: false }); }; - /** *JVM 未加载 Class 数量 */ @@ -143,7 +135,6 @@ export const getJvmClassesUnloaded = () => { return defHttp.get({ url: Api.jvmClassesUnloaded }, { isTransformResponse: false }); }; - /** **GC 时, 年轻代分配的内存空间 */ @@ -151,7 +142,6 @@ export const getJvmGcMemoryAllocated = () => { return defHttp.get({ url: Api.jvmGcMemoryAllocated }, { isTransformResponse: false }); }; - /** *GC 时, 老年代分配的内存空间 */ @@ -159,7 +149,6 @@ export const getJvmGcMemoryPromoted = () => { return defHttp.get({ url: Api.jvmGcMemoryPromoted }, { isTransformResponse: false }); }; - /** *GC 时, 老年代的最大内存空间 */ @@ -167,7 +156,6 @@ export const getJvmGcMaxDataSize = () => { return defHttp.get({ url: Api.jvmGcMaxDataSize }, { isTransformResponse: false }); }; - /** *FullGC 时, 老年代的内存空间 */ @@ -182,7 +170,6 @@ export const getJvmGcPause = () => { return defHttp.get({ url: Api.jvmGcPause }, { isTransformResponse: false }); }; - /** *tomcat 已创建 session 数 */ @@ -190,7 +177,6 @@ export const getTomcatSessionsCreated = () => { return defHttp.get({ url: Api.tomcatSessionsCreated }, { isTransformResponse: false }); }; - /** *tomcat 已过期 session 数 */ @@ -198,7 +184,6 @@ export const getTomcatSessionsExpired = () => { return defHttp.get({ url: Api.tomcatSessionsExpired }, { isTransformResponse: false }); }; - /** *tomcat 当前活跃 session 数 */ @@ -206,7 +191,6 @@ export const getTomcatSessionsActiveCurrent = () => { return defHttp.get({ url: Api.tomcatSessionsActiveCurrent }, { isTransformResponse: false }); }; - /** *tomcat 活跃 session 数峰值 */ @@ -221,7 +205,6 @@ export const getTomcatSessionsRejected = () => { return defHttp.get({ url: Api.tomcatSessionsRejected }, { isTransformResponse: false }); }; - export const getMoreInfo = (infoType) => { if (infoType == '1') { return {}; @@ -237,7 +220,6 @@ export const getMoreInfo = (infoType) => { } }; - export const getTextInfo = (infoType) => { if (infoType == '1') { return { @@ -288,20 +270,13 @@ export const getTextInfo = (infoType) => { } }; - /** * 查询cpu数量 * @param params */ export const getServerInfo = (infoType) => { if (infoType == '1') { - return Promise.all([ - getCpuCount(), - getCpuUsage(), - getProcessStartTime(), - getProcessUptime(), - getProcessCpuUsage(), - ]); + return Promise.all([getCpuCount(), getCpuUsage(), getProcessStartTime(), getProcessUptime(), getProcessCpuUsage()]); } if (infoType == '2') { return Promise.all([ @@ -323,14 +298,6 @@ export const getServerInfo = (infoType) => { ]); } if (infoType == '3') { - return Promise.all([ - getTomcatSessionsActiveCurrent(), - getTomcatSessionsActiveMax(), - getTomcatSessionsCreated(), - getTomcatSessionsExpired(), - getTomcatSessionsRejected(), - ]); + return Promise.all([getTomcatSessionsActiveCurrent(), getTomcatSessionsActiveMax(), getTomcatSessionsCreated(), getTomcatSessionsExpired(), getTomcatSessionsRejected()]); } - }; - diff --git a/src/views/monitor/trace/index.vue b/src/views/monitor/trace/index.vue index 0a2d621..f6b8e6f 100644 --- a/src/views/monitor/trace/index.vue +++ b/src/views/monitor/trace/index.vue @@ -1,37 +1,37 @@ diff --git a/src/views/monitor/trace/trace.api.ts b/src/views/monitor/trace/trace.api.ts index 14a1e9b..f41b093 100644 --- a/src/views/monitor/trace/trace.api.ts +++ b/src/views/monitor/trace/trace.api.ts @@ -1,14 +1,12 @@ import { defHttp } from '/@/utils/http/axios'; enum Api { - actuatorList = '/actuator/httptrace' + actuatorList = '/actuator/httptrace', } - /** * 追踪信息 */ export const getActuatorList = () => { - return defHttp.get({ url: Api.actuatorList },{ isTransformResponse: false }); + return defHttp.get({ url: Api.actuatorList }, { isTransformResponse: false }); }; - diff --git a/src/views/monitor/trace/trace.data.ts b/src/views/monitor/trace/trace.data.ts index f31054b..13c7747 100644 --- a/src/views/monitor/trace/trace.data.ts +++ b/src/views/monitor/trace/trace.data.ts @@ -1,5 +1,5 @@ import { BasicColumn } from '/@/components/Table'; -import moment from 'moment' +import moment from 'moment'; export const columns: BasicColumn[] = [ { title: '请求时间', @@ -13,23 +13,23 @@ export const columns: BasicColumn[] = [ title: '请求方法', dataIndex: 'request.method', width: 20, - slots: { customRender: 'requestMethod' } + slots: { customRender: 'requestMethod' }, }, { title: '请求URL', dataIndex: 'request.uri', - width: 200 + width: 200, }, { title: '响应状态', dataIndex: 'response.status', width: 50, - slots: { customRender: 'responseStatus' } + slots: { customRender: 'responseStatus' }, }, { title: '请求耗时', dataIndex: 'timeTaken', width: 50, - slots: { customRender: 'timeTaken' } + slots: { customRender: 'timeTaken' }, }, ]; diff --git a/src/views/report/chartdemo/chartdemo.data.ts b/src/views/report/chartdemo/chartdemo.data.ts index dcafec9..d87e020 100644 --- a/src/views/report/chartdemo/chartdemo.data.ts +++ b/src/views/report/chartdemo/chartdemo.data.ts @@ -3,47 +3,47 @@ export const getData = (() => { const barDataSource: any[] = []; const barMultiData: any[] = []; const barLineData: any[] = []; - + for (let i = 0; i < 20; i++) { - let obj={name:'',value:0}; + let obj = { name: '', value: 0 }; const date = new Date((dottedBase += 1000 * 3600 * 24)); obj.name = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'); obj.value = Math.random() * 200; - barDataSource.push(obj) + barDataSource.push(obj); } - - for(let j = 0; j < 2; j++){ - for (let i = 0; i < 20; i++) { - let obj={name:'', value:0, type:2010+j+''}; - const date = new Date(dottedBase+1000 * 3600 * 24 * i); - obj.name = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'); - obj.value = Math.random() * 200; - barMultiData.push(obj) - } + + for (let j = 0; j < 2; j++) { + for (let i = 0; i < 20; i++) { + let obj = { name: '', value: 0, type: 2010 + j + '' }; + const date = new Date(dottedBase + 1000 * 3600 * 24 * i); + obj.name = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'); + obj.value = Math.random() * 200; + barMultiData.push(obj); + } } - const pieData = [ + const pieData = [ { value: 335, name: '客服电话' }, { value: 310, name: '奥迪官网' }, { value: 234, name: '媒体曝光' }, { value: 135, name: '质检总局' }, - { value: 105, name: '其他' } + { value: 105, name: '其他' }, ]; - const radarData = [ - { value: 75, name: '政治',type:'文综',max:100 }, - { value: 65, name: '历史',type:'文综',max:100 }, - { value: 55, name: '地理',type:'文综',max:100 }, - { value: 74, name: '化学',type:'文综',max:100 }, - { value: 38, name: '物理',type:'文综',max:100 }, - { value: 88, name: '生物',type:'文综',max:100 }, + const radarData = [ + { value: 75, name: '政治', type: '文综', max: 100 }, + { value: 65, name: '历史', type: '文综', max: 100 }, + { value: 55, name: '地理', type: '文综', max: 100 }, + { value: 74, name: '化学', type: '文综', max: 100 }, + { value: 38, name: '物理', type: '文综', max: 100 }, + { value: 88, name: '生物', type: '文综', max: 100 }, ]; - for(let j = 0; j < 2; j++){ + for (let j = 0; j < 2; j++) { for (let i = 0; i < 15; i++) { - let obj={name:'', value:0, type:2010+j+'',seriesType:j>=1?'line':'bar'}; - const date = new Date(dottedBase+1000 * 3600 * 24 * i); - obj.name = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'); - obj.value = Math.random() * 200; - barLineData.push(obj) + let obj = { name: '', value: 0, type: 2010 + j + '', seriesType: j >= 1 ? 'line' : 'bar' }; + const date = new Date(dottedBase + 1000 * 3600 * 24 * i); + obj.name = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'); + obj.value = Math.random() * 200; + barLineData.push(obj); } } - return { barDataSource, barMultiData,pieData,barLineData,radarData }; + return { barDataSource, barMultiData, pieData, barLineData, radarData }; })(); diff --git a/src/views/report/chartdemo/index.vue b/src/views/report/chartdemo/index.vue index b1152a8..5df2256 100644 --- a/src/views/report/chartdemo/index.vue +++ b/src/views/report/chartdemo/index.vue @@ -1,93 +1,93 @@ diff --git a/src/views/report/statisticst/index.vue b/src/views/report/statisticst/index.vue index 34f1351..bfcd5e3 100644 --- a/src/views/report/statisticst/index.vue +++ b/src/views/report/statisticst/index.vue @@ -1,138 +1,135 @@ diff --git a/src/views/sys/about/index.vue b/src/views/sys/about/index.vue index 1b2cf37..a8f8d01 100644 --- a/src/views/sys/about/index.vue +++ b/src/views/sys/about/index.vue @@ -4,8 +4,7 @@
{{ name }} - 是一个基于Vue3.0、Vite、 Ant-Design-Vue 、TypeScript - 的后台解决方案,目标是为中大型项目开发,提供现成的开箱解决方案及丰富的示例,原则上不会限制任何代码用于商用。 + 是一个基于Vue3.0、Vite、 Ant-Design-Vue 、TypeScript 的后台解决方案,目标是为中大型项目开发,提供现成的开箱解决方案及丰富的示例,原则上不会限制任何代码用于商用。
diff --git a/src/views/sys/error-log/data.tsx b/src/views/sys/error-log/data.tsx index 3ffc2f4..2aef412 100644 --- a/src/views/sys/error-log/data.tsx +++ b/src/views/sys/error-log/data.tsx @@ -12,16 +12,7 @@ export function getColumns(): BasicColumn[] { title: t('sys.errorLog.tableColumnType'), width: 80, customRender: ({ text }) => { - const color = - text === ErrorTypeEnum.VUE - ? 'green' - : text === ErrorTypeEnum.RESOURCE - ? 'cyan' - : text === ErrorTypeEnum.PROMISE - ? 'blue' - : ErrorTypeEnum.AJAX - ? 'red' - : 'purple'; + const color = text === ErrorTypeEnum.VUE ? 'green' : text === ErrorTypeEnum.RESOURCE ? 'cyan' : text === ErrorTypeEnum.PROMISE ? 'blue' : ErrorTypeEnum.AJAX ? 'red' : 'purple'; return {() => text}; }, }, diff --git a/src/views/sys/error-log/index.vue b/src/views/sys/error-log/index.vue index 571bb24..1895524 100644 --- a/src/views/sys/error-log/index.vue +++ b/src/views/sys/error-log/index.vue @@ -17,11 +17,7 @@
@@ -58,15 +54,15 @@ const [registerModal, { openModal }] = useModal(); watch( - () => errorLogStore.getErrorLogInfoList, - (list) => { - nextTick(() => { - setTableData(cloneDeep(list)); - }); - }, - { - immediate: true, - } + () => errorLogStore.getErrorLogInfoList, + (list) => { + nextTick(() => { + setTableData(cloneDeep(list)); + }); + }, + { + immediate: true, + } ); const { createMessage } = useMessage(); if (import.meta.env.DEV) { diff --git a/src/views/sys/exception/Exception.vue b/src/views/sys/exception/Exception.vue index 7db1002..c3db956 100644 --- a/src/views/sys/exception/Exception.vue +++ b/src/views/sys/exception/Exception.vue @@ -1,148 +1,143 @@ diff --git a/src/views/sys/exception/NetworkErrorException.vue b/src/views/sys/exception/NetworkErrorException.vue index f9492a1..e4ce2b9 100644 --- a/src/views/sys/exception/NetworkErrorException.vue +++ b/src/views/sys/exception/NetworkErrorException.vue @@ -1,11 +1,11 @@ \ No newline at end of file + const status = ref(ExceptionEnum.NET_WORK_ERROR); + diff --git a/src/views/sys/exception/NotAccessException.vue b/src/views/sys/exception/NotAccessException.vue index 4d9f9f7..a5b2a5f 100644 --- a/src/views/sys/exception/NotAccessException.vue +++ b/src/views/sys/exception/NotAccessException.vue @@ -1,11 +1,11 @@ \ No newline at end of file + const status = ref(ExceptionEnum.PAGE_NOT_ACCESS); + diff --git a/src/views/sys/exception/NotDataErrorException.vue b/src/views/sys/exception/NotDataErrorException.vue index e799b68..9a09dd0 100644 --- a/src/views/sys/exception/NotDataErrorException.vue +++ b/src/views/sys/exception/NotDataErrorException.vue @@ -1,11 +1,11 @@ \ No newline at end of file + const status = ref(ExceptionEnum.PAGE_NOT_DATA); + diff --git a/src/views/sys/exception/ServerErrorException.vue b/src/views/sys/exception/ServerErrorException.vue index fafd127..9742f55 100644 --- a/src/views/sys/exception/ServerErrorException.vue +++ b/src/views/sys/exception/ServerErrorException.vue @@ -1,11 +1,11 @@ \ No newline at end of file + const status = ref(ExceptionEnum.ERROR); + diff --git a/src/views/sys/forget-password/step1.vue b/src/views/sys/forget-password/step1.vue index f5e0d6f..7a7892f 100644 --- a/src/views/sys/forget-password/step1.vue +++ b/src/views/sys/forget-password/step1.vue @@ -1,36 +1,29 @@ diff --git a/src/views/sys/lock/LockPage.vue b/src/views/sys/lock/LockPage.vue index a887566..76262c3 100644 --- a/src/views/sys/lock/LockPage.vue +++ b/src/views/sys/lock/LockPage.vue @@ -1,29 +1,10 @@ diff --git a/src/views/sys/login/QrCodeForm.vue b/src/views/sys/login/QrCodeForm.vue index 821c77e..3b36731 100644 --- a/src/views/sys/login/QrCodeForm.vue +++ b/src/views/sys/login/QrCodeForm.vue @@ -2,7 +2,7 @@ diff --git a/src/views/sys/login/RegisterForm.vue b/src/views/sys/login/RegisterForm.vue index 0c2dd9e..c8af2de 100644 --- a/src/views/sys/login/RegisterForm.vue +++ b/src/views/sys/login/RegisterForm.vue @@ -1,115 +1,108 @@ diff --git a/src/views/sys/login/ThirdModal.vue b/src/views/sys/login/ThirdModal.vue index dad7b38..aa7a8df 100644 --- a/src/views/sys/login/ThirdModal.vue +++ b/src/views/sys/login/ThirdModal.vue @@ -1,70 +1,62 @@ diff --git a/src/views/sys/login/useLogin.ts b/src/views/sys/login/useLogin.ts index 3c766e7..34456be 100644 --- a/src/views/sys/login/useLogin.ts +++ b/src/views/sys/login/useLogin.ts @@ -2,8 +2,8 @@ import type { ValidationRule } from 'ant-design-vue/lib/form/Form'; import type { RuleObject } from 'ant-design-vue/lib/form/interface'; import { ref, computed, unref, Ref } from 'vue'; import { useI18n } from '/@/hooks/web/useI18n'; -import { checkOnlyUser } from "/@/api/sys/user"; -import {defHttp} from "/@/utils/http/axios"; +import { checkOnlyUser } from '/@/api/sys/user'; +import { defHttp } from '/@/utils/http/axios'; export enum LoginStateEnum { LOGIN, @@ -14,9 +14,9 @@ export enum LoginStateEnum { } export enum SmsEnum { - LOGIN = "0", - REGISTER = "1", - FORGET_PASSWORD = "2", + LOGIN = '0', + REGISTER = '1', + FORGET_PASSWORD = '2', } const currentState = ref(LoginStateEnum.LOGIN); @@ -52,11 +52,9 @@ export function useFormRules(formData?: Recordable) { const getPasswordFormRule = computed(() => createRule(t('sys.login.passwordPlaceholder'))); const getSmsFormRule = computed(() => createRule(t('sys.login.smsPlaceholder'))); const getMobileFormRule = computed(() => createRule(t('sys.login.mobilePlaceholder'))); - - + const getRegisterAccountRule = computed(() => createRegisterAccountRule('account')); const getRegisterMobileRule = computed(() => createRegisterAccountRule('mobile')); - const validatePolicy = async (_: RuleObject, value: boolean) => { return !value ? Promise.reject(t('sys.login.policyPlaceholder')) : Promise.resolve(); @@ -79,7 +77,7 @@ export function useFormRules(formData?: Recordable) { const passwordFormRule = unref(getPasswordFormRule); const smsFormRule = unref(getSmsFormRule); const mobileFormRule = unref(getMobileFormRule); - + const registerAccountRule = unref(getRegisterAccountRule); const registerMobileRule = unref(getRegisterMobileRule); @@ -95,9 +93,7 @@ export function useFormRules(formData?: Recordable) { password: passwordFormRule, mobile: registerMobileRule, sms: smsFormRule, - confirmPassword: [ - { validator: validateConfirmPassword(formData?.password), trigger: 'change' }, - ], + confirmPassword: [{ validator: validateConfirmPassword(formData?.password), trigger: 'change' }], policy: [{ validator: validatePolicy, trigger: 'change' }], }; @@ -105,9 +101,7 @@ export function useFormRules(formData?: Recordable) { case LoginStateEnum.RESET_PASSWORD: return { username: accountFormRule, - confirmPassword: [ - { validator: validateConfirmPassword(formData?.password), trigger: 'change' }, - ], + confirmPassword: [{ validator: validateConfirmPassword(formData?.password), trigger: 'change' }], ...mobileRule, }; @@ -136,35 +130,36 @@ function createRule(message: string) { ]; } function createRegisterAccountRule(type) { - return [{ - validator: type=='account'?checkUsername:checkPhone, - trigger: 'change' - } + return [ + { + validator: type == 'account' ? checkUsername : checkPhone, + trigger: 'change', + }, ]; } - function checkUsername(rule, value, callback) { +function checkUsername(rule, value, callback) { const { t } = useI18n(); - if(!value){ - return Promise.reject(t('sys.login.accountPlaceholder')) - }else{ + if (!value) { + return Promise.reject(t('sys.login.accountPlaceholder')); + } else { return new Promise((resolve, reject) => { - checkOnlyUser({username: value}).then((res) => { - res.success?resolve():reject("用户名已存在!"); - }) - }) + checkOnlyUser({ username: value }).then((res) => { + res.success ? resolve() : reject('用户名已存在!'); + }); + }); } } async function checkPhone(rule, value, callback) { const { t } = useI18n(); - var reg=/^1[3456789]\d{9}$/ - if(!reg.test(value)){ - return Promise.reject(new Error("请输入正确手机号")) - }else{ + var reg = /^1[3456789]\d{9}$/; + if (!reg.test(value)) { + return Promise.reject(new Error('请输入正确手机号')); + } else { return new Promise((resolve, reject) => { - checkOnlyUser({phone: value}).then((res) => { - res.success?resolve():reject("手机号已存在!"); - }) - }) + checkOnlyUser({ phone: value }).then((res) => { + res.success ? resolve() : reject('手机号已存在!'); + }); + }); } } diff --git a/src/views/system/address/address.api.ts b/src/views/system/address/address.api.ts index cb20fff..4890d34 100644 --- a/src/views/system/address/address.api.ts +++ b/src/views/system/address/address.api.ts @@ -1,20 +1,19 @@ -import { defHttp } from '/@/utils/http/axios' +import { defHttp } from '/@/utils/http/axios'; export enum Api { - list='/sys/user/queryByOrgCodeForAddressList', - positionList='/sys/position/list', + list = '/sys/user/queryByOrgCodeForAddressList', + positionList = '/sys/position/list', queryDepartTreeSync = '/sys/sysDepart/queryDepartTreeSync', } /** * 获取部门树列表 */ -export const queryDepartTreeSync = (params?) => defHttp.get({ url: Api.queryDepartTreeSync, params }) +export const queryDepartTreeSync = (params?) => defHttp.get({ url: Api.queryDepartTreeSync, params }); /** * 部门用户信息 */ -export const list = (params?) => defHttp.get({ url: Api.list, params }) +export const list = (params?) => defHttp.get({ url: Api.list, params }); /** * 职务list */ -export const positionList = (params?) => defHttp.get({ url: Api.positionList, params }) - +export const positionList = (params?) => defHttp.get({ url: Api.positionList, params }); diff --git a/src/views/system/address/address.data.ts b/src/views/system/address/address.data.ts index de8919c..ffa5945 100644 --- a/src/views/system/address/address.data.ts +++ b/src/views/system/address/address.data.ts @@ -1,51 +1,51 @@ -import { FormSchema } from '/@/components/Form' -import {BasicColumn} from '/@/components/Table'; +import { FormSchema } from '/@/components/Form'; +import { BasicColumn } from '/@/components/Table'; export const columns: BasicColumn[] = [ - { - title: '姓名', - dataIndex: 'realname', - width: 150, - }, - { - title: '工号', - dataIndex: 'workNo', - width: 100, - }, - { - title: '部门', - dataIndex: 'departName', - width: 200 - }, - { - title: '职务', - dataIndex: 'post', - width: 150, - slots: { customRender: 'post' }, - }, - { - title: '手机', - width: 150, - dataIndex: 'telephone', - }, - { - title: '邮箱', - width: 150, - dataIndex: 'email', - } + { + title: '姓名', + dataIndex: 'realname', + width: 150, + }, + { + title: '工号', + dataIndex: 'workNo', + width: 100, + }, + { + title: '部门', + dataIndex: 'departName', + width: 200, + }, + { + title: '职务', + dataIndex: 'post', + width: 150, + slots: { customRender: 'post' }, + }, + { + title: '手机', + width: 150, + dataIndex: 'telephone', + }, + { + title: '邮箱', + width: 150, + dataIndex: 'email', + }, ]; export const searchFormSchema: FormSchema[] = [ - { - label: '姓名', - field: 'realname', - component: 'Input', - colProps: {span: 6} - }, - { - label: '工号', - field: 'workNo', - component: 'Input', - colProps: {span: 6}, - } + { + label: '姓名', + field: 'realname', + component: 'Input', + colProps: { span: 6 }, + }, + { + label: '工号', + field: 'workNo', + component: 'Input', + colProps: { span: 6 }, + }, ]; diff --git a/src/views/system/address/components/DepartLeftTree.vue b/src/views/system/address/components/DepartLeftTree.vue index 2e023a9..f371062 100644 --- a/src/views/system/address/components/DepartLeftTree.vue +++ b/src/views/system/address/components/DepartLeftTree.vue @@ -1,159 +1,158 @@ diff --git a/src/views/system/address/index.less b/src/views/system/address/index.less index 1e98464..82554ac 100644 --- a/src/views/system/address/index.less +++ b/src/views/system/address/index.less @@ -7,5 +7,4 @@ padding: 0 20px; } } - -} \ No newline at end of file +} diff --git a/src/views/system/address/index.vue b/src/views/system/address/index.vue index c16105e..6b2f328 100644 --- a/src/views/system/address/index.vue +++ b/src/views/system/address/index.vue @@ -1,83 +1,88 @@ diff --git a/src/views/system/category/category.api.ts b/src/views/system/category/category.api.ts index 591ef0b..9295745 100644 --- a/src/views/system/category/category.api.ts +++ b/src/views/system/category/category.api.ts @@ -1,10 +1,10 @@ -import {defHttp} from "/@/utils/http/axios"; -import {Modal} from 'ant-design-vue'; +import { defHttp } from '/@/utils/http/axios'; +import { Modal } from 'ant-design-vue'; enum Api { list = '/sys/category/rootList', - save='/sys/category/add', - edit='/sys/category/edit', + save = '/sys/category/add', + edit = '/sys/category/edit', deleteCategory = '/sys/category/delete', deleteBatch = '/sys/category/deleteBatch', importExcel = '/sys/category/importExcel', @@ -27,16 +27,15 @@ export const getImportUrl = Api.importExcel; * 列表接口 * @param params */ -export const list = (params) => - defHttp.get({url: Api.list, params}); +export const list = (params) => defHttp.get({ url: Api.list, params }); /** * 删除 */ -export const deleteCategory = (params,handleSuccess) => { - return defHttp.delete({url: Api.deleteCategory, params}, {joinParamsToUrl: true}).then(() => { +export const deleteCategory = (params, handleSuccess) => { + return defHttp.delete({ url: Api.deleteCategory, params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); -} +}; /** * 批量删除 * @param params @@ -48,35 +47,32 @@ export const batchDeleteCategory = (params, handleSuccess) => { okText: '确认', cancelText: '取消', onOk: () => { - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); - } + }, }); -} +}; /** * 保存或者更新 * @param params */ export const saveOrUpdateDict = (params, isUpdate) => { let url = isUpdate ? Api.edit : Api.save; - return defHttp.post({url: url, params}); -} + return defHttp.post({ url: url, params }); +}; /** * 查询全部树形节点数据 * @param params */ -export const loadTreeData = (params) => - defHttp.get({url: Api.loadTreeData,params}); +export const loadTreeData = (params) => defHttp.get({ url: Api.loadTreeData, params }); /** * 查询子节点数据 * @param params */ -export const getChildList = (params) => - defHttp.get({url: Api.getChildList, params}); +export const getChildList = (params) => defHttp.get({ url: Api.getChildList, params }); /** * 批量查询子节点数据 * @param params */ -export const getChildListBatch = (params) => - defHttp.get({url: Api.getChildListBatch, params},{isTransformResponse:false}); +export const getChildListBatch = (params) => defHttp.get({ url: Api.getChildListBatch, params }, { isTransformResponse: false }); diff --git a/src/views/system/category/category.data.ts b/src/views/system/category/category.data.ts index 2f4ee92..c1f117f 100644 --- a/src/views/system/category/category.data.ts +++ b/src/views/system/category/category.data.ts @@ -1,5 +1,5 @@ -import {BasicColumn} from '/@/components/Table'; -import {FormSchema} from '/@/components/Table'; +import { BasicColumn } from '/@/components/Table'; +import { FormSchema } from '/@/components/Table'; export const columns: BasicColumn[] = [ { @@ -11,21 +11,22 @@ export const columns: BasicColumn[] = [ { title: '分类编码', dataIndex: 'code', - }]; + }, +]; export const searchFormSchema: FormSchema[] = [ - { - label: '名称', - field: 'name', - component: 'Input', - colProps: {span: 6}, - }, - { - label: '编码', - field: 'code', - component: 'Input', - colProps: {span: 6}, - } + { + label: '名称', + field: 'name', + component: 'Input', + colProps: { span: 6 }, + }, + { + label: '编码', + field: 'code', + component: 'Input', + colProps: { span: 6 }, + }, ]; export const formSchema: FormSchema[] = [ @@ -33,7 +34,7 @@ export const formSchema: FormSchema[] = [ label: '', field: 'id', component: 'Input', - show:false + show: false, }, { label: '父级节点', @@ -43,15 +44,15 @@ export const formSchema: FormSchema[] = [ replaceFields: { value: 'key', }, - dropdownStyle:{ - maxHeight:'50vh' + dropdownStyle: { + maxHeight: '50vh', }, - getPopupContainer: () => document.body + getPopupContainer: () => document.body, }, - show: ({values}) => { - return values.pid !== '0'; + show: ({ values }) => { + return values.pid !== '0'; }, - dynamicDisabled: ({values}) => { + dynamicDisabled: ({ values }) => { return !!values.id; }, }, @@ -60,6 +61,5 @@ export const formSchema: FormSchema[] = [ field: 'name', required: true, component: 'Input', - } + }, ]; - diff --git a/src/views/system/category/components/CategoryModal.vue b/src/views/system/category/components/CategoryModal.vue index d7d3a4f..3a3ffb9 100644 --- a/src/views/system/category/components/CategoryModal.vue +++ b/src/views/system/category/components/CategoryModal.vue @@ -1,21 +1,21 @@ diff --git a/src/views/system/category/index.vue b/src/views/system/category/index.vue index 42de9d4..0986017 100644 --- a/src/views/system/category/index.vue +++ b/src/views/system/category/index.vue @@ -1,13 +1,13 @@ - + diff --git a/src/views/system/checkRule/CheckRuleModal.vue b/src/views/system/checkRule/CheckRuleModal.vue index 92505d0..cc3e019 100644 --- a/src/views/system/checkRule/CheckRuleModal.vue +++ b/src/views/system/checkRule/CheckRuleModal.vue @@ -1,261 +1,237 @@ - diff --git a/src/views/system/checkRule/CheckRuleTestModal.vue b/src/views/system/checkRule/CheckRuleTestModal.vue index 6b0dca9..06dd10c 100644 --- a/src/views/system/checkRule/CheckRuleTestModal.vue +++ b/src/views/system/checkRule/CheckRuleTestModal.vue @@ -1,57 +1,55 @@ - + diff --git a/src/views/system/checkRule/check.rule.api.ts b/src/views/system/checkRule/check.rule.api.ts index 0988b51..c4b5391 100644 --- a/src/views/system/checkRule/check.rule.api.ts +++ b/src/views/system/checkRule/check.rule.api.ts @@ -1,15 +1,15 @@ -import { defHttp } from "/@/utils/http/axios"; -import { Modal } from "ant-design-vue"; +import { defHttp } from '/@/utils/http/axios'; +import { Modal } from 'ant-design-vue'; enum Api { - list = '/sys/checkRule/list', - delete = '/sys/checkRule/delete', - deleteBatch = '/sys/checkRule/deleteBatch', - exportXls = 'sys/checkRule/exportXls', - importXls = 'sys/checkRule/importExcel', - checkByCode = '/sys/checkRule/checkByCode', - save = '/sys/checkRule/add', - edit = '/sys/checkRule/edit' + list = '/sys/checkRule/list', + delete = '/sys/checkRule/delete', + deleteBatch = '/sys/checkRule/deleteBatch', + exportXls = 'sys/checkRule/exportXls', + importXls = 'sys/checkRule/importExcel', + checkByCode = '/sys/checkRule/checkByCode', + save = '/sys/checkRule/add', + edit = '/sys/checkRule/edit', } /** @@ -26,8 +26,8 @@ export const importUrl = Api.importXls; * @param params */ export const getCheckRuleList = (params) => { - return defHttp.get({url: Api.list, params}); -} + return defHttp.get({ url: Api.list, params }); +}; /** * 删除 @@ -35,53 +35,52 @@ export const getCheckRuleList = (params) => { * @param handleSuccess */ export const deleteCheckRule = (params, handleSuccess) => { - return defHttp.delete({url: Api.delete, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); -} + return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; /** * 批量删除 * @param params */ export const batchDeleteCheckRule = (params, handleSuccess) => { - Modal.confirm({ - title: '确认删除', - content: '是否删除选中数据', - okText: '确认', - cancelText: '取消', - onOk: () => { - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); - } - }); -} + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; /** * 根据编码校验规则code,校验传入的值是否合法 * @param ruleCode * @param value */ -export const validateCheckRule = (ruleCode, value)=>{ - value = encodeURIComponent(value) - let params = { ruleCode, value } - return defHttp.get({url: Api.checkByCode, params},{isTransformResponse: false}) -} - +export const validateCheckRule = (ruleCode, value) => { + value = encodeURIComponent(value); + let params = { ruleCode, value }; + return defHttp.get({ url: Api.checkByCode, params }, { isTransformResponse: false }); +}; /** * 保存 * @param params */ export const saveCheckRule = (params) => { - return defHttp.post({url: Api.save, params}); -} + return defHttp.post({ url: Api.save, params }); +}; /** * 更新 * @param params */ export const updateCheckRule = (params) => { - return defHttp.put({url: Api.edit, params}); -} + return defHttp.put({ url: Api.edit, params }); +}; diff --git a/src/views/system/checkRule/check.rule.data.ts b/src/views/system/checkRule/check.rule.data.ts index 221c132..59fe236 100644 --- a/src/views/system/checkRule/check.rule.data.ts +++ b/src/views/system/checkRule/check.rule.data.ts @@ -1,156 +1,152 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; -import { render } from "/@/utils/common/renderUtils"; -import {duplicateCheck} from "/@/views/system/user/user.api"; -import { validateCheckRule } from "/@/views/system/checkRule/check.rule.api"; -import {array} from "vue-types"; - +import { render } from '/@/utils/common/renderUtils'; +import { duplicateCheck } from '/@/views/system/user/user.api'; +import { validateCheckRule } from '/@/views/system/checkRule/check.rule.api'; +import { array } from 'vue-types'; export const columns: BasicColumn[] = [ - { - title: '规则名称', - dataIndex: 'ruleName', - width: 200, - align: 'center', + { + title: '规则名称', + dataIndex: 'ruleName', + width: 200, + align: 'center', + }, + { + title: '规则编码', + dataIndex: 'ruleCode', + width: 200, + align: 'center', + }, + { + title: '规则描述', + dataIndex: 'ruleDescription', + width: 300, + align: 'center', + customRender: function ({ text }) { + return render.renderTip(text, 30); }, - { - title: '规则编码', - dataIndex: 'ruleCode', - width: 200, - align: 'center', - }, - { - title: '规则描述', - dataIndex: 'ruleDescription', - width: 300, - align: 'center', - customRender: function({text}){ - return render.renderTip(text, 30) - } - } + }, ]; export const searchFormSchema: FormSchema[] = [ - { - field: 'ruleName', - label: '规则名称', - component: 'Input', - colProps: { span: 6 }, - }, - { - field: 'ruleCode', - label: '规则编码', - component: 'Input', - colProps: { span: 6 }, - }, + { + field: 'ruleName', + label: '规则名称', + component: 'Input', + colProps: { span: 6 }, + }, + { + field: 'ruleCode', + label: '规则编码', + component: 'Input', + colProps: { span: 6 }, + }, ]; - export const formSchema: FormSchema[] = [ - { - label: '', - field: 'id', - component: 'Input', - show:false + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + field: 'ruleName', + label: '规则名称', + component: 'Input', + required: true, + colProps: { span: 24 }, + }, + { + field: 'ruleCode', + label: '规则编码', + component: 'Input', + colProps: { span: 24 }, + dynamicDisabled: ({ values }) => { + return !!values.id; }, - { - field: 'ruleName', - label: '规则名称', - component: 'Input', - required: true, - colProps: { span: 24 } - }, - { - field: 'ruleCode', - label: '规则编码', - component: 'Input', - colProps: { span: 24 }, - dynamicDisabled: ({values}) => { - return !!values.id; + dynamicRules: ({ model }) => { + return [ + { + required: true, + validator: (_, value) => { + return new Promise((resolve, reject) => { + if (!value) { + return reject('请输入规则编码!'); + } + let params = { + tableName: 'sys_check_rule', + fieldName: 'rule_code', + fieldVal: value, + dataId: model.id, + }; + duplicateCheck(params) + .then((res) => { + res.success ? resolve() : reject('规则编码已存在!'); + }) + .catch((err) => { + reject(err.message || '校验失败'); + }); + }); + }, }, - dynamicRules: ({ model }) => { - return [ - { - required: true, - validator: (_, value) => { - return new Promise((resolve, reject) => { - if (!value) { - return reject('请输入规则编码!'); - } - let params = { - tableName: "sys_check_rule", - fieldName: "rule_code", - fieldVal: value, - dataId: model.id, - }; - duplicateCheck(params) - .then((res) => { - res.success ? resolve() : reject('规则编码已存在!'); - }).catch((err) => { - reject(err.message || '校验失败'); - }); - }); - }, - }, - ]; - } + ]; }, - { - field: 'ruleDescription', - label: '规则描述', - colProps: { span: 24 }, - component: 'InputTextArea', - componentProps: { - placeholder: '请输入规则描述', - rows: 2, - }, + }, + { + field: 'ruleDescription', + label: '规则描述', + colProps: { span: 24 }, + component: 'InputTextArea', + componentProps: { + placeholder: '请输入规则描述', + rows: 2, }, - -] - - + }, +]; export const checkRuleInput: FormSchema[] = [ - { - label: '123', - field: 'ruleCode', - component: 'Input', - show: false - }, - { - field: 'testValue', - label: '需要测试的值:', - component: 'Input', - componentProps:({formModel}) => { - return { - onChange: (e) => { - formModel.testValue = e.target.value - } - } + { + label: '123', + field: 'ruleCode', + component: 'Input', + show: false, + }, + { + field: 'testValue', + label: '需要测试的值:', + component: 'Input', + componentProps: ({ formModel }) => { + return { + onChange: (e) => { + formModel.testValue = e.target.value; }, - dynamicRules: ({ model }) => { - const { ruleCode } = model - return [ - { - required: false, - validator: (_, value) => { - return new Promise((resolve, reject) => { - if (ruleCode && value) { - /*console.log({ruleCode,value})*/ - validateCheckRule(ruleCode, value).then(res => { - //console.log(1233, res) - res['success'] ? resolve() : reject(res['message']) - }).catch(err => { - reject(err.message || err) - }) - }else{ - resolve(); - } - }); - }, - }, - ]; - } + }; }, - -] - + dynamicRules: ({ model }) => { + const { ruleCode } = model; + return [ + { + required: false, + validator: (_, value) => { + return new Promise((resolve, reject) => { + if (ruleCode && value) { + /*console.log({ruleCode,value})*/ + validateCheckRule(ruleCode, value) + .then((res) => { + //console.log(1233, res) + res['success'] ? resolve() : reject(res['message']); + }) + .catch((err) => { + reject(err.message || err); + }); + } else { + resolve(); + } + }); + }, + }, + ]; + }, + }, +]; diff --git a/src/views/system/checkRule/index.vue b/src/views/system/checkRule/index.vue index f8ff320..7f76d98 100644 --- a/src/views/system/checkRule/index.vue +++ b/src/views/system/checkRule/index.vue @@ -1,147 +1,143 @@ diff --git a/src/views/system/depart/components/DepartDataRuleDrawer.vue b/src/views/system/depart/components/DepartDataRuleDrawer.vue index 19f0c04..3427872 100644 --- a/src/views/system/depart/components/DepartDataRuleDrawer.vue +++ b/src/views/system/depart/components/DepartDataRuleDrawer.vue @@ -1,32 +1,23 @@ \ No newline at end of file + function doReset() { + functionId.value = ''; + dataRuleList.value = []; + dataRuleChecked.value = []; + } + diff --git a/src/views/system/depart/components/DepartFormModal.vue b/src/views/system/depart/components/DepartFormModal.vue index fbc9e1d..7376154 100644 --- a/src/views/system/depart/components/DepartFormModal.vue +++ b/src/views/system/depart/components/DepartFormModal.vue @@ -1,95 +1,92 @@ - \ No newline at end of file + diff --git a/src/views/system/depart/components/DepartFormTab.vue b/src/views/system/depart/components/DepartFormTab.vue index 420ec17..83600c5 100644 --- a/src/views/system/depart/components/DepartFormTab.vue +++ b/src/views/system/depart/components/DepartFormTab.vue @@ -1,7 +1,7 @@ \ No newline at end of file + + // 提交事件 + async function onSubmit() { + try { + loading.value = true; + let values = await validate(); + values = Object.assign({}, model.value, values); + //提交表单 + await saveOrUpdateDepart(values, isUpdate.value); + //刷新列表 + emit('success'); + Object.assign(model.value, values); + } finally { + loading.value = false; + } + } + diff --git a/src/views/system/depart/components/DepartLeftTree.vue b/src/views/system/depart/components/DepartLeftTree.vue index 0f0a4b5..503a03b 100644 --- a/src/views/system/depart/components/DepartLeftTree.vue +++ b/src/views/system/depart/components/DepartLeftTree.vue @@ -1,6 +1,6 @@
- + \ No newline at end of file + defineExpose({ + loadRootTreeData, + }); + diff --git a/src/views/system/depart/components/DepartRuleTab.vue b/src/views/system/depart/components/DepartRuleTab.vue index 343c1b4..fcf8fe0 100644 --- a/src/views/system/depart/components/DepartRuleTab.vue +++ b/src/views/system/depart/components/DepartRuleTab.vue @@ -2,28 +2,28 @@ \ No newline at end of file + // 【VUEN-188】解决滚动条不灵敏的问题 + .depart-rule-tree ::v-deep(.scrollbar__bar) { + pointer-events: none; + } + diff --git a/src/views/system/depart/depart.api.ts b/src/views/system/depart/depart.api.ts index c1bf2d7..d39c853 100644 --- a/src/views/system/depart/depart.api.ts +++ b/src/views/system/depart/depart.api.ts @@ -1,8 +1,8 @@ -import { unref } from 'vue' -import { defHttp } from '/@/utils/http/axios' -import { useMessage } from '/@/hooks/web/useMessage' +import { unref } from 'vue'; +import { defHttp } from '/@/utils/http/axios'; +import { useMessage } from '/@/hooks/web/useMessage'; -const { createConfirm } = useMessage() +const { createConfirm } = useMessage(); export enum Api { queryDepartTreeSync = '/sys/sysDepart/queryDepartTreeSync', @@ -26,18 +26,18 @@ export enum Api { /** * 获取部门树列表 */ -export const queryDepartTreeSync = (params?) => defHttp.get({ url: Api.queryDepartTreeSync, params }) +export const queryDepartTreeSync = (params?) => defHttp.get({ url: Api.queryDepartTreeSync, params }); /** * 保存或者更新部门角色 */ export const saveOrUpdateDepart = (params, isUpdate) => { if (isUpdate) { - return defHttp.put({ url: Api.edit, params }) + return defHttp.put({ url: Api.edit, params }); } else { - return defHttp.post({ url: Api.save, params }) + return defHttp.post({ url: Api.save, params }); } -} +}; /** * 批量删除部门角色 @@ -45,8 +45,8 @@ export const saveOrUpdateDepart = (params, isUpdate) => { export const deleteBatchDepart = (params, confirm = false) => { return new Promise((resolve, reject) => { const doDelete = () => { - resolve(defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true })) - } + resolve(defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true })); + }; if (confirm) { createConfirm({ iconType: 'warning', @@ -54,42 +54,42 @@ export const deleteBatchDepart = (params, confirm = false) => { content: '确定要删除吗?', onOk: () => doDelete(), onCancel: () => reject(), - }) + }); } else { - doDelete() + doDelete(); } - }) -} + }); +}; /** * 获取权限树列表 */ -export const queryRoleTreeList = (params?) => defHttp.get({ url: Api.roleQueryTreeList, params }) +export const queryRoleTreeList = (params?) => defHttp.get({ url: Api.roleQueryTreeList, params }); /** * 查询部门权限 */ -export const queryDepartPermission = (params?) => defHttp.get({ url: Api.queryDepartPermission, params }) +export const queryDepartPermission = (params?) => defHttp.get({ url: Api.queryDepartPermission, params }); /** * 保存部门权限 */ -export const saveDepartPermission = (params) => defHttp.post({ url: Api.saveDepartPermission, params }) +export const saveDepartPermission = (params) => defHttp.post({ url: Api.saveDepartPermission, params }); /** * 查询部门数据权限列表 */ export const queryDepartDataRule = (functionId, departId, params?) => { - let url = `${Api.dataRule}/${unref(functionId)}/${unref(departId)}` - return defHttp.get({ url, params }) -} + let url = `${Api.dataRule}/${unref(functionId)}/${unref(departId)}`; + return defHttp.get({ url, params }); +}; /** * 保存部门数据权限 */ -export const saveDepartDataRule = (params) => defHttp.post({ url: Api.dataRule, params }) +export const saveDepartDataRule = (params) => defHttp.post({ url: Api.dataRule, params }); /** * 获取登录用户部门信息 */ -export const getUserDeparts = (params?) => defHttp.get({ url: Api.getCurrentUserDeparts, params }) +export const getUserDeparts = (params?) => defHttp.get({ url: Api.getCurrentUserDeparts, params }); /** * 切换选择部门 */ -export const selectDepart = (params?) => defHttp.put({ url: Api.selectDepart, params }) +export const selectDepart = (params?) => defHttp.put({ url: Api.selectDepart, params }); diff --git a/src/views/system/depart/depart.data.ts b/src/views/system/depart/depart.data.ts index bc6c0d0..9e0346e 100644 --- a/src/views/system/depart/depart.data.ts +++ b/src/views/system/depart/depart.data.ts @@ -1,4 +1,4 @@ -import { FormSchema } from '/@/components/Form' +import { FormSchema } from '/@/components/Form'; // 部门基础表单 export function useBasicFormSchema() { @@ -74,8 +74,8 @@ export function useBasicFormSchema() { placeholder: '请输入备注', }, }, - ] - return { basicFormSchema } + ]; + return { basicFormSchema }; } // 机构类型选项 @@ -83,5 +83,8 @@ export const orgCategoryOptions = { // 一级部门 root: [{ value: '1', label: '公司' }], // 子级部门 - child: [{ value: '2', label: '部门' }, { value: '3', label: '岗位' }], -} \ No newline at end of file + child: [ + { value: '2', label: '部门' }, + { value: '3', label: '岗位' }, + ], +}; diff --git a/src/views/system/depart/index.less b/src/views/system/depart/index.less index 1e98464..82554ac 100644 --- a/src/views/system/depart/index.less +++ b/src/views/system/depart/index.less @@ -7,5 +7,4 @@ padding: 0 20px; } } - -} \ No newline at end of file +} diff --git a/src/views/system/depart/index.vue b/src/views/system/depart/index.vue index 2422f4d..332b4a9 100644 --- a/src/views/system/depart/index.vue +++ b/src/views/system/depart/index.vue @@ -1,24 +1,24 @@ diff --git a/src/views/system/departUser/components/DepartBaseInfoTab.vue b/src/views/system/departUser/components/DepartBaseInfoTab.vue index ca792c5..911319f 100644 --- a/src/views/system/departUser/components/DepartBaseInfoTab.vue +++ b/src/views/system/departUser/components/DepartBaseInfoTab.vue @@ -1,36 +1,40 @@ diff --git a/src/views/system/departUser/components/DepartRoleAuthDrawer.vue b/src/views/system/departUser/components/DepartRoleAuthDrawer.vue index adf08f3..14b24f2 100644 --- a/src/views/system/departUser/components/DepartRoleAuthDrawer.vue +++ b/src/views/system/departUser/components/DepartRoleAuthDrawer.vue @@ -1,36 +1,29 @@ \ No newline at end of file + + // tree展开事件 + function onExpand($expandedKeys) { + expandedKeys.value = $expandedKeys; + } + + // tree选中事件 + function onSelect($selectedKeys, { selectedNodes }) { + if (selectedNodes[0]?.props?.ruleFlag) { + let functionId = $selectedKeys[0]; + dataRuleDrawer.openDrawer(true, { roleId, departId, functionId }); + } + selectedKeys.value = []; + } + + function doClose() { + reset(); + closeDrawer(); + } + + function onClose() { + reset(); + } + + async function onSubmit(exit) { + try { + loading.value = true; + let params = { + roleId: roleId.value, + permissionIds: checkedKeys.value.join(','), + lastpermissionIds: lastCheckedKeys.value.join(','), + }; + await saveDeptRolePermission(params); + if (exit) { + doClose(); + } + } finally { + loading.value = false; + if (!exit) { + loadData(); + } + } + } + diff --git a/src/views/system/departUser/components/DepartRoleDataRuleDrawer.vue b/src/views/system/departUser/components/DepartRoleDataRuleDrawer.vue index b0be5f4..04f2e45 100644 --- a/src/views/system/departUser/components/DepartRoleDataRuleDrawer.vue +++ b/src/views/system/departUser/components/DepartRoleDataRuleDrawer.vue @@ -1,32 +1,23 @@ \ No newline at end of file + function doReset() { + functionId.value = ''; + roleId.value = ''; + dataRuleList.value = []; + dataRuleChecked.value = []; + } + diff --git a/src/views/system/departUser/components/DepartRoleInfoTab.vue b/src/views/system/departUser/components/DepartRoleInfoTab.vue index e74e14a..7722534 100644 --- a/src/views/system/departUser/components/DepartRoleInfoTab.vue +++ b/src/views/system/departUser/components/DepartRoleInfoTab.vue @@ -5,199 +5,191 @@ - - + + diff --git a/src/views/system/departUser/components/DepartRoleModal.vue b/src/views/system/departUser/components/DepartRoleModal.vue index 0e07117..4eec504 100644 --- a/src/views/system/departUser/components/DepartRoleModal.vue +++ b/src/views/system/departUser/components/DepartRoleModal.vue @@ -1,68 +1,63 @@ \ No newline at end of file + diff --git a/src/views/system/departUser/components/DepartRoleUserAuthDrawer.vue b/src/views/system/departUser/components/DepartRoleUserAuthDrawer.vue index 2d0c975..78dbc1b 100644 --- a/src/views/system/departUser/components/DepartRoleUserAuthDrawer.vue +++ b/src/views/system/departUser/components/DepartRoleUserAuthDrawer.vue @@ -1,9 +1,5 @@ \ No newline at end of file + function doReset() { + userId.value = ''; + departId.value = ''; + oldRoleId.value = ''; + desformList.value = []; + designNameValue.value = []; + } + diff --git a/src/views/system/departUser/components/DepartTree.vue b/src/views/system/departUser/components/DepartTree.vue index 17cf163..eb3f385 100644 --- a/src/views/system/departUser/components/DepartTree.vue +++ b/src/views/system/departUser/components/DepartTree.vue @@ -1,9 +1,9 @@ diff --git a/src/views/system/departUser/components/DepartUserInfoTab.vue b/src/views/system/departUser/components/DepartUserInfoTab.vue index c6a60cb..a941e8a 100644 --- a/src/views/system/departUser/components/DepartUserInfoTab.vue +++ b/src/views/system/departUser/components/DepartUserInfoTab.vue @@ -10,228 +10,220 @@ 批量操作 - + - - - + + + diff --git a/src/views/system/departUser/depart.user.api.ts b/src/views/system/departUser/depart.user.api.ts index aef9377..bf9adc1 100644 --- a/src/views/system/departUser/depart.user.api.ts +++ b/src/views/system/departUser/depart.user.api.ts @@ -1,8 +1,8 @@ -import { unref } from 'vue' -import { defHttp } from '/@/utils/http/axios' -import { useMessage } from '/@/hooks/web/useMessage' +import { unref } from 'vue'; +import { defHttp } from '/@/utils/http/axios'; +import { useMessage } from '/@/hooks/web/useMessage'; -const { createConfirm } = useMessage() +const { createConfirm } = useMessage(); enum Api { treeList = '/sys/sysDepart/queryMyDeptTreeList', @@ -35,23 +35,22 @@ enum DepartRoleApi { /** * 获取部门树列表 */ -export const queryMyDepartTreeList = (params?) => - defHttp.get({ url: Api.treeList, params }, { isTransformResponse: false }) +export const queryMyDepartTreeList = (params?) => defHttp.get({ url: Api.treeList, params }, { isTransformResponse: false }); /** * 查询数据,以树结构形式加载所有部门的名称 */ -export const queryIdTree = (params?) => defHttp.get({ url: Api.queryIdTree, params }) +export const queryIdTree = (params?) => defHttp.get({ url: Api.queryIdTree, params }); /** * 根据关键字搜索部门 */ -export const searchByKeywords = (params) => defHttp.get({ url: Api.searchBy, params }) +export const searchByKeywords = (params) => defHttp.get({ url: Api.searchBy, params }); /** * 查询部门下的用户信息 */ -export const departUserList = (params) => defHttp.get({ url: DepartUserApi.list, params }) +export const departUserList = (params) => defHttp.get({ url: DepartUserApi.list, params }); /** * 批量添加部门和用户的关联关系 @@ -59,8 +58,7 @@ export const departUserList = (params) => defHttp.get({ url: DepartUserApi.list, * @param departId 部门ID * @param userIdList 用户ID列表 */ -export const linkDepartUserBatch = (departId: string, userIdList: string[]) => - defHttp.post({ url: DepartUserApi.link, params: { depId: departId, userIdList } }) +export const linkDepartUserBatch = (departId: string, userIdList: string[]) => defHttp.post({ url: DepartUserApi.link, params: { depId: departId, userIdList } }); /** * 批量取消部门和用户的关联关系 @@ -68,8 +66,8 @@ export const linkDepartUserBatch = (departId: string, userIdList: string[]) => export const unlinkDepartUserBatch = (params, confirm = false) => { return new Promise((resolve, reject) => { const doDelete = () => { - resolve(defHttp.delete({ url: DepartUserApi.unlink, params }, { joinParamsToUrl: true })) - } + resolve(defHttp.delete({ url: DepartUserApi.unlink, params }, { joinParamsToUrl: true })); + }; if (confirm) { createConfirm({ iconType: 'warning', @@ -77,28 +75,28 @@ export const unlinkDepartUserBatch = (params, confirm = false) => { content: '确定要取消关联吗?', onOk: () => doDelete(), onCancel: () => reject(), - }) + }); } else { - doDelete() + doDelete(); } - }) -} + }); +}; /** * 查询部门角色信息 */ -export const departRoleList = (params) => defHttp.get({ url: DepartRoleApi.list, params }) +export const departRoleList = (params) => defHttp.get({ url: DepartRoleApi.list, params }); /** * 保存或者更新部门角色 */ export const saveOrUpdateDepartRole = (params, isUpdate) => { if (isUpdate) { - return defHttp.put({ url: DepartRoleApi.edit, params }) + return defHttp.put({ url: DepartRoleApi.edit, params }); } else { - return defHttp.post({ url: DepartRoleApi.save, params }) + return defHttp.post({ url: DepartRoleApi.save, params }); } -} +}; /** * 批量删除部门角色 @@ -106,8 +104,8 @@ export const saveOrUpdateDepartRole = (params, isUpdate) => { export const deleteBatchDepartRole = (params, confirm = false) => { return new Promise((resolve, reject) => { const doDelete = () => { - resolve(defHttp.delete({ url: DepartRoleApi.deleteBatch, params }, { joinParamsToUrl: true })) - } + resolve(defHttp.delete({ url: DepartRoleApi.deleteBatch, params }, { joinParamsToUrl: true })); + }; if (confirm) { createConfirm({ iconType: 'warning', @@ -115,46 +113,46 @@ export const deleteBatchDepartRole = (params, confirm = false) => { content: '确定要删除吗?', onOk: () => doDelete(), onCancel: () => reject(), - }) + }); } else { - doDelete() + doDelete(); } - }) -} + }); +}; /** * 用户角色授权功能,查询菜单权限树 */ -export const queryTreeListForDeptRole = (params) => defHttp.get({ url: DepartRoleApi.queryTreeListForDeptRole, params }) +export const queryTreeListForDeptRole = (params) => defHttp.get({ url: DepartRoleApi.queryTreeListForDeptRole, params }); /** * 查询角色授权 */ -export const queryDeptRolePermission = (params) => defHttp.get({ url: DepartRoleApi.queryDeptRolePermission, params }) +export const queryDeptRolePermission = (params) => defHttp.get({ url: DepartRoleApi.queryDeptRolePermission, params }); /** * 保存角色授权 */ -export const saveDeptRolePermission = (params) => defHttp.post({ url: DepartRoleApi.saveDeptRolePermission, params }) +export const saveDeptRolePermission = (params) => defHttp.post({ url: DepartRoleApi.saveDeptRolePermission, params }); /** * 查询部门角色数据权限列表 */ export const queryDepartRoleDataRule = (functionId, departId, roleId, params?) => { - let url = `${DepartRoleApi.dataRule}/${unref(functionId)}/${unref(departId)}/${unref(roleId)}` - return defHttp.get({ url, params }) -} + let url = `${DepartRoleApi.dataRule}/${unref(functionId)}/${unref(departId)}/${unref(roleId)}`; + return defHttp.get({ url, params }); +}; /** * 保存部门角色数据权限 */ -export const saveDepartRoleDataRule = (params) => defHttp.post({ url: DepartRoleApi.dataRule, params }) +export const saveDepartRoleDataRule = (params) => defHttp.post({ url: DepartRoleApi.dataRule, params }); /** * 查询部门角色用户授权 */ -export const queryDepartRoleUserList = (params) => defHttp.get({ url: DepartRoleApi.getDeptRoleList, params }) +export const queryDepartRoleUserList = (params) => defHttp.get({ url: DepartRoleApi.getDeptRoleList, params }); /** * 根据 userId 查询部门角色用户授权 */ -export const queryDepartRoleByUserId = (params) => defHttp.get({ url: DepartRoleApi.getDeptRoleByUserId, params }) +export const queryDepartRoleByUserId = (params) => defHttp.get({ url: DepartRoleApi.getDeptRoleByUserId, params }); /** * 保存部门角色用户授权 */ -export const saveDepartRoleUser = (params) => defHttp.post({ url: DepartRoleApi.saveDeptRoleUser, params }) +export const saveDepartRoleUser = (params) => defHttp.post({ url: DepartRoleApi.saveDeptRoleUser, params }); diff --git a/src/views/system/departUser/depart.user.data.ts b/src/views/system/departUser/depart.user.data.ts index ff07137..6eaa191 100644 --- a/src/views/system/departUser/depart.user.data.ts +++ b/src/views/system/departUser/depart.user.data.ts @@ -1,8 +1,8 @@ -import { Ref } from 'vue' -import { duplicateCheck } from '/@/views/system/user/user.api' -import { BasicColumn, FormSchema } from '/@/components/Table' -import {DescItem} from "/@/components/Description"; -import {findTree} from "/@/utils/common/compUtils"; +import { Ref } from 'vue'; +import { duplicateCheck } from '/@/views/system/user/user.api'; +import { BasicColumn, FormSchema } from '/@/components/Table'; +import { DescItem } from '/@/components/Description'; +import { findTree } from '/@/utils/common/compUtils'; // 用户信息 columns export const userInfoColumns: BasicColumn[] = [ @@ -19,7 +19,7 @@ export const userInfoColumns: BasicColumn[] = [ { title: '部门', dataIndex: 'orgCode', - width: 200, + width: 200, }, { title: '性别', @@ -31,7 +31,7 @@ export const userInfoColumns: BasicColumn[] = [ dataIndex: 'phone', width: 120, }, -] +]; // 用户信息查询条件表单 export const userInfoSearchFormSchema: FormSchema[] = [ @@ -40,7 +40,7 @@ export const userInfoSearchFormSchema: FormSchema[] = [ label: '用户账号', component: 'Input', }, -] +]; // 部门角色 columns export const departRoleColumns: BasicColumn[] = [ @@ -64,7 +64,7 @@ export const departRoleColumns: BasicColumn[] = [ dataIndex: 'description', width: 100, }, -] +]; // 部门角色查询条件表单 export const departRoleSearchFormSchema: FormSchema[] = [ @@ -73,7 +73,7 @@ export const departRoleSearchFormSchema: FormSchema[] = [ label: '部门角色名称', component: 'Input', }, -] +]; // 部门角色弹窗form表单 export const departRoleModalFormSchema: FormSchema[] = [ @@ -96,7 +96,7 @@ export const departRoleModalFormSchema: FormSchema[] = [ field: 'roleCode', label: '部门角色编码', component: 'Input', - dynamicDisabled: ({values}) => { + dynamicDisabled: ({ values }) => { return !!values.id; }, dynamicRules: ({ model }) => { @@ -106,7 +106,7 @@ export const departRoleModalFormSchema: FormSchema[] = [ { validator: (_, value) => { if (/[\u4E00-\u9FA5]/g.test(value)) { - return Promise.reject('部门角色编码不可输入汉字!') + return Promise.reject('部门角色编码不可输入汉字!'); } return new Promise((resolve, reject) => { let params = { @@ -114,27 +114,27 @@ export const departRoleModalFormSchema: FormSchema[] = [ fieldName: 'role_code', fieldVal: value, dataId: model.id, - } - duplicateCheck(params).then((res) => { - res.success ? resolve() : reject(res.message || '校验失败') - }).catch((err) => { - reject(err.message || '验证失败') - }) - }) + }; + duplicateCheck(params) + .then((res) => { + res.success ? resolve() : reject(res.message || '校验失败'); + }) + .catch((err) => { + reject(err.message || '验证失败'); + }); + }); }, }, - ] + ]; }, }, { field: 'description', label: '描述', component: 'Input', - rules: [ - { min: 0, max: 126, message: '长度不能超过 126 个字符', trigger: 'blur' }, - ], + rules: [{ min: 0, max: 126, message: '长度不能超过 126 个字符', trigger: 'blur' }], }, -] +]; // 基本信息form export function useBaseInfoForm(treeData: Ref) { @@ -148,10 +148,10 @@ export function useBaseInfoForm(treeData: Ref) { label: '上级部门', render(val) { if (val) { - let data = findTree(treeData.value, (item) => item.key == val) - return data?.title ?? val + let data = findTree(treeData.value, (item) => item.key == val); + return data?.title ?? val; } - return val + return val; }, }, { @@ -163,13 +163,13 @@ export function useBaseInfoForm(treeData: Ref) { label: '机构类型', render(val) { if (val === '1') { - return '公司' + return '公司'; } else if (val === '2') { - return '部门' + return '部门'; } else if (val === '3') { - return '岗位' + return '岗位'; } - return val + return val; }, }, { @@ -189,7 +189,7 @@ export function useBaseInfoForm(treeData: Ref) { field: 'memo', label: '备注', }, - ] + ]; - return {descItems} + return { descItems }; } diff --git a/src/views/system/departUser/index.less b/src/views/system/departUser/index.less index 546396d..df2d981 100644 --- a/src/views/system/departUser/index.less +++ b/src/views/system/departUser/index.less @@ -1,7 +1,6 @@ @prefix-cls: ~'@{namespace}-depart-user'; .@{prefix-cls} { - &--tree-search { width: 100%; margin: 10px 0 20px; @@ -37,7 +36,7 @@ } // 夜间模式样式兼容 -[data-theme="dark"] .@{prefix-cls} { +[data-theme='dark'] .@{prefix-cls} { &--base-info-form { .ant-select.ant-select-disabled { .ant-select-selector { diff --git a/src/views/system/departUser/index.vue b/src/views/system/departUser/index.vue index a2e852a..8e053f3 100644 --- a/src/views/system/departUser/index.vue +++ b/src/views/system/departUser/index.vue @@ -1,21 +1,21 @@ diff --git a/src/views/system/dict/components/DictItemList.vue b/src/views/system/dict/components/DictItemList.vue index 759f1a8..da25813 100644 --- a/src/views/system/dict/components/DictItemList.vue +++ b/src/views/system/dict/components/DictItemList.vue @@ -5,31 +5,31 @@ 新增 - + diff --git a/src/views/system/dict/components/DictItemModal.vue b/src/views/system/dict/components/DictItemModal.vue index 5c00a53..1fea1c8 100644 --- a/src/views/system/dict/components/DictItemModal.vue +++ b/src/views/system/dict/components/DictItemModal.vue @@ -1,20 +1,20 @@ diff --git a/src/views/system/dict/components/DictModal.vue b/src/views/system/dict/components/DictModal.vue index 09b0dc4..812a788 100644 --- a/src/views/system/dict/components/DictModal.vue +++ b/src/views/system/dict/components/DictModal.vue @@ -1,52 +1,52 @@ diff --git a/src/views/system/dict/components/DictRecycleBinModal.vue b/src/views/system/dict/components/DictRecycleBinModal.vue index 8c459fc..c7e7cf5 100644 --- a/src/views/system/dict/components/DictRecycleBinModal.vue +++ b/src/views/system/dict/components/DictRecycleBinModal.vue @@ -3,25 +3,25 @@ diff --git a/src/views/system/dict/dict.api.ts b/src/views/system/dict/dict.api.ts index d95540f..1a839ac 100644 --- a/src/views/system/dict/dict.api.ts +++ b/src/views/system/dict/dict.api.ts @@ -1,9 +1,9 @@ -import {defHttp} from '/@/utils/http/axios'; -import {Modal} from 'ant-design-vue'; +import { defHttp } from '/@/utils/http/axios'; +import { Modal } from 'ant-design-vue'; enum Api { list = '/sys/dict/list', - save='/sys/dict/add', - edit='/sys/dict/edit', + save = '/sys/dict/add', + edit = '/sys/dict/edit', duplicateCheck = '/sys/duplicate/check', deleteDict = '/sys/dict/delete', deleteBatch = '/sys/dict/deleteBatch', @@ -18,7 +18,7 @@ enum Api { itemEdit = '/sys/dictItem/edit', dictItemCheck = '/sys/dictItem/dictItemCheck', refreshCache = '/sys/dict/refleshCache', - queryAllDictItems = "/sys/dict/queryAllDictItems", + queryAllDictItems = '/sys/dict/queryAllDictItems', } /** * 导出api @@ -34,16 +34,15 @@ export const getImportUrl = Api.importExcel; * 字典列表接口 * @param params */ -export const list = (params) => - defHttp.get({url: Api.list, params}); +export const list = (params) => defHttp.get({ url: Api.list, params }); /** * 删除字典 */ -export const deleteDict = (params,handleSuccess) => { - return defHttp.delete({url: Api.deleteDict, params}, {joinParamsToUrl: true}).then(() => { +export const deleteDict = (params, handleSuccess) => { + return defHttp.delete({ url: Api.deleteDict, params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); -} +}; /** * 批量删除字典 * @param params @@ -55,88 +54,82 @@ export const batchDeleteDict = (params, handleSuccess) => { okText: '确认', cancelText: '取消', onOk: () => { - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); - } + }, }); -} +}; /** * 保存或者更新字典 * @param params */ export const saveOrUpdateDict = (params, isUpdate) => { let url = isUpdate ? Api.edit : Api.save; - return defHttp.post({url: url, params}); -} + return defHttp.post({ url: url, params }); +}; /** * 唯一校验 * @param params */ -export const duplicateCheck = (params) => - defHttp.get({url: Api.duplicateCheck, params},{isTransformResponse:false}); +export const duplicateCheck = (params) => defHttp.get({ url: Api.duplicateCheck, params }, { isTransformResponse: false }); /** * 字典回收站列表 * @param params */ -export const getRecycleBinList = (params) => - defHttp.get({url: Api.recycleBinList, params}); +export const getRecycleBinList = (params) => defHttp.get({ url: Api.recycleBinList, params }); /** * 回收站还原 * @param params */ -export const putRecycleBin = (id,handleSuccess) =>{ - return defHttp.put({url: Api.putRecycleBin+`/${id}`}).then(() => { +export const putRecycleBin = (id, handleSuccess) => { + return defHttp.put({ url: Api.putRecycleBin + `/${id}` }).then(() => { handleSuccess(); }); -} +}; /** * 回收站删除 * @param params */ -export const deleteRecycleBin = (id,handleSuccess) => { - return defHttp.delete({url: Api.deleteRecycleBin+`/${id}`}).then(() => { +export const deleteRecycleBin = (id, handleSuccess) => { + return defHttp.delete({ url: Api.deleteRecycleBin + `/${id}` }).then(() => { handleSuccess(); }); -} +}; /** * 字典配置列表 * @param params */ -export const itemList = (params) => - defHttp.get({url: Api.itemList, params}); +export const itemList = (params) => defHttp.get({ url: Api.itemList, params }); /** * 字典配置删除 * @param params */ -export const deleteItem = (params,handleSuccess) => { - return defHttp.delete({url: Api.deleteItem, params}, {joinParamsToUrl: true}).then(() => { +export const deleteItem = (params, handleSuccess) => { + return defHttp.delete({ url: Api.deleteItem, params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); -} +}; /** * 保存或者更新字典配置 * @param params */ export const saveOrUpdateDictItem = (params, isUpdate) => { let url = isUpdate ? Api.itemEdit : Api.itemSave; - return defHttp.post({url: url, params}); -} + return defHttp.post({ url: url, params }); +}; /** * 校验字典数据值 * @param params */ -export const dictItemCheck = (params) => - defHttp.get({url: Api.dictItemCheck, params},{isTransformResponse:false}); +export const dictItemCheck = (params) => defHttp.get({ url: Api.dictItemCheck, params }, { isTransformResponse: false }); /** * 刷新字典 * @param params */ -export const refreshCache = () => - defHttp.get({url: Api.refreshCache},{isTransformResponse:false}); +export const refreshCache = () => defHttp.get({ url: Api.refreshCache }, { isTransformResponse: false }); /** * 获取所有字典项 * @param params */ -export const queryAllDictItems = () => - defHttp.get({url: Api.queryAllDictItems},{isTransformResponse:false}); +export const queryAllDictItems = () => defHttp.get({ url: Api.queryAllDictItems }, { isTransformResponse: false }); diff --git a/src/views/system/dict/dict.data.ts b/src/views/system/dict/dict.data.ts index 936b5d8..97c9b58 100644 --- a/src/views/system/dict/dict.data.ts +++ b/src/views/system/dict/dict.data.ts @@ -1,7 +1,7 @@ import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Table'; -import {dictItemCheck} from "./dict.api"; -import { rules} from '/@/utils/helper/validator'; +import { dictItemCheck } from './dict.api'; +import { rules } from '/@/utils/helper/validator'; export const columns: BasicColumn[] = [ { title: '字典名称', @@ -17,7 +17,8 @@ export const columns: BasicColumn[] = [ title: '描述', dataIndex: 'description', // width: 120 - }]; + }, +]; export const recycleBincolumns: BasicColumn[] = [ { @@ -33,22 +34,23 @@ export const recycleBincolumns: BasicColumn[] = [ { title: '描述', dataIndex: 'description', - width: 120 - }]; + width: 120, + }, +]; export const searchFormSchema: FormSchema[] = [ { label: '字典名称', field: 'dictName', component: 'Input', - colProps: {span: 6}, + colProps: { span: 6 }, }, { label: '字典编码', field: 'dictCode', component: 'Input', - colProps: {span: 6}, - } + colProps: { span: 6 }, + }, ]; export const formSchema: FormSchema[] = [ @@ -56,7 +58,7 @@ export const formSchema: FormSchema[] = [ label: '', field: 'id', component: 'Input', - show:false + show: false, }, { label: '字典名称', @@ -68,47 +70,46 @@ export const formSchema: FormSchema[] = [ label: '字典编码', field: 'dictCode', component: 'Input', - dynamicDisabled: ({values}) => { + dynamicDisabled: ({ values }) => { return !!values.id; }, - dynamicRules:({model,schema}) =>rules.duplicateCheckRule("sys_dict", "dict_code",model,schema,true), + dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_dict', 'dict_code', model, schema, true), }, { label: '描述', field: 'description', - component: 'Input' - } + component: 'Input', + }, ]; export const dictItemColumns: BasicColumn[] = [ { title: '名称', dataIndex: 'itemText', - width: 80 + width: 80, }, { title: '数据值', dataIndex: 'itemValue', - width: 80 - }]; + width: 80, + }, +]; export const dictItemSearchFormSchema: FormSchema[] = [ { label: '名称', field: 'itemText', component: 'Input', - }, { label: '状态', field: 'status', component: 'JDictSelectTag', componentProps: { - dictCode:'dict_item_status', - stringToNumber:true + dictCode: 'dict_item_status', + stringToNumber: true, }, - - } + }, ]; export const itemFormSchema: FormSchema[] = [ @@ -116,7 +117,7 @@ export const itemFormSchema: FormSchema[] = [ label: '', field: 'id', component: 'Input', - show:false + show: false, }, { label: '名称', @@ -128,7 +129,7 @@ export const itemFormSchema: FormSchema[] = [ label: '数据值', field: 'itemValue', component: 'Input', - dynamicRules: ({values, model}) => { + dynamicRules: ({ values, model }) => { return [ { required: true, @@ -143,14 +144,15 @@ export const itemFormSchema: FormSchema[] = [ let params = { dictId: values.dictId, id: model.id, - itemValue: value + itemValue: value, }; dictItemCheck(params) .then((res) => { res.success ? resolve() : reject(res.message || '校验失败'); - }).catch((err) => { - reject(err.message || '验证失败'); - }); + }) + .catch((err) => { + reject(err.message || '验证失败'); + }); }); }, }, @@ -160,7 +162,7 @@ export const itemFormSchema: FormSchema[] = [ { label: '描述', field: 'description', - component: 'Input' + component: 'Input', }, { field: 'sortOrder', @@ -174,9 +176,9 @@ export const itemFormSchema: FormSchema[] = [ defaultValue: 1, component: 'JDictSelectTag', componentProps: { - type:'radioButton', - dictCode:'dict_item_status', - stringToNumber:true + type: 'radioButton', + dictCode: 'dict_item_status', + stringToNumber: true, }, - } + }, ]; diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index c4261bc..05e060a 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -1,68 +1,69 @@ - + diff --git a/src/views/system/examples/demo/DemoModal.vue b/src/views/system/examples/demo/DemoModal.vue index f2035af..f9f9473 100644 --- a/src/views/system/examples/demo/DemoModal.vue +++ b/src/views/system/examples/demo/DemoModal.vue @@ -1,53 +1,53 @@ diff --git a/src/views/system/examples/demo/demo.api.ts b/src/views/system/examples/demo/demo.api.ts index eb2d3e0..1cde92b 100644 --- a/src/views/system/examples/demo/demo.api.ts +++ b/src/views/system/examples/demo/demo.api.ts @@ -1,15 +1,15 @@ -import {defHttp} from '/@/utils/http/axios'; -import {Modal} from 'ant-design-vue'; +import { defHttp } from '/@/utils/http/axios'; +import { Modal } from 'ant-design-vue'; enum Api { - list = "/test/jeecgDemo/list", - save = "/test/jeecgDemo/add", - edit = "/test/jeecgDemo/edit", - get = "/test/jeecgDemo/queryById", - delete = "/test/jeecgDemo/delete", - deleteBatch = "/test/jeecgDemo/deleteBatch", - exportXls = "/test/jeecgDemo/exportXls", - importExcel = "/test/jeecgDemo/importExcel", + list = '/test/jeecgDemo/list', + save = '/test/jeecgDemo/add', + edit = '/test/jeecgDemo/edit', + get = '/test/jeecgDemo/queryById', + delete = '/test/jeecgDemo/delete', + deleteBatch = '/test/jeecgDemo/deleteBatch', + exportXls = '/test/jeecgDemo/exportXls', + importExcel = '/test/jeecgDemo/importExcel', } /** * 导出api @@ -24,51 +24,50 @@ export const getImportUrl = Api.importExcel; * @param params */ export const getDemoList = (params) => { - return defHttp.get({url: Api.list, params}); -} + return defHttp.get({ url: Api.list, params }); +}; /** * 保存或者更新示例 * @param params */ export const saveOrUpdateDemo = (params, isUpdate) => { - let url = isUpdate ? Api.edit : Api.save; - return defHttp.post({url: url, params}); -} + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({ url: url, params }); +}; /** * 查询示例详情 * @param params */ export const getDemoById = (params) => { - return defHttp.get({url: Api.get, params}); -} + return defHttp.get({ url: Api.get, params }); +}; /** * 删除示例 * @param params */ -export const deleteDemo = (params,handleSuccess) => { - return defHttp.delete({url: Api.delete, data: params}, {joinParamsToUrl: true}).then(()=>{ - handleSuccess(); - }); -} +export const deleteDemo = (params, handleSuccess) => { + return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; /** * 批量删除示例 * @param params */ export const batchDeleteDemo = (params, handleSuccess) => { - Modal.confirm({ - title: '确认删除', - content: '是否删除选中数据', - okText: '确认', - cancelText: '取消', - onOk: () => { - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); - } - }); -} - + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; diff --git a/src/views/system/examples/demo/demo.data.ts b/src/views/system/examples/demo/demo.data.ts index 86f055a..b780095 100644 --- a/src/views/system/examples/demo/demo.data.ts +++ b/src/views/system/examples/demo/demo.data.ts @@ -1,182 +1,180 @@ -import {BasicColumn} from '/@/components/Table'; -import {FormSchema} from '/@/components/Table'; -import {render} from "/@/utils/common/renderUtils"; +import { BasicColumn } from '/@/components/Table'; +import { FormSchema } from '/@/components/Table'; +import { render } from '/@/utils/common/renderUtils'; export const columns: BasicColumn[] = [ - { - title: '姓名', - dataIndex: 'name', - width: 70, - align: 'left', - }, - { - title: '关键词', - dataIndex: 'keyWord', - width: 30, - }, - { - title: '打卡时间', - dataIndex: 'punchTime', - width: 40, - }, - { - title: '工资', - dataIndex: 'salaryMoney', - width: 40 - }, - { - title: '奖金', - dataIndex: 'bonusMoney', - width: 40, - }, - { - title: '性别', - dataIndex: 'sex', - customRender: ({record}) => { - return render.renderDict(record.sex, 'sex') - // let v = record.sex ? (record.sex == '1' ? '男' : '女') : ''; - // return h('span', v); - }, - width: 20 - }, - { - title: '生日', - dataIndex: 'birthday', - width: 20 - }, - { - title: '邮箱', - dataIndex: 'email', - width: 20 - }, - { - title: '个人简介', - dataIndex: 'content', - width: 20 + { + title: '姓名', + dataIndex: 'name', + width: 70, + align: 'left', + }, + { + title: '关键词', + dataIndex: 'keyWord', + width: 30, + }, + { + title: '打卡时间', + dataIndex: 'punchTime', + width: 40, + }, + { + title: '工资', + dataIndex: 'salaryMoney', + width: 40, + }, + { + title: '奖金', + dataIndex: 'bonusMoney', + width: 40, + }, + { + title: '性别', + dataIndex: 'sex', + customRender: ({ record }) => { + return render.renderDict(record.sex, 'sex'); + // let v = record.sex ? (record.sex == '1' ? '男' : '女') : ''; + // return h('span', v); }, + width: 20, + }, + { + title: '生日', + dataIndex: 'birthday', + width: 20, + }, + { + title: '邮箱', + dataIndex: 'email', + width: 20, + }, + { + title: '个人简介', + dataIndex: 'content', + width: 20, + }, ]; export const searchFormSchema: FormSchema[] = [ - { - field: 'name', - label: '姓名', - component: 'Input', - colProps: {span: 8}, - }, - { - field: 'birthday', - label: '生日', - component: 'RangePicker', - colProps: {span: 8}, - }, - { - field: 'age', - label: '年龄', - component: 'Input', - slot:"age", - colProps: {span: 8}, - }, - { - field: 'sex', - label: '性别', - colProps: {span: 8}, - component: 'JDictSelectTag', - componentProps: { - dictCode:'sex', - placeholder:'请选择性别' - }, + { + field: 'name', + label: '姓名', + component: 'Input', + colProps: { span: 8 }, + }, + { + field: 'birthday', + label: '生日', + component: 'RangePicker', + colProps: { span: 8 }, + }, + { + field: 'age', + label: '年龄', + component: 'Input', + slot: 'age', + colProps: { span: 8 }, + }, + { + field: 'sex', + label: '性别', + colProps: { span: 8 }, + component: 'JDictSelectTag', + componentProps: { + dictCode: 'sex', + placeholder: '请选择性别', }, + }, ]; export const formSchema: FormSchema[] = [ - { - field: 'id', - label: 'id', - component: 'Input', - show:false + { + field: 'id', + label: 'id', + component: 'Input', + show: false, + }, + { + field: 'name', + label: '名字', + component: 'Input', + required: true, + componentProps: { + placeholder: '请输入名字', }, - { - field: 'name', - label: '名字', - component: 'Input', - required: true, - componentProps: { - placeholder: '请输入名字', - } + }, + { + field: 'keyWord', + label: '关键词', + component: 'Input', + componentProps: { + placeholder: '请输入关键词', }, - { - field: 'keyWord', - label: '关键词', - component: 'Input', - componentProps: { - placeholder: '请输入关键词', - } + }, + { + field: 'punchTime', + label: '打卡时间', + component: 'DatePicker', + componentProps: { + showTime: true, + valueFormat: 'YYYY-MM-DD HH:mm:ss', + placeholder: '请选择打卡时间', }, - { - field: 'punchTime', - label: '打卡时间', - component: 'DatePicker', - componentProps: { - showTime:true, - valueFormat:'YYYY-MM-DD HH:mm:ss', - placeholder: '请选择打卡时间', - } + }, + { + field: 'salaryMoney', + label: '工资', + component: 'Input', + componentProps: { + placeholder: '请输入工资', }, - { - field: 'salaryMoney', - label: '工资', - component: 'Input', - componentProps: { - placeholder: '请输入工资', - } + }, + { + field: 'sex', + label: '性别', + component: 'JDictSelectTag', + defaultValue: '1', + componentProps: { + type: 'radio', + dictCode: 'sex', + placeholder: '请选择性别', }, - { - field: 'sex', - label: '性别', - component: 'JDictSelectTag', - defaultValue: '1', - componentProps: { - type: 'radio', - dictCode:'sex', - placeholder:'请选择性别' - }, + }, + { + field: 'age', + label: '年龄', + component: 'InputNumber', + defaultValue: 1, + componentProps: { + placeholder: '请输入年龄', }, - { - field: 'age', - label: '年龄', - component: 'InputNumber', - defaultValue: 1, - componentProps: { - placeholder: '请输入年龄', - }, + }, + { + field: 'birthday', + label: '生日', + component: 'DatePicker', + componentProps: { + showTime: true, + valueFormat: 'YYYY-MM-DD', + placeholder: '请选择生日', }, - { - field: 'birthday', - label: '生日', - component: 'DatePicker', - componentProps: { - showTime:true, - valueFormat:'YYYY-MM-DD', - placeholder: '请选择生日', - }, + }, + { + field: 'email', + label: '邮箱', + component: 'Input', + rules: [{ required: false, type: 'email', message: '邮箱格式不正确', trigger: 'blur' }], + componentProps: { + placeholder: '请输入邮箱', }, - { - field: 'email', - label: '邮箱', - component: 'Input', - rules: [ - { required: false, type: 'email', message: '邮箱格式不正确', trigger: 'blur' } - ], - componentProps: { - placeholder: '请输入邮箱', - }, - }, - { - field: 'content', - label: '个人简介', - component: 'InputTextArea', - componentProps: { - placeholder: '请输入个人简介', - }, + }, + { + field: 'content', + label: '个人简介', + component: 'InputTextArea', + componentProps: { + placeholder: '请输入个人简介', }, + }, ]; diff --git a/src/views/system/examples/demo/index.vue b/src/views/system/examples/demo/index.vue index 3b20307..68e8dc8 100644 --- a/src/views/system/examples/demo/index.vue +++ b/src/views/system/examples/demo/index.vue @@ -1,262 +1,262 @@ diff --git a/src/views/system/fillRule/FillRuleModal.vue b/src/views/system/fillRule/FillRuleModal.vue index 918f889..6dec588 100644 --- a/src/views/system/fillRule/FillRuleModal.vue +++ b/src/views/system/fillRule/FillRuleModal.vue @@ -1,66 +1,65 @@ + }); + //表单提交事件 + async function handleSubmit() { + try { + let formValue = await validate(); + setModalProps({ confirmLoading: true }); + if (isUpdate.value) { + let allFieldsValue = getFieldsValue(); + // 编辑页面 如果表单没有父级下拉框 则提交时候 validate方法不返该值 需要手动设置 + if (!formValue.parentId && allFieldsValue.parentId) { + formValue.parentId = allFieldsValue.parentId; + } + await updateFillRule(formValue); + } else { + await saveFillRule(formValue); + } + //关闭弹窗 + closeModal(); + //刷新列表 + emit('success'); + } finally { + setModalProps({ confirmLoading: false }); + } + } + diff --git a/src/views/system/fillRule/fill.rule.api.ts b/src/views/system/fillRule/fill.rule.api.ts index b970bfa..1348a12 100644 --- a/src/views/system/fillRule/fill.rule.api.ts +++ b/src/views/system/fillRule/fill.rule.api.ts @@ -2,14 +2,14 @@ import { defHttp } from '/@/utils/http/axios'; import { Modal } from 'ant-design-vue'; enum Api { - list = '/sys/fillRule/list', - test = '/sys/fillRule/testFillRule', - save = '/sys/fillRule/add', - edit = '/sys/fillRule/edit', - delete = '/sys/fillRule/delete', - deleteBatch = '/sys/fillRule/deleteBatch', - exportXls = '/sys/fillRule/exportXls', - importExcel = '/sys/fillRule/importExcel' + list = '/sys/fillRule/list', + test = '/sys/fillRule/testFillRule', + save = '/sys/fillRule/add', + edit = '/sys/fillRule/edit', + delete = '/sys/fillRule/delete', + deleteBatch = '/sys/fillRule/deleteBatch', + exportXls = '/sys/fillRule/exportXls', + importExcel = '/sys/fillRule/importExcel', } /** @@ -26,8 +26,8 @@ export const importUrl = Api.importExcel; * @param params */ export const getFillRuleList = (params) => { - return defHttp.get({url: Api.list, params}); -} + return defHttp.get({ url: Api.list, params }); +}; /** * 删除 @@ -35,50 +35,49 @@ export const getFillRuleList = (params) => { * @param handleSuccess */ export const deleteFillRule = (params, handleSuccess) => { - return defHttp.delete({url: Api.delete, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); -} + return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); +}; /** * 批量删除 * @param params */ export const batchDeleteFillRule = (params, handleSuccess) => { - Modal.confirm({ - title: '确认删除', - content: '是否删除选中数据', - okText: '确认', - cancelText: '取消', - onOk: () => { - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { - handleSuccess(); - }); - } - }); -} + Modal.confirm({ + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { + handleSuccess(); + }); + }, + }); +}; /** * 规则功能测试 * @param params */ export const handleTest = (params) => { - return defHttp.get({url: Api.test, params}, {isTransformResponse: false}); -} - + return defHttp.get({ url: Api.test, params }, { isTransformResponse: false }); +}; /** * 保存 * @param params */ export const saveFillRule = (params) => { - return defHttp.post({url: Api.save, params}); -} + return defHttp.post({ url: Api.save, params }); +}; /** * 更新 * @param params */ export const updateFillRule = (params) => { - return defHttp.put({url: Api.edit, params}); -} + return defHttp.put({ url: Api.edit, params }); +}; diff --git a/src/views/system/fillRule/fill.rule.data.ts b/src/views/system/fillRule/fill.rule.data.ts index 7f1bd97..4e07fd1 100644 --- a/src/views/system/fillRule/fill.rule.data.ts +++ b/src/views/system/fillRule/fill.rule.data.ts @@ -1,109 +1,109 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; -import {duplicateCheck} from "/@/views/system/user/user.api"; +import { duplicateCheck } from '/@/views/system/user/user.api'; export const columns: BasicColumn[] = [ - { - title: '规则名称', - dataIndex: 'ruleName', - width: 200, - align: 'center', - }, - { - title: '规则编码', - dataIndex: 'ruleCode', - width: 200, - align: 'center', - }, - { - title: '规则实现类', - dataIndex: 'ruleClass', - width: 300, - align: 'center', - }, - { - title: '规则参数', - dataIndex: 'ruleParams', - width: 200, - align: 'center' - } + { + title: '规则名称', + dataIndex: 'ruleName', + width: 200, + align: 'center', + }, + { + title: '规则编码', + dataIndex: 'ruleCode', + width: 200, + align: 'center', + }, + { + title: '规则实现类', + dataIndex: 'ruleClass', + width: 300, + align: 'center', + }, + { + title: '规则参数', + dataIndex: 'ruleParams', + width: 200, + align: 'center', + }, ]; export const searchFormSchema: FormSchema[] = [ - { - field: 'ruleName', - label: '规则名称', - component: 'Input', - colProps: { span: 6 }, - }, - { - field: 'ruleCode', - label: '规则编码', - component: 'Input', - colProps: { span: 6 }, - }, + { + field: 'ruleName', + label: '规则名称', + component: 'Input', + colProps: { span: 6 }, + }, + { + field: 'ruleCode', + label: '规则编码', + component: 'Input', + colProps: { span: 6 }, + }, ]; - export const formSchema: FormSchema[] = [ - { - label: '', - field: 'id', - component: 'Input', - show:false + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + field: 'ruleName', + label: '规则名称', + component: 'Input', + required: true, + colProps: { span: 24 }, + }, + { + field: 'ruleCode', + label: '规则编码', + component: 'Input', + colProps: { span: 24 }, + dynamicDisabled: ({ values }) => { + return !!values.id; }, - { - field: 'ruleName', - label: '规则名称', - component: 'Input', - required: true, - colProps: { span: 24 } - }, - { - field: 'ruleCode', - label: '规则编码', - component: 'Input', - colProps: { span: 24 }, - dynamicDisabled: ({values}) => { - return !!values.id; + dynamicRules: ({ model }) => { + return [ + { + required: true, + validator: (_, value) => { + return new Promise((resolve, reject) => { + if (!value) { + return reject('请输入规则编码!'); + } + let params = { + tableName: 'sys_fill_rule', + fieldName: 'rule_code', + fieldVal: value, + dataId: model.id, + }; + duplicateCheck(params) + .then((res) => { + res.success ? resolve() : reject('规则编码已存在!'); + }) + .catch((err) => { + reject(err.message || '校验失败'); + }); + }); + }, }, - dynamicRules: ({ model }) => { - return [ - { - required: true, - validator: (_, value) => { - return new Promise((resolve, reject) => { - if (!value) { - return reject('请输入规则编码!'); - } - let params = { - tableName: "sys_fill_rule", - fieldName: "rule_code", - fieldVal: value, - dataId: model.id, - }; - duplicateCheck(params) - .then((res) => { - res.success ? resolve() : reject('规则编码已存在!'); - }).catch((err) => { - reject(err.message || '校验失败'); - }); - }); - }, - }, - ]; - } + ]; }, - { - field: 'ruleClass', - label: '规则实现类', - component: 'Input', - required: true, - colProps: { span: 24 } - }, - { - field: 'ruleParams', - label: '规则参数', - colProps: { span: 24 }, - component: 'JAddInput' - }, -] + }, + { + field: 'ruleClass', + label: '规则实现类', + component: 'Input', + required: true, + colProps: { span: 24 }, + }, + { + field: 'ruleParams', + label: '规则参数', + colProps: { span: 24 }, + component: 'JAddInput', + }, +]; diff --git a/src/views/system/fillRule/index.vue b/src/views/system/fillRule/index.vue index dbf9b4f..93d5e1c 100644 --- a/src/views/system/fillRule/index.vue +++ b/src/views/system/fillRule/index.vue @@ -1,149 +1,146 @@ diff --git a/src/views/system/menu/DataRuleList.vue b/src/views/system/menu/DataRuleList.vue index 72ae3be..e3731fb 100644 --- a/src/views/system/menu/DataRuleList.vue +++ b/src/views/system/menu/DataRuleList.vue @@ -5,30 +5,30 @@ 新增 - + diff --git a/src/views/system/menu/DataRuleModal.vue b/src/views/system/menu/DataRuleModal.vue index 7230398..1daa5a8 100644 --- a/src/views/system/menu/DataRuleModal.vue +++ b/src/views/system/menu/DataRuleModal.vue @@ -1,28 +1,28 @@ diff --git a/src/views/system/menu/MenuDrawer.vue b/src/views/system/menu/MenuDrawer.vue index 4e47529..412cb8c 100644 --- a/src/views/system/menu/MenuDrawer.vue +++ b/src/views/system/menu/MenuDrawer.vue @@ -1,80 +1,83 @@ - diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index a6de0f2..3cd4907 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -1,71 +1,70 @@ diff --git a/src/views/system/message/manage/index.less b/src/views/system/message/manage/index.less index 690d891..63b7bd0 100644 --- a/src/views/system/message/manage/index.less +++ b/src/views/system/message/manage/index.less @@ -2,4 +2,4 @@ @prefix-cls: ~'@{namespace}-message-manage'; .@{prefix-cls} { -} \ No newline at end of file +} diff --git a/src/views/system/message/manage/index.vue b/src/views/system/message/manage/index.vue index 1fd3708..2602be1 100644 --- a/src/views/system/message/manage/index.vue +++ b/src/views/system/message/manage/index.vue @@ -21,112 +21,109 @@ - +
- diff --git a/src/views/system/message/manage/manage.api.ts b/src/views/system/message/manage/manage.api.ts index a3100c8..b83d6c2 100644 --- a/src/views/system/message/manage/manage.api.ts +++ b/src/views/system/message/manage/manage.api.ts @@ -1,8 +1,8 @@ -import { unref } from 'vue' -import { defHttp } from '/@/utils/http/axios' -import { useMessage } from '/@/hooks/web/useMessage' +import { unref } from 'vue'; +import { defHttp } from '/@/utils/http/axios'; +import { useMessage } from '/@/hooks/web/useMessage'; -const { createConfirm } = useMessage() +const { createConfirm } = useMessage(); export enum Api { list = '/sys/message/sysMessage/list', @@ -14,7 +14,7 @@ export enum Api { edit = '/sys/message/sysMessage/edit', } -export const list = (params) => defHttp.get({ url: Api.list, params }) +export const list = (params) => defHttp.get({ url: Api.list, params }); /** * 批量删除 @@ -24,8 +24,8 @@ export const list = (params) => defHttp.get({ url: Api.list, params }) export const deleteBatch = (params, confirm = false) => { return new Promise((resolve, reject) => { const doDelete = () => { - resolve(defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true })) - } + resolve(defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true })); + }; if (confirm) { createConfirm({ iconType: 'warning', @@ -33,20 +33,20 @@ export const deleteBatch = (params, confirm = false) => { content: '确定要删除吗?', onOk: () => doDelete(), onCancel: () => reject(), - }) + }); } else { - doDelete() + doDelete(); } - }) -} + }); +}; /** * 保存或者更改消息模板 */ export const saveOrUpdate = (params, isUpdate) => { if (unref(isUpdate)) { - return defHttp.put({ url: Api.edit, params }) + return defHttp.put({ url: Api.edit, params }); } else { - return defHttp.post({ url: Api.save, params }) + return defHttp.post({ url: Api.save, params }); } -} +}; diff --git a/src/views/system/message/manage/manage.data.ts b/src/views/system/message/manage/manage.data.ts index 87495b0..97b2a92 100644 --- a/src/views/system/message/manage/manage.data.ts +++ b/src/views/system/message/manage/manage.data.ts @@ -1,4 +1,4 @@ -import { BasicColumn, FormSchema } from '/@/components/Table' +import { BasicColumn, FormSchema } from '/@/components/Table'; export const columns: BasicColumn[] = [ { @@ -37,7 +37,7 @@ export const columns: BasicColumn[] = [ dataIndex: 'esType_dictText', width: 120, }, -] +]; export const searchFormSchema: FormSchema[] = [ { @@ -61,7 +61,7 @@ export const searchFormSchema: FormSchema[] = [ dictCode: 'msgType', }, }, -] +]; export const formSchemas: FormSchema[] = [ { @@ -131,4 +131,4 @@ export const formSchemas: FormSchema[] = [ component: 'InputTextArea', componentProps: { readOnly: true }, }, -] +]; diff --git a/src/views/system/message/template/TemplateModal.vue b/src/views/system/message/template/TemplateModal.vue index 24e5087..6eb9193 100644 --- a/src/views/system/message/template/TemplateModal.vue +++ b/src/views/system/message/template/TemplateModal.vue @@ -1,46 +1,46 @@ diff --git a/src/views/system/message/template/TemplateTestModal.vue b/src/views/system/message/template/TemplateTestModal.vue index ade95f5..eeea2f5 100644 --- a/src/views/system/message/template/TemplateTestModal.vue +++ b/src/views/system/message/template/TemplateTestModal.vue @@ -1,40 +1,40 @@ diff --git a/src/views/system/message/template/index.less b/src/views/system/message/template/index.less index 360fab9..15e8d49 100644 --- a/src/views/system/message/template/index.less +++ b/src/views/system/message/template/index.less @@ -2,4 +2,4 @@ @prefix-cls: ~'@{namespace}-message-template'; .@{prefix-cls} { -} \ No newline at end of file +} diff --git a/src/views/system/message/template/index.vue b/src/views/system/message/template/index.vue index b02aded..28077a3 100644 --- a/src/views/system/message/template/index.vue +++ b/src/views/system/message/template/index.vue @@ -24,134 +24,129 @@ - - + +
- diff --git a/src/views/system/message/template/template.api.ts b/src/views/system/message/template/template.api.ts index ef8fb8c..fe4f03c 100644 --- a/src/views/system/message/template/template.api.ts +++ b/src/views/system/message/template/template.api.ts @@ -1,8 +1,8 @@ -import { unref } from 'vue' -import { defHttp } from '/@/utils/http/axios' -import { useMessage } from '/@/hooks/web/useMessage' +import { unref } from 'vue'; +import { defHttp } from '/@/utils/http/axios'; +import { useMessage } from '/@/hooks/web/useMessage'; -const { createConfirm } = useMessage() +const { createConfirm } = useMessage(); export enum Api { list = '/sys/message/sysMessageTemplate/list', @@ -16,7 +16,7 @@ export enum Api { send = '/sys/message/sysMessageTemplate/sendMsg', } -export const list = (params) => defHttp.get({ url: Api.list, params }) +export const list = (params) => defHttp.get({ url: Api.list, params }); /** * 批量删除 @@ -26,8 +26,8 @@ export const list = (params) => defHttp.get({ url: Api.list, params }) export const deleteBatch = (params, confirm = false) => { return new Promise((resolve, reject) => { const doDelete = () => { - resolve(defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true })) - } + resolve(defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true })); + }; if (confirm) { createConfirm({ iconType: 'warning', @@ -35,26 +35,26 @@ export const deleteBatch = (params, confirm = false) => { content: '确定要删除吗?', onOk: () => doDelete(), onCancel: () => reject(), - }) + }); } else { - doDelete() + doDelete(); } - }) -} + }); +}; /** * 保存或者更改消息模板 */ export const saveOrUpdate = (params, isUpdate) => { if (unref(isUpdate)) { - return defHttp.put({ url: Api.edit, params }) + return defHttp.put({ url: Api.edit, params }); } else { - return defHttp.post({ url: Api.save, params }) + return defHttp.post({ url: Api.save, params }); } -} +}; /** * 发送消息测试 * @param params */ -export const sendMessageTest = (params) => defHttp.post({ url: Api.send, params }) +export const sendMessageTest = (params) => defHttp.post({ url: Api.send, params }); diff --git a/src/views/system/message/template/template.data.ts b/src/views/system/message/template/template.data.ts index e655298..317f243 100644 --- a/src/views/system/message/template/template.data.ts +++ b/src/views/system/message/template/template.data.ts @@ -1,5 +1,5 @@ -import { BasicColumn, FormSchema } from '/@/components/Table' -import { rules } from '/@/utils/helper/validator' +import { BasicColumn, FormSchema } from '/@/components/Table'; +import { rules } from '/@/utils/helper/validator'; export const columns: BasicColumn[] = [ { @@ -23,21 +23,21 @@ export const columns: BasicColumn[] = [ width: 100, customRender: function ({ text }) { if (text == '1') { - return '短信' + return '短信'; } if (text == '2') { - return '邮件' + return '邮件'; } if (text == '3') { - return '微信' + return '微信'; } if (text == '4') { - return '系统' + return '系统'; } - return text + return text; }, }, -] +]; export const searchFormSchema: FormSchema[] = [ { @@ -58,7 +58,7 @@ export const searchFormSchema: FormSchema[] = [ dictCode: 'msgType', }, }, -] +]; export const formSchemas: FormSchema[] = [ { @@ -78,15 +78,11 @@ export const formSchemas: FormSchema[] = [ field: 'templateCode', component: 'Input', dynamicRules: ({ model, schema }) => { - return [ - { required: true, message: '请输入模板编码!' }, - ...rules.duplicateCheckRule('sys_sms_template', 'template_code', model, schema, true), - ] + return [{ required: true, message: '请输入模板编码!' }, ...rules.duplicateCheckRule('sys_sms_template', 'template_code', model, schema, true)]; }, // 编辑模式下不可修改编码 dynamicDisabled: (params) => !!params.values.id, - } - , + }, { label: '模板类型', field: 'templateType', @@ -108,7 +104,7 @@ export const formSchemas: FormSchema[] = [ }, }, ifShow: ({ values }) => { - return !['2', '4'].includes(values.templateType) + return !['2', '4'].includes(values.templateType); }, }, @@ -117,10 +113,10 @@ export const formSchemas: FormSchema[] = [ field: 'templateContent', component: 'JEditor', ifShow: ({ values }) => { - return ['2', '4'].includes(values.templateType) + return ['2', '4'].includes(values.templateType); }, }, -] +]; export const sendTestFormSchemas: FormSchema[] = [ { @@ -165,4 +161,4 @@ export const sendTestFormSchemas: FormSchema[] = [ component: 'Input', required: true, }, -] +]; diff --git a/src/views/system/notice/DetailModal.vue b/src/views/system/notice/DetailModal.vue index 1690eeb..7497e73 100644 --- a/src/views/system/notice/DetailModal.vue +++ b/src/views/system/notice/DetailModal.vue @@ -1,11 +1,11 @@