monomer_template_edit.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * Created by zhang on 2018/9/3.
  3. */
  4. $(document).ready(function () {
  5. const locked = lockUtil.getLocked();
  6. lockUtil.lockTools($(document.body), locked);
  7. try {
  8. let tem = sortJson(JSON.parse($("#originalFeature").val()));
  9. $("#templateLibs").val(JSON.stringify(tem.data,null,4));
  10. }catch (err){
  11. console.log(err);
  12. }
  13. $("#format").click( function() {
  14. try {
  15. let jsonText = $("#templateLibs").val();
  16. $("#templateLibs").val(JSON.stringify(JSON.parse(jsonText),null,4));
  17. }catch (err){
  18. console.log(err);
  19. alert("输入的JSON格式有误,请重新输入!");
  20. }
  21. });
  22. $("#save").click(async function() {
  23. try {
  24. let libID = $("#libID").val();
  25. let jsonText = $("#templateLibs").val();
  26. if(jsonText.indexOf("'")!=-1){
  27. alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18));
  28. return;
  29. }
  30. let newFeature = await ajaxPost("/monomerTemplate/saveLib",{query:{ID:libID},data:{data:JSON.parse(jsonText)}});
  31. }catch (err){
  32. console.log(err);
  33. alert("保存失败,请查看输入数据");
  34. }
  35. });
  36. $("#createNormal").click(()=>{
  37. $("#createNormal").click(async function() {
  38. let explorer =[
  39. {
  40. "dispName": "学校",
  41. "items": [
  42. {
  43. "dispName": "教学楼",
  44. "isHaveStructuralSegment": "true",
  45. "key": "academicBuilding",
  46. "monomerType": "building"
  47. },
  48. {
  49. "dispName": "体育馆",
  50. "isHaveStructuralSegment": "true",
  51. "key": "gymnasium",
  52. "monomerType": "building"
  53. },
  54. {
  55. "dispName": "食堂",
  56. "isHaveStructuralSegment": "true",
  57. "key": "Canteen",
  58. "monomerType": "building"
  59. },
  60. {
  61. "dispName": "集体宿舍",
  62. "isHaveStructuralSegment": "true",
  63. "key": "collectiveDormitory",
  64. "monomerType": "building"
  65. }
  66. ],
  67. "key": "school"
  68. },
  69. {
  70. "dispName": "医院",
  71. "items": [
  72. {
  73. "dispName": "门诊楼",
  74. "isHaveStructuralSegment": "true",
  75. "key": "outpatientBuilding",
  76. "monomerType": "building"
  77. },
  78. {
  79. "dispName": "住院楼",
  80. "isHaveStructuralSegment": "true",
  81. "key": "inpatientBuilding",
  82. "monomerType": "building"
  83. },
  84. {
  85. "dispName": "集体宿舍",
  86. "isHaveStructuralSegment": "true",
  87. "key": "collectiveDormitory",
  88. "monomerType": "building"
  89. }
  90. ],
  91. "key": "hospital"
  92. },
  93. {
  94. "dispName": "市政工程",
  95. "items": [
  96. {
  97. "dispName": "新建改建扩建",
  98. "isHaveStructuralSegment": "true",
  99. "key": "newConstruction",
  100. "monomerType": "civil"
  101. },
  102. {
  103. "dispName": "景观提升",
  104. "isHaveStructuralSegment": "true",
  105. "key": "landscapeImprovement",
  106. "monomerType": "civil"
  107. },
  108. {
  109. "dispName": "养护大中修",
  110. "isHaveStructuralSegment": "true",
  111. "key": "curing",
  112. "monomerType": "civil"
  113. },
  114. {
  115. "dispName": "小修保养",
  116. "isHaveStructuralSegment": "true",
  117. "key": "routineMaintenance",
  118. "monomerType": "civil"
  119. }
  120. ],
  121. "key": "municipalConstruction"
  122. }
  123. ];
  124. try {
  125. let jsonText = JSON.stringify(explorer);
  126. $("#templateLibs").val(JSON.stringify(JSON.parse(jsonText),null,4));
  127. }catch (err){
  128. console.log(err);
  129. }
  130. })
  131. })
  132. });