StaffList.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. school.util.BaseUtil.showConfirm('确认删除', '确定要删除这' + data.length + '条记录吗?')
  74. .then(function(yes) {
  75. if(yes == 'yes') {
  76. grid.setLoading(true);
  77. school.util.BaseUtil.request({
  78. // url: 'http://10.1.80.47:9560/teacher/batchDelete',
  79. url: '/api/school/teacher/batchDelete',
  80. method: 'POST',
  81. params: JSON.stringify({
  82. baseDTOs: data
  83. })
  84. }).then(function (res) {
  85. grid.setLoading(false);
  86. school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
  87. grid.store.loadPage(grid.store.currentPage);
  88. }).catch(function (e) {
  89. grid.setLoading(false);
  90. school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
  91. });
  92. }
  93. });
  94. }
  95. }],
  96. columns: [{
  97. text: 'ID',
  98. dataIndex: 'teacher_id',
  99. hidden: true
  100. }, {
  101. text: '工号',
  102. dataIndex: 'teacher_number',
  103. width: 150
  104. }, {
  105. text: '姓名',
  106. dataIndex: 'teacher_name',
  107. width: 120
  108. }, {
  109. text: '手机号',
  110. dataIndex: 'teacher_phone',
  111. width: 120
  112. }, {
  113. text: '性别',
  114. dataIndex: 'teacher_sex',
  115. renderer: function (v, m, r) {
  116. return v == 1 ? '男' : (v == 0 ? '女' : '未知');
  117. }
  118. }, {
  119. text: '民族',
  120. dataIndex: 'teacher_nation'
  121. }, {
  122. text: '学历',
  123. dataIndex: 'teacher_education'
  124. }, {
  125. text: '专业',
  126. dataIndex: 'teacher_major'
  127. }]
  128. },
  129. });
  130. this.callParent(arguments);
  131. },
  132. /**
  133. * 处理部分字段值
  134. */
  135. getConditionValue: function (field, value) {
  136. var me = this,
  137. xtypes = field.getXTypes().split('/'),
  138. conditionValue;
  139. if (me.isContainsAny(xtypes, ['datefield'])) {
  140. conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
  141. } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
  142. var from = value.from,
  143. to = value.to;
  144. conditionValue = from + ',' + to;
  145. } else if (me.isContainsAny(xtypes, ['condatefield'])) {
  146. var from = value.from,
  147. to = value.to;
  148. 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');
  149. } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
  150. conditionValue = value;
  151. } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
  152. conditionValue = value;
  153. } else if (me.isContainsAny(xtypes, ['multicombo'])) {
  154. conditionValue = value.map ? value.map(function (v) {
  155. return v.value;
  156. }).join(',') : '';
  157. } else {
  158. conditionValue = value;
  159. }
  160. return conditionValue;
  161. },
  162. getExtraParams: function (store, op, condition) {
  163. var temp = {};
  164. for (let x = 0; x < condition.length; x++) {
  165. let c = condition[x];
  166. if (c.field == 'keyword') {
  167. temp.keyword = c.value;
  168. } else if (c.field == 'date') {
  169. temp.fromDate = new Date(c.value.split(',')[0]).getTime();
  170. temp.endDate = new Date(c.value.split(',')[1]).getTime();
  171. } else if (c.field == 'quoted') {
  172. temp.quoted = c.value == 'all' ? null : c.value;
  173. } else if (c.field == 'closed') {
  174. // temp.endDate = c.value == 'all' ? null : (
  175. // c.value == '0' ?
  176. // );
  177. }
  178. }
  179. let obj = {
  180. pageNumber: store.exportNumber ? store.exportNumber : op._page,
  181. pageSize: store.exportPageSize ? store.exportPageSize : store.pageSize
  182. };
  183. for (let k in temp) {
  184. if (!!temp[k]) {
  185. obj[k] = temp[k];
  186. }
  187. }
  188. return obj;
  189. },
  190. });