瀏覽代碼

挂牌点价部分代码

zhou.xiaoning 2 年之前
父節點
當前提交
3629ec3564

+ 25 - 0
src/constants/order.ts

@@ -20,6 +20,14 @@ export enum BuildType {
 }
 
 /**
+ * 取价方式
+ */
+export enum PriceMode {
+    Market = 1, // 市价
+    Limit = 2, // 限价
+}
+
+/**
  * 获取买卖方向列表
  * @returns 
  */
@@ -166,4 +174,21 @@ export function getOrderStatusList() {
 export function getOrderStatusName(value: number) {
     const enums = getOrderStatusList()
     return getEnumTypeName(enums, value)
+}
+
+/**
+ * 获取取价方式列表
+ * @returns 
+ */
+export function getPricemode2List() {
+    return getEnumTypeList('Pricemode2')
+}
+
+/**
+ * 获取取价方式名称
+ * @returns 
+ */
+export function getPricemode2Name(value: number) {
+    const enums = getPricemode2List()
+    return getEnumTypeName(enums, value)
 }

+ 163 - 0
src/packages/mobile/views/pricing/detail/Index.vue

@@ -3,8 +3,171 @@
         <template #header>
             <app-navbar title="点价详情" />
         </template>
+        <div v-if="quote">
+            <!-- 商品代码、现价 -->
+            <div style="padding: .3rem;">
+                <span>商品代码/名称</span>
+                <span style="margin-left: .3rem; color: blue;">{{ quote.goodscode }}/{{ quote.goodsname }}</span>
+                <span :class="quote.lastColor" style="margin-left: .5rem;">{{ handleNumberValue(quote.last) }}</span>
+            </div>
+            <!-- 盘面 -->
+            <div style="padding: .3rem; background-color: white;">
+                <table cellspacing="10" cellpadding="0" style="width: 100%;">
+                    <tr>
+                        <td style="width: calc(`100% / 3`);">
+                            <span>幅度</span>
+                            <span :class="quote.lastColor" style="margin-left: .2rem;">{{ handleNumberValue(quote.amplitude)
+                            }}</span>
+                        </td>
+                        <td style="width: calc(`100% / 3`);">
+                            <span>涨跌</span>
+                            <span :class="quote.lastColor" style="margin-left: .2rem;">{{ handleNumberValue(quote.change)
+                            }}</span>
+                        </td>
+                        <td style="width: calc(`100% / 3`);" rowspan="3">
+                            <div>
+                                <span style="background-color: green; color: white; padding: 0.05rem;">卖</span>
+                                <span :class="quote.bidColor" style="margin-left: .2rem;">{{ handleNumberValue(quote.bid)
+                                }}</span>
+                            </div>
+                            <div style="margin-top: .2rem;">
+                                <span style="background-color: red; color: white; padding: .05rem;">买</span>
+                                <span :class="quote.askColor" style="margin-left: .2rem;">{{ handleNumberValue(quote.ask)
+                                }}</span>
+                            </div>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td style="width: calc(`100% / 3`);">
+                            <span>今开</span>
+                            <span :class="quote.openedColor" style="margin-left: .2rem;">{{ handleNumberValue(quote.opened)
+                            }}</span>
+                        </td>
+                        <td style="width: calc(`100% / 3`);">
+                            <span>昨结</span>
+                            <span style="margin-left: .2rem;">{{ handleNumberValue(quote.presettle) }}</span>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td style="width: calc(`100% / 3`);">
+                            <span>最高</span>
+                            <span :class="quote.highestColor" style="margin-left: .2rem;">{{
+                                handleNumberValue(quote.highest) }}</span>
+                        </td>
+                        <td style="width: calc(`100% / 3`);">
+                            <span>最低</span>
+                            <span :class="quote.lowestColor" style="margin-left: .2rem;">{{ handleNumberValue(quote.lowest)
+                            }}</span>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+            <!-- 下单 -->
+            <Form ref="formRef" style="padding: 0.2rem; background-color: white;" @submit="onSubmit">
+                <Field label="方向">
+                    <template #input>
+                        <RadioGroup v-model="formData.BuyOrSell" direction="horizontal">
+                            <Radio v-for="(item, index) in getBuyOrSellList()" :key="index" :name="item.value">{{ item.label
+                            }}</Radio>
+                        </RadioGroup>
+                    </template>
+                </Field>
+                <Field label="类型">
+                    <template #input>
+                        <RadioGroup v-model="formData.BuildType" direction="horizontal">
+                            <Radio :name="BuildType.Open">{{ getBuildTypeName(BuildType.Open) }}</Radio>
+                            <Radio :name="BuildType.Close">{{ getBuildTypeName(BuildType.Close) }}</Radio>
+                        </RadioGroup>
+                    </template>
+                </Field>
+                <Field label="价格方式">
+                    <template #input>
+                        <RadioGroup v-model="formData.PriceMode" direction="horizontal">
+                            <Radio v-for="(item, index) in getPricemode2List()" :key="index" :name="item.value">{{
+                                item.label
+                            }}</Radio>
+                        </RadioGroup>
+                    </template>
+                </Field>
+                <Field name="OrderQty" label="挂牌数量">
+                    <template #input>
+                        <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :auto-fixed="false" integer />
+                    </template>
+                </Field>
+                <!-- 市价 -->
+                <Field label="价格" v-if="formData.PriceMode === PriceMode.Market">
+                    <template #input>
+                        <span>{{ handleNumberValue(marketPrice) }}</span>
+                    </template>
+                </Field>
+                <Field name="MarketMaxSub" label="允许成交范围" v-if="formData.PriceMode === PriceMode.Market">
+                    <template #input>
+                        <Stepper v-model="formData.MarketMaxSub" theme="round" button-size="22" :auto-fixed="false" integer />
+                    </template>
+                </Field>
+                <!-- 限价 -->
+                
+            </Form>
+        </div>
+        <template #footer>
+            <Button type="primary" block round @click="formRef?.submit">确定</Button>
+        </template>
     </app-view>
 </template>
 
 <script lang="ts" setup>
+import { useFuturesStore } from '@/stores'
+import { useNavigation } from '@/hooks/navigation'
+import { handleNumberValue } from '@/filters'
+import quoteSocket from '@/services/websocket/quote'
+import { shallowRef, onMounted, onUnmounted, computed } from 'vue'
+import { Form, Field, Stepper, Button, FieldRule, FormInstance, Radio, RadioGroup } from 'vant'
+import { useOrder } from '@/business/trade'
+import { BuyOrSell, getBuyOrSellList, BuildType, getBuildTypeName, getPricemode2List, PriceMode } from '@/constants/order'
+import { fullloading, dialog } from '@/utils/vant'
+
+const futuresStore = useFuturesStore()
+const { getQueryString, getQueryStringToNumber } = useNavigation()
+
+const goodscode = getQueryString('goodscode')
+const buyOrSell = getQueryStringToNumber('buyOrSell')
+const buildType = getQueryStringToNumber('buildType')
+const quote = futuresStore.getQuoteInfo(goodscode)
+const subscribe = quoteSocket.addSubscribe([goodscode])
+const formRef = shallowRef<FormInstance>()
+const { formData, formSubmit } = useOrder()
+const marketPrice = computed(() => {
+    const { ask = 0, bid = 0 } = quote.value ?? {}
+    return formData.BuyOrSell === BuyOrSell.Buy ? ask : bid
+})
+
+onMounted(() => {
+    subscribe.start()
+
+    formData.BuyOrSell = buyOrSell
+    formData.BuildType = buildType
+    formData.PriceMode = PriceMode.Market
+    formData.MarketMaxSub = 100.0
+})
+
+onUnmounted(() => {
+    subscribe.stop()
+})
+
+// 委托下单
+const onSubmit = () => {
+    const { goodsid, marketid } = quote.value ?? {}
+    formData.GoodsID = goodsid
+    formData.MarketID = marketid
+
+    fullloading((hideLoading) => {
+        formSubmit().then(() => {
+            hideLoading()
+            dialog('委托成功。')
+        }).catch((err) => {
+            hideLoading(err, 'fail')
+        })
+    })
+}
+
 </script>

+ 0 - 0
src/packages/mobile/views/pricing/detail/index.less


+ 105 - 1
src/packages/mobile/views/pricing/list/Index.vue

@@ -1,10 +1,114 @@
 <template>
     <app-view>
         <template #header>
-            <app-navbar title="挂牌点价" />
+            <app-navbar title="订单点价" />
         </template>
+        <app-list :columns="columns" :data-list="tableList">
+            <template #goodsname="{ row }">
+                <span @click="$router.push({ name: 'pricing-detail', query: { goodscode: row.goodscode, buyOrSell: BuyOrSell.Buy, buildType: BuildType.Open } })">{{ row.goodsname }}</span>
+            </template>
+            <!-- 当前价 -->
+            <template #last="{ row }">
+                <span :class="row.lastColor">{{ row.last }}</span>
+            </template>
+            <!-- 涨跌 -->
+            <template #rise="{ row }">
+                <span :class="row.lastColor">{{ row.rise }}</span>
+            </template>
+            <!-- 幅度 -->
+            <template #change="{ row }">
+                <span :class="row.lastColor">{{ row.change }}</span>
+            </template>
+            <!-- 今开 -->
+            <template #opened="{ row }">
+                <span :class="row.openedColor">{{ row.opened }}</span>
+            </template>
+            <!-- 最低 -->
+            <template #lowest="{ row }">
+                <span :class="row.lowestColor">{{ row.lowest }}</span>
+            </template>
+            <!-- 最高 -->
+            <template #highest="{ row }">
+                <span :class="row.highestColor">{{ row.highest }}</span>
+            </template>
+            <!-- 买价 -->
+            <template #ask="{ row }">
+                <span :class="row.askColor">{{ row.ask }}</span>
+            </template>
+            <!-- 卖价 -->
+            <template #bid="{ row }">
+                <span :class="row.bidColor">{{ row.bid }}</span>
+            </template>
+        </app-list>
     </app-view>
 </template>
 
 <script lang="ts" setup>
+
+import { computed } from 'vue'
+import { v4 } from 'uuid'
+import { parsePercent, handleNumberValue } from '@/filters'
+import { useRequest } from '@/hooks/request'
+import { queryQuoteGoodsList } from '@/services/api/swap'
+import { useFuturesStore, useUserStore } from '@/stores'
+import quoteSocket from '@/services/websocket/quote'
+import AppList from '@mobile/components/base/list/index.vue'
+import { BuyOrSell, BuildType } from '@/constants/order'
+
+const futuresStore = useFuturesStore()
+const userStore = useUserStore()
+const subscribeId = v4()
+
+const { dataList } = useRequest(queryQuoteGoodsList, {
+    params: {
+        usertype: userStore.userType ?? 0,
+        marketids: '10101'
+    },
+    onSuccess: (res) => {
+        const goodsCodes = res.data.map((e) => e.refgoodscode)
+        const subscribe = quoteSocket.addSubscribe(goodsCodes,  subscribeId)
+        subscribe.start()
+    }
+})
+
+const tableList = computed(() => {
+    return dataList.value.map((item) => {
+        const quote = futuresStore.getQuoteInfo(item.goodscode)
+        const { lastColor, openedColor, lowestColor, highestColor, last, presettle, rise, change, amplitude, highest, lowest, opened, ask, bid, bidColor, askColor } = quote.value ?? {}
+        return {
+            ...item,
+            lastColor,
+            openedColor,
+            lowestColor,
+            highestColor,
+            last: handleNumberValue(last),
+            rise: handleNumberValue(rise?.toFixed(item.decimalplace)),
+            change: parsePercent(change),
+            opened: handleNumberValue(opened),
+            presettle: handleNumberValue(presettle),
+            lowest: handleNumberValue(lowest),
+            highest: handleNumberValue(highest),
+            amplitude: parsePercent(amplitude),
+            ask: handleNumberValue(ask),
+            bid: handleNumberValue(bid),
+            bidColor,
+            askColor
+        }
+    })
+})
+
+const columns: Model.TableColumn[] = [
+    { prop: 'goodsname', label: '商品/标的' },
+    { prop: 'last', label: '当前价' },
+    { prop: 'ask', label: '买价' },
+    { prop: 'bid', label: '卖价' },
+    { prop: 'rise', label: '涨跌' },
+    { prop: 'change', label: '幅度' },
+    { prop: 'opened', label: '今开' },
+    { prop: 'presettle', label: '昨结' },
+    { prop: 'lowest', label: '最低' },
+    { prop: 'highest', label: '最高' },
+    { prop: 'amplitude', label: '振幅' },
+]
+
 </script>

+ 1 - 1
src/stores/modules/enum.ts

@@ -12,7 +12,7 @@ export interface EnumType {
     disabled?: boolean;
 }
 
-const enumKeys = ['clientType', 'scoreConfigType', 'accountBusinessCode', 'certificatetype', 'signstatus', 'thjOrderStatus', 'THJDeliveryMode', 'goodsunit', 'WROutInApplyStatus2', 'THJTransferStatus', 'WRTradeOrderStatus', 'THJMarket', 'THJProfitRoleType', 'appointmentModelOut', 'orderstatus'] as const
+const enumKeys = ['clientType', 'scoreConfigType', 'accountBusinessCode', 'certificatetype', 'signstatus', 'thjOrderStatus', 'THJDeliveryMode', 'goodsunit', 'WROutInApplyStatus2', 'THJTransferStatus', 'WRTradeOrderStatus', 'THJMarket', 'THJProfitRoleType', 'appointmentModelOut', 'orderstatus', 'Pricemode2'] as const
 
 const enumMap = new Map<typeof enumKeys[number], ShallowRef<Model.EnumRsp[]>>()