export default {
	namespaced: true,
	state: {},
	mutations: {
		SET_DICT: (state, data) => {
			state[data.dictType] = data.data
		},
	},
	actions: {
		getDicts(store, { dictType , customFlag }) {
			if (store.rootGetters.ccbModel && customFlag) {
				// 建行催收
				if (["debt_contact_relation", "debt_phone_type","debt_negotiation_type"].includes(dictType)) {
					dictType = dictType + "_ccb";
				}
			}
			return new Promise((resolve) => {
				if (store.state[dictType]) {
					resolve(store.state[dictType])
				} else {
					uni.$u.api.getDicts(dictType).then(res => {
						store.commit('SET_DICT', {
							dictType,
							data: res.data
						});
						resolve(res.data)
					})
				}
			});
		},
	}
}