export default {
  setPlanList(state, planList) {
    planList.forEach((planId) => {
      if(!state.planList.some(p => p.id == planId)) {
        let plan = {};
        plan.id = planId;
        plan.checked = false;
        plan.carline = [];
        plan.case_list = [109, 110, 111, 112, 113]
        plan.cluster = 1
        plan.create_time = ""
        plan.creator = ""
        plan.delete_flag = 0
        plan.description = ""
        plan.function = [1, 2]
        plan.language = [1, 2]
        plan.level = [1, 2]
        plan.market = [1, 2]
        plan.name = ""
        plan.platform = [1, 2]
        plan.project = [1, 2]
        plan.sub_function = [1, 2]
        plan.update_time = ""
        plan.uuid = ""
        state.planList.push(plan)
      }
    });
  },
  setMaualPlanList(state, planList) {
    let maualPlanList = state.planList;
    maualPlanList.forEach(p => {
      let plan = planList.find(s => s.id == p.id);
      if (plan) {
        for(let key in p) {
          p[key] = plan[key];
        }
      }
      
    })
  },
  setAutoPlanList(state, planList) {
    planList.forEach((planId) => {
      if(!state.autoPlanList.some(p => p.id == planId)) {
        let plan = {}
        plan.id = planId < 100 ? planId + 101 : planId;
        plan.checked = false;
        plan.active_time = null
        plan.active_user = null
        plan.case_quantity = 5
        plan.comment = null
        plan.create_time = "2023-04-21T06:55:18.403Z"
        plan.create_user = "testserver@audi.com.cn"
        plan.create_user_name = "testserver@audi.com.cn"
        plan.description =  ""
        plan.is_delete = 1
        plan.lastrun_time = null
        plan.modify_time =  null
        plan.modify_user = null
        plan.modify_user_name = null
        plan.name = "testplan"
        plan.repeats =  ["1", "1", "1", "1", "1"]
        plan.repository = "repo3"
        plan.skips = ["not", "not", "not", "not", "not"]
        plan.skips_count = 0
        plan.task_array = null
        plan.task_quantity = null
        plan.testcase_array = [2863, 2824, 2915, 2820, 2722]
        plan.type = null
        plan.auto = true;
        state.autoPlanList.push(plan)
      }
    });
  },
  setAutoPlanDetail(state, planDetail) {
    planDetail = planDetail.data;
    let id = planDetail.id;
    let detail = state.autoPlanList.find(p => p.id == id);
    if (detail) {
      for (let key in planDetail) {
        detail[key] = planDetail[key];
      }
    }
  },
  setTaskList(state, taskList) {
    taskList.forEach((task) => {
      if(!state.taskList.some(p => p.id == task.id)) {
        task.checked = false;
        state.taskList.push(task)
      }
    });
  },
};