import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import * as React from 'react';
import { createForm, createRow, createColumn, createElement } from "../../../utils";
import _preview from "../emptyBlock/preview.png";
import { handleElementSetting } from "../util";
var defaultData = [{
  type: 'input',
  data: {
    formSettings: {
      name: 'orderTitle',
      label: '工单标题',
      defaultValue: ''
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'Sponsor',
      label: '工单发起人',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "Lucy",
        value: "lucy"
      }, {
        label: "Candy",
        value: "candy"
      }]
    }
  }
}, {
  type: 'input',
  data: {
    formSettings: {
      name: 'Tel',
      label: '联系方式',
      defaultValue: ''
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'ModifiedBy',
      label: '工单修改人',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "Lucy",
        value: "lucy"
      }, {
        label: "Candy",
        value: "candy"
      }]
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'Archivist',
      label: '工单归档人',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "Lucy",
        value: "lucy"
      }, {
        label: "Candy",
        value: "candy"
      }]
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'Company',
      label: '所属公司',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "iwhalecloud",
        value: "iwahlecloud"
      }, {
        label: "ztesoft",
        value: "ztesoft"
      }]
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'Department',
      label: '所属部门',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "研发",
        value: "development"
      }, {
        label: "销售",
        value: "sale"
      }]
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'Segment',
      label: '工单环节',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "开发",
        value: "develop"
      }, {
        label: "测试",
        value: "test"
      }]
    }
  }
}, {
  type: 'timePicker',
  data: {
    formSettings: {
      name: 'CompletionTime',
      label: '要求完成时间',
      defaultValue: '12:05:05'
    }
  }
}, {
  type: 'checkBoxGroup',
  data: {
    formSettings: {
      name: 'IsChange',
      label: '资源是否变更',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "是",
        value: "Y"
      }, {
        label: "否",
        value: "N"
      }]
    }
  }
}, {
  type: 'textArea',
  data: {
    formSettings: {
      name: 'AccessInformation',
      label: '资源入网信息',
      defaultValue: ''
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'DifficultyLevel',
      label: '等级难度',
      defaultValue: ''
    },
    formItemSettings: {
      options: [{
        label: "高",
        value: "High"
      }, {
        label: "低",
        value: "Low"
      }]
    }
  }
}, {
  type: 'input',
  data: {
    formSettings: {
      name: 'Longitude',
      label: '任务位置经度',
      defaultValue: ''
    }
  }
}, {
  type: 'input',
  data: {
    formSettings: {
      name: 'Latitude',
      label: '任务位置纬度',
      defaultValue: ''
    }
  }
}, {
  value: '',
  type: 'inputNumber',
  data: {
    formSettings: {
      name: 'Points',
      label: '积分',
      defaultValue: ''
    }
  }
}, {
  type: 'select',
  data: {
    formSettings: {
      name: 'Skill',
      label: '技能要求',
      defaultValue: undefined
    },
    formItemSettings: {
      mode: 'multiple',
      options: [{
        label: "高级",
        value: "High"
      }, {
        label: "中级",
        value: "Medium"
      }]
    }
  }
}, {
  type: 'upload',
  data: {
    formSettings: {
      name: 'uploadFile',
      label: '附件',
      defaultValue: ''
    }
  }
}, {
  type: 'buttons',
  group: [{
    type: 'button',
    data: {
      formItemSettings: {
        type: 'primary',
        htmlType: 'submit',
        text: '保存'
      },
      settings: {}
    }
  }, {
    type: 'button',
    data: {
      formItemSettings: {
        htmlType: 'button',
        type: null,
        text: '取消'
      }
    }
  }]
}];

var createTpl = function createTpl(datas, formContainer) {
  datas.forEach(function (item) {
    var type = item.type,
        _item$data = item.data,
        data = _item$data === void 0 ? {} : _item$data;
    var element;

    if (type !== 'buttons') {
      element = createElement(type, {});
      handleElementSetting(element, data);
      formContainer.elements[0].elements[0].elements.push(element);
    } else {
      var _item$group = item.group,
          group = _item$group === void 0 ? [] : _item$group;
      var columnContainer = createColumn({
        data: {
          direction: 'horizontal'
        },
        elements: []
      });
      group.forEach(function (btn) {
        element = createElement(btn.type, {});
        handleElementSetting(element, btn.data);
        columnContainer.elements.push(element);
      });
      formContainer.elements[0].elements[0].elements.push(columnContainer);
    }
  });
  return formContainer;
};

export default {
  name: 'pb-editor-block-form-only-column',
  type: 'pb-editor-block',
  category: 'general',
  title: 'Form block',
  create: function create() {
    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var form = createForm(_objectSpread(_objectSpread({}, options), {}, {
      elements: [createRow({
        elements: [createColumn({
          elements: []
        })]
      })]
    }));
    form = createTpl(defaultData, form);
    return form;
  },
  image: {
    meta: {
      width: 500,
      height: 73,
      aspectRatio: 500 / 73
    }
  },
  preview: function preview() {
    return /*#__PURE__*/React.createElement("img", {
      src: _preview,
      alt: 'Form block'
    });
  }
};
//# sourceMappingURL=index.js.map