basic_info_edit.js 4.5 KB

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