xinxicaiji.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. var dataBase,
  2. jiandangCase2;
  3. var d = dialog({contentType:'load', skin:'bk-popup'});
  4. function toast(msg){
  5. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
  6. }
  7. //请求失败
  8. function queryFailed(){ d.close();toast('请求失败');}
  9. $(function(){
  10. var case2 = window.localStorage.getItem("jiandangCase2");
  11. jiandangCase2 = case2?JSON.parse(case2):'';
  12. // 获取字典
  13. d.show()
  14. sendPost('patient/getArchiveComboList', {}, 'json', 'get',queryFailed, function(res) {
  15. d.close()
  16. if(res.status==200) {
  17. dataBase = res.data;
  18. var html = template('list_tmp',{data:dataBase,cache:jiandangCase2})
  19. $('.c-main').html(html)
  20. bindEvent()
  21. }else{
  22. toast('获取数据失败')
  23. }
  24. })
  25. function bindEvent(){
  26. $('.xc-li-more .one').on('click',function(e){
  27. e.stopPropagation();
  28. var $this = $(this)
  29. $this.addClass('active').siblings().removeClass('active')
  30. var $parent = $this.closest('.xc-li-more');
  31. if($this.attr('data-id')==1){
  32. $parent.find('.xc-li-radio').show()
  33. }else{
  34. $parent.find('.xc-li-radio').hide()
  35. $parent.find('.child').removeClass('active')
  36. $parent.find('input').val('')
  37. $parent.find('input.j-hide').hide()
  38. $parent.find('select.sickSel').attr('data-code','')
  39. $parent.find('select.sickSel').attr('data-name','')
  40. if($parent.hasClass('j-family')){
  41. addContent5(dataBase.familyHistory,true)//初始化
  42. }
  43. }
  44. })
  45. $(".j-checkbox").on('tap',function(){
  46. var $this = $(this).parent()
  47. if($this.hasClass('active')){
  48. $this.removeClass('active')
  49. }else{
  50. $this.addClass('active')
  51. }
  52. })
  53. $(".j-showbox").on('click',function(){
  54. var $this = $(this).parent()
  55. if($this.hasClass('active')){
  56. $this.removeClass('active')
  57. $this.find('input').hide()
  58. $this.find('input').val('')
  59. }else{
  60. $this.addClass('active')
  61. $this.find('input').css('display','block')
  62. }
  63. })
  64. //提交
  65. $(".jm-btn").on('tap',function(){
  66. var $gen = $('.j-gen').find('.one.active').attr('data-id'),
  67. $past = $('.j-past').find('.one.active').attr('data-id'),
  68. $drug = $('.j-drug').find('.one.active').attr('data-id'),
  69. $family = $('.j-family').find('.one.active').attr('data-id');
  70. function getCode($id){
  71. var that = $id.find('.j-noOther.active')
  72. var codeArr=[];
  73. for(var i=0;i<that.length;i++){
  74. codeArr.push(that.eq(i).attr('data-code'))
  75. }
  76. return codeArr.join(',')
  77. }
  78. function getName($id){
  79. var that = $id.find('.j-noOther.active')
  80. var nameArr=[];
  81. for(var i=0;i<that.length;i++){
  82. nameArr.push(that.eq(i).attr('data-name'))
  83. }
  84. return nameArr.join(',')
  85. }
  86. function getTime($id){
  87. var that = $id.find('.j-noOther.active .dateSel')
  88. var timeArr=[];
  89. for(var i=0;i<that.length;i++){
  90. timeArr.push(that.eq(i).val()?that.eq(i).val():'0')
  91. }
  92. return timeArr.join(',')
  93. }
  94. var allData = {
  95. education:$('#school').attr('data-code'),//教育
  96. educationName:$('#school').attr('data-name'),
  97. occupation:$('#job').attr('data-code'),//职业
  98. occupationName:$('#job').attr('data-name'),
  99. payment:$('#pay').attr('data-code'),//支付方式
  100. paymentName:$('#pay').attr('data-name'),
  101. disabilitys:$('#disability').attr('data-code'),//残疾
  102. disabilitysName:$('#disability').attr('data-name'),
  103. drugFlag:$drug==undefined?'':$drug,
  104. drugAllergys:getCode($('.j-drug')),//药物过敏
  105. drugAllergysName:getName($('.j-drug')),
  106. drugOtherContent:$('.j-drug').find('input.other').val().trim(),//过敏其他
  107. pastHistorysFlag:$past==undefined?'':$past,
  108. pastHistorys:getCode($('.j-past')),//既往史
  109. pastHistorysName:getName($('.j-past')),
  110. pastHistoryDate:getTime($('.j-past')),
  111. pastHistoryContent:$('.j-past').find('input.past').val().trim(),
  112. geneticFlag:$gen==undefined?'':$gen,
  113. geneticContent:$('.j-gen').find('input.other').val().trim(),//遗传病
  114. familyHistoryFlag:$family==undefined?'':$family,
  115. familyFatherHistorys:$('.j-sel').eq(0).find('select').attr('data-code'),//父亲的疾病
  116. familyMotherHistorys:$('.j-sel').eq(1).find('select').attr('data-code'), //母亲的疾病
  117. familyBrotherHistorys:$('.j-sel').eq(2).find('select').attr('data-code'), //兄弟的疾病
  118. familyChildrenHistorys:$('.j-sel').eq(3).find('select').attr('data-code'), //子女的疾病
  119. familyFatherHistorysName:$('.j-sel').eq(0).find('select').attr('data-name'),
  120. familyMotherHistorysName:$('.j-sel').eq(1).find('select').attr('data-name'),
  121. familyBrotherHistorysName:$('.j-sel').eq(2).find('select').attr('data-name'),
  122. familyChildrenHistorysName:$('.j-sel').eq(3).find('select').attr('data-name'),
  123. }
  124. //判断字段不为空
  125. if($drug == 1){
  126. if(!(allData.drugOtherContent || allData.drugAllergys)){
  127. toast('请选择药物过敏史')
  128. return
  129. }
  130. }
  131. if($past == 1){
  132. if(!(allData.pastHistoryContent || allData.pastHistorys)){
  133. toast('请选择既往史')
  134. return
  135. }
  136. }
  137. if($gen == 1){
  138. if(!allData.geneticContent){
  139. toast('请填写遗传病史')
  140. return
  141. }
  142. }
  143. if($family == 1){
  144. if(!(allData.familyFatherHistorys || allData.familyMotherHistorys || allData.familyBrotherHistorys || allData.familyChildrenHistorys)){
  145. toast('请选择家族史')
  146. return
  147. }
  148. }
  149. //跳转
  150. d.show()
  151. window.localStorage.setItem("jiandangCase2",JSON.stringify(allData))
  152. window.location.href = "xinxiqueren.html";
  153. })
  154. //选择时间
  155. $(".dateSel").mobiscroll().date({
  156. theme: "ios",
  157. lang: "zh",
  158. display: "bottom",
  159. dateFormat: "yy-mm-dd",
  160. onSelect: function(valueText, inst) {
  161. }
  162. })
  163. addContent1(dataBase.education)//文化
  164. addContent2(dataBase.occupation)//职业
  165. addContent3(dataBase.payment)//支付方式
  166. addContent4(dataBase.disability)//残疾
  167. addContent5(dataBase.familyHistory)//家族疾病
  168. }
  169. function addContent1(arr) {
  170. var len = arr.length;
  171. var html = "<option disabled selected></option>";
  172. for(var i = 0; i < len; i++) {
  173. if(jiandangCase2&&jiandangCase2.education == arr[i].code){
  174. html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
  175. }else{
  176. html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
  177. }
  178. }
  179. $('#schoolSel').html(html)
  180. $('#schoolSel').mobiscroll().select({
  181. theme: "ios",
  182. lang: "zh",
  183. placeholder:'请选择文化程度',
  184. display: "bottom",
  185. onSelect: function(valueText, inst) {
  186. $('#school').attr('data-code',inst._tempValue)
  187. $('#school').attr('data-name',valueText)
  188. }
  189. })
  190. }
  191. function addContent2(arr) {
  192. var len = arr.length;
  193. var html = "<option disabled selected></option>";
  194. for(var i = 0; i < len; i++) {
  195. if(jiandangCase2&&jiandangCase2.occupation == arr[i].code){
  196. html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
  197. }else{
  198. html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
  199. }
  200. }
  201. $('#jobSel').html(html)
  202. $('#jobSel').mobiscroll().select({
  203. theme: "ios",
  204. lang: "zh",
  205. placeholder:'请选择职业',
  206. display: "bottom",
  207. onSelect: function(valueText, inst) {
  208. $('#job').attr('data-code',inst._tempValue)
  209. $('#job').attr('data-name',valueText)
  210. }
  211. })
  212. }
  213. function addContent3(arr) {
  214. var len = arr.length;
  215. var html = "<option disabled selected></option>";
  216. for(var i = 0; i < len; i++) {
  217. if(jiandangCase2&&jiandangCase2.payment == arr[i].code){
  218. html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
  219. }else{
  220. html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
  221. }
  222. }
  223. $('#paySel').html(html)
  224. $('#paySel').mobiscroll().select({
  225. theme: "ios",
  226. lang: "zh",
  227. placeholder:'请选择支付方式',
  228. display: "bottom",
  229. onSelect: function(valueText, inst) {
  230. $('#pay').attr('data-code',inst._tempValue)
  231. $('#pay').attr('data-name',valueText)
  232. }
  233. })
  234. }
  235. function addContent4(arr) {
  236. var len = arr.length;
  237. var html = "<option disabled selected></option>";
  238. for(var i = 0; i < len; i++) {
  239. if(jiandangCase2&&jiandangCase2.disabilitys == arr[i].code){
  240. html += '<option selected value="'+arr[i].code+'">' + arr[i].value + '</option>'
  241. }else{
  242. html += '<option value="'+arr[i].code+'">' + arr[i].value + '</option>'
  243. }
  244. }
  245. $('#disabilitySel').html(html)
  246. $('#disabilitySel').mobiscroll().select({
  247. theme: "ios",
  248. lang: "zh",
  249. placeholder:'请选择残疾情况',
  250. display: "bottom",
  251. onSelect: function(valueText, inst) {
  252. $('#disability').attr('data-code',inst._tempValue)
  253. $('#disability').attr('data-name',valueText)
  254. }
  255. })
  256. }
  257. function addContent5(arr,init) {
  258. for(var i=0;i<$('.j-sel').length;i++){
  259. var $this = $('.j-sel').eq(i).find('.sickSel');
  260. var len = arr.length;
  261. var html = "<option disabled selected></option>";
  262. if(init){
  263. for(var j = 0; j < len; j++) {
  264. html += '<option value="'+arr[j].code+'">' + arr[j].value + '</option>'
  265. }
  266. $this.html(html)
  267. }else{
  268. for(var j = 0; j < len; j++) {
  269. if(jiandangCase2){
  270. if(i==0){ html += isSelFun(jiandangCase2.familyFatherHistorys,arr[j]) }
  271. if(i==1){ html += isSelFun(jiandangCase2.familyMotherHistorys,arr[j]) }
  272. if(i==2){ html += isSelFun(jiandangCase2.familyBrotherHistorys,arr[j]) }
  273. if(i==3){ html += isSelFun(jiandangCase2.familyChildrenHistorys,arr[j]) }
  274. }else{
  275. html += '<option value="'+arr[j].code+'">' + arr[j].value + '</option>'
  276. }
  277. }
  278. $this.html(html)
  279. }
  280. $this.mobiscroll().select({
  281. theme: "ios",
  282. lang: "zh",
  283. placeholder:'请选择疾病类型',
  284. display: "bottom",
  285. onSelect: function(valueText, inst) {
  286. $(this).attr('data-code',inst._tempValue)
  287. $(this).attr('data-name',valueText)
  288. }
  289. })
  290. }
  291. }
  292. function isSelFun(str,own){
  293. var bood = false;
  294. if(str){
  295. var child = str.split(',')
  296. for(var z = 0; z < child .length; z++){
  297. if(own.code == child[z]){
  298. bood = true;
  299. }
  300. }
  301. }
  302. if(!!bood){
  303. return '<option selected value="'+own.code+'">' + own.value + '</option>'
  304. }else{
  305. return '<option value="'+own.code+'">' + own.value + '</option>'
  306. }
  307. }
  308. })