FormUtil.js 873 B

123456789101112131415161718192021222324252627282930313233
  1. Ext.define('saas.util.FormUtil', {
  2. BaseUtil: Ext.create('saas.util.BaseUtil'),
  3. /**
  4. * 请求页面组件接口模板
  5. */
  6. baseUrl: 'http://192.168.0.181:8560/api/ui/co_view/config?name={xtype}',
  7. /**
  8. * 获得form的字段配置
  9. * @param form: form组件
  10. * @param url: url
  11. */
  12. getFormItems: function(form) {
  13. var me = this,
  14. xtype = form.xtype,
  15. reg = /(.*){xtype}(.*)/g,
  16. url = me.baseUrl.replace(reg, '$1' + xtype);
  17. this.BaseUtil.request({url})
  18. .then(function(response) {
  19. var res = Ext.decode(response.responseText);
  20. if(res.success) {
  21. var config = res.data;
  22. form.add(config.items);
  23. }
  24. })
  25. .catch(function(response) {
  26. console.log(response);
  27. });
  28. }
  29. });