|
@@ -1,32 +1,50 @@
|
|
|
import { handleDeliveryRelation } from "@/common/setup/deliveryRelation";
|
|
import { handleDeliveryRelation } from "@/common/setup/deliveryRelation";
|
|
|
import { getSelectedAccountId } from "@/services/bus/account";
|
|
import { getSelectedAccountId } from "@/services/bus/account";
|
|
|
import { getQuoteDayInfoByCode } from "@/services/bus/goods";
|
|
import { getQuoteDayInfoByCode } from "@/services/bus/goods";
|
|
|
|
|
+import { QueryDeliveryRelationRsp } from "@/services/go/delivery/interface";
|
|
|
import { QueryTradePositionRsp } from "@/services/go/ermcp/order/interface";
|
|
import { QueryTradePositionRsp } from "@/services/go/ermcp/order/interface";
|
|
|
import { queryWrDeliveryAvalidHoldLB } from "@/services/go/wrtrade";
|
|
import { queryWrDeliveryAvalidHoldLB } from "@/services/go/wrtrade";
|
|
|
import { QueryWrDeliveryAvalidHoldLBReq } from "@/services/go/wrtrade/interface";
|
|
import { QueryWrDeliveryAvalidHoldLBReq } from "@/services/go/wrtrade/interface";
|
|
|
import { ref } from "vue";
|
|
import { ref } from "vue";
|
|
|
import { DBType } from "./interface";
|
|
import { DBType } from "./interface";
|
|
|
|
|
|
|
|
|
|
+// 选中的交收合约
|
|
|
|
|
+const selected = ref<DBType>()
|
|
|
|
|
+const checked = ref<string>();
|
|
|
|
|
+// 交割商品
|
|
|
|
|
+const deliveryGoods = ref<QueryDeliveryRelationRsp | undefined>();
|
|
|
|
|
+
|
|
|
// 查询合约交收可点选仓单
|
|
// 查询合约交收可点选仓单
|
|
|
export function getTableList(goodsid: number) {
|
|
export function getTableList(goodsid: number) {
|
|
|
|
|
+ // 交割商品
|
|
|
|
|
+ const { getItemDeliveryRelationByGoodsId } = handleDeliveryRelation()
|
|
|
const param: QueryWrDeliveryAvalidHoldLBReq = {
|
|
const param: QueryWrDeliveryAvalidHoldLBReq = {
|
|
|
goodsid,
|
|
goodsid,
|
|
|
accountid: getSelectedAccountId(),
|
|
accountid: getSelectedAccountId(),
|
|
|
};
|
|
};
|
|
|
const tableList = ref<DBType[]>([]);
|
|
const tableList = ref<DBType[]>([]);
|
|
|
queryWrDeliveryAvalidHoldLB(param).then((res) => {
|
|
queryWrDeliveryAvalidHoldLB(param).then((res) => {
|
|
|
- tableList.value = res.map((e) => {
|
|
|
|
|
- return { ...e, checked: false, num: 0 };
|
|
|
|
|
|
|
+ tableList.value = res.map((e, i) => {
|
|
|
|
|
+ if (i) {
|
|
|
|
|
+ return { ...e, checked: false, num: 0 };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 默认勾选第一个
|
|
|
|
|
+ checked.value = e.ladingbillid
|
|
|
|
|
+ const result = { ...e, checked: true, num: 0 };
|
|
|
|
|
+ selected.value = result
|
|
|
|
|
+ deliveryGoods.value = getItemDeliveryRelationByGoodsId(e.goodsid).value
|
|
|
|
|
+ return result
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
return { tableList }
|
|
return { tableList }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 选中的交收合约
|
|
|
|
|
-const selected = ref<DBType>()
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
export function handleCheck() {
|
|
export function handleCheck() {
|
|
|
- const checked = ref<string>();
|
|
|
|
|
|
|
+ // 交割商品
|
|
|
|
|
+ const { getItemDeliveryRelationByGoodsId } = handleDeliveryRelation()
|
|
|
|
|
|
|
|
function checkGroupChange(checkedValue: string[]) {
|
|
function checkGroupChange(checkedValue: string[]) {
|
|
|
checked.value = checkedValue[checkedValue.length - 1];
|
|
checked.value = checkedValue[checkedValue.length - 1];
|
|
@@ -36,23 +54,32 @@ export function handleCheck() {
|
|
|
}
|
|
}
|
|
|
function checkboxChange(item: DBType) {
|
|
function checkboxChange(item: DBType) {
|
|
|
selected.value = item;
|
|
selected.value = item;
|
|
|
|
|
+ deliveryGoods.value = getItemDeliveryRelationByGoodsId(item.goodsid).value
|
|
|
}
|
|
}
|
|
|
- return { checked, selected, checkGroupChange, isChecked, checkboxChange }
|
|
|
|
|
|
|
+ // true 基差点价; false 挂牌点选
|
|
|
|
|
+ function isBaseSpread() {
|
|
|
|
|
+ if (deliveryGoods.value) {
|
|
|
|
|
+ // 1和3是订单交易 挂牌转让
|
|
|
|
|
+ // 2和4是基差点价
|
|
|
|
|
+ const arr = [2, 3]
|
|
|
|
|
+ return arr.includes(deliveryGoods.value.deliverytype)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return { checked, selected, deliveryGoods, checkGroupChange, isChecked, checkboxChange, isBaseSpread }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function handleCalculation(selectedRow: QueryTradePositionRsp) {
|
|
export function handleCalculation(selectedRow: QueryTradePositionRsp) {
|
|
|
// 商品合约单位
|
|
// 商品合约单位
|
|
|
- const { agreeunit, goodsid, goodscode, decimalplace, enableqty } = selectedRow
|
|
|
|
|
- // 交割商品
|
|
|
|
|
- const { getItemDeliveryRelationByGoodsId } = handleDeliveryRelation()
|
|
|
|
|
- const deliveryRetation = getItemDeliveryRelationByGoodsId(goodsid)
|
|
|
|
|
|
|
+ const { agreeunit, goodscode, decimalplace, enableqty } = selectedRow
|
|
|
function selctedNum() {
|
|
function selctedNum() {
|
|
|
return selected.value ? selected.value.num : '--'
|
|
return selected.value ? selected.value.num : '--'
|
|
|
}
|
|
}
|
|
|
// 选中数量的 最小变动值 = 合约单位 * 最小交割系数 * 仓单商品的单位r2
|
|
// 选中数量的 最小变动值 = 合约单位 * 最小交割系数 * 仓单商品的单位r2
|
|
|
function getStepValue() {
|
|
function getStepValue() {
|
|
|
- if (deliveryRetation.value) {
|
|
|
|
|
- const { rratio2, mindeliveryqty } = deliveryRetation.value
|
|
|
|
|
|
|
+ if (deliveryGoods.value) {
|
|
|
|
|
+ const { rratio2, mindeliveryqty } = deliveryGoods.value
|
|
|
return agreeunit * mindeliveryqty * rratio2
|
|
return agreeunit * mindeliveryqty * rratio2
|
|
|
} else {
|
|
} else {
|
|
|
return agreeunit
|
|
return agreeunit
|
|
@@ -60,23 +87,39 @@ export function handleCalculation(selectedRow: QueryTradePositionRsp) {
|
|
|
}
|
|
}
|
|
|
// 可交收数量 = 合约可用手数 * 合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1)
|
|
// 可交收数量 = 合约可用手数 * 合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1)
|
|
|
function getCanSettlementNum() {
|
|
function getCanSettlementNum() {
|
|
|
- if (deliveryRetation.value) {
|
|
|
|
|
- const { rratio1, rratio2, mindeliveryqty } = deliveryRetation.value
|
|
|
|
|
|
|
+ if (deliveryGoods.value) {
|
|
|
|
|
+ const { rratio1, rratio2, mindeliveryqty } = deliveryGoods.value
|
|
|
const result = enableqty * agreeunit * mindeliveryqty * (rratio2 / rratio1)
|
|
const result = enableqty * agreeunit * mindeliveryqty * (rratio2 / rratio1)
|
|
|
return result.toFixed(2)
|
|
return result.toFixed(2)
|
|
|
} else {
|
|
} else {
|
|
|
return '--'
|
|
return '--'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 需要合约手数 = (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1))) / (p1合约系数 / x合约系数)
|
|
|
|
|
- function getNeedContractNum() {
|
|
|
|
|
|
|
+ // (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1)))
|
|
|
|
|
+ function XQty() {
|
|
|
let result = 0
|
|
let result = 0
|
|
|
if (selected.value?.num) {
|
|
if (selected.value?.num) {
|
|
|
- if (deliveryRetation.value) {
|
|
|
|
|
- const { rratio1, rratio2, mindeliveryqty, xdeliveryratio, pdeliveryratio } = deliveryRetation.value
|
|
|
|
|
- result = selected.value.num / (agreeunit * mindeliveryqty * (rratio2 / rratio1)) / pdeliveryratio / xdeliveryratio
|
|
|
|
|
|
|
+ if (deliveryGoods.value) {
|
|
|
|
|
+ const { rratio1, rratio2, mindeliveryqty, xdeliveryratio, pdeliveryratio } = deliveryGoods.value
|
|
|
|
|
+ result = selected.value.num / (agreeunit * mindeliveryqty * (rratio2 / rratio1))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+ }
|
|
|
|
|
+ // 需要合约手数 = (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1))) / (p1合约系数 / x合约系数)
|
|
|
|
|
+ function PQty() {
|
|
|
|
|
+ let result = XQty()
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ if (deliveryGoods.value) {
|
|
|
|
|
+ const { xdeliveryratio, pdeliveryratio } = deliveryGoods.value
|
|
|
|
|
+ result = result / pdeliveryratio / xdeliveryratio
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return result
|
|
|
|
|
+ }
|
|
|
|
|
+ // 需要合约手数 = (选中的数量 / (合约单位 * 最小交割系数 * (仓单商品的单位r2/合约商品的单位r1))) / (p1合约系数 / x合约系数)
|
|
|
|
|
+ function getNeedContractNum() {
|
|
|
|
|
+ const result = PQty()
|
|
|
return result ? result.toFixed(decimalplace) : '--'
|
|
return result ? result.toFixed(decimalplace) : '--'
|
|
|
}
|
|
}
|
|
|
// 预估货款 = 需要合约手数 * 合约交割价 * 合约单位 + 升贴水
|
|
// 预估货款 = 需要合约手数 * 合约交割价 * 合约单位 + 升贴水
|
|
@@ -86,7 +129,7 @@ export function handleCalculation(selectedRow: QueryTradePositionRsp) {
|
|
|
let result = 0
|
|
let result = 0
|
|
|
if (selected.value) {
|
|
if (selected.value) {
|
|
|
if (num !== '--' && price !== '--') {
|
|
if (num !== '--' && price !== '--') {
|
|
|
- if (deliveryRetation.value) {
|
|
|
|
|
|
|
+ if (deliveryGoods.value) {
|
|
|
result = (+num) * (+price) * agreeunit + selected.value.pricemove
|
|
result = (+num) * (+price) * agreeunit + selected.value.pricemove
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -134,5 +177,5 @@ export function handleCalculation(selectedRow: QueryTradePositionRsp) {
|
|
|
value.num = +value.num.toFixed(decimalplace)
|
|
value.num = +value.num.toFixed(decimalplace)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return { getStepValue, getCanSettlementNum, getNeedContractNum, getEstimatedPayment, getDeliveryGoodsPrice, increase, decrease, selctedNum }
|
|
|
|
|
|
|
+ return { getStepValue, getCanSettlementNum, getNeedContractNum, getEstimatedPayment, XQty, PQty, getDeliveryGoodsPrice, increase, decrease, selctedNum }
|
|
|
}
|
|
}
|