|
|
@@ -1,11 +1,16 @@
|
|
|
import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request";
|
|
|
+import { validateCommon } from "@/common/setup/validate";
|
|
|
+import { QueryAccMgrLoginUser } from "@/services/go/ermcp/account";
|
|
|
+import { ErmcpLoginUserEx } from "@/services/go/ermcp/account/interface";
|
|
|
import { QueryDeliveryGoodsDetail } from '@/services/go/ermcp/goodsInfo';
|
|
|
-import { ErmcpDeliveryGoodsDetailEx } from "@/services/go/ermcp/goodsInfo/interface";
|
|
|
+import { Ermcp3Wrstandard, ErmcpDeliveryGoodsDetailEx } from "@/services/go/ermcp/goodsInfo/interface";
|
|
|
import { hedgePlanReq, oldHedgePlanReq } from "@/services/proto/hedgeplan";
|
|
|
import { ErmcpHedgePlanReq, HedgePlanOperateReq } from "@/services/proto/hedgeplan/interface";
|
|
|
import { deletePlanSign, hedgePlanSign } from "@/views/business/plan/setup";
|
|
|
import { message } from "ant-design-vue";
|
|
|
-import { ref, Ref } from "vue";
|
|
|
+import { RuleObject } from "ant-design-vue/lib/form/interface";
|
|
|
+import { reactive, ref, Ref, UnwrapRef } from "vue";
|
|
|
+import { FormState } from "./interface";
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -36,7 +41,36 @@ export function cancelPlan(req: HedgePlanOperateReq, loading: Ref<boolean>): Pro
|
|
|
* 表单
|
|
|
*/
|
|
|
export function handleForm() {
|
|
|
+ const formRef = ref();
|
|
|
+ const formState: UnwrapRef<FormState> = reactive({
|
|
|
+ HedgePlanNo: '',// string 套保计划名称
|
|
|
+ ContractType: undefined,// int32 计划类型-1:采购-1:销售
|
|
|
+ DeliveryGoodsID: undefined,// uint64 现货品种ID
|
|
|
+ PlanQty: '', // double 计划数量
|
|
|
+ ConvertFactor: 1, // double 标仓系数
|
|
|
+ Remark: '', // string 计划备注
|
|
|
+ OperateType: 2, // int32 操作类型-1:保存草稿2:提交申请
|
|
|
+ WRStandardID: undefined, // uint64 现货品类ID
|
|
|
+ Tradeuserid: undefined, // uint64 交易用户ID
|
|
|
+ Currencyid: undefined, // uint64 结算币种ID
|
|
|
+ })
|
|
|
|
|
|
+ const v_ContractType = async (rule: RuleObject, value: number) => {
|
|
|
+ return validateCommon(value, '请选择计划类型');
|
|
|
+ };
|
|
|
+ const v_DeliveryGoodsID = async (rule: RuleObject, value: number) => {
|
|
|
+ return validateCommon(value, '请选择现货品种');
|
|
|
+ };
|
|
|
+ const v_Currencyid = async (rule: RuleObject, value: number) => {
|
|
|
+ return validateCommon(value, '请选择结算币种');
|
|
|
+ };
|
|
|
+ const rules = {
|
|
|
+ PlanQty: [{ required: true, message: '请输入计划数量', trigger: 'blur' }],
|
|
|
+ ContractType: [{ required: true, validator: v_ContractType, trigger: 'change' }],
|
|
|
+ DeliveryGoodsID: [{ required: true, validator: v_DeliveryGoodsID, trigger: 'change' }],
|
|
|
+ Currencyid: [{ required: true, validator: v_Currencyid, trigger: 'change' }],
|
|
|
+ }
|
|
|
+ return { formRef, formState, rules }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -45,6 +79,8 @@ export function handleForm() {
|
|
|
export function getMiddleGoodsD() {
|
|
|
// 现货品种列表
|
|
|
const DGList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
|
|
|
+ // 品类
|
|
|
+ const gmlist = ref<Ermcp3Wrstandard[]>([])
|
|
|
// 获取品种数据
|
|
|
function getDG() {
|
|
|
QueryDeliveryGoodsDetail().then(res => {
|
|
|
@@ -53,7 +89,33 @@ export function getMiddleGoodsD() {
|
|
|
}
|
|
|
// 选中品种数据
|
|
|
function chooseMG(id: number) {
|
|
|
+ const temp = DGList.value.find(e => e.data.deliverygoodsid === id)
|
|
|
+ gmlist.value = temp ? temp.gmlist : []
|
|
|
+ }
|
|
|
+ return { DGList, getDG, gmlist, chooseMG }
|
|
|
+}
|
|
|
|
|
|
+/**
|
|
|
+ * 交易用户
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+export function handleTrader() {
|
|
|
+ // 交易用户
|
|
|
+ const traderList = ref<ErmcpLoginUserEx[]>([])
|
|
|
+ function getRoleList() {
|
|
|
+ QueryAccMgrLoginUser(2).then(res => {
|
|
|
+ const set = new Set<number>([])
|
|
|
+ traderList.value.length = 0;
|
|
|
+ res.forEach(e => {
|
|
|
+ const { roleid, rolename, accountstatus } = e;
|
|
|
+ if (accountstatus === 4) { // 账户的状态 - 4 正常
|
|
|
+ if (!set.has(roleid)) { // 去重
|
|
|
+ set.add(roleid)
|
|
|
+ traderList.value.push(e)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(err => message.error(err))
|
|
|
}
|
|
|
- return { DGList, getDG }
|
|
|
+ return { traderList, getRoleList }
|
|
|
}
|