Browse Source

班级学生排序

11wqe1 1 week ago
parent
commit
4189d6149f
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/components/pages/studentManageNew/component/table.vue

+ 11 - 1
src/components/pages/studentManageNew/component/table.vue

@@ -1671,7 +1671,7 @@ export default {
             });
             e.classname = kk.join("/");
           });
-          this.tableData = res.data[0];
+          this.tableData = this.groupByName(res.data[0] || []);
           console.log(
             JSON.parse(JSON.stringify(this.tableData)),
             "this.tableData"
@@ -1686,6 +1686,16 @@ export default {
           console.error(err);
         });
     },
+    // 拼音排序
+    groupByName(list) {
+      return [...list].sort((a, b) => {
+        const nameA = (a && a.username ? a.username : "").trim();
+        const nameB = (b && b.username ? b.username : "").trim();
+        return nameA.localeCompare(nameB, "zh-Hans-CN-u-co-pinyin", {
+          sensitivity: "base"
+        });
+      });
+    },
     // 获取兴趣班
     getInterestClass() {
       this.tab1Loading = true;