List.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * 学校通知
  3. */
  4. Ext.define('school.view.interaction.notice.List', {
  5. extend: 'school.view.core.base.BasePanel',
  6. xtype: 'interaction-notice-list',
  7. dataUrl: 'http://10.1.80.180:9520/api/school/notice/list',
  8. // dataUrl: '/api/school/notice/list',
  9. _title: '学校通知',
  10. initComponent: function() {
  11. var me = this;
  12. Ext.apply(this, {
  13. searchField: [{
  14. xtype: 'textfield',
  15. name: 'keyword',
  16. fieldLabel:'关键字',
  17. getCondition: function (value) {
  18. return ' (notify_title like\'%' + value + '%\' or notify_details like \'%' + value + '%\') ';
  19. }
  20. }, {
  21. xtype: 'textfield',
  22. name: 'creator',
  23. fieldLabel: '发布人'
  24. }, {
  25. xtype: 'combobox',
  26. name: 'notify_status',
  27. fieldLabel: '发布状态',
  28. displayField: 'name',
  29. valueField: 'value',
  30. editable: true,
  31. store: Ext.create('Ext.data.ArrayStore', {
  32. fields: ['name', 'value'],
  33. data: [['已发布', 1], ['未发布', 2]]
  34. }),
  35. minChars: 0,
  36. queryMode: 'local'
  37. // }, {
  38. // xtype: 'condatefield',
  39. // name: 'publish_date',
  40. // fieldLabel: '发布时间',
  41. // columnWidth: 0.5
  42. }],
  43. gridConfig: {
  44. addTitle: '学校通知',
  45. addXtype: 'interaction-notice-schoolnotice',
  46. idField: 'notify_id',
  47. codeField: 'notify_title',
  48. detailField: 'notify_title',
  49. dataUrl: me.dataUrl,
  50. caller: null,
  51. rootProperty: 'data.list',
  52. totalProperty: 'data.total',
  53. actionColumn: [],
  54. selModel: {
  55. checkOnly:true,
  56. type:'checkboxmodel',
  57. mode : "MULTI" ,
  58. ignoreRightMouseSelection : false
  59. },
  60. hiddenTools: false,
  61. toolBtns: [{
  62. xtype: 'button',
  63. text: '新增',
  64. handler: function() {
  65. school.util.BaseUtil.openTab('interaction-notice-schoolnotice', '新增学校通知', 'interaction-notice-schoolnotice-add');
  66. }
  67. }, {
  68. xtype: 'button',
  69. text: '删除',
  70. handler: function() {
  71. let grid = this.up('grid'),
  72. selectedRecords = grid.getSelection();
  73. let data;
  74. data = selectedRecords.map(function(r) {
  75. return {
  76. id: r.get('notify_id')
  77. };
  78. });
  79. if(data.length == 0) {
  80. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  81. return;
  82. }
  83. grid.setLoading(true);
  84. school.util.BaseUtil.request({
  85. // url: 'http://10.1.80.47:9560/teacher/batchDelete',
  86. url: '/api/school/notice/batchDelete',
  87. method: 'POST',
  88. params: JSON.stringify({
  89. baseDTOs: data
  90. })
  91. }).then(function(res) {
  92. grid.setLoading(false);
  93. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  94. grid.store.loadPage(grid.store.currentPage);
  95. }).catch(function(e) {
  96. grid.setLoading(false);
  97. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  98. });
  99. }
  100. }],
  101. columns : [{
  102. text: 'id',
  103. dataIndex: 'notify_id',
  104. hidden: true
  105. }, {
  106. text: '标题',
  107. dataIndex: 'notify_title',
  108. width: 120,
  109. // tdCls: 'x-detail-column',
  110. // listeners: {
  111. // click: function(view, td, row, col, e, record, tr, eOpts, event) {
  112. // let gridConfig = me.gridConfig;
  113. // school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('notify_title') + ')', gridConfig.addXtype + record.get(gridConfig.idField), {
  114. // initId: record.get(gridConfig.idField)
  115. // });
  116. // }
  117. // }
  118. }, {
  119. text: '内容',
  120. dataIndex: 'notify_details',
  121. width: 300
  122. }, {
  123. text: '发布人',
  124. dataIndex: 'creator',
  125. width: 150
  126. }, {
  127. text: '发布状态',
  128. dataIndex: 'notify_status',
  129. width: 120,
  130. renderer: function(v) {
  131. return !!v ? (v == 2 ? '未发布' : '已发布') : '未发布'
  132. }
  133. }, {
  134. xtype: 'datecolumn',
  135. formate: 'Y-m-d H:i:s',
  136. text: '发布时间',
  137. dataIndex: 'publish_date',
  138. width: 120
  139. }]
  140. },
  141. });
  142. this.callParent(arguments);
  143. }
  144. });