import Vue from "vue";

/**
 * 格式说明：属性名称==对应属性编辑器的组件名称
 */
const COMMON_PROPERTIES = {
  //字段
  name: "name-editor",
  keyNameEnabled: "keyNameEnabled-editor",
  keyName: "keyName-editor",
  label: "label-editor",
  formField: "formField-editor",
  // 'labelAlign': 'labelAlign-editor',
  type: "type-editor",
  buttonTypeFlag: "button-type-editor",
  defaultValue: "defaultValue-editor",
  placeholder: "placeholder-editor",
  startPlaceholder: "startPlaceholder-editor",
  endPlaceholder: "endPlaceholder-editor",
  widgetWidth: "widgetWidth-editor",
  columnWidth: "columnWidth-editor",
  size: "size-editor",
  space: "space-editor",
  showStops: "showStops-editor",
  displayStyle: "displayStyle-editor",
  buttonStyle: "buttonStyle-editor",
  border: "border-editor",
  labelWidth: "labelWidth-editor",
  labelHidden: "labelHidden-editor",
  rows: "rows-editor",
  required: "required-editor",
  // 'requiredHint': 'requiredHint-editor',
  validation: "validation-editor",
  validationHint: "validationHint-editor",
  readonly: "readonly-editor",
  disabled: "disabled-editor",
  hidden: "hidden-editor",
  clearable: "clearable-editor",
  editable: "editable-editor",
  showPassword: "showPassword-editor",
  textContent: "textContent-editor",
  fontSize: "fontSize-editor",
  htmlContent: "htmlContent-editor",
  format: "format-editor",
  valueFormat: "valueFormat-editor",
  dateLimit: "dateLimit-editor",
  utcTransformEnabled: "utcTransformEnabled-editor",
  defaultTime: "defaultTime-editor",
  filterable: "filterable-editor",
  allowCreate: "allowCreate-editor",
  remote: "remote-editor",
  automaticDropdown: "automaticDropdown-editor",
  checkStrictly: "checkStrictly-editor",
  multiple: "multiple-editor",
  multipleLimit: "multipleLimit-editor",
  contentPosition: "contentPosition-editor",
  // 'dsEnabled'       :            'dsEnabled-editor',//启用数据源，个人
  // 'dsName'       :            'dsName-editor',//指定数据源，个人
  optionItems: "optionItems-editor",
  censusItems: "censusItems-editor",
  listItems: "listItems-editor",
  uploadURL: "uploadURL-editor",
  uploadTip: "uploadTip-editor",
  withCredentials: "withCredentials-editor",
  multipleSelect: "multipleSelect-editor",
  limit: "limit-editor",
  fileMaxSize: "fileMaxSize-editor",
  fileTypes: "fileTypes-editor",
  customClass: "customClass-editor",
  styleTitClass: "styleTitClass-editor",
  styleTableClass: "styleTableClass-editor",
  iconClass: "iconClass-editor",
  echartHeight: "echartHeight-editor",
  descriptionsItems: "descriptionsItems-editor",
  isFullscreen: "isFullscreen-editor",
  tabClass: "tabClass-editor",
  censusClass: "censusClass-editor",
  // 'scriptUuid': 'script-editor',
  entityTableCode: "entityTableCode-editor",

  echarPieOption: "echart-pie-editor", //饼图
  echarBarOption: "echart-bar-editor", //柱状图
  echarCategoryOption: "echart-category-editor", //折线图
  vabSearchName: "vabSearchName-editor",
  copyButton: "copyButton-editor",
  tempStorageFlag: "tempStorage-editor",
  formatType: "formatType-editor",
  preWrap: "preWrap-editor",
  customUploadConfig: "customUploadConfig-editor",

  //容器
  showBlankRow: "showBlankRow-editor",
  showRowNumber: "showRowNumber-editor",
  cellWidth: "cellWidth-editor",
  cellHeight: "cellHeight-editor",
  colHeight: "colHeight-editor",
  gutter: "gutter-editor",
  responsive: "responsive-editor",
  span: "span-editor",
  offset: "offset-editor",
  push: "push-editor",
  pull: "pull-editor",
  height: "height-editor",
  detailContainer: "detail-editor",
  detailPaneContainer: "detail-pane-editor",
  vabSearchField: "vabSearchField-editor",
  fullWidth: "table-fullWidth-editor",
  dataTable: "data-table-editor",
  accessUrl: "accessUrl-editor",
  formulaEnabled: "formulaEnabled-editor",
  formula: "formula-editor",
  showText: "showText-editor",
  detailH5Container: "detail-h5-editor",
  h5Card: "h5-card-editor",
  listH5: "list-h5-editor",
  formScriptEnabled: "formScriptEnabled-editor",
  textFlag: "textFlag-editor",
  showRuleFlag: "showRuleFlag-editor",
  widgetShowRuleFlag: "widgetShowRuleFlag-editor",

  dropdownFlag: "dropdownFlag-editor",
  // 'dropdownItemFlag': 'dropdown-item-editor',

  oplogFlag: "oplogFlag-editor",
  ganttConfig: "gantt-editor",

  //弹框
  title: "title-editor",
  width: "width-editor",
  fullscreen: "fullscreen-editor",
  showModal: "showModal-editor",
  showClose: "showClose-editor",
  closeOnClickModal: "closeOnClickModal-editor",
  closeOnPressEscape: "closeOnPressEscape-editor",
  center: "center-editor",
  // direction: "direction-editor",
  readMode: "readMode-editor",
  disabledMode: "disabledMode-editor",
  okButtonLabel: "okButtonLabel-editor",
  okButtonHidden: "okButtonHidden-editor",
  cancelButtonLabel: "cancelButtonLabel-editor",
  cancelButtonHidden: "cancelButtonHidden-editor",

  showCheckBox: "show-checkbox-editor",
  filter: "show-filter-editor",
  defaultExpandAllNode: "show-defaultExpandAllNode-editor",
  expandRetractAllNode: "tree-expandRetractAllNode-editor",
  selectClearAllNode: "tree-selectClearAllNode-editor",
  expandOnClickNode: "show-expandOnClickNode-editor",
  nodeEdit: "tree-nodeEdit-editor",
  draggable: "show-draggable-editor",
  lazy: "tree-lazy-editor",
  treeDataEdit: "treeData-editor",
  treePane: "tree-pane-editor",

  tableExportFlag: "table-export-button-editor",
  selectExportFlag: "select-export-button-editor",
  selectExportItemFlag: "select-export-item-button-editor",
  importEntity: "import-button-editor",
  frontImportFlag: "import2-button-editor",
  printButtonFlag: "print-button-editor",
  printDetailButtonFlag: "print-detail-button-editor",
  statusParam: "field-status-editor",
  // searchDialogEventEnabled: "search-dialog-event-editor"
  clickBindEvent: "clickBindEvent-editor",
  vabUpload: "field-vabUpload-editor",
  vabUpload2Flag: "field-vabUpload2-editor",
  submitFlag: "submitFlag-editor",
  aLinkFlag: "a-link-editor",
  aTextFlag: "a-text-editor",
  tagFormCode: "project-tag-editor",
  autoValueEnabled: "autoValueEnabled-editor",
  // "commonAttributeEnabled": "commonAttributeEnabled-editor"
  colorClass: "colorClass-editor",
  downloadButtonFlag: "downloadButtonFlag-editor",
};

