import LoadParams from "./LoadParams";

/**
 * 把配置文件 数组形式 转成 Object形式
 * @param res: 数组格式得安检隐患项配置文件
 * @param number: 燃气表配置项 index 开始
 */
export var arr =
  [
    {
      "checkname": "燃气表",
      "checkmust":false,
      "items":[
        {"lname": "表具状态","multiple":false,"type":"selector","options":[{"data":"正常","isdefect":false,"isdefault": true},{"data":"包裹","isdefect":true,"level":"C2","isdefault": false,"tooltip":"1.整改时限1日，2，禁止使用，及时联系公司客服"},{"data":"漏气","isdefect":true,"level":"A1","isdefault": false,"tooltip":"1.整改时限1日，2，禁止使用，及时联系公司客服"}]},
        {"lname": "表故障","multiple":true,"type":"selector","options":[{"data":"正常","isdefect":false,"isdefault": true},{"data":"破损变形","isdefect":true,"level":"B2","isdefault": false,"tooltip":"1.整改时限1日，2，禁止使用，及时联系公司客服"},{"data":"失效","isdefect":true,"level":"B2","isdefault": false},{"data":"不走字","isdefect":true,"level":"B2","isdefault": false},{"data":"铅封损坏","isdefect":true,"level":"B2","isdefault": false},{"data":"气表到期(使用年限超过八年)","isdefect":true,"level":"B2","isdefault": false}]},
        {"lname": "腐蚀","multiple":false,"type":"selector","options":[{"data":"正常","isdefect":false,"isdefault": true},{"data":"轻微","isdefect":false,"isdefault": false},{"data":"中度","isdefect":false,"isdefault": false},{"data":"严重","isdefect":true,"level":"A2","isdefault": false,"tooltip":"1.整改时限1日，2，禁止使用，及时联系公司客服"}]},
        {"lname": "使用年限","type":"string", "data": 8,"isshow": false}
      ]
    },
    {
      "checkname": "阀门",
      "checkmust":true,
      "items":[
        {"lname": "阀门","multiple":true,"type":"selector","options":[{"data":"无阀门","isdefect":true,"level":"A2"},{"data":"无阀柄","isdefect":true,"level":"A2"},{"data":"失效","isdefect":true,"level":"A2"}]},
        {"lname": "表前阀","multiple":false,"type":"selector","options":[{"data":"正常","isdefect":false,"isdefault": true},{"data":"异常","isdefect":true,"level":"A1","isdefault": false}]},
        {"lname": "灶前阀","multiple":false,"type":"selector","options":[{"data":"正常","isdefect":false,"isdefault": true},{"data":"异常","isdefect":true,"level":"A1","isdefault": false}]},
        {"lname":"使用年限","type":"string", "data": 8,"isshow": false}
      ]
    }
]

let ObjConfig = {
  getObjConfig (arr,index) {
    var obj = {}
    var start = false
    for(var i = 0;i<arr.length;i++){
      var name = arr[i].checkname
      delete arr[i].checkname
      obj[name] = arr[i]
      if(start){
        obj[name]['index'] = index + i
      }else{
        obj[name]['index'] = i+1
      }
      if(arr[i].isstart){
        obj[name]['index'] = index
        start = true
      }
      if(arr[i].items){
        obj[name].items = this.getObjConfig(arr[i].items,index)
      }
    }
    return obj
  }


}

export default ObjConfig
