huangbin 4 anni fa
parent
commit
b0bf4f6dca

+ 37 - 83
src/views/market/spot_trade/components/buy-sell-market/components/financing_delisting/components/choose-finance/index.vue

@@ -1,101 +1,55 @@
 <template>
-    <!-- 仓单贸易&仓单预售 融资-->
+  <!-- 仓单贸易&仓单预售 融资-->
 
-    <Drawer
-        :title="'选择融资方案'"
-        :placement="'right'"
-        :visible="visible"
-        width="486px"
-        height="580px"
-        @cancel="update"
-        class="topHigh financing"
-    >
-        <div class="financingCont">
-            <a-row class="f-t">
-                <a-col :span="7">融出方/名称</a-col>
-                <a-col :span="10">天数/保证金/利息</a-col>
-                <a-col :span="7">结息/起息天数</a-col>
-            </a-row>
-            <div
-                class="contBar"
-                v-for="(item, index) in list"
-                :key="index + 11"
-                @click="choose(item)"
-            >
-                <a-row class="firstRow">
-                    <a-col :span="17">{{item.username}}</a-col>
-                    <a-col :span="7" v-if="item.isautoloan">放款快</a-col>
-                </a-row>
-                <a-row class="secondRow">
-                    <a-col :span="7">{{item.productname}}</a-col>
-                    <a-col :span="10">
-                        <a-row class="middle">
-                            <a-col :span="7">{{item.financingdays}}天</a-col>
-                            <a-col :span="10">{{item.marginratio * 100}}%</a-col>
-                            <a-col :span="7">
-                                <!-- <div class="two">{{item.interestrate * 100}}%</div>
-                                <div class="two">{{item.interestrate * 100}}%</div>-->
-                                {{item.interestratemode === 3 ? item.interestrate : item.interestrate * 10000}}{{item.interestratemode === 3 ? '' : '‱'}}
-                            </a-col>
-                        </a-row>
-                    </a-col>
-                    <a-col :span="7">
-                        <div class="settle">
-                            <div>{{item.interestsettlemode === 1 ? '日' : '月'}}结</div>
-                            <div>{{item.interestminlen}}天起息</div>
-                        </div>
-                    </a-col>
-                </a-row>
-            </div>
-            <div class="noDataContBar" v-if="!list.length">
-                <div class="noData"></div>
-            </div>
-            <!-- <div class="contBar">
+  <Drawer :title="'选择融资方案'"
+          :placement="'right'"
+          :visible="visible"
+          width="486px"
+          height="580px"
+          @cancel="update"
+          class="topHigh financing">
+    <div class="financingCont">
+      <a-row class="f-t">
+        <a-col :span="7">融出方/名称</a-col>
+        <a-col :span="10">天数/保证金/利息</a-col>
+        <a-col :span="7">结息/起息天数</a-col>
+      </a-row>
+      <div class="contBar"
+           v-for="(item, index) in list"
+           :key="index + 11"
+           @click="choose(item)">
         <a-row class="firstRow">
-          <a-col :span="7">铜供应链金融</a-col>
-          <a-col :span="17">放款快</a-col>
+          <a-col :span="17">{{item.username}}</a-col>
+          <a-col :span="7"
+                 v-if="item.isautoloan">放款快</a-col>
         </a-row>
         <a-row class="secondRow">
-          <a-col :span="7">铜杆帮你采</a-col>
+          <a-col :span="7">{{item.productname}}</a-col>
           <a-col :span="10">
             <a-row class="middle">
-              <a-col :span="7">30天</a-col>
-              <a-col :span="10">30%</a-col>
-              <a-col :span="7">11%</a-col>
+              <a-col :span="7">{{item.financingdays}}天</a-col>
+              <a-col :span="10">{{(item.marginratio * 100).toFixed(2)}}%</a-col>
+              <a-col :span="7">
+                <!-- <div class="two">{{item.interestrate * 100}}%</div>
+                                <div class="two">{{item.interestrate * 100}}%</div>-->
+                {{item.interestratemode === 3 ? item.interestrate : (item.interestrate * 10000).toFixed(2)}}{{item.interestratemode === 3 ? '' : '‱'}}
+              </a-col>
             </a-row>
           </a-col>
           <a-col :span="7">
             <div class="settle">
