|
|
@@ -0,0 +1,119 @@
|
|
|
+<template>
|
|
|
+ <app-popup class="supply-demand-listing" title="出价" v-model:show="showModal" :refresh="refresh">
|
|
|
+ <Form class="supply-demand-listing__form" ref="formRef" @submit="onSubmit">
|
|
|
+ <Field label="发行价">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ detail.refprice }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="认购数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderQty" theme="round" :max="detail.presaleqty" button-size="22"
|
|
|
+ :auto-fixed="false" integer />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="预售定金">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ deposit }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="可用资金">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ accountStore.avaiableMoney.toFixed(2) }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </Form>
|
|
|
+ <template #footer>
|
|
|
+ <Button type="primary" block round @click="formRef?.submit">确定</Button>
|
|
|
+ </template>
|
|
|
+ </app-popup>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, PropType, onMounted, computed } from 'vue'
|
|
|
+import { Form, Field, Stepper, Button, FieldRule, FormInstance } from 'vant'
|
|
|
+import { fullloading, dialog } from '@/utils/vant'
|
|
|
+import { useAccountStore } from '@/stores'
|
|
|
+import { useOrder } from '@/business/trade'
|
|
|
+import AppPopup from '@mobile/components/base/popup/index.vue'
|
|
|
+import { BuyOrSell } from '@/constants/order'
|
|
|
+import { EPriceMode, EValidType } from '@/constants/client'
|
|
|
+//import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ detail: {
|
|
|
+ type: Object as PropType<Model.PresaleAuctionsRsp>,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+const { formData, formSubmit } = useOrder()
|
|
|
+const accountStore = useAccountStore()
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+const refresh = shallowRef(false) // 是否刷新父组件数据
|
|
|
+const showModal = shallowRef(true)
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
|
|
|
+ OrderQty: [{
|
|
|
+ message: '请输入数量',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.OrderQty
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+// 预售定金
|
|
|
+const deposit = computed(() => {
|
|
|
+ const { refprice, presaledepositalgorithm, presaledepositvalue } = props.detail
|
|
|
+ const qty = formData.OrderQty ?? 0
|
|
|
+
|
|
|
+ switch (presaledepositalgorithm) {
|
|
|
+ case 1:
|
|
|
+ return (presaledepositvalue * refprice * qty).toFixed(2)
|
|
|
+ case 2:
|
|
|
+ return (presaledepositvalue * qty).toFixed(2)
|
|
|
+ default:
|
|
|
+ return '0.0'
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 关闭弹窗
|
|
|
+const closed = (isRefresh = false) => {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ showModal.value = false
|
|
|
+}
|
|
|
+
|
|
|
+// 提交摘牌
|
|
|
+const onSubmit = () => {
|
|
|
+ const { applyid, goodsid, marketid } = props.detail
|
|
|
+ formData.GoodsID = goodsid
|
|
|
+ formData.MarketID = marketid
|
|
|
+ formData.BuyOrSell = BuyOrSell.Buy
|
|
|
+ formData.RelatedID = applyid
|
|
|
+ formData.ValidType = EValidType.VALIDTYPE_YZ
|
|
|
+ formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
+
|
|
|
+ fullloading((hideLoading) => {
|
|
|
+ formSubmit().then(() => {
|
|
|
+ hideLoading()
|
|
|
+ dialog('提交成功').then(() => closed(true))
|
|
|
+ }).catch((err) => {
|
|
|
+ hideLoading(err, 'fail')
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ formData.OrderPrice = props.detail.startprice
|
|
|
+})
|
|
|
+
|
|
|
+// 暴露组件属性给父组件调用
|
|
|
+defineExpose({
|
|
|
+ closed,
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less">
|
|
|
+@import './index.less';
|
|
|
+</style>
|