List.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.StoreMgr.get('store_grade').load();
  13. Ext.StoreMgr.get('store_class').load();
  14. Ext.apply(this, {
  15. searchField: [{
  16. xtype: 'textfield',
  17. name: 'keyword',
  18. fieldLabel: '关键字',
  19. getCondition: function (value) {
  20. return ' (notify_title like\'%' + value + '%\' or notify_details like \'%' + value + '%\') ';
  21. }
  22. }, {
  23. xtype: 'textfield',
  24. name: 'creator',
  25. fieldLabel: '发布人'
  26. }, {
  27. xtype: 'combobox',
  28. name: 'notify_status',
  29. fieldLabel: '发布状态',
  30. displayField: 'name',
  31. valueField: 'value',
  32. editable: false,
  33. clearable: true,
  34. store: Ext.create('Ext.data.ArrayStore', {
  35. fields: ['name', 'value'],
  36. data: [
  37. ['已发布', 1],
  38. ['未发布', 2]
  39. ]
  40. }),
  41. minChars: 0,
  42. queryMode: 'local',
  43. listeners: {
  44. select: function (combo, record, e) {
  45. let condatefield = combo.up('form').down('condatefield')
  46. if (record.data.value == 1) {
  47. condatefield.setHidden(false);
  48. condatefield.ignore = false;
  49. } else {
  50. condatefield.setHidden(true);
  51. condatefield.ignore = true;
  52. }
  53. },
  54. clear: function (combo) {
  55. let condatefield = combo.up('form').down('condatefield')
  56. condatefield.setHidden(true);
  57. condatefield.ignore = true;
  58. }
  59. }
  60. }, {
  61. hidden: true,
  62. ignore: true,
  63. xtype: 'condatefield',
  64. name: 'publish_date',
  65. fieldLabel: '发布时间',
  66. columnWidth: 0.5
  67. }],
  68. gridConfig: {
  69. addTitle: '学校通知',
  70. addXtype: 'interaction-notice-schoolnotice',
  71. idField: 'notify_id',
  72. codeField: 'notify_title',
  73. detailField: 'notify_title',
  74. dataUrl: me.dataUrl,
  75. caller: null,
  76. rootProperty: 'data.list',
  77. totalProperty: 'data.total',
  78. actionColumn: [],
  79. selModel: {
  80. checkOnly: true,
  81. type: 'checkboxmodel',
  82. mode: "MULTI",
  83. ignoreRightMouseSelection: false
  84. },
  85. hiddenTools: false,
  86. toolBtns: [{
  87. xtype: 'button',
  88. text: '新增',
  89. handler: function () {
  90. school.util.BaseUtil.openTab('interaction-notice-schoolnotice', '新增学校通知', 'interaction-notice-schoolnotice-add');
  91. }
  92. }, {
  93. xtype: 'button',
  94. text: '删除',
  95. handler: function () {
  96. let grid = this.up('grid'),
  97. selectedRecords = grid.getSelection();
  98. let data;
  99. data = selectedRecords.map(function (r) {
  100. return {
  101. id: r.get('notify_id')
  102. };
  103. });
  104. if (data.length == 0) {
  105. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  106. return;
  107. }
  108. school.util.BaseUtil.showConfirm('确认删除', '确定要删除这' + data.length + '条记录吗?')
  109. .then(function(yes) {
  110. if(yes == 'yes') {
  111. grid.setLoading(true);
  112. school.util.BaseUtil.request({
  113. // url: 'http://10.1.80.47:9560/teacher/batchDelete',
  114. url: '/api/school/notice/batchDelete',
  115. method: 'POST',
  116. params: JSON.stringify({
  117. baseDTOs: data
  118. })
  119. }).then(function (res) {
  120. grid.setLoading(false);
  121. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  122. grid.store.loadPage(grid.store.currentPage);
  123. }).catch(function (e) {
  124. grid.setLoading(false);
  125. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  126. });
  127. }
  128. });
  129. }
  130. }],
  131. columns: [{
  132. text: 'id',
  133. dataIndex: 'notify_id',
  134. hidden: true
  135. }, {
  136. text: '标题',
  137. dataIndex: 'notify_title',
  138. width: 250
  139. }, {
  140. text: '内容',
  141. dataIndex: 'notify_details',
  142. width: 300,
  143. xtype: 'widgetcolumn',
  144. tdCls: 'content-column',
  145. widget: {
  146. xtype: 'textareatrigger',
  147. winTitle: '内容',
  148. margin: '0',
  149. editable: false
  150. },
  151. }, {
  152. text: '发布人',
  153. dataIndex: 'creator',
  154. width: 150
  155. }, {
  156. text: '发布状态',
  157. dataIndex: 'notify_status',
  158. width: 120,
  159. renderer: function (v) {
  160. return !!v ? (v == 2 ? '未发布' : '已发布') : '未发布'
  161. }
  162. }, {
  163. xtype: 'datecolumn',
  164. formate: 'Y-m-d H:i:s',
  165. text: '发布时间',
  166. dataIndex: 'publish_date',
  167. width: 120
  168. }]
  169. },
  170. });
  171. this.callParent(arguments);
  172. }
  173. });