index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div class="capital-info">
  3. <!-- 资金信息 -->
  4. <a-select
  5. class="capitalSelect"
  6. style="width: 180px"
  7. v-if="false"
  8. @change="accountChange"
  9. v-model:value="selectedAccountId"
  10. >
  11. <a-select-option
  12. v-for="item in getAllTaAccount()"
  13. :value="item.accountid"
  14. :key="item.accountid"
  15. >{{ item.accountid }}</a-select-option>
  16. </a-select>
  17. <div class="numBlocks">
  18. <div class="capitalItem">
  19. <div class="firstLine">
  20. <div>资金账号</div>
  21. <div>
  22. <i class="iconfont icon-zhengyan" @click="showAction"></i>
  23. </div>
  24. </div>
  25. <div class="numBar">{{ showValue(getSelectedAccount().accountid) }}</div>
  26. </div>
  27. <div class="capitalItem">
  28. <div class="firstLine">
  29. <div>余额</div>
  30. <!-- <div>
  31. <i class="iconfont icon-zhengyan" @click="showAction"></i>
  32. </div>-->
  33. </div>
  34. <div class="numBar">{{ showValue(data.currentbalance) }}</div>
  35. </div>
  36. <!-- <div class="capitalItem">
  37. <div class="firstLine">
  38. <div>占用</div>
  39. </div>
  40. <div class="numBar green">128,000.00</div>
  41. </div>-->
  42. <div class="capitalItem">
  43. <div class="firstLine">
  44. <div>冻结</div>
  45. </div>
  46. <div class="numBar red">{{ showValue(data.freeze) }}</div>
  47. </div>
  48. <div class="capitalItem">
  49. <div class="firstLine">
  50. <div>可用</div>
  51. </div>
  52. <div class="numBar blue">{{ showValue(canUseMoney(getSelectedAccount())) }}</div>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. <script lang="ts">
  58. import { defineComponent, ref, reactive } from 'vue';
  59. import { getAllTaAccount, getCanUseMoney, getFreeze, getSelectedAccount, setSelectedAccount } from '@/services/bus/account';
  60. import { AccountListItem } from '@/services/dataCenter/interafce/account';
  61. import Bus from '@/utils/eventBus/index';
  62. import { getTaAccount } from '@/services/go/TaAccount';
  63. import { useHazardRates } from '@/views/order/funding_information/components/funding_information_funding_summary/setup'
  64. import { initData } from '@/common/methods';
  65. export default defineComponent({
  66. name: 'capital-info',
  67. setup(props, context) {
  68. // 当前选中的资金账号
  69. const selectedAccount = getSelectedAccount();
  70. const selectedAccountId = ref<number>(selectedAccount.accountid);
  71. const data = reactive(getMoney(selectedAccount));
  72. const show = ref<boolean>(true);
  73. function showAction() {
  74. show.value = !show.value;
  75. }
  76. // 脱敏处理
  77. function showValue(value: number | string) {
  78. return show.value ? value : '******';
  79. }
  80. const loading = ref<boolean>(false)
  81. const { canUseMoney, getHoldsList } = useHazardRates();
  82. initData(() => {
  83. // 获取头寸
  84. getHoldsList(loading)
  85. })
  86. function getMoney(value: AccountListItem) {
  87. const { currentbalance } = value;
  88. return { currentbalance, freeze: getFreeze(value, true), canUse: getCanUseMoney(value) };
  89. }
  90. function accountChange(id: number) {
  91. const item = getAllTaAccount().find((e) => e.accountid === id) as AccountListItem;
  92. Object.assign(data, getMoney(item));
  93. setSelectedAccount(item);
  94. }
  95. // 资金变化,重新加载数据
  96. Bus.$on('moneyChangedNtf_UI', () => {
  97. getTaAccount().then(() => {
  98. accountChange(selectedAccountId.value);
  99. });
  100. });
  101. return {
  102. getAllTaAccount,
  103. selectedAccountId,
  104. accountChange,
  105. data,
  106. show,
  107. showValue,
  108. showAction,
  109. loading,
  110. canUseMoney,
  111. getSelectedAccount,
  112. };
  113. },
  114. });
  115. </script>
  116. <style lang="less">
  117. .capital-info {
  118. width: 100%;
  119. height: 100%;
  120. background: @m-grey6;
  121. .ant-select.capitalSelect {
  122. .ant-select-selector {
  123. width: 180px;
  124. height: 40px;
  125. line-height: 40px;
  126. background: @m-grey6;
  127. border: 1px solid @m-blue0;
  128. .ant-select-selection-item {
  129. font-size: 14px;
  130. color: @m-white0;
  131. line-height: 40px;
  132. }
  133. }
  134. }
  135. .numBlocks {
  136. padding: 10px 12px 18px 12px;
  137. }
  138. .capitalItem {
  139. width: 100%;
  140. padding-top: 10px;
  141. font-size: 14px;
  142. color: @m-grey1;
  143. .firstLine {
  144. width: 100%;
  145. .inlineflex;
  146. justify-content: space-between;
  147. height: 18px;
  148. line-height: 18px;
  149. .iconfont {
  150. font-size: 18px;
  151. color: @m-black3;
  152. }
  153. }
  154. .numBar {
  155. width: 100%;
  156. margin-top: 12px;
  157. height: 16px;
  158. line-height: 16px;
  159. font-size: 16px;
  160. text-align: left;
  161. color: @m-white0;
  162. margin-bottom: 8px;
  163. }
  164. .green {
  165. color: @m-green0;
  166. }
  167. .red {
  168. color: @m-red1;
  169. }
  170. .blue {
  171. color: @m-blue0;
  172. }
  173. }
  174. .capitalCollapse {
  175. height: 100%;
  176. background: transparent;
  177. .ant-collapse-item {
  178. height: 100%;
  179. border: 0;
  180. .ant-collapse-header {
  181. width: 100%;
  182. padding: 0 25px 0 12px;
  183. height: 40px;
  184. line-height: 40px;
  185. border: 1px solid @m-blue0;
  186. border-left: 0;
  187. font-size: 14px;
  188. font-family: Adobe Heiti Std;
  189. color: @m-white0;
  190. .ellipse;
  191. .ant-collapse-arrow {
  192. right: 10px;
  193. }
  194. }
  195. .ant-collapse-content {
  196. height: calc(100% - 60px);
  197. overflow: auto;
  198. .ant-collapse-content-box {
  199. padding: 10px 12px;
  200. .flex();
  201. flex-direction: column;
  202. }
  203. }
  204. }
  205. }
  206. }
  207. </style>;