export default {
  props: {
  },
  data() {
    return {
    }
  },
  created() {
  },
  computed: {
  },
  watch: {
  },
  filters: {
  },
  methods: {
    mapDistriction(str) {
      if (typeof str == "number") {
        return str
      }
      if (!str) {
        return "温州市";
      }
      if (str == "330301000000") {
        return "市辖区";
      }
      if (str == "330302000000") {
        return "鹿城区";
      }
      if (str == "330303000000") {
        return "龙湾区";
      }
      if (str == "330304000000") {
        return "瓯海区";
      }
      if (str == "330305000000") {
        return "洞头县";
      }
      if (str == "330324000000") {
        return "永嘉县";
      }
      if (str == "330326000000") {
        return "平阳县";
      }
      if (str == "330327000000") {
        return "苍南县";
      }
      if (str == "330328000000") {
        return "文成县";
      }
      if (str == "330329000000") {
        return "泰顺县";
      }
      if (str == "330381000000") {
        return "瑞安市";
      }
      if (str == "330382000000") {
        return "乐清市";
      }
      //丽岙
      if (str == "330304109001") {
        return "下川村";
      }
      if (str == "330304109002") {
        return "王宅村";
      }
      if (str == "330304109003") {
        return "丽塘村";
      }
      if (str == "330304109004") {
        return "泊岙村";
      }
      if (str == "330304109005") {
        return "姜宅村";
      }
      if (str == "330304109006") {
        return "曹建村";
      }
      if (str == "330304109007") {
        return "下嶂村";
      }
      if (str == "330304109008") {
        return "林山村";
      }
      if (str == "330304109009") {
        return "梓上村";
      }
      if (str == "330304109010") {
        return "上胜村";
      }
      if (str == "330304109011") {
        return "后东村";
      }
      if (str == "330304109012") {
        return "路溪村";
      }
      if (str == "330304109013") {
        return "梓河村";
      }
      if (str == "330304109014") {
        return "后中村";
      }
      if (str == "330304109015") {
        return "河头村";
      }
      if (str == "330304109016") {
        return "上坦村";
      }
      if (str == "330304109017") {
        return "叶宅村";
      }
      if (str == "330304109018") {
        return "任宅村";
      }
      if (str == "330304109019") {
        return "杨宅村";
      }
      if (str == "330304109020") {
        return "茶堂村";
      }
      if (str == "330304109021") {
        return "下呈村";
      } else return "";
    },
    mapDict(str) {
      const codeDict = {
        "市辖区": "330301000000",
        "鹿城区": "330302000000",
        "龙湾区": "330303000000",
        "瓯海区": "330304000000",
        "洞头县": "330305000000",
        "永嘉县": "330324000000",
        "平阳县": "330326000000",
        "苍南县": "330327000000",
        "文成县": "330328000000",
        "泰顺县": "330329000000",
        "瑞安市": "330381000000",
        "乐清市": "330382000000",
        "景山街道": 330304001000,
        "梧田街道": 330304002000,
        "南白象街道": 330304003000,
        "茶山街道": 330304004000,
        "娄桥街道": 330304005000,
        "新桥街道": 330304006000,
        "三垟街道": 330304007000,
        "瞿溪街道": 330304008000,
        "郭溪街道": 330304009000,
        "潘桥街道": 330304010000,
        "丽岙街道": 330304000000,//330304011000
        "仙岩街道": 330304012000,
        "泽雅镇": 330304108000,
      }
      for (let key in codeDict) {
        if (str == key) {
          return String(codeDict[key])
        }
        if (str == String(codeDict[key])) {
          return key
        }
        else {
          if (!str) {
            return "温州市"
          }
        }
      }
    },
    mapCode(str) {
      return str + "000000"
    },
    diseaseDict(str,mode) {
      let codeDict = {}
      if(mode=="chronic"){
        codeDict = {
          "癌症诊断数":"cancerCount",
          "慢病数量":"chronicCount",
          "其他疾病":"otherLesionsCount",
          "hp阳性数":"hpPositivityCount"
        }
      }
      else{
        codeDict = {
          "低级别食管粘膜上皮内瘤变": "lowIntraCarcinomaCount",
          "高级别食管粘膜上皮内瘤变": "highIntraCarcinomaCount",
          "早期食管癌": "earlyEsophagealCancerCount",
          "进展期食管癌": "advancedEsophagealCancerCount",
          "Barret食管": "barretEsophagealCount",
          "反流性食管炎": "refluxEsophagealCancerCount",
          "低级别胃粘膜上皮内瘤变": "lowGastricNeoplasiaCount",
          "高级别胃粘膜上皮内瘤变": "highGastricNeoplasiaCount",
          "早期胃癌": "earlyGastricCancerCount",
          "进展性胃癌": "advancedGastricCancerCount",
          "萎缩性胃炎": "atrophicGastritisCount",
          "胃溃疡": "gastricUlcerCount",
          "胃息肉": "gastricPolypsCount",
          "非萎缩性胃炎": "nonatrophicGastritisCount",
          "十二指肠球部溃疡": "duodenalBulbarUlcerCount",
          "其他病变": "otherLesionsCount",
        }
      }  
      for (let key in codeDict) {
        if (str == key) {
          return String(codeDict[key])
        }
        if (str == String(codeDict[key])) {
          return key
        }
        else {
          if (!str) {
            return "暂无疾病"
          }
        }
      }
    },
    toArray(obj, mode) {
      let arr = [];
      for (let key in obj) {
        // if (!mode) {
          arr.push({
            name: this.diseaseDict(key,mode), // label 字段
            value: obj[key], // value字段
          });
        // }
        // else {

        // }
      }
      return arr;
    },
    toPercent(str) {
      if (str.indexOf("%") > 0) {
        str = str.replace("%", "");
        return str;
      }
    },
    toSpot(n) {
      var b = parseInt(n).toString();
      var len = b.length;
      if (len <= 3) {
        return b;
      }
      var r = len % 3;
      return r > 0
        ? b.slice(0, r) + "," + b.slice(r, len).match(/\d{3}/g).join(",")
        : b.slice(r, len).match(/\d{3}/g).join(",");
    },
    toNumber(str) {
      if (str.indexOf("%") > 0) {
        str = str.replace("%", "");
        str = parseFloat(str / 100).toFixed(3);

        return str;
      }
    },
    toFit(num) {
      if (typeof num == "undefined" || typeof num == "object") {
        return "--";
      } else {
        if (typeof num == "number") {
          return num;
        } else {
          if (num == "100.00%") {
            return "100%";
          }
          if (num == "0.00%") {
            return "0%";
          }
          return num;
        }
      }
    },
  }
}
