Browse Source

perf(组件:SmartLayoutSeparate): 支持设置第二元素宽度

shizhongming 2 years ago
parent
commit
28ea02fc7a
  1. 3
      src/components/LayoutSeparate/index.ts
  2. 3
      src/components/SmartLayoutSeparate/index.ts
  3. 0
      src/components/SmartLayoutSeparate/src/SmartLayoutSeparate.less
  4. 84
      src/components/SmartLayoutSeparate/src/SmartLayoutSeparate.tsx
  5. 6
      src/modules/smart-code/views/codeList/CodeListView.vue
  6. 6
      src/modules/smart-code/views/codeList/components/TemplateSelectTable.vue
  7. 6
      src/modules/smart-code/views/database/DatabaseListView.vue
  8. 6
      src/modules/smart-code/views/template/CodeTemplateList.vue
  9. 6
      src/modules/smart-system/views/authSecret/SmartAuthSecretKeyListView.vue
  10. 8
      src/modules/smart-system/views/dataDict/DataDictListView.vue
  11. 6
      src/modules/smart-system/views/license/LicenseListView.vue
  12. 6
      src/modules/smart-system/views/user/UserListView.vue

3
src/components/LayoutSeparate/index.ts

@ -1,3 +0,0 @@
import LayoutSeparate from './src/LayoutSeparate';
export { LayoutSeparate };

3
src/components/SmartLayoutSeparate/index.ts

@ -0,0 +1,3 @@
import SmartLayoutSeparate from './src/SmartLayoutSeparate';
export { SmartLayoutSeparate };

0
src/components/LayoutSeparate/src/LayoutSeparate.less → src/components/SmartLayoutSeparate/src/SmartLayoutSeparate.less

84
src/components/LayoutSeparate/src/LayoutSeparate.tsx → src/components/SmartLayoutSeparate/src/SmartLayoutSeparate.tsx

