li.shaoyi 4 anos atrás
pai
commit
24a904f84b

+ 18 - 12
src/common/components/echart/echart-kline/index.vue

@@ -322,22 +322,28 @@ export default defineComponent({
             loading.value = true;
             const params: QueryHistoryDatas = {
                 cycleType: props.cycleType,
-                goodsCode: props.quoteData.goodscode,
+                goodsCode: props.quoteData.goodscode.toUpperCase(),
                 count: 1440,
             };
             // 查询K线数据
-            queryHistoryDatas(params).then((res) => {
-                loading.value = false;
-                if (res.length) {
-                    isEmpty.value = false;
-                    // 日期升序排序
-                    const kdata = res.sort((a, b) => moment(a.ts).valueOf() - moment(b.ts).valueOf());
-                    handleData(kdata);
-                } else {
+            queryHistoryDatas(params)
+                .then((res) => {
+                    if (res.length) {
+                        isEmpty.value = false;
+                        // 日期升序排序
+                        const kdata = res.sort((a, b) => moment(a.ts).valueOf() - moment(b.ts).valueOf());
+                        handleData(kdata);
+                    } else {
+                        isEmpty.value = true;
+                    }
+                    initOptions(props.seriesType);
+                })
+                .catch(() => {
                     isEmpty.value = true;
-                }
-                initOptions(props.seriesType);
-            });
+                })
+                .finally(() => {
+                    loading.value = false;
+                });
         });
 
         return {

+ 17 - 11
src/common/components/echart/echart-timeline/index.vue

@@ -166,18 +166,24 @@ export default defineComponent({
         onMounted(() => {
             loading.value = true;
             // 查询分时数据
-            QueryTSData(props.quoteData.goodscode).then((res) => {
-                loading.value = false;
-                if (res.historyDatas.length) {
-                    isEmpty.value = false;
-                    handleData(res);
-                    // 调用父级函数查询tik数据 (不合理的逻辑处理,待优化)
-                    emit('change', res.startTime, res.endTime);
-                } else {
+            QueryTSData(props.quoteData.goodscode)
+                .then((res) => {
+                    if (res.historyDatas.length) {
+                        isEmpty.value = false;
+                        handleData(res);
+                        // 调用父级函数查询tik数据 (不合理的逻辑处理,待优化)
+                        emit('change', res.startTime, res.endTime);
+                    } else {
+                        isEmpty.value = true;
+                    }
+                    initOptions();
+                })
+                .catch(() => {
                     isEmpty.value = true;
-                }
-                initOptions();
-            });
+                })
+                .finally(() => {
+                    loading.value = false;
+                });
         });
 
         watch(

+ 7 - 2
src/common/components/echart/echart-timeline/setup.ts

@@ -55,12 +55,17 @@ export function handleEchart() {
 
     // 计算涨跌幅百分比,涨跌幅=(今日收盘价-昨日收盘价)/昨日收盘价*100%
     const calcRatio = (val: number) => {
+        const yestclose = chartData.value.yestclose;
         const num = Number(val);
+
         if (isNaN(num)) {
             return "-";
         }
-        const result = (num - chartData.value.yestclose) / chartData.value.yestclose * 100;
-        return toDecimalFull(result) + '%';
+        if (yestclose > 0) {
+            const result = (num - yestclose) / yestclose * 100;
+            return toDecimalFull(result) + '%';
+        }
+        return '0%';
     }
 
     // 初始化图表配置