-              <div>日结</div>
-              <div>1天起息</div>
+              <div>{{item.interestsettlemode === 1 ? '日' : '月'}}结</div>
+              <div>{{item.interestminlen}}天起息</div>
             </div>
           </a-col>
         </a-row>
       </div>
-      <div class="contBar">
-        <a-row class="firstRow">
-          <a-col :span="7">铜供应链金融</a-col>
-          <a-col :span="17">放款快</a-col>
-        </a-row>
-        <a-row class="secondRow">
-          <a-col :span="7">铜杆帮你采</a-col>
-          <a-col :span="10">
-            <a-row class="middle">
-              <a-col :span="7">30天</a-col>
-              <a-col :span="10">30%</a-col>
-              <a-col :span="7">11%</a-col>
-            </a-row>
-          </a-col>
-          <a-col :span="7">
-            <div class="settle">
-              <div>日结</div>
-              <div>1天起息</div>
-            </div>
-          </a-col>
-        </a-row>
-            </div>-->
-        </div>
-    </Drawer>
+      <div class="noDataContBar"
+           v-if="!list.length">
+        <div class="noData"></div>
+      </div>
+    </div>
+  </Drawer>
 </template>
 
 <script lang="ts">

+ 192 - 145
src/views/market/spot_trade/components/buy-sell-market/components/financing_delisting/index.vue

@@ -1,145 +1,172 @@
 <template>
