| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { defineStore } from 'pinia'
- import { reactive } from 'vue'
- import { createCollection, deleteCollection, queryCollection, updateCollection } from '@/api/collection'
- export const collectionOperate = defineStore('payment', () => {
- // 定义数据
- const paymentList = reactive([])
- // 定义修改数据的方法
- const getPaymentList = (code) => {
- queryCollection(code).then(res => {
- if (res.code === 0) {
- paymentList.length = 0
- paymentList.push(...res.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)
- }
- })
- }
- return {
- paymentList,
- getPaymentList,
- postCollection,
- putCollection,
- delCollection
- }
- })
|