import { getStore, removeStore, setStore } from '@/util/store'
import { listData ,getDicts} from '@/api/system/dict/data'


const dict = {
  state: {
    paytypelist: getStore({ name: 'paytypelist' }) || [], //支付方式
    tooltypelist: getStore({ name: 'tooltypelist' }) || [], //工具类型
    testtypelist: getStore({ name: 'testtypelist' }) || [], //测试类型
    feescopelist: getStore({ name: 'feescopelist' }) || [], //金额范围
  },
  actions: {
    SET_KEYSAASDICT({commit})  {
      getDicts('sys_pay_type').then(res=>{
        // console.log('支付方式：',res)
        commit("SET_PAYTYPE", res.data);      
      })
      getDicts('sys_tool_type').then(res=>{
        // console.log('工具类型',res)
        commit("SET_TOOLTYPE", res.data);
      })
      getDicts('sys_test_type').then(res=>{
        commit("SET_TESTTYPE", res.data);
      })
      getDicts('sys_fee_scope').then(res=>{
        commit("SET_FEESCOPE", res.data);
      })
    },
  },
  mutations:{
    SET_PAYTYPE: (state, paytypelist) => {
      state.paytypelist = paytypelist
      setStore({
        name: 'paytypelist',
        content: state.paytypelist,
      })
    },
    SET_TOOLTYPE: (state, tooltypelist) => {
      state.tooltypelist = tooltypelist
      setStore({
        name: 'tooltypelist',
        content: state.tooltypelist,
      })
    },
    SET_TESTTYPE: (state, testtypelist) => {
      state.testtypelist = testtypelist
      setStore({
        name: 'testtypelist',
        content: state.testtypelist,
      })
    },
    SET_FEESCOPE: (state, feescopelist) => {
      state.feescopelist = feescopelist
      setStore({
        name: 'feescopelist',
        content: state.feescopelist,
      })
    },
  }
}

export default dict