@ -1,22 +1,33 @@
import { defineComponent, computed, toRefs, ref, watch } from 'vue'; import { defineComponent, computed, toRefs, ref, watch, unref } from 'vue';
import type { PropType, Ref, StyleValue } from 'vue'; import type { PropType, Ref, StyleValue } from 'vue';
import { Divider } from 'ant-design-vue'; import { Divider } from 'ant-design-vue';
import { isFinite, endsWith, replace, parseInt, toNumber } from 'lodash-es'; import { isFinite, endsWith, replace, parseInt, toNumber } from 'lodash-es';
import './LayoutSeparate.less'; import './SmartLayoutSeparate.less';
enum Layout { enum Layout {
'LEFT_RIGHT_LAYOUT' = 'leftRight', 'LEFT_RIGHT_LAYOUT' = 'leftRight',
'TOP_BOTTOM_LAYOUT' = 'topBottom', 'TOP_BOTTOM_LAYOUT' = 'topBottom',
} }
const sizeType = {
type: [Number, String] as PropType<number | string>,
validator(value: string | number) {
if (!isFinite(value)) {
// @ts-ignore
return endsWith(value, '%') || endsWith(value, 'px');
}
return true;
},
};
/** /**
* layout * layout
* @author shizhongming * @author shizhongming
*/ */
export default defineComponent({ export default defineComponent({
name: 'LayoutSeparate', name: 'SmartLayoutSeparate',
props: { props: {
//布局,默认左右布局 //布局,默认左右布局
layout: { layout: {
@ -33,17 +44,8 @@ export default defineComponent({
default: false, default: false,
}, },
// 尺寸,如果是number类型,按照百分比分隔 // 尺寸,如果是number类型,按照百分比分隔
firstSize: { firstSize: sizeType,
type: [Number, String] as PropType<number | string>, secondSize: sizeType,
default: 50,
validator(value: string | number) {
if (!isFinite(value)) {
// @ts-ignore
return endsWith(value, '%') || endsWith(value, 'px');
}
return true;
},
},
showLine: { showLine: {
type: Boolean as PropType<boolean>, type: Boolean as PropType<boolean>,
default: true, default: true,
@ -66,7 +68,15 @@ export default defineComponent({
}, },
}, },
setup(props, { slots }) { setup(props, { slots }) {
const { layout, draggable, firstSize, showLine } = toRefs(props); const { layout, draggable, firstSize, secondSize, showLine } = toRefs(props);
if (unref(firstSize) && unref(secondSize)) {
throw new Error('firstSize和secondSize不能同时设置');
}
if (!unref(firstSize) && !unref(secondSize)) {
firstSize.value = 50;
}
// 是否是设置了第一尺寸
const computedIsFirstSize = computed(() => unref(firstSize) !== undefined);
// 是否是左右布局 // 是否是左右布局
const isLeftRight = computed(() => layout.value === Layout.LEFT_RIGHT_LAYOUT); const isLeftRight = computed(() => layout.value === Layout.LEFT_RIGHT_LAYOUT);
// 拖拽是否初始化 // 拖拽是否初始化
@ -109,28 +119,46 @@ export default defineComponent({
const { xLength, yLength } = dragVue; const { xLength, yLength } = dragVue;
const firstStyle: StyleValue = {}; const firstStyle: StyleValue = {};
const firstSizeValue = firstSize.value; const firstSizeValue = firstSize.value;
const secondSizeValue = unref(secondSize);
const sizeValue = firstSizeValue || secondSizeValue;
const isFirstSize = unref(computedIsFirstSize);
let firstValue = ''; let firstValue = '';
let secondValue = ''; let secondValue = '';
const addValue = isLeftRight.value ? xLength.value : yLength.value; const addValue = isLeftRight.value ? xLength.value : yLength.value;
if (isFinite(firstSizeValue) || isFinite(toNumber(firstSizeValue))) { if (isFinite(sizeValue) || isFinite(toNumber(sizeValue))) {
// 按照百分比处理 // 按照百分比处理
firstValue = toNumber(firstSizeValue) + addValue + 'px'; if (isFirstSize) {
secondValue = `calc(100% - ${firstValue})`; firstValue = toNumber(sizeValue) + addValue + 'px';
secondValue = `calc(100% - ${firstValue})`;
} else {
secondValue = toNumber(sizeValue) - addValue + 'px';
firstValue = `calc(100% - ${secondValue})`;
}
} else { } else {
// @ts-ignore // @ts-ignore
if (endsWith(firstSizeValue, '%')) { if (endsWith(sizeValue, '%')) {
// @ts-ignore // @ts-ignore
const firstSize = parseInt(replace(firstSizeValue, '%')); const size = parseInt(replace(sizeValue, '%'));
firstValue = `calc(${firstSize}% ${addValue > 0 ? '+' : '-'} ${Math.abs(addValue)}px)`; if (isFirstSize) {
secondValue = `calc(${100 - firstSize}% ${addValue < 0 ? '+' : '-'} ${Math.abs( firstValue = `calc(${size}% ${addValue > 0 ? '+' : '-'} ${Math.abs(addValue)}px)`;
addValue, secondValue = `calc(${100 - size}% ${addValue < 0 ? '+' : '-'} ${Math.abs(
)}px)`; addValue,
)}px)`;
} else {
secondValue = `calc(${size}% ${addValue < 0 ? '+' : '-'} ${Math.abs(addValue)}px)`;
firstValue = `calc(${100 - size}% ${addValue > 0 ? '+' : '-'} ${Math.abs(addValue)}px)`;
}
// @ts-ignore // @ts-ignore
} else if (endsWith(firstSizeValue, 'px')) { } else if (endsWith(sizeValue, 'px')) {
// @ts-ignore // @ts-ignore
const firstSize = parseInt(replace(firstSizeValue, 'px')); const size = parseInt(replace(sizeValue, 'px'));
firstValue = firstSize + addValue + 'px'; if (isFirstSize) {
secondValue = `calc(100% - ${firstValue})`; firstValue = size + addValue + 'px';
secondValue = `calc(100% - ${firstValue})`;
} else {
secondValue = size - addValue + 'px';
firstValue = `calc(100% - ${secondValue})`;
}
} }
} }
const secondStyle: any = {}; const secondStyle: any = {};

6
src/modules/smart-code/views/codeList/CodeListView.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="full-height page-container"> <div class="full-height page-container">
<LayoutSeparate first-size="240px" :show-line="false" class="full-height"> <SmartLayoutSeparate first-size="240px" :show-line="false" class="full-height">
<template #first> <template #first>
<div class="full-height system-container"> <div class="full-height system-container">
<SystemSimpleList <SystemSimpleList
@ -17,7 +17,7 @@
</template> </template>
</SmartTable> </SmartTable>
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
<CodeCreateModal @register="registerCodeCreateModal" /> <CodeCreateModal @register="registerCodeCreateModal" />
</div> </div>
</template> </template>
@ -35,7 +35,7 @@
import { SmartVxeTableAction, SmartTable, useSmartTable } from '@/components/SmartTable'; import { SmartVxeTableAction, SmartTable, useSmartTable } from '@/components/SmartTable';
import CodeCreateModal from './components/CodeCreateModal.vue'; import CodeCreateModal from './components/CodeCreateModal.vue';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue'; import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue';
import { errorMessage } from '@/utils/message/SystemNotice'; import { errorMessage } from '@/utils/message/SystemNotice';

6
src/modules/smart-code/views/codeList/components/TemplateSelectTable.vue

@ -1,5 +1,5 @@
<template> <template>
<LayoutSeparate first-size="200px" :show-line="false" class="full-height"> <SmartLayoutSeparate first-size="200px" :show-line="false" class="full-height">
<template #first> <template #first>
<TemplateGroup class="full-height" @change="handleCurrentChange" :editable="false" /> <TemplateGroup class="full-height" @change="handleCurrentChange" :editable="false" />
</template> </template>
@ -11,7 +11,7 @@
@checkbox-all="handleCheckboxAll" @checkbox-all="handleCheckboxAll"
/> />
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -19,7 +19,7 @@
import { ApiServiceEnum, defHttp } from '@/utils/http/axios'; import { ApiServiceEnum, defHttp } from '@/utils/http/axios';
import { SmartTable, useSmartTable } from '@/components/SmartTable'; import { SmartTable, useSmartTable } from '@/components/SmartTable';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import { TemplateType as templateTypeConstants } from '@/modules/smart-code/constants/DatabaseConstants'; import { TemplateType as templateTypeConstants } from '@/modules/smart-code/constants/DatabaseConstants';
import TemplateGroup from '@/modules/smart-code/components/template/TemplateGroup.vue'; import TemplateGroup from '@/modules/smart-code/components/template/TemplateGroup.vue';
import { watch } from 'vue'; import { watch } from 'vue';

6
src/modules/smart-code/views/database/DatabaseListView.vue

@ -4,7 +4,7 @@
--> -->
<template> <template>
<div class="full-height page-container"> <div class="full-height page-container">
<LayoutSeparate first-size="240px" :show-line="false" class="full-height layout-container"> <SmartLayoutSeparate first-size="240px" :show-line="false" class="full-height layout-container">
<template #first> <template #first>
<div class="full-height system-container"> <div class="full-height system-container">
<SystemSimpleList <SystemSimpleList
@ -24,7 +24,7 @@
</template> </template>
</SmartTable> </SmartTable>
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
<TemplateSelectedModal template-type="template_db_dict" @register="registerModal" /> <TemplateSelectedModal template-type="template_db_dict" @register="registerModal" />
</div> </div>
</template> </template>
@ -41,7 +41,7 @@
import TemplateSelectedModal from './components/TemplateSelectedModal.vue'; import TemplateSelectedModal from './components/TemplateSelectedModal.vue';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue'; import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue';
import { useSizeSetting } from '@/hooks/setting/UseSizeSetting'; import { useSizeSetting } from '@/hooks/setting/UseSizeSetting';

6
src/modules/smart-code/views/template/CodeTemplateList.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="full-height page-container" id="codeTemplateContainer"> <div class="full-height page-container" id="codeTemplateContainer">
<LayoutSeparate :show-line="false" first-size="240px" class="full-height"> <SmartLayoutSeparate :show-line="false" first-size="240px" class="full-height">
<template #first> <template #first>
<div class="full-height" style="margin-right: 5px; background: white"> <div class="full-height" style="margin-right: 5px; background: white">
<TemplateGroup @change="handleGroupChange" /> <TemplateGroup @change="handleGroupChange" />
@ -18,7 +18,7 @@
</template> </template>
</SmartTable> </SmartTable>
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
</div> </div>
</template> </template>
@ -30,7 +30,7 @@
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { SmartTable, SmartVxeTableAction, useSmartTable } from '@/components/SmartTable'; import { SmartTable, SmartVxeTableAction, useSmartTable } from '@/components/SmartTable';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import TemplateGroup from '../../components/template/TemplateGroup.vue'; import TemplateGroup from '../../components/template/TemplateGroup.vue';
import { CodeEditor } from '@/components/CodeEditor'; import { CodeEditor } from '@/components/CodeEditor';

6
src/modules/smart-system/views/authSecret/SmartAuthSecretKeyListView.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="full-height page-container"> <div class="full-height page-container">
<LayoutSeparate first-size="240px" :show-line="false" class="full-height"> <SmartLayoutSeparate first-size="240px" :show-line="false" class="full-height">
<template #first> <template #first>
<div class="full-height system-container"> <div class="full-height system-container">
<SystemSimpleList <SystemSimpleList
@ -37,7 +37,7 @@
</template> </template>
</SmartTable> </SmartTable>
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
</div> </div>
</template> </template>
@ -52,7 +52,7 @@
SmartVxeTableAction, SmartVxeTableAction,
useSmartTable, useSmartTable,
} from '@/components/SmartTable'; } from '@/components/SmartTable';
import LayoutSeparate from '@/components/LayoutSeparate/src/LayoutSeparate'; import SmartLayoutSeparate from '@/components/SmartLayoutSeparate/src/SmartLayoutSeparate';
import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue'; import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue';
import { hasPermission } from '@/utils/auth'; import { hasPermission } from '@/utils/auth';

8
src/modules/smart-system/views/dataDict/DataDictListView.vue

@ -1,20 +1,20 @@
<template> <template>
<div class="full-height page-container"> <div class="full-height page-container">
<LayoutSeparate :show-line="false" first-size="60%" class="full-height"> <SmartLayoutSeparate :show-line="false" first-size="60%" class="full-height">
<template #first> <template #first>
<DataDictGroup @code-change="handleCodeChange" /> <DataDictGroup @code-change="handleCodeChange" />
</template> </template>
<template #second> <template #second>
<DataDictItem :dict-id="dictId" /> <DataDictItem :dict-id="dictId" />
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref } from 'vue'; import { defineComponent, ref } from 'vue';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import DataDictGroup from './DataDictGroup.vue'; import DataDictGroup from './DataDictGroup.vue';
import DataDictItem from './DataDictItem.vue'; import DataDictItem from './DataDictItem.vue';
@ -25,7 +25,7 @@
export default defineComponent({ export default defineComponent({
name: 'DataDictListView', name: 'DataDictListView',
components: { components: {
LayoutSeparate, SmartLayoutSeparate,
DataDictGroup, DataDictGroup,
DataDictItem, DataDictItem,
}, },

6
src/modules/smart-system/views/license/LicenseListView.vue

@ -3,7 +3,7 @@ license管理页面
--> -->
<template> <template>
<div class="full-height page-container"> <div class="full-height page-container">
<LayoutSeparate first-size="240px" :show-line="false" class="full-height"> <SmartLayoutSeparate first-size="240px" :show-line="false" class="full-height">
<template #first> <template #first>
<div class="full-height system-container"> <div class="full-height system-container">
<SystemSimpleList <SystemSimpleList
@ -33,7 +33,7 @@ license管理页面
</template> </template>
</SmartTable> </SmartTable>
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
</div> </div>
</template> </template>
@ -41,7 +41,7 @@ license管理页面
import type { ActionItem } from '@/components/SmartTable'; import type { ActionItem } from '@/components/SmartTable';
import { computed, ref, unref } from 'vue'; import { computed, ref, unref } from 'vue';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue'; import SystemSimpleList from '@/modules/smart-system/components/system/SystemSimpleList.vue';
import { useSmartTable, SmartTable, SmartVxeTableAction } from '@/components/SmartTable'; import { useSmartTable, SmartTable, SmartVxeTableAction } from '@/components/SmartTable';
import { useI18n } from '@/hooks/web/useI18n'; import { useI18n } from '@/hooks/web/useI18n';

6
src/modules/smart-system/views/user/UserListView.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="full-height page-container"> <div class="full-height page-container">
<LayoutSeparate :show-line="false" first-size="280px" class="full-height"> <SmartLayoutSeparate :show-line="false" first-size="280px" class="full-height">
<template #first> <template #first>
<div class="full-height dept-container"> <div class="full-height dept-container">
<SysDeptTree async show-search @select="handleDeptSelected" /> <SysDeptTree async show-search @select="handleDeptSelected" />
@ -41,7 +41,7 @@
</template> </template>
</SmartTable> </SmartTable>
</template> </template>
</LayoutSeparate> </SmartLayoutSeparate>
<UserAccountUpdateModal @register="registerAccountModal" /> <UserAccountUpdateModal @register="registerAccountModal" />
<UserSetRole @register="registerSetRoleModal" /> <UserSetRole @register="registerSetRoleModal" />
</div> </div>
@ -56,7 +56,7 @@
import { hasPermission } from '@/utils/auth'; import { hasPermission } from '@/utils/auth';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import { LayoutSeparate } from '@/components/LayoutSeparate'; import { SmartLayoutSeparate } from '@/components/SmartLayoutSeparate';
import SysDeptTree from '@/modules/smart-system/components/SysDept/SysDeptTree.vue'; import SysDeptTree from '@/modules/smart-system/components/SysDept/SysDeptTree.vue';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';

Loading…
Cancel
Save