huangbin 4 лет назад
Родитель
Сommit
108c4239c1

+ 3 - 4
src/layout/components/header.vue

@@ -5,7 +5,7 @@
   </div>
   <div class="m-layout-header-right">
     <div @click="openDrawer">
-      <span>{{ username }},您好!</span>
+      <span>{{ getUserName() }},您好!</span>
     </div>
     <div class="relative">
       <!-- <a-input-search ref="userNameInput"
@@ -46,10 +46,10 @@
 
 <script lang="ts">
 import { defineComponent, ref, provide } from 'vue';
-import APP from '@/services';
 import { openModal } from '@/common/setup/modal/index';
 import { UserOutlined } from '@ant-design/icons-vue';
 import Setting from '@/views/setting/index.vue';
+import { getUserName } from '@/services/bus/user';
 
 // 设置
 const setFn = () => {
@@ -94,11 +94,10 @@ export default defineComponent({
         },
     },
     setup() {
-        const username = APP.get('username');
         const { openAction: openNotice } = openModal('notice');
         return {
-            username,
             openNotice,
+            getUserName,
             ...setFn(),
             ...onSearch(),
         };

+ 23 - 0
src/services/bus/user.ts

@@ -6,4 +6,27 @@ import APP from '@/services';
  */
 export function getUserAccountType() {
     return APP.get('userAccount').usertype
+}
+
+/**
+ * 获取用户
+ */
+export function getUserInfo() {
+    return APP.get('userInfo')
+}
+
+/**
+ * 获取用户名
+ * @returns 
+ */
+export function getUserName() {
+    return getUserInfo().customername
+}
+
+/**
+ * 获取用户id 
+ * 登录中也写了一个 获取用户id的方法,那个方法是在登录信息里面获取用户id,这个方法是在go服务修改登录请求方法,返回用户信息,后期有时间进行优化
+ */
+export function getUsrId() {
+    return getUserInfo().userid
 }

+ 10 - 11
src/services/go/useInfo/index.ts

@@ -1,7 +1,7 @@
-import { commonSearch_go } from '../index'
-import * as type from './interface'
 import APP from '@/services';
 import { getLongTypeLoginID } from '@/services/bus/login';
+import { commonSearch_go } from '../index';
+import * as type from './interface';
 
 /**
  * 获取登录ID
@@ -30,13 +30,13 @@ export function LoginQuery(): Promise<type.LoginQueryRsp> {
     const id = getLongTypeLoginID();
     return commonSearch_go('/User/LoginQuery', { loginID: Number(id) }).then(res => {
         const { externalExchanges,
-                goodsgroups,
-                loginAccount,
-                markets,
-                systemParams,
-                userAccount,
-                userInfo,
-                username }= res;
+            goodsgroups,
+            loginAccount,
+            markets,
+            systemParams,
+            userAccount,
+            userInfo,
+            username } = res;
         externalExchanges && APP.set('externalexchange', externalExchanges);
         goodsgroups && APP.set('goodsgroups', goodsgroups);
         loginAccount && APP.set('loginAccount', loginAccount);
@@ -46,7 +46,6 @@ export function LoginQuery(): Promise<type.LoginQueryRsp> {
         userInfo && APP.set('userInfo', userInfo);
         username && APP.set('username', username);
         console.log('LoginQuery', res);
-
         return res
     })
 }
@@ -56,6 +55,6 @@ export function LoginQuery(): Promise<type.LoginQueryRsp> {
  * @returns
  */
 export function QueryUserInfo(userID: number, isDecrypt?: boolean): Promise<type.Userinfo> {
-    const param = isDecrypt ? { isDecrypt, userID } : {userID }
+    const param = isDecrypt ? { isDecrypt, userID } : { userID }
     return commonSearch_go('/User/QueryUserInfo', param)
 }

+ 22 - 18
src/views/information/spot-contract/components/add/index.vue

@@ -83,7 +83,7 @@
             <a-col :span="12">
               <a-form-item label="销售方"
                            name="SellUserID">
-                <span class="white">河北石家庄刚强矿石公司</span>
+                <span class="white">{{getUserName()}}</span>
               </a-form-item>
             </a-col>
           </template>
@@ -91,7 +91,7 @@
             <a-col :span="12">
               <a-form-item label="采购方"
                            name="BuyUserID">
-                <span class="white">河北石家庄刚强矿石公司</span>
+                <span class="white">{{getUserName()}}</span>
               </a-form-item>
             </a-col>
             <a-col :span="12">
@@ -215,8 +215,10 @@
             </a-form-item>
           </a-col>
           <a-col :span="12">
-            <a-form-item label="结算币种">
+            <a-form-item label="结算币种"
+                         name="CurrencyID">
               <a-select class="inlineFormSelect"
+                        v-model:value="formState.CurrencyID"
                         style="width: 200px"
                         placeholder="请选择结算币种">
                 <a-select-option v-for="item in payCurrency"
@@ -231,13 +233,14 @@
             <a-form-item label="数量">
               <a-input class="dialogInput suffixGrey"
                        placeholder="请输入数量"
-                       suffix="单位" />
+                       :suffix="numberUnit" />
             </a-form-item>
           </a-col>
           <a-col :span="12"
                  v-if="formState.PriceType === 3">
             <a-form-item label="暂定价">
               <a-input class="dialogInput suffixGrey"
+                       :suffix="payCurrencyUnit"
                        placeholder="请输入暂定价" />
             </a-form-item>
           </a-col>
@@ -261,7 +264,7 @@
               <a-form-item label="升贴水">
                 <a-input class="dialogInput suffixGrey"
                          placeholder="请输入升贴水"
-                         suffix="元/单位"
+                         :suffix="`${payCurrencyUnit}/${numberUnit}`"
                          style="width: 200px" />
               </a-form-item>
             </a-col>
@@ -310,15 +313,18 @@
               <a-form-item label="价格">
                 <a-input class="dialogInput suffixGrey"
                          placeholder="请输入价格"
-                         suffix="元/单位"
+                         :suffix="`${payCurrencyUnit}/${numberUnit}`"
                          style="width: 200px" />
               </a-form-item>
             </a-col>
             <a-col :span="12">
               <a-form-item label="金额"
                            class="relative">
-                <span class="white">输入数量和价格后自动算</span>
-                <span class="unit">元</span>
+                <a-input class="dialogInput suffixGrey"
+                         readonly
+                         placeholder="输入数量和价格后自动算"
+                         :suffix="payCurrencyUnit"
+                         style="width: 200px" />
               </a-form-item>
             </a-col>
             <a-col :span="24">
@@ -350,7 +356,7 @@
             <a-form-item label="保证金">
               <a-input class="dialogInput suffixGrey"
                        placeholder="请输入保证金"
-                       suffix="元" />
+                       :suffix="payCurrencyUnit" />
             </a-form-item>
           </a-col>
           <a-col :span="12">
@@ -417,6 +423,7 @@ import { defineComponent, ref } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods';
 import { handleFromState, handleContract, handlevalidate, handleDeliveryGoods, handlePrice } from './setup';
+import { getUserName } from '@/services/bus/user';
 
 export default defineComponent({
     name: 'add-spot-contract',
@@ -445,15 +452,9 @@ export default defineComponent({
             SpotGoodsDesc: [{ required: true, message: '请输入商品规格', trigger: 'blur' }],
         };
         //  处理现货商品
-        const { deliveryGoodsList, gblist, gmlist, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods();
-        // 品类变更
-        function WrStandardChange(value: number) {
-            const obj = gmlist.value.find((e) => e.wrstandardid === value);
-            //标仓系数
-            formState.ConvertFactor = obj?.convertfactor;
-        }
+        const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
         // 价格信息
-        const { priceType, payCurrency, isPriceType } = handlePrice(formState);
+        const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
         function submit() {
             loading.value = true;
             setTimeout(() => {
@@ -485,7 +486,10 @@ export default defineComponent({
             WrStandardChange,
             priceType,
             payCurrency,
-            isPriceType,
+            payCurrencyUnit,
+            parCurrencyChange,
+            numberUnit,
+            getUserName,
         };
     },
 });

+ 1 - 0
src/views/information/spot-contract/components/add/interface.ts

@@ -34,4 +34,5 @@ export interface FormState {
     SaleUserID: number | undefined // uint64 业务员ID
     AccountID: number | undefined // uint64 期货账户ID
     BizType: number // uint32 业务类型 - 1:套保 2:套利
+    CurrencyID: number | undefined // 结算币种ID
 }

+ 35 - 9
src/views/information/spot-contract/components/add/setup.ts

@@ -32,7 +32,8 @@ export function handleFromState() {
         SaleUserID: undefined, // uint64 业务员ID
         MerUserID: undefined, // uint64 跟单员ID
         AccountID: undefined, // uint64 期货账户ID
-        Remark: '' // string 合同备注
+        Remark: '', // string 合同备注
+        CurrencyID: undefined, // 结算币种ID
     })
     // 业务类型
     const businessType = [
@@ -115,7 +116,7 @@ export function handlevalidate(formState: UnwrapRef<FormState>) {
 /**
  * 处理现货商品
  */
-export function handleDeliveryGoods() {
+export function handleDeliveryGoods(formState: UnwrapRef<FormState>) {
     // 现货品种
     const deliveryGoodsList = ref<ErmcpDeliveryGoodsRsp[]>([])
     // 品牌
@@ -153,7 +154,21 @@ export function handleDeliveryGoods() {
             message.error(err)
         })
     }
-    return { deliveryGoodsList, gblist, gmlist, getDeliveryGoods, getDeliveryGoodsDetail, deliveryGoodsChange }
+    const numberUnit = ref<string>('')
+    // 品类变更
+    function WrStandardChange(value: number) {
+        const obj = gmlist.value.find((e) => e.wrstandardid === value);
+        if (obj) {
+            //标仓系数
+            formState.ConvertFactor = obj.convertfactor;
+            // 单位
+            const unitInfo = getItemEnum('goodsunit').find(e => e.enumitemname === obj.unitid)
+            if (unitInfo) {
+                numberUnit.value = unitInfo.enumdicname
+            }
+        }
+    }
+    return { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, getDeliveryGoodsDetail, deliveryGoodsChange }
 }
 
 /**
@@ -166,12 +181,23 @@ export function handlePrice(formState: UnwrapRef<FormState>) {
         { key: 2, value: '点价' },
         { key: 3, value: '暂定价' },
     ];
-    // value: 1 => 一口价; 2 => 点价; 3 => 暂定价
-    function isPriceType(value: number) {
-        formState.PriceType == value
-    }
     // 币种
     const payCurrency = getItemEnum('paycurrency')
-    console.log('payCurrency', payCurrency)
-    return { priceType, payCurrency, isPriceType }
+    console.log('payCurrency', payCurrency);
+    // 目前写死,获取枚举信息里面没有 单位名称,后期进行优化
+    const payCurrencyUnit = ref<string>('元')
+    // 切换币种
+    function parCurrencyChange(value: number) {
+        const obj = payCurrency.find(e => e.enumdicid === value)
+        console.log('切换币种', obj);
+
+        // payCurrencyUnit.value = obj?.enumdicname
+    }
+    return { priceType, payCurrency, payCurrencyUnit, parCurrencyChange }
+}
+
+export function handleAddAction() {
+    function addAction() {
+        // orderContract()
+    }
 }