List.js 6.9 KB

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