-    <!-- 仓单贸易&仓单预售 买/卖 摘牌 -->
-    <Drawer
-        :title="'摘牌'"
-        :placement="'right'"
-        :visible="visible"
-        width="486px"
-        height="580px"
-        @cancel="cancel"
-        class="topHigh"
-    >
-        <div class="delisting">
-            <div class="formBar">
-                <a-form
-                    class="inlineForm dialogForm"
-                    ref="formRef"
-                    :model="formState"
-                    :rules="rules"
-                >
-                    <a-row :gutter="24">
-                        <a-col :span="24">
-                            <a-form-item label="交易账户" name="accountid">
-                                <a-select
-                                    class="inlineFormSelect"
-                                    style="width: 260px"
-                                    v-model:value="formState.accountid"
-                                    placeholder="请选择"
-                                >
-                                    <a-select-option
-                                        v-for="item in accountList"
-                                        :value="item.accountid"
-                                        :key="item.accountid"
-                                    >{{item.accountid}}</a-select-option>
-                                </a-select>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-                    <a-row :gutter="24">
-                        <a-col :span="24">
-                            <a-form-item label="挂牌方">
-                                <span class="white">{{selectedRow.username}}</span>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-                    <a-row :gutter="24">
-                        <a-col :span="24">
-                            <a-form-item label="基差" v-if="isFloat()">
-                                <span class="yellow">{{selectedRow.pricemove}}</span>
-                            </a-form-item>
-                            <a-form-item label="挂牌价格" v-if="!isFloat()">
-                                <span class="yellow">{{selectedRow.fixedprice}}</span>
-                            </a-form-item>
-                            <a-row :gutter="24">
-                                <a-col :span="24"></a-col>
-                            </a-row>
-                            <a-form-item label="挂牌数量">
-                                <span
-                                    class="white"
-                                >{{selectedRow.orderqty}}{{selectedRow.enumdicname}}</span>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-                    <a-row :gutter="24">
-                        <a-col :span="24">
-                            <a-form-item label="摘牌数量" name="num">
-                                <a-input-number
-                                    class="dialogInput yellowInput"
-                                    style="width: 260px"
-                                    :min="0"
-                                    v-model:value="formState.num"
-                                    :suffix="selectedRow.enumdicname"
-                                />
-                                <span class="input-enumdicname">{{selectedRow.enumdicname}}</span>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-                    <a-row :gutter="24">
-                        <a-col :span="24" class="mt-10">
-                            <a-form-item>
-                                <a-slider
-                                    ::min="0"
-                                    v-model:value="formState.num"
-                                    :max="selectedRow.orderqty"
-                                    class="formSlider"
-                                />
-                                <div class="unit">
-                                    <span>0</span>
-                                    <span>{{selectedRow.orderqty}}{{selectedRow.enumdicname}}</span>
-                                </div>
-                            </a-form-item>
-                        </a-col>
-                        <a-col :span="12">&nbsp;</a-col>
-                    </a-row>
-                    <a-row :gutter="24">
-                        <a-col :span="24" class="mt-10">
-                            <a-form-item
-                                label="融资方案"
-                                @click="openComponent({code: 'ChooseFinance'})"
-                                name="case"
-                            >
-                                <div class="way">
-                                    <div class="left">{{formState.case}}</div>
-                                    <div class="right">
-                                        <svg class="icon svg-icon" aria-hidden="true">
-                                            <use xlink:href="#icon-fangan" />
-                                        </svg>
-                                    </div>
-                                </div>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-
-                    <a-row :gutter="24">
-                        <a-col :span="24">
-                            <a-form-item label="挂牌金额">
-                                <span class="white">--</span>
-                                <span class="need">(需履约保证金5040.00)</span>
-                                <div class="tip">可用资金:10000.00</div>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-                    <a-row :gutter="24">
-                        <a-col :span="24" class="mt25">
-                            <a-form-item class="tc">
-                                <a-button class="listedBtn" @click="submit">融资买入</a-button>
-                                <a-button class="ml10 cancelBtn" @click="cancel">取消</a-button>
-                            </a-form-item>
-                        </a-col>
-                    </a-row>
-                </a-form>
-            </div>
-        </div>
-    </Drawer>
-    <!-- <ChooseFinance v-if="show"
-    @cancel="showAction" />-->
-    <component
-        :is="componentId"
-        v-if="componentId"
-        :selectedRow="selectedRow"
-        @update="choose"
-        @cancel="closeComponent"
-    ></component>
+  <!-- 仓单贸易&仓单预售 买/卖 摘牌 -->
+  <Drawer :title="'摘牌'"
+          :placement="'right'"
+          :visible="visible"
+          width="486px"
+          height="580px"
+          @cancel="cancel"
+          class="topHigh">
+    <div class="delisting">
+      <div class="formBar">
+        <a-form class="inlineForm dialogForm"
+                ref="formRef"
+                :model="formState"
+                :rules="rules">
+          <a-row :gutter="24">
+            <a-col :span="24">
+              <a-form-item label="交易账户"
+                           name="accountid">
+                <a-select class="inlineFormSelect"
+                          style="width: 260px"
+                          v-model:value="formState.accountid"
+                          placeholder="请选择">
+                  <a-select-option v-for="item in accountList"
+                                   :value="item.accountid"
+                                   :key="item.accountid">{{item.accountid}}</a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24">
+              <a-form-item label="挂牌方">
+                <span class="white ml8">{{selectedRow.username}}</span>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24">
+              <a-form-item label="基差"
+                           v-if="isFloat()">
+                <span class="yellow ml8">{{selectedRow.pricemove}}</span>
+              </a-form-item>
+              <a-form-item label="挂牌价格"
+                           v-if="!isFloat()">
+                <span class="yellow ml8">{{selectedRow.fixedprice}}</span>
+              </a-form-item>
+              <a-row :gutter="24">
+                <a-col :span="24"></a-col>
+              </a-row>
+              <a-form-item label="挂牌数量">
+                <span class="white ml8">{{selectedRow.orderqty}}{{selectedRow.enumdicname}}</span>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24"
+                   class="mt-10">
+              <a-form-item label="融资方案"
+                           @click="openComponent({code: 'ChooseFinance'})"
+                           name="caseId">
+                <div class="way">
+                  <div class="left">{{formState.case ? formState.case : '请选择'}}</div>
+                  <div class="right">
+                    <svg class="icon svg-icon"
+                         aria-hidden="true">
+                      <use xlink:href="#icon-fangan" />
+                    </svg>
+                  </div>
+                </div>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24"
+                 v-if="isBuy() && isWR()">
+            <a-col :span="24">
+              <a-form-item label="现货仓单"
+                           name="LadingBillId">
+                <a-select class="inlineFormSelect"
+                          style="width: 260px"
+                          v-model:value="formState.LadingBillId"
+                          placeholder="请选择">
+                  <a-select-option v-for="item in wrHoldList"
+                                   :value="item.id"
+                                   :key="item.id">{{item.name}}</a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24">
+              <a-form-item label="摘牌数量"
+                           class="relative"
+                           name="num">
+                <a-input-number class="dialogInput yellowInput"
+                                style="width: 260px"
+                                :min="0"
+                                :max="getMaxNum()"
+                                v-model:value="formState.num" />
+                <span class="input-enumdicname-absolute">{{selectedRow.enumdicname}}</span>
+                <div class="labelTip">({{selectedRow.minivalue}}{{selectedRow.enumdicname}}起)</div>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24"
+                   class="mt-20">
+              <a-form-item>
+                <a-slider ::min="0"
+                          v-model:value="formState.num"
+                          :max="selectedRow.orderqty"
+                          class="formSlider" />
+                <div class="unit">
+                  <span>0</span>
+                  <span>{{getMaxNum()}}{{selectedRow.enumdicname}}</span>
+                </div>
+              </a-form-item>
+            </a-col>
+            <a-col :span="12">&nbsp;</a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24"
+                   class="mt-20">
+              <a-form-item :label="isFloat() ? '估算金额' : '摘牌金额'">
+                <span class="white ml8">{{getMoney()}}</span>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24"
+                   class="mt-20">
+              <a-form-item :label="getMargin() ? '履约保证金' : ''">
+                <a-row>
+                  <a-col :span="8"
+                         v-if="getMargin()">
+                    <span class="white ml8">{{getMargin()}}</span>
+                  </a-col>
+                  <a-col :span="4"
+                         class="tr">
+                    <span class="grey1">可用资金</span>
+                  </a-col>
+                  <a-col :span="12">
+                    <span class="white ml8">{{getCanUseMoney(getSelectedAccount())}}</span>
+                  </a-col>
+                </a-row>
+              </a-form-item>
+            </a-col>
+          </a-row>
+          <a-row :gutter="24">
+            <a-col :span="24">
+              <a-form-item class="tc">
+                <a-button class="listedBtn"
+                          :loading="loading"
+                          :disabled="loading"
+                          @click="submit">{{isBuy() ? '卖出' : '买入'}}</a-button>
+                <a-button class="ml10 cancelBtn"
+                          @click="cancel">取消</a-button>
+              </a-form-item>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+    </div>
+  </Drawer>
+  <component :is="componentId"
+             v-if="componentId"
+             :selectedRow="selectedRow"
+             @update="choose"
+             @cancel="closeComponent"></component>
 </template>
 
 <script lang="ts">
