specialPersonnelLYS2.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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 = 5;
  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/addOutUserLY2.js')({
  182. isEdit: false,
  183. confirm: function () {
  184. queryGrid1();
  185. }
  186. })
  187. );
  188. }
  189. },
  190. // {
  191. // text: '保存', iconCls: 'fa fa-pencil-square-o', onClick: function () {
  192. // var row = $grid1.rowData();
  193. // if (!row) {
  194. // $.yvan.msg('请选择一条要保存的数据');
  195. // return;
  196. // }
  197. // var startDateStr = row.startDateStr;
  198. // var endDateStr = row.endDateStr;
  199. // if (startDateStr > endDateStr) {
  200. // $.yvan.msg('开始时间必须小于等于结束时间');
  201. // return;
  202. // }
  203. // $.yvan.ajax({
  204. // url: api('/OutUser/updateOutUser'),
  205. // data: {
  206. // tuId: row.tuId,
  207. // startDate: row.startDateStr,
  208. // endDate: row.endDateStr
  209. // },
  210. // method: 'post',
  211. // async: false,
  212. // success: function (data) {
  213. // $.yvan.msg("操作成功");
  214. // $grid1.reload();
  215. // queryGrid1();
  216. // }
  217. // });
  218. // }
  219. // },
  220. {
  221. text: '删除', iconCls: 'fa fa fa-pencil-square-o fa-lg', onClick: function () {
  222. var row = $grid1.checkedData();
  223. if (row.length == 0) {
  224. $.yvan.msg('请至少选择一行数据');
  225. return;
  226. }
  227. var ids = "";
  228. for (var i=0; i<row.length; i++) {
  229. ids += row[i].tuId + ","
  230. }
  231. $.yvan.confirm('确定删除勾选的这' + row.length + '条二类特殊人员吗?', {
  232. yes: function (index) {
  233. $.yvan.ajax({
  234. method: 'post',
  235. url: api('/OutUser/deleteOutUser'),
  236. data: {ids: ids},
  237. success: function (data) {
  238. $.yvan.msg("删除成功");
  239. $grid1.reload();
  240. queryGrid1();
  241. }
  242. });
  243. }
  244. });
  245. }
  246. }
  247. ]
  248. },
  249. multiselect: true, /// 表格多选
  250. idField: 'tuId',
  251. editable: true,
  252. editOnSelected: true,
  253. autoSizeColumns: true,
  254. columns:
  255. [
  256. [
  257. {field: 'tuId', title: '用户ID', hidden: true},
  258. {field: 'userId', title: '用户ID', hidden: true},
  259. {field: 'unit', title: '部门', maxWidth: 200, align: 'left',},
  260. {field: 'departmentName', title: '二级部门', maxWidth: 200, align: 'left',},
  261. {field: 'name', title: '名字', maxWidth: 200, align: 'left',},
  262. {field: 'phone', title: '电话', maxWidth: 200, align: 'left',},
  263. {field: 'doorplate', title: '工号', maxWidth: 200, align: 'left',},
  264. {
  265. field: 'startDateStr', title: '开始时间', minWidth: 120, maxWidth: 300, align: 'left', editor: {
  266. xtype: 'datebox',
  267. required: true,
  268. onChange: function (value) {
  269. var row = $grid1.rowData();
  270. $.yvan.ajax({
  271. url: api('/OutUser/updateOutUserLY2'),
  272. data: {
  273. tuId: row.tuId,
  274. startDate: row.startDateStr,
  275. },
  276. method: 'post',
  277. async: false,
  278. success: function (data) {
  279. $.yvan.msg("操作成功");
  280. return;
  281. }
  282. });
  283. },
  284. maxlength: 50
  285. }
  286. },
  287. {field: 'createName', title: '新增人', maxWidth: 200, align: 'left',},
  288. {field: 'updateName', title: '修改人', maxWidth: 200, align: 'left',},
  289. {field: 'timeUpdate', title: '更新时间', formatter: 'ts'},
  290. ]
  291. ]
  292. }
  293. }
  294. };
  295. };
  296. }
  297. );