liyongli 3 роки тому
батько
коміт
e4eb00af3c

+ 1 - 0
package.json

@@ -27,6 +27,7 @@
     "compression-webpack-plugin": "5.0.1",
     "eslint": "^6.7.2",
     "eslint-plugin-vue": "^7.0.0",
+    "unplugin-auto-import": "^0.6.6",
     "unplugin-element-plus": "^0.1.0",
     "unplugin-vue-components": "^0.15.4"
   },

+ 43 - 19
src/views/ChannelRanking/ChannelRanking.vue

@@ -45,7 +45,7 @@
         :list="tableData"
         v-if="tableData.length"
         xName="channelName"
-        toolTipUnit="元"
+        :toolTipUnit="col[type - 1].unit"
         :notzoom="true"
         :keys="select"
       ></line-charts>
@@ -77,7 +77,7 @@
         >
           <template #header>
             <div>
-            <!-- <div @click="() => sortChange({ prop: item.key })"> -->
+              <!-- <div @click="() => sortChange({ prop: item.key })"> -->
               <el-icon
                 style="vertical-align: middle;"
                 :color="i === type - 1 ? '#409eff' : ''"
@@ -89,7 +89,7 @@
                     (i === type - 1 ? 'color: #409eff' : '')
                 "
               >
-                {{ `${item.name}(${item.unit})` }}
+                {{ `${item.name}(${item.unit === "元" ? "万元" : item.unit})` }}
               </span>
             </div>
           </template>
@@ -116,12 +116,15 @@
 <script>
 // @ is an alias to /src
 import { channelRank } from "@/api/index";
-// import { ElNotification } from 'element-plus'
 import lineCharts from "@/views/ChannelRanking/components/lineCharts";
 
