specialPersonnelLYSix.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. define(function (require) {
  2. return function (context) {
  3. var $grid1, $form, $coma;
  4. // 弹框的方式
  5. var widgets = {
  6. // 搜索分类检索
  7. selectTableUnit: {
  8. url: 'app/whepi/home/selectLYbumen.js',
  9. bind: {
  10. unitId: 'unitId',
  11. unit: 'unit',
  12. },
  13. },
  14. };
  15. // 下拉选清空并重新赋值
  16. function reloadValuea(_datas) {
  17. if ($coma) {
  18. $coma.combobox('clear');// 清除当前的选项
  19. $coma.combobox('loadData', _datas);// 重新加载数据
  20. }
  21. }
  22. // 获取联机下拉选二级信息
  23. function getList(id) {
  24. id = id == undefined ? 0 : id
  25. var _datas = [];
  26. _datas.push({
  27. "id": "",
  28. "text": "全部",
  29. "selected": true
  30. });
  31. $.yvan.ajax({
  32. url: api('/home/getDepartmentIdLYepi.json?unitId=' + id),
  33. method: 'GET',
  34. async: true,
  35. success: function (data) {
  36. if (data.data != null && data.data != undefined) {
  37. for (var i = 0; i < data.data.length; i++) {
  38. _datas.push({
  39. "id": data.data[i].departmentId,
  40. "text": data.data[i].departmentName
  41. })
  42. }
  43. reloadValuea(_datas);
  44. }
  45. }
  46. });
  47. return _datas;
  48. }
  49. // 输入搜索文本后点击回车按钮查询列表
  50. function enterQueryGrid1(e) {
  51. if (e.keyCode === 13) {
  52. var tmp = $(this).val();
  53. $form.formSet({queryProperties: tmp});
  54. queryGrid1();
  55. }
  56. }
  57. function enterQueryGrid2(e) {
  58. if (e.keyCode === 13) {
  59. var tmp = $(this).val();
  60. $form.formSet({phone: tmp});
  61. queryGrid1();
  62. }
  63. }
  64. // 检索条件查询
  65. function queryGrid1() {
  66. var queryForm = $form.formGet();
  67. queryForm.tuType = 4;
  68. $grid1.reload({
  69. mtype: 'POST',
  70. url: api('/OutUser/selectAllOutUserLY'),
  71. queryParams: queryForm
  72. }, true);
  73. }
  74. var queryToolbar = {
  75. xtype: 'toolbar',
  76. title: '六类人员详情',
  77. items: [
  78. {
  79. text: '查询', iconCls: 'fa fa-search', onClick: function () {
  80. queryGrid1();
  81. }
  82. }, {
  83. text: '重置', iconCls: 'fa fa-refresh', onClick: function () {
  84. $form.formClear();
  85. queryGrid1();
  86. }
  87. }, {
  88. text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
  89. App.closeMe(this);
  90. }
  91. }
  92. ]
  93. };
  94. var queryForm = {
  95. onRender: function () {
  96. $form = $(this);
  97. },
  98. xtype: 'form',
  99. items: [[
  100. {
  101. xtype: 'textbox',
  102. label: '检索条件',
  103. name: 'queryProperties',
  104. prompt: "联系人姓名/工号",
  105. labelWidth: 'auto',
  106. events: {keydown: enterQueryGrid1}, width: 300
  107. },
  108. {xtype: 'hidden', name: 'unitId'},
  109. {
  110. xtype: 'searchbox',
  111. label: '部门',
  112. labelWidth: 'auto',
  113. name: 'unit',
  114. prompt: "部门",
  115. width: 250,
  116. widget: widgets.selectTableUnit,// 弹出框方法
  117. onChange: function (value) {
  118. if (!isNotNullOrEmpty(value)) {
  119. $form.formSet({
  120. unitId : 0
  121. })
  122. }
  123. getList($form.formGet().unitId);
  124. queryGrid1();
  125. },
  126. },
  127. {
  128. xtype: 'combobox',
  129. label: '二级部门',
  130. name: 'departmentId',
  131. labelWidth: 'auto',
  132. width: 280,
  133. value: '',
  134. data: getList(),
  135. onRender: function () {
  136. $coma = $(this);
  137. },
  138. onValue: function (data) {
  139. },
  140. onChange: function () {
  141. queryGrid1();
  142. }
  143. },
  144. {
  145. xtype: 'textbox',
  146. label: '电话',
  147. name: 'phone',
  148. prompt: "请输入完整的电话号码",
  149. labelWidth: 'auto',
  150. events: {keydown: enterQueryGrid2}, width: 300
  151. },
  152. ]]
  153. };
  154. return {
  155. north: {
  156. height: 88,
  157. /* split: true,
  158. border: false,*///底框是否可变动
  159. items: [
  160. queryToolbar,
  161. queryForm
  162. ]
  163. },
  164. center: {
  165. height: '60%',
  166. split: true,
  167. items:
  168. {
  169. onRender: function () {
  170. $grid1 = $(this);
  171. queryGrid1()
  172. },
  173. xtype: 'grid',
  174. toolbar: {
  175. xtype: 'toolbar',
  176. title: '六类人员详情',
  177. items: [
  178. {
  179. text: '添加', iconCls: 'fa fa-plus-circle fa-lg', onClick: function () {
  180. $.yvan.showDialog(this,
  181. require('/app/whepi/scan/addOutUserLYSix.js')({
  182. isEdit: false,
  183. confirm: function () {
  184. queryGrid1();
  185. }
  186. })
  187. );
  188. }
  189. },
  190. {
  191. text: '删除', iconCls: 'fa fa fa-pencil-square-o fa-lg', onClick: function () {
  192. var row = $grid1.checkedData();
  193. if (row.length == 0) {
  194. $.yvan.msg('请至少选择一行数据');
  195. return;
  196. }
  197. var ids = "";
  198. for (var i=0; i<row.length; i++) {
  199. ids += row[i].tuId + ","
  200. }
  201. $.yvan.confirm('确定删除勾选的这' + row.length + '条六类人员吗?', {
  202. yes: function (index) {
  203. $.yvan.ajax({
  204. method: 'post',
  205. url: api('/OutUser/deleteOutUser'),
  206. data: {ids: ids},
  207. success: function (data) {
  208. $.yvan.msg("删除成功");
  209. $grid1.reload();
  210. queryGrid1();
  211. }
  212. });
  213. }
  214. });
  215. }
  216. },
  217. {
  218. text: '导出系统六类人员', iconCls: 'fa fa-cloud-upload', onClick: function () {
  219. var queryForm = $form.formGet();
  220. $.yvan.download({
  221. method: 'post',
  222. url: api('/sweepCode/getByReportSuspected'),
  223. fileName: '系统六类人员-' + $.yvan.getMoment().format('YYYY-MM-DD HH:mm:ss') + '.xlsx'
  224. });
  225. }
  226. },
  227. ]
  228. },
  229. multiselect: true, /// 表格
  230. // 多选
  231. idField: 'tuId',
  232. editable: true,
  233. editOnSelected: true,
  234. autoSizeColumns: true,
  235. columns:
  236. [
  237. [
  238. {field: 'tuId', title: '用户ID', hidden: true},
  239. {field: 'userId', title: '用户ID', hidden: true},
  240. {field: 'unit', title: '部门', maxWidth: 200, align: 'left',},
  241. {field: 'departmentName', title: '二级部门', maxWidth: 200, align: 'left',},
  242. {field: 'name', title: '名字', maxWidth: 200, align: 'left',},
  243. {field: 'phone', title: '电话', maxWidth: 200, align: 'left',},
  244. {field: 'doorplate', title: '工号', maxWidth: 200, align: 'left',},
  245. {
  246. field: 'startDateStr', title: '开始时间', minWidth: 120, maxWidth: 300, align: 'left', editor: {
  247. xtype: 'datebox',
  248. required: true,
  249. onChange: function (value) {
  250. console.log(value)
  251. var row = $grid1.rowData();
  252. var startDateStr = row.startDateStr;
  253. var endDateStr = row.endDateStr;
  254. if (startDateStr > endDateStr) {
  255. $.yvan.msg('开始时间必须小于等于结束时间');
  256. return;
  257. } else {
  258. $.yvan.ajax({
  259. url: api('/OutUser/updateOutUser'),
  260. data: {
  261. tuId: row.tuId,
  262. startDate: row.startDateStr,
  263. endDate: row.endDateStr
  264. },
  265. method: 'post',
  266. async: false,
  267. success: function (data) {
  268. $.yvan.msg("操作成功");
  269. return;
  270. }
  271. });
  272. }
  273. },
  274. maxlength: 50
  275. }
  276. },
  277. {
  278. field: 'endDateStr', title: '结束时间', minWidth: 120, maxWidth: 200, align: 'left', editor: {
  279. xtype: 'datebox',
  280. required: true,
  281. onChange: function (value) {
  282. console.log(value)
  283. var row = $grid1.rowData();
  284. var startDateStr = row.startDateStr;
  285. var endDateStr = row.endDateStr;
  286. if (startDateStr > endDateStr) {
  287. $.yvan.msg('开始时间必须小于等于结束时间');
  288. return;
  289. } else {
  290. $.yvan.ajax({
  291. url: api('/OutUser/updateOutUser'),
  292. data: {
  293. tuId: row.tuId,
  294. startDate: row.startDateStr,
  295. endDate: row.endDateStr
  296. },
  297. method: 'post',
  298. async: false,
  299. success: function (data) {
  300. $.yvan.msg("操作成功");
  301. return;
  302. }
  303. });
  304. }
  305. },
  306. maxlength: 50
  307. }
  308. },
  309. ]
  310. ]
  311. }
  312. }
  313. };
  314. };
  315. }
  316. );