美文网首页
javaScript问题解决

javaScript问题解决

作者: 山顶冻人0 | 来源:发表于2017-10-30 19:01 被阅读0次

    1.数据库是时间戳,java是dataTime,在前台显示一串数字,格式化时间

    for(var k=0;k<this.models.length;k++){
                  this.models[k].createTime = sjc(this.models[k].createTime);
                  //console.log(this.models[k].createTime);
                                }
    function sjc(sjc){
            return  new Date(sjc).toLocaleDateString().replace(/\//g, "-") + " " + new Date(sjc).toTimeString().substr(0, 8);       
            }
    

    2.解析json数据嵌套json字符串在嵌套json字符串,一共三层嵌套

     this.recipeData = recipeData;
                            for(var i=0;i<this.recipeData.length;i++){
                                  //遗留改进,消除空格
    
                                  //处理用药处方
                                  if(this.recipeData[i].prescriptionDrugContent!=""&&this.recipeData[i].prescriptionDrugContent!=null){
                                      this.recipeData[i].prescriptionDrugContent=JSON.parse(this.recipeData[i].prescriptionDrugContent);
                                  }else{
                                      this.recipeData[i].prescriptionDrugContent=[];
                                  }
                                  //处理处置处方
                                  if(this.recipeData[i].prescriptionHandleContent!=""&&this.recipeData[i].prescriptionHandleContent!=null){
                                      this.recipeData[i].prescriptionHandleContent=JSON.parse(this.recipeData[i].prescriptionHandleContent);
                                  }else{
                                      this.recipeData[i].prescriptionHandleContent=[];
                                  }
    
                                  //遍历content,处理others,因为遗留数据问题,用undefined判断是否存在others
                                  for(var x=0;x<this.recipeData[i].prescriptionDrugContent.length;x++){
                                      if(this.recipeData[i].prescriptionDrugContent[x].others!=undefined&&this.recipeData[i].prescriptionDrugContent[x].others!=""&&this.recipeData[i].prescriptionDrugContent[x].others!=null){
                                          this.recipeData[i].prescriptionDrugContent[x].others=JSON.parse(this.recipeData[i].prescriptionDrugContent[x].others)
                                      }else{
                                          this.recipeData[i].prescriptionDrugContent[x].others=[]
                                      }
                                  }
    
                                  for(var x=0;x<this.recipeData[i].prescriptionHandleContent.length;x++){
                                      if(this.recipeData[i].prescriptionHandleContent[x].others!=undefined&&this.recipeData[i].prescriptionHandleContent[x].others!=""&&this.recipeData[i].prescriptionHandleContent[x].others!=null){
                                              this.recipeData[i].prescriptionHandleContent[x].others=JSON.parse(this.recipeData[i].prescriptionHandleContent[x].others)
                                      }else{
                                          this.recipeData[i].prescriptionHandleContent[x].others=[]
                                      }
                                  }
                            }
    

    json数据

    {
      "success": true,
      "data": [
        {
          "medicalRecordsId": 507,
          "createTime": "2017-09-22 14:44:54.0",
          "doctorId": 2,
          "doctorName": "崔文勤",
          "patientId": 385,
          "patientName": "1",
          "chiefComplaintContent": "是否#@%发热咳嗽咽痛1天#@%干咳",
          "diagnosisContent": "感冒",
          "prescriptionDrugContent": "",
          "prescriptionHandleContent": "[{\"administration\":\"处置\",\"factoryAbbrNameJoinDrugName\":\"贵州六盘水制药厂葡萄糖注射液\",\"medicineId\":\"3\",\"medicineName\":\"葡萄糖注射液\",\"minimumUnitCount\":\"0\",\"minimumUnitMeasure\":\"ml\",\"minimumUnitMeasureCount\":\"100\",\"minimumUnitMeasureFinishedCount\":0,\"minimumUnitMeasurePrice\":\"3.33\",\"others\":\"{\"drugNumber\":\"\",\"drugUnit\":\"瓶\",\"drugMethod\":\"口服\",\"drugUsageMode\":\"一日1次\",\"drugEachQuantity\":\"\",\"drugEachQuantityUnit\":\"瓶\"}\",\"pacingMeasurement\":\"瓶\",\"pacingMeasurementFinishedCount\":0,\"pacingMeasurementPrice\":\"333\",\"specification\":\"100ml/瓶\"}]",
          "patientSex": "男",
          "weight": null,
          "height": null,
          "phoneNumber": "12341234123",
          "planeNumber": null,
          "birthday": "2015-01-01",
          "familyAddress": "",
          "idcard": "",
          "uniqueIdentification": "123123",
          "uniqueIdentificationType": "社保号",
          "familyInfo": "",
          "clinicId": 1,
          "allergy": "",
          "presentAddress": ""
        },
        {
          "medicalRecordsId": 518,
          "createTime": "2017-11-01 17:45:22.0",
          "doctorId": 2,
          "doctorName": "崔文勤",
          "patientId": 404,
          "patientName": "ce00",
          "chiefComplaintContent": "牙龈出血#@%呼吸困难",
          "diagnosisContent": " 类风湿性关节炎#@%中暑",
          "prescriptionDrugContent": "[{\"administration\":\"用药\",\"factoryAbbrNameJoinDrugName\":\"珠海联邦制药股份有限阿莫西林\",\"medicineId\":\"2\",\"medicineName\":\"阿莫西林\",\"minimumUnit\":\"胶囊\",\"minimumUnitCount\":\"24\",\"minimumUnitMeasure\":\"mg\",\"minimumUnitMeasureCount\":\"12000\",\"minimumUnitMeasureFinishedCount\":0,\"minimumUnitMeasurePrice\":\"0.19\",\"minimumUnitPrice\":\"93.625\",\"others\":\"{\"drugNumber\":\"\",\"drugUnit\":\"盒\",\"drugMethod\":\"口服\",\"drugUsageMode\":\"\",\"drugEachQuantity\":\"\",\"drugEachQuantityUnit\":\"片\"}\",\"pacingMeasurement\":\"盒\",\"pacingMeasurementFinishedCount\":0,\"pacingMeasurementPrice\":\"2247\",\"specification\":\"24胶囊/盒(12000mg)\"}]",
          "prescriptionHandleContent": "",
          "patientSex": "男",
          "weight": "",
          "height": "",
          "phoneNumber": "143678909788",
          "planeNumber": "",
          "birthday": "1967-01-01",
          "familyAddress": "",
          "idcard": "",
          "uniqueIdentification": "",
          "uniqueIdentificationType": "其它",
          "familyInfo": "",
          "clinicId": 1,
          "allergy": "",
          "presentAddress": ""
        }],
      "error": null
    }
    

    相关文章

      网友评论

          本文标题:javaScript问题解决

          本文链接:https://www.haomeiwen.com/subject/ersmpxtx.html