export default {

  state:{
    count: '0',
    fileDownloads: [],
    step:0,
    tempText:'新建模版',
    templateVal:'',
    templateId:'',
    imageSrc:'',
  },

  mutations: {
    updateImageSrc(state,val){
      state.imageSrc = val;
    },
    changeStep(state,val){
      state.step = val;
    },
    changeTempText(state,val){
      state.tempText = val;
    },
    changeTemplate(state,val){
      state.templateVal = val;
    },
    changeTemplateId(state,val){
      state.templateId = val;
    },
    /**
     * 添加下载次数和下载文件
     * @param {*} state 
     * @param {*} item 
     */
    addCount(state, item) {
      state.fileDownloads.push(item);
      var i = 0;
      state.fileDownloads.forEach(function (item1) {
        if (item1.status == '') {
          i++;
        }
      });
      state.count = i;
    },

    /**
     * 修改下载次数和文件下载状态
     * @param {*} state 
     * @param {*} item 
     */
    updateCount(state, item) {
      var i = 0;
      state.fileDownloads.forEach(function (item1) {
        if (item1.taskId == item.taskId) {
          item1.status = item.status;
        }
        if (item1.status == '') {
          i++;
        }
      });
      state.count = i;
    },
  },

  actions: {},

  getters: {},
};