|
|
@@ -0,0 +1,160 @@
|
|
|
+<!-- 我的订单- 挂牌点价 - 订单明细 - 交收 -->
|
|
|
+<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.delivery')" @back="closed" />
|
|
|
+ </template>
|
|
|
+ <Form ref="formRef" class="g-form__container" @submit="onDeliverySumit">
|
|
|
+ <CellGroup :title="$t('position.goods.subtitle')" inset>
|
|
|
+ <Cell :title="$t('position.goods.goodsname')" :value="`${selectedRow.goodsCode}`" />
|
|
|
+ <Cell :title="$t('position.goods.buyorsell')" :value="getBuyOrSellName(selectedRow.tHDetailEx.buyOrSell)" />
|
|
|
+ <Cell :title="$t('position.goods.curholderamount')" :value="formatDecimal(selectedRow.tHDetailEx.holderAmount, selectedRow.decimalPlace)" />
|
|
|
+ <Cell :title="$t('position.goods.curpositionqty')" :value="selectedRow.tHDetailEx.holderQty*selectedRow.agreeUnit + getGoodsUnitName(selectedRow.goodsUnitID)" />
|
|
|
+ <Cell :title="$t('position.goods.frozenqty')" :value="selectedRow.tHDetailEx.freezeQty*selectedRow.agreeUnit + getGoodsUnitName(selectedRow.goodsUnitID)" />
|
|
|
+ <Cell :title="$t('position.goods.enableqty')" :value="enableqty" />
|
|
|
+ <Cell :title="$t('position.goods.mindeliverylot')" :value="mindeliverylot" />
|
|
|
+ <Cell :title="$t('position.goods.closepl')">
|
|
|
+ <template #value>
|
|
|
+ <span :class="handlePriceColor(selectedRow.tHDetailEx.floatPL)">
|
|
|
+ {{ formatDecimal(selectedRow.tHDetailEx.floatPL, selectedRow.decimalPlace) }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </Cell>
|
|
|
+ <Cell :title="$t('position.goods.tradetime')" :value="selectedRow.tHDetailEx.tradeTime" />
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup :title="$t('position.goods.subtitle2')" inset>
|
|
|
+ <Field name="DeliveryLot" type="digit" :rules="formRules.DeliveryLot" :label="$t('position.goods.deliverylot')">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.DeliveryLot" theme="round" button-size="22" :min="0"
|
|
|
+ :max="enableqty" :auto-fixed="false" integer />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Cell :title="$t('position.goods.deliveryqty')" :value="((formData.DeliveryLot ?? 0) * selectedRow.agreeUnit) + selectedRow.goodsUnit" />
|
|
|
+ <Field name="DeliveryInfo" v-model="formData.DeliveryInfo" type="textarea" autosize clearable
|
|
|
+ :rules="formRules.DeliveryInfo" maxlength="50"
|
|
|
+ :label="selectedRow.tHDetailEx.buyOrSell === BuyOrSell.Buy ? $t('position.goods.address') : $t('position.goods.deliveryinfo')" :placeholder="$t('common.required')">
|
|
|
+ <template #right-icon v-if="selectedRow.tHDetailEx.buyOrSell === BuyOrSell.Buy">
|
|
|
+ <Icon name="add-o" @click="showContact = true" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </CellGroup>
|
|
|
+ </Form>
|
|
|
+ <app-contact v-model:show="showContact" @change="contactChange" />
|
|
|
+ <template #footer>
|
|
|
+ <div class="g-form__footer inset">
|
|
|
+ <Button :disabled="enableqty === 0" block square type="danger" @click="formRef?.submit">{{ $t('operation.delivery') }}</Button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </app-view>
|
|
|
+ </app-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, PropType, computed } from 'vue'
|
|
|
+import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper, FormInstance, Icon } from 'vant'
|
|
|
+import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
|
|
|
+import { formatDecimal, handlePriceColor, handleRequestBigNumber } from '@/filters'
|
|
|
+import { useOfflineDelivery } from '@/business/trade'
|
|
|
+import { dialog, fullloading } from '@/utils/vant'
|
|
|
+import { i18n, useFuturesStore } from '@/stores'
|
|
|
+import { getGoodsUnitName } from '@/constants/unit'
|
|
|
+import AppModal from '@/components/base/modal/index.vue'
|
|
|
+import AppContact from '@mobile/components/modules/contact/index.vue'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.SBYJMyOrderRsp & {
|
|
|
+ closepl: number; // 浮动盈亏
|
|
|
+ closeplColor: string; // 浮动盈亏颜色
|
|
|
+ }>,
|
|
|
+ required: true,
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const { global: { t } } = i18n
|
|
|
+const showModal = shallowRef(true)
|
|
|
+// 是否刷新父组件数据
|
|
|
+const refresh = shallowRef(false)
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+const showContact = shallowRef(false) // 显示联系人选择列表
|
|
|
+const { formSubmit, formData } = useOfflineDelivery()
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
+const goods = futuresStore.getGoods(props.selectedRow.goodsCode)
|
|
|
+const { mindeliverylot = 0 } = goods ?? {}
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key: string]: FieldRule[] } = {
|
|
|
+ DeliveryLot: [{
|
|
|
+ message: t('position.goods.tips7'),
|
|
|
+ validator: (val) => {
|
|
|
+ if (val >= mindeliverylot) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return t('position.goods.tips8') + `${mindeliverylot}`
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ DeliveryInfo: [{
|
|
|
+ required: true,
|
|
|
+ message: props.selectedRow.tHDetailEx.buyOrSell === BuyOrSell.Buy ? t('position.goods.tips9') : t('position.goods.tips10'),
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.DeliveryInfo
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+// 可用重量
|
|
|
+const enableqty = computed(() => {
|
|
|
+ const { tHDetailEx, agreeUnit } = props.selectedRow
|
|
|
+ return (tHDetailEx.holderQty - tHDetailEx.freezeQty) * agreeUnit
|
|
|
+})
|
|
|
+
|
|
|
+// 选择联系信息
|
|
|
+const contactChange = (item: Model.UserReceiveInfoRsp) => {
|
|
|
+ const contact = `${item.receivername} ${item.phonenum}`
|
|
|
+ const address = `${item.provincename} ${item.cityname} ${item.districtname} ${item.address}`
|
|
|
+ formData.DeliveryInfo = [contact, address].join('\n')
|
|
|
+ formRef.value?.validate('Region')
|
|
|
+}
|
|
|
+
|
|
|
+const onDeliverySumit = () => {
|
|
|
+ dialog({
|
|
|
+ message: t('position.goods.tips5'),
|
|
|
+ showCancelButton: true,
|
|
|
+ }).then(() => {
|
|
|
+ const { buyOrSell, tradeID } = props.selectedRow.tHDetailEx
|
|
|
+ const { goodsCode } = props.selectedRow
|
|
|
+ const { marketid, goodsid } = goods ?? {}
|
|
|
+ /// 市场ID
|
|
|
+ formData.Header = { MarketID: marketid, GoodsID: goodsid }
|
|
|
+ formData.GoodsCode = goodsCode
|
|
|
+ formData.GoodsID = goodsid
|
|
|
+ formData.BuyOrSell = buyOrSell
|
|
|
+ formData.TradeID = handleRequestBigNumber(tradeID)
|
|
|
+ /// loding....
|
|
|
+ fullloading((hideLoading) => {
|
|
|
+ formSubmit().then(() => {
|
|
|
+ hideLoading(t('position.goods.tips6'), 'success')
|
|
|
+ closed(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ hideLoading(err, 'fail')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 关闭弹窗
|
|
|
+const closed = (isRefresh = false) => {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ if (showContact.value) {
|
|
|
+ showContact.value = false
|
|
|
+ } else {
|
|
|
+ showModal.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 暴露组件属性给父组件调用
|
|
|
+defineExpose({
|
|
|
+ closed,
|
|
|
+})
|
|
|
+</script>
|