huangbin vor 4 Jahren
Ursprung
Commit
903355b9fe

+ 17 - 1
src/utils/time/index.ts

@@ -3,7 +3,7 @@ import moment, { DurationInputArg1, Moment, unitOfTime } from "moment";
 
 /**
  * 获取number类型时间戳
- * @returns 
+ * @returns
  */
 export function getTimeValue(): number {
     return moment().valueOf()
@@ -54,4 +54,20 @@ export function debounce(fn: () => void, wait: number, timer: keyof TimeoutTimer
         timerUtil.clearTimeout(timer);
         timerUtil.setTimeout(fn, wait, timer);
     })();
+}
+
+/**
+ * 时间排序
+ * @param arr
+ * @param key
+ * @param isUp true: 升序,false: 倒序
+ * @returns
+ */
+export function sortTime<T extends object>(arr: T[], key: keyof T, isUp = true) {
+    const result = arr.sort((a, b) => {
+        const time1 = new Date((a[key] as unknown) as string).getTime();
+        const time2 = new Date((b[key] as unknown) as string).getTime();
+        return isUp ? time1 - time2 : time2 - time1;
+    });
+    return result;
 }

+ 2 - 1
src/views/account-manager/account-manager-agency/account-manager-agency-sub/index.vue

@@ -91,6 +91,7 @@ import { QueryPermancePlanTmpRsp } from '@/services/go/wrtrade/interface';
 import { ref, watch, watchEffect } from 'vue';
 import { getColumns } from './setup';
 import Bus from '@/utils/eventBus/index';
+import { sortTime } from '@/utils/time';
 
 const addCode = 'account-manager-agency-sub-add';
 const updateCode = 'account-manager-agency-sub-modiy';
@@ -145,7 +146,7 @@ export default defineComponent({
         function queryDetail() {
             const { queryTable } = queryTableList<QueryAccountInOutApplyRsp>();
             queryTable(QueryAccountInOutApply, {}).then((res) => {
-                allDetailList.value = res;
+                allDetailList.value = sortTime<QueryAccountInOutApplyRsp>(res, 'updatetime', false);
                 changeTab(cacheIndex, tabList.value[cacheIndex]);
             });
         }

+ 1 - 8
src/views/order/financing_manager/components/financing_manager_apply_order/index.vue

@@ -62,6 +62,7 @@ import Bus from '@/utils/eventBus/index';
 import { expandIcon } from '@/common/setup/table/clolumn';
 import { getApplyStatusFinanceName, getFinanceTypeName, getInterestrateModeName, getInterestSettleModeName } from '@/common/constants/enumsName';
 import { BtnListType } from '@/common/components/btnList/interface';
+import { sortTime } from '@/utils/time';
 
 export default defineComponent({
     name: enumOrderComponents.financing_manager_apply_order,
@@ -72,14 +73,6 @@ export default defineComponent({
     setup() {
         // 表格列表数据
         const { loading, tableList, queryTable } = queryTableList<WrFinanceBuyApply>();
-        function sortTime<T extends object>(arr: T[], key: keyof T, isUp = true) {
-            const result = arr.sort((a, b) => {
-                const time1 = new Date((a[key] as unknown) as string).getTime();
-                const time2 = new Date((b[key] as unknown) as string).getTime();
-                return isUp ? time1 - time2 : time2 - time1;
-            });
-            return result;
-        }
         // 获取列表数据
         const queryTableAction = () => {
             queryTable(queryWrFinanceBuyApply).then((res) => {