提交 7156e47c 作者: Vben

fix(table): ensure that the value of the table action is updated correctly close #301 #313

上级 b7ce74ab
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
- 重构项目以解决循环依赖项导致的热更新问题 - 重构项目以解决循环依赖项导致的热更新问题
### 🐛 Bug Fixes
- 确保 `table action` 的值被正确更新
## 2.0.3 (2021-03-07) ## 2.0.3 (2021-03-07)
### ✨ Features ### ✨ Features
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
"vite-plugin-style-import": "^0.8.1", "vite-plugin-style-import": "^0.8.1",
"vite-plugin-svg-icons": "^0.3.3", "vite-plugin-svg-icons": "^0.3.3",
"vite-plugin-theme": "^0.4.8", "vite-plugin-theme": "^0.4.8",
"vite-plugin-windicss": "0.6.11", "vite-plugin-windicss": "0.7.0",
"vue-eslint-parser": "^7.6.0", "vue-eslint-parser": "^7.6.0",
"yargs": "^16.2.0" "yargs": "^16.2.0"
}, },
......
...@@ -82,12 +82,12 @@ export function useDrawer(): UseDrawerReturnType { ...@@ -82,12 +82,12 @@ export function useDrawer(): UseDrawerReturnType {
if (openOnSet) { if (openOnSet) {
dataTransferRef[unref(uidRef)] = null; dataTransferRef[unref(uidRef)] = null;
dataTransferRef[unref(uidRef)] = data; dataTransferRef[unref(uidRef)] = toRaw(data);
return; return;
} }
const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), data); const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), toRaw(data));
if (!equal) { if (!equal) {
dataTransferRef[unref(uidRef)] = data; dataTransferRef[unref(uidRef)] = toRaw(data);
} }
}, },
}; };
......
...@@ -82,12 +82,12 @@ export function useModal(): UseModalReturnType { ...@@ -82,12 +82,12 @@ export function useModal(): UseModalReturnType {
if (openOnSet) { if (openOnSet) {
dataTransferRef[unref(uidRef)] = null; dataTransferRef[unref(uidRef)] = null;
dataTransferRef[unref(uidRef)] = data; dataTransferRef[unref(uidRef)] = toRaw(data);
return; return;
} }
const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), data); const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), toRaw(data));
if (!equal) { if (!equal) {
dataTransferRef[unref(uidRef)] = data; dataTransferRef[unref(uidRef)] = toRaw(data);
} }
}, },
}; };
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import { defineComponent, ref } from 'vue'; import { defineComponent, ref, computed } from 'vue';
import { Dropdown, Menu, Input } from 'ant-design-vue'; import { Dropdown, Menu, Input } from 'ant-design-vue';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
}, },
title: propTypes.string, title: propTypes.string,
toolbar: propTypes.bool, toolbar: propTypes.bool,
checkable: propTypes.bool,
search: propTypes.bool, search: propTypes.bool,
checkAll: propTypes.func, checkAll: propTypes.func,
expandAll: propTypes.func, expandAll: propTypes.func,
...@@ -65,14 +66,32 @@ ...@@ -65,14 +66,32 @@
emits: ['strictly-change', 'search'], emits: ['strictly-change', 'search'],
setup(props, { emit }) { setup(props, { emit }) {
const { t } = useI18n(); const { t } = useI18n();
const toolbarList = ref([
{ label: t('component.tree.selectAll'), value: ToolbarEnum.SELECT_ALL }, const toolbarList = computed(() => {
{ label: t('component.tree.unSelectAll'), value: ToolbarEnum.UN_SELECT_ALL, divider: true }, const { checkable } = props;
const defaultToolbarList = [
{ label: t('component.tree.expandAll'), value: ToolbarEnum.EXPAND_ALL }, { label: t('component.tree.expandAll'), value: ToolbarEnum.EXPAND_ALL },
{ label: t('component.tree.unExpandAll'), value: ToolbarEnum.UN_EXPAND_ALL, divider: true }, {
label: t('component.tree.unExpandAll'),
value: ToolbarEnum.UN_EXPAND_ALL,
divider: checkable,
},
];
return checkable
? [
{ label: t('component.tree.selectAll'), value: ToolbarEnum.SELECT_ALL },
{
label: t('component.tree.unSelectAll'),
value: ToolbarEnum.UN_SELECT_ALL,
divider: checkable,
},
...defaultToolbarList,
{ label: t('component.tree.checkStrictly'), value: ToolbarEnum.CHECK_STRICTLY }, { label: t('component.tree.checkStrictly'), value: ToolbarEnum.CHECK_STRICTLY },
{ label: t('component.tree.checkUnStrictly'), value: ToolbarEnum.CHECK_UN_STRICTLY }, { label: t('component.tree.checkUnStrictly'), value: ToolbarEnum.CHE },
]); ]
: defaultToolbarList;
});
function handleMenuClick(e: MenuInfo) { function handleMenuClick(e: MenuInfo) {
const { key } = e; const { key } = e;
......
...@@ -323,13 +323,14 @@ ...@@ -323,13 +323,14 @@
}); });
} }
return () => { return () => {
const { title, helpMessage, toolbar, search } = props; const { title, helpMessage, toolbar, search, checkable } = props;
const showTitle = title || toolbar || search; const showTitle = title || toolbar || search;
const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' }; const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' };
return ( return (
<div class={[prefixCls, 'h-full bg-white', attrs.class]}> <div class={[prefixCls, 'h-full bg-white', attrs.class]}>
{showTitle && ( {showTitle && (
<TreeHeader <TreeHeader
checkable={checkable}
checkAll={checkAll} checkAll={checkAll}
expandAll={expandAll} expandAll={expandAll}
title={title} title={title}
......
...@@ -22,6 +22,7 @@ export const basicProps = { ...@@ -22,6 +22,7 @@ export const basicProps = {
search: propTypes.bool, search: propTypes.bool,
checkStrictly: propTypes.bool, checkStrictly: propTypes.bool,
clickRowToExpand: propTypes.bool.def(true), clickRowToExpand: propTypes.bool.def(true),
checkable: propTypes.bool.def(false),
replaceFields: { replaceFields: {
type: Object as PropType<ReplaceFields>, type: Object as PropType<ReplaceFields>,
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
reload(); reload();
} }
function handleSelect(deptId: string = '') { function handleSelect(deptId = '') {
reload({ searchInfo: { deptId } }); reload({ searchInfo: { deptId } });
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论