import db from "../plugins/db";

export default {
  methods: {
    async initScanArea(subjects) {
      const storeScanArea = await db.getDict("scanArea", {});
      let newScanArea = {};
      subjects.map(subject => {
        let info = { ...subject };
        if (
          storeScanArea[subject.id] &&
          storeScanArea[subject.id].collectConfig
        )
          info.collectConfig = storeScanArea[subject.id].collectConfig;

        newScanArea[subject.id] = info;
      });
      this.$store.commit("client/setScanArea", newScanArea);
    },
    async initStore() {
      const curDate = this.$store.state.client.startCountTime;
      const scanNo = await db.countScanList(curDate);
      const uploadNo = await db.getUploadCount(curDate);

      this.$store.commit("client/setScanNo", scanNo);
      this.$store.commit("client/setUploadNo", uploadNo);
    }
  }
};
