| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { shallowRef, reactive } from 'vue'
- import { v4 } from 'uuid'
- import { formatDate } from '@/filters'
- import { ClientType } from '@/constants/client'
- import { BuyOrSell } from '@/constants/order'
- import { order } from '@/services/api/presale'
- import { useLoginStore, useAccountStore } from '@/stores'
- const loginStore = useLoginStore()
- const accountStore = useAccountStore()
- export function useOrder(selectedRow: Model.PresaleAuctionsRsp) {
- const loading = shallowRef(false)
- const formData = reactive<Partial<Proto.OrderReq>>({
- ClientType: ClientType.Web, // 终端类型
- LoginID: loginStore.loginId, // 登陆账号
- AccountID: accountStore.accountId, // 交易账号
- GoodsID: selectedRow.goodsid, // 商品ID
- MarketID: 48201, // 市场ID
- ValidType: 1, // 校验类型
- BuyOrSell: BuyOrSell.Buy, // 买卖方向
- DelistingType: 2, // 摘牌类型
- })
- const formSubmit = async () => {
- try {
- loading.value = true
- return await order({
- data: {
- ClientSerialNo: v4(),
- ClientOrderTime: formatDate(new Date().toISOString(), 'YYYY-MM-DD HH:mm:ss'),
- ...formData,
- }
- })
- } finally {
- loading.value = false
- }
- }
- return {
- loading,
- formData,
- formSubmit,
- }
- }
|