const ADVANCED_PROPERTIES = {
  min: "min-editor",
  max: "max-editor",
  precision: "precision-editor",
  step: "step-editor",
  showbutton: "showbutton-editor",
  controlsPosition: "controlsPosition-editor",
  minLength: "minLength-editor",
  maxLength: "maxLength-editor",
  // 'showWordLimit': 'showWordLimit-editor',
  prefixIcon: "prefixIcon-editor",
  suffixIcon: "suffixIcon-editor",
  switchWidth: "switchWidth-editor",
  activeText: "activeText-editor",
  inactiveText: "inactiveText-editor",
  labelColor: "labelColor-editor",
  activeColor: "activeColor-editor",
  inactiveColor: "inactiveColor-editor",
  lowThreshold: "lowThreshold-editor",
  highThreshold: "highThreshold-editor",
  allowHalf: "allowHalf-editor",
  showText: "showText-editor",
  showScore: "showScore-editor",
  range: "range-editor",
  vertical: "vertical-editor",
  plain: "plain-editor",
  round: "round-editor",
  circle: "circle-editor",
  icon: "icon-editor",
  labelIconClass: "labelIconClass-editor",
  labelIconPosition: "labelIconPosition-editor",
  labelTooltip: "labelTooltip-editor",
  // 'appendButton': 'appendButton-editor',
  // 'appendButtonDisabled': 'appendButtonDisabled-editor',
  // 'buttonIcon': 'buttonIcon-editor',
};

//流程属性
const WF_PROPERTIES = {
  wfFlag: "wfFlag-editor",
};

