You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Form.js 26 KiB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 北京泉江科技有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2020-02-03 14:37
  5. * 描 述:疫情记录
  6. */
  7. var acceptClick;
  8. var keyValue = request('keyValue');
  9. var bootstrap = function ($, learun) {
  10. "use strict";
  11. var page = {
  12. init: function () {
  13. $('.lr-form-wrap').lrscroll();
  14. page.bind();
  15. page.initData();
  16. },
  17. bind: function () {
  18. $('#Creater').lrDataSourceSelect({ code: 'BaseUser', value: 'f_userid', text: 'f_realname' });
  19. $('#Department').lrDataSourceSelect({ code: 'classdata', value: 'id', text: 'name' });
  20. $('#UnitName').lrDataSourceSelect({ code: 'company', value: 'f_companyid', text: 'f_fullname' });
  21. $('#Type').lrDataItemSelect({ code: 'EUserType' });
  22. $('#RelationShip').lrDataItemSelect({ code: 'ERelationship' });
  23. $('#OutReason').lrDataItemSelect({ code: 'OutReason' });
  24. $('#HealthSituation').lrDataItemSelect({ code: 'EpiHealth' });
  25. $('#IsOut').lrDataItemSelect({
  26. code: 'YesOrNoInt',
  27. select: function (item) {
  28. if (item) {
  29. console.log(item);
  30. if (item.text == "是") {
  31. $("#PassPlaces").parent().show();
  32. } else {
  33. $("#PassPlaces").parent().hide();
  34. }
  35. } else {
  36. $("#PassPlaces").parent().hide();
  37. }
  38. }
  39. });
  40. $('#HasFamily').lrDataItemSelect({
  41. code: 'YesOrNoInt',
  42. select: function (item) {
  43. if (item) {
  44. console.log(item);
  45. if (item.text == "是") {
  46. $("#ContactsDetails").parent().show();
  47. } else {
  48. $("#ContactsDetails").parent().hide();
  49. }
  50. } else {
  51. $("#ContactsDetails").parent().hide();
  52. }
  53. }
  54. });
  55. $('#HasPeople').lrDataItemSelect({
  56. code: 'YesOrNoInt',
  57. select: function (item) {
  58. if (item) {
  59. console.log(item);
  60. if (item.text == "是") {
  61. $("#PeopleDetails").parent().show();
  62. } else {
  63. $("#PeopleDetails").parent().hide();
  64. }
  65. } else {
  66. $("#PeopleDetails").parent().hide();
  67. }
  68. }
  69. });
  70. $('#Gender').lrDataItemSelect({ code: 'usersex' });
  71. $('#Provice').lrDataSourceSelect({
  72. code: 'DIC_PROVINCE', value: 'pcode', text: 'pname',
  73. select: function (item) {
  74. if (!!item) {
  75. $('#OutArea').lrselectRefresh({
  76. url: "/DIC_CITY/GetListByProvinceCode",
  77. param: { ProvinceCode: item.pcode },
  78. value: 'CCODE',
  79. text: 'CNAME'
  80. });
  81. $('#City').lrselectRefresh({
  82. url: "",
  83. data: []
  84. });
  85. }
  86. }
  87. });
  88. $('#OutArea').lrselect({
  89. select: function (item) {
  90. if (!!item) {
  91. $('#City').lrselectRefresh({
  92. url: top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode",
  93. param: { cityCode: item.CCODE },
  94. value: 'ACODE',
  95. text: 'ANAME'
  96. });
  97. }
  98. }
  99. });
  100. $('#City').lrselect();
  101. $('#Vehicle').lrDataItemSelect({ code: 'Vehicle' });
  102. $('#PassPlaces').jfGrid({
  103. headData: [
  104. {
  105. label: '类别', name: 'PassType', width: 100, align: 'left'
  106. , edit: {
  107. type: 'select',
  108. init: function (row, $edit) {
  109. },
  110. datatype: 'dataItem',
  111. code: 'EpiPassType'
  112. }
  113. },
  114. {
  115. label: '省', name: 'Province', width: 100, align: 'left'
  116. , edit: {
  117. type: 'select',
  118. init: function (row, $edit) {
  119. },
  120. datatype: 'dataSource',
  121. code: 'DIC_PROVINCE',
  122. op: {
  123. value: 'pcode',
  124. text: 'pname',
  125. title: 'pname'
  126. }
  127. }
  128. }, {
  129. label: '市', name: 'City', width: 100, align: 'left',
  130. formatter: function (value, row, op, $cell) {
  131. var province = row.Province;
  132. var res;
  133. learun.httpSync('GET', '/DIC_CITY/GetListByProvinceCode', { ProvinceCode: province }, function (data) {
  134. $.each(data, function (_index, _item) {
  135. if (value == _item.CCODE) {
  136. res = _item.CNAME;
  137. }
  138. });
  139. });
  140. return res;
  141. },
  142. edit: {
  143. type: 'select',
  144. init: function (row, $self) {
  145. var province = row.Province;
  146. learun.httpAsync('GET', '/DIC_CITY/GetListByProvinceCode', { ProvinceCode: province }, function (data) {
  147. var res = [];
  148. $.each(data, function (_index, _item) {
  149. res.push(_item);
  150. });
  151. $self.lrselectRefresh({
  152. data: res,
  153. });
  154. });
  155. },
  156. op: {
  157. value: 'CCODE',
  158. text: 'CNAME',
  159. title: 'CNAME',
  160. }
  161. }
  162. },
  163. {
  164. label: '区域', name: 'Area', width: 100, align: 'left',
  165. formatter: function (value, row, op, $cell) {
  166. var cityCode = row.City;
  167. var res;
  168. learun.httpSync('GET', top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode", { cityCode: cityCode }, function (data) {
  169. $.each(data, function (_index, _item) {
  170. if (value == _item.ACODE) {
  171. res = _item.ANAME;
  172. }
  173. });
  174. });
  175. return res;
  176. },
  177. edit: {
  178. type: 'select',
  179. init: function (row, $edit) {
  180. var cityCode = row.City;
  181. learun.httpAsync('GET', top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode", { cityCode: cityCode }, function (data) {
  182. var res = [];
  183. $.each(data, function (_index, _item) {
  184. res.push(_item);
  185. });
  186. $edit.lrselectRefresh({
  187. data: res,
  188. });
  189. });
  190. },
  191. op: {
  192. value: 'ACODE',
  193. text: 'ANAME',
  194. title: 'ANAME'
  195. }
  196. }
  197. },
  198. {
  199. label: '详细地址', name: 'Address', width: 100, align: 'left'
  200. , edit: {
  201. type: 'input',
  202. }
  203. },
  204. {
  205. label: '时间', name: 'Time', width: 100, align: 'left', edit: { type: 'datatime' }
  206. },
  207. {
  208. label: '交通工具', name: 'Vehicle', width: 100, align: 'left', edit: {
  209. type: 'select',
  210. init: function (row, $edit) {
  211. },
  212. datatype: 'dataItem',
  213. code: 'Vehicle'
  214. }
  215. },
  216. {
  217. label: '班次号', name: 'VehicleNo', width: 100, align: 'left'
  218. , edit: {
  219. type: 'input',
  220. }
  221. }],
  222. isMultiselect: true,
  223. isEdit: true,
  224. height: 200
  225. });
  226. $('#ContactsDetails').jfGrid({
  227. headData: [
  228. {
  229. label: '名字', name: 'Name', width: 100, align: 'left',
  230. edit: { type: 'input' }
  231. },
  232. {
  233. label: '性别', name: 'Gender', width: 100, align: 'left'
  234. , edit: {
  235. type: 'select',
  236. init: function (row, $edit) {
  237. },
  238. datatype: 'dataItem',
  239. code: 'usersex'
  240. }
  241. },
  242. {
  243. label: '联系方式', name: 'Mobile', width: 100, align: 'left', edit: { type: 'input' }
  244. },
  245. {
  246. label: '隔离方式', name: 'QTType', width: 100, align: 'left'
  247. , edit: {
  248. type: 'select',
  249. init: function (data, $edit) {
  250. },
  251. datatype: 'dataItem',
  252. code: 'QuarantineType'
  253. }
  254. },
  255. {
  256. label: '省', name: 'Province', width: 100, align: 'left'
  257. , edit: {
  258. type: 'select',
  259. init: function (row, $edit) {
  260. },
  261. datatype: 'dataSource',
  262. code: 'DIC_PROVINCE',
  263. op: {
  264. value: 'pcode',
  265. text: 'pname',
  266. title: 'pname'
  267. }
  268. }
  269. }, {
  270. label: '市', name: 'City', width: 100, align: 'left',
  271. formatter: function (value, row, op, $cell) {
  272. var province = row.Province;
  273. var res;
  274. learun.httpSync('GET', '/DIC_CITY/GetListByProvinceCode', { ProvinceCode: province }, function (data) {
  275. $.each(data, function (_index, _item) {
  276. if (value == _item.CCODE) {
  277. res = _item.CNAME;
  278. }
  279. });
  280. });
  281. return res;
  282. },
  283. edit: {
  284. type: 'select',
  285. init: function (row, $self) {
  286. var province = row.Province;
  287. learun.httpAsync('GET', '/DIC_CITY/GetListByProvinceCode', { ProvinceCode: province }, function (data) {
  288. var res = [];
  289. $.each(data, function (_index, _item) {
  290. res.push(_item);
  291. });
  292. $self.lrselectRefresh({
  293. data: res,
  294. });
  295. });
  296. },
  297. op: {
  298. value: 'CCODE',
  299. text: 'CNAME',
  300. title: 'CNAME',
  301. }
  302. }
  303. },
  304. {
  305. label: '区域', name: 'Area', width: 100, align: 'left',
  306. formatter: function (value, row, op, $cell) {
  307. var cityCode = row.City;
  308. var res;
  309. learun.httpSync('GET', top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode", { cityCode: cityCode }, function (data) {
  310. $.each(data, function (_index, _item) {
  311. if (value == _item.ACODE) {
  312. res = _item.ANAME;
  313. }
  314. });
  315. });
  316. return res;
  317. },
  318. edit: {
  319. type: 'select',
  320. init: function (row, $edit) {
  321. var cityCode = row.City;
  322. learun.httpAsync('GET', top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode", { cityCode: cityCode }, function (data) {
  323. var res = [];
  324. $.each(data, function (_index, _item) {
  325. res.push(_item);
  326. });
  327. $edit.lrselectRefresh({
  328. data: res,
  329. });
  330. });
  331. },
  332. op: {
  333. value: 'ACODE',
  334. text: 'ANAME',
  335. title: 'ANAME'
  336. }
  337. }
  338. },
  339. {
  340. label: '隔离地点', name: 'QTAddress', width: 100, align: 'left', edit: { type: 'input' }
  341. },
  342. {
  343. label: '隔离时间', name: 'QTTime', width: 100, align: 'left'
  344. , edit: {
  345. type: 'datatime',
  346. dateformat: '1'
  347. }
  348. },
  349. {
  350. label: '接触隔离时间', name: 'QTContactTime', width: 100, align: 'left'
  351. , edit: {
  352. type: 'datatime',
  353. dateformat: '1'
  354. }
  355. },
  356. {
  357. label: '健康状况', name: 'Fever', width: 100, align: 'left'
  358. , edit: {
  359. type: 'select',
  360. init: function (data, $edit) {
  361. },
  362. datatype: 'dataItem',
  363. code: 'EpiHealth'
  364. }
  365. },
  366. ],
  367. isMultiselect: true,
  368. isEdit: true,
  369. height: 200
  370. });
  371. $('#PeopleDetails').jfGrid({
  372. headData: [
  373. {
  374. label: '名字', name: 'Name', width: 100, align: 'left',
  375. edit: { type: 'input' }
  376. },
  377. {
  378. label: '性别', name: 'Gender', width: 100, align: 'left'
  379. , edit: {
  380. type: 'select',
  381. init: function (row, $edit) {
  382. },
  383. datatype: 'dataItem',
  384. code: 'usersex'
  385. }
  386. },
  387. {
  388. label: '联系方式', name: 'Mobile', width: 100, align: 'left', edit: { type: 'input' }
  389. },
  390. {
  391. label: '隔离方式', name: 'QTType', width: 100, align: 'left'
  392. , edit: {
  393. type: 'select',
  394. init: function (data, $edit) {
  395. },
  396. datatype: 'dataItem',
  397. code: 'QuarantineType'
  398. }
  399. },
  400. {
  401. label: '省', name: 'Province', width: 100, align: 'left'
  402. , edit: {
  403. type: 'select',
  404. init: function (row, $edit) {
  405. },
  406. datatype: 'dataSource',
  407. code: 'DIC_PROVINCE',
  408. op: {
  409. value: 'pcode',
  410. text: 'pname',
  411. title: 'pname'
  412. }
  413. }
  414. }, {
  415. label: '市', name: 'City', width: 100, align: 'left',
  416. formatter: function (value, row, op, $cell) {
  417. var province = row.Province;
  418. var res;
  419. learun.httpSync('GET', '/DIC_CITY/GetListByProvinceCode', { ProvinceCode: province }, function (data) {
  420. $.each(data, function (_index, _item) {
  421. if (value == _item.CCODE) {
  422. res = _item.CNAME;
  423. }
  424. });
  425. });
  426. return res;
  427. },
  428. edit: {
  429. type: 'select',
  430. init: function (row, $self) {
  431. var province = row.Province;
  432. learun.httpAsync('GET', '/DIC_CITY/GetListByProvinceCode', { ProvinceCode: province }, function (data) {
  433. var res = [];
  434. $.each(data, function (_index, _item) {
  435. res.push(_item);
  436. });
  437. $self.lrselectRefresh({
  438. data: res,
  439. });
  440. });
  441. },
  442. op: {
  443. value: 'CCODE',
  444. text: 'CNAME',
  445. title: 'CNAME',
  446. }
  447. }
  448. },
  449. {
  450. label: '区域', name: 'Area', width: 100, align: 'left',
  451. formatter: function (value, row, op, $cell) {
  452. var cityCode = row.City;
  453. var res;
  454. learun.httpSync('GET', top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode", { cityCode: cityCode }, function (data) {
  455. $.each(data, function (_index, _item) {
  456. if (value == _item.ACODE) {
  457. res = _item.ANAME;
  458. }
  459. });
  460. });
  461. return res;
  462. },
  463. edit: {
  464. type: 'select',
  465. init: function (row, $edit) {
  466. var cityCode = row.City;
  467. learun.httpAsync('GET', top.$.rootUrl + "/DIC_AREA/GetAreasListByCityCode", { cityCode: cityCode }, function (data) {
  468. var res = [];
  469. $.each(data, function (_index, _item) {
  470. res.push(_item);
  471. });
  472. $edit.lrselectRefresh({
  473. data: res,
  474. });
  475. });
  476. },
  477. op: {
  478. value: 'ACODE',
  479. text: 'ANAME',
  480. title: 'ANAME'
  481. }
  482. }
  483. },
  484. {
  485. label: '隔离地点', name: 'QTAddress', width: 100, align: 'left', edit: { type: 'input' }
  486. },
  487. {
  488. label: '隔离时间', name: 'QTTime', width: 100, align: 'left'
  489. , edit: {
  490. type: 'datatime',
  491. dateformat: '1'
  492. }
  493. },
  494. {
  495. label: '接触隔离时间', name: 'QTContactTime', width: 100, align: 'left'
  496. , edit: {
  497. type: 'datatime',
  498. dateformat: '1'
  499. }
  500. },
  501. {
  502. label: '健康状况', name: 'Fever', width: 100, align: 'left'
  503. , edit: {
  504. type: 'select',
  505. init: function (data, $edit) {
  506. },
  507. datatype: 'dataItem',
  508. code: 'EpiHealth'
  509. }
  510. },
  511. ],
  512. isMultiselect: true,
  513. isEdit: true,
  514. height: 200
  515. });
  516. var loginInfo = top.learun.clientdata.get(['userinfo']);
  517. //添加当前登录人员
  518. if (!keyValue) {
  519. $("#Creater").val(loginInfo.realName);
  520. var time = new Date();
  521. var _dateFmt = $("#CreateTime").attr('data-dateFmt') || 'yyyy-MM-dd';
  522. $("#CreateTime").val(learun.formatDate(time.toLocaleDateString(), _dateFmt));
  523. $('#Department').lrselectSet(loginInfo.departmentId);
  524. $('#UnitName').lrselectSet(loginInfo.companyId);
  525. $('#Gender').lrselectSet(loginInfo.gender);
  526. $('#Mobile').lrselectSet(loginInfo.mobile);
  527. $('#Creater').lrselectSet(loginInfo.userId);
  528. $('#Objective').val(returnCitySN.cname);
  529. //loginInfo.userId
  530. if (loginInfo.Description == "学生") {
  531. $("#Type").lrselectSet(5);
  532. learun.httpSync('GET', top.$.rootUrl + "/PersonnelManagement/EpidemicSituationCopy/GetStudentSource", { studentId: loginInfo.account }, function (data) {
  533. console.log(data);
  534. $('#StudentSource').val(data.res);
  535. $('#HomeAddress').val(data.Address);
  536. });
  537. } else {
  538. learun.httpSync('GET', top.$.rootUrl + "/PersonnelManagement/EpidemicSituationCopy/GetEmpSource", { empId: loginInfo.userId }, function (data) {
  539. $('#HomeAddress').val(data.Address);
  540. });
  541. }
  542. }
  543. if (loginInfo.Description == "学生") {
  544. $('#Department').parent().hide();
  545. $('#StudentSource').parent().show();
  546. } else {
  547. $('#Department').parent().show();
  548. $('#StudentSource').parent().hide();
  549. }
  550. },
  551. initData: function () {
  552. if (!!keyValue) {
  553. $.lrSetForm(top.$.rootUrl + '/PersonnelManagement/EpidemicSituationCopy/GetFormData?keyValue=' + keyValue, function (data) {
  554. for (var id in data) {
  555. if (!!data[id].length && data[id].length > 0) {
  556. $('#' + id).jfGridSet('refreshdata', data[id]);
  557. }
  558. else {
  559. $('[data-table="' + id + '"]').lrSetFormData(data[id]);
  560. }
  561. }
  562. });
  563. }
  564. }
  565. };
  566. // 保存数据
  567. acceptClick = function (callBack) {
  568. if (!$('body').lrValidform()) {
  569. return false;
  570. }
  571. var postData = {};
  572. postData.strEntity = JSON.stringify($('[data-table="EpidemicSituation"]').lrGetFormData());
  573. postData.strcontactsDetailsList = JSON.stringify($('#ContactsDetails').jfGridGet('rowdatas'));
  574. postData.passPlaceDetailsList = JSON.stringify($('#PassPlaces').jfGridGet('rowdatas'));
  575. postData.strpeopleDetailsList = JSON.stringify($('#PeopleDetails').jfGridGet('rowdatas'));
  576. $.lrSaveForm(top.$.rootUrl + '/PersonnelManagement/EpidemicSituationCopy/SaveForm?keyValue=' + keyValue, postData, function (res) {
  577. // 保存成功后才回调
  578. if (!!callBack) {
  579. callBack();
  580. }
  581. });
  582. };
  583. page.init();
  584. }