diff --git a/pages.json b/pages.json
index a9290f3..f8b6a3c 100644
--- a/pages.json
+++ b/pages.json
@@ -176,6 +176,15 @@
// "navigationBarTextStyle": "white"
}
},
+ {
+ "path": "pages/views/shengchan/ribaoshuju/rbsjLsxq",
+ "style": {
+ // "navigationStyle": "custom"
+ "navigationBarTitleText": "历史详情",
+ "enablePullDownRefresh": false,
+ "navigationBarTextStyle": "white"
+ }
+ },
{
"path": "pages/userlist/index",
"style": {
diff --git a/pages/product/NatrueGas/index.vue b/pages/product/NatrueGas/index.vue
deleted file mode 100644
index c3d2a27..0000000
--- a/pages/product/NatrueGas/index.vue
+++ /dev/null
@@ -1,444 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- {{ item.gas }}
-
- 当日量:
- {{ item.dailyVolume }}
- 年累计:
- {{ item.yearVolume }}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/product/index.vue b/pages/product/index.vue
deleted file mode 100644
index 2526a18..0000000
--- a/pages/product/index.vue
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- 生产经营数据
-
-
-
-
-
-
-
-
diff --git a/pages/views/renliziyuan/renyuanxinxi/tongji.vue b/pages/views/renliziyuan/renyuanxinxi/tongji.vue
index d16d0d2..5b20670 100644
--- a/pages/views/renliziyuan/renyuanxinxi/tongji.vue
+++ b/pages/views/renliziyuan/renyuanxinxi/tongji.vue
@@ -6,8 +6,7 @@
-
+
@@ -72,7 +71,7 @@
- 详情
+ 详情
@@ -83,295 +82,290 @@
\ No newline at end of file
+/* 内容样式 */
+.dataStyle {
+ max-font-size: 14px;
+ /* 最大字体限制 */
+ min-font-size: 10px;
+ /* 最小字体限制 */
+ font-size: 12px;
+ color: #00007f;
+ line-height: 30px;
+ height: 30px;
+ font-weight: 500;
+ text-align: center;
+ vertical-align: middle;
+ border-bottom: 1px solid #919191;
+ border-left: 1px solid #919191;
+ text-overflow: ellipsis;
+}
+
diff --git a/pages/views/shengchan/index.vue b/pages/views/shengchan/index.vue
index 16a5d57..6b2fbd9 100644
--- a/pages/views/shengchan/index.vue
+++ b/pages/views/shengchan/index.vue
@@ -1,52 +1,61 @@
-
- 生产经营数据
+
+
+
+
+
+
\ No newline at end of file
+.placeholder {
+ height: v-bind(cusnavbarheight);
+}
+
diff --git a/pages/views/shengchan/ribaoshuju/rbsjLsxq.vue b/pages/views/shengchan/ribaoshuju/rbsjLsxq.vue
new file mode 100644
index 0000000..2f147b4
--- /dev/null
+++ b/pages/views/shengchan/ribaoshuju/rbsjLsxq.vue
@@ -0,0 +1,302 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ 最大值: {{ dataStats.max }}
+ 最小值: {{ dataStats.min }}
+ 平均值: {{ dataStats.average }}
+
+
+
+
+
+
+
+
+ {{ index + 1 }}
+ {{ item.unit }}
+ {{ item.rqDate }}
+
+ {{ item.rq }}
+
+
+
+
+ 暂无相关数据
+
+
+
+
+
+
+
+
+
diff --git a/pages/views/shengchan/ribaoshuju/trqRbsj.vue b/pages/views/shengchan/ribaoshuju/trqRbsj.vue
index 345c1e9..776e73b 100644
--- a/pages/views/shengchan/ribaoshuju/trqRbsj.vue
+++ b/pages/views/shengchan/ribaoshuju/trqRbsj.vue
@@ -1,6 +1,10 @@
-
+
+
+
+
+ 全年时间进度:{{ timePercent }}%
@@ -14,6 +18,12 @@
年累计
{{ item.yearVolume || '-' }}
+
+
+
+
+ {{ item.yearPerCent }}%
+
@@ -25,424 +35,476 @@
-
-
-
-
-
+
+
+
+
-
- {{ index }}
+
+ {{ index + 1 }}
{{ item.unit }}
{{ formatNumber(item.rq) }}
-
- {{ formatNumber(item.totalGas) }}
{{ formatNumber(item.yearVolume) }}
+ 历史
-
- 暂无相关数据
-
-
-
+ 暂无相关数据
+
+
-
\ No newline at end of file
+.progress-text {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+ color: red; /* 保持红色 */
+ font-size: 12px;
+ font-weight: bold;
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* 提升可读性 */
+}
+
diff --git a/pages/views/shengchan/ribaoshuju/yyRbsj.vue b/pages/views/shengchan/ribaoshuju/yyRbsj.vue
index eea775c..7a832df 100644
--- a/pages/views/shengchan/ribaoshuju/yyRbsj.vue
+++ b/pages/views/shengchan/ribaoshuju/yyRbsj.vue
@@ -18,6 +18,19 @@
年累计
{{ item.nl || '-' }}
+
+
+
+
+
+ {{ item.yearPerCent }}%
+
@@ -33,17 +46,17 @@
-
- {{ index }}
+
+ {{ index }}
{{ item.dw }}
{{ formatNumber(item.rcwy) }}
@@ -52,275 +65,305 @@
{{ formatNumber(item.nl) }}
+ 历史
-
- 暂无相关数据
-
+ 暂无相关数据
-
\ No newline at end of file
+}
+.progress-item {
+ margin-bottom: 20px;
+}
+
+.progress-bar {
+ position: relative;
+ height: 20px;
+ background: #f0f0f0;
+ border-radius: 10px;
+ overflow: hidden;
+}
+
+.progress {
+ height: 100%;
+ transition: all 0.3s;
+}
+
+.progress-text {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+ color: red; /* 保持红色 */
+ font-size: 12px;
+ font-weight: bold;
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* 提升可读性 */
+}
+
diff --git a/uni_modules/cxc-szcx-dateRangeSelect/changelog.md b/uni_modules/cxc-szcx-dateRangeSelect/changelog.md
new file mode 100644
index 0000000..e69de29
diff --git a/uni_modules/cxc-szcx-dateRangeSelect/components/cxc-szcx-dateRangeSelect/cxc-szcx-dateRangeSelect.vue b/uni_modules/cxc-szcx-dateRangeSelect/components/cxc-szcx-dateRangeSelect/cxc-szcx-dateRangeSelect.vue
new file mode 100644
index 0000000..2c641fa
--- /dev/null
+++ b/uni_modules/cxc-szcx-dateRangeSelect/components/cxc-szcx-dateRangeSelect/cxc-szcx-dateRangeSelect.vue
@@ -0,0 +1,573 @@
+
+
+
+
+
+ {{ formattedStart || '开始日期' }}
+
+ 至
+
+ {{ formattedEnd || '结束日期' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/cxc-szcx-dateRangeSelect/package.json b/uni_modules/cxc-szcx-dateRangeSelect/package.json
new file mode 100644
index 0000000..727d7ea
--- /dev/null
+++ b/uni_modules/cxc-szcx-dateRangeSelect/package.json
@@ -0,0 +1,83 @@
+{
+ "id": "cxc-szcx-dateRangeSelect",
+ "displayName": "cxc-szcx-dateRangeSelect",
+ "version": "1.0.0",
+ "description": "cxc-szcx-dateRangeSelect",
+ "keywords": [
+ "cxc-szcx-dateRangeSelect"
+],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "type": "component-vue",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "",
+ "data": "",
+ "permissions": ""
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "u",
+ "aliyun": "u",
+ "alipay": "u"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "u",
+ "vue3": "u"
+ },
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "u",
+ "app-uvue": "u"
+ },
+ "H5-mobile": {
+ "Safari": "u",
+ "Android Browser": "u",
+ "微信浏览器(Android)": "u",
+ "QQ浏览器(Android)": "u"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "u",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/cxc-szcx-dateRangeSelect/readme.md b/uni_modules/cxc-szcx-dateRangeSelect/readme.md
new file mode 100644
index 0000000..a96c0b4
--- /dev/null
+++ b/uni_modules/cxc-szcx-dateRangeSelect/readme.md
@@ -0,0 +1,139 @@
+# cxc-szcx-dateRangeSelect
+# # 紧凑型日期时间选择器组件说明书
+
+## 一、组件概述
+`compact-datetime-picker` 是一个基于 Vue 开发的紧凑型日期时间选择器组件,用于在页面中选择日期范围。组件提供了自然周期和相对周期两种选择模式,并且支持快捷选择本周、本月、本季、本年、近一周、近一月、近一季、近一年等常见时间范围。
+
+## 二、组件依赖
+- **Vue**:组件基于 Vue 框架开发。
+- **uni-popup**:来自 `uni-app` 的弹窗组件,用于显示日期选择器的弹出层。
+
+## 三、组件使用方法
+
+### 1. 引入组件
+在需要使用该组件的 Vue 文件中,引入 `compact-datetime-picker` 组件。
+```vue
+
+
+
+
+
+
+
+```
+
+### 2. 组件属性
+| 属性名 | 类型 | 默认值 | 描述 |
+| ---- | ---- | ---- | ---- |
+| `modelValue` | `Array` | `[null, null]` | 双向绑定的日期范围数组,第一个元素为开始日期,第二个元素为结束日期。 |
+
+## 四、组件内部实现
+
+### 1. 模板部分
+- **输入框区域**:显示开始日期和结束日期的输入框,点击输入框可打开日期选择弹窗。
+- **日期选择弹窗**:
+ - **快捷按钮区域**:包含自然周期和相对周期的切换按钮,以及不同模式下的快捷操作按钮。
+ - **日历选择区域**:显示当前月份的日历,可选择日期。
+ - **操作按钮**:包含取消和确定按钮,用于关闭弹窗和确认选择的日期范围。
+
+### 2. 脚本部分
+
+#### 2.1 数据属性
+```javascript
+data() {
+ return {
+ isNatural: true, // 是否为自然周期模式
+ activeType: 'start', // 当前活跃的日期选择类型(开始或结束)
+ currentMonth: new Date(), // 当前显示的月份
+ tempStart: null, // 临时开始日期
+ tempEnd: null, // 临时结束日期
+ weekDays: ['日', '一', '二', '三', '四', '五', '六'], // 星期几的显示文本
+ quickButtonszr: [
+ { label: '本周', type: 'week' },
+ { label: '本月', type: 'month' },
+ { label: '本季', type: 'quarter' },
+ { label: '本年', type: 'year' }
+ ], // 自然周期模式下的快捷按钮
+ quickButtonsxd: [
+ { label: '近一周', type: 'week' },
+ { label: '近一月', type: 'month' },
+ { label: '近一季', type: 'quarter' },
+ { label: '近一年', type: 'year' }
+ ] // 相对周期模式下的快捷按钮
+ };
+}
+```
+
+#### 2.2 计算属性
+- `formattedStart`:格式化后的开始日期。
+- `formattedEnd`:格式化后的结束日期。
+- `calendarDays`:生成当前月份的日历数据。
+- `monthText`:当前月份的显示文本。
+
+#### 2.3 监听属性
+```javascript
+watch: {
+ modelValue: {
+ immediate: true,
+ handler(newVal) {
+ this.tempStart = newVal[0];
+ this.tempEnd = newVal[1];
+ }
+ }
+}
+```
+监听 `modelValue` 的变化,初始化临时日期。
+
+#### 2.4 方法
+- **打开弹窗并初始化临时值**:`openPicker(type)`,打开日期选择弹窗,并根据活跃类型初始化临时日期。
+- **日期点击处理**:`handleDayClick(day)`,处理日期点击事件,更新临时开始或结束日期。
+- **确认选择**:`confirmSelection()`,确认选择的日期范围,触发 `update:modelValue` 事件并关闭弹窗。
+- **关闭弹窗**:`closePicker()`,关闭日期选择弹窗,并重置临时日期。
+- **重置临时日期**:`resetTempDates()`,将临时日期重置为当前的 `modelValue`。
+- **生成日历数据**:`generateCalendar(date)`,根据给定的月份生成日历数据。
+- **日期选择处理**:`selectDate(date)`,处理日期选择,更新 `modelValue`。
+- **切换月份**:`changeMonth(offset)`,切换当前显示的月份。
+- **判断日期状态**:
+ - `isSelected(date)`:判断日期是否被选中。
+ - `isEnd(date)`:判断日期是否为结束日期。
+ - `isToday(date)`:判断日期是否为今天。
+ - `isStart(date)`:判断日期是否为开始日期。
+ - `isInRange(date)`:判断日期是否在选择的范围内。
+ - `isSameDay(d1, d2)`:判断两个日期是否为同一天。
+- **快捷范围设置**:`setQuickRange(type)`,根据快捷按钮的类型设置日期范围,并关闭弹窗。
+- **自然周期计算**:`calcNaturalRange(type, currentDate)`,计算自然周期模式下的日期范围。
+- **相对周期计算**:`calcRelativeRange(type, currentDate)`,计算相对周期模式下的日期范围。
+- **周计算(周一为起点)**:
+ - `getWeekStart(date)`:获取一周的开始日期。
+ - `getWeekEnd(startDate)`:获取一周的结束日期。
+- **月末处理**:`lastDayOfMonth(date)`,获取给定月份的最后一天。
+- **月末日调整**:`adjustMonthEnd(start, end)`,调整开始日期到合适的月末日期。
+- **闰年判断**:`isLeapYear(year)`,判断给定年份是否为闰年。
+- **模式切换**:`toggleMode(isNatural)`,切换自然周期和相对周期模式。
+- **日期格式化**:`formatDate(date)`,将日期格式化为 `YYYY-MM-DD` 的字符串。
+
+### 3. 样式部分
+- **输入框区域**:设置输入框的样式,包括边框、背景色、字体大小等。
+- **紧凑弹窗**:设置弹窗的整体样式,包括背景色、边框半径等。
+- **紧凑头部**:设置月份标题和导航箭头的样式。
+- **紧凑日期网格**:设置星期几和日期的显示样式,以及不同状态下的日期背景色和字体颜色。
+- **快捷按钮区域**:设置模式切换按钮和快捷操作按钮的样式。
+- **底部操作**:设置取消和确定按钮的样式。
+
+## 五、注意事项
+- 组件使用了 `uni-popup` 组件,确保项目中已正确引入和配置。
+- 日期范围的选择逻辑较为复杂,特别是在自然周期和相对周期的切换以及快捷范围设置时,需注意日期的计算和显示。
+- 组件的样式是基于 `scoped` 作用域的,可根据项目需求进行调整和扩展。
\ No newline at end of file
diff --git a/uni_modules/cxc-szcx-lineChart/changelog.md b/uni_modules/cxc-szcx-lineChart/changelog.md
new file mode 100644
index 0000000..e69de29
diff --git a/uni_modules/cxc-szcx-lineChart/components/cxc-szcx-lineChart/cxc-szcx-lineChart.vue b/uni_modules/cxc-szcx-lineChart/components/cxc-szcx-lineChart/cxc-szcx-lineChart.vue
new file mode 100644
index 0000000..a3268aa
--- /dev/null
+++ b/uni_modules/cxc-szcx-lineChart/components/cxc-szcx-lineChart/cxc-szcx-lineChart.vue
@@ -0,0 +1,274 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/cxc-szcx-lineChart/package.json b/uni_modules/cxc-szcx-lineChart/package.json
new file mode 100644
index 0000000..dd31225
--- /dev/null
+++ b/uni_modules/cxc-szcx-lineChart/package.json
@@ -0,0 +1,83 @@
+{
+ "id": "cxc-szcx-lineChart",
+ "displayName": "cxc-szcx-lineChart",
+ "version": "1.0.0",
+ "description": "cxc-szcx-lineChart",
+ "keywords": [
+ "cxc-szcx-lineChart"
+],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "type": "component-vue",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "",
+ "data": "",
+ "permissions": ""
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "u",
+ "aliyun": "u",
+ "alipay": "u"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "u",
+ "vue3": "u"
+ },
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "u",
+ "app-uvue": "u"
+ },
+ "H5-mobile": {
+ "Safari": "u",
+ "Android Browser": "u",
+ "微信浏览器(Android)": "u",
+ "QQ浏览器(Android)": "u"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "u",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/cxc-szcx-lineChart/readme.md b/uni_modules/cxc-szcx-lineChart/readme.md
new file mode 100644
index 0000000..9ea8aef
--- /dev/null
+++ b/uni_modules/cxc-szcx-lineChart/readme.md
@@ -0,0 +1,179 @@
+# cxc-szcx-lineChart
+# # `line-chart.vue` 组件说明书
+
+## 一、组件概述
+`line-chart.vue` 是一个基于 ECharts 实现的折线图组件,用于在 UniApp 项目中展示数据的折线图。该组件接收一系列数据和配置参数,支持动态更新数据,并展示参考线。
+
+## 二、组件依赖
+- **Vue 3**:使用 Vue 3 的组合式 API 进行开发。
+- **ECharts**:用于绘制折线图。
+- **`lime-echart`**:UniApp 插件,提供 ECharts 的渲染支持。
+
+## 三、组件使用方法
+
+### 1. 引入组件
+在需要使用该组件的页面中引入 `line-chart.vue` 组件。
+```vue
+
+
+
+
+
+
+
+```
+
+### 2. 组件属性
+
+| 属性名 | 类型 | 默认值 | 描述 |
+| ---- | ---- | ---- | ---- |
+| `dataList` | `Object` | `[]` | 包含图表数据的数组,每个元素是一个对象,包含 `xField`、`yField` 和 `legendField` 对应的数据。 |
+| `xField` | `String` | `''` | 数据中用于表示 x 轴的字段名。 |
+| `yField` | `String` | `''` | 数据中用于表示 y 轴的字段名。 |
+| `legendField` | `String` | `''` | 数据中用于表示图例的字段名。 |
+| `referenceValue` | `Number` | `10` | 图表中参考线的数值。 |
+
+## 四、组件内部实现
+
+### 1. 模板部分
+```vue
+
+
+
+
+
+```
+- 使用 `l-echart` 组件渲染图表,通过 `ref` 绑定到 `chart`,并在初始化完成时调用 `initChart` 方法。
+
+### 2. 脚本部分
+
+#### 2.1 引入必要的模块
+```javascript
+import { ref, watch } from 'vue';
+```
+引入 Vue 3 的 `ref` 和 `watch` 函数。
+
+#### 2.2 定义组件属性
+```javascript
+const props = defineProps({
+ dataList: {
+ type: Object,
+ default: () => []
+ },
+ // 其他属性...
+});
+```
+定义组件接收的属性。
+
+#### 2.3 初始化图表
+```javascript
+const chart = ref(null);
+let echarts = null;
+
+const initChart = async (canvas) => {
+ await initEcharts(canvas);
+ updateChart();
+};
+
+const initEcharts = async (canvas) => {
+ echarts = await import('echarts');
+ const { init } = await import('@/uni_modules/lime-echart/static/echarts.min');
+ echarts = init(canvas, echarts);
+};
+```
+- `chart` 用于引用 `l-echart` 组件。
+- `initChart` 方法在图表初始化时调用,先初始化 ECharts 实例,再更新图表。
+- `initEcharts` 方法异步加载 ECharts 并初始化实例。
+
+#### 2.4 处理数据
+```javascript
+const processData = () => {
+ const legendData = [...new Set(props.dataList.map((item) => item[props.legendField]))];
+
+ return legendData.map((legendItem) => {
+ const seriesData = props.dataList
+ .filter((item) => item[props.legendField] === legendItem)
+ .sort((a, b) => new Date(a[props.xField]) - new Date(b[props.xField]))
+ .map((item) => ({
+ name: item[props.xField],
+ value: [item[props.xField], item[props.yField]]
+ }));
+
+ return {
+ name: legendItem,
+ type: 'line',
+ showSymbol: true,
+ data: seriesData
+ };
+ });
+};
+```
+处理传入的数据,根据 `legendField` 分组,对每组数据按 `xField` 排序,并转换为 ECharts 所需的格式。
+
+#### 2.5 获取图表配置
+```javascript
+const getOption = () => ({
+ tooltip: {
+ trigger: 'axis',
+ formatter: (params) => {
+ return `${params[0].axisValue}
` + params.map((item) => `${item.marker} ${item.seriesName}: ${item.value[1]}`).join('
');
+ }
+ },
+ // 其他配置...
+});
+```
+返回 ECharts 的配置对象,包括 tooltip、x 轴、y 轴、系列数据、图例和网格等配置。
+
+#### 2.6 更新图表
+```javascript
+const updateChart = () => {
+ if (!chart.value) return;
+
+ const option = getOption();
+ chart.value.setOption(option);
+};
+```
+如果 `chart` 实例存在,获取最新的图表配置并更新图表。
+
+#### 2.7 监听数据变化
+```javascript
+watch(
+ () => props.dataList,
+ () => {
+ updateChart();
+ },
+ { deep: true }
+);
+```
+当 `props.dataList` 发生变化时,调用 `updateChart` 方法更新图表。
+
+### 3. 样式部分
+```css
+.chart-container {
+ width: 100%;
+ height: 30vh;
+}
+```
+设置图表容器的宽度为 100%,高度为 30vh。
+
+## 五、注意事项
+- 确保项目中已经正确安装并配置了 `lime-echart` 插件。
+- 传入的 `dataList` 数据格式要符合要求,包含 `xField`、`yField` 和 `legendField` 对应的数据。
+- 由于使用了异步加载 ECharts,可能会有一定的延迟,需要确保在合适的时机初始化图表。
\ No newline at end of file
diff --git a/utils/dateTime.js b/utils/dateTime.js
index 9095266..f614bbe 100644
--- a/utils/dateTime.js
+++ b/utils/dateTime.js
@@ -52,8 +52,67 @@ function getDateAfterDays(date, days) {
return newDate;
}
+function getDateAfterMonths(date, months) {
+ const newDate = new Date(date);
+ const originalDate = date.getDate();
+
+ // 保存原始年月日
+ const originalYear = date.getFullYear();
+ const originalMonth = date.getMonth();
+
+ // 计算目标年月
+ const totalMonths = originalMonth + months;
+ const expectedYear = originalYear + Math.floor(totalMonths / 12);
+ const expectedMonth = totalMonths % 12;
+
+ // 尝试设置新月份
+ newDate.setMonth(totalMonths);
+
+ // 处理月末边界情况
+ if (
+ newDate.getFullYear() !== expectedYear ||
+ newDate.getMonth() !== expectedMonth
+ ) {
+ // 当设置月份失败时(如1月31日设置到2月)
+ // 设置为目标月份的最后一天
+ newDate.setFullYear(expectedYear, expectedMonth + 1, 0);
+ } else if (newDate.getDate() !== originalDate) {
+ // 当日期自动变化时(如1月30日设置到2月)
+ // 同样设置为目标月份的最后一天
+ newDate.setDate(0);
+ }
+
+ return newDate;
+}
+
+
+//计算当前日期占全年的进度数据
+// 示例用法
+// console.log(getYearProgress()); // 输出如 "35.42%"
+function getYearProgress() {
+ const now = new Date(); // 当前时间
+ const year = now.getFullYear();
+
+ // 关键时间点
+ const yearStart = new Date(year, 0, 1); // 当年1月1日
+ const nextYearStart = new Date(year + 1, 0, 1); // 下一年1月1日
+
+ // 计算时间差(毫秒)
+ const totalMs = nextYearStart - yearStart; // 全年总时长
+ const passedMs = now - yearStart; // 已过时长
+
+ // 计算百分比(保留2位小数)
+ const progress = ((passedMs / totalMs) * 100).toFixed(2);
+
+ return parseFloat(progress);
+}
+
+
+
export {
formatDate,
getDateAfterDays,
- getDaysDifference
+ getDaysDifference,
+ getDateAfterMonths,
+ getYearProgress
}
\ No newline at end of file