const EVENT_PROPERTIES = {
  //字段
  onCreatedEnter: "onCreatedEnter-editor",
  onCreated: "onCreated-editor",
  onMounted: "onMounted-editor",
  onClick: "onClick-editor",
  onInput: "onInput-editor",
  onChange: "onChange-editor",
  onFocus: "onFocus-editor",
  onBlur: "onBlur-editor",
  onRemoteQuery: "onRemoteQuery-editor",
  onBeforeUpload: "onBeforeUpload-editor",
  onUploadSuccess: "onUploadSuccess-editor",
  onUploadError: "onUploadError-editor",
  onFileRemove: "onFileRemove-editor",
  onValidate: "onValidate-editor",
  onAppendButtonClick: "onAppendButtonClick-editor",
  onSearchConfirm: "onSearchConfirm-editor",
  onSearchClear: "onSearchClear-editor",
  onAfterConfirmFile: "onAfterConfirmFile-editor",

  //容器
  onSubFormRowAdd: "onSubFormRowAdd-editor",
  onSubFormRowInsert: "onSubFormRowInsert-editor",
  onSubFormRowDelete: "onSubFormRowDelete-editor",
  onSubFormRowChange: "onSubFormRowChange-editor",

  onOkButtonClick: "onOkButtonClick-editor",
  onCancelButtonClick: "onCancelButtonClick-editor",
  onDialogOpened: "onDialogOpened-editor",
  onDialogBeforeClose: "onDialogBeforeClose-editor",

  //vxe-table事件
  onCellDblclick: "onCellDblclick-editor",
  onCheckboxAll: "onCheckboxAll-editor",
  onCheckboxChange: "onCheckboxChange-editor",
  onSearchTable: "onSearchTable-editor",
  onResetTable: "onResetTable-editor",

  //tree事件
  onNodeClick: "onNodeClick-editor",
  onNodeCheck: "onNodeCheck-editor",
  onNodeContextmenu: "onNodeContextmenu-editor",
  onCheckChange: "onCheckChange-editor",
  onLoadNode: "onLoadNode-editor",
  //tree-pane事件
  onTreeLabelClick: "onTreeLabelClick-editor",
};

/**
 * 注册组件常见属性
 * 如属性编辑器的组件名称propEditorName设置为null，则不显示该属性编辑器！！
 * @param uniquePropName 属性名称（保证名称唯一，不跟其他组件属性冲突）
 * @param propEditorName 对应属性编辑器的组件名称
 */
export function registerCommonProperty(uniquePropName, propEditorName) {
  COMMON_PROPERTIES[uniquePropName] = propEditorName;
}

/**
 * 注册组件高级属性
 * 如属性编辑器的组件名称propEditorName设置为null，则不显示该属性编辑器！！
 * @param uniquePropName 属性名称（保证名称唯一，不跟其他组件属性冲突）
 * @param propEditorName 对应属性编辑器的组件名称
 */
export function registerAdvancedProperty(uniquePropName, propEditorName) {
  ADVANCED_PROPERTIES[uniquePropName] = propEditorName;
}

/**
 * 注册组件事件属性
 * 如属性编辑器的组件名称propEditorName设置为null，则不显示该属性编辑器！！
 * @param uniquePropName 属性名称（保证名称唯一，不跟其他组件属性冲突）
 * @param propEditorName 对应属性编辑器的组件名称
 */
export function registerEventProperty(uniquePropName, propEditorName) {
  EVENT_PROPERTIES[uniquePropName] = propEditorName;
}

/**
 * 判断属性是否已注册
 * @param uniquePropName 属性名称（保证名称唯一，不跟其他组件属性冲突）
 */
export function propertyRegistered(uniquePropName) {
  return (
    !!COMMON_PROPERTIES[uniquePropName] ||
    !!ADVANCED_PROPERTIES[uniquePropName] ||
    !!EVENT_PROPERTIES[uniquePropName]
  );
}

/**
 * 注册常见属性对应的属性编辑器
 * @param uniquePropName
 * @param propEditorName
 * @param editorComponent
 */
export function registerCPEditor(
  uniquePropName,
  propEditorName,
  editorComponent
) {
  Vue.component(propEditorName, editorComponent);
  registerCommonProperty(uniquePropName, propEditorName);
}

/**
 * 注册高级属性对应的属性编辑器
 * @param uniquePropName
 * @param propEditorName
 * @param editorComponent
 */
export function registerAPEditor(
  uniquePropName,
  propEditorName,
  editorComponent
) {
  Vue.component(propEditorName, editorComponent);
  registerAdvancedProperty(uniquePropName, propEditorName);
}

/**
 * 注册事件属性对应的属性编辑器
 * @param uniquePropName
 * @param propEditorName
 * @param editorComponent
 */
export function registerEPEditor(
  uniquePropName,
  propEditorName,
  editorComponent
) {
  Vue.component(propEditorName, editorComponent);
  registerEventProperty(uniquePropName, propEditorName);
}

export default {
  COMMON_PROPERTIES,
  ADVANCED_PROPERTIES,
  EVENT_PROPERTIES,
  WF_PROPERTIES,
};
