Açıklama Yok

addOrEditWash.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /**
  2. * 增加或编辑洗涤工单信息
  3. * */
  4. $(function() {
  5. var nowts = helper.DateFormat.getNowDateTime();
  6. var pro_Id = helper.request.queryString("edit_id");
  7. //项目名称
  8. //helper.getDropList.getProlistDrop($('#pro_title'));
  9. //项目所在地
  10. //getProLocation($('#pro_province'), $('#pro_city'));
  11. getProLocations($('#pro_province'), $('#pro_city'), $('#pro_title'));
  12. //获取科室下拉
  13. getDepartmentList($('#department'));
  14. //获取楼层下拉
  15. getFloorList($('#floor'));
  16. if(pro_Id) { //修改
  17. getProject(pro_Id);
  18. //创建时间
  19. laydate.render({
  20. elem: '#createtime',
  21. type: 'datetime',
  22. theme: '#249fea',
  23. });
  24. //任务时间
  25. laydate.render({
  26. elem: '#tasktime',
  27. type: 'datetime',
  28. theme: '#249fea',
  29. });
  30. } else {
  31. //创建时间
  32. laydate.render({
  33. elem: '#createtime',
  34. type: 'datetime',
  35. theme: '#249fea',
  36. //min: nowts,
  37. });
  38. //任务时间
  39. laydate.render({
  40. elem: '#tasktime',
  41. type: 'datetime',
  42. theme: '#249fea',
  43. //min: nowts,
  44. });
  45. }
  46. //添加编辑保存按钮点击
  47. $('#pro_save').on('click', saveProject);
  48. });
  49. //获取单个项目
  50. function getProject(ids) {
  51. $.getJSON(huayi.config.callcenter_url + "equipmentapi/api/WoWash/getdetails", {
  52. id: ids,
  53. }, function(data) {
  54. if(data.state == "success") {
  55. var res = data.data;
  56. $('#pro_province').val(res.provincecode); //项目所在省
  57. $('#pro_province').trigger('change');
  58. $('#pro_city').val(res.citycode); //项目所在市
  59. $('#pro_city').trigger('change');
  60. $('#pro_title').val(res.projectid); //项目id
  61. $('#department').val(res.departmentsid); //科室名称id
  62. $('#department').trigger('change');
  63. $('#floor').val(res.floorid); //楼层名称id
  64. $('#floor').trigger('change');
  65. $('#person').val(res.personid); //负责人id
  66. $('#person').trigger('change');
  67. $('#task_type').val(res.tasktype); //任务状态id(0实收,1实发)
  68. $('#task_type').trigger('change');
  69. $('#createtime').val(res.createtime); //添加时间
  70. $('#tasktime').val(res.tasktime); //任务时间
  71. $('#batchesnumber').val(res.batchesnumber); //关联批次(编号)
  72. $('#bigsheetonenum').val(res.bigsheetnum); //大单
  73. $('#quiltcovernum').val(res.quiltcovernum); //被罩
  74. $('#pillowcasenum').val(res.pillowcasenum); //枕套
  75. $('#pillownum').val(res.pillownum); //枕芯
  76. $('#clothesnum').val(res.clothesnum); //条衣
  77. $('#pantsnum').val(res.pantsnum); //条裤
  78. $('#whitepatientclothesnum').val(res.whitepatientclothesnum); //白病人衣
  79. $('#whitepatientpantsnum').val(res.whitepatientpantsnum); //白病人裤
  80. $('#singlelayer').val(res.singlelayer); //单层中单
  81. $('#doublelayer').val(res.doublelayer); //双层中单
  82. $('#quiltnum').val(res.quiltnum); //被子
  83. $('#matnum').val(res.matnum); //褥子
  84. $('#coolquiltnum').val(res.coolquiltnum); //凉被子
  85. $('#bedspreadnum').val(res.bedspreadnum); //床罩
  86. $('#blindsnum').val(res.blindsnum); //窗帘
  87. $('#workclothesnum').val(res.workclothesnum); //工作衣
  88. $('#nurseclothesnum').val(res.nurseclothesnum); //护士衣
  89. $('#nursepantnum').val(res.nursepantnum); //护士裤
  90. $('#constraintsnum').val(res.constraintsnum); //约束带
  91. $('#hatsnum').val(res.hatsnum); //帽子
  92. }
  93. });
  94. }
  95. //保存项目
  96. function saveProject() {
  97. var pro_Id = helper.request.queryString("edit_id");
  98. var wUrl;
  99. if(!$.trim($('#pro_province').val())) {
  100. layer.confirm('项目所在省不能为空', {
  101. icon: 2,
  102. btn: ['确定'] //按钮
  103. });
  104. return;
  105. }
  106. if(!$.trim($('#pro_city').val())) {
  107. layer.confirm('项目所在市不能为空', {
  108. icon: 2,
  109. btn: ['确定'] //按钮
  110. });
  111. return;
  112. }
  113. if(!$.trim($('#pro_title').val())) {
  114. layer.confirm('项目名称不能为空', {
  115. icon: 2,
  116. btn: ['确定'] //按钮
  117. });
  118. return;
  119. }
  120. if(!$.trim($('#department').val())) {
  121. layer.confirm('科室名称不能为空', {
  122. icon: 2,
  123. btn: ['确定'] //按钮
  124. });
  125. return;
  126. }
  127. if(!$.trim($('#floor').val())) {
  128. layer.confirm('楼层名称不能为空', {
  129. icon: 2,
  130. btn: ['确定'] //按钮
  131. });
  132. return;
  133. }
  134. if(!$.trim($('#person').val())) {
  135. layer.confirm('负责人不能为空', {
  136. icon: 2,
  137. btn: ['确定'] //按钮
  138. });
  139. return;
  140. }
  141. if(!$.trim($('#task_type').val())) {
  142. layer.confirm('任务状态不能为空', {
  143. icon: 2,
  144. btn: ['确定'] //按钮
  145. });
  146. return;
  147. }
  148. if(!regexs.nums.test($.trim($('#bigsheetonenum').val()))) {
  149. layer.confirm('大单只能输入数字', {
  150. icon: 2,
  151. btn: ['确定'] //按钮
  152. });
  153. return;
  154. }
  155. if(!regexs.nums.test($.trim($('#quiltcovernum').val()))) {
  156. layer.confirm('被罩只能输入数字', {
  157. icon: 2,
  158. btn: ['确定'] //按钮
  159. });
  160. return;
  161. }
  162. if(!regexs.nums.test($.trim($('#pillowcasenum').val()))) {
  163. layer.confirm('枕套只能输入数字', {
  164. icon: 2,
  165. btn: ['确定'] //按钮
  166. });
  167. return;
  168. }
  169. if(!regexs.nums.test($.trim($('#pillownum').val()))) {
  170. layer.confirm('枕芯只能输入数字', {
  171. icon: 2,
  172. btn: ['确定'] //按钮
  173. });
  174. return;
  175. }
  176. if(!regexs.nums.test($.trim($('#clothesnum').val()))) {
  177. layer.confirm('条衣只能输入数字', {
  178. icon: 2,
  179. btn: ['确定'] //按钮
  180. });
  181. return;
  182. }
  183. if(!regexs.nums.test($.trim($('#pantsnum').val()))) {
  184. layer.confirm('条裤只能输入数字', {
  185. icon: 2,
  186. btn: ['确定'] //按钮
  187. });
  188. return;
  189. }
  190. if(!regexs.nums.test($.trim($('#whitepatientclothesnum').val()))) {
  191. layer.confirm('白病人衣只能输入数字', {
  192. icon: 2,
  193. btn: ['确定'] //按钮
  194. });
  195. return;
  196. }
  197. if(!regexs.nums.test($.trim($('#whitepatientpantsnum').val()))) {
  198. layer.confirm('白病人裤只能输入数字', {
  199. icon: 2,
  200. btn: ['确定'] //按钮
  201. });
  202. return;
  203. }
  204. if(!regexs.nums.test($.trim($('#singlelayer').val()))) {
  205. layer.confirm('单层中单只能输入数字', {
  206. icon: 2,
  207. btn: ['确定'] //按钮
  208. });
  209. return;
  210. }
  211. if(!regexs.nums.test($.trim($('#doublelayer').val()))) {
  212. layer.confirm('双层中单只能输入数字', {
  213. icon: 2,
  214. btn: ['确定'] //按钮
  215. });
  216. return;
  217. }
  218. if(!regexs.nums.test($.trim($('#quiltnum').val()))) {
  219. layer.confirm('被子只能输入数字', {
  220. icon: 2,
  221. btn: ['确定'] //按钮
  222. });
  223. return;
  224. }
  225. if(!regexs.nums.test($.trim($('#matnum').val()))) {
  226. layer.confirm('褥子只能输入数字', {
  227. icon: 2,
  228. btn: ['确定'] //按钮
  229. });
  230. return;
  231. }
  232. if(!regexs.nums.test($.trim($('#coolquiltnum').val()))) {
  233. layer.confirm('凉被子只能输入数字', {
  234. icon: 2,
  235. btn: ['确定'] //按钮
  236. });
  237. return;
  238. }
  239. if(!regexs.nums.test($.trim($('#bedspreadnum').val()))) {
  240. layer.confirm('床罩只能输入数字', {
  241. icon: 2,
  242. btn: ['确定'] //按钮
  243. });
  244. return;
  245. }
  246. if(!regexs.nums.test($.trim($('#blindsnum').val()))) {
  247. layer.confirm('窗帘只能输入数字', {
  248. icon: 2,
  249. btn: ['确定'] //按钮
  250. });
  251. return;
  252. }
  253. if(!regexs.nums.test($.trim($('#workclothesnum').val()))) {
  254. layer.confirm('工作衣只能输入数字', {
  255. icon: 2,
  256. btn: ['确定'] //按钮
  257. });
  258. return;
  259. }
  260. if(!regexs.nums.test($.trim($('#nurseclothesnum').val()))) {
  261. layer.confirm('护士衣只能输入数字', {
  262. icon: 2,
  263. btn: ['确定'] //按钮
  264. });
  265. return;
  266. }
  267. if(!regexs.nums.test($.trim($('#nursepantnum').val()))) {
  268. layer.confirm('护士裤只能输入数字', {
  269. icon: 2,
  270. btn: ['确定'] //按钮
  271. });
  272. return;
  273. }
  274. if(!regexs.nums.test($.trim($('#constraintsnum').val()))) {
  275. layer.confirm('约束带只能输入数字', {
  276. icon: 2,
  277. btn: ['确定'] //按钮
  278. });
  279. return;
  280. }
  281. if(!regexs.nums.test($.trim($('#hatsnum').val()))) {
  282. layer.confirm('帽子只能输入数字', {
  283. icon: 2,
  284. btn: ['确定'] //按钮
  285. });
  286. return;
  287. }
  288. if(pro_Id) {
  289. wURL = "equipmentapi/api/WoWash/update";
  290. } else {
  291. wURL = "equipmentapi/api/WoWash/add";
  292. }
  293. $.post(huayi.config.callcenter_url + wURL, {
  294. id: pro_Id, //pro_Id为空的时候添加
  295. //wocode: // //工单编号
  296. projectid: $('#pro_title').val(), //项目id
  297. provincecode: $('#pro_province').val(), //项目所在省
  298. citycode: $('#pro_city').val(), //项目所在市
  299. departmentsid: $('#department').val(), //科室名称id
  300. floorid: $('#floor').val(), //楼层名称id
  301. personid: $('#person').val(), //负责人id
  302. tasktype: $('#task_type').val(), //任务状态id(0实收,1实发)
  303. createtime: $('#createtime').val(), //添加时间
  304. tasktime: $('#tasktime').val(), //任务时间
  305. batchesnumber: $('#batchesnumber').val(), //关联批次(编号)
  306. bigsheetnum: $('#bigsheetonenum').val(), //大单
  307. quiltcovernum: $('#quiltcovernum').val(), //被罩
  308. pillowcasenum: $('#pillowcasenum').val(), //枕套
  309. pillownum: $('#pillownum').val(), //枕芯
  310. clothesnum: $('#clothesnum').val(), //条衣
  311. pantsnum: $('#pantsnum').val(), //条裤
  312. whitepatientclothesnum: $('#whitepatientclothesnum').val(), //白病人衣
  313. whitepatientpantsnum: $('#whitepatientpantsnum').val(), //白病人裤
  314. singlelayer: $('#singlelayer').val(), //单层中单
  315. doublelayer: $('#doublelayer').val(), //双层中单
  316. quiltnum: $('#quiltnum').val(), //被子
  317. matnum: $('#matnum').val(), //褥子
  318. coolquiltnum: $('#coolquiltnum').val(), //凉被子
  319. bedspreadnum: $('#bedspreadnum').val(), //床罩
  320. blindsnum: $('#blindsnum').val(), //窗帘
  321. workclothesnum: $('#workclothesnum').val(), //工作衣
  322. nurseclothesnum: $('#nurseclothesnum').val(), //护士衣
  323. nursepantnum: $('#nursepantnum').val(), //护士裤
  324. constraintsnum: $('#constraintsnum').val(), //约束带
  325. hatsnum: $('#hatsnum').val(), //帽子
  326. //isdelete: ,//是否删除(0正常,-1删除)
  327. }, function(data) {
  328. data = JSON.parse(data);
  329. if(data.state == "success") {
  330. var index = parent.layer.getFrameIndex(window.name);
  331. parent.layer.close(index);
  332. parent.initTable();
  333. parent.layer.msg("保存成功");
  334. }
  335. });
  336. }
  337. //获取科室下拉
  338. function getDepartmentList(el) {
  339. $.ajax({
  340. type: "get",
  341. url: huayi.config.callcenter_url + "configurationapi/api/Department/getlistdrop",
  342. dataType: 'json',
  343. async: false,
  344. data: {
  345. //projectid: ,//string 项目名称id
  346. //floorid: ,//string 楼层名称id
  347. },
  348. success: function(data) {
  349. var res = data.data;
  350. for(var i = 0; i < res.length; i++) {
  351. $('<option value=' + res[i].id + '>' + res[i].departmenname + '</option>').appendTo(el);
  352. }
  353. el.selectpicker('refresh');
  354. }
  355. });
  356. }
  357. //获取楼层下拉
  358. function getFloorList(el) {
  359. $.ajax({
  360. type: "get",
  361. url: huayi.config.callcenter_url + "configurationapi/api/FloorManage/getlistdrop",
  362. dataType: 'json',
  363. async: false,
  364. data: {},
  365. success: function(data) {
  366. var res = data.data;
  367. for(var i = 0; i < res.length; i++) {
  368. $('<option value=' + res[i].id + '>' + res[i].floorname + '</option>').appendTo(el);
  369. }
  370. el.selectpicker('refresh');
  371. }
  372. });
  373. }
  374. //项目所在地二级联动
  375. function getProLocation(obj, obj1) {
  376. obj.empty();
  377. obj1.empty();
  378. obj.append('<option selected="selected" value="">请选择所在省</option>');
  379. obj1.append('<option selected="selected" value="">请选择所在市</option>');
  380. $.getJSON(huayi.config.callcenter_url + "configurationapi/api/provincesaddress/getaddressjson", {}, function(data) {
  381. var content = data.data; //省信息
  382. var cityInfos = []; //市信息
  383. //初始化省
  384. $(content).each(function(i, n) {
  385. if(n.parentcode === null) {
  386. $("<option value='" + n.code + "'>" + n.name + "</option>").appendTo(obj);
  387. }
  388. if(n.entityJson != null) {
  389. cityInfos.push(n.entityJson);
  390. }
  391. });
  392. //市
  393. obj.change(function() {
  394. obj1.empty();
  395. for(var i = 0; i < cityInfos.length; i++) {
  396. $(cityInfos[i]).each(function(j, v) {
  397. if(v.parentcode > 0) {
  398. if(obj.find("option:selected").val() == v.parentcode) {
  399. $("<option value='" + v.code + "'>" + v.name + "</option>").appendTo(obj1);
  400. }
  401. }
  402. });
  403. }
  404. if(obj.find("option:selected").val() == '') {
  405. obj1.append('<option selected="selected" value="">请选择所在市</option>');
  406. }
  407. if(obj1.val() == null) {
  408. obj1.append('<option selected="selected" value="">没有数据</option>');
  409. }
  410. });
  411. })
  412. }
  413. //省市项目三级联动
  414. function getProLocations(obj, obj1, obj2) {
  415. obj.empty();
  416. obj1.empty();
  417. obj2.empty();
  418. obj.append('<option selected="selected" value="">请选择所在省</option>');
  419. obj1.append('<option selected="selected" value="">请选择所在市</option>');
  420. obj2.append('<option selected="selected" value="">请选择项目</option>');
  421. $.ajax({
  422. type: "get",
  423. url: huayi.config.callcenter_url + "configurationapi/api/provincesaddress/getaddressandprojson",
  424. dataType: 'json',
  425. async: false,
  426. success: function(data) {
  427. var content = data.data; //省信息
  428. var cityInfos = []; //市信息
  429. var proInfos = []; //项目信息
  430. //初始化省
  431. $(content).each(function(i, n) {
  432. if(n.parentcode === null) {
  433. $("<option value='" + n.code + "'>" + n.name + "</option>").appendTo(obj);
  434. if(n.entityJson != null && n.entityJson.length > 0) {
  435. cityInfos.push(n.entityJson);
  436. }
  437. }
  438. });
  439. //市
  440. obj.change(function() {
  441. obj1.empty();
  442. for(var i = 0; i < cityInfos.length; i++) {
  443. $(cityInfos[i]).each(function(j, v) {
  444. if(v.parentcode > 0) {
  445. if(obj.find("option:selected").val() == v.parentcode) {
  446. $("<option value='" + v.code + "'>" + v.name + "</option>").appendTo(obj1);
  447. if(v.entityJson != null && v.entityJson.length > 0) {
  448. proInfos.push(v.entityJson);
  449. }
  450. }
  451. }
  452. });
  453. }
  454. if(obj.find("option:selected").val() == '') {
  455. obj1.append('<option selected="selected" value="">请选择所在市</option>');
  456. }
  457. if(obj1.val() == null) {
  458. obj1.append('<option selected="selected" value="">没有数据</option>');
  459. }
  460. obj1.trigger('change');
  461. });
  462. //项目
  463. obj1.change(function() {
  464. obj2.empty();
  465. for(var j = 0; j < proInfos.length; j++) {
  466. $(proInfos[j]).each(function(i, n) {
  467. if(n.parentcode > 0) {
  468. if(obj1.find("option:selected").val() == n.parentcode) {
  469. $("<option value='" + n.code + "'>" + n.name + "</option>").appendTo(obj2);
  470. }
  471. }
  472. });
  473. }
  474. obj2.selectpicker('refresh');
  475. if(obj1.find("option:selected").val() == '') {
  476. obj2.append('<option selected="selected" value="">请选择项目</option>');
  477. }
  478. if(obj2.val() == null || obj1.val() == '') {
  479. obj2.append('<option selected="selected" value="">没有项目</option>');
  480. }
  481. });
  482. },
  483. });
  484. }