|
|
@@ -0,0 +1,145 @@
|
|
|
+<!-- 商品订单-合约汇总-交收 -->
|
|
|
+<template>
|
|
|
+ <app-drawer title="交收" :width="600" v-model:show="show" :loading="loading" :refresh="refresh">
|
|
|
+ <div>
|
|
|
+ <span>持仓数量:{{ selectedRow.curpositionqty }}</span>
|
|
|
+ <span>可用数量:{{ selectedRow.enableqty }}</span>
|
|
|
+ </div>
|
|
|
+ <table class="table-form" cellspacing="0" cellpadding="0" border="1" style="width: 100%;text-align: center;">
|
|
|
+ <tr>
|
|
|
+ <th>持有人/商品/仓库</th>
|
|
|
+ <th>升贴水</th>
|
|
|
+ <th>数量</th>
|
|
|
+ <th>选择数量</th>
|
|
|
+ </tr>
|
|
|
+ <template v-for="(item, index) in dataList" :key="index">
|
|
|
+ <tr>
|
|
|
+ <td colspan="4">{{ item.username }}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td>{{ item.wrstandardname }}</td>
|
|
|
+ <td rowspan="2">{{ item.pricemove }}</td>
|
|
|
+ <td rowspan="2">{{ item.avalidqty }}</td>
|
|
|
+ <td rowspan="2">
|
|
|
+ <el-input-number placeholder="请输入" v-model="item.deliveryLot" :precision="0" :max="item.avalidqty"
|
|
|
+ :min="0" />
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td>{{ item.warehousename }}</td>
|
|
|
+ </tr>
|
|
|
+ <tr v-if="(dataList.length - 1) > index">
|
|
|
+ <td colspan="4"></td>
|
|
|
+ </tr>
|
|
|
+ </template>
|
|
|
+ </table>
|
|
|
+ <div>
|
|
|
+ <span>已点选数量:{{ totalQty }}</span>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <span>点选合约:{{ selectedRow.goodscode }}</span>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <span :class="selectedRow.lastColor">现价:{{ selectedRow.lastprice }}</span>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <el-button type="info" @click="onCancel(false)">取消</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit">交收</el-button>
|
|
|
+ </template>
|
|
|
+ </app-drawer>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { ref, PropType, computed } from 'vue'
|
|
|
+import { ElMessage, FormInstance, FormRules } from 'element-plus'
|
|
|
+import { useOfflineDelivery } from '@/business/trade'
|
|
|
+import { useFuturesStore } from '@/stores'
|
|
|
+import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
|
|
|
+import { formatDecimal, handlePriceColor } from '@/filters'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { queryWrDeliveryAvalidHoldLB } from '@/services/api/transfer'
|
|
|
+import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.TradePositionRsp & { lastColor: string }>,
|
|
|
+ required: true,
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const { formSubmit, formData, loading } = useOfflineDelivery()
|
|
|
+const show = ref(true)
|
|
|
+const refresh = ref(false)
|
|
|
+const formRef = ref<FormInstance>()
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
+const dataList = ref<(Model.WrDeliveryAvalidHoldLBRsp & { deliveryLot: number })[]>([])
|
|
|
+const quote = futuresStore.getGoodsQuote(props.selectedRow.goodscode)
|
|
|
+
|
|
|
+useRequest(queryWrDeliveryAvalidHoldLB, {
|
|
|
+ params: {
|
|
|
+ goodsid: props.selectedRow.goodsid,
|
|
|
+ },
|
|
|
+ onSuccess: (res) => {
|
|
|
+ dataList.value = res.data.map((e) => ({
|
|
|
+ ...e,
|
|
|
+ deliveryLot: 0,
|
|
|
+ }))
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 已点选数量
|
|
|
+const totalQty = computed(() => dataList.value.reduce((pre, cur) => pre + cur.deliveryLot, 0))
|
|
|
+
|
|
|
+// 剩余可用点选数量
|
|
|
+const remainQty = computed(() => props.selectedRow.enableqty - totalQty.value)
|
|
|
+
|
|
|
+/// 计算参考损益
|
|
|
+const closepl = computed(() => {
|
|
|
+ const { last = 0 } = quote.value ?? {}
|
|
|
+ const { curpositionqty, curholderamount, agreeunit, buyorsell } = props.selectedRow
|
|
|
+ return (last * curpositionqty * agreeunit - curholderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1)
|
|
|
+})
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: FormRules = {
|
|
|
+ DeliveryLot: [{
|
|
|
+ message: '请输入交收数量',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.DeliveryLot
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ DeliveryInfo: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入交收信息',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.DeliveryInfo
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+const onCancel = (isRefresh = false) => {
|
|
|
+ show.value = false
|
|
|
+ refresh.value = isRefresh
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const { marketid, goodsid, goodscode, buyorsell } = props.selectedRow
|
|
|
+ /// 市场ID
|
|
|
+ formData.Header = { MarketID: marketid, GoodsID: goodsid }
|
|
|
+ formData.GoodsCode = goodscode
|
|
|
+ formData.GoodsID = goodsid
|
|
|
+ formData.BuyOrSell = buyorsell
|
|
|
+ formSubmit().then(() => {
|
|
|
+ ElMessage.success('交收成功')
|
|
|
+ onCancel(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage.error('交收失败:' + err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|