소스 검색

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP20_WEB_GLOBAL

li.shaoyi 2 년 전
부모
커밋
809f85ca0e

+ 18 - 17
src/business/trade/index.ts

@@ -1,7 +1,7 @@
 import { reactive, ref, shallowRef, computed } from 'vue'
 import { v4 } from 'uuid'
-import { ClientType, EBuildType, EDelistingType, EListingSelectType, EOperateType, EOrderDirection, EOrderOperateType, EPriceMode, EValidType, OrderSrc } from '@/constants/client'
-import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
+import { ClientType, EBuildType, EDelistingType, EListingSelectType, EOperateType, EOrderOperateType, EValidType, OrderSrc } from '@/constants/client'
+import { useLoginStore, useAccountStore } from '@/stores'
 import {
     spotPresaleDestingOrder,
     spotPresaleTransferCancel,
@@ -26,7 +26,7 @@ import { BuyOrSell } from '@/constants/order'
 
 const loginStore = useLoginStore()
 const accountStore = useAccountStore()
-const userStore = useUserStore()
+
 
 // 采购摘牌
 export function usePurchaseOrderDesting() {
@@ -480,23 +480,22 @@ export function useSpotPresalePointPrice(WRTradeDetailID = '0') {
 // 撤单请求接口
 export function useCancelOrder() {
     const loading = shallowRef(false)
-
-    const cancelSubmit = async (orderid: string, marketid: number) => {
-        /// 参数信息
-        const params = {
-            OperatorID: loginStore.loginId,
-            OrderSrc: OrderSrc.ORDERSRC_CLIENT,
-            AccountID: accountStore.accountId,
-            ClientSerialNo: v4(),
-            ClientOrderTime: formatDate(new Date().toString(), 'YYYY-MM-DD HH:mm:ss'),
-            ClientType: ClientType.Web,
-            OperateType: EOperateType.OPERATETYPE_ORDERCANCEL,
-        }
+    /// 参数信息
+    const formData = reactive<Partial<Proto.CancelOrderReq>> ({
+        OperatorID: loginStore.loginId,
+        OrderSrc: OrderSrc.ORDERSRC_CLIENT,
+        AccountID: accountStore.accountId,
+        ClientSerialNo: v4(),
+        ClientOrderTime: formatDate(new Date().toString(), 'YYYY-MM-DD HH:mm:ss'),
+        ClientType: ClientType.Web,
+        OperateType: EOperateType.OPERATETYPE_ORDERCANCEL,
+    })
+    const cancelSubmit = async (orderid: string) => {
         try {
             loading.value = true
             return await cancelOrder({
                 data: {
-                    ...params,
+                    ...formData,
                     OldOrderId: orderid
                 }
             })
@@ -507,7 +506,8 @@ export function useCancelOrder() {
 
     return {
         loading,
-        cancelSubmit
+        cancelSubmit,
+        formData
     }
 }
 
@@ -552,6 +552,7 @@ export function useHolderClose() {
 // 交易委托
 export function useOrder() {
     const loading = shallowRef(false)
+
     const formData = reactive<Partial<Proto.OrderReq>>({
         ClientSerialNo: v4(),
         ClientOrderTime: formatDate(new Date().toISOString()),

+ 4 - 3
src/packages/mobile/views/order/list/components/swaporder/list/Index.vue

@@ -69,7 +69,7 @@ const componentMap = new Map<string, unknown>([
     ['detail', defineAsyncComponent(() => import('../detail/Index.vue'))]
 ])
 
-const { cancelSubmit } = useCancelOrder()
+const { cancelSubmit, formData } = useCancelOrder()
 const dataList = shallowRef<Model.TradeOrderDetailRsp[]>([])
 const selectedRow = shallowRef<Model.TradeOrderDetailRsp>()
 const error = shallowRef(false)
@@ -100,10 +100,11 @@ const onCancelSumit = (item: Model.TradeOrderDetailRsp) => {
         message: '确认要撤销吗?',
         showCancelButton: true,
     }).then(() => {
-        const { orderid = '', marketid = 0 } = item ?? {}
+        const { orderid = '' } = item ?? {}
+        formData.Header = { MarketID: item.marketid }
         /// loding....
         fullloading((hideLoading) => {
-            cancelSubmit(orderid, marketid).then(() => {
+            cancelSubmit(orderid).then(() => {
                 hideLoading('撤销成功')
             }).catch((err) => {
                 showFailToast(err)

+ 41 - 29
src/packages/mobile/views/swap/detail/Index.vue

@@ -9,53 +9,59 @@
                 </template>
             </app-navbar>
         </template>
-        <Tabs v-model:active="tabIndex">
-            <Tab title="卖大厅" />
+        <Tabs v-model:active="tabIndex" @click="onTabChange">
             <Tab title="买大厅" />
+            <Tab title="卖大厅" />
         </Tabs>
-        <div class="trade">
-                <div class="trade-section sell" v-if="dataList.length">
-                    <app-list :columns="columns" :data-list="dataList">
-                        <template #username="{ row }">
-                            <span >{{ row.userid }}</span>
-                            <span >{{ row.username }}</span>
-                        </template>
-                        <template #operate="{ row }">
-                            <Button size="small" type="primary" round @click="onDelisting(row, tabIndex)">摘牌</Button>
-                        </template>
-                    </app-list>
-                </div>
+        <app-pull-refresh ref="pullRefreshRef" v-model:loading="loading" v-model:error="error" v-model:pageIndex="pageIndex"
+        :page-count="pageCount" @refresh="onTabChange">
+            <div class="trade-section sell" v-if="dataList.length">
+                <app-list :columns="columns" :data-list="dataList">
+                    <template #username="{ row }">
+                        <span >{{ row.userid }}</span>
+                        <span >{{ row.username }}</span>
+                    </template>
+                    <template #operate="{ row }">
+                        <Button size="small" type="primary" round @click="onDelisting(row)">{{ tabIndex === 0 ? '卖出' : '买入' }}</Button>
+                    </template>
+                </app-list>
             </div>
-        <component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ selectedRow, tabIndex }" @closed="closeComponent"
+        </app-pull-refresh>
+        <component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ selectedRow, tabIndex, item }" @closed="closeComponent"
             v-if="componentId" />
     </app-view>
 </template>
 
 <script lang="ts" setup>
 import { shallowRef, defineAsyncComponent } from 'vue'
-import { Tab, Tabs, Button } from 'vant'
+import { Tab, Tabs, Button, showToast } from 'vant'
 import { useRequest } from '@/hooks/request'
 import { useNavigation } from '@/hooks/navigation'
 import { useComponent } from '@/hooks/component'
 import AppList from '@mobile/components/base/list/index.vue'
 import { queryTjmdTradeOrderDetail } from '@/services/api/swap'
+import { useLoginStore } from '@/stores'
+import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
 
 const componentMap = new Map<string, unknown>([
     ['delisting', defineAsyncComponent(() => import('./components/delisting/Index.vue'))],
-    ['listing', defineAsyncComponent(() => import('./components/delisting/Index.vue'))],
+    ['listing', defineAsyncComponent(() => import('./components/listing/Index.vue'))],
 ])
 
-const { getQueryStringToNumber } = useNavigation()
+const loginStore = useLoginStore()
+
+const { getParamString } = useNavigation()
 const { componentRef, componentId, openComponent, closeComponent } = useComponent()
-const goodsId = getQueryStringToNumber('id')
+const item: Model.QuoteGoodsListRsp = JSON.parse(getParamString('item')?.toString() || '{}')
 const tabIndex = shallowRef(0)
 const selectedRow = shallowRef<Model.TjmdTradeOrderDetailRsp>()
 const error = shallowRef(false)
 const dataList = shallowRef<Model.TjmdTradeOrderDetailRsp[]>([])
 
-const { pageIndex } = useRequest(queryTjmdTradeOrderDetail, {
+const { pageIndex, loading, run, pageCount } = useRequest(queryTjmdTradeOrderDetail, {
     params: {
-        goodsid: goodsId,
+        pagesize: 20,
+        goodsid: item.goodsid,
         buyorsell: tabIndex.value
     },
     onSuccess: (res) => {
@@ -69,6 +75,12 @@ const { pageIndex } = useRequest(queryTjmdTradeOrderDetail, {
     }
 })
 
+const onTabChange = () => {
+    run({
+        buyorsell: tabIndex.value
+    })
+}
+
 const columns: Model.TableColumn[] = [
     { prop: 'orderprice', label: '价格' },
     { prop: 'orderqty', label: '数量' },
@@ -76,18 +88,18 @@ const columns: Model.TableColumn[] = [
     { prop: 'operate', label: '摘牌' },
 ]
 
-const onDelisting = (row: Model.TjmdTradeOrderDetailRsp, value: number) => {
-    tabIndex.value = value
+const onDelisting = (row: Model.TjmdTradeOrderDetailRsp) => {
     selectedRow.value = row
-    showComponent('delisting')
+    /// 不能与自己成交
+    if (row.userid === loginStore.userId) {
+        showToast('不能与自己成交')
+        return
+    }
+    openComponent('delisting')
 }
 
 const onListing = () => {
-    showComponent('listing')
-}
-
-const showComponent = (componentName: string) => {
-    openComponent(componentName)
+    openComponent('listing')
 }
 
 </script>

+ 30 - 21
src/packages/mobile/views/swap/detail/components/delisting/Index.vue

@@ -1,6 +1,6 @@
 <template>
     <app-popup :title="'摘牌'" v-model:show="showModal" :refresh="refresh">
-        <Form class="swap-delisting__form" ref="formRef" @submit="onSubmit">
+        <Form class="swap-delisting__form" ref="formRef" @submit="onSubmit" v-if="props">
             <Field label="交易账户">
                 <template #input>
                     <span>{{ accountStore.accountId }}</span>
@@ -8,7 +8,7 @@
             </Field>
             <Field label="挂牌方">
                 <template #input>
-                    <span>{{ '******' }}</span>
+                    <span>{{ selectedRow.username }}</span>
                 </template>
             </Field>
             <Field label="价格类型">
@@ -21,7 +21,7 @@
             </Field>
             <Field label="当前价格" v-if="priceMove === 2">
                 <template #input>
-                    <span>{{ '******' }}</span>
+                    <span>{{ selectedRow.orderprice }}</span>
                 </template>
             </Field>
             <Field label="浮动价格" v-if="priceMove === 3">
@@ -31,17 +31,17 @@
             </Field>
             <Field label="可摘数量">
                 <template #input>
-                    <span>{{ '******' }}</span>
+                    <span>{{ selectedRow.orderqty }}</span>
                 </template>
             </Field>
             <Field name="OrderQty" :rules="formRules.OrderQty" label="挂牌数量">
                 <template #input>
-                    <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :auto-fixed="false" integer />
+                    <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0" :max="selectedRow.orderqty" :auto-fixed="false" :step = 1 integer />
                 </template>
             </Field>
-            <Field label="挂牌金额" v-if="priceMove === 2">
+            <Field name="OrderPrice" v-if="priceMove === 2" :rules="formRules.OrderPrice" label="挂牌金额">
                 <template #input>
-                    <span>{{ amount.toFixed(2) }}</span>
+                    <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0" :auto-fixed="false" />
                 </template>
             </Field>
             <Field label="估算金额" v-if="priceMove === 3">
@@ -60,17 +60,20 @@
                 </template>
             </Field>
         </Form>
+        <div v-else>
+            <Empty />
+        </div>
         <template #footer>
-            <Button type="primary" block round @click="formRef?.submit">摘牌</Button>
+            <Button type="primary" block round @click="formRef?.submit">{{ tabIndex === 0 ? '卖出' : '买入' }}</Button>
         </template>
     </app-popup>
 </template>
 
 <script lang="ts" setup>
-import { shallowRef } from 'vue'
+import { shallowRef, PropType } from 'vue'
 import { Form, FormInstance, Button, Field, RadioGroup, Radio, FieldRule, Stepper} from 'vant'
-import { useAccountStore } from '@/stores'
-import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
+import { useAccountStore, useFuturesStore } from '@/stores'
+import { EBuildType, EDelistingType, EListingSelectType, EOrderDirection, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
 import { useOrder } from '@/business/trade'
 import { fullloading, dialog } from '@/utils/vant'
 
@@ -88,7 +91,15 @@ const priceMove = shallowRef(EPriceMode.PRICEMODE_LIMIT)
 
 const props = defineProps({
     selectedRow: {
-        type: Object,
+        type: Object as PropType<Model.TjmdTradeOrderDetailRsp>,
+        required: true
+    },
+    item: {
+        type: Object as PropType<Model.QuoteGoodsListRsp>,
+        required: true
+    },
+    tabIndex: {
+        type: Number,
         required: true
     }
 })
@@ -97,7 +108,6 @@ const formRef = shallowRef<FormInstance>()
 const showModal = shallowRef(true)
 const refresh = shallowRef(false) // 是否刷新父组件数据
 
-
 // 表单验证规则
 const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
     OrderPrice: [{
@@ -134,14 +144,13 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
 
 // 提交挂牌
 const onSubmit = () => {
-    // GoodsID: goodsid,
-                    // MarketID: marketid,
-                    // BuyOrSell: buyOrSell === EOrderDirection.BUY ? EOrderDirection.SELL : EOrderDirection.BUY,
-                    // RelatedID: orderid,
-                    // PriceMode: priceMode,
-                    // OrderPrice: priceMode === EPriceMode.PRICEMODE_LIMIT ? orderPrice : maxSub,
-                    // OrderQty: orderQty,  
-
+    const { goodsid, orderid } = props.selectedRow
+    /// 获取对应的市场ID
+    formData.MarketID = useFuturesStore().getGoods(goodsid).value?.marketid ?? 0
+    formData.PriceMode = priceMove.value
+    formData.RelatedID = orderid
+    formData.BuyOrSell = props.tabIndex === EOrderDirection.BUY ? EOrderDirection.SELL : EOrderDirection.BUY,
+    formData.GoodsID = goodsid
     formData.PriceMode = priceMove.value
     formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTING
     formData.DelistingType = EDelistingType.DELISTINGTYPE_SELECTED

+ 16 - 11
src/packages/mobile/views/swap/detail/components/listing/Index.vue

@@ -75,8 +75,8 @@ import { shallowRef, PropType } from 'vue'
 import { Form, FormInstance, Button, FieldRule, Field, Tab, Tabs, Stepper, Radio, RadioGroup } from 'vant'
 import { useOrder } from '@/business/trade'
 import { fullloading, dialog } from '@/utils/vant'
-import { useAccountStore } from '@/stores'
-import { EOrderDirection, EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType, EOrderOperateType } from '@/constants/client'
+import { useAccountStore, useFuturesStore } from '@/stores'
+import { EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType, EOrderOperateType } from '@/constants/client'
 
 import AppPopup from '@mobile/components/base/popup/index.vue'
 
@@ -86,28 +86,33 @@ const showModal = shallowRef(true)
 const refresh = shallowRef(false) // 是否刷新父组件数据
 /// 履约保证金
 const permargin = shallowRef(0.0)
-/// 买卖方向
-const buyOrSell = shallowRef(0)
 /// 挂牌金额
 const amount = shallowRef(0.0)
 /// 价格类型
 const priceMove = shallowRef(EPriceMode.PRICEMODE_LIMIT)
-
 const { formData, formSubmit } = useOrder()
 
 const props = defineProps({
-    selectedRow: {
-        type: Object as PropType<Model.TjmdTradeOrderDetailRsp>,
-        required: true,
+    item: {
+        type: Object as PropType<Model.QuoteGoodsListRsp>,
+        required: true
+    },
+    tabIndex: {
+        type: Number,
+        required: true
     }
 })
 
+/// 买卖方向
+const buyOrSell = shallowRef(props.tabIndex)
+
 // 提交挂牌
 const onSubmit = () => {
     /// 买卖方向
-    const { goodsid = 0 } = props.selectedRow ?? {}
-
-    formData.BuyOrSell = buyOrSell.value === 0 ? EOrderDirection.SELL : EOrderDirection.BUY,
+    const { goodsid } = props.item ?? {}
+    /// 获取对应的市场ID
+    formData.MarketID = useFuturesStore().getGoods(goodsid).value?.marketid ?? 0
+    formData.BuyOrSell = buyOrSell.value,
     formData.OrderPrice = priceMove.value === EPriceMode.PRICEMODE_LIMIT ? formData.OrderPrice : 0.0
     formData.PriceMode = priceMove.value
     formData.MarketMaxSub = priceMove.value === EPriceMode.PRICEMODE_LIMIT ? 0.0 : formData.MarketMaxSub

+ 5 - 5
src/packages/mobile/views/swap/list/Index.vue

@@ -5,7 +5,7 @@
         </template>
         <app-list :columns="columns" :data-list="tableList">
             <template #goodsname="{ row }">
-                <span @click="$router.push({ name: 'swap-detail', query: { id: row.goodsid } })">{{ row.goodsname }}</span>
+                <span @click="$router.push({ name: 'swap-detail', params: { item: JSON.stringify(row) } })">{{ row.goodsname }}</span>
             </template>
             <!-- 当前价 -->
             <template #last="{ row }">
@@ -62,18 +62,18 @@ const { dataList } = useRequest(queryQuoteGoodsList, {
 })
 
 const tableList = computed(() => {
-    return dataList.value.map(({ refgoodscode, decimalplace, goodsid }) => {
-        const quote = futuresStore.getQuoteInfo(refgoodscode)
+    return dataList.value.map((item) => {
+        const quote = futuresStore.getQuoteInfo(item.refgoodscode)
         const { goodsname, lastColor, openedColor, lowestColor, highestColor, last, presettle, rise, change, amplitude, highest, lowest, opened } = quote.value ?? {}
         return {
+            ...item,
             goodsname,
             lastColor,
             openedColor,
             lowestColor,
             highestColor,
-            goodsid,
             last: handleNumberValue(last),
-            rise: handleNumberValue(rise?.toFixed(decimalplace)),
+            rise: handleNumberValue(rise?.toFixed(item.decimalplace)),
             change: parsePercent(change),
             opened: handleNumberValue(opened),
             presettle: handleNumberValue(presettle),

+ 1 - 0
src/services/api/trade/index.ts

@@ -182,6 +182,7 @@ export function cancelOrder(config: RequestConfig<Proto.CancelOrderReq>) {
  * 交易下单
  */
 export function order(config: RequestConfig<Proto.OrderReq>) {
+    console.log(config.data)
     return http.mqRequest<Proto.OrderRsp>({
         data: config.data,
         requestCode: 'OrderReq',

+ 6 - 0
src/stores/modules/futures.ts

@@ -18,6 +18,11 @@ export const useFuturesStore = defineStore(() => {
         quoteDayList: <Model.QuoteDayRsp[]>[], // 盘面列表
     })
 
+    /// 根据商品id获取对应的商品信息
+    const getGoods = (goodsid: number) => {
+        return computed(() => state.goodsList.find((e) => e.goodsid === goodsid))
+    }
+
     // 行情列表
     const quoteList = computed(() => {
         return state.goodsList.reduce((res, cur) => {
@@ -330,6 +335,7 @@ export const useFuturesStore = defineStore(() => {
         getGoodsList,
         getQuoteInfo,
         getQuotePrice,
+        getGoods,
         quotePushNotify,
     }
 })

+ 1 - 1
src/types/model/swap.d.ts

@@ -209,7 +209,7 @@ declare namespace Model {
 
     /** 查询掉期协议单 响应 */
     interface TjmdTransferApplyRsp {
-        /// 申请ID(自增ID SEQ_TRADE_HOLDTRANSFERAPPLY)
+        /// 申请ID(自增ID SEQ_TRADE_HOLDTRANSFERAPPLY)
         applyid: number
         /// 状态 - 0:未提交 1:待审核 2:审核中 3:审核通过 4:审核拒绝 5:审核失败 6:已撤销
         applystatus: number