basic_info_edit.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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($("#originalInfo").val()), compareInfo);
  9. $("#basicInfoList").val(JSON.stringify(tem,null,4));
  10. }catch (err){
  11. console.log(err);
  12. }
  13. $("#format").click( function() {
  14. try {
  15. let jsonText = $("#basicInfoList").val();
  16. $("#basicInfoList").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 = $("#basicInfoList").val();
  27. if(jsonText.indexOf("'")!=-1){
  28. alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18));
  29. return;
  30. }
  31. await ajaxPost("/basicInfo/saveLib",{query:{ID:libID},data:{info:JSON.parse(jsonText)}});
  32. $.bootstrapLoading.end();
  33. }catch (err){
  34. $.bootstrapLoading.end();
  35. console.log(err);
  36. alert("保存失败,请查看输入数据");
  37. }
  38. });
  39. $("#createNormal").click(async function() {
  40. let basicInfo = [
  41. {dispName: '基本信息', key: 'basicInfo', readOnly: true, items: [
  42. {dispName: '合同号', key: 'contractNum', value: ''},
  43. {dispName: '建设地点', key: 'constructionPlace', value: ''},
  44. {dispName: '质量标准', key: 'qualityStandard', value: ''},
  45. {dispName: '工程类别', key: 'projectCategory', value: ''},
  46. {dispName: '建设日期', key: 'constructionDate', cellType: 'date', value: ''},
  47. {dispName: '工程规模', key: 'projectScale', value: ''},
  48. {dispName: '总建筑面积(m2)', key: 'grossArea', cellType: 'number', value: ''},
  49. {dispName: '建设单位', key: 'constructionUnit', value: ''},
  50. {dispName: '设计单位', key: 'designUnit', value: ''},
  51. {dispName: '施工单位', key: 'buildingUnit', value: ''},
  52. {dispName: '监理单位', key: 'supervisingUnit', value: ''},
  53. {dispName: '审核单位', key: 'auditUnit', value: ''},
  54. {dispName: '建设单位审核人', key: 'constructionUnitAudit', value: ''},
  55. {dispName: '设计单位负责人', key: 'designUnitPrincipal', value: ''},
  56. {dispName: '施工单位编制人', key: 'buildingUnitAuthor', value: ''},
  57. {dispName: '监理单位审核人', key: 'supervisingUnitAuditor', value: ''},
  58. {dispName: '审核单位审核人', key: 'auditUnitAuditor', value: ''},
  59. {dispName: '编制时间', key: 'establishDate', cellType: 'date', value: ''}
  60. ]},
  61. {dispName: '招标信息', key: 'biddingInfo', readOnly: true, items: [
  62. {dispName: '招标人', key: 'bidInviter', value: ''},
  63. {dispName: '法定代表人或其他授权人', key: 'tenderRepresentative', value: ''},
  64. {dispName: '造价工程师', key: 'tenderCostEngineer', value: ''}
  65. ]},
  66. {dispName: '投标信息', key: 'bidInfo', readOnly: true, items: [
  67. {dispName: '投标人', key: 'bidder', value: ''},
  68. {dispName: '法定代表人或其授权人', key: 'representative', value: ''},
  69. {dispName: '造价工程师', key: 'bidCostEngineer', value: ''}
  70. ]},
  71. {dispName: '工程造价咨询信息', key: 'engineeringCostConsultationInfo', readOnly: true, items: [
  72. {dispName: '工程造价咨询人', key: 'consultRepresentative', value: ''},
  73. {dispName: '法定代表人或其授权人', key: 'representative', value: ''},
  74. {dispName: '造价工程师', key: 'consultCostEngineer', value: ''}
  75. ]}
  76. ];
  77. try {
  78. let jsonText = JSON.stringify(basicInfo);
  79. $("#basicInfoList").val(JSON.stringify(JSON.parse(jsonText),null,4));
  80. }catch (err){
  81. console.log(err);
  82. }
  83. })
  84. });
  85. function compareInfo(a, b) {
  86. let mapping = {
  87. dispName: 1,
  88. key: 2,
  89. cellType: 3,
  90. readOnly: 4,
  91. required: 5,
  92. value: 6,
  93. options: 7,
  94. items: 8
  95. };
  96. let aV = mapping[a] ? mapping[a] : 0,
  97. bV = mapping[b] ? mapping[b] : 0;
  98. return aV - bV;
  99. }