edit.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. "name": "不计算"
  98. },
  99. {
  100. "name": "高度增加20m"
  101. },{
  102. "code": "JZCG-1",
  103. "name": "高度增加30m",
  104. "unit": "元",
  105. "labourRate": "0.0124",
  106. "machineRate": "0.0313"
  107. },{
  108. "code": "JZCG-2",
  109. "name": "高度增加40m",
  110. "unit": "元",
  111. "labourRate": "0.023",
  112. "machineRate": "0.0513"
  113. },{
  114. "code": "JZCG-3",
  115. "name": "高度增加50m",
  116. "unit": "元",
  117. "labourRate": "0.0336",
  118. "machineRate": "0.0665"
  119. },{
  120. "code": "JZCG-4",
  121. "name": "高度增加60m",
  122. "unit": "元",
  123. "labourRate": "0.023",
  124. "machineRate": "0.0513"
  125. },{
  126. "code": "JZCG-5",
  127. "name": "高度增加70m",
  128. "unit": "元",
  129. "labourRate": "0.0664",
  130. "machineRate": "0.1104"
  131. },{
  132. "code": "JZCG-6",
  133. "name": "高度增加80m",
  134. "unit": "元",
  135. "labourRate": "0.0837",
  136. "machineRate": "0.1324"
  137. },{
  138. "code": "JZCG-7",
  139. "name": "高度增加90m",
  140. "unit": "元",
  141. "labourRate": "0.1012",
  142. "machineRate": "0.1528"
  143. },{
  144. "code": "JZCG-8",
  145. "name": "高度增加100m",
  146. "unit": "元",
  147. "benchmark": "100",
  148. "labourRate": "0.1309",
  149. "machineRate": "0.1881"
  150. },{
  151. "code": "JZCG-9",
  152. "name": "每增10m以内",
  153. "unit": "元",
  154. "extra": "10",
  155. "labourRate": "0.0206",
  156. "machineRate": "0.0249"
  157. },{
  158. "code": "JZCG-8 + JZCG-9",
  159. "name": "高度增加110m",
  160. "unit": "元",
  161. "labourRate": "0.1515",
  162. "machineRate": "0.213"
  163. },{
  164. "code": "JZCG-8 + JZCG-9 * 2",
  165. "name": "高度增加110m",
  166. "unit": "元",
  167. "limit": "110",
  168. "labourRate": "0.1721",
  169. "machineRate": "0.2379"
  170. }];
  171. try {
  172. let jsonText = JSON.stringify(normalInfo);
  173. $("#editValue").val(JSON.stringify(JSON.parse(jsonText),null,4));
  174. }catch (err){
  175. console.log(err);
  176. }
  177. })
  178. });
  179. function compareInfo(a, b) {
  180. let mapping = {
  181. name: 1,
  182. labourName: 2,
  183. machineName: 3,
  184. labourMachineName: 4,
  185. items: 5,
  186. code: 6,
  187. labourRate: 7,
  188. machineRate: 8,
  189. labourMachineRate: 9
  190. };
  191. let aV = mapping[a] ? mapping[a] : 0,
  192. bV = mapping[b] ? mapping[b] : 0;
  193. return aV - bV;
  194. }