Skip to content

Commit

Permalink
fix(table): ensure that the value of the table action is updated corr…
Browse files Browse the repository at this point in the history
…ectly close #301 #313
  • Loading branch information
anncwb committed Mar 8, 2021
1 parent b7ce74a commit 7156e47
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 117 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- 重构项目以解决循环依赖项导致的热更新问题

### 🐛 Bug Fixes

- 确保 `table action` 的值被正确更新

## 2.0.3 (2021-03-07)

### ✨ Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"vite-plugin-style-import": "^0.8.1",
"vite-plugin-svg-icons": "^0.3.3",
"vite-plugin-theme": "^0.4.8",
"vite-plugin-windicss": "0.6.11",
"vite-plugin-windicss": "0.7.0",
"vue-eslint-parser": "^7.6.0",
"yargs": "^16.2.0"
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/Drawer/src/useDrawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export function useDrawer(): UseDrawerReturnType {

if (openOnSet) {
dataTransferRef[unref(uidRef)] = null;
dataTransferRef[unref(uidRef)] = data;
dataTransferRef[unref(uidRef)] = toRaw(data);
return;
}
const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), data);
const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), toRaw(data));
if (!equal) {
dataTransferRef[unref(uidRef)] = data;
dataTransferRef[unref(uidRef)] = toRaw(data);
}
},
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/Modal/src/hooks/useModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export function useModal(): UseModalReturnType {

if (openOnSet) {
dataTransferRef[unref(uidRef)] = null;
dataTransferRef[unref(uidRef)] = data;
dataTransferRef[unref(uidRef)] = toRaw(data);
return;
}
const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), data);
const equal = isEqual(toRaw(dataTransferRef[unref(uidRef)]), toRaw(data));
if (!equal) {
dataTransferRef[unref(uidRef)] = data;
dataTransferRef[unref(uidRef)] = toRaw(data);
}
},
};
Expand Down
37 changes: 28 additions & 9 deletions src/components/Tree/src/TreeHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</template>
<script lang="ts">
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 { Icon } from '/@/components/Icon';
Expand Down Expand Up @@ -58,21 +58,40 @@
},
title: propTypes.string,
toolbar: propTypes.bool,
checkable: propTypes.bool,
search: propTypes.bool,
checkAll: propTypes.func,
expandAll: propTypes.func,
},
emits: ['strictly-change', 'search'],
setup(props, { emit }) {
const { t } = useI18n();
const toolbarList = ref([
{ label: t('component.tree.selectAll'), value: ToolbarEnum.SELECT_ALL },
{ label: t('component.tree.unSelectAll'), value: ToolbarEnum.UN_SELECT_ALL, divider: true },
{ 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.checkStrictly'), value: ToolbarEnum.CHECK_STRICTLY },
{ label: t('component.tree.checkUnStrictly'), value: ToolbarEnum.CHECK_UN_STRICTLY },
]);
const toolbarList = computed(() => {
const { checkable } = props;
const defaultToolbarList = [
{ label: t('component.tree.expandAll'), value: ToolbarEnum.EXPAND_ALL },
{
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.checkUnStrictly'), value: ToolbarEnum.CHE },
]
: defaultToolbarList;
});
function handleMenuClick(e: MenuInfo) {
const { key } = e;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Tree/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,14 @@
});
}
return () => {
const { title, helpMessage, toolbar, search } = props;
const { title, helpMessage, toolbar, search, checkable } = props;
const showTitle = title || toolbar || search;
const scrollStyle: CSSProperties = { height: 'calc(100% - 38px)' };
return (
<div class={[prefixCls, 'h-full bg-white', attrs.class]}>
{showTitle && (
<TreeHeader
checkable={checkable}
checkAll={checkAll}
expandAll={expandAll}
title={title}
Expand Down
1 change: 1 addition & 0 deletions src/components/Tree/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const basicProps = {
search: propTypes.bool,
checkStrictly: propTypes.bool,
clickRowToExpand: propTypes.bool.def(true),
checkable: propTypes.bool.def(false),

replaceFields: {
type: Object as PropType<ReplaceFields>,
Expand Down
2 changes: 1 addition & 1 deletion src/views/demo/system/account/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
reload();
}
function handleSelect(deptId: string = '') {
function handleSelect(deptId = '') {
reload({ searchInfo: { deptId } });
}
Expand Down
Loading

0 comments on commit 7156e47

Please sign in to comment.