Skip to content

Commit

Permalink
fix: 修复getComponentRef获取错误的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Apr 10, 2023
1 parent 004652b commit 67ee58e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
23 changes: 14 additions & 9 deletions packages/fast-crud/src/components/crud/fs-cell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCompute } from "../../use/use-compute";
import { defineComponent, PropType } from "vue";
import { defineComponent, PropType, ref } from "vue";
import { CellConditionalRender } from "../../d";

/**
Expand Down Expand Up @@ -29,7 +29,7 @@ export default defineComponent({
type: Object as PropType<CellConditionalRender>
}
},
setup(props: any) {
setup(props: any, ctx) {
const { doComputed } = useCompute();
const computedPropsComponent = () => {
return props.item.component;
Expand All @@ -38,6 +38,17 @@ export default defineComponent({
return props.scope;
};
const computedComponent = doComputed(computedPropsComponent, getScope);
const targetRef = ref();

function getTargetRef() {
return targetRef.value.getTargetRef();
}

ctx.expose({
getTargetRef,
targetRef
});

return () => {
let title = props.item.showTitle;
const value = props.scope.value;
Expand Down Expand Up @@ -67,16 +78,10 @@ export default defineComponent({
if (computedComponent.value?.show === false) {
return;
}
return <fs-component-render title={title} ref={"targetRef"} {...computedComponent.value} scope={scope} />;
return <fs-component-render title={title} ref={targetRef} {...computedComponent.value} scope={scope} />;
} else {
return cellContentRender(value);
}
};
},
methods: {
getTargetRef() {
// @ts-ignore
return this.$refs.targetRef?.getTargetRef();
}
}
});
1 change: 0 additions & 1 deletion packages/fast-crud/src/components/crud/fs-row-handle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default defineComponent({
setup(props: any, ctx) {
const { ui } = useUi();
const { merge } = useMerge();
traceUtil.trace("fs-row-handler");
const { t } = useI18n();
const doClick = (item: any) => {
const index = props.scope[ui.tableColumn.index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export default defineComponent({
ctx.expose({
props,
getTargetRefSync,
getTargetRef
getTargetRef,
getTargetRefAsync
});

return () => {
Expand Down
1 change: 1 addition & 0 deletions packages/fast-extends/src/uploader/type/validators.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { compute } from "@fast-crud/fast-crud";
export const createAllUploadSuccessValidator = (getFormComponentRef: (key: string, isAsync: boolean) => any) => {
return async (rule: any, value: any) => {
debugger;
const ref = await getFormComponentRef(rule.fullField, true);
if (ref && ref.hasUploading()) {
throw new Error("还有未上传完成的文件");
Expand Down

0 comments on commit 67ee58e

Please sign in to comment.