index.js 1.96 KB
export default {
  namespaced: true,
  state: {
    goodsSource: [], // 财务商品来源
    goodsSourceReconciliation: [] // 对账
  },
  mutations: {
    /**
     * @description 合计商品来源
     * @param {Object} goodsSource 商品来源
     * @param {Boolean} tabIndex  tab索引
     */
    setGoodsSource(state, { goodsSource, tabIndex }) {
      // console.log("setGoodsSource", goodsSource, tabIndex, state)
      if (goodsSource) {
        state.goodsSource[tabIndex] = goodsSource
        state.goodsSource = [...state.goodsSource]
      }
    },
    /**
     * @description 删除商品来源
     * @param {Object} goodsSource 商品来源
     * @param {Boolean} tabIndex  tab索引
     */
    delGoodsSource(state, { goodsSource, tabIndex }) {
      state.goodsSource = state.goodsSource.splice(1, tabIndex)
    },
    /**
     * @description 合计对账商品来源
     * @param {Object} goodsSource 商品来源
     * @param {Boolean} tabIndex  tab索引
     */
    setGoodsSourceReconciliation(state, { goodsSource, tabIndex }) {
      // console.log("setGoodsSource", goodsSource, tabIndex, state)
      if (goodsSource) {
        state.goodsSourceReconciliation[tabIndex] = goodsSource
        state.goodsSourceReconciliation = [...state.goodsSourceReconciliation]
      }
    },
    /**
     * @description 删除对账商品来源
     * @param {Object} goodsSource 商品来源
     * @param {Boolean} tabIndex  tab索引
     */
    delGoodsSourceReconciliation(state, { goodsSource, tabIndex }) {
      state.goodsSourceReconciliation = state.goodsSourceReconciliation.splice(
        1,
        tabIndex
      )
    }
  },
  actions: {},
  getters: {
    // 财务商品来源去重
    goodsSourceSet(state) {
      return [...new Set(state.goodsSource)]
    },
    // 对账商品来源去重
    goodsSourceReconciliationSet(state) {
      return [...new Set(state.goodsSourceReconciliation)]
    }
  }
}