popupEdit.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. const {post,config} = require('./promise.js');
  2. const $ = require("jquery");
  3. function bindTipsEvent() {
  4. $(".conditTips").on('click',".radioChecks",function(e){
  5. const isShow = $(this).parent().attr("data-isShow")
  6. if(isShow == '0') {
  7. return;
  8. }
  9. e.stopPropagation()
  10. $(this).attr("data-select","select").children("i").css({
  11. "background":"url('../images/sex2.png') center center no-repeat"
  12. })
  13. $(this).siblings().attr("data-select","").children("i").css("background","url('../images/sex1.png') center center no-repeat")
  14. })
  15. $(".conditTips").on('click',".closeModal",function(e){
  16. e.stopPropagation()
  17. $(this).parents(".popupModal").css("display","none")
  18. })
  19. $(".conditTips").on('click',".popupModal",function(e){
  20. e.stopPropagation()
  21. })
  22. $(".conditTips").on('click',".mayResultSelect",function(){
  23. $(".popupModal").css('display',"none")
  24. $(this).children(".popupModal").css('display',"block")
  25. var that = $(this);
  26. var numFlg = $(this).attr("data-num")
  27. var tmpMoadlData = window.pushMessage[numFlg]
  28. for(var i = 0;i<tmpMoadlData.details.length;i++){
  29. var tmpPushMsgDetail = tmpMoadlData.details[i]
  30. if(tmpPushMsgDetail.type == 2){
  31. for(var m = 0;m < tmpPushMsgDetail.content.details.length;m++){
  32. var tmpPushMsgDetailContentVal = tmpPushMsgDetail.content.details[m]
  33. if(that.find(".makesureResult").html() != '请选择'){
  34. if(tmpPushMsgDetailContentVal.controlType == 0){
  35. var domList = that.find(".caculateLis").children("li")
  36. for(var n =0;n < tmpPushMsgDetailContentVal.details.length;n++){
  37. if(tmpPushMsgDetailContentVal.details[n].state == 1){
  38. domList.eq(n).attr("data-select","select").children("i").css({
  39. "background":"url('../images/sex2.png') center center no-repeat"
  40. })
  41. }
  42. if(tmpPushMsgDetailContentVal.details[n].state == 0){
  43. domList.eq(n).attr("data-select","").children("i").css({
  44. "background":"url('../images/sex1.png') center center no-repeat"
  45. })
  46. }
  47. }
  48. }
  49. if(tmpPushMsgDetailContentVal.controlType == 2){
  50. var domLis = that.find("input[type=text]").eq(m)
  51. $(domLis).val(tmpPushMsgDetailContentVal.value)
  52. }
  53. }
  54. }
  55. }
  56. if(tmpPushMsgDetail.type == 3 && that.find(".sureScore").attr("data-type") == 3){
  57. for(var a = 0;a < tmpPushMsgDetail.content.details.length;a++){
  58. var tmpPushMsgDetailContentValS = tmpPushMsgDetail.content.details[a]
  59. var domLi = that.find(".radioChecks")
  60. for(var b = 0;b <domLi.length;b++){
  61. if(that.find(".makesureResult").html() == tmpPushMsgDetailContentValS.detailName){
  62. domLi.eq(a).attr("data-select","select").children("i").css({
  63. "background":"url('../images/sex2.png') center center no-repeat"
  64. })
  65. }else{
  66. domLi.eq(a).attr("data-select","").children("i").css({
  67. "background":"url('../images/sex1.png') center center no-repeat"
  68. })
  69. }
  70. }
  71. }
  72. }
  73. }
  74. })
  75. $(".conditTips").on('click',".sureScore",function(e){
  76. e.stopPropagation()
  77. if($(this).attr("data-type") == 3){
  78. var tempVal = $(this).parents(".mayResultSelect").find(".radioChecks[data-select='select'] span").html()
  79. tempVal && $(this).parents(".mayResultSelect").find(".makesureResult").html(tempVal)
  80. }
  81. $(this).parents(".popupModal").css('display',"none")
  82. })
  83. $(".conditTips").on('click','.calculate',function(e){
  84. e.stopPropagation()
  85. var that = $(this)
  86. var numFlg = that.attr("data-num")
  87. var tmpMoadlData = window.pushMessage[numFlg]
  88. var paramsJson = {}
  89. var resultParams = {}
  90. for(var i = 0;i<tmpMoadlData.details.length;i++){
  91. var tmpPushMsgDetail = tmpMoadlData.details[i]
  92. if(tmpPushMsgDetail.type == 2){
  93. var tmpDetailArr = []
  94. paramsJson = tmpPushMsgDetail;
  95. for(var m = 0;m < tmpPushMsgDetail.content.details.length;m++){
  96. var tmpPushMsgDetailContentVal = tmpPushMsgDetail.content.details[m]
  97. if(tmpPushMsgDetailContentVal.controlType == 0){
  98. var domList = that.parent(".modalMainTwo").find(".caculateLis").children("li")
  99. for(var n =0;n < domList.length;n++){
  100. if($(domList[n]).attr("data-select")){
  101. tmpPushMsgDetailContentVal.details[n].state = 1
  102. }else{
  103. tmpPushMsgDetailContentVal.details[n].state = 0
  104. }
  105. }
  106. }
  107. if(tmpPushMsgDetailContentVal.controlType == 2&&tmpPushMsgDetailContentVal.isShow !='0'){
  108. tmpPushMsgDetailContentVal.value = $('.'+paramsJson.content.name+tmpPushMsgDetailContentVal.name).val()
  109. }
  110. tmpDetailArr.push(tmpPushMsgDetailContentVal)
  111. }
  112. resultParams.type = paramsJson.type
  113. resultParams.data = paramsJson
  114. }
  115. }
  116. for(var s = 0;s < paramsJson.content.details.length;s++){
  117. var hasSelect = false
  118. if(paramsJson.content.details[s].controlType == 0) {
  119. for(let i = 0; i < paramsJson.content.details[s].details.length; i++) {
  120. if(paramsJson.content.details[s].details[i].state == '1') {
  121. hasSelect = true
  122. }
  123. }
  124. }
  125. if(paramsJson.content.details[s].controlType == 2 && paramsJson.content.details[s].value == ''|| paramsJson.content.details[s].controlType == 0 && !hasSelect){
  126. that.parent().find(".calculateError").css("display","block");
  127. that.parent().find(".calculateResult").html('');
  128. return;
  129. }
  130. }
  131. post(config.calculate,resultParams).then((res)=>{
  132. var data = res.data
  133. if(data.code == 0){
  134. var result = data.data;
  135. var tmpName = that.parent().find(".calculateName");
  136. var deepDetailResultStr = '';
  137. for(var v = 0;v < result.result.length;v++){
  138. var name = result.result[v].name
  139. var text = result.result[v].text
  140. deepDetailResultStr+='<p class="result"><span class="calculateName">'+name+':</span><span class="calculateResult">'+text+'</span></p>'
  141. }
  142. $('.resultLis').html(deepDetailResultStr)
  143. if($(".sureScore").attr("data-type") == 2){
  144. var tmpVal = that.parents(".mayResultSelect").find(".calculateResult:last").html()
  145. tmpVal && that.parents(".mayResultSelect").find(".makesureResult").html(tmpVal)
  146. }
  147. that.parent().find(".calculateError").css("display","none")
  148. }else{
  149. that.parent().find(".calculateError").html(data.msg).css("display","block")
  150. that.parent().find(".calculateResult").html('')
  151. }
  152. })
  153. })
  154. }
  155. module.exports = {
  156. bindTipsEvent
  157. }