Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

删除二次弹窗在接口报code500时,应该取消或者删除之后就不展示二次弹窗了 #936

Closed
Apricity-yu opened this issue Dec 18, 2023 · 3 comments

Comments

@Apricity-yu
Copy link

版本号:

3.6.0

问题描述:

当删除的时候调用删除接口,但是当接口报code500时,不能关闭删除的弹窗提示,但是取消和不报错的接口都可正常显示,请问删除失败的时候接口的回调函数是什么,怎么可以实现接口失败也关闭提示弹框

截图&代码:

1702883350605

友情提示(为了提高issue处理效率):

  • 未按格式要求发帖,会被直接删掉;
  • 请自己初判问题描述是否清楚,是否方便我们调查处理;
  • 描述过于简单或模糊,导致无法处理的,会被直接删掉;
@zhangdaiscott
Copy link
Member

zy

@liaozhiyang
Copy link

liaozhiyang commented Dec 27, 2023

已经修复,下一版本发布。
你本地可按如下图修复
在 src/components/Button/src/PopConfirmButton.vue
image

const getBindValues = computed(() => {
        // update-begin--author:liaozhiyang---date:20231228---for:【issues/936】表格操作栏删除当接口失败时,气泡确认框不会消失
        const result: any = Object.assign(
          {
            okText: t('common.okText'),
            cancelText: t('common.cancelText'),
          },
          { ...props, ...unref(attrs) }
        );
        if (result.onConfirm) {
          const confirm = result.confirm;
          result.onConfirm = () => {
            return new Promise<void>((resolve) => {
              confirm()
                ?.finally(() => {
                  resolve();
                })
                .catch((err) => {
                  console.log(err);
                });
            });
          };
        }
        return result;
        // update-end--author:liaozhiyang---date:20231228---for:【issues/936】表格操作栏删除当接口失败时,气泡确认框不会消失
      });

@liaozhiyang
Copy link

之前那个改法有副作用。
src/components/Button/src/PopConfirmButton.vue 需要回滚
image

const getBindValues = computed(() => {
        return Object.assign(
          {
            okText: t('common.okText'),
            cancelText: t('common.cancelText'),
          },
          { ...props, ...unref(attrs) }
        );
      });

正确改法:

src/components/Table/src/components/TableAction.vue
image

const handelConfirm = (fn) => {
        if (typeof fn !== 'function') return fn;
        const anyc = () => {
          return new Promise<void>((resolve) => {
            const result = fn();
            if (Object.prototype.toString.call(result) === '[object Promise]') {
              result
                .finally(() => {
                  resolve();
                })
                .catch((err) => {
                  console.log(err);
                });
            } else {
              resolve();
            }
          });
        };
        return anyc;
      };


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants