|
|
@@ -2,32 +2,50 @@ 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
|
|
|
*/
|
|
|
- getFormItems: function(form) {
|
|
|
+ setItems: function(form) {
|
|
|
var me = this,
|
|
|
xtype = form.xtype,
|
|
|
- reg = /(.*){xtype}(.*)/g,
|
|
|
- url = me.baseUrl.replace(reg, '$1' + xtype);
|
|
|
+ url = me.baseUrl.replace(me.urlRe, '$1' + xtype);
|
|
|
|
|
|
- this.BaseUtil.request({url})
|
|
|
+ this.BaseUtil.request({url, })
|
|
|
.then(function(response) {
|
|
|
var res = Ext.decode(response.responseText);
|
|
|
if(res.success) {
|
|
|
- var config = res.data;
|
|
|
- form.add(config.items);
|
|
|
+
|
|
|
+ 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.log(response);
|
|
|
+ console.error(response);
|
|
|
});
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ loadData: function(form) {
|
|
|
+
|
|
|
}
|
|
|
});
|