import dayjs, { Dayjs } from 'dayjs'; import isoWeek from 'dayjs/plugin/isoWeek'; // 如果需要严格的 ISO 周计算 import quarterOfYear from 'dayjs/plugin/quarterOfYear'; // 用于季度操作 import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'; import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'; // 启用插件 dayjs.extend(quarterOfYear); dayjs.extend(isoWeek); dayjs.extend(isSameOrBefore); dayjs.extend(isSameOrAfter); // 设置全局语言为中文(可选,根据项目需求) import 'dayjs/locale/zh-cn'; dayjs.locale('zh-cn'); namespace Options { //开发方式 export const developmentMode = [ { value: '1', label: '堤坝式' }, { value: '2', label: '引水式' }, { value: '3', label: '混合式' } ]; // 建设状态 export const bldsttList = [ { value: '1', label: '在建' }, { value: '2', label: '已建' }, { value: '0', label: '规划' } ]; export const developmentMode2 = [ { value: 'RRU', label: '上水库' }, { value: 'RRL', label: '下水库' }, { value: 'GN', label: '机组' }, { value: 'GT', label: '闸门' } ]; //电站类型 export const powerStationType = [ { value: '', label: '所有' }, { value: '1', label: '已接入' }, { value: '0', label: '未接入' } ]; //工程类型 export const projectType = [ { value: '', label: '所有' }, { value: '1', label: '常规水电' }, { value: '2', label: '抽水蓄能' } ]; //调节性能 export const performance = [ { value: '1', label: '多年' }, { value: '2', label: '年' }, { value: '3', label: '不完全年' }, { value: '4', label: '径流式' }, { value: '5', label: '季' }, { value: '6', label: '月' }, { value: '7', label: '周' }, { value: '8', label: '日' }, { value: '9', label: '无' } ]; //流域 export const type = [ { value: 'district', label: '行政区' }, { value: 'basin', label: '流域' }, { value: 'company', label: '公司' } ]; export const type2 = [{ value: 'district', label: '行政区' }]; export const evaluateType = [ { value: '1', label: '水能效益' }, { value: '2', label: '水量效益' }, { value: '3', label: '水位运行评价' }, { value: '4', label: '防洪效益' }, { value: '5', label: '生态效益' } ]; } namespace DateSetting { //获取当前时间 function getStartTime(): Dayjs { return dayjs().startOf('day').startOf('hour'); } function getStartYear(): Dayjs { return dayjs().startOf('year'); } function getEarlyDays(): Array { return [dayjs().startOf('month'), dayjs().startOf('month').add(9, 'day')]; } function getMidmonth(): Array { return [ dayjs().startOf('month').add(10, 'day'), dayjs().startOf('month').add(19, 'day') ]; } function getLastTenDays(): Array { return [dayjs().startOf('month').add(20, 'day'), dayjs().endOf('month')]; } export const RangeButton: any = { days: [ { label: '今天', value: [dayjs().startOf('day'), dayjs().endOf('day')] }, { label: '昨天', value: [ dayjs().subtract(1, 'day').startOf('day'), dayjs().subtract(1, 'day').endOf('day') ] }, { label: '本周', // 注意:如果项目配置了 isoWeek 插件且希望周一为起始,可使用 startOf('isoWeek') value: [dayjs().startOf('week'), dayjs().endOf('week')] }, { label: '上周', value: [ dayjs().subtract(1, 'week').startOf('week'), dayjs().subtract(1, 'week').endOf('week') ] }, { label: '本月', value: [dayjs().startOf('month'), dayjs().endOf('month')] }, { label: '上月', value: [ dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month') ] }, { label: '上半年', value: [ dayjs().startOf('year'), dayjs() .startOf('year') .add(6, 'month') .subtract(1, 'day') .endOf('day') ] }, { label: '本年', value: [dayjs().startOf('year'), dayjs().endOf('year')] } ], days1: [ { label: '今天', value: [dayjs().startOf('day'), dayjs().endOf('day')] }, { label: '昨天', value: [ dayjs().subtract(1, 'day').startOf('day'), dayjs().subtract(1, 'day').endOf('day') ] }, { label: '近七天', // 注意:如果项目配置了 isoWeek 插件且希望周一为起始,可使用 startOf('isoWeek') value: [dayjs().subtract(6, 'day').startOf('day'), dayjs().endOf('day')] }, { label: '最近一个月', value: [ dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month') ] }, { label: '最近三个月', value: [ dayjs().subtract(3, 'month').startOf('month'), dayjs().endOf('month') ] }, { label: '今年', value: [dayjs().startOf('year'), dayjs().endOf('year')] } ], tenDays: [ { label: '上旬', value: getEarlyDays() }, { label: '中旬', value: getMidmonth() }, { label: '下旬', value: getLastTenDays() } ], month: [ { label: '最近一个月', value: [getStartTime().subtract(1, 'month'), getStartTime()] }, { label: '最近三个月', value: [getStartTime().subtract(3, 'month'), getStartTime()] }, { label: '最近半年', value: [getStartTime().subtract(6, 'month'), getStartTime()] }, { label: '最近一年', value: [getStartTime().subtract(1, 'year'), getStartTime()] } ], month1: [ { label: '最近7天', value: [getStartTime().subtract(6, 'day'), getStartTime()] }, { label: '最近1个月', value: [getStartTime().subtract(1, 'month'), getStartTime()] }, { label: '最近3个月', value: [getStartTime().subtract(3, 'month'), getStartTime()] }, { label: '最近6个月', value: [getStartTime().subtract(6, 'month'), getStartTime()] } ], hour: [ { label: '最近7小时', value: [getStartTime().subtract(7, 'hour'), getStartTime()] }, { label: '最近24小时', value: [getStartTime().subtract(24, 'hour'), getStartTime()] }, { label: '最近一周', value: [getStartTime().subtract(7, 'day'), getStartTime()] } ], season: [ { label: '第一季度', value: [getStartYear(), getStartYear().add(2, 'month').endOf('month')] }, { label: '第二季度', value: [ getStartYear().add(3, 'month'), getStartYear().add(5, 'month').endOf('month') ] }, { label: '第三季度', value: [ getStartYear().add(6, 'month'), getStartYear().add(8, 'month').endOf('month') ] }, { label: '第四季度', value: [ getStartYear().add(9, 'month'), getStartYear().add(11, 'month').endOf('month') ] } ], year: [ { label: '最近一年', value: [getStartTime().subtract(1, 'year'), getStartTime()] }, { label: '近三年', value: [getStartTime().subtract(3, 'year'), getStartTime()] }, { label: '最近五年', value: [getStartTime().subtract(5, 'year'), getStartTime()] }, { label: '最近十年', value: [getStartTime().subtract(10, 'year'), getStartTime()] } ], future: [ { label: '未来一周', value: [getStartTime(), getStartTime().add(7, 'day')] }, { label: '未来一个月', value: [getStartTime(), getStartTime().add(1, 'month')] }, { label: '未来三个月', value: [getStartTime(), getStartTime().add(3, 'month')] } ] }; } export { Options, DateSetting };