cost.js 847 B

12345678910111213141516171819202122232425262728293031
  1. import { defineStore } from 'pinia'
  2. import { reactive, ref } from 'vue'
  3. import { queryProjectCost } from '@/api/cost'
  4. export const payData = defineStore('expenses', () => {
  5. const projectCostList = reactive([])
  6. const costListTotal = ref(0)
  7. const getCostList = (data) => {
  8. queryProjectCost(data).then(res => {
  9. if (res.code === 0) {
  10. projectCostList.length = 0
  11. const list = res.data.list === null ? [] : res.data.list
  12. console.log('查询费用列表', list)
  13. projectCostList.push(...list)
  14. }
  15. })
  16. }
  17. const changeCostList = (list) => {
  18. projectCostList.length = 0
  19. projectCostList.push(...list)
  20. }
  21. const changeCostTotal = (total) => {
  22. costListTotal.value = total
  23. }
  24. return {
  25. projectCostList,
  26. changeCostList,
  27. costListTotal,
  28. changeCostTotal,
  29. getCostList
  30. }
  31. })