sh-view 2.5.7 → 2.5.9
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 +2 -3
- package/packages/components/global-components/sh-form/js/useForm.js +7 -7
- package/packages/components/global-components/sh-table/components/sh-column.vue +4 -0
- package/packages/components/global-components/sh-table/js/props.js +1 -0
- package/packages/components/global-components/sh-table/js/tableMethods.js +1 -1
- package/packages/components/global-components/sh-table/js/useTable.js +8 -6
- package/packages/components/global-components/sh-table/table.vue +9 -4
- package/packages/components/global-components/sh-toolbar/index.vue +0 -1
- package/packages/components/global-components/sh-water-mark/index.vue +96 -0
- package/packages/components/index.js +2 -0
- package/packages/directive/module/resize.js +2 -5
- package/packages/utils/resize.js +70 -0
- package/packages/vxeTable/render/globalRenders.jsx +2 -5
- package/packages/vxeTable/render/mixin/cell-hooks.js +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sh-view",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.9",
|
|
4
4
|
"description": "基于vxe-table二次封装",
|
|
5
5
|
"main": "packages/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"jspdf": "^2.5.1",
|
|
29
29
|
"jszip": "^3.10.1",
|
|
30
30
|
"popper.js": "^1.16.1",
|
|
31
|
-
"
|
|
32
|
-
"sh-tools": "^2.1.5",
|
|
31
|
+
"sh-tools": "^2.1.6",
|
|
33
32
|
"tinymce": "^5.10.5",
|
|
34
33
|
"vue": "^3.3.4",
|
|
35
34
|
"vue-masonry": "^0.16.0",
|
|
@@ -62,9 +62,9 @@ export default function (props, context, proxy, isForm) {
|
|
|
62
62
|
emit('reset', params)
|
|
63
63
|
}
|
|
64
64
|
// 表单项编辑回调
|
|
65
|
-
const onFormEditClosed = async
|
|
66
|
-
emit('edit-closed',
|
|
67
|
-
Object.assign(props.data,
|
|
65
|
+
const onFormEditClosed = async params => {
|
|
66
|
+
emit('edit-closed', params)
|
|
67
|
+
Object.assign(props.data, params.data)
|
|
68
68
|
}
|
|
69
69
|
// 表单校验不通过
|
|
70
70
|
const onFormSubmitInvalid = params => {
|
|
@@ -75,12 +75,12 @@ export default function (props, context, proxy, isForm) {
|
|
|
75
75
|
emit('collapse', params)
|
|
76
76
|
}
|
|
77
77
|
// 前缀点击事件
|
|
78
|
-
const onPrefixClick =
|
|
79
|
-
emit('prefix-click', params
|
|
78
|
+
const onPrefixClick = params => {
|
|
79
|
+
emit('prefix-click', params)
|
|
80
80
|
}
|
|
81
81
|
// 后缀点击事件
|
|
82
|
-
const onSuffixClick =
|
|
83
|
-
emit('suffix-click', params
|
|
82
|
+
const onSuffixClick = params => {
|
|
83
|
+
emit('suffix-click', params)
|
|
84
84
|
}
|
|
85
85
|
// 表单验证方法
|
|
86
86
|
const validate = callback => {
|
|
@@ -24,6 +24,10 @@ export default defineComponent({
|
|
|
24
24
|
} else {
|
|
25
25
|
config.editRender = config.editRender || renderObj
|
|
26
26
|
}
|
|
27
|
+
if (config.renderName === '$vMoney' && props.column.renderProps.bill) {
|
|
28
|
+
config.filter = false
|
|
29
|
+
config.headerClassName += ' header-bill-cell'
|
|
30
|
+
}
|
|
27
31
|
if (config.filter === true || Number(config.filter) === 1) {
|
|
28
32
|
shTable.turnColumnItemFilters(config, renderObj.props)
|
|
29
33
|
}
|
|
@@ -138,7 +138,7 @@ export const getTransfarFields = (oriArr = [], columnObj, isSearch) => {
|
|
|
138
138
|
}
|
|
139
139
|
if (tar.renderName === '$vMoney' && renderConfig.props.bill) {
|
|
140
140
|
tar.filter = false
|
|
141
|
-
tar.headerClassName
|
|
141
|
+
tar.headerClassName += ' header-bill-cell'
|
|
142
142
|
}
|
|
143
143
|
// 初始化排序条件
|
|
144
144
|
if (Number(tar.sortable) === 0 || tar.sortable === 'false') {
|
|
@@ -153,7 +153,8 @@ export default function (props, context, proxy, isGrid) {
|
|
|
153
153
|
}
|
|
154
154
|
// 获取全部数据
|
|
155
155
|
// visible为true获取视图数据
|
|
156
|
-
const getFullData =
|
|
156
|
+
const getFullData = params => {
|
|
157
|
+
const { visible = false, deleteXid = false } = params || {}
|
|
157
158
|
let data = $vUtils.clone(tableRef.value.getTableData().fullData, true)
|
|
158
159
|
const columns = tableRef.value.getColumns()
|
|
159
160
|
let rnameColumns = columns.filter(col => col.rname)
|
|
@@ -165,6 +166,7 @@ export default function (props, context, proxy, isGrid) {
|
|
|
165
166
|
let { rvalue, rtext } = $vUtils.formatRender(cellValue, property, row, rname, rprops, proxy)
|
|
166
167
|
$vUtils.set(row, property, visible || ['$vMoney'].includes(rname) ? rtext : rvalue)
|
|
167
168
|
}
|
|
169
|
+
if (deleteXid) delete row._XID
|
|
168
170
|
})
|
|
169
171
|
})
|
|
170
172
|
return data
|
|
@@ -395,11 +397,11 @@ export default function (props, context, proxy, isGrid) {
|
|
|
395
397
|
searchFields.push({ rkey: col.property, rname: renderObj.name, rprops: Object.assign({}, renderObj.props, col.rprops) })
|
|
396
398
|
}
|
|
397
399
|
})
|
|
398
|
-
|
|
399
|
-
filterData = $vUtils.searchTree(fullVisibleData, row => {
|
|
400
|
+
filterData = $vUtils.searchTree(props.dataSourse, row => {
|
|
400
401
|
return searchFields.some(item => {
|
|
401
402
|
let cellValue = $vUtils.get(row, item.rkey)
|
|
402
|
-
|
|
403
|
+
let { rtext } = $vUtils.formatRender(cellValue, item.rkey, row, item.rname, item.rprops, proxy)
|
|
404
|
+
return $vUtils.trim(rtext).toLowerCase().indexOf(filterText) > -1
|
|
403
405
|
})
|
|
404
406
|
})
|
|
405
407
|
}
|
|
@@ -479,7 +481,7 @@ export default function (props, context, proxy, isGrid) {
|
|
|
479
481
|
}
|
|
480
482
|
let { row: newRow } = await tableRef.value.insertAt(addRows, index)
|
|
481
483
|
await tableRef.value.setActiveRow(newRow)
|
|
482
|
-
if (
|
|
484
|
+
if (isTool) emit('toolbaroption', 'add', newRow, tableRef.value)
|
|
483
485
|
}
|
|
484
486
|
// 删除行按钮
|
|
485
487
|
const handleTableDeleteRow = async (rows, isTool = false) => {
|
|
@@ -501,7 +503,7 @@ export default function (props, context, proxy, isGrid) {
|
|
|
501
503
|
let keyField = props.rowConfig.keyField || proxy.$vTableSetup.table.rowConfig.keyField
|
|
502
504
|
selectionRows.value = selectionRows.value.filter(sr => !deleteRows.find(dr => dr[keyField] === sr[keyField]))
|
|
503
505
|
}
|
|
504
|
-
if (
|
|
506
|
+
if (isTool) emit('toolbaroption', 'delete', deleteRows, tableRef.value)
|
|
505
507
|
}
|
|
506
508
|
|
|
507
509
|
watch(
|
|
@@ -116,11 +116,16 @@
|
|
|
116
116
|
@toolbar-button-click="onToolbarButtonClick"
|
|
117
117
|
@toolbar-tool-click="onToolbarToolClick"
|
|
118
118
|
@option-click="handleGoptionClick">
|
|
119
|
-
<template v-
|
|
120
|
-
<
|
|
119
|
+
<template v-if="customLayout">
|
|
120
|
+
<slot></slot>
|
|
121
121
|
</template>
|
|
122
|
-
<template v-
|
|
123
|
-
<
|
|
122
|
+
<template v-else>
|
|
123
|
+
<template v-for="(column, columnIndex) in tablePrevColumns" :key="columnIndex">
|
|
124
|
+
<vxe-column v-bind="column"></vxe-column>
|
|
125
|
+
</template>
|
|
126
|
+
<template v-for="(column, columnIndex) in columns" :key="columnIndex">
|
|
127
|
+
<sh-column :column="column"></sh-column>
|
|
128
|
+
</template>
|
|
124
129
|
</template>
|
|
125
130
|
<template #empty>
|
|
126
131
|
<sh-empty :icon="emptyIcon" :content="emptyText"></sh-empty>
|
|
@@ -169,7 +169,6 @@ export default defineComponent({
|
|
|
169
169
|
width: 100%;
|
|
170
170
|
.toolbar-left {
|
|
171
171
|
flex: 1;
|
|
172
|
-
white-space: nowrap;
|
|
173
172
|
.vxe-radio-button > input:checked + .vxe-radio--label {
|
|
174
173
|
border-color: var(--vxe-primary-color);
|
|
175
174
|
background: linear-gradient(-10deg, var(--vxe-primary-color), var(--vxe-primary-lighten-color));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="rootRef" class="sh-water-mark">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { defineComponent, computed, getCurrentInstance, ref, watch, onMounted } from 'vue'
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: 'ShWaterMark',
|
|
11
|
+
props: {
|
|
12
|
+
content: String,
|
|
13
|
+
font: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: '1.5em Arial'
|
|
16
|
+
},
|
|
17
|
+
color: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: '#666'
|
|
20
|
+
},
|
|
21
|
+
rotate: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: -45
|
|
24
|
+
},
|
|
25
|
+
height: {
|
|
26
|
+
type: Number,
|
|
27
|
+
default: 150
|
|
28
|
+
},
|
|
29
|
+
width: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 150
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setup(props, context) {
|
|
35
|
+
const { proxy } = getCurrentInstance()
|
|
36
|
+
const { $vUtils } = proxy
|
|
37
|
+
const { emit, slots } = context
|
|
38
|
+
|
|
39
|
+
const rootRef = ref()
|
|
40
|
+
let content = null
|
|
41
|
+
|
|
42
|
+
const initWaterMark = () => {
|
|
43
|
+
if (!rootRef.value) return
|
|
44
|
+
const parentElement = rootRef.value
|
|
45
|
+
const watermarkCanvas = document.createElement('canvas')
|
|
46
|
+
watermarkCanvas.setAttribute('width', `${props.width}`)
|
|
47
|
+
watermarkCanvas.setAttribute('height', `${props.height}`)
|
|
48
|
+
const ctx = watermarkCanvas.getContext('2d')
|
|
49
|
+
ctx.font = `${props.font}`
|
|
50
|
+
ctx.fillStyle = props.color
|
|
51
|
+
ctx.textAlign = 'center'
|
|
52
|
+
ctx.translate(props.width / 2, props.height / 2)
|
|
53
|
+
ctx.rotate((Math.PI / 180) * props.rotate)
|
|
54
|
+
ctx.fillText(props.content, 0, 0)
|
|
55
|
+
const base64Url = watermarkCanvas.toDataURL()
|
|
56
|
+
if (content) content.remove()
|
|
57
|
+
content = document.createElement('div')
|
|
58
|
+
const styles = `position: absolute;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
z-index: 9999;
|
|
61
|
+
inset: 0;
|
|
62
|
+
mix-blend-mode: multiply;
|
|
63
|
+
background-repeat:repeat;
|
|
64
|
+
background-size: ${props.width}px, ${props.height}px;
|
|
65
|
+
background-image:url('${base64Url}');
|
|
66
|
+
`
|
|
67
|
+
content.setAttribute('style', styles)
|
|
68
|
+
content.classList.add('sh-watermark-box')
|
|
69
|
+
parentElement.appendChild(content)
|
|
70
|
+
const observer = new MutationObserver(() => {
|
|
71
|
+
const wortmarkBox = parentElement.querySelector('.sh-watermark-box')
|
|
72
|
+
if (!wortmarkBox) {
|
|
73
|
+
parentElement.appendChild(content)
|
|
74
|
+
} else if (wortmarkBox.getAttribute('style') !== styles) {
|
|
75
|
+
wortmarkBox.setAttribute('style', styles)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
observer.observe(parentElement, { attributes: true, subtree: true, childList: true })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
onMounted(() => {
|
|
82
|
+
initWaterMark()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
rootRef
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<style scoped lang="scss">
|
|
93
|
+
.sh-water-mark {
|
|
94
|
+
position: relative;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
@@ -31,6 +31,7 @@ import ShToolbar from './global-components/sh-toolbar/index.vue'
|
|
|
31
31
|
import ShTree from './global-components/sh-tree/index.vue'
|
|
32
32
|
import ShUpload from './global-components/sh-upload/index.vue'
|
|
33
33
|
import ShWaterFall from './global-components/sh-water-fall/index.vue'
|
|
34
|
+
import ShWaterMark from './global-components/sh-water-mark/index.vue'
|
|
34
35
|
import { VxeButton, VxeInput, VxeTextarea, VxeSelect } from 'vxe-table'
|
|
35
36
|
|
|
36
37
|
const components = {
|
|
@@ -66,6 +67,7 @@ const components = {
|
|
|
66
67
|
ShTree,
|
|
67
68
|
ShUpload,
|
|
68
69
|
ShWaterFall,
|
|
70
|
+
ShWaterMark,
|
|
69
71
|
|
|
70
72
|
ShButton: VxeButton,
|
|
71
73
|
ShInput: VxeInput,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
// import { utils } from 'sh-tools'
|
|
3
|
-
// const throttleTime = 200
|
|
1
|
+
import { createResizeEvent, XEResizeObserver } from '../../utils/resize'
|
|
4
2
|
|
|
5
3
|
export default {
|
|
6
4
|
beforeMount(el, binding) {
|
|
7
|
-
// const _callback = utils.throttle(binding.value, throttleTime)
|
|
8
5
|
const _callback = binding.value
|
|
9
|
-
el.__observer__ =
|
|
6
|
+
el.__observer__ = createResizeEvent(_callback)
|
|
10
7
|
el.__observer__.observe(el)
|
|
11
8
|
},
|
|
12
9
|
unmounted(el, binding) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { utils } from 'sh-tools'
|
|
2
|
+
|
|
3
|
+
let resizeTimeout = null
|
|
4
|
+
const eventStore = []
|
|
5
|
+
const defaultInterval = 500
|
|
6
|
+
|
|
7
|
+
function eventHandle() {
|
|
8
|
+
if (eventStore.length) {
|
|
9
|
+
eventStore.forEach(item => {
|
|
10
|
+
item.tarList.forEach(observer => {
|
|
11
|
+
const { target, width, heighe } = observer
|
|
12
|
+
const clientWidth = target.clientWidth
|
|
13
|
+
const clientHeight = target.clientHeight
|
|
14
|
+
const rWidth = clientWidth && width !== clientWidth
|
|
15
|
+
const rHeight = clientHeight && heighe !== clientHeight
|
|
16
|
+
if (rWidth || rHeight) {
|
|
17
|
+
observer.width = clientWidth
|
|
18
|
+
observer.heighe = clientHeight
|
|
19
|
+
setTimeout(item.callback)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
eventListener()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function eventListener() {
|
|
28
|
+
clearTimeout(resizeTimeout)
|
|
29
|
+
resizeTimeout = setTimeout(eventHandle, defaultInterval)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class XEResizeObserver {
|
|
33
|
+
// target: Element, width: number, heighe: number
|
|
34
|
+
tarList = []
|
|
35
|
+
callback = () => {}
|
|
36
|
+
constructor(callback) {
|
|
37
|
+
this.callback = callback
|
|
38
|
+
}
|
|
39
|
+
observe(target) {
|
|
40
|
+
if (target) {
|
|
41
|
+
const { tarList } = this
|
|
42
|
+
if (!tarList.some(observer => observer.target === target)) {
|
|
43
|
+
tarList.push({
|
|
44
|
+
target,
|
|
45
|
+
width: target.clientWidth,
|
|
46
|
+
heighe: target.clientHeight
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
if (!eventStore.length) {
|
|
50
|
+
eventListener()
|
|
51
|
+
}
|
|
52
|
+
if (!eventStore.some(item => item === this)) {
|
|
53
|
+
eventStore.push(this)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
unobserve(target) {
|
|
58
|
+
utils.remove(eventStore, item => item.tarList.some(observer => observer.target === target))
|
|
59
|
+
}
|
|
60
|
+
disconnect() {
|
|
61
|
+
utils.remove(eventStore, item => item === this)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function createResizeEvent(callback) {
|
|
66
|
+
if (window.ResizeObserver) {
|
|
67
|
+
return new window.ResizeObserver(callback)
|
|
68
|
+
}
|
|
69
|
+
return new XEResizeObserver(callback)
|
|
70
|
+
}
|
|
@@ -478,11 +478,8 @@ const filterRenders = {
|
|
|
478
478
|
filterMethod({ value, option, cellValue, row, column, $table }) {
|
|
479
479
|
const { data } = option
|
|
480
480
|
const { rname, rprops, property } = column
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return String(rtext).toLowerCase().indexOf(data.toLowerCase()) > -1
|
|
484
|
-
}
|
|
485
|
-
return String(cellValue).toLowerCase().indexOf(data.toLowerCase()) > -1
|
|
481
|
+
let { rtext } = utils.formatRender(cellValue, property, row, rname, rprops, { $vUtils: utils })
|
|
482
|
+
return String(rtext).toLowerCase().indexOf(data.toLowerCase()) > -1
|
|
486
483
|
}
|
|
487
484
|
}
|
|
488
485
|
}
|
|
@@ -34,7 +34,9 @@ export default function (props, context, proxy) {
|
|
|
34
34
|
const rsize = computed(() => props.rprops.size || props.rparams.$table?.props?.size || props.rparams.$form?.props?.size)
|
|
35
35
|
const rform = computed(() => !!props.rparams.$form)
|
|
36
36
|
const reditmode = computed(() => props.rparams.$table?.props?.editConfig?.mode)
|
|
37
|
-
const isEditAll = computed(() =>
|
|
37
|
+
const isEditAll = computed(() => {
|
|
38
|
+
return props.rparams.$table?.props?.editConfig?.enabled && reditmode.value === 'all'
|
|
39
|
+
})
|
|
38
40
|
const moneyUnitText = computed(() => {
|
|
39
41
|
let moneyConstant = moneyUnitConstants.find(item => item.value === props.rprops.moneyUnit)
|
|
40
42
|
return moneyConstant && moneyConstant.label
|
|
@@ -46,10 +48,10 @@ export default function (props, context, proxy) {
|
|
|
46
48
|
return cnGroups.slice(startIndex, endIndex)
|
|
47
49
|
})
|
|
48
50
|
const psButtonConfig = computed(() => {
|
|
49
|
-
return { disabled: props.rprops.disabled, size: props.rsize, status: '
|
|
51
|
+
return { disabled: props.rprops.disabled, size: props.rsize, status: 'primary' }
|
|
50
52
|
})
|
|
51
|
-
const prefixButton = computed(() => props.rprops.prefixType
|
|
52
|
-
const suffixButton = computed(() => props.rprops.suffixType
|
|
53
|
+
const prefixButton = computed(() => props.rprops.prefixType?.toLowerCase() === 'button')
|
|
54
|
+
const suffixButton = computed(() => props.rprops.suffixType?.toLowerCase() === 'button')
|
|
53
55
|
|
|
54
56
|
// 初始化数据
|
|
55
57
|
const initData = () => {
|