edit.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /**
  2. * Created by Zhong on 2019/12/11.
  3. */
  4. $(document).ready(function () {
  5. const locked = lockUtil.getLocked();
  6. lockUtil.lockTools($(document.body), locked);
  7. try {
  8. let tem = sortJson(JSON.parse($("#originalInfo").val()), compareInfo);
  9. $("#editValue").val(JSON.stringify(tem,null,4));
  10. }catch (err){
  11. console.log(err);
  12. }
  13. $("#format").click( function() {
  14. try {
  15. let jsonText = $("#editValue").val();
  16. $("#editValue").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. $.bootstrapLoading.start();
  25. let libID = $("#libID").val();
  26. let jsonText = $("#editValue").val();
  27. if(jsonText.indexOf("'")!=-1){
  28. alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18));
  29. return;
  30. }
  31. await ajaxPost("/overHeight/saveLib",{query:{ID:libID},data:{list:JSON.parse(jsonText)}});
  32. $.bootstrapLoading.end();
  33. }catch (err){
  34. $.bootstrapLoading.end();
  35. console.log(err);
  36. alert("保存失败,请查看输入数据");
  37. }
  38. });
  39. /*[{
  40. "name": "多层建筑物",
  41. "labourMachineName": "定额人工机械名称",
  42. "items": [{
  43. "code": "JZCG-1",
  44. "name": "20-40",
  45. "labourMachineRate": "0.0701"
  46. },{
  47. "code": "JZCG-2",
  48. "name": "40-60",
  49. "labourMachineRate": "0.1148"
  50. },{
  51. "code": "JZCG-3",
  52. "name": "60-80",
  53. "labourMachineRate": "0.1594"
  54. },{
  55. "code": "JZCG-4",
  56. "name": "80-100",
  57. "labourMachineRate": "0.2104"
  58. },{
  59. "code": "JZCG-5",
  60. "name": "100-120",
  61. "benchmark": "120",
  62. "labourMachineRate": "0.2614"
  63. },{
  64. "code": "JZCG-6",
  65. "name": "每增20m",
  66. "extra": "20",
  67. "labourMachineRate": "0.045"
  68. },{
  69. "code": "JZCG-5 + JZCG-6",
  70. "name": "120-140",
  71. "labourMachineRate": "0.3064"
  72. },{
  73. "code": "JZCG-5 + JZCG-6 * 2",
  74. "name": "140-160",
  75. "limit": "160",
  76. "labourMachineRate": "0.3514"
  77. }]
  78. }, {
  79. "name": "单层建筑物",
  80. "labourMachineName": "定额人工机械名称",
  81. "items": [{
  82. "code": "DCCG-1",
  83. "name": "30以内",
  84. "labourMachineRate": "0.025"
  85. },{
  86. "code": "DCCG-2",
  87. "name": "40以内",
  88. "labourMachineRate": "0.0374"
  89. },{
  90. "code": "DCCG-3",
  91. "name": "50以内",
  92. "labourMachineRate": "0.0544"
  93. }]
  94. }]*/
  95. $("#createNormal").click(async function() {
  96. let normalInfo = [{
  97. "code": "JZCG-1",
  98. "name": "高度增加30m",
  99. "labourRate": "0.0124",
  100. "machineRate": "0.0313"
  101. },{
  102. "code": "JZCG-2",
  103. "name": "高度增加40m",
  104. "labourRate": "0.023",
  105. "machineRate": "0.0513"
  106. },{
  107. "code": "JZCG-3",
  108. "name": "高度增加50m",
  109. "labourRate": "0.0336",
  110. "machineRate": "0.0665"
  111. },{
  112. "code": "JZCG-4",
  113. "name": "高度增加60m",
  114. "labourRate": "0.023",
  115. "machineRate": "0.0513"
  116. },{
  117. "code": "JZCG-5",
  118. "name": "高度增加70m",
  119. "labourRate": "0.0664",
  120. "machineRate": "0.1104"
  121. },{
  122. "code": "JZCG-6",
  123. "name": "高度增加80m",
  124. "labourRate": "0.0837",
  125. "machineRate": "0.1324"
  126. },{
  127. "code": "JZCG-7",
  128. "name": "高度增加90m",
  129. "labourRate": "0.1012",
  130. "machineRate": "0.1528"
  131. },{
  132. "code": "JZCG-8",
  133. "name": "高度增加100m",
  134. "benchmark": "100",
  135. "labourRate": "0.1309",
  136. "machineRate": "0.1881"
  137. },{
  138. "code": "JZCG-9",
  139. "name": "每增10m以内",
  140. "extra": "10",
  141. "labourRate": "0.0206",
  142. "machineRate": "0.0249"
  143. },{
  144. "code": "JZCG-8 + JZCG-9",
  145. "name": "高度增加110m",
  146. "labourRate": "0.1515",
  147. "machineRate": "0.213"
  148. },{
  149. "code": "JZCG-8 + JZCG-9 * 2",
  150. "name": "高度增加110m",
  151. "limit": "110",
  152. "labourRate": "0.1721",
  153. "machineRate": "0.2379"
  154. }];
  155. try {
  156. let jsonText = JSON.stringify(normalInfo);
  157. $("#editValue").val(JSON.stringify(JSON.parse(jsonText),null,4));
  158. }catch (err){
  159. console.log(err);
  160. }
  161. })
  162. });
  163. function compareInfo(a, b) {
  164. let mapping = {
  165. name: 1,
  166. labourName: 2,
  167. machineName: 3,
  168. labourMachineName: 4,
  169. items: 5,
  170. code: 6,
  171. labourRate: 7,
  172. machineRate: 8,
  173. labourMachineRate: 9
  174. };
  175. let aV = mapping[a] ? mapping[a] : 0,
  176. bV = mapping[b] ? mapping[b] : 0;
  177. return aV - bV;
  178. }