import { Ref , nextTick } from "vue";

/**
 * 表单设计器增强 hook
 * 新增
 * - 文件上传
 * - 单图上传
 * - 多图上传
 * - 字典选择器
 * - 用户选择器
 * - 部门选择器
 * - 富文本
 */
export const useTwinsFormCreateDesigner = async (designer: Ref) => {
   /**
   * 构建表单组件
   */
  const buildFormComponents = () => {
    // 移除自带的上传组件规则，使用 uploadFileRule、uploadImgRule、uploadImgsRule 替代
    designer.value?.removeMenuItem('upload')
    // 移除自带的富文本组件规则，使用 editorRule 替代
    designer.value?.removeMenuItem('fc-editor')
    designer.value?.removeMenuItem('fcRow')
    designer.value?.removeMenuItem('elTreeSelect')
    designer.value?.removeMenuItem('tree')
    designer.value?.removeMenuItem('colorPicker')
    designer.value?.removeMenuItem('group')
    designer.value?.removeMenuItem('subForm')
    designer.value?.removeMenuItem('elButton')
    designer.value?.removeMenuItem('text')
    designer.value?.removeMenuItem('elAlert')
    designer.value?.removeMenuItem('subform')
    designer.value?.removeMenuItem('text')
    designer.value?.removeMenuItem('slider')
    designer.value?.removeMenuItem('rate')
    designer.value?.removeMenuItem('inputNumber')
    designer.value?.removeMenuItem('cascader')
    designer.value?.removeMenuItem('datePicker')
    designer.value?.removeMenuItem('el-transfer')
    designer.value?.removeMenuItem('dataTable')
    designer.value?.removeMenu('layout')
    designer.value?.removeMenu('aide')

  }

  
  onMounted(async () => {
    await nextTick()
    buildFormComponents()
   })
}
