import DcsDetailsDialog from '@/views/dcs/components/DcsDetailsDialog';
const DcsDetailsDialogPlugin = {};
DcsDetailsDialogPlugin.install = function(Vue, options) {
  // 创建一个 Vue 组件构造器
  const DcsDetailsDialogConstructor = Vue.extend(DcsDetailsDialog);

  Vue.prototype.$dcsDetailsDialog = function(methodOptions) {
    const rootInstance = this;

    // 创建一个新实例
    const instance = new DcsDetailsDialogConstructor({
      propsData: {
        title: methodOptions.title,
        dealId: methodOptions.dealId,
        product: methodOptions.product,
        instrument: methodOptions.instrument,
        onClose: methodOptions.onClose,
      },
      parent: rootInstance,
      $t: rootInstance.$i18n.t,
    });

    // 挂载实例到 DOM
    const container = document.createElement('div');
    document.body.appendChild(container);
    instance.$mount(container);

    // 添加事件处理
    if (methodOptions.onClose) {
      instance.onClose = methodOptions.onClose;
    }

    // 显示弹窗
    instance.show();

    // 返回实例以便后续操作
    return instance;
  };
};

export default DcsDetailsDialogPlugin;
