DataTemplate.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * DataList导出数据模板
  3. *
  4. * @author yingp
  5. */
  6. Ext.define('erp.view.core.window.DataTemplate', {
  7. extend: 'Ext.window.Window',
  8. alias: 'widget.datatemplate',
  9. title: '<font color=#CD6839>选择模板</font>',
  10. iconCls: 'x-button-icon-set',
  11. height: screen.height*0.6,
  12. width: screen.width*0.8,
  13. maximizable : true,
  14. buttonAlign : 'center',
  15. layout : 'anchor',
  16. caller : null,
  17. initComponent: function() {
  18. this.callParent(arguments);
  19. this.show();
  20. this.store = this.getDataTemplateStore(this.caller);
  21. this.add(this.createDataView(this.store));
  22. },
  23. createDataView: function(store){
  24. return Ext.create('Ext.view.View', {
  25. anchor: '100% 70%',
  26. bodyStyle: 'background:#f1f1f1;',
  27. deferInitialRefresh: false,
  28. store : store,
  29. tpl: Ext.create('Ext.XTemplate',
  30. '<tpl for=".">',
  31. '<div class="phone">',
  32. (!Ext.isIE6? '<img width="64" height="64" src="images/phones/{[values.name.replace(/ /g, "-")]}.png" />' :
  33. '<div style="width:74px;height:74px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/phones/{[values.name.replace(/ /g, "-")]}.png\',sizingMethod=\'scale\')"></div>'),
  34. '<strong>{name}</strong>',
  35. '<span>{price:usMoney} ({reviews} Review{[values.reviews == 1 ? "" : "s"]})</span>',
  36. '</div>',
  37. '</tpl>'
  38. ),
  39. id: 'phones',
  40. style: 'background:#f1f1f1;',
  41. itemSelector: 'div.phone',
  42. overItemCls : 'phone-hover',
  43. multiSelect : true,
  44. autoScroll : true
  45. });
  46. },
  47. getDataTemplateStore : function(caller) {
  48. Ext.define('DataTemplate', {
  49. extend: 'Ext.data.Model',
  50. fields: [
  51. {name: 'DT_CALLER', type: 'string'},
  52. {name: 'DT_DESC', type: 'string'},
  53. {name: 'DT_MAN', type: 'string'},
  54. {name: 'DT_DATE', type: 'string'},
  55. {name: 'DT_FIELDS', type: 'string'}
  56. ]
  57. });
  58. return Ext.create('Ext.data.Store', {
  59. model: 'DataTemplate',
  60. proxy: {
  61. type: 'ajax',
  62. url: basePath + 'common/getFieldsDatas.action',
  63. params: {
  64. caller: 'DataTemplate',
  65. fields: 'dt_fields,dt_desc,dt_man,to_char(dt_date,\'yyyy-mm-dd\')',
  66. condition: 'dt_caller=\'' + caller + '\''
  67. },
  68. reader: {
  69. type: 'json',
  70. root: 'data'
  71. }
  72. },
  73. autoLoad: true
  74. });
  75. }
  76. });