| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- Ext.define('saas.util.FormUtil', {
- BaseUtil: Ext.create('saas.util.BaseUtil'),
- // 请求页面组件接口模板
- baseUrl: 'http://192.168.0.181:8560/api/ui/co_view/config?name={xtype}',
- // 模板替换正则
- urlRe: /(.*){xtype}(.*)/g,
-
- /**
- * 获得form的字段配置
- * @param form: form组件
- * @param url: url
- */
- setItems: function(form) {
- var me = this,
- xtype = form.xtype,
- url = me.baseUrl.replace(me.urlRe, '$1' + xtype);
-
- this.BaseUtil.request({url, })
- .then(function(response) {
- var res = Ext.decode(response.responseText);
- if(res.success) {
- var config = res.data, items = [];
- if(config) {
- items = config.items,
- bindFields = items.filter(function(item) {
- return !!item.bind;
- }).map(function(item) {
- return item.bind.replace(/[{ | }]/g, '');
- }),
- viewModel = form.getViewModel();
-
- form.bindFields = bindFields;
- form.add(items);
- }
- form.fireEvent('afterSetItems', form, items);
- }
- })
- .catch(function(response) {
- console.error(response);
- });
- },
- loadData: function(form) {
- }
- });
|