@@ -149,12 +176,16 @@ import { WrOrderQuote, WrOrderQuoteDetail } from '@/services/go/wrtrade/interfac
 import { getAccountTypeList } from '@/services/bus/account';
 import { ModalEnum } from '@/common/constants/modalNameEnum';
 import { _closeModal } from '@/common/setup/modal/modal';
-import { handleForm, handleIs, handleSpotWarrant } from './setup';
+import { handleForm, handleSpotWarrant } from './setup';
 import { BuyOrSell } from '@/common/constants/enumCommon';
 import { EnumRouterName } from '@/common/constants/enumRouterName';
 import { handleModalComponent } from '@/common/setup/asyncComponent';
 import { WrFAProductDetail } from '@/services/go/wrtrade/interface';
 import { validateAction } from '@/common/setup/form';
+import { handleNumAndMoney, getWrPosition, selecedFinance } from './setup';
+import { handleIs } from '../../setup';
+import { getCanUseMoney } from '@/services/bus/account';
+
 export default defineComponent({
     name: ModalEnum.spot_trade_warehouse_delisting,
     components: { Drawer, ChooseFinance: defineAsyncComponent(() => import('./components/choose-finance/index.vue')) },
@@ -180,14 +211,23 @@ export default defineComponent({
 
     setup(props, context) {
         const { visible, cancel } = _closeModal(context);
+        // 资金账号
         const accountList = getAccountTypeList([2]);
         const { rules, formState, formRef } = handleForm(props.selectedRow);
         if (accountList.length) {
             formState.accountid = accountList[0].accountid;
         }
+        function getSelectedAccount() {
+            return accountList.find((e) => e.accountid === formState.accountid);
+        }
         const loading = ref<boolean>(false);
-        const { isSale, isBuy, isFloat } = handleIs(props.enumName, props.buyOrSell);
+        // 判断
+        const { isWR, isBuy, isFloat } = handleIs(props.enumName, props.buyOrSell);
+        // 现货仓单
         const { wrHoldList } = handleSpotWarrant(props.enumName, props.buyOrSell, props.parantSelectedRow, loading);
+        getWrPosition(props.enumName, props.buyOrSell, loading);
+        const { getMaxNum, getMoney, getMargin } = handleNumAndMoney(props.enumName, props.buyOrSell, props.selectedRow, props.parantSelectedRow, formState);
+
         const { componentId, closeComponent, openComponent } = handleModalComponent(() => {}, ref({}));
 
         const show = ref<boolean>(false);
@@ -195,7 +235,9 @@ export default defineComponent({
             show.value = !show.value;
         }
         function choose(item: WrFAProductDetail) {
-            formState.case = `${item.productname}-${item.username}-${item.financingdays}天-${item.marginratio * 100}%-${item.interestratemode === 3 ? item.interestrate : item.interestrate * 10000}%-${item.interestsettlemode === 1 ? '按日结息' : '按月结息'}-${item.interestminlen}天起息`;
+            selecedFinance.value = item;
+            formState.caseId = item.productdetailid;
+            formState.case = `${item.productname}-${item.username}-${item.financingdays}天-${(item.marginratio * 100).toFixed(2)}%-${item.interestratemode === 3 ? item.interestrate : (item.interestrate * 10000).toFixed(2)}%-${item.interestsettlemode === 1 ? '按日结息' : '按月结息'}-${item.interestminlen}天起息`;
         }
         function submit() {
             // validateAction<ListingForm>(formRef, formState).then((res) => {
@@ -241,9 +283,12 @@ export default defineComponent({
             accountList,
             wrHoldList,
             submit,
-            isSale,
+            getMaxNum,
+            getMoney,
+            getMargin,
             isBuy,
             isFloat,
+            isWR,
             rules,
             formState,
             formRef,
@@ -252,6 +297,8 @@ export default defineComponent({
             componentId,
             closeComponent,
             openComponent,
+            getCanUseMoney,
+            getSelectedAccount,
         };
     },
 });

+ 1 - 1
src/views/market/spot_trade/components/buy-sell-market/components/financing_delisting/interface.ts

@@ -3,7 +3,7 @@ export interface ListingForm {
     num: number,
     LadingBillId: string,
     case: string,
-    caseId: string,
+    caseId: number,
 }
 
 export interface Wrhold {

+ 136 - 32
src/views/market/spot_trade/components/buy-sell-market/components/financing_delisting/setup.ts

@@ -1,11 +1,16 @@
 import { BuyOrSell } from "@/common/constants/enumCommon";
 import { EnumRouterName } from "@/common/constants/enumRouterName";
 import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
-import { queryHoldLB } from '@/services/go/wrtrade';
-import { WrHoldLB, WrOrderQuote, WrOrderQuoteDetail } from "@/services/go/wrtrade/interface";
+import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
+import { AccountListItem } from "@/services/dataCenter/interafce/account";
+import { queryHoldLB, queryWrPosition } from '@/services/go/wrtrade';
+import { QueryWrPositionReq, WrFAProductDetail, WrHoldLB, WrOrderQuote, WrOrderQuoteDetail, WrPosition } from "@/services/go/wrtrade/interface";
 import { reactive, Ref, ref, UnwrapRef } from "vue";
+import { getGoodsPrice, getRules, handleIs } from "../../setup";
 import { ListingForm, Wrhold } from "./interface";
 
+export const selecedFinance = ref<WrFAProductDetail>()
+
 export function handleForm(data: WrOrderQuoteDetail) {
     const formRef = ref();
     const formState: UnwrapRef<ListingForm> = reactive({
@@ -13,55 +18,45 @@ export function handleForm(data: WrOrderQuoteDetail) {
         num: 0,
         LadingBillId: '',
         case: '',
-        caseId: ''
+        caseId: 0
     })
     const rules = {
         accountid: [{ required: true, message: '请选择交易账户' }],
         LadingBillId: [{ required: true, message: '请选择现货仓单' }],
+        caseId: [{ required: true, message: '请选择融资方案' }],
         num: [{ required: true, message: '请输入摘牌数量', trigger: 'blur', type: 'number', min: 1, ma: data.orderqty }],
 
     }
     return { rules, formState, formRef }
 }
 
-
-export function handleIs(enumName: EnumRouterName, buyOrSell: BuyOrSell) {
-    /**
-     *
-     * @returns true => 仓单预售; false => 仓单贸易
-     */
-    function isSale(): boolean {
-        return enumName === EnumRouterName.warehouse_pre_sale_price ||
-            enumName === EnumRouterName.warehouse_pre_sale_floating_price
-    }
-    /**
-     *
-     * @returns true => 买; false =>卖
-     */
-    function isBuy() {
-        return buyOrSell === BuyOrSell.buy
+// 预售仓单汇总
+const wrPostion = ref<WrPosition[]>([])
+export function getWrPosition(enumName: EnumRouterName, buyOrSell: BuyOrSell, loading: Ref<boolean>) {
+    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
+    if (isBuy() && !isWR()) {
+        const param: QueryWrPositionReq = {
+            haswr: 0,
+            querytype: 2,
+        };
+        queryResultLoadingAndInfo(queryWrPosition, loading, param).then(res => {
+            wrPostion.value = res;
+        })
     }
-    /**
-     *
-     * @returns  true => 浮动价; false =>一口价
-     */
-    function isFloat() {
-        return enumName === EnumRouterName.warehouse_receipt_trade_floating_price ||
-            enumName === EnumRouterName.warehouse_pre_sale_floating_price
-    }
-    return { isSale, isBuy, isFloat }
 }
 
+const allWR = ref<WrHoldLB[]>([])
 // 处理现货仓单
 export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuote, loading: Ref<boolean>) {
-    const { isSale, isBuy } = handleIs(enumName, buyOrSell)
+    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
     const wrHoldList = ref<Wrhold[]>([])
     if (isBuy()) {
-        if (!isSale()) {
+        if (isWR()) {
             queryResultLoadingAndInfo(queryHoldLB, loading).then(res => {
+                allWR.value = res;
                 wrHoldList.value = res.filter((e: WrHoldLB) => e.wrfactortypeid === String(selectedRow.wrfactortypeid)).map((e: WrHoldLB) => {
-                    const { wrholdeno, enableqty, ladingbillid } = e
-                    return { id: ladingbillid, name: `${wrholdeno}(${enableqty})` }
+                    const { wrholdeno, enableqty, ladingbillid, enumdicname } = e
+                    return { id: ladingbillid, name: `${wrholdeno}(${enableqty}${enumdicname})` }
                 })
             })
         }
@@ -69,3 +64,112 @@ export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell
     return { wrHoldList }
 }
 
+// // 处理现货仓单
+// export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuote, loading: Ref<boolean>) {
+//     const { isWR, isBuy } = handleIs(enumName, buyOrSell)
+//     const wrHoldList = ref<Wrhold[]>([])
+//     if (isBuy()) {
+//         if (isWR()) {
+//             queryResultLoadingAndInfo(queryHoldLB, loading).then(res => {
+//                 wrHoldList.value = res.filter((e: WrHoldLB) => e.wrfactortypeid === String(selectedRow.wrfactortypeid)).map((e: WrHoldLB) => {
+//                     const { wrholdeno, enableqty, ladingbillid } = e
+//                     return { id: ladingbillid, name: `${wrholdeno}(${enableqty})` }
+//                 })
+//             })
+//         }
+//     }
+//     return { wrHoldList }
+// }
+
+export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuoteDetail, parantSelectedRow: WrOrderQuote, formState: UnwrapRef<ListingForm>) {
+    const { isWR, isBuy, isFloat } = handleIs(enumName, buyOrSell)
+    // 资金账号
+    const accountList = getAccountTypeList([2]);
+    // 获取选中的资金账号
+    const getSelectedAccount = () => accountList.find((e) => e.accountid === formState.accountid);
+    // 交易规则
+    const rules = getRules().value
+    // 是否有规则
+    const hasRule = () => rules.length > 0;
+    //保证金模式 1: 比率 2: 固定
+    const marginMethod = (buymarginalgorithm: number) => buymarginalgorithm === 1
+    const { fixedprice, orderqty, pricemove } = selectedRow;
+    // 获取摘牌最大可摘量
+    function getMaxNum() {
+        let result = 0;
+        if (hasRule()) {
+            const { buymarginvalue, buymarginalgorithm } = rules[0]
+            // 可用资金
+            const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
+            if (!isBuy()) {
+                if (isFloat()) {
+                    const goodsPrice = getGoodsPrice()
+                    // 估算总价=挂牌基差+期货合约价;
+                    if (goodsPrice.value && goodsPrice.value !== '--') {   // 有实时行情价格
+                        // 估算总价
+                        const predictTotal = pricemove + (goodsPrice.value as number);
+                        // 买方履约保证金比例*估算总价
+                        const marginMoney = marginMethod(buymarginalgorithm) ? (buymarginvalue * predictTotal) : (buymarginvalue + predictTotal)
+                        // 浮动价 摘买 最大数量=min{可用资金/(买方履约保证金比例*估算总价),挂牌数量}
+                        result = Math.min(orderqty, canUseMoney / marginMoney)
+                    }
+                } else {
+                    // 买方履约保证金比例*挂牌价格
+                    const marginMoney = marginMethod(buymarginalgorithm) ? (buymarginvalue * fixedprice) : (buymarginvalue + fixedprice)
+                    //  一口价 摘买 最大数量=min{挂牌数量,可用资金/(买方履约保证金比例*挂牌价格)
+                    result = Math.min(orderqty, canUseMoney / marginMoney)
+                }
+            } else {
+                if (isWR()) {
+                    if (formState.LadingBillId) {
+                        // 现货库存数量
+                        const warehouseNum = allWR.value.find((e) => e.ladingbillid === formState.LadingBillId)?.enableqty;
+                        // 仓单贸易 一口价/浮动价 摘卖 最大数量=min(现货库存可用数量,挂牌数量),现货库存数量为所选仓单数量
+                        if (warehouseNum) {
+                            result = Math.min(orderqty, warehouseNum)
+                        }
+                    }
+                } else {
+                    // 获取头寸
+                    const item = wrPostion.value.find(e => String(e.wrfactortypeid) === String(parantSelectedRow.wrfactortypeid))
+                    if (item) {
+                        result = item.enalbeqty
+                    }
+                }
+            }
+        }
+        return Math.floor(result)
+    }
+    //  摘牌金额
+    function getMoney() {
+        let result = 0
+        if (isFloat()) {
+            const goodsPrice = getGoodsPrice()
+            if (goodsPrice.value && goodsPrice.value !== '--') {   // 有实时行情价格
+                // 估算总价=挂牌基差+期货合约价;
+                const predictTotal = pricemove + (goodsPrice.value as number);
+                // 估算总额=估算总价*摘牌数量;
+                result = predictTotal * formState.num
+            }
+        } else {
+            // 摘牌金额=挂牌价格*摘牌数量
+            result = formState.num * orderqty
+        }
+        return Number(result.toFixed(2))
+    }
+    // 履约保证金
+    function getMargin() {
+        // fixed sell  履约保证金=卖方履约保证金比例*摘牌金额
+        // fixed bull  履约保证金=买方履约保证金比例*摘牌金额
+        // floor sell  履约保证金=卖方履约保证金比例*估算总额,履约保证金为0则括号内容不显示
+        //  floor  buy 履约保证金=买方履约保证金比例*估算总额
+        let result = 0
+        if (hasRule()) {
+            if (selecedFinance.value) {
+                result = selecedFinance.value.marginratio * getMoney()
+            }
+        }
+        return Number(result.toFixed(2))
+    }
+    return { getMaxNum, getMoney, getMargin }
+}