@aochuang/common 1.0.0 → 1.0.1

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 (194) hide show
  1. package/common/loading/index.js +7 -0
  2. package/common/loading/loading.vue +71 -0
  3. package/common/tips/index.js +7 -0
  4. package/common/tips/tips.vue +82 -0
  5. package/common/tooltip/index.js +7 -0
  6. package/common/tooltip/popper.js +18 -0
  7. package/common/tooltip/tooltip.vue +55 -0
  8. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-boolean.vue +33 -0
  9. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-date-range.vue +30 -0
  10. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-date.vue +41 -0
  11. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-datetime-range.vue +34 -0
  12. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-datetime.vue +41 -0
  13. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-number-range.vue +67 -0
  14. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-number.vue +35 -0
  15. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-string.vue +41 -0
  16. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item-value.vue +73 -0
  17. package/components/advanced-filter/advanced-filter-condition-item/advanced-filter-condition-item.vue +226 -0
  18. package/components/advanced-filter/advanced-filter-condition-toggle.vue +112 -0
  19. package/components/advanced-filter/advanced-filter-condition.vue +352 -0
  20. package/components/advanced-filter/advanced-filter-permanent-item.vue +10 -0
  21. package/components/advanced-filter/advanced-filter-permanent.vue +10 -0
  22. package/components/advanced-filter/advanced-filter-scene-form.vue +95 -0
  23. package/components/advanced-filter/advanced-filter-scene-item.vue +64 -0
  24. package/components/advanced-filter/advanced-filter-scene-manage.vue +264 -0
  25. package/components/advanced-filter/advanced-filter-scene-transfer.vue +283 -0
  26. package/components/advanced-filter/advanced-filter-scene.vue +199 -0
  27. package/components/advanced-filter/advanced-filter.vue +114 -0
  28. package/components/advanced-filter/index.js +36 -0
  29. package/components/advanced-filter/utils.js +132 -0
  30. package/components/autocomplete/autocomplete.vue +121 -0
  31. package/components/autocomplete/index.js +7 -0
  32. package/components/avatar/avatar.png +0 -0
  33. package/components/avatar/avatar.vue +212 -0
  34. package/components/avatar/index.js +7 -0
  35. package/components/brick-wall/brick-wall-skeleton.vue +125 -0
  36. package/components/brick-wall/brick-wall.vue +293 -0
  37. package/components/brick-wall/index.js +7 -0
  38. package/components/button/button.vue +537 -0
  39. package/components/button/index.js +7 -0
  40. package/components/button/utils.js +20 -0
  41. package/components/cascader/cascader.vue +184 -0
  42. package/components/cascader/index.js +7 -0
  43. package/components/cascader/util.js +50 -0
  44. package/components/checkbox/checkbox.vue +114 -0
  45. package/components/checkbox/index.js +7 -0
  46. package/components/checkbox-button/index.js +8 -0
  47. package/components/checkbox-group/checkbox-group.vue +11 -0
  48. package/components/checkbox-group/index.js +7 -0
  49. package/components/date-picker/date-picker.vue +300 -0
  50. package/components/date-picker/index.js +7 -0
  51. package/components/dialog/dialog.vue +182 -0
  52. package/components/dialog/index.js +14 -0
  53. package/components/dialog/utils.js +20 -0
  54. package/components/drawer/drawer.vue +186 -0
  55. package/components/drawer/index.js +14 -0
  56. package/components/drawer/utils.js +36 -0
  57. package/components/dropdown/dropdown-item.vue +63 -0
  58. package/components/dropdown/dropdown.vue +286 -0
  59. package/components/dropdown/index.js +16 -0
  60. package/components/empty/empty.vue +62 -0
  61. package/components/empty/index.js +7 -0
  62. package/components/filter/filter-group.vue +44 -0
  63. package/components/filter/filter-item.vue +122 -0
  64. package/components/filter/filter-more.vue +114 -0
  65. package/components/filter/filter.vue +407 -0
  66. package/components/filter/index.js +20 -0
  67. package/components/filter/refresh-line.svg +1 -0
  68. package/components/filter/util.js +5 -0
  69. package/components/form/form-cell.vue +231 -0
  70. package/components/form/form-group.vue +147 -0
  71. package/components/form/form-row.vue +51 -0
  72. package/components/form/form.vue +256 -0
  73. package/components/form/index.js +13 -0
  74. package/components/grid/grid-card-view/grid-card-view.vue +157 -0
  75. package/components/grid/grid-column.vue +136 -0
  76. package/components/grid/grid-filter/grid-filter-group.vue +41 -0
  77. package/components/grid/grid-filter/grid-filter-item.vue +68 -0
  78. package/components/grid/grid-filter/grid-filter.vue +115 -0
  79. package/components/grid/grid-filter/util.js +7 -0
  80. package/components/grid/grid-filter-operate/grid-filter-operate-item.vue +55 -0
  81. package/components/grid/grid-filter-operate/grid-filter-operate.vue +46 -0
  82. package/components/grid/grid-sort/grid-sort-proxy.js +27 -0
  83. package/components/grid/grid-sort/grid-sort.vue +205 -0
  84. package/components/grid/grid-sort/icons/asc.png +0 -0
  85. package/components/grid/grid-sort/icons/desc.png +0 -0
  86. package/components/grid/grid-sort/index.js +7 -0
  87. package/components/grid/grid-table-view/grid-table-view.vue +178 -0
  88. package/components/grid/grid-table.vue +547 -0
  89. package/components/grid/grid-toolbar/grid-batch-toolbar-proxy.js +21 -0
  90. package/components/grid/grid-toolbar/grid-batch-toolbar.vue +129 -0
  91. package/components/grid/grid-toolbar/grid-global-toolbar-proxy.js +21 -0
  92. package/components/grid/grid-toolbar/grid-global-toolbar.vue +37 -0
  93. package/components/grid/grid-toolbar/grid-more-toolbar-proxy.js +21 -0
  94. package/components/grid/grid-toolbar/grid-more-toolbar.vue +138 -0
  95. package/components/grid/grid-toolbar/grid-row-toolbar.vue +279 -0
  96. package/components/grid/grid-view-select.vue +78 -0
  97. package/components/grid/grid.vue +1102 -0
  98. package/components/grid/icons/more-line.svg +1 -0
  99. package/components/grid/icons/refresh.svg +14 -0
  100. package/components/grid/index.js +61 -0
  101. package/components/grid/util.js +31 -0
  102. package/components/icon/demo.css +539 -0
  103. package/components/icon/demo_index.html +7433 -0
  104. package/components/icon/icon.vue +96 -0
  105. package/components/icon/iconfont.css +1275 -0
  106. package/components/icon/iconfont.eot +0 -0
  107. package/components/icon/iconfont.js +1 -0
  108. package/components/icon/iconfont.json +2214 -0
  109. package/components/icon/iconfont.svg +455 -0
  110. package/components/icon/iconfont.ttf +0 -0
  111. package/components/icon/iconfont.woff +0 -0
  112. package/components/icon/iconfont.woff2 +0 -0
  113. package/components/icon/index.js +7 -0
  114. package/components/image/image.vue +299 -0
  115. package/components/image/index.js +12 -0
  116. package/components/image/util.js +26 -0
  117. package/components/index.js +153 -0
  118. package/components/loading/index.js +7 -0
  119. package/components/loading/loading.vue +130 -0
  120. package/components/menu/index.js +14 -0
  121. package/components/menu/menu-group.vue +240 -0
  122. package/components/menu/menu-item.vue +215 -0
  123. package/components/menu/menu.vue +64 -0
  124. package/components/message/index.js +19 -0
  125. package/components/message/message.js +28 -0
  126. package/components/message/message.less +6 -0
  127. package/components/message-box/index.js +10 -0
  128. package/components/message-box/message-box.js +140 -0
  129. package/components/message-box/message-box.less +5 -0
  130. package/components/pagination/index.js +7 -0
  131. package/components/pagination/pagination.vue +193 -0
  132. package/components/panel/index.js +7 -0
  133. package/components/panel/panel.vue +44 -0
  134. package/components/popover/index.js +7 -0
  135. package/components/popover/popover.vue +140 -0
  136. package/components/popup-select/index.js +7 -0
  137. package/components/popup-select/popup-select.vue +114 -0
  138. package/components/radio/index.js +7 -0
  139. package/components/radio/radio.vue +92 -0
  140. package/components/radio-button/index.js +7 -0
  141. package/components/radio-button/radio-button.vue +20 -0
  142. package/components/radio-group/index.js +7 -0
  143. package/components/radio-group/radio-group.vue +22 -0
  144. package/components/searchbox/index.js +7 -0
  145. package/components/searchbox/searchbox.vue +260 -0
  146. package/components/select/index.js +9 -0
  147. package/components/select/select-load-more.vue +53 -0
  148. package/components/select/select.vue +572 -0
  149. package/components/skeleton/index.js +14 -0
  150. package/components/skeleton/skeleton-rows.vue +52 -0
  151. package/components/skeleton/skeleton.vue +72 -0
  152. package/components/sortable/index.js +9 -0
  153. package/components/sortable/sortable-item.vue +77 -0
  154. package/components/sortable/sortable.vue +62 -0
  155. package/components/spinner/index.js +7 -0
  156. package/components/spinner/spinner.vue +121 -0
  157. package/components/spinner-range/index.js +7 -0
  158. package/components/spinner-range/spinner-range.vue +97 -0
  159. package/components/spinner-textarea/index.js +7 -0
  160. package/components/spinner-textarea/spinner-textarea.vue +65 -0
  161. package/components/switch/index.js +7 -0
  162. package/components/switch/switch.vue +105 -0
  163. package/components/tabs/index.js +10 -0
  164. package/components/tabs/tabs.vue +115 -0
  165. package/components/tag/index.js +9 -0
  166. package/components/tag/tag.less +30 -0
  167. package/components/text/index.js +7 -0
  168. package/components/text/text.vue +69 -0
  169. package/components/textarea/index.js +7 -0
  170. package/components/textarea/textarea.vue +229 -0
  171. package/components/textbox/index.js +7 -0
  172. package/components/textbox/textbox.vue +275 -0
  173. package/components/time-picker/index.js +7 -0
  174. package/components/time-picker/time-picker.vue +77 -0
  175. package/components/toolbar/index.js +14 -0
  176. package/components/toolbar/toolbar-item.vue +43 -0
  177. package/components/toolbar/toolbar.vue +81 -0
  178. package/components/tooltip/index.js +9 -0
  179. package/components/tooltip/tooltip.vue +86 -0
  180. package/components/transfer/index.js +7 -0
  181. package/components/transfer/transfer-load-more.vue +53 -0
  182. package/components/transfer/transfer.vue +245 -0
  183. package/components/tree/index.js +7 -0
  184. package/components/tree/tree.vue +326 -0
  185. package/components/tree/utils.js +122 -0
  186. package/components/video/index.js +7 -0
  187. package/components/video/video.vue +53 -0
  188. package/package.json +4 -1
  189. package/utils/date.js +55 -0
  190. package/utils/emitter.js +3 -0
  191. package/utils/json.js +19 -0
  192. package/utils/resize-event.js +35 -0
  193. package/utils/util.js +12 -0
  194. package/utils/utils.js +0 -0
