const state = {
  industryAttrList:[], //行业属性 即 左边供选择的属性
  checkedAttrIdLst: [], //选中属性的Id
  settingAttrId: null, //当前正在配置的属性Id
  checkedAttrConfig:{
    scope:null,//属性应用范围  1 基本属性 2：专属属性
    channelCodeList:[],//TM,JD
    attrNameAlias:null,
    require:false,
    select:null, //输入；选择；复杂
    type:0, // 【单行输入 、多行属性】；【单选、多选】；【单复杂 | 多复杂】
    cascade: false , //是否级联属性
    checkedAttrValIds:[],//选中的属性值ID集合
    checkedValues:[], //选中的属性对象列表
    values:[], //所有的属性值 - select 为 1 时有值
  }
};

const mutations = {
  SET_INIT_DATA(){
	  state.industryAttrList = [];
    state.checkedAttrIdLst=[];
    state.settingAttrId = null;

    state.checkedAttrConfig.scope = null;
    state.checkedAttrConfig.channelCodeList = [];
    state.checkedAttrConfig.name = null;
    state.checkedAttrConfig.attrNameAlias = null;
    state.checkedAttrConfig.require = false;
    state.checkedAttrConfig.select = null;
    state.checkedAttrConfig.type = null;
    state.checkedAttrConfig.cascade = false;
    state.checkedAttrConfig.checkedAttrValIds = [];
    state.checkedAttrConfig.checkedValues = [];
    state.checkedAttrConfig.values = [];
	},
  SET_INDUSTRY_ATTRS(state,industryAttrList){
    state.industryAttrList = industryAttrList;
  },
  SET_CHECKED_ATTR_IDS(state,checkAttrIds){
  	state.checkedAttrIdLst = checkAttrIds;
  },
  SET_CURR_ATTR_ID(state,attrId){ //当前操作的属性ID
    state.settingAttrId = attrId;
  },
  SET_CHECKED_CONFIG(state,config){
	  state.checkedAttrConfig = config;
  }
};

const actions = {
  setInitData({ commit }, data) {
    commit('SET_INIT_DATA',data );
  },
  setIndustryAttrList({ commit }, data) {
    commit('SET_INDUSTRY_ATTRS', data);
  },
  setCheckedAttrIds({ commit }, data) {
    commit('SET_CHECKED_ATTR_IDS', data);
  },
  setCurrAttrId({ commit }, data) {
    commit('SET_CURR_ATTR_ID',data);
  },
  setCheckedConfig({ commit}, data) {
    commit('SET_CHECKED_CONFIG',data);
  },
};
export default {
  state,
  mutations,
  actions
}