+import { ElNotification } from "element-plus";
+import "element-plus/lib/theme-chalk/el-notification.css";
+
 // import config from "@/config/index";
 export default {
   name: "Channel",
+  from: {},
   data() {
     return {
       type: 1,
@@ -130,7 +133,7 @@ export default {
         {
           key: "fee",
           name: "费用",
-          unit: "元",
+          unit: "元",
           type: 1,
         },
         {
@@ -145,17 +148,10 @@ export default {
           unit: "次",
           type: 3,
         },
-        {
-          key: "customer",
-          name: "客户数",
-          unit: "个",
-          type: 4,
-        },
       ],
       dateRank: [],
       tableData: [],
       loading: false,
-      from: {},
     };
   },
   computed: {
@@ -164,7 +160,8 @@ export default {
     },
   },
   mounted() {
-    const date = new Date();
+    let date = new Date();
+    date = new Date(date.getTime() - 86400000);
     let month = date.getMonth() + 1,
       day = date.getDate();
     month > 9 ? "" : (month = "0" + month);
@@ -175,10 +172,12 @@ export default {
     ];
     this.from = {
       dataType: this.type,
-      end: dateRank[0] || "",
-      start: dateRank[1] || "",
+      end: dateRank[1] || "",
+      start: dateRank[0] || "",
     };
+    this.loading = true;
     channelRank(this.from).then(res => {
+      this.loading = false;
       this.tableData = res || [];
       this.dateRank = dateRank;
     });
@@ -192,7 +191,9 @@ export default {
         customer: 4,
       };
       this.from.dataType = T[v.prop] || 1;
+      this.loading = true;
       channelRank(this.from).then(res => {
+        this.loading = false;
         this.tableData = res || [];
         this.type = T[v.prop] || 1;
         this.dateRank = [this.from.start, this.from.end];
@@ -218,11 +219,34 @@ export default {
       return time.getTime() > Date.now() - 86400000;
     },
     onSubmit() {
-      channelRank({
+      if (!this.dateRank || this.dateRank.length !== 2) {
+        ElNotification({
+          title: "错误",
+          message: "日期选择有误",
+          type: "error",
+          duration: 0,
+        });
+        return;
+      }
+      let s = new Date(this.dateRank[0]),
+        e = new Date(this.dateRank[1]);
+      if (e - s > 86400000 * 31) {
+        ElNotification({
+          title: "错误",
+          message: "日期跨度超过一个月",
+          type: "error",
+          duration: 0,
+        });
+        return;
+      }
+      this.from = {
         dataType: this.type,
-        end: this.dateRank[0] || "",
-        start: this.dateRank[1] || "",
-      }).then(res => {
+        end: this.dateRank[1] || "",
+        start: this.dateRank[0] || "",
+      };
+      this.loading = true;
+      channelRank(this.from).then(res => {
+        this.loading = false;
         this.tableData = res || [];
       });
     },

+ 15 - 11
src/views/ChannelRanking/components/lineCharts.vue

@@ -60,7 +60,9 @@ export default {
         for (let i = 0; i < this.keys.length; i++) {
           const p = this.keys[i];
           if (!values[i]) values[i] = [];
-          values[i][o] = v[p.key] * 100;
+          if (p.key === "timeSize") {
+            values[i][o] = v[p.key] / 60000;
+          } else values[i][o] = v[p.key];
         }
       }
       return {
@@ -109,8 +111,8 @@ export default {
               out +=
                 par.seriesName +
                 ": " +
-                this.format(par.value, 2) +
-                (this.toolTipUnit || "%") +
+                this.format(par.value, this.keys[0].key !== "pinci" ? 2 : 0) +
+                (this.toolTipUnit || "") +
                 " <br />";
             }
             return t + out;
@@ -124,12 +126,14 @@ export default {
           axisLabel: {
             formatter: arr => {
               const li = arr.split("");
-              let out = "", num = 2;
+              let out = "",
+                num = 2;
               for (let i = 0; i < li.length; i++) {
                 const v = li[i];
                 out += v;
-                if(!isNaN(v)) num = 3;
-                if (i !== 0 && i !== li.length - 1 && i % num === 1) out += "\n", num = 2;
+                if (!isNaN(v)) num = 3;
+                if (i !== 0 && i !== li.length - 1 && i % num === 1)
+                  (out += "\n"), (num = 2);
               }
               return out;
             },
@@ -154,17 +158,17 @@ export default {
           };
         }),
       };
-    
+
       option.dataZoom = [
         {
           show: true,
           realtime: true,
           start: 0,
-          end: Math.ceil(this.$refs.countryLineChart.offsetWidth/20),
-          maxValueSpan: Math.ceil(this.$refs.countryLineChart.offsetWidth/20),
-          minValueSpan: Math.ceil(this.$refs.countryLineChart.offsetWidth/40),
+          end: Math.ceil(this.$refs.countryLineChart.offsetWidth / 20),
+          maxValueSpan: Math.ceil(this.$refs.countryLineChart.offsetWidth / 20),
+          minValueSpan: Math.ceil(this.$refs.countryLineChart.offsetWidth / 40),
           xAxisIndex: [0, 1],
-        }
+        },
       ];
       option && lineTypeOneCharts.setOption(option);
     },

+ 7 - 3
vue.config.js

@@ -1,4 +1,5 @@
 const Components = require("unplugin-vue-components/webpack");
+const AutoImport = require("unplugin-auto-import/webpack");
 const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");
 
 // const CompressionPlugin = require("compression-webpack-plugin");
@@ -21,9 +22,12 @@ module.exports = {
   },
   configureWebpack: {
     plugins: [
-      Components({
-        resolvers: [ElementPlusResolver()],
-      }),
+        AutoImport({
+          resolvers: [ElementPlusResolver()],
+        }),
+        Components({
+          resolvers: [ElementPlusResolver()],
+        }),
     ],
   },
 };

+ 83 - 2
yarn.lock

@@ -9,6 +9,11 @@
   dependencies:
     "@types/throttle-debounce" "^2.1.0"
 
+"@antfu/utils@^0.5.0":
+  version "0.5.0"
+  resolved "https://registry.npmmirror.com/@antfu/utils/-/utils-0.5.0.tgz#b3169429997cb87850e543cb74660f9e2fed7efd"
+  integrity sha512-MrAQ/MrPSxbh1bBrmwJjORfJymw4IqSHFBXqvxaga3ZdDM+/zokYF8DjyJpSjY2QmpmgQrajDUBJOWrYeARfzA==
+
 "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.14.5":
   version "7.14.5"
   resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.14.5.tgz#23b08d740e83f49c5e59945fbf1b43e80bbf4edb"
@@ -1029,6 +1034,14 @@
     estree-walker "^2.0.1"
     picomatch "^2.2.2"
 
+"@rollup/pluginutils@^4.2.0":
+  version "4.2.0"
+  resolved "https://registry.npmmirror.com/@rollup/pluginutils/-/pluginutils-4.2.0.tgz#a14bbd058fdbba0a5647143b16ed0d86fb60bd08"
+  integrity sha512-2WUyJNRkyH5p487pGnn4tWAsxhEFKN/pT8CMgHshd5H+IXkOnKvKZwsz5ZWz+YCXkleZRAU5kwbfgF8CPfDRqA==
+  dependencies:
+    estree-walker "^2.0.1"
+    picomatch "^2.2.2"
+
 "@soda/friendly-errors-webpack-plugin@^1.7.1":
   version "1.8.0"
   resolved "https://registry.yarnpkg.com/@soda/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-1.8.0.tgz#84751d82a93019d5c92c0cf0e45ac59087cd2240"
@@ -2561,6 +2574,21 @@ chokidar@^3.4.1, chokidar@^3.5.2:
   optionalDependencies:
     fsevents "~2.3.2"
 
+chokidar@^3.5.3:
+  version "3.5.3"
+  resolved "https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
+  integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
+  dependencies:
+    anymatch "~3.1.2"
+    braces "~3.0.2"
+    glob-parent "~5.1.2"
+    is-binary-path "~2.1.0"
+    is-glob "~4.0.1"
+    normalize-path "~3.0.0"
+    readdirp "~3.6.0"
+  optionalDependencies:
+    fsevents "~2.3.2"
+
 chownr@^1.1.1:
   version "1.1.4"
   resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b"
@@ -5032,6 +5060,13 @@ is-core-module@^2.2.0:
   dependencies:
     has "^1.0.3"
 
+is-core-module@^2.8.1:
+  version "2.8.1"
+  resolved "https://registry.npmmirror.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211"
+  integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==
+  dependencies:
+    has "^1.0.3"
+
 is-data-descriptor@^0.1.4:
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"
@@ -5487,6 +5522,11 @@ loader-utils@^2.0.0:
     emojis-list "^3.0.0"
     json5 "^2.1.2"
 
+local-pkg@^0.4.1:
+  version "0.4.1"
+  resolved "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.1.tgz#e7b0d7aa0b9c498a1110a5ac5b00ba66ef38cfff"
+  integrity sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw==
+
 locate-path@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
@@ -5588,6 +5628,13 @@ magic-string@^0.25.7:
   dependencies:
     sourcemap-codec "^1.4.4"
 
+magic-string@^0.26.1:
+  version "0.26.1"
+  resolved "https://registry.npmmirror.com/magic-string/-/magic-string-0.26.1.tgz#ba9b651354fa9512474199acecf9c6dbe93f97fd"
+  integrity sha512-ndThHmvgtieXe8J/VGPjG+Apu7v7ItcD5mhEIvOscWjPF/ccOiLxHaSuCAS2G+3x4GKsAbT8u7zdyamupui8Tg==
+  dependencies:
+    sourcemap-codec "^1.4.8"
+
 make-dir@^2.0.0:
   version "2.1.0"
   resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
@@ -6487,7 +6534,7 @@ path-key@^3.0.0, path-key@^3.1.0:
   resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
   integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
 
-path-parse@^1.0.6:
+path-parse@^1.0.6, path-parse@^1.0.7:
   version "1.0.7"
   resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
   integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
@@ -7350,6 +7397,15 @@ resolve@^1.10.0, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.20.0:
     is-core-module "^2.2.0"
     path-parse "^1.0.6"
 
+resolve@^1.22.0:
+  version "1.22.0"
+  resolved "https://registry.npmmirror.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
+  integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==
+  dependencies:
+    is-core-module "^2.8.1"
+    path-parse "^1.0.7"
+    supports-preserve-symlinks-flag "^1.0.0"
+
 restore-cursor@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
@@ -7788,7 +7844,7 @@ source-map@^0.7.3:
   resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
   integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
 
-sourcemap-codec@^1.4.4:
+sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8:
   version "1.4.8"
   resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
   integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
@@ -8077,6 +8133,11 @@ supports-color@^7.1.0:
   dependencies:
     has-flag "^4.0.0"
 
+supports-preserve-symlinks-flag@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
+  integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
+
 svg-tags@^1.0.0:
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764"
@@ -8434,6 +8495,18 @@ unpipe@1.0.0, unpipe@~1.0.0:
   resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
   integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=
 
+unplugin-auto-import@^0.6.6:
+  version "0.6.6"
+  resolved "https://registry.npmmirror.com/unplugin-auto-import/-/unplugin-auto-import-0.6.6.tgz#2677b72245b476f4e0f86fc051dab8a68788bbb0"
+  integrity sha512-x3YxAI9ePoumXOakuS5YJlFkSyAkl5vJlaFZSJhSp75nH5gg8LpqQ/0Gz1/CG/JRRv+xaE1CZpEV161AqFGjEg==
+  dependencies:
+    "@antfu/utils" "^0.5.0"
+    "@rollup/pluginutils" "^4.2.0"
+    local-pkg "^0.4.1"
+    magic-string "^0.26.1"
+    resolve "^1.22.0"
+    unplugin "^0.4.0"
+
 unplugin-element-plus@^0.1.0:
   version "0.1.0"
   resolved "https://registry.nlark.com/unplugin-element-plus/download/unplugin-element-plus-0.1.0.tgz#eb68721f152a79ebe39a7404cc60cfcd6a8e587b"
@@ -8467,6 +8540,14 @@ unplugin@^0.2.13, unplugin@^0.2.7:
   dependencies:
     webpack-virtual-modules "^0.4.3"
 
+unplugin@^0.4.0:
+  version "0.4.0"
+  resolved "https://registry.npmmirror.com/unplugin/-/unplugin-0.4.0.tgz#43a923f0267f8834118a926c406131d1d84a1358"
+  integrity sha512-4ScITEmzlz1iZW3tkz+3L1V5k/xMQ6kjgm4lEXKxH0ozd8/OUWfiSA7RMRyrawsvq/t50JIzPpp1UyuSL/AXkA==
+  dependencies:
+    chokidar "^3.5.3"
+    webpack-virtual-modules "^0.4.3"
+
 unquote@~1.1.1:
   version "1.1.1"
   resolved "https://registry.yarnpkg.com/unquote/-/unquote-1.1.1.tgz#8fded7324ec6e88a0ff8b905e7c098cdc086d544"