|
@@ -38,10 +38,10 @@ Ext.define('saas.util.FormUtil', {
|
|
|
item.bind = {
|
|
item.bind = {
|
|
|
store: '{' + storeName + '}'
|
|
store: '{' + storeName + '}'
|
|
|
};
|
|
};
|
|
|
- var detailGrids = viewModel.get('detailGrids');
|
|
|
|
|
|
|
+ var detailGrids = formModel.get('detailGrids');
|
|
|
detailGrids.push(storeName);
|
|
detailGrids.push(storeName);
|
|
|
- viewModel.set('detailGrids', detailGrids);
|
|
|
|
|
- viewModel.set(storeName, Ext.create('Ext.data.Store', {
|
|
|
|
|
|
|
+ formModel.set('detailGrids', detailGrids);
|
|
|
|
|
+ formModel.set(storeName, Ext.create('Ext.data.Store', {
|
|
|
fields: item.columns ? item.columns.filter(function(c) {
|
|
fields: item.columns ? item.columns.filter(function(c) {
|
|
|
return !!c.dataIndex;
|
|
return !!c.dataIndex;
|
|
|
}).map(function(c) {
|
|
}).map(function(c) {
|
|
@@ -63,6 +63,9 @@ Ext.define('saas.util.FormUtil', {
|
|
|
.then(function(items) {
|
|
.then(function(items) {
|
|
|
form.fireEvent('afterSetItems', form, items);
|
|
form.fireEvent('afterSetItems', form, items);
|
|
|
})
|
|
})
|
|
|
|
|
+ .then(function() {
|
|
|
|
|
+ me.loadData(form);
|
|
|
|
|
+ })
|
|
|
.catch(function(response) {
|
|
.catch(function(response) {
|
|
|
console.error(response);
|
|
console.error(response);
|
|
|
});
|
|
});
|
|
@@ -70,6 +73,23 @@ Ext.define('saas.util.FormUtil', {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
loadData: function(form) {
|
|
loadData: function(form) {
|
|
|
-
|
|
|
|
|
|
|
+ var me = this;
|
|
|
|
|
+
|
|
|
|
|
+ if(form.initId && form.initId!=0) {
|
|
|
|
|
+ var url = form._dataModelUrl + form.initId,async=false;
|
|
|
|
|
+ me.BaseUtil.request({url,async })
|
|
|
|
|
+ .then(function(response) {
|
|
|
|
|
+ var res = Ext.decode(response.responseText);
|
|
|
|
|
+ if(res.success) {
|
|
|
|
|
+ var viewModel = form.getViewModel();
|
|
|
|
|
+ viewModel.setData(res.data.main);
|
|
|
|
|
+ var detailStore = viewModel.get('detailGridField');
|
|
|
|
|
+ detailStore.loadData(res.data.items);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(function(response) {
|
|
|
|
|
+ console.error(response);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|