sh-view 2.7.8 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/other.js +8 -0
  2. package/package.json +4 -3
  3. package/packages/components/index.js +35 -35
  4. package/packages/components/{global-components/sh-alert → sh-alert}/index.vue +8 -15
  5. package/packages/components/{global-components/sh-badge → sh-badge}/index.vue +6 -5
  6. package/packages/components/{global-components/sh-calendar → sh-calendar}/index.vue +167 -36
  7. package/packages/components/{global-components/sh-date → sh-date}/index.vue +37 -9
  8. package/packages/components/{global-components/sh-drawer → sh-drawer}/index.vue +49 -27
  9. package/packages/components/{global-components/sh-form → sh-form}/js/useForm.js +2 -2
  10. package/packages/components/sh-header/index.vue +260 -0
  11. package/packages/components/sh-icon/css/font/icons.scss +135 -0
  12. package/packages/components/{global-components/sh-image → sh-image}/index.vue +2 -1
  13. package/packages/components/{global-components/sh-poptip → sh-poptip}/index.vue +1 -1
  14. package/packages/components/{global-components/sh-progress → sh-progress}/index.vue +2 -18
  15. package/packages/components/{global-components/sh-table → sh-table}/css/index.scss +18 -0
  16. package/packages/components/{global-components/sh-table → sh-table}/js/tableMethods.js +12 -20
  17. package/packages/components/{global-components/sh-table → sh-table}/js/useTable.js +4 -6
  18. package/packages/components/{global-components/sh-table → sh-table}/table.vue +217 -218
  19. package/packages/components/{global-components/sh-tabs → sh-tabs}/index.vue +97 -34
  20. package/packages/components/{global-components/sh-tree → sh-tree}/components/table-tree.vue +1 -2
  21. package/packages/components/{global-components/sh-tree → sh-tree}/css/index.scss +1 -0
  22. package/packages/components/{global-components/sh-tree → sh-tree}/index.vue +228 -217
  23. package/packages/components/{global-components/sh-tree → sh-tree}/mixin/treeProps.js +1 -1
  24. package/packages/index.js +39 -39
  25. package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-week-box.vue +126 -126
  26. package/packages/{components/other-components → other}/sh-menu/index.vue +3 -0
  27. package/packages/{components/other-components → other}/sh-menu/menu-item-content.vue +3 -3
  28. package/packages/other/sh-preview/components/sh-excel.vue +163 -0
  29. package/packages/{components/other-components → other}/sh-preview/index.vue +92 -89
  30. package/packages/vxeTable/css/index.scss +31 -8
  31. package/packages/vxeTable/render/cell/vxe-render-tree.vue +70 -63
  32. package/packages/vxeTable/render/filters/vxe-filter-input.vue +26 -25
  33. package/packages/vxeTable/render/filters/vxe-filter-time.vue +26 -0
  34. package/packages/vxeTable/render/globalRenders.jsx +26 -7
  35. package/packages/vxeTable/render/mixin/filter-hooks.js +31 -13
  36. package/packages/components/global-components/sh-header/index.vue +0 -278
  37. package/packages/components/global-components/sh-icon/css/font/icons.scss +0 -135
  38. package/packages/components/other-components/sh-preview/components/sh-excel.vue +0 -929
  39. /package/packages/components/{global-components/sh-card → sh-card}/index.vue +0 -0
  40. /package/packages/components/{global-components/sh-code-editor → sh-code-editor}/index.vue +0 -0
  41. /package/packages/components/{global-components/sh-code-editor → sh-code-editor}/themes/dark.js +0 -0
  42. /package/packages/components/{global-components/sh-code-editor → sh-code-editor}/themes/dracula.js +0 -0
  43. /package/packages/components/{global-components/sh-code-editor → sh-code-editor}/themes/index.js +0 -0
  44. /package/packages/components/{global-components/sh-col → sh-col}/css/index.scss +0 -0
  45. /package/packages/components/{global-components/sh-col → sh-col}/index.vue +0 -0
  46. /package/packages/components/{global-components/sh-corner → sh-corner}/index.vue +0 -0
  47. /package/packages/components/{global-components/sh-count-to → sh-count-to}/index.vue +0 -0
  48. /package/packages/components/{global-components/sh-drawer → sh-drawer}/scrollbar.js +0 -0
  49. /package/packages/components/{global-components/sh-empty → sh-empty}/index.vue +0 -0
  50. /package/packages/components/{global-components/sh-form → sh-form}/form.vue +0 -0
  51. /package/packages/components/{global-components/sh-form → sh-form}/js/props.js +0 -0
  52. /package/packages/components/{global-components/sh-form → sh-form}/query.vue +0 -0
  53. /package/packages/components/{global-components/sh-icon → sh-icon}/css/default/icons.scss +0 -0
  54. /package/packages/components/{global-components/sh-icon → sh-icon}/css/default/ionicons.svg +0 -0
  55. /package/packages/components/{global-components/sh-icon → sh-icon}/css/default/ionicons.ttf +0 -0
  56. /package/packages/components/{global-components/sh-icon → sh-icon}/css/default/ionicons.woff +0 -0
  57. /package/packages/components/{global-components/sh-icon → sh-icon}/css/default/ionicons.woff2 +0 -0
  58. /package/packages/components/{global-components/sh-icon → sh-icon}/css/font/iconfont.js +0 -0
  59. /package/packages/components/{global-components/sh-icon → sh-icon}/css/font/iconfont.json +0 -0
  60. /package/packages/components/{global-components/sh-icon → sh-icon}/css/font/iconfont.ttf +0 -0
  61. /package/packages/components/{global-components/sh-icon → sh-icon}/css/font/iconfont.woff +0 -0
  62. /package/packages/components/{global-components/sh-icon → sh-icon}/css/font/iconfont.woff2 +0 -0
  63. /package/packages/components/{global-components/sh-icon → sh-icon}/css/index.scss +0 -0
  64. /package/packages/components/{global-components/sh-icon → sh-icon}/index.vue +0 -0
  65. /package/packages/components/{global-components/sh-list → sh-list}/index.vue +0 -0
  66. /package/packages/components/{global-components/sh-loading → sh-loading}/index.vue +0 -0
  67. /package/packages/components/{global-components/sh-modal → sh-modal}/index.vue +0 -0
  68. /package/packages/components/{global-components/sh-noticebar → sh-noticebar}/index.vue +0 -0
  69. /package/packages/components/{global-components/sh-pull-refresh → sh-pull-refresh}/index.vue +0 -0
  70. /package/packages/components/{global-components/sh-result → sh-result}/index.vue +0 -0
  71. /package/packages/components/{global-components/sh-row → sh-row}/css/index.scss +0 -0
  72. /package/packages/components/{global-components/sh-row → sh-row}/index.vue +0 -0
  73. /package/packages/components/{global-components/sh-split → sh-split}/components/trigger.vue +0 -0
  74. /package/packages/components/{global-components/sh-split → sh-split}/index.vue +0 -0
  75. /package/packages/components/{global-components/sh-table → sh-table}/components/importModal.vue +0 -0
  76. /package/packages/components/{global-components/sh-table → sh-table}/components/sh-column.vue +0 -0
  77. /package/packages/components/{global-components/sh-table → sh-table}/grid.vue +0 -0
  78. /package/packages/components/{global-components/sh-table → sh-table}/js/excel_to_json.js +0 -0
  79. /package/packages/components/{global-components/sh-table → sh-table}/js/props.js +0 -0
  80. /package/packages/components/{global-components/sh-tag → sh-tag}/index.vue +0 -0
  81. /package/packages/components/{global-components/sh-toolbar → sh-toolbar}/index.vue +0 -0
  82. /package/packages/components/{global-components/sh-upload → sh-upload}/index.vue +0 -0
  83. /package/packages/components/{global-components/sh-upload → sh-upload}/js/ajax.js +0 -0
  84. /package/packages/components/{global-components/sh-water-fall → sh-water-fall}/index.vue +0 -0
  85. /package/packages/components/{global-components/sh-water-mark → sh-water-mark}/index.vue +0 -0
  86. /package/packages/{components/other-components → other}/sh-cron-modal/components/cron-content.vue +0 -0
  87. /package/packages/{components/other-components → other}/sh-cron-modal/css/index.scss +0 -0
  88. /package/packages/{components/other-components → other}/sh-cron-modal/index.vue +0 -0
  89. /package/packages/{components/other-components → other}/sh-cron-modal/mixin/cron-emits.js +0 -0
  90. /package/packages/{components/other-components → other}/sh-cron-modal/mixin/cron-hooks.js +0 -0
  91. /package/packages/{components/other-components → other}/sh-cron-modal/mixin/cron-props.js +0 -0
  92. /package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-day-box.vue +0 -0
  93. /package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-hour-box.vue +0 -0
  94. /package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-minute-box.vue +0 -0
  95. /package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-month-box.vue +0 -0
  96. /package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-second-box.vue +0 -0
  97. /package/packages/{components/other-components → other}/sh-cron-modal/tabs/cron-year-box.vue +0 -0
  98. /package/packages/{components/other-components → other}/sh-cron-modal/utils/index.js +0 -0
  99. /package/packages/{components/other-components → other}/sh-markdown/index.vue +0 -0
  100. /package/packages/{components/other-components → other}/sh-markdown/tinymce/langs/zh-Hans.js +0 -0
  101. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/content/default/content.css +0 -0
  102. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/content.css +0 -0
  103. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/content.inline.css +0 -0
  104. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/content.inline.min.css +0 -0
  105. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/content.min.css +0 -0
  106. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/content.mobile.css +0 -0
  107. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/content.mobile.min.css +0 -0
  108. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
  109. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/skin.css +0 -0
  110. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/skin.min.css +0 -0
  111. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/skin.mobile.css +0 -0
  112. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/skin.mobile.min.css +0 -0
  113. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/skin.shadowdom.css +0 -0
  114. /package/packages/{components/other-components → other}/sh-markdown/tinymce/skins/ui/oxide/skin.shadowdom.min.css +0 -0
  115. /package/packages/{components/other-components → other}/sh-menu/menu-group-content.vue +0 -0
  116. /package/packages/{components/other-components → other}/sh-menu-card/index.vue +0 -0
  117. /package/packages/{components/other-components → other}/sh-menu-card/menu-box.vue +0 -0
  118. /package/packages/{components/other-components → other}/sh-preview/components/sh-word.vue +0 -0
  119. /package/packages/{components/other-components → other}/sh-preview/js/data-hook.js +0 -0
  120. /package/packages/{components/other-components → other}/sh-preview/js/data-props.js +0 -0
  121. /package/packages/{components/other-components → other}/sh-system-tip/index.vue +0 -0
