Browse Source

修改匹配度、招商辅助、同比增速、效益检测行业下拉框

littleblue55 1 month ago
parent
commit
4ecf33c8ec
4 changed files with 101 additions and 18 deletions
  1. 22 1
      src/views/benefit/index.vue
  2. 35 15
      src/views/growthRate/index.vue
  3. 22 1
      src/views/investment/index.vue
  4. 22 1
      src/views/match/index.vue

+ 22 - 1
src/views/benefit/index.vue

@@ -235,6 +235,26 @@ export default {
     handlePageChange(newPage) {
       this.currentPage = newPage;
     },
+    sortByCode(arr) {
+      return arr.sort((a, b) => {
+        const numA = Number(a.code);
+        const numB = Number(b.code);
+
+        // 检查是否为有效数字
+        const isANum = !isNaN(numA);
+        const isBNum = !isNaN(numB);
+
+        if (isANum && isBNum) {
+          return numA - numB; // 都是数字,按数字升序排序
+        } else if (isANum) {
+          return -1; // a 是数字,放在前面
+        } else if (isBNum) {
+          return 1; // b 是数字,放在前面
+        } else {
+          return 0; // 都不是数字,保持原顺序
+        }
+      });
+    },
     async init() {
       const that = this;
       // 获取所有的行业
@@ -247,7 +267,8 @@ export default {
       await listAllIndustry()
         .then((res) => {
           if (res && res?.rows) {
-            that.selectedIndustryArray = res.rows.map((item) => {
+            let arr = this.sortByCode(res.rows);
+            that.selectedIndustryArray = arr.map((item) => {
               return {
                 key: item.code,
                 value: item.code + item.industryName,

+ 35 - 15
src/views/growthRate/index.vue

@@ -338,9 +338,9 @@ export default {
       // 获取年份,获取季度、月度
       const loading = this.$loading({
         lock: true,
-        text: 'Loading',
-        spinner: 'el-icon-loading',
-        background: 'rgba(0, 0, 0, 0.7)'
+        text: "Loading",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
       });
       Promise.all([
         this.getYearData(),
@@ -352,8 +352,8 @@ export default {
           this.initChart();
         })
         .catch((error) => {
-          loading.close()
-          this.$message.error(error)
+          loading.close();
+          this.$message.error(error);
           // console.error("Error fetching data:", error);
         });
     },
@@ -368,7 +368,8 @@ export default {
     getAllIndustry() {
       return listAllIndustry().then((response) => {
         if (response?.rows) {
-          this.industryData = response.rows.map((item) => ({
+          let arr = this.sortByCode(response.rows);
+          this.industryData = arr.map((item) => ({
             key: item.code,
             value: item.code + item.industryName,
           }));
@@ -468,7 +469,6 @@ export default {
         });
     },
     updateChart(rawData) {
-      
       const that = this;
       if (!this.chart) {
         return;
@@ -496,15 +496,15 @@ export default {
       } else if (this.sortActive === "desc") {
         sortedData.sort((a, b) => {
           if (a.rate === null && b.rate === null) return 0;
-            if (a.rate === null) return 1;   // 将null排在最后
-            if (b.rate === null) return -1; 
-            if (a.rate === "Infinity" && b.rate === "Infinity") return 0;
-            if (a.rate === "Infinity") return -1; // 将Infinity排在最前
-            if (b.rate === "Infinity") return 1;
-            // 转换为数字进行比较并进行降序排列
-            return parseFloat(b.rate) - parseFloat(a.rate);
+          if (a.rate === null) return 1; // 将null排在最后
+          if (b.rate === null) return -1;
+          if (a.rate === "Infinity" && b.rate === "Infinity") return 0;
+          if (a.rate === "Infinity") return -1; // 将Infinity排在最前
+          if (b.rate === "Infinity") return 1;
+          // 转换为数字进行比较并进行降序排列
+          return parseFloat(b.rate) - parseFloat(a.rate);
         });
-      }else if(this.sortActive === "location") {
+      } else if (this.sortActive === "location") {
         sortedData.sort((a, b) => a.location.localeCompare(b.location));
       }
       // 处理数据
@@ -671,6 +671,26 @@ export default {
       this.sortActive = sortType;
       this.updateChart(this.searchData);
     },
+    sortByCode(arr) {
+      return arr.sort((a, b) => {
+        const numA = Number(a.code);
+        const numB = Number(b.code);
+
+        // 检查是否为有效数字
+        const isANum = !isNaN(numA);
+        const isBNum = !isNaN(numB);
+
+        if (isANum && isBNum) {
+          return numA - numB; // 都是数字,按数字升序排序
+        } else if (isANum) {
+          return -1; // a 是数字,放在前面
+        } else if (isBNum) {
+          return 1; // b 是数字,放在前面
+        } else {
+          return 0; // 都不是数字,保持原顺序
+        }
+      });
+    },
   },
   watch: {
     // littlegreen - 关闭监测数值变化

+ 22 - 1
src/views/investment/index.vue

@@ -441,6 +441,26 @@ export default {
           console.error("Error fetching data:", error);
         });
     },
+    sortByCode(arr) {
+      return arr.sort((a, b) => {
+        const numA = Number(a.code);
+        const numB = Number(b.code);
+
+        // 检查是否为有效数字
+        const isANum = !isNaN(numA);
+        const isBNum = !isNaN(numB);
+
+        if (isANum && isBNum) {
+          return numA - numB; // 都是数字,按数字升序排序
+        } else if (isANum) {
+          return -1; // a 是数字,放在前面
+        } else if (isBNum) {
+          return 1; // b 是数字,放在前面
+        } else {
+          return 0; // 都不是数字,保持原顺序
+        }
+      });
+    },
     getYearData() {
       return getYearData().then((res) => {
         this.yearsOptions = res.rows[0].years;
@@ -450,7 +470,8 @@ export default {
     getAllIndustry() {
       return listAllIndustry().then((response) => {
         if (response?.rows) {
-          this.industryData = response.rows.map((item) => ({
+          let arr = this.sortByCode(response.rows);
+          this.industryData = arr.map((item) => ({
             key: item.code,
             value: item.code + item.industryName,
           }));

+ 22 - 1
src/views/match/index.vue

@@ -255,6 +255,26 @@ export default {
           this.$message.error(err);
         });
     },
+    sortByCode(arr) {
+      return arr.sort((a, b) => {
+        const numA = Number(a.code);
+        const numB = Number(b.code);
+
+        // 检查是否为有效数字
+        const isANum = !isNaN(numA);
+        const isBNum = !isNaN(numB);
+
+        if (isANum && isBNum) {
+          return numA - numB; // 都是数字,按数字升序排序
+        } else if (isANum) {
+          return -1; // a 是数字,放在前面
+        } else if (isBNum) {
+          return 1; // b 是数字,放在前面
+        } else {
+          return 0; // 都不是数字,保持原顺序
+        }
+      });
+    },
     getYearData() {
       return getYearData().then((res) => {
         this.yearsOptions = res.rows[0].years;
@@ -266,7 +286,8 @@ export default {
     getAllIndustry() {
       return listAllIndustry().then((response) => {
         if (response?.rows) {
-          this.industryData = response.rows.map((item) => ({
+          let arr = this.sortByCode(response.rows);
+          this.industryData = arr.map((item) => ({
             key: item.code,
             value: item.code + item.industryName,
           }));