StaffList.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /**
  2. * 教职工信息
  3. */
  4. Ext.define('school.view.basic.staff.StaffList', {
  5. extend: 'school.view.core.base.BasePanel',
  6. xtype: 'basic-staff-stafflist',
  7. dataUrl: '/api/school/teacher/list',
  8. _title: '教职工信息导入',
  9. caller: 'Teacher',
  10. pathKey: 'teacher',
  11. initComponent: function () {
  12. var me = this;
  13. Ext.apply(this, {
  14. searchField: [{
  15. xtype: 'textfield',
  16. name: 'teacher_number',
  17. fieldLabel: '教职工号'
  18. }, {
  19. xtype: 'textfield',
  20. name: 'teacher_name',
  21. fieldLabel: '姓名'
  22. }],
  23. gridConfig: {
  24. addTitle: '教职工信息',
  25. addXtype: 'basic-staff-staffdetail',
  26. idField: 'teacher_id',
  27. codeField: 'teacher_number',
  28. detailField: 'teacher_number',
  29. dataUrl: me.dataUrl,
  30. rootProperty: 'data.list',
  31. totalProperty: 'data.total',
  32. actionColumn: [],
  33. selModel: {
  34. checkOnly: true,
  35. type: 'checkboxmodel',
  36. mode: "MULTI",
  37. ignoreRightMouseSelection: false
  38. },
  39. hiddenTools: false,
  40. toolBtns: [{
  41. xtype: 'button',
  42. text: '新增',
  43. handler: function () {
  44. school.util.BaseUtil.openTab('basic-staff-staffdetail', '新增教职工信息', 'basic-staff-staffdetail-add');
  45. }
  46. }, {
  47. xtype: 'importbutton',
  48. text: '导入',
  49. belong: me,
  50. caller: me.caller,
  51. pathKey: me.pathKey,
  52. onSuccess: function () {
  53. //刷新界面
  54. var g = me.down('grid');
  55. g.store.loadPage(g.store.currentPage);
  56. }
  57. }, {
  58. xtype: 'button',
  59. text: '删除',
  60. handler: function () {
  61. let grid = this.up('grid'),
  62. selectedRecords = grid.getSelection();
  63. let data;
  64. data = selectedRecords.map(function (r) {
  65. return {
  66. id: r.get('teacher_id')
  67. };
  68. });
  69. if (data.length == 0) {
  70. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  71. return;
  72. }
  73. grid.setLoading(true);
  74. school.util.BaseUtil.request({
  75. // url: 'http://10.1.80.47:9560/teacher/batchDelete',
  76. url: '/api/school/teacher/batchDelete',
  77. method: 'POST',
  78. params: JSON.stringify({
  79. baseDTOs: data
  80. })
  81. }).then(function (res) {
  82. grid.setLoading(false);
  83. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  84. grid.store.loadPage(grid.store.currentPage);
  85. }).catch(function (e) {
  86. grid.setLoading(false);
  87. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  88. });
  89. }
  90. }],
  91. columns: [{
  92. text: 'ID',
  93. dataIndex: 'teacher_id',
  94. hidden: true
  95. }, {
  96. text: '工号',
  97. dataIndex: 'teacher_number',
  98. width: 150
  99. }, {
  100. text: '姓名',
  101. dataIndex: 'teacher_name',
  102. width: 120
  103. }, {
  104. text: '手机号',
  105. dataIndex: 'phone',
  106. width: 120
  107. }, {
  108. text: '性别',
  109. dataIndex: 'teacher_sex',
  110. renderer: function (v, m, r) {
  111. return v == 1 ? '男' : (v == 0 ? '女' : '未知');
  112. }
  113. }, {
  114. text: '民族',
  115. dataIndex: 'teacher_nation'
  116. }, {
  117. text: '学历',
  118. dataIndex: 'teacher_education'
  119. }, {
  120. text: '专业',
  121. dataIndex: 'teacher_major'
  122. }]
  123. },
  124. });
  125. this.callParent(arguments);
  126. },
  127. /**
  128. * 处理部分字段值
  129. */
  130. getConditionValue: function (field, value) {
  131. var me = this,
  132. xtypes = field.getXTypes().split('/'),
  133. conditionValue;
  134. if (me.isContainsAny(xtypes, ['datefield'])) {
  135. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
  136. } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
  137. var from = value.from,
  138. to = value.to;
  139. conditionValue = from + ',' + to;
  140. } else if (me.isContainsAny(xtypes, ['condatefield'])) {
  141. var from = value.from,
  142. to = value.to;
  143. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
  144. } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
  145. conditionValue = value;
  146. } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
  147. conditionValue = value;
  148. } else if (me.isContainsAny(xtypes, ['multicombo'])) {
  149. conditionValue = value.map ? value.map(function (v) {
  150. return v.value;
  151. }).join(',') : '';
  152. } else {
  153. conditionValue = value;
  154. }
  155. return conditionValue;
  156. },
  157. getExtraParams: function (store, op, condition) {
  158. var temp = {};
  159. for (let x = 0; x < condition.length; x++) {
  160. let c = condition[x];
  161. if (c.field == 'keyword') {
  162. temp.keyword = c.value;
  163. } else if (c.field == 'date') {
  164. temp.fromDate = new Date(c.value.split(',')[0]).getTime();
  165. temp.endDate = new Date(c.value.split(',')[1]).getTime();
  166. } else if (c.field == 'quoted') {
  167. temp.quoted = c.value == 'all' ? null : c.value;
  168. } else if (c.field == 'closed') {
  169. // temp.endDate = c.value == 'all' ? null : (
  170. // c.value == '0' ?
  171. // );
  172. }
  173. }
  174. let obj = {
  175. pageNumber: store.exportNumber ? store.exportNumber : op._page,
  176. pageSize: store.exportPageSize ? store.exportPageSize : store.pageSize
  177. };
  178. for (let k in temp) {
  179. if (!!temp[k]) {
  180. obj[k] = temp[k];
  181. }
  182. }
  183. return obj;
  184. },
  185. });