| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import { defineStore } from 'pinia'
- import { reactive, ref } from 'vue'
- import { createCollection, deleteCollection, queryCollection, updateCollection, retrievalCollection } from '@/api/collection'
- import { formatDate } from '@/utils/formatDate'
- export const collectionOperate = defineStore('payment', () => {
- // 定义数据
- const paymentList = reactive([])
- const paymentCode = ref('')
- const paymentTotal = ref(0)
- // 定义修改数据的方法
- const getPaymentList = (code) => {
- // retrievalCollection().then(res => {
- // if (res.code === 0) {
- //
- // }
- // })
- queryCollection(code).then(res => {
- if (res.code === 0) {
- const data = res.data
- data.forEach(item => {
- item.collectionTime = formatDate(item.collectionTime)
- })
- paymentList.length = 0
- paymentList.push(...data)
- console.log(paymentList)
- }
- })
- }
- const postCollection = (data) => {
- createCollection(data).then(res => {
- if (res.code === 0) {
- console.log(res.data)
- }
- })
- }
- const putCollection = (data) => {
- updateCollection(data).then(res => {
- if (res.code === 0) {
- console.log(res.data)
- }
- })
- }
- const delCollection = (data) => {
- deleteCollection(data).then(res => {
- if (res.code === 0) {
- console.log(res.data)
- }
- })
- }
- const changePaymentList = (list) => {
- list.forEach(item => {
- item.collectionTime = formatDate(item.collectionTime)
- })
- paymentList.length = 0
- paymentList.push(...list)
- paymentTotal.value = list.length
- }
- const changePaymentCode = (code) => {
- paymentCode.value = code
- }
- const changePaymentTotal = (total) => {
- paymentTotal.value = total
- }
- return {
- paymentList,
- paymentCode,
- paymentTotal,
- getPaymentList,
- postCollection,
- putCollection,
- delCollection,
- changePaymentList,
- changePaymentCode,
- changePaymentTotal
- }
- })
|