huangbin 4 anos atrás
pai
commit
4e9f411122

+ 1 - 0
src/common/methods/table/interface.ts

@@ -12,6 +12,7 @@ export interface ColumnType {
     slots?: CustomRender;
     onFilter?: Function;
     sorter?: Function;
+    render?: Function;
 }
 export interface TableKey {
     table_pcweb_application_record: "string; // 库存查询-申请记录"

+ 4 - 0
src/common/setup/table/clolumn.ts

@@ -31,6 +31,7 @@ export function getTableColumns() {
         columns.value.length = 0;
         list.forEach((e, i) => {
             const { columnfield, columntitle, columnwidth, aligntype } = e;
+            console.log();
 
             const item: ColumnType = {
                 key: String(i),
@@ -39,6 +40,9 @@ export function getTableColumns() {
                 align: aligntype === 1 ? 'center' : aligntype === 2 ? 'left' : 'right',
                 slots: { customRender: columnfield },
             };
+            if (columntitle === '序号') {
+                item.render = (text: any, record: any, index: number) => `${index + 1}`
+            }
             if (columnwidth) {
                 item.width = +columnwidth
             }

+ 13 - 11
src/utils/objHandle/index.ts

@@ -26,17 +26,19 @@ export function mergeObj(a: ObjType, ...rest: ObjType[]): void {
  * @param callBack 
  */
 export function mergeTwoObj(a: any, b: any, callBack?: Function) {
-    const obj: ObjType = {};
-    Object.keys(a).forEach((el) => {
-        const key = el.toLocaleLowerCase();
-        if (Reflect.has(b, key)) {
-            obj[el] = b[key];
-        } else {
-            console.warn(`为找到对应的key:${key}`);
-            callBack && callBack(el)
-        }
-    });
-    Object.assign(a, obj);
+    if (b && typeof b === 'object') {
+        const obj: ObjType = {};
+        Object.keys(a).forEach((el) => {
+            const key = el.toLocaleLowerCase();
+            if (Reflect.has(b, key)) {
+                obj[el] = b[key];
+            } else {
+                console.warn(`为找到对应的key:${key}`);
+                callBack && callBack(el)
+            }
+        });
+        Object.assign(a, obj);
+    }
 }
 
 /**

+ 13 - 5
src/views/information/account_info/compoments/modify-futures/index.vue

@@ -3,7 +3,7 @@
   <a-modal class="commonModal add-futures"
            title="修改期货账户"
            v-model:visible="visible"
-           @cancel="cancel"
+           @cancel="closeAction"
            centered
            :maskClosable="false"
            width="890px">
@@ -55,6 +55,7 @@
                        name="password">
             <a-input-password class="dialogInput"
                               style="width: 200px"
+                              autocomplete="new-password"
                               v-model:value="formState.password"
                               placeholder="请输入登录密码" />
           </a-form-item>
@@ -97,10 +98,13 @@ export default defineComponent({
         const { visible, cancel } = closeModal('account_info_futures_btn_modify');
         const loading = ref<boolean>(false);
         const companyList = ref<ErmcpFuturesCompany[]>([]);
-        const { rules, formState, formRef } = handleAddOrModifyFuturesForm();
+        const { rules, formState, formRef, initFormData } = handleAddOrModifyFuturesForm();
         watchEffect(() => {
             if (visible.value) {
-                mergeTwoObj(formState, props.selectedData.mainAcc);
+                mergeTwoObj(formState, props.selectedData?.mainAcc);
+                if(props.selectedData?.mainAcc) {
+                  formState.accountid = props.selectedData.mainAcc.accountid.toString()
+                }
                 queryResultLoadingAndInfo(QueryFuturesCompany, loading).then((res) => {
                     companyList.value = res;
                 });
@@ -121,17 +125,21 @@ export default defineComponent({
                 // };
 
                 requestResultLoadingAndInfo(hedgeOutMainReq, {}, loading, ['新增账户成功', '新增账户失败:']).then(() => {
-                    cancel();
+                    closeAction();
                     context.emit('refresh');
                 });
             });
         }
+        function closeAction() {
+          Object.assign(formState, initFormData())
+          cancel();
+        }
         return {
             formState,
             rules,
             formRef,
             visible,
-            cancel,
+            closeAction,
             companyList,
             getUserName,
             submit,

+ 10 - 7
src/views/information/account_info/compoments/setup.ts

@@ -108,17 +108,20 @@ export function handleTradeForm() {
  */
 export function handleAddOrModifyFuturesForm() {
     const formRef = ref();
-    const formState: UnwrapRef<AddFuturesFormState> = reactive({
-        accountid: '',
-        accountname: '',
-        password: '',
-        fcid: undefined,
-    })
+    function initFormData() {
+        return {
+            accountid: '',
+            accountname: '',
+            password: '',
+            fcid: undefined,
+        }
+    }
+    const formState: UnwrapRef<AddFuturesFormState> = reactive(initFormData())
     const rules = {
         accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
         password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }],
         accountid: [{ required: true, message: '请输入期货登录账号', trigger: 'blur' }],
         fcid: [{ required: true, message: '请选择期货公司' }],
     }
-    return { rules, formState, formRef }
+    return { rules, formState, formRef, initFormData }
 }