Skip to content

Commit

Permalink
fix: 修复第一次自动触发查询不带参数的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Aug 9, 2023
1 parent 7bd5ed3 commit 484277f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/fast-crud/src/components/search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export default defineComponent({

const { doComputed, AsyncComputeValue } = useCompute();

// eslint-disable-next-line vue/no-setup-props-destructure
_.each(props.columns, (item) => {
if (item.value != null && item.value instanceof AsyncComputeValue) {
logger.warn("search.value配置不支持AsyncCompute类型的动态计算");
Expand All @@ -216,18 +217,18 @@ export default defineComponent({
return key;
}

const debounceValidate = _.debounce(async () => {
if (await doValidate()) {
onFormValidated();
}
}, 500);
// const debounceValidate = _.debounce(async () => {
// if (await doValidate()) {
// onFormValidated();
// }
// }, 500);

function cellRender(item: any) {
const key = item.key;

async function _onUpdateModelValue($event: any) {
// await debounceValidate();
onValueChanged($event, item);
await debounceValidate();
}

function _onInput() {
Expand Down Expand Up @@ -416,6 +417,7 @@ export default defineComponent({
show: true,
type: "primary",
disabled: false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
click: (context: SearchEventContext) => {
doSearch();
},
Expand All @@ -425,6 +427,7 @@ export default defineComponent({
reset: {
show: true,
disabled: false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
click: (context: SearchEventContext) => {
doReset();
},
Expand Down Expand Up @@ -501,7 +504,7 @@ export default defineComponent({
doAutoSearch();
};

function onValueChanged(value: any, item: SearchItemProps) {
async function onValueChanged(value: any, item: SearchItemProps) {
const key = item.key;
_.set(formData, key, value);
if (item.valueChange) {
Expand All @@ -511,6 +514,11 @@ export default defineComponent({
const valueChange = item.valueChange instanceof Function ? item.valueChange : item.valueChange.handle;
valueChange({ key, value, componentRef, ...getContextFn() });
}

if (await doValidate()) {
onFormValidated();
}

if (item.autoSearchTrigger == null || item.autoSearchTrigger === true || item.autoSearchTrigger === "change") {
doAutoSearch();
}
Expand Down

0 comments on commit 484277f

Please sign in to comment.