import { _list, _view, _export, _add, _adds, _up, _ups, _del } from '@/api/app'
import { reformateObjectRes } from '@/utils/index'
import { _sh } from '@/api/orderinvoiceManage'

const useOrderinvoiceManageStore = defineStore('orderinvoiceManage', {
  state: () => ({
    //...
  }),
  actions: {
    //* *********** 发票 **************
    // 获取列表
    list(data) {
      return new Promise((resolve, reject) => {
        data.pagevalue = 63
        _list(data)
          .then((res) => {
            resolve(res.Data)
          })
          .catch((err) => {
            reject(err)
          })
      })
    },
    // 获取详情
    view(data) {
      return new Promise((resolve, reject) => {
        data.pagevalue = 64
        _view(data)
          .then((res) => {
            resolve(reformateObjectRes(res.Data))
          })
          .catch((err) => {
            reject(err)
          })
      })
    },
    // 更新
    up(data) {
      return new Promise((resolve, reject) => {
        data.pagevalue = 65
        _up(data)
          .then((res) => {
            resolve(res.Data)
          })
          .catch((err) => {
            reject(err)
          })
      })
    },
    // 新增
    add(data) {
      return new Promise((resolve, reject) => {
        data.pagevalue = 66
        _add(data)
          .then((res) => {
            resolve(res.Data)
          })
          .catch((err) => {
            reject(err)
          })
      })
    },
    // 发票审核
    sh(data) {
      return new Promise((resolve, reject) => {
        data.pagevalue = 363
        _sh(data)
          .then((res) => {
            resolve(res.Data)
          })
          .catch((err) => {
            reject(err)
          })
      })
    },
  },
})

export default useOrderinvoiceManageStore
