|
|
@@ -0,0 +1,102 @@
|
|
|
+<!-- 我的持仓-现货持仓-挂牌 -->
|
|
|
+<template>
|
|
|
+ <app-modal direction="right" height="100%" v-model:show="showModal" :refresh="refresh">
|
|
|
+ <app-view class="g-form">
|
|
|
+ <template #header>
|
|
|
+ <app-navbar title="挂牌" @back="closed" />
|
|
|
+ </template>
|
|
|
+ <Form ref="formRef" class="g-form__container" @submit="onSubmit">
|
|
|
+ <CellGroup title="现货持仓信息">
|
|
|
+ <Cell title="商品代码/名称" :value="selectedRow.wrstandardname" />
|
|
|
+ <Cell title="仓库" :value="selectedRow.warehousename" />
|
|
|
+ <Cell title="库存量" :value="selectedRow.qty" />
|
|
|
+ <Cell title="冻结量" :value="selectedRow.freezerqty" />
|
|
|
+ <Cell title="可用量" :value="selectedRow.enableqty" />
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup title="挂牌信息">
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="挂牌数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :auto-fixed="false"
|
|
|
+ integer />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="FixedPrice" :rules="formRules.FixedPrice" label="挂牌价格">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.FixedPrice" :default-value="selectedRow.spotgoodsprice" theme="round"
|
|
|
+ :decimal-length="2" :auto-fixed="false" button-size="22" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </CellGroup>
|
|
|
+ </Form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="g-form__footer">
|
|
|
+ <Button block round type="primary" @click="formRef?.submit">卖出</Button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </app-view>
|
|
|
+ </app-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, PropType } from 'vue'
|
|
|
+import { CellGroup, Cell, Button, Stepper, Field, Form, FormInstance, FieldRule } from 'vant'
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
+import { useHdWROrder } from '@/business/trade'
|
|
|
+import AppModal from '@/components/base/modal/index.vue'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.HoldLBRsp>,
|
|
|
+ required: true,
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const { formData, listingSubmit } = useHdWROrder()
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+const showModal = shallowRef(true)
|
|
|
+const refresh = shallowRef(false) // 是否刷新父组件数据
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key in keyof Proto.HdWROrderReq]?: FieldRule[] } = {
|
|
|
+ FixedPrice: [{
|
|
|
+ message: '请输入价格',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.FixedPrice
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ OrderQty: [{
|
|
|
+ message: '请输入数量',
|
|
|
+ validator: (val) => {
|
|
|
+ if (val) {
|
|
|
+ if (val > props.selectedRow.enableqty) {
|
|
|
+ return '可用数量不足'
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ fullloading((hideLoading) => {
|
|
|
+ listingSubmit().then(() => {
|
|
|
+ hideLoading('下单成功', 'success')
|
|
|
+ closed(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ hideLoading(err, 'fail')
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 关闭弹窗
|
|
|
+const closed = (isRefresh = false) => {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ showModal.value = false
|
|
|
+}
|
|
|
+
|
|
|
+// 暴露组件属性给父组件调用
|
|
|
+defineExpose({
|
|
|
+ closed,
|
|
|
+})
|
|
|
+</script>
|