package/other.js ADDED
@@ -0,0 +1,8 @@
1
+ import { defineAsyncComponent } from 'vue'
2
+
3
+ export const ShCronModal = defineAsyncComponent(() => import('./packages/other/sh-cron-modal/index.vue'))
4
+ export const ShMarkdown = defineAsyncComponent(() => import('./packages/other/sh-markdown/index.vue'))
5
+ export const ShMenu = defineAsyncComponent(() => import('./packages/other/sh-menu/index.vue'))
6
+ export const ShMenuCard = defineAsyncComponent(() => import('./packages/other/sh-menu-card/index.vue'))
7
+ export const ShPreview = defineAsyncComponent(() => import('./packages/other/sh-preview/index.vue'))
8
+ export const ShSystemTip = defineAsyncComponent(() => import('./packages/other/sh-system-tip/index.vue'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sh-view",
3
- "version": "2.7.8",
3
+ "version": "2.8.0",
4
4
  "description": "基于vxe-table二次封装,更包含Alert,Badge,Card,CodeEditor,Col,Corner,CountTo,Drawer,Empty,Form,Header,Icon,List,Loading,Modal,Noticebar,Poptip,Progress,PullRefresh,Query,Result,Row,Split,Grid,Table,Tabs,Tag,Toolbar,Tree,Upload,WaterFall,WaterMark等丰富组件库",
5
5
  "main": "packages/index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@
18
18
  "@codemirror/lang-json": "^6.0.1",
19
19
  "@codemirror/lang-sql": "^6.5.2",
20
20
  "@tinymce/tinymce-vue": "^5.0.0",
21
+ "@wolf-table/table": "^0.0.1",
21
22
  "babel-polyfill": "^6.26.0",
22
23
  "codemirror": "^6.0.1",
23
24
  "core-js": "^3.32.2",
@@ -29,12 +30,12 @@
29
30
  "jszip": "^3.10.1",
30
31
  "lunar-typescript": "^1.6.10",
31
32
  "popper.js": "^1.16.1",
32
- "sh-tools": "^2.2.2",
33
+ "sh-tools": "^2.2.5",
33
34
  "tinymce": "^5.10.5",
34
35
  "vue": "^3.3.4",
35
36
  "vue-masonry": "^0.16.0",
36
37
  "vue-router": "^4.2.4",
37
- "vxe-table": "^4.5.12",
38
+ "vxe-table": "^4.5.13",
38
39
  "vxe-table-plugin-export-pdf": "^3.0.4",
39
40
  "vxe-table-plugin-export-xlsx": "^3.0.5",
40
41
  "xe-clipboard": "^1.10.2",
@@ -1,39 +1,39 @@
1
1
  // 全局公共封装组件
2
- import ShAlert from './global-components/sh-alert/index.vue'
3
- import ShBadge from './global-components/sh-badge/index.vue'
4
- import ShCalendar from './global-components/sh-calendar/index.vue'
5
- import ShCard from './global-components/sh-card/index.vue'
6
- import ShCodeEditor from './global-components/sh-code-editor/index.vue'
7
- import ShCol from './global-components/sh-col/index.vue'
8
- import ShCorner from './global-components/sh-corner/index.vue'
9
- import ShCountTo from './global-components/sh-count-to/index.vue'
10
- import ShDate from './global-components/sh-date/index.vue'
11
- import ShDrawer from './global-components/sh-drawer/index.vue'
12
- import ShEmpty from './global-components/sh-empty/index.vue'
13
- import ShForm from './global-components/sh-form/form.vue'
14
- import ShHeader from './global-components/sh-header/index.vue'
15
- import ShIcon from './global-components/sh-icon/index.vue'
16
- import ShImage from './global-components/sh-image/index.vue'
17
- import ShList from './global-components/sh-list/index.vue'
18
- import ShLoading from './global-components/sh-loading/index.vue'
19
- import ShModal from './global-components/sh-modal/index.vue'
20
- import ShNoticebar from './global-components/sh-noticebar/index.vue'
21
- import ShPoptip from './global-components/sh-poptip/index.vue'
22
- import ShProgress from './global-components/sh-progress/index.vue'
23
- import ShPullRefresh from './global-components/sh-pull-refresh/index.vue'
24
- import ShQuery from './global-components/sh-form/query.vue'
25
- import ShResult from './global-components/sh-result/index.vue'
26
- import ShRow from './global-components/sh-row/index.vue'
27
- import ShSplit from './global-components/sh-split/index.vue'
28
- import ShGrid from './global-components/sh-table/grid.vue'
29
- import ShTable from './global-components/sh-table/table.vue'
30
- import ShTabs from './global-components/sh-tabs/index.vue'
31
- import ShTag from './global-components/sh-tag/index.vue'
32
- import ShToolbar from './global-components/sh-toolbar/index.vue'
33
- import ShTree from './global-components/sh-tree/index.vue'
34
- import ShUpload from './global-components/sh-upload/index.vue'
35
- import ShWaterFall from './global-components/sh-water-fall/index.vue'
36
- import ShWaterMark from './global-components/sh-water-mark/index.vue'
2
+ import ShAlert from './sh-alert/index.vue'
3
+ import ShBadge from './sh-badge/index.vue'
4
+ import ShCalendar from './sh-calendar/index.vue'
5
+ import ShCard from './sh-card/index.vue'
6
+ import ShCodeEditor from './sh-code-editor/index.vue'
7
+ import ShCol from './sh-col/index.vue'
8
+ import ShCorner from './sh-corner/index.vue'
9
+ import ShCountTo from './sh-count-to/index.vue'
10
+ import ShDate from './sh-date/index.vue'
11
+ import ShDrawer from './sh-drawer/index.vue'
12
+ import ShEmpty from './sh-empty/index.vue'
13
+ import ShForm from './sh-form/form.vue'
14
+ import ShHeader from './sh-header/index.vue'
15
+ import ShIcon from './sh-icon/index.vue'
16
+ import ShImage from './sh-image/index.vue'
17
+ import ShList from './sh-list/index.vue'
18
+ import ShLoading from './sh-loading/index.vue'
19
+ import ShModal from './sh-modal/index.vue'
20
+ import ShNoticebar from './sh-noticebar/index.vue'
21
+ import ShPoptip from './sh-poptip/index.vue'
22
+ import ShProgress from './sh-progress/index.vue'
23
+ import ShPullRefresh from './sh-pull-refresh/index.vue'
24
+ import ShQuery from './sh-form/query.vue'
25
+ import ShResult from './sh-result/index.vue'
26
+ import ShRow from './sh-row/index.vue'
27
+ import ShSplit from './sh-split/index.vue'
28
+ import ShGrid from './sh-table/grid.vue'
29
+ import ShTable from './sh-table/table.vue'
30
+ import ShTabs from './sh-tabs/index.vue'
31
+ import ShTag from './sh-tag/index.vue'
32
+ import ShToolbar from './sh-toolbar/index.vue'
33
+ import ShTree from './sh-tree/index.vue'
34
+ import ShUpload from './sh-upload/index.vue'
35
+ import ShWaterFall from './sh-water-fall/index.vue'
36
+ import ShWaterMark from './sh-water-mark/index.vue'
37
37
  import { VxeButton, VxeInput, VxeTextarea, VxeSelect } from 'vxe-table'
38
38
 
39
39
  const components = {
@@ -55,23 +55,16 @@ export default defineComponent({
55
55
  const { slots, emit } = context
56
56
  const closed = ref(false)
57
57
 
58
+ const iconTypeMap = {
59
+ success: 'ios-checkmark-circle',
60
+ info: 'ios-information-circle',
61
+ warning: 'ios-alert',
62
+ error: 'ios-close-circle'
63
+ }
64
+
58
65
  const isDesc = computed(() => !!slots.content)
59
66
  const iconType = computed(() => {
60
- let type = ''
61
- switch (props.type) {
62
- case 'success':
63
- type = 'ios-checkmark-circle'
64
- break
65
- case 'info':
66
- type = 'ios-information-circle'
67
- break
68
- case 'warning':
69
- type = 'ios-alert'
70
- break
71
- case 'error':
72
- type = 'ios-close-circle'
73
- break
74
- }
67
+ let type = iconTypeMap[props.type]
75
68
  if (isDesc.value) type += '-outline'
76
69
  return type
77
70
  })
@@ -72,19 +72,20 @@ export default defineComponent({
72
72
  return parseInt(props.count) >= parseInt(props.overflowCount) ? `${props.overflowCount}+` : props.count
73
73
  })
74
74
  const hasBadge = computed(() => {
75
+ let hasStatus = false
75
76
  if (props.count) {
76
- status = !(parseInt(props.count) === 0)
77
+ hasStatus = !(parseInt(props.count) === 0)
77
78
  }
78
79
  if (props.dot) {
79
- status = true
80
+ hasStatus = true
80
81
  if (props.count !== null) {
81
82
  if (parseInt(props.count) === 0) {
82
- status = false
83
+ hasStatus = false
83
84
  }
84
85
  }
85
86
  }
86
- if (props.text !== '') status = true
87
- return status || props.showZero
87
+ if (props.text !== '') hasStatus = true
88
+ return hasStatus || props.showZero
88
89
  })
89
90
  const hasCount = computed(() => {
90
91
  if (props.count || props.text !== '') return true
@@ -1,7 +1,10 @@
1
1
  <template>
2
2
  <div class="sh-calendar">
3
3
  <div v-if="header" class="sh-calendar-row sh-calendar-head">
4
- <div class="info">{{ monthInfo }}</div>
4
+ <div class="info">
5
+ <sh-select v-if="type !== 'year'" v-bind="yearSelectConfig" @change="onYearChange" />
6
+ <sh-select v-if="!['month', 'year'].includes(type)" v-bind="monthSelectConfig" @change="onMonthChange"></sh-select>
7
+ </div>
5
8
  <div class="extra">
6
9
  <template v-for="item in headerHandles" :key="item.code">
7
10
  <span class="sh-calendar-btn" @click="handleBtn(item)"><i :class="item.icon"></i></span>
@@ -9,7 +12,7 @@
9
12
  </div>
10
13
  </div>
11
14
  <table class="sh-calendar-table" :class="{ 'sh-calendar-pulldown': pulldown }" v-bind="tableConfig">
12
- <thead>
15
+ <thead v-if="showHeader">
13
16
  <tr>
14
17
  <template v-for="(head, headIndex) in headers" :key="headIndex">
15
18
  <th :style="{ textAlign: headerAlign }">{{ head.label }}</th>
@@ -17,13 +20,13 @@
17
20
  </tr>
18
21
  </thead>
19
22
  <tbody @mouseleave="dateMouseleaveEvent">
20
- <template v-for="(row, rowIndex) in dayDatas" :key="rowIndex">
23
+ <template v-for="(row, rowIndex) in bodyDatas" :key="rowIndex">
21
24
  <tr>
22
25
  <template v-for="(item, itemIndex) in row" :key="itemIndex">
23
26
  <td :class="getCellClass(item)" @mouseenter="dateMouseenterEvent(item)" @click="dateSelectEvent(item)">
24
27
  <slot name="cell" v-bind="item">
25
28
  <div class="sh-calendar-cell" :style="{ textAlign: align }">
26
- <div class="sh-calendar-cell-head">{{ item.label }}</div>
29
+ <div class="sh-calendar-cell-head" :class="{ 'is-month': type === 'month' }">{{ item.label }}</div>
27
30
  <div v-if="note" class="sh-calendar-cell-body" :style="{ height: noteHeight }">{{ noteMethod(item) }}</div>
28
31
  <div v-if="festival" class="sh-calendar-cell-foot">{{ getLunarDate(item.date) }}</div>
29
32
  </div>
@@ -73,7 +76,7 @@ export default defineComponent({
73
76
  name: 'ShCalendar',
74
77
  props: {
75
78
  modelValue: [String, Number, Date],
76
- type: { type: String, default: 'day' }, // day, month, year 暂时只支持day
79
+ type: { type: String, default: 'day' }, // day, month, year
77
80
  startDay: { type: [String, Number], default: 1 },
78
81
  headerAlign: { type: String, default: 'center' },
79
82
  align: { type: String, default: 'center' },
@@ -99,6 +102,8 @@ export default defineComponent({
99
102
  const { $vUtils } = proxy
100
103
  const { emit, slots } = context
101
104
 
105
+ const yearSize = 12
106
+ const monthSize = 12
102
107
  const headerHandles = [
103
108
  { code: 'prev', icon: 'vxe-icon-caret-left' },
104
109
  { code: 'current', icon: 'vxe-icon-dot' },
@@ -133,6 +138,55 @@ export default defineComponent({
133
138
  const dateValue = computeDateValue.value
134
139
  return dateValue ? (dateValue.getHours() * 3600 + dateValue.getMinutes() * 60 + dateValue.getSeconds()) * 1000 : 0
135
140
  })
141
+
142
+ const computeYearList = computed(() => {
143
+ const { selectMonth, currentDate } = reactData
144
+ const years = []
145
+ if (selectMonth && currentDate) {
146
+ const currFullYear = currentDate.getFullYear()
147
+ const selectFullYear = selectMonth.getFullYear()
148
+ const startYearDate = new Date(selectFullYear - (selectFullYear % yearSize), 0, 1)
149
+ for (let index = -4; index < yearSize + 4; index++) {
150
+ const date = $vUtils.getWhatYear(startYearDate, index, 'first')
151
+ const itemFullYear = date.getFullYear()
152
+ years.push({
153
+ date,
154
+ isCurrent: true,
155
+ isPrev: index < 0,
156
+ isNow: currFullYear === itemFullYear,
157
+ isNext: index >= yearSize,
158
+ year: itemFullYear,
159
+ label: `${itemFullYear}年`
160
+ })
161
+ }
162
+ }
163
+ return years
164
+ })
165
+ const computeMonthList = computed(() => {
166
+ const { selectMonth, currentDate } = reactData
167
+ const months = []
168
+ if (selectMonth && currentDate) {
169
+ const currFullYear = currentDate.getFullYear()
170
+ const currMonth = currentDate.getMonth()
171
+ const selFullYear = $vUtils.getWhatYear(selectMonth, 0, 'first').getFullYear()
172
+ for (let index = 0; index < monthSize; index++) {
173
+ const date = $vUtils.getWhatYear(selectMonth, 0, index)
174
+ const itemFullYear = date.getFullYear()
175
+ const itemMonth = date.getMonth()
176
+ const isPrev = itemFullYear < selFullYear
177
+ months.push({
178
+ date,
179
+ isPrev,
180
+ isCurrent: itemFullYear === selFullYear,
181
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth,
182
+ isNext: !isPrev && itemFullYear > selFullYear,
183
+ month: itemMonth,
184
+ label: `${itemMonth + 1}月`
185
+ })
186
+ }
187
+ }
188
+ return months
189
+ })
136
190
  const computeDayList = computed(() => {
137
191
  const { selectMonth, currentDate } = reactData
138
192
  const days = []
@@ -159,13 +213,13 @@ export default defineComponent({
159
213
  isCurrent: itemFullYear === selFullYear && itemMonth === selMonth,
160
214
  isNow: itemFullYear === currFullYear && itemMonth === currMonth && itemDate === currDate,
161
215
  isNext: !isPrev && selMonth !== itemMonth,
216
+ day: itemDate,
162
217
  label: itemDate
163
218
  })
164
219
  }
165
220
  }
166
221
  return days
167
222
  })
168
-
169
223
  // 以下为日历需要
170
224
  const tableConfig = computed(() => ({ cellspacing: 0, cellpadding: 0, border: 0 }))
171
225
  const headers = computed(() => {
@@ -174,9 +228,13 @@ export default defineComponent({
174
228
  return { value: day, label: props.weeks[day] }
175
229
  })
176
230
  })
177
- const dayDatas = computed(() => {
178
- const dayList = computeDayList.value
179
- return $vUtils.chunk(dayList, 7)
231
+ const bodyDatas = computed(() => {
232
+ if ('month' === props.type) {
233
+ return $vUtils.chunk(computeMonthList.value, 3)
234
+ } else if ('year' === props.type) {
235
+ return $vUtils.chunk(computeYearList.value, 4)
236
+ }
237
+ return $vUtils.chunk(computeDayList.value, 7)
180
238
  })
181
239
  const computeDateValue = computed(() => {
182
240
  const { inputValue } = reactData
@@ -189,8 +247,40 @@ export default defineComponent({
189
247
  }
190
248
  return val
191
249
  })
192
- const monthInfo = computed(() => $vUtils.toDateString(reactData.selectMonth, 'yyyy 年 MM 月'))
193
- const dayInfo = computed(() => $vUtils.toDateString(reactData.currentDate, 'yyyyMMdd'))
250
+ const showHeader = computed(() => !['month', 'year'].includes(props.type))
251
+ const yearValue = computed(() => $vUtils.toDateString(reactData.selectMonth, 'yyyy'))
252
+ const monthValue = computed(() => $vUtils.toDateString(reactData.selectMonth, 'MM'))
253
+ const dayValue = computed(() => $vUtils.toDateString(reactData.selectMonth, 'dd'))
254
+ const yearSelectConfig = computed(() => {
255
+ const options = []
256
+ for (let index = 1880; index < 2116; index++) {
257
+ options.push({
258
+ value: index + '',
259
+ label: `${index}年`
260
+ })
261
+ }
262
+ return {
263
+ modelValue: yearValue.value,
264
+ options: options,
265
+ filterable: true,
266
+ style: { width: '85px' }
267
+ }
268
+ })
269
+ const monthSelectConfig = computed(() => {
270
+ const options = []
271
+ for (let index = 1; index < 13; index++) {
272
+ options.push({
273
+ value: index + '',
274
+ label: `${index}月`
275
+ })
276
+ }
277
+ return {
278
+ modelValue: monthValue.value,
279
+ options: options,
280
+ filterable: true,
281
+ style: { width: '75px' }
282
+ }
283
+ })
194
284
  const lunarInfo = computed(() => {
195
285
  let dayDate = reactData.inputValue || reactData.currentDate
196
286
  let lunarDate = Lunar.fromDate(dayDate)
@@ -216,12 +306,7 @@ export default defineComponent({
216
306
  emit('change', date)
217
307
  }
218
308
  const dateSelectItem = date => {
219
- const { type } = props
220
- if (type === 'month') {
221
- } else if (type === 'year') {
222
- } else {
223
- dateChange(date)
224
- }
309
+ dateChange(date)
225
310
  }
226
311
  const dateCheckMonth = date => {
227
312
  const month = $vUtils.getWhatMonth(date, 0, 'first')
@@ -229,13 +314,29 @@ export default defineComponent({
229
314
  reactData.selectMonth = month
230
315
  }
231
316
  }
232
- const dateMoveDay = date => {
233
- if (isDateDisabled(date)) return
317
+ const dateMoveDay = offsetDay => {
318
+ if (isDateDisabled({ date: offsetDay })) return
234
319
  const dayList = computeDayList.value
235
- if (!dayList.some(item => $vUtils.isDateSame(item.date, date.date, 'yyyyMMdd'))) {
236
- dateCheckMonth(date.date)
320
+ if (!dayList.some(item => $vUtils.isDateSame(item.date, offsetDay, 'yyyyMMdd'))) {
321
+ dateCheckMonth(offsetDay)
237
322
  }
238
- dateParseValue(date.date)
323
+ dateParseValue(offsetDay)
324
+ }
325
+ const dateMoveMonth = offsetMonth => {
326
+ if (isDateDisabled({ date: offsetMonth })) return
327
+ const monthList = computeMonthList.value
328
+ if (!monthList.some(item => $vUtils.isDateSame(item.date, offsetMonth, 'yyyyMM'))) {
329
+ dateCheckMonth(offsetMonth)
330
+ }
331
+ dateParseValue(offsetMonth)
332
+ }
333
+ const dateMoveYear = offsetYear => {
334
+ if (isDateDisabled({ date: offsetYear })) return
335
+ const yearList = computeYearList.value
336
+ if (!yearList.some(item => $vUtils.isDateSame(item.date, offsetYear, 'yyyy'))) {
337
+ dateCheckMonth(offsetYear)
338
+ }
339
+ dateParseValue(offsetYear)
239
340
  }
240
341
  const dateSelectEvent = item => {
241
342
  if (isDateDisabled(item)) return
@@ -243,13 +344,12 @@ export default defineComponent({
243
344
  }
244
345
  const dateMouseenterEvent = item => {
245
346
  if (isDateDisabled(item)) return
246
- const { datePanelType } = reactData
247
- if (datePanelType === 'month') {
248
- // dateMoveMonth(item.date)
249
- } else if (datePanelType === 'year') {
250
- // dateMoveYear(item.date)
347
+ if (props.type === 'month') {
348
+ dateMoveMonth(item.date)
349
+ } else if (props.type === 'year') {
350
+ dateMoveYear(item.date)
251
351
  } else {
252
- dateMoveDay(item)
352
+ dateMoveDay(item.date)
253
353
  }
254
354
  }
255
355
  const dateMouseleaveEvent = () => {
@@ -285,8 +385,10 @@ export default defineComponent({
285
385
  const getCellClass = item => {
286
386
  const { panelValue } = reactData
287
387
  const dateValue = computeDateValue.value
288
- const matchFormat = 'yyyyMMdd'
289
- const ymd = $vUtils.toDateString(item.date, matchFormat)
388
+ let matchFormat = 'yyyyMMdd'
389
+ if ('month' === props.type) matchFormat = 'yyyyMM'
390
+ else if ('year' === props.type) matchFormat = 'yyyy'
391
+ const ymd = $vUtils.toDateString(item.date, 'yyyyMMdd')
290
392
  const lunarDate = Lunar.fromDate(item.date)
291
393
  const holiday = HolidayUtil.getHoliday(ymd)
292
394
  let rest = false
@@ -309,12 +411,16 @@ export default defineComponent({
309
411
  const handleBtn = ({ code }) => {
310
412
  try {
311
413
  const { currentDate, selectMonth } = reactData
414
+ let getName = 'getWhatMonth'
415
+ let getSize = 1
416
+ if (['month', 'year'].includes(props.type)) getName = 'getWhatYear'
417
+ if (['year'].includes(props.type)) getSize = yearSize
312
418
  switch (code) {
313
419
  case 'prev':
314
- reactData.selectMonth = $vUtils.getWhatMonth(selectMonth, -1, 'first')
420
+ reactData.selectMonth = $vUtils[getName](selectMonth, getSize * -1, 'first')
315
421
  break
316
422
  case 'next':
317
- reactData.selectMonth = $vUtils.getWhatMonth(selectMonth, 1, 'first')
423
+ reactData.selectMonth = $vUtils[getName](selectMonth, getSize, 'first')
318
424
  break
319
425
  case 'current':
320
426
  reactData.selectMonth = $vUtils.getWhatMonth(currentDate, 0, 'first')
@@ -334,7 +440,23 @@ export default defineComponent({
334
440
  // 初始化
335
441
  const initValue = () => {
336
442
  reactData.currentDate = $vUtils.getWhatDay(Date.now(), 0, 'first')
337
- reactData.selectMonth = $vUtils.getWhatMonth(reactData.currentDate, 0, 'first')
443
+ reactData.selectMonth = $vUtils.getWhatMonth(computeDateValue.value || reactData.currentDate, 0, 'first')
444
+ }
445
+ // 年度切换
446
+ const onYearChange = ({ value }) => {
447
+ const { selectMonth } = reactData
448
+ const selMonth = selectMonth.getMonth() + 1
449
+ const selDate = selectMonth.getDate()
450
+ const changeDate = `${value}-${selMonth}-${selDate}`
451
+ reactData.selectMonth = $vUtils.toStringDate(changeDate)
452
+ }
453
+ // 月份切换
454
+ const onMonthChange = ({ value }) => {
455
+ const { selectMonth } = reactData
456
+ const selYear = selectMonth.getFullYear()
457
+ const selDate = selectMonth.getDate()
458
+ const changeDate = `${selYear}-${value}-${selDate}`
459
+ reactData.selectMonth = $vUtils.toStringDate(changeDate)
338
460
  }
339
461
 
340
462
  onBeforeMount(() => {
@@ -349,13 +471,19 @@ export default defineComponent({
349
471
  )
350
472
 
351
473
  return {
474
+ reactData,
352
475
  tableConfig,
476
+ yearSelectConfig,
477
+ monthSelectConfig,
353
478
  headers,
354
- dayDatas,
355
- monthInfo,
356
- dayInfo,
479
+ bodyDatas,
357
480
  lunarInfo,
358
481
  headerHandles,
482
+ computeYearList,
483
+ computeMonthList,
484
+ showHeader,
485
+ onYearChange,
486
+ onMonthChange,
359
487
  getLunarDate,
360
488
  getCellClass,
361
489
  handleBtn,
@@ -439,6 +567,9 @@ export default defineComponent({
439
567
  & + .sh-calendar-cell-foot {
440
568
  padding-top: 0;
441
569
  }
570
+ &.is-month {
571
+ padding: 20px 5px;
572
+ }
442
573
  }
443
574
  &-body {
444
575
  overflow: auto;
@@ -13,9 +13,9 @@
13
13
  </template>
14
14
  <template #dropdown>
15
15
  <div class="sh-date-content">
16
- <sh-calendar v-model="rangeValue[0]" v-bind="startCalendarConfig"></sh-calendar>
16
+ <sh-calendar v-model="rangeValue[0]" v-bind="startCalendarConfig" @change="onCalendarChange($event, 1)"></sh-calendar>
17
17
  <div style="min-width: 10px"></div>
18
- <sh-calendar v-model="rangeValue[1]" v-bind="endCalendarConfig"></sh-calendar>
18
+ <sh-calendar v-model="rangeValue[1]" v-bind="endCalendarConfig" @change="onCalendarChange($event, 2)"></sh-calendar>
19
19
  </div>
20
20
  </template>
21
21
  </vxe-pulldown>
@@ -78,6 +78,8 @@ export default defineComponent({
78
78
  transfer: Boolean,
79
79
  // 个性化参数
80
80
  range: Boolean,
81
+ rangeFormat: String,
82
+ autoBlur: { type: Boolean, default: true },
81
83
  separator: { type: String, default: '至' },
82
84
  startPlaceholder: { type: String, default: '起始日期' },
83
85
  endPlaceholder: { type: String, default: '截止日期' },
@@ -121,18 +123,32 @@ export default defineComponent({
121
123
  const pulldownConfig = computed(() => {
122
124
  return Object.assign({ transfer: true }, props.pulldown)
123
125
  })
126
+ const calendarFormat = computed(() => {
127
+ if (props.rangeFormat) return props.rangeFormat
128
+ else if (props.type === 'month') return 'yyyy-MM'
129
+ else if (props.type === 'year') return 'yyyy'
130
+ return props.valueFormat
131
+ })
124
132
  const rangeInputConfig = computed(() => ({ type: 'text', readonly: true }))
125
133
  const startInputConfig = computed(() => {
126
134
  let startValue = rangeValue.value[0] || ''
127
- let startLabel = $vUtils.toDateString(startValue, props.labelFormat)
135
+ let startLabel = $vUtils.toDateString(startValue, calendarFormat.value)
128
136
  return { ...rangeInputConfig.value, value: startLabel, placeholder: props.startPlaceholder }
129
137
  })
130
138
  const endInputConfig = computed(() => {
131
139
  let endValue = rangeValue.value[1] || ''
132
- let endLabel = $vUtils.toDateString(endValue, props.labelFormat)
140
+ let endLabel = $vUtils.toDateString(endValue, calendarFormat.value)
133
141
  return { ...rangeInputConfig.value, value: endLabel, placeholder: props.endPlaceholder }
134
142
  })
135
- const calendarConfig = computed(() => ({ pulldown: true, style: { height: '100%' }, align: 'center', valueFormat: props.valueFormat }))
143
+ const calendarConfig = computed(() => {
144
+ return {
145
+ pulldown: true,
146
+ style: { height: '100%' },
147
+ align: 'center',
148
+ valueFormat: calendarFormat.value,
149
+ type: props.type
150
+ }
151
+ })
136
152
  const startCalendarConfig = computed(() => {
137
153
  let startValue = rangeValue.value[0] || ''
138
154
  return {
@@ -175,12 +191,23 @@ export default defineComponent({
175
191
  dispatch('blur')
176
192
  }
177
193
 
194
+ const onCalendarChange = (date, type) => {
195
+ let valueList = rangeValue.value.filter(_ => _)
196
+ if (props.autoBlur && valueList.length === 2) {
197
+ pulldownValue.value = false
198
+ onHidePanel()
199
+ }
200
+ }
201
+
178
202
  // 回调事件
179
203
  const dispatch = (code, params) => {
180
- if (code === 'value') {
181
- emit('update:modelValue', rangeValue.value)
182
- } else if (props.range) {
183
- emit(code, { value: rangeValue.value, params })
204
+ if (props.range) {
205
+ let formarValue = rangeValue.value.map(item => $vUtils.toDateString(item, calendarFormat.value))
206
+ if (code === 'value') {
207
+ emit('update:modelValue', formarValue)
208
+ } else {
209
+ emit(code, { value: formarValue, params })
210
+ }
184
211
  } else {
185
212
  if (code === 'change') {
186
213
  emit('update:modelValue', params.value)
@@ -213,6 +240,7 @@ export default defineComponent({
213
240
  onRangeFocus,
214
241
  onHidePanel,
215
242
  onRangeClear,
243
+ onCalendarChange,
216
244
  dispatch
217
245
  }
218
246
  }