Handy_Cao 1 yıl önce
ebeveyn
işleme
9f7efc37a1

+ 0 - 168
src/packages/mobile/views/pricing/trade/holdlb/components/transfer/Index.vue

@@ -1,168 +0,0 @@
-<!-- 我的持仓- 明细 - 转让 -->
-<template>
-    <app-modal direction="right-top" height="100%" width="100%" v-model:show="showModal" :refresh="refresh">
-        <app-view class="g-form">
-            <template #header>
-                <app-navbar :title="$t('operation.transfer')" @back="closed" />
-            </template>
-            <Form ref="formRef" class="g-form__container" @submit="onCloseSumit">
-                <CellGroup :title="$t('position.goods.subtitle')" inset>
-                    <Cell :title="$t('position.goods.goodsname')" :value="`${selectedRow.goodscode}/${selectedRow.goodsname}`" />
-                    <Cell :title="$t('position.goods.buyorsell')" :value="getBuyOrSellName(selectedRow.buyorsell)" />
-                    <Cell :title="$t('position.goods.holderprice')" :value="selectedRow.holderprice" />
-                    <Cell :title="$t('position.goods.curholderamount')" :value="formatDecimal(selectedRow.holderamount)" />
-                    <Cell :title="$t('position.goods.curpositionqty')" :value="selectedRow.holderqty" />
-                    <Cell :title="$t('position.goods.freezeqty')" :value="selectedRow.freezeqty" />
-                    <Cell :title="$t('position.goods.enableqty')" :value="maxQty" />
-                    <Cell :title="$t('position.goods.closepl')">
-                        <template #value>
-                            <span :class="handlePriceColor(closepl)">
-                                {{ formatDecimal(closepl, selectedRow.decimalplace) }}
-                            </span>
-                        </template>
-                    </Cell>
-                    <Cell :title="$t('position.goods.tradetime')" :value="selectedRow.tradetime" />
-                </CellGroup>
-                <CellGroup :title="$t('position.goods.subtitle3')" inset>
-                    <Cell :title="$t('position.goods.last')" :value="handleNumberValue(quote?.last)" />
-                    <Field name="OrderPrice" :rules="formRules.OrderPrice" :label="$t('position.goods.transferprice')">
-                        <template #input>
-                            <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
-                                :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" :auto-fixed="false" />
-                        </template>
-                    </Field>
-                    <Field name="OrderQty" :rules="formRules.OrderQty" :label="$t('position.goods.orderqty')">
-                        <template #input>
-                            <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0" :max="maxQty"
-                                :auto-fixed="false" integer />
-                        </template>
-                    </Field>
-                </CellGroup>
-            </Form>
-            <template #footer>
-                <Button block square type="danger" @click="formRef?.submit">{{ $t('operation.transfer') }}</Button>
-            </template>
-        </app-view>
-    </app-modal>
-</template>
-
-<script lang="ts" setup>
-import { shallowRef, PropType, onMounted, computed } from 'vue'
-import AppModal from '@/components/base/modal/index.vue'
-import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper, FormInstance } from 'vant'
-import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
-import { formatDecimal, handleNumberValue, handleRequestBigNumber, handlePriceColor } from '@/filters'
-import { useOrder } from '@/business/trade'
-import { dialog, fullloading } from '@/utils/vant'
-import { useFuturesStore, usePositionStore, i18n } from '@/stores'
-import { EBuildType, EDelistingType, EListingSelectType, EPriceMode, EValidType } from '@/constants/client'
-
-const props = defineProps({
-    selectedRow: {
-        type: Object as PropType<Model.TradeHolderDetailRsp>,
-        required: true,
-    }
-})
-
-const futuresStore = useFuturesStore()
-const positionStore = usePositionStore()
-const quote = futuresStore.getGoodsQuote(props.selectedRow.goodscode)
-const { global: { t } } = i18n
-// 可用数量
-const maxQty = computed(() => {
-    const record = positionStore.positionList.find((e) => e.goodsid === props.selectedRow.goodsid && e.buyorsell === props.selectedRow.buyorsell)
-    const qty = props.selectedRow.holderqty - props.selectedRow.freezeqty
-    return Math.min(record?.enableqty ?? 0, qty)
-})
-
-// 损益
-const closepl = computed(() => {
-    const { presettle = 0, last = 0 } = quote.value ?? {}
-    const { holderqty, holderamount, agreeunit, buyorsell } = props.selectedRow
-    const price = last || presettle // 没有最新价取昨结价
-    // 计算市值 = 现价 * 数量 * 合约单位
-    const marketValue = price ? price * holderqty * agreeunit : 0
-
-    return price ? (marketValue - holderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1) : 0
-})
-
-const formRef = shallowRef<FormInstance>()
-const showModal = shallowRef(true)
-// 是否刷新父组件数据
-const refresh = shallowRef(false)
-const { formSubmit, formData } = useOrder()
-
-// 表单验证规则
-const formRules: { [key: string]: FieldRule[] } = {
-    OrderPrice: [{
-        message: t('position.goods.tips1'),
-        validator: () => {
-            return !!formData.OrderPrice
-        }
-    }],
-    OrderQty: [{
-        message: t('position.goods.tips2'),
-        validator: () => {
-            return !!formData.OrderQty
-        }
-    }],
-}
-
-const onCloseSumit = () => {
-    dialog({
-        message: t('position.goods.tips3'),
-        showCancelButton: true,
-    }).then(() => {
-
-        const { marketid, goodsid, buyorsell, tradeid } = props.selectedRow
-        /// 市场ID
-        formData.Header = { GoodsID: goodsid }
-        formData.MarketID = marketid
-        formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
-        formData.BuyOrSell = buyorsell === BuyOrSell.Buy ? BuyOrSell.Sell : BuyOrSell.Buy
-        formData.GoodsID = goodsid
-        formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
-        formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
-        formData.BuildType = EBuildType.BUILDTYPE_CLOSE
-        formData.TimevalidType = EValidType.VALIDTYPE_DR
-        formData.OperateType = 24
-        formData.RelatedID = handleRequestBigNumber(tradeid)
-
-        /// loding....
-        fullloading((hideLoading) => {
-            formSubmit().then(() => {
-                hideLoading(t('position.goods.tips4'), 'success')
-                closed(true)
-            }).catch((err) => {
-                hideLoading(err, 'fail')
-            })
-        })
-    })
-}
-
-// 关闭弹窗
-const closed = (isRefresh = false) => {
-    refresh.value = isRefresh
-    showModal.value = false
-}
-
-onMounted(() => {
-    const { bid, ask, presettle = 0 } = quote.value ?? {}
-    switch (props.selectedRow.buyorsell) {
-        case BuyOrSell.Buy:
-            formData.OrderPrice = ask || presettle
-            break
-        case BuyOrSell.Sell:
-            formData.OrderPrice = bid || presettle
-            break
-        default:
-            formData.OrderPrice = presettle
-    }
-    formData.OrderQty = maxQty.value
-})
-
-// 暴露组件属性给父组件调用
-defineExpose({
-    closed,
-})
-</script>