StaffList.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: 'code',
  17. fieldLabel:'教职工号'
  18. }, {
  19. xtype: 'textfield',
  20. name: 'name',
  21. fieldLabel: '姓名'
  22. }, {
  23. xtype: 'textfield',
  24. name: 'job',
  25. fieldLabel: '职位'
  26. }],
  27. gridConfig: {
  28. addTitle: '教职工信息',
  29. addXtype: 'basic-staff-staffdetail',
  30. idField: 'teacher_id',
  31. codeField: 'teacher_number',
  32. detailField: 'teacher_number',
  33. dataUrl: me.dataUrl,
  34. rootProperty: 'data.list',
  35. totalProperty: 'data.total',
  36. actionColumn: [],
  37. selModel: {
  38. checkOnly:true,
  39. type:'checkboxmodel',
  40. mode : "MULTI" ,
  41. ignoreRightMouseSelection : false
  42. },
  43. hiddenTools: false,
  44. toolBtns: [{
  45. xtype: 'importbutton',
  46. belong: me,
  47. caller: me.caller,
  48. pathKey: me.pathKey,
  49. onSuccess: function() {
  50. //刷新界面
  51. var g = me.down('grid');
  52. g.store.loadPage(g.store.currentPage);
  53. }
  54. }, {
  55. xtype: 'button',
  56. text: '一键开通'
  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. xtype: 'button',
  92. text: '新增',
  93. handler: function() {
  94. school.util.BaseUtil.openTab('basic-staff-staffdetail', '新增教职工信息', 'basic-staff-staffdetail-add');
  95. }
  96. }],
  97. columns : [{
  98. text: 'ID',
  99. dataIndex: 'teacher_id',
  100. hidden: true
  101. }, {
  102. text: '工号',
  103. dataIndex: 'teacher_number',
  104. width: 150
  105. }, {
  106. text: '绑定手机号',
  107. dataIndex: 'phone',
  108. width: 120
  109. }, {
  110. text: '姓名',
  111. dataIndex: 'teacher_name',
  112. width: 120
  113. }, {
  114. text: '性别',
  115. dataIndex: 'teacher_sex',
  116. renderer: function(v, m, r) {
  117. return v == 1 ? '男' : (v == 0 ? '女' : '未知');
  118. }
  119. }, {
  120. text: '工龄',
  121. dataIndex: 'teacher_working_age'
  122. }, {
  123. text: '是否开通',
  124. dataIndex: 'open'
  125. }, {
  126. text: '状态',
  127. dataIndex: 'teacher_status'
  128. }]
  129. },
  130. });
  131. this.callParent(arguments);
  132. },
  133. /**
  134. * 处理部分字段值
  135. */
  136. getConditionValue: function (field, value) {
  137. var me = this,
  138. xtypes = field.getXTypes().split('/'),
  139. conditionValue;
  140. if (me.isContainsAny(xtypes, ['datefield'])) {
  141. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
  142. } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
  143. var from = value.from,
  144. to = value.to;
  145. conditionValue = from + ',' + to;
  146. } else if (me.isContainsAny(xtypes, ['condatefield'])) {
  147. var from = value.from,
  148. to = value.to;
  149. 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');
  150. } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
  151. conditionValue = value;
  152. } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
  153. conditionValue = value;
  154. } else if (me.isContainsAny(xtypes, ['multicombo'])) {
  155. conditionValue = value.map ? value.map(function (v) {
  156. return v.value;
  157. }).join(',') : '';
  158. } else {
  159. conditionValue = value;
  160. }
  161. return conditionValue;
  162. },
  163. getExtraParams: function(store, op, condition) {
  164. var temp = {};
  165. for(let x = 0; x < condition.length; x++) {
  166. let c = condition[x];
  167. if(c.field == 'keyword') {
  168. temp.keyword = c.value;
  169. }else if(c.field == 'date') {
  170. temp.fromDate = new Date(c.value.split(',')[0]).getTime();
  171. temp.endDate = new Date(c.value.split(',')[1]).getTime();
  172. }else if(c.field == 'quoted') {
  173. temp.quoted = c.value == 'all' ? null : c.value;
  174. }else if(c.field == 'closed') {
  175. // temp.endDate = c.value == 'all' ? null : (
  176. // c.value == '0' ?
  177. // );
  178. }
  179. }
  180. let obj = {
  181. pageNumber: store.exportNumber?store.exportNumber:op._page,
  182. pageSize: store.exportPageSize?store.exportPageSize:store.pageSize
  183. };
  184. for(let k in temp) {
  185. if(!!temp[k]) {
  186. obj[k] = temp[k];
  187. }
  188. }
  189. return obj;
  190. },
  191. });