li.shaoyi hace 4 años
padre
commit
80fd732709

+ 1 - 1
src/common/components/capitalInfo/index.vue

@@ -39,7 +39,7 @@
           </tr>
           <tr>
             <td>浮盈</td>
-            <td :class="tradeAccount.positionProfitAndLoss > 0 ? 'up-quote-color' : 'down-quote-color'">{{showValue(tradeAccount.positionProfitAndLoss.toFixed(2))}}</td>
+            <td :class="{ 'up-quote-color': tradeAccount.positionProfitAndLoss > 0, 'down-quote-color': tradeAccount.positionProfitAndLoss < 0 } ">{{showValue(tradeAccount.positionProfitAndLoss.toFixed(2))}}</td>
           </tr>
           <tr>
             <td>风险率</td>

+ 5 - 2
src/hooks/account/index.ts

@@ -247,13 +247,16 @@ function calcCapitalValue(account: Taaccount, positionList: TradePosition[]) {
         const flag = systemParams.find((e) => e.paramcode === '132')?.paramvalue === '1';
         const { usedmargin, mortgagecredit } = account;
 
+        let result = 0
         if (flag) {
             // 风险率 = 占用 / 风险净值
-            return usedmargin / valueAtRisk.value;
+            result = usedmargin / valueAtRisk.value;
         } else {
             // 风险率 = (占用 - 授信金额) / (风险净值 - 授信金额)
-            return (usedmargin - mortgagecredit) / (valueAtRisk.value - mortgagecredit);
+            result = (usedmargin - mortgagecredit) / (valueAtRisk.value - mortgagecredit);
         }
+
+        return isNaN(result) ? 0 : result;
     })
 
     return {

+ 4 - 0
src/main.ts

@@ -8,8 +8,12 @@ import Antd, { message } from 'ant-design-vue';
 import { createApp } from 'vue';
 import App from './App.vue';
 import router from './router';
+import directive from "./views/market/futures/directive"; // 自定义指令集
+
 const app = createApp(App);
+app.use(directive);
 app.use(router);
 app.use(Antd).mount('#app');
+
 // 配置全局属性
 app.config.globalProperties.$message = message;

+ 14 - 0
src/views/market/futures/directive.ts

@@ -0,0 +1,14 @@
+
+import { App, Component } from 'vue';
+
+const install: Component = (app: App) => {
+    app.directive('resize', {
+        mounted(el, binding) {
+            debugger
+        },
+    })
+}
+
+export default {
+    install,
+}