import { defineStore } from 'pinia'
import { retrievalReimburse } from '@/api/reimbursement'
import { reactive, ref } from 'vue'

export const reimburseOperate = defineStore('account', () => {
  // 定义数据
  const reimburseList = reactive([])
  const reimburseTotal = ref(0)
  // 定义修改数据的方法
  const getReimburseList = (data) => {
    retrievalReimburse(data).then(res => {
      console.log(res)
      if (res.code === 0) {
        reimburseList.length = 0
        reimburseList.push(...res.data.list)
      }
    })
  }
  const changeReimburseList = (list) => {
    reimburseList.length = 0
    reimburseList.push(...list)
  }
  const changeReimburseTotal = (total) => {
    reimburseTotal.value = total
  }
  return {
    reimburseList,
    reimburseTotal,
    getReimburseList,
    changeReimburseList,
    changeReimburseTotal
  }
})