@@ -0,0 +1,184 @@
1
+ <template>
2
+ <el-cascader
3
+ ref="control"
4
+ class="ui-cascader"
5
+ v-model="innerValue"
6
+ :options="options"
7
+ :disabled="disabled"
8
+ :show-all-levels="showAllLevels"
9
+ :collapse-tags="collapseTags"
10
+ :clearable="clearable"
11
+ :props="props"
12
+ :placeholder="placeholder"
13
+ size="small"
14
+ >
15
+ </el-cascader>
16
+ </template>
17
+
18
+ <script>
19
+ import ElCascader from 'element-ui/lib/cascader'
20
+ import 'element-ui/lib/theme-chalk/cascader.css'
21
+ import { getClosestNodes, removeEmptyChildren } from './util'
22
+ import { clone } from '../../utils/json'
23
+
24
+ export default {
25
+ name: 'UiCascader',
26
+ components: {
27
+ ElCascader
28
+ },
29
+ props: {
30
+ textField: {
31
+ type: String,
32
+ default: 'label'
33
+ },
34
+ valueField: {
35
+ type: String,
36
+ default: 'id'
37
+ },
38
+ checkStrictly: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ collapseTags: {
43
+ type: Boolean
44
+ },
45
+ placeholder: {
46
+ type: String,
47
+ default: '请选择'
48
+ },
49
+ // 保持完整路径
50
+ keepPath: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ multiple: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ disabled: {
59
+ type: Boolean,
60
+ default: false
61
+ },
62
+ items: {
63
+ type: Array,
64
+ default: () => []
65
+ },
66
+ value: {
67
+ type: [String, Number, Array]
68
+ },
69
+ queryMethod: {
70
+ type: Function
71
+ },
72
+ showAllLevels: {
73
+ type: Boolean,
74
+ default: true
75
+ },
76
+ clearable: {
77
+ type: Boolean,
78
+ default: true
79
+ }
80
+ },
81
+ data () {
82
+ return {
83
+ loading: false,
84
+ options: []
85
+ }
86
+ },
87
+ computed: {
88
+ innerValue: {
89
+ get () {
90
+ if (this.keepPath) {
91
+ return this.value
92
+ }
93
+ if (Array.isArray(this.value)) {
94
+ return this.value.map(v => getClosestNodes(v, this.options, this.valueField).map(v => v[this.valueField]))
95
+ } else {
96
+ return getClosestNodes(this.value, this.options, this.valueField).map(v => v[this.valueField])
97
+ }
98
+ },
99
+ set (val) {
100
+ if (this.keepPath) {
101
+ this.$emit('input', val)
102
+ } else {
103
+ if (val && Array.isArray(val)) {
104
+ if (this.multiple) {
105
+ val = val.map(v => v[v.length - 1])
106
+ } else {
107
+ val = val[val.length - 1]
108
+ }
109
+ }
110
+ this.$emit('input', val || null)
111
+ this.$emit('change', {
112
+ items: getClosestNodes(val, this.options, this.valueField)
113
+ })
114
+ }
115
+ }
116
+ },
117
+ props () {
118
+ return {
119
+ checkStrictly: this.checkStrictly,
120
+ multiple: this.multiple,
121
+ value: this.valueField,
122
+ label: this.textField
123
+ }
124
+ }
125
+ },
126
+ watch: {
127
+ items () {
128
+ this.syncItems()
129
+ }
130
+ },
131
+ mounted () {
132
+ this.syncItems()
133
+ this.loadOptions()
134
+ },
135
+ methods: {
136
+ loadOptions () {
137
+ if (!this.queryMethod) {
138
+ return
139
+ }
140
+ this.loading = true
141
+ this.queryMethod().then(rs => {
142
+ this.options = removeEmptyChildren(rs) || []
143
+ }).finally(() => {
144
+ this.loading = false
145
+ })
146
+ },
147
+ syncItems () {
148
+ this.options = removeEmptyChildren(clone(this.items)) || []
149
+ }
150
+ }
151
+ }
152
+ </script>
153
+ <style lang="less">
154
+ .ui-cascader{
155
+ width: 100%;
156
+ box-sizing: border-box;
157
+ .el-input__inner{
158
+ font-size: 14px;
159
+ padding-left: 11px;
160
+ transition: all 0.15s ease-in-out;
161
+ box-sizing: border-box;
162
+ }
163
+ .is-focus{
164
+ .el-input__inner{
165
+ border-color: #1aa2e8;
166
+ box-shadow: 0 0 0 0.2rem rgba(26, 162, 232,.25);
167
+ }
168
+ }
169
+ }
170
+ .el-cascader-panel{
171
+ .el-scrollbar__wrap{
172
+ min-height: 240px;
173
+ max-height: 360px;
174
+ }
175
+ }
176
+ body {
177
+ .el-cascader-node.in-active-path,
178
+ .el-cascader-node.is-active,
179
+ .el-cascader-node.is-selectable.in-checked-path{
180
+ font-weight: normal;
181
+ }
182
+ }
183
+
184
+ </style>
@@ -0,0 +1,7 @@
1
+ import Cascader from './cascader.vue'
2
+
3
+ Cascader.install = (Vue) => {
4
+ Vue.component(Cascader.name, Cascader)
5
+ }
6
+
7
+ export default Cascader
@@ -0,0 +1,50 @@
1
+ export function getClosestNodes (value, data, valueField) {
2
+ const result = []
3
+ if (value === null || value === '' || value === undefined) {
4
+ return result
5
+ }
6
+ if (!data) {
7
+ return value
8
+ }
9
+ const loop = (data) => {
10
+ let rs = null
11
+ if (!data || !data.length) {
12
+ return rs
13
+ }
14
+ data.some(v => {
15
+ if (v[valueField] === value) {
16
+ rs = true
17
+ result.push(v)
18
+ return rs
19
+ }
20
+ if (v.children) {
21
+ if (loop(v.children)) {
22
+ result.push(v)
23
+ rs = v
24
+ }
25
+ }
26
+ })
27
+ return rs
28
+ }
29
+ loop(data)
30
+ return result.reverse()
31
+ }
32
+
33
+ export function removeEmptyChildren (options) {
34
+ if (!options || !options.length) {
35
+ return []
36
+ }
37
+ const loop = (data) => {
38
+ if (!data || !data.length) {
39
+ return
40
+ }
41
+ data.forEach(v => {
42
+ if (v.children && !v.children.length) {
43
+ delete v.children
44
+ }
45
+ loop(v.children)
46
+ })
47
+ }
48
+ loop(options)
49
+ return options
50
+ }
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <el-checkbox :border="border" class="ui-checkbox" :indeterminate="indeterminate" :disabled="disabled" v-model="inputValue" :label="label">
3
+ <slot></slot>
4
+ </el-checkbox>
5
+ </template>
6
+ <script>
7
+ import ElCheckbox from 'element-ui/lib/checkbox'
8
+ import 'element-ui/lib/theme-chalk/checkbox.css'
9
+
10
+ export default {
11
+ name: 'UiCheckbox',
12
+ components: {
13
+ ElCheckbox
14
+ },
15
+ props: {
16
+ value: {
17
+ type: Boolean
18
+ },
19
+ border: {
20
+ type: Boolean
21
+ },
22
+ indeterminate: {
23
+ type: Boolean
24
+ },
25
+ disabled: {
26
+ type: Boolean
27
+ },
28
+ label: {
29
+ type: [String, Number]
30
+ }
31
+ },
32
+ computed: {
33
+ inputValue: {
34
+ get () {
35
+ return this.value || false
36
+ },
37
+ set (val) {
38
+ this.$emit('input', val)
39
+ }
40
+ }
41
+ }
42
+ }
43
+ </script>
44
+ <style lang="less">
45
+ body {
46
+ .ui-checkbox-group{
47
+ .el-checkbox{
48
+ &:not(.is-bordered) {
49
+ margin-right: 20px;
50
+ }
51
+ }
52
+ }
53
+ .ui-checkbox.el-checkbox{
54
+ font-size: 14px;
55
+ max-width: 100%;
56
+ .el-checkbox__label{
57
+ font-size: inherit;
58
+ max-width: calc(~'100% - 0px');
59
+ white-space: nowrap;
60
+ overflow: hidden;
61
+ text-overflow: ellipsis;
62
+ }
63
+ .el-checkbox__inner{
64
+ vertical-align: top;
65
+ }
66
+ &:not(.is-bordered) {
67
+ height: 20px;
68
+ line-height: 20px;
69
+ .el-checkbox__input{
70
+ vertical-align: top;
71
+ margin-top: 2px;
72
+ }
73
+ .el-checkbox__label{
74
+ padding-left: 6px;
75
+ }
76
+ }
77
+ &.is-bordered {
78
+ margin-right: 0;
79
+ background-color: #fff;
80
+ padding-top: 6px;
81
+ padding-bottom: 6px;
82
+ line-height: 18px;
83
+ height: 32px;
84
+ padding-right: 12px;
85
+ transition: all .25s;
86
+ .el-checkbox__input,
87
+ .el-checkbox__label{
88
+ vertical-align: top;
89
+ }
90
+ .el-checkbox__input{
91
+ margin-top: 1px;
92
+ }
93
+ .el-checkbox__label{
94
+ padding-left: 6px;
95
+ }
96
+ &:hover {
97
+ color: #1aa2e8;
98
+ border-color: #1aa2e8;
99
+ background-color: transparent;
100
+ }
101
+ }
102
+ }
103
+ .ui-checkbox .el-checkbox__inner{
104
+ width: 16px;
105
+ height: 16px;
106
+ border-width: 2px;
107
+ font-weight: bold;
108
+ box-sizing: border-box;
109
+ }
110
+ .ui-checkbox .el-checkbox__input.is-checked+.el-checkbox__label{
111
+ color: #404040;
112
+ }
113
+ }
114
+ </style>
@@ -0,0 +1,7 @@
1
+ import Checkbox from './checkbox.vue'
2
+
3
+ Checkbox.install = (Vue) => {
4
+ Vue.component(Checkbox.name, Checkbox)
5
+ }
6
+
7
+ export default Checkbox
@@ -0,0 +1,8 @@
1
+ import CheckboxButton from 'element-ui/lib/checkbox-button'
2
+ import 'element-ui/lib/theme-chalk/checkbox-button.css'
3
+
4
+ CheckboxButton.install = (Vue) => {
5
+ Vue.component('UiCheckboxButton', CheckboxButton)
6
+ }
7
+
8
+ export default CheckboxButton
@@ -0,0 +1,11 @@
1
+ <script>
2
+ import CheckboxGroup from 'element-ui/lib/checkbox-group'
3
+ import 'element-ui/lib/theme-chalk/checkbox-group.css'
4
+
5
+ export default {
6
+ ...CheckboxGroup,
7
+ name: 'UiCheckboxGroup'
8
+ }
9
+ </script>
10
+ <style lang="less">
11
+ </style>
@@ -0,0 +1,7 @@
1
+ import CheckboxGroup from './checkbox-group'
2
+
3
+ CheckboxGroup.install = (Vue) => {
4
+ Vue.component(CheckboxGroup.name, CheckboxGroup)
5
+ }
6
+
7
+ export default CheckboxGroup
@@ -0,0 +1,300 @@
1
+ <template>
2
+ <div class="ui-date-picker" :class="{'is-readonly': isReadonly, 'is-clearable' : clearable}" @click="handlePickerClick">
3
+ <el-date-picker
4
+ ref="datePicker"
5
+ v-model="innerValue"
6
+ class="ui-date-picker__input"
7
+ range-separator="~"
8
+ :type="type"
9
+ :size="size"
10
+ :clearable="clearable"
11
+ :disabled="disabled"
12
+ :placeholder="placeholder"
13
+ :start-placeholder="startPlaceholder"
14
+ :end-placeholder="endPlaceholder"
15
+ :picker-options="pickerOptions"
16
+ :format="innerFormat"
17
+ :value-format="innerValueFormat"
18
+ :readonly="isReadonly"
19
+ @input="handleDateChange"
20
+ />
21
+ <div v-if="isReadonly" class="ui-date-picker__default">
22
+ <slot>
23
+ <span v-if="!showText" class="ui-date-picker__placeholder">{{ placeholder }}</span>
24
+ <span v-else class="ui-date-picker__value">{{ showText }}</span>
25
+ </slot>
26
+ </div>
27
+ </div>
28
+ </template>
29
+ <script>
30
+ import DatePicker from 'element-ui/lib/date-picker'
31
+ import 'element-ui/lib/theme-chalk/date-picker.css'
32
+ import 'element-ui/lib/theme-chalk/icon.css'
33
+ import { parseDate, formatDate } from '../../utils/date'
34
+
35
+ export default {
36
+ name: 'UiDatePicker',
37
+ components: {
38
+ ElDatePicker: DatePicker
39
+ },
40
+ inject: {
41
+ UiFilter: {
42
+ default: null
43
+ }
44
+ },
45
+ props: {
46
+ value: {
47
+ type: [String, Array, Number]
48
+ },
49
+ inputable: {
50
+ type: Boolean,
51
+ default: true
52
+ },
53
+ format: {
54
+ type: String
55
+ },
56
+ valueFormat: {
57
+ type: String
58
+ },
59
+ type: {
60
+ type: String
61
+ },
62
+ clearable: {
63
+ type: Boolean,
64
+ default: true
65
+ },
66
+ placeholder: {
67
+ type: String
68
+ },
69
+ maxDate: {
70
+ type: [String, Number, Date]
71
+ },
72
+ minDate: {
73
+ type: [String, Number, Date]
74
+ },
75
+ shortcuts: {
76
+ type: Array,
77
+ default: () => []
78
+ },
79
+ size: {
80
+ type: String,
81
+ default: 'small'
82
+ },
83
+ disabled: {
84
+ type: Boolean,
85
+ default: false
86
+ },
87
+ // 如果在uifilter里面使用的时候,是否需要补全时分秒为00:00:00 23:59:59,因为有些场景不需要,所以需要这个配置
88
+ completion: {
89
+ type: Boolean,
90
+ default: true
91
+ },
92
+ startPlaceholder: {
93
+ type: String,
94
+ default: '开始日期'
95
+ },
96
+ endPlaceholder: {
97
+ type: String,
98
+ default: '结束日期'
99
+ },
100
+ onPick: {
101
+ type: Function,
102
+ default: () => {}
103
+ }
104
+ },
105
+ data () {
106
+ return {
107
+ showText: null
108
+ }
109
+ },
110
+ computed: {
111
+ innerValueFormat () {
112
+ if (this.valueFormat) {
113
+ return this.valueFormat
114
+ }
115
+ if (this.type === 'datetime') {
116
+ return 'yyyy-MM-dd HH:mm:ss'
117
+ }
118
+ return 'yyyy-MM-dd'
119
+ },
120
+ innerFormat () {
121
+ if (this.format) {
122
+ return this.format
123
+ }
124
+ if (this.type === 'datetime') {
125
+ return 'yyyy-MM-dd HH:mm:ss'
126
+ }
127
+ return 'yyyy-MM-dd'
128
+ },
129
+ isReadonly () {
130
+ return !this.inputable
131
+ },
132
+ disabledDate () {
133
+ return (date) => {
134
+ let rs = false
135
+ if (this.innerMinDate && date < this.innerMinDate) {
136
+ rs = true
137
+ }
138
+ if (this.innerMaxDate && date > this.innerMaxDate) {
139
+ rs = true
140
+ }
141
+ return rs
142
+ }
143
+ },
144
+ innerMaxDate () {
145
+ if (this.maxDate) {
146
+ return parseDate(this.maxDate)
147
+ }
148
+ return null
149
+ },
150
+ innerMinDate () {
151
+ if (this.minDate) {
152
+ return parseDate(this.minDate)
153
+ }
154
+ return null
155
+ },
156
+ pickerOptions () {
157
+ return {
158
+ onPick: this.onPick,
159
+ disabledDate: this.disabledDate,
160
+ shortcuts: this.shortcuts.length ? this.shortcuts : null
161
+ }
162
+ },
163
+ innerValue: {
164
+ get () {
165
+ if (typeof this.value === 'number') {
166
+ return new Date(this.value)
167
+ } else if (typeof this.value === 'string') {
168
+ if (this.type === 'daterange' || this.type === 'datetimerange') {
169
+ return this.value.split('~').map(v => parseDate(v))
170
+ } else {
171
+ return this.value
172
+ }
173
+ }
174
+ return this.value
175
+ },
176
+ set (val) {
177
+ if (this.UiFilter) {
178
+ if (this.type === 'daterange') {
179
+ if (val && val.length) {
180
+ if (this.completion) {
181
+ this.$emit('input', [
182
+ formatDate(val[0], 'YYYY-mm-dd 00:00:00'),
183
+ formatDate(val[1], 'YYYY-mm-dd 23:59:59')
184
+ ])
185
+ } else {
186
+ this.$emit('input', val)
187
+ }
188
+ } else {
189
+ this.$emit('input', null)
190
+ }
191
+ }
192
+ } else {
193
+ this.$emit('input', val)
194
+ }
195
+ }
196
+ }
197
+ },
198
+ watch: {
199
+ innerValue () {
200
+ this.updateShowText()
201
+ }
202
+ },
203
+ created () {
204
+ this.updateShowText()
205
+ },
206
+ methods: {
207
+ updateShowText () {
208
+ this.$nextTick(() => {
209
+ let val
210
+ if (this.type === 'daterange' || this.type === 'datetimerange') {
211
+ if (this.$refs.datePicker.displayValue) {
212
+ val = this.$refs.datePicker.displayValue.join(' ~ ')
213
+ } else if (this.innerValue) {
214
+ val = this.innerValue.join(' ~ ')
215
+ }
216
+ } else {
217
+ val = this.$refs.datePicker.displayValue
218
+ }
219
+ this.showText = val || ''
220
+ })
221
+ },
222
+ handlePickerClick () {
223
+ if (this.inputable) {
224
+ return
225
+ }
226
+ if (!this.visible) {
227
+ this.showPicker()
228
+ } else {
229
+ this.hidePicker()
230
+ }
231
+ },
232
+ handleDateChange () {
233
+ this.$nextTick(() => {
234
+ this.visible = this.$refs.datePicker.pickerVisible
235
+ })
236
+ },
237
+ showPicker () {
238
+ this.visible = true
239
+ this.$refs.datePicker && this.$refs.datePicker.showPicker()
240
+ },
241
+ hidePicker () {
242
+ this.visible = false
243
+ this.$refs.datePicker && this.$refs.datePicker.hidePicker()
244
+ }
245
+ }
246
+ }
247
+ </script>
248
+ <style lang="less">
249
+ .ui-date-picker{
250
+ display: block;
251
+ .el-input__inner{
252
+ box-sizing: border-box;
253
+ }
254
+ .el-date-editor.ui-date-picker__input{
255
+ width: 100%;
256
+ .el-input__inner{
257
+ padding-right: 3px;
258
+ &:focus{
259
+ border-color: #1aa2e8;
260
+ box-shadow: 0 0 0 0.2rem rgba(26, 162, 232,.25);
261
+ }
262
+ }
263
+ .el-range__close-icon{
264
+ width: 18px;
265
+ display: none;
266
+ }
267
+ }
268
+ &.is-clearable{
269
+ .el-date-editor{
270
+ .el-range__close-icon{
271
+ display: inline-block;
272
+ }
273
+ }
274
+ }
275
+ &.is-readonly {
276
+ position: relative;
277
+ .ui-date-picker__default{
278
+ z-index: 3;
279
+ display: block;
280
+ position: relative;
281
+ }
282
+ .el-date-editor{
283
+ position: absolute;
284
+ opacity: 0;
285
+ left: 0;
286
+ right: 0;
287
+ top: 0;
288
+ bottom: 0;
289
+ overflow: hidden;
290
+ }
291
+ }
292
+ .ui-date-picker__default{
293
+ line-height: 32px;
294
+ display: block;
295
+ }
296
+ .ui-date-picker__placeholder{
297
+ color: #bababa;
298
+ }
299
+ }
300
+ </style>
@@ -0,0 +1,7 @@
1
+ import DatePicker from './date-picker.vue'
2
+
3
+ DatePicker.install = (Vue) => {
4
+ Vue.component(DatePicker.name, DatePicker)
5
+ }
6
+
7
+ export default DatePicker