import { defineStore } from "pinia";
import moment from "moment";
const useMapLog = defineStore('mapLog',{
    state: ()=>({
      exitContent:[

      ]
    }),
    actions: {
      addContent(data){
        console.log(moment().format("HH : mm"))
         let val = {
          mapType:'',//regon:特征物，line:线
          actionType:'',//add,exit,del,
          isrevoke:false,//是否允许撤回,
          oldGeometry:[],
          oldAttributes:[],
          tips:'',
          id:'',
          time:'',
          ...data
         }
         val.oldGeometry = val.oldGeometry.map(item=>{
          return JSON.stringify(item)
         })
         val.oldAttributes = val.oldAttributes.map(item=>{
          return JSON.stringify(item)
         })
         val.time = moment().format("HH : mm")
         this.exitContent.push(val)
      },
      revokeContent(index){
        this.exitContent.splice(index,1)
      },
      clearExitContent(){
        this.exitContent = []
      }

    }
 }
)
export default useMapLog
