import { add } from "lodash";

const state = {
    validate: [],
    address: "",
    page: ""
}
const getters = {}

const actions = {
    linkageValidate ({ commit, state }, data) {
        setTimeout(() => {
            commit("linkageValidate", data);
        }, 100)

    },
    delValidate ({ commit, state }, data) {
        commit("delValidate", data);
    },
}

const mutations = {
    linkageValidate (state, data) {
        if (!data.validate && data.required) {
            data.validate = { "required": data.required };
        }
        state.validate.push(data);
    },
    delValidate (state, data) {
        if (data) {
            state.validate.remove(data);
        } else {
            state.validate.length = 0;
        }
    },
    addressMap (state, address) {
        state.address = address
        console.log(address);
        console.log("add调用了");
    },
    cdPage (state, page) {
        state.page = page
    }
}

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}
