sh-view 2.8.3 → 2.8.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sh-view",
3
- "version": "2.8.3",
3
+ "version": "2.8.5",
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
  "typings": "types/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "jszip": "^3.10.1",
32
32
  "lunar-typescript": "^1.6.10",
33
33
  "popper.js": "^1.16.1",
34
- "sh-tools": "^2.2.5",
34
+ "sh-tools": "^2.2.6",
35
35
  "tinymce": "^5.10.5",
36
36
  "vue": "^3.3.4",
37
37
  "vue-masonry": "^0.16.0",
@@ -21,10 +21,36 @@
21
21
 
22
22
  <script>
23
23
  import { defineComponent, ref, computed } from 'vue'
24
- import { alertProps } from './alert.ts'
25
24
  export default defineComponent({
26
25
  name: 'ShAlert',
27
- props: alertProps,
26
+ props: {
27
+ type: {
28
+ type: String,
29
+ default: 'info'
30
+ },
31
+ title: {
32
+ type: String
33
+ },
34
+ content: {
35
+ type: String
36
+ },
37
+ closable: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ showIcon: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ fade: {
46
+ type: Boolean,
47
+ default: true
48
+ },
49
+ block: {
50
+ type: Boolean,
51
+ default: false
52
+ }
53
+ },
28
54
  emits: ['close'],
29
55
  setup(props, context) {
30
56
  const { slots, emit } = context
@@ -86,16 +86,6 @@ export default function (props, context, proxy, isForm) {
86
86
  const validate = callback => {
87
87
  return formRef.value.validate(callback)
88
88
  }
89
- // 初始化表单字段
90
- const initFormData = () => {
91
- let initItems = isForm ? props.items : props.items.filter(item => item.search && item.search !== '0')
92
- $vUtils.eachTree(initItems, item => {
93
- let renderProps = item.renderProps || item.itemRender?.props || {}
94
- if (!$vUtils.isNone(renderProps?.defaultValue) && $vUtils.isNone($vUtils.get(props.data, item.field))) {
95
- $vUtils.set(props.data, item.field, renderProps.defaultValue)
96
- }
97
- })
98
- }
99
89
  // 初始化表单项
100
90
  const initFormItems = () => {
101
91
  let rules = getFieldsRules(props.items)
@@ -124,7 +114,6 @@ export default function (props, context, proxy, isForm) {
124
114
  // tag: vxe-form在 item监听时数据length为0时没有刷新视图补充
125
115
  refreshRender()
126
116
  }
127
- initFormData()
128
117
  }
129
118
  // 初始化验证规则
130
119
  const initEditRules = rules => {
@@ -177,15 +166,6 @@ export default function (props, context, proxy, isForm) {
177
166
  initFormItems()
178
167
  }
179
168
  )
180
- watch(
181
- () => props.data,
182
- () => {
183
- initFormData()
184
- },
185
- {
186
- immediate: true
187
- }
188
- )
189
169
  watch(
190
170
  () => props.items,
191
171
  nv => {
@@ -84,7 +84,7 @@ export default defineComponent({
84
84
  const styles = computed(() => {
85
85
  return {
86
86
  color: props.color,
87
- backgroundColor: $vUtils.fade(props.color, 30)
87
+ backgroundColor: $vUtils.fade(props.color, 20)
88
88
  }
89
89
  })
90
90
  const animateStyles = computed(() => {
@@ -164,44 +164,42 @@ export default defineComponent({
164
164
  z-index: 15;
165
165
  padding: 10px 0 10px 15px;
166
166
  box-sizing: border-box;
167
- &.sh-notice-bar-round {
167
+ &-round {
168
168
  border-radius: 6px;
169
169
  }
170
- .sh-notice-icon {
171
- cursor: pointer;
170
+ &-left,
171
+ &-right {
172
+ display: flex;
173
+ align-items: center;
172
174
  }
173
- }
174
- .sh-notice-bar-left,
175
- .sh-notice-bar-right {
176
- display: flex;
177
- align-items: center;
178
- }
179
-
180
- .sh-notice-bar-left {
181
- padding-right: 10px;
182
- }
183
- .sh-notice-bar-right {
184
- padding: 0 10px;
185
- }
186
- .sh-notice-bar-empty {
187
- padding-right: 0;
188
- }
189
-
190
- .sh-notice-bar-content {
191
- flex: 1;
192
- margin: auto;
193
- width: auto;
194
- white-space: nowrap;
195
- overflow: hidden;
196
- &.sh-notice-bar-multi-content {
197
- padding: 0;
198
- line-height: 1.5;
199
- white-space: normal;
175
+ &-left {
176
+ padding-right: 10px;
177
+ }
178
+ &-right {
179
+ padding: 0 10px;
180
+ }
181
+ &-empty {
182
+ padding-right: 0;
183
+ }
184
+ &-content {
185
+ flex: 1;
186
+ margin: auto;
187
+ width: auto;
188
+ white-space: nowrap;
189
+ overflow: hidden;
190
+ &-multi-content {
191
+ padding: 0;
192
+ line-height: 1.5;
193
+ white-space: normal;
194
+ }
195
+ &-animate {
196
+ padding-left: 100%;
197
+ display: inline-block;
198
+ animation: sh-notice-bar-animation linear 30s infinite both;
199
+ }
200
200
  }
201
- .sh-notice-bar-content-animate {
202
- padding-left: 100%;
203
- display: inline-block;
204
- animation: sh-notice-bar-animation linear 30s infinite both;
201
+ .sh-notice-icon {
202
+ cursor: pointer;
205
203
  }
206
204
  }
207
205
  @keyframes sh-notice-bar-animation {
@@ -68,18 +68,19 @@ export const tableFooterCompute = (columns, data, computeType, typeObj = {}) =>
68
68
  export const turnColumnItemFilters = (column, props) => {
69
69
  if (column.filters) return
70
70
  let columnRender = column.cellRender || column.editRender || column.contentRender
71
- let columnProps = Object.assign({}, props)
72
71
  let renderSelects = ['$select', '$vSelect', '$vCheckgroup', '$vRadiogroup', '$vSwitch']
73
- let renderTimes = ['$vTime']
74
- if (renderTimes.includes(columnRender.name)) {
75
- column.filters = [{ data: null }]
76
- column.filterRender = { name: '$vFilterTime', props: columnProps }
72
+ let renderComplexs = ['$vTime', '$vMoney', '$vProgress']
73
+ let defaultProps = { colRender: columnRender }
74
+ if (renderComplexs.includes(columnRender.name)) {
75
+ defaultProps.type = columnRender.name === '$vTime' ? 'date' : 'number'
76
+ column.filters = [{ data: { type: 'has', valueSt: null, valueEd: null }, resetValue: { type: 'has', valueSt: null, valueEd: null } }]
77
+ column.filterRender = { name: '$vFilterComplex', props: Object.assign(defaultProps, props) }
77
78
  } else if (renderSelects.includes(columnRender.name)) {
78
79
  column.filters = Array.isArray(columnRender.props && columnRender.props.options) ? columnRender.props.options : []
79
80
  if (column.filterMultiple === undefined) column.filterMultiple = true
80
81
  } else {
81
82
  column.filters = [{ data: null }]
82
- column.filterRender = { name: '$vFilterInput', props: columnProps }
83
+ column.filterRender = { name: '$vFilterInput', props: Object.assign(defaultProps, props) }
83
84
  }
84
85
  }
85
86
  // 转换表头校验规则
@@ -394,39 +394,6 @@ export default function (props, context, proxy, isGrid) {
394
394
  })
395
395
  }
396
396
  }
397
- // 初始化表头配置默认值
398
- const initColsDefaultValue = () => {
399
- let colsDefaultValue = {}
400
- let colsFormulaValue = {}
401
- $vUtils.eachTree(props.columns, item => {
402
- let columnProps = item.renderProps || item.editRender?.props || item.cellRender?.props || {}
403
- if (!$vUtils.isNone(columnProps.defaultValue)) {
404
- colsDefaultValue[item.field] = columnProps.defaultValue
405
- }
406
- if (!$vUtils.isNone(columnProps.formula)) {
407
- colsFormulaValue[item.field] = columnProps.formula
408
- }
409
- })
410
- tableRowDefaultData.value = colsDefaultValue
411
- if (Array.isArray(props.dataSourse)) {
412
- props.dataSourse.forEach(row => {
413
- if (Object.keys(colsDefaultValue).length > 0) {
414
- Object.keys(colsDefaultValue).forEach(defaultKey => {
415
- if ($vUtils.isNone($vUtils.get(row, defaultKey))) {
416
- $vUtils.set(row, defaultKey, colsDefaultValue[defaultKey])
417
- }
418
- })
419
- }
420
- if (Object.keys(colsFormulaValue).length > 0) {
421
- Object.keys(colsFormulaValue).forEach(formulaKey => {
422
- let formulaValue = $vUtils.calculate(colsFormulaValue[formulaKey], row)
423
- $vUtils.set(row, formulaKey, formulaValue)
424
- })
425
- }
426
- })
427
- }
428
- }
429
-
430
397
  // 全局搜索输入框事件
431
398
  const handleTableFilter = obj => {
432
399
  let filterText = tableFilterText.value
@@ -563,7 +530,6 @@ export default function (props, context, proxy, isGrid) {
563
530
  watch(
564
531
  () => props.dataSourse,
565
532
  value => {
566
- initColsDefaultValue()
567
533
  selectionRows.value = []
568
534
  },
569
535
  {
@@ -9,10 +9,7 @@
9
9
  <div ref="navScrollRef" class="sh-tabs-nav-scroll" @DOMMouseScroll="handleScroll" @mousewheel="handleScroll">
10
10
  <div ref="navRef" v-resize="handleResize" class="sh-tabs-nav-inner" :style="navStyle">
11
11
  <template v-for="(tab, tabIndex) in tabList" :key="tabIndex">
12
- <div
13
- :class="{ 'sh-tab-item': true, 'sh-tab-item-disabled': tab.disabled, 'sh-tab-item-active': tab[labelKey] === activeKey }"
14
- :style="getTabItemStyle(tab, tabIndex)"
15
- @click="handleChange(tab)">
12
+ <div v-ripple v-bind="getTabItemBind(tab, tabIndex)" @click="handleChange(tab)">
16
13
  <slot name="tabItem" v-bind="{ ...tab, isActive: tab[labelKey] === activeKey }">
17
14
  <div v-if="tab.icon" class="sh-tab-icon"><sh-icon :type="tab.icon"></sh-icon></div>
18
15
  <div class="sh-tab-label">{{ tab[labelField] }}</div>
@@ -161,14 +158,21 @@ export default defineComponent({
161
158
  const getTabIsClosable = tab => {
162
159
  return props.closable && !tab.disabled && !tab.unClosed
163
160
  }
164
- const getTabItemStyle = (tab, tabIndex) => {
161
+ const getTabItemBind = (tab, tabIndex) => {
165
162
  let itemStyle = {}
166
163
  if (isHorizontal.value) {
167
164
  itemStyle.marginTop = tabIndex ? `${props.gutter}px` : 0
168
165
  } else {
169
166
  itemStyle.marginLeft = tabIndex ? `${props.gutter}px` : 0
170
167
  }
171
- return itemStyle
168
+ return {
169
+ style: itemStyle,
170
+ class: {
171
+ 'sh-tab-item': true,
172
+ 'sh-tab-item-disabled': tab.disabled,
173
+ 'sh-tab-item-active': tab[props.labelKey] === activeKey.value
174
+ }
175
+ }
172
176
  }
173
177
  const handleResize = e => {
174
178
  const navOffset = isHorizontal.value ? navRef.value.offsetHeight : navRef.value.offsetWidth
@@ -269,7 +273,7 @@ export default defineComponent({
269
273
  handleChange,
270
274
  handleClose,
271
275
  getTabIsClosable,
272
- getTabItemStyle
276
+ getTabItemBind
273
277
  }
274
278
  }
275
279
  })
@@ -198,6 +198,13 @@ button:focus, .vxe-button.type--button:not(.is--disabled):focus{
198
198
  box-sizing: border-box;
199
199
  }
200
200
  &--input{
201
+ display: flex;
202
+ justify-content: space-between;
203
+ align-items: center;
204
+ .vxe-input{
205
+ width: 120px;
206
+ flex: 1;
207
+ }
201
208
  }
202
209
  &--list {
203
210
  margin: 0;
@@ -215,14 +222,16 @@ button:focus, .vxe-button.type--button:not(.is--disabled):focus{
215
222
  display: block;
216
223
  }
217
224
  }
225
+ &--inner{
226
+ }
218
227
  &--top{
219
228
  position: relative;
220
- margin-bottom: 5px;
229
+ margin-bottom: 8px;
221
230
  }
222
231
  &--body{
223
232
  }
224
233
  &--footer{
225
- margin-top: 5px;
234
+ margin-top: 8px;
226
235
  padding: 5px 0 2px;
227
236
  .vxe-button{
228
237
  margin-left: 0;
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <div class="vxe-filter--wrap">
3
+ <div class="vxe-filter--top">
4
+ <vxe-radio-group v-model="renderOption.data.type">
5
+ <template v-for="filterType in filterTypes" :key="filterType.value">
6
+ <vxe-radio-button v-ripple :label="filterType.value" size="mini">{{ filterType.label }}</vxe-radio-button>
7
+ </template>
8
+ </vxe-radio-group>
9
+ </div>
10
+ <div class="vxe-filter--input">
11
+ <vxe-input v-model="renderOption.data.valueSt" v-bind="rprops" :disabled="false" />
12
+ <template v-if="renderOption.data.type === 'ltgt'">
13
+ <span style="margin: 0 8px">至</span>
14
+ <vxe-input v-model="renderOption.data.valueEd" v-bind="rprops" :disabled="false" />
15
+ </template>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ import { defineComponent, getCurrentInstance, reactive, ref } from 'vue'
22
+ import cellProps from '../mixin/cell-props'
23
+ import filterHooks from '../mixin/filter-hooks'
24
+ export default defineComponent({
25
+ name: 'VxeFilterTime',
26
+ props: cellProps,
27
+ setup(props, context) {
28
+ const { proxy } = getCurrentInstance()
29
+ const filterTypes = [
30
+ { value: 'has', label: '包含' },
31
+ { value: 'eq', label: '等于' },
32
+ { value: 'gt', label: '大于' },
33
+ { value: 'lt', label: '小于' },
34
+ { value: 'ltgt', label: '区间' }
35
+ ]
36
+
37
+ const useFilter = filterHooks(props, context, proxy)
38
+
39
+ return {
40
+ ...useFilter,
41
+ filterTypes
42
+ }
43
+ }
44
+ })
45
+ </script>
@@ -29,7 +29,7 @@ import vxeFooterMoney from './footer/vxe-footer-money.vue'
29
29
 
30
30
  // 过滤器组件封装
31
31
  import vxeFilterInput from './filters/vxe-filter-input.vue'
32
- import vxeFilterTime from './filters/vxe-filter-time.vue'
32
+ import vxeFilterComplex from './filters/vxe-filter-complex.vue'
33
33
 
34
34
  // 渲染器通用默认配置
35
35
  let defaultPublicProps = {
@@ -464,8 +464,7 @@ const extraRenders = {
464
464
  const filterRenders = {
465
465
  $vFilterInput: {
466
466
  renderFilter(renderOpts, params) {
467
- let props = getFixedProp(renderOpts, params)
468
- return [<vxeFilterInput rparams={params} rname={renderOpts.name} rprops={props.rprops} rkey={props.rkey} />]
467
+ return [<vxeFilterInput rparams={params} rprops={renderOpts.props} />]
469
468
  },
470
469
  filterResetMethod({ options, column }) {
471
470
  options.forEach(option => {
@@ -479,26 +478,36 @@ const filterRenders = {
479
478
  return String(rtext).toLowerCase().indexOf(data.toLowerCase()) > -1
480
479
  }
481
480
  },
482
- $vFilterTime: {
481
+ $vFilterComplex: {
483
482
  renderFilter(renderOpts, params) {
484
- let props = getFixedProp(renderOpts, params)
485
- return [<vxeFilterTime rparams={params} rname={renderOpts.name} rprops={props.rprops} rkey={props.rkey} />]
483
+ return [<vxeFilterComplex rparams={params} rprops={renderOpts.props} />]
486
484
  },
487
485
  filterResetMethod({ options, column }) {
488
486
  options.forEach(option => {
489
- option.data = option.resetValue || []
487
+ option.data = option.resetValue || {}
490
488
  })
491
489
  },
492
490
  filterMethod({ value, option, cellValue, row, column, $table }) {
493
491
  const { data } = option
494
492
  const { rname, rprops, property } = column
495
- let { rtext } = utils.formatRender(cellValue, property, row, rname, rprops, { $vUtils: utils })
496
- if (rprops.range || rprops.range === undefined) {
497
- let startDiff = utils.getDateDiff(data[0], rtext)
498
- let endDiff = utils.getDateDiff(rtext, data[1])
499
- return startDiff.done && endDiff.done
493
+ const { type, valueSt, valueEd } = data
494
+ let { rvalue, rtext } = utils.formatRender(cellValue, property, row, rname, rprops, { $vUtils: utils })
495
+ let isDate = ['date', 'time', 'datetime', 'week', 'month', 'year'].includes(rprops.type)
496
+ switch (type) {
497
+ case 'has':
498
+ return String(rtext).indexOf(valueSt) > -1
499
+ case 'eq':
500
+ return utils.isEqual(rvalue, valueSt)
501
+ case 'gt':
502
+ return isDate ? utils.getDateDiff(valueSt, rvalue).done : Number(rvalue) > Number(valueSt)
503
+ case 'lt':
504
+ return isDate ? utils.getDateDiff(rvalue, valueSt).done : Number(rvalue) < Number(valueSt)
505
+ case 'ltgt':
506
+ if (isDate) {
507
+ return utils.getDateDiff(valueSt, rvalue).done && utils.getDateDiff(rvalue, valueEd).done
508
+ }
509
+ return Number(rvalue) > Number(valueSt) && Number(rvalue) < Number(valueEd)
500
510
  }
501
- return data === rtext
502
511
  }
503
512
  }
504
513
  }
@@ -1,30 +1,30 @@
1
- import { ShType } from '../../../types/component'
2
-
3
- export const alertProps = {
4
- type: {
5
- type: String as () => ShType,
6
- default: 'info'
7
- },
8
- title: {
9
- type: String
10
- },
11
- content: {
12
- type: String
13
- },
14
- closable: {
15
- type: Boolean,
16
- default: false
17
- },
18
- showIcon: {
19
- type: Boolean,
20
- default: false
21
- },
22
- fade: {
23
- type: Boolean,
24
- default: true
25
- },
26
- block: {
27
- type: Boolean,
28
- default: false
29
- }
30
- }
1
+ import { ShType } from './component'
2
+
3
+ export const alertProps = {
4
+ type: {
5
+ type: String as () => ShType,
6
+ default: 'info'
7
+ },
8
+ title: {
9
+ type: String
10
+ },
11
+ content: {
12
+ type: String
13
+ },
14
+ closable: {
15
+ type: Boolean,
16
+ default: false
17
+ },
18
+ showIcon: {
19
+ type: Boolean,
20
+ default: false
21
+ },
22
+ fade: {
23
+ type: Boolean,
24
+ default: true
25
+ },
26
+ block: {
27
+ type: Boolean,
28
+ default: false
29
+ }
30
+ }
@@ -1 +1 @@
1
- export type ShType = 'info' | 'success' | 'warning' | 'error'
1
+ export type ShType = 'info' | 'success' | 'warning' | 'error'
@@ -1,26 +0,0 @@
1
- <template>
2
- <div class="vxe-filter--wrap">
3
- <span class="vxe-filter--inner">
4
- <sh-date v-model="renderOption.data" v-bind="rprops" :disabled="false" @change="vxeFilterChange" />
5
- </span>
6
- </div>
7
- </template>
8
-
9
- <script>
10
- import { defineComponent, getCurrentInstance, reactive, ref } from 'vue'
11
- import cellProps from '../mixin/cell-props'
12
- import filterHooks from '../mixin/filter-hooks'
13
- export default defineComponent({
14
- name: 'VxeFilterTime',
15
- props: cellProps,
16
- setup(props, context) {
17
- const { proxy } = getCurrentInstance()
18
-
19
- const useFilter = filterHooks(props, context, proxy)
20
-
21
- return {
22
- ...useFilter
23
- }
24
- }
25
- })
26
- </script>