cost.js 993 B

123456789101112131415161718192021222324252627282930313233343536
  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. costListTotal.value = res.data.total
  15. }
  16. })
  17. }
  18. const changeCostList = (list) => {
  19. costListTotal.value = list.length
  20. if (list.length > 8) {
  21. list = list.slice(0, 8)
  22. }
  23. projectCostList.length = 0
  24. projectCostList.push(...list)
  25. }
  26. const changeCostTotal = (total) => {
  27. costListTotal.value = total
  28. }
  29. return {
  30. projectCostList,
  31. changeCostList,
  32. costListTotal,
  33. changeCostTotal,
  34. getCostList
  35. }
  36. })