Commit ae7821e29690bea8934ea724bfd0ae4e2cf30c77

Authored by Vben
1 parent a1d956d3

fix(modal): ensure that props are passed correctly,fix #897

CHANGELOG.zh_CN.md
@@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
26 - 修复菜单默认折叠的配置不起作用的问题 26 - 修复菜单默认折叠的配置不起作用的问题
27 - 修复`safari`浏览器报错导致网站打不开 27 - 修复`safari`浏览器报错导致网站打不开
28 - 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题 28 - 修复在 window 上,拉取代码后 eslint 因 endOfLine 而保错问题
  29 +- **Modal** 确保 props 正确被传递
29 30
30 ### 🎫 Chores 31 ### 🎫 Chores
31 32
src/components/Modal/src/BasicModal.vue
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 </template> 18 </template>
19 19
20 <template #footer v-if="!$slots.footer"> 20 <template #footer v-if="!$slots.footer">
21 - <ModalFooter v-bind="getProps" @ok="handleOk" @cancel="handleCancel"> 21 + <ModalFooter v-bind="getBindValue" @ok="handleOk" @cancel="handleCancel">
22 <template #[item]="data" v-for="item in Object.keys($slots)"> 22 <template #[item]="data" v-for="item in Object.keys($slots)">
23 <slot :name="item" v-bind="data"></slot> 23 <slot :name="item" v-bind="data"></slot>
24 </template> 24 </template>
@@ -82,7 +82,7 @@ @@ -82,7 +82,7 @@
82 setup(props, { emit, attrs }) { 82 setup(props, { emit, attrs }) {
83 const visibleRef = ref(false); 83 const visibleRef = ref(false);
84 const propsRef = ref<Partial<ModalProps> | null>(null); 84 const propsRef = ref<Partial<ModalProps> | null>(null);
85 - const modalWrapperRef = ref<ComponentRef>(null); 85 + const modalWrapperRef = ref<any>(null);
86 86
87 // modal Bottom and top height 87 // modal Bottom and top height
88 const extHeightRef = ref(0); 88 const extHeightRef = ref(0);
@@ -133,7 +133,7 @@ @@ -133,7 +133,7 @@
133 }); 133 });
134 134
135 const getBindValue = computed((): Recordable => { 135 const getBindValue = computed((): Recordable => {
136 - const attr = { ...attrs, ...unref(getProps) }; 136 + const attr = { ...attrs, ...unref(getMergeProps), visible: unref(visibleRef) };
137 if (unref(fullScreenRef)) { 137 if (unref(fullScreenRef)) {
138 return omit(attr, 'height'); 138 return omit(attr, 'height');
139 } 139 }
src/views/demo/comp/modal/Modal1.vue
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 @visible-change="handleShow" 8 @visible-change="handleShow"
9 > 9 >
10 <template #insertFooter> 10 <template #insertFooter>
11 - <a-button type="danger" @click="setLines" :disabled="loading">点我更新内容</a-button> 11 + <a-button type="primary" danger @click="setLines" :disabled="loading">点我更新内容</a-button>
12 </template> 12 </template>
13 <template v-if="loading"> 13 <template v-if="loading">
14 <div class="empty-tips"> 加载中,稍等3秒…… </div> 14 <div class="empty-tips"> 加载中,稍等3秒…… </div>
src/views/demo/comp/modal/Modal2.vue
1 <template> 1 <template>
2 <BasicModal 2 <BasicModal
3 - v-bind="$attrs"  
4 @register="register" 3 @register="register"
5 title="Modal Title" 4 title="Modal Title"
6 :helpMessage="['提示1', '提示2']" 5 :helpMessage="['提示1', '提示2']"
  6 + :okButtonProps="{ disabled: true }"
7 > 7 >
8 <a-button type="primary" @click="closeModal" class="mr-2"> 从内部关闭弹窗 </a-button> 8 <a-button type="primary" @click="closeModal" class="mr-2"> 从内部关闭弹窗 </a-button>
9 -  
10 <a-button type="primary" @click="setModalProps"> 从内部修改title </a-button> 9 <a-button type="primary" @click="setModalProps"> 从内部修改title </a-button>
11 </BasicModal> 10 </BasicModal>
12 </template> 11 </template>
src/views/demo/system/account/AccountDetail.vue
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 @back="goBack" 6 @back="goBack"
7 > 7 >
8 <template #extra> 8 <template #extra>
9 - <a-button type="danger"> 禁用账号 </a-button> 9 + <a-button type="primary" danger> 禁用账号 </a-button>
10 <a-button type="primary"> 修改密码 </a-button> 10 <a-button type="primary"> 修改密码 </a-button>
11 </template> 11 </template>
12 <template #footer> 12 <template #footer>