sh-view 2.5.6 → 2.5.8
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 +3 -3
- 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/cell/vxe-render-code.vue +36 -28
- package/packages/vxeTable/render/cell/vxe-render-input.vue +53 -83
- package/packages/vxeTable/render/cell/vxe-render-select.vue +52 -44
- package/packages/vxeTable/render/cell/vxe-render-tree.vue +8 -0
- package/packages/vxeTable/render/globalRenders.jsx +2 -5
- package/packages/vxeTable/render/mixin/cell-hooks.js +29 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sh-view",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
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') {
|
|
@@ -395,11 +395,11 @@ export default function (props, context, proxy, isGrid) {
|
|
|
395
395
|
searchFields.push({ rkey: col.property, rname: renderObj.name, rprops: Object.assign({}, renderObj.props, col.rprops) })
|
|
396
396
|
}
|
|
397
397
|
})
|
|
398
|
-
|
|
399
|
-
filterData = $vUtils.searchTree(fullVisibleData, row => {
|
|
398
|
+
filterData = $vUtils.searchTree(props.dataSourse, row => {
|
|
400
399
|
return searchFields.some(item => {
|
|
401
400
|
let cellValue = $vUtils.get(row, item.rkey)
|
|
402
|
-
|
|
401
|
+
let { rtext } = $vUtils.formatRender(cellValue, item.rkey, row, item.rname, item.rprops, proxy)
|
|
402
|
+
return $vUtils.trim(rtext).toLowerCase().indexOf(filterText) > -1
|
|
403
403
|
})
|
|
404
404
|
})
|
|
405
405
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform }">
|
|
3
|
-
<template v-if="redit || isEditAll">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform }">
|
|
3
|
+
<template v-if="redit || isEditAll">
|
|
4
|
+
<span v-if="rprops.prefixText && rform" class="prefix">
|
|
5
|
+
<vxe-button v-if="prefixButton" v-bind="psButtonConfig" @click="vxeInputPrefixClick">{{ rprops.prefixText }}</vxe-button>
|
|
6
|
+
<span v-else @click="vxeInputPrefixClick">{{ rprops.prefixText }}</span>
|
|
7
|
+
</span>
|
|
8
|
+
<sh-code-editor v-model="renderValue" v-bind="rprops" @change="vxeInputChange" @blur="vxeBlurCallback"></sh-code-editor>
|
|
9
|
+
<span v-if="rprops.suffixText && rform" class="suffix">
|
|
10
|
+
<vxe-button v-if="suffixButton" v-bind="psButtonConfig" @click="vxeInputSuffixClick">{{ rprops.suffixText }}</vxe-button>
|
|
11
|
+
<span v-else @click="vxeInputSuffixClick">{{ rprops.suffixText }}</span>
|
|
12
|
+
</span>
|
|
13
|
+
</template>
|
|
14
|
+
<template v-else>
|
|
15
|
+
<span>{{ renderText }}</span>
|
|
16
|
+
</template>
|
|
17
|
+
</span>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { defineComponent, getCurrentInstance } from 'vue'
|
|
22
|
+
import cellProps from '../mixin/cell-props'
|
|
23
|
+
import cellHooks from '../mixin/cell-hooks'
|
|
24
|
+
export default defineComponent({
|
|
25
|
+
name: 'VxeRenderCode',
|
|
26
|
+
props: cellProps,
|
|
27
|
+
setup(props, context) {
|
|
28
|
+
const { proxy } = getCurrentInstance()
|
|
29
|
+
const useCell = cellHooks(props, context, proxy)
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
...useCell
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
@@ -1,83 +1,53 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform, 'flex-render': controlButton }">
|
|
3
|
-
<template v-if="redit || isEditAll">
|
|
4
|
-
<span v-if="rprops.prefixText && rform" class="prefix">
|
|
5
|
-
<vxe-button v-if="prefixButton" v-bind="psButtonConfig" @click="vxeInputPrefixClick">{{ rprops.prefixText }}</vxe-button>
|
|
6
|
-
<span v-else @click="vxeInputPrefixClick">{{ rprops.prefixText }}</span>
|
|
7
|
-
</span>
|
|
8
|
-
<span v-else-if="controlButton" class="control-btn before" @click="vxeControlClick(false)">-</span>
|
|
9
|
-
<vxe-input v-model="renderValue" v-bind="rprops" :size="rsize" @change="vxeInputChange" @blur="vxeBlurCallback" @clear="vxeBlurCallback"></vxe-input>
|
|
10
|
-
<span v-if="rprops.suffixText && rform" class="suffix">
|
|
11
|
-
<vxe-button v-if="suffixButton" v-bind="psButtonConfig" @click="vxeInputSuffixClick">{{ rprops.suffixText }}</vxe-button>
|
|
12
|
-
<span v-else @click="vxeInputSuffixClick">{{ rprops.suffixText }}</span>
|
|
13
|
-
</span>
|
|
14
|
-
<span v-else-if="controlButton" class="control-btn after" @click="vxeControlClick(true)">+</span>
|
|
15
|
-
</template>
|
|
16
|
-
<template v-else>
|
|
17
|
-
<span v-if="rprops.prefixText && renderText" class="prefix">{{ rprops.prefixText }}</span>
|
|
18
|
-
<span v-html="renderText"></span>
|
|
19
|
-
<span v-if="rprops.suffixText && renderText" class="suffix">{{ rprops.suffixText }}</span>
|
|
20
|
-
</template>
|
|
21
|
-
</span>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script>
|
|
25
|
-
import { computed, defineComponent, getCurrentInstance } from 'vue'
|
|
26
|
-
import cellProps from '../mixin/cell-props'
|
|
27
|
-
import cellHooks from '../mixin/cell-hooks'
|
|
28
|
-
export default defineComponent({
|
|
29
|
-
name: 'VxeRenderInput',
|
|
30
|
-
props: cellProps,
|
|
31
|
-
setup(props, context) {
|
|
32
|
-
const { proxy } = getCurrentInstance()
|
|
33
|
-
const { $vUtils } = proxy
|
|
34
|
-
const useCell = cellHooks(props, context, proxy)
|
|
35
|
-
|
|
36
|
-
const controlButton = computed(() => props.rprops.control && ['number', 'float', 'integer'].includes(props.rprops.type))
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
// 输入框后缀点击事件
|
|
56
|
-
const vxeInputSuffixClick = () => {
|
|
57
|
-
if (props.rprops.disabled) return
|
|
58
|
-
if (useCell.rform.value) {
|
|
59
|
-
let { $form } = props.rparams
|
|
60
|
-
$form.context.emit('suffix-click', props.rparams)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// 输入框数字加减控制
|
|
64
|
-
const vxeControlClick = bol => {
|
|
65
|
-
const { step = 1, min, max } = props.rprops
|
|
66
|
-
let value = bol ? $vUtils.add(useCell.renderValue.value, step) : $vUtils.subtract(useCell.renderValue.value, step)
|
|
67
|
-
if ((min !== undefined && value < min) || (max !== undefined && value > max)) return
|
|
68
|
-
useCell.setRenderValue(value)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
...useCell,
|
|
73
|
-
controlButton,
|
|
74
|
-
psButtonConfig,
|
|
75
|
-
prefixButton,
|
|
76
|
-
suffixButton,
|
|
77
|
-
vxeInputPrefixClick,
|
|
78
|
-
vxeInputSuffixClick,
|
|
79
|
-
vxeControlClick
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform, 'flex-render': controlButton }">
|
|
3
|
+
<template v-if="redit || isEditAll">
|
|
4
|
+
<span v-if="rprops.prefixText && rform" class="prefix">
|
|
5
|
+
<vxe-button v-if="prefixButton" v-bind="psButtonConfig" @click="vxeInputPrefixClick">{{ rprops.prefixText }}</vxe-button>
|
|
6
|
+
<span v-else @click="vxeInputPrefixClick">{{ rprops.prefixText }}</span>
|
|
7
|
+
</span>
|
|
8
|
+
<span v-else-if="controlButton" class="control-btn before" @click="vxeControlClick(false)">-</span>
|
|
9
|
+
<vxe-input v-model="renderValue" v-bind="rprops" :size="rsize" @change="vxeInputChange" @blur="vxeBlurCallback" @clear="vxeBlurCallback"></vxe-input>
|
|
10
|
+
<span v-if="rprops.suffixText && rform" class="suffix">
|
|
11
|
+
<vxe-button v-if="suffixButton" v-bind="psButtonConfig" @click="vxeInputSuffixClick">{{ rprops.suffixText }}</vxe-button>
|
|
12
|
+
<span v-else @click="vxeInputSuffixClick">{{ rprops.suffixText }}</span>
|
|
13
|
+
</span>
|
|
14
|
+
<span v-else-if="controlButton" class="control-btn after" @click="vxeControlClick(true)">+</span>
|
|
15
|
+
</template>
|
|
16
|
+
<template v-else>
|
|
17
|
+
<span v-if="rprops.prefixText && renderText" class="prefix">{{ rprops.prefixText }}</span>
|
|
18
|
+
<span v-html="renderText"></span>
|
|
19
|
+
<span v-if="rprops.suffixText && renderText" class="suffix">{{ rprops.suffixText }}</span>
|
|
20
|
+
</template>
|
|
21
|
+
</span>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { computed, defineComponent, getCurrentInstance } from 'vue'
|
|
26
|
+
import cellProps from '../mixin/cell-props'
|
|
27
|
+
import cellHooks from '../mixin/cell-hooks'
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: 'VxeRenderInput',
|
|
30
|
+
props: cellProps,
|
|
31
|
+
setup(props, context) {
|
|
32
|
+
const { proxy } = getCurrentInstance()
|
|
33
|
+
const { $vUtils } = proxy
|
|
34
|
+
const useCell = cellHooks(props, context, proxy)
|
|
35
|
+
|
|
36
|
+
const controlButton = computed(() => props.rprops.control && ['number', 'float', 'integer'].includes(props.rprops.type))
|
|
37
|
+
|
|
38
|
+
// 输入框数字加减控制
|
|
39
|
+
const vxeControlClick = bol => {
|
|
40
|
+
const { step = 1, min, max } = props.rprops
|
|
41
|
+
let value = bol ? $vUtils.add(useCell.renderValue.value, step) : $vUtils.subtract(useCell.renderValue.value, step)
|
|
42
|
+
if ((min !== undefined && value < min) || (max !== undefined && value > max)) return
|
|
43
|
+
useCell.setRenderValue(value)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...useCell,
|
|
48
|
+
controlButton,
|
|
49
|
+
vxeControlClick
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
@@ -1,44 +1,52 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform }">
|
|
3
|
-
<template v-if="redit || isEditAll">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform }">
|
|
3
|
+
<template v-if="redit || isEditAll">
|
|
4
|
+
<span v-if="rprops.prefixText && rform" class="prefix">
|
|
5
|
+
<vxe-button v-if="prefixButton" v-bind="psButtonConfig" @click="vxeInputPrefixClick">{{ rprops.prefixText }}</vxe-button>
|
|
6
|
+
<span v-else @click="vxeInputPrefixClick">{{ rprops.prefixText }}</span>
|
|
7
|
+
</span>
|
|
8
|
+
<vxe-select v-model="renderValue" v-bind="rprops" :size="rsize" @change="vxeChangeCallBack" />
|
|
9
|
+
<span v-if="rprops.suffixText && rform" class="suffix">
|
|
10
|
+
<vxe-button v-if="suffixButton" v-bind="psButtonConfig" @click="vxeInputSuffixClick">{{ rprops.suffixText }}</vxe-button>
|
|
11
|
+
<span v-else @click="vxeInputSuffixClick">{{ rprops.suffixText }}</span>
|
|
12
|
+
</span>
|
|
13
|
+
</template>
|
|
14
|
+
<template v-else-if="!redit && showType">
|
|
15
|
+
<template v-for="showTag in showTags" :key="showTag.value">
|
|
16
|
+
<sh-tag :color="showTag.tagColor || rprops.tagColor" :type="showTag.tagType || rprops.tagType">{{ showTag.label }}</sh-tag>
|
|
17
|
+
</template>
|
|
18
|
+
</template>
|
|
19
|
+
<span v-else v-html="renderText"></span>
|
|
20
|
+
</span>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
import { computed, defineComponent, getCurrentInstance } from 'vue'
|
|
25
|
+
import cellProps from '../mixin/cell-props'
|
|
26
|
+
import cellHooks from '../mixin/cell-hooks'
|
|
27
|
+
export default defineComponent({
|
|
28
|
+
name: 'VxeRenderSelect',
|
|
29
|
+
props: cellProps,
|
|
30
|
+
setup(props, context) {
|
|
31
|
+
const { proxy } = getCurrentInstance()
|
|
32
|
+
const useCell = cellHooks(props, context, proxy)
|
|
33
|
+
|
|
34
|
+
const showType = computed(() => props.rprops.showType === 'tag')
|
|
35
|
+
|
|
36
|
+
const showTags = computed(() => {
|
|
37
|
+
const renderValue = useCell.renderValue.value
|
|
38
|
+
const { options = [], multiple } = props.rprops
|
|
39
|
+
if (multiple && Array.isArray(renderValue)) {
|
|
40
|
+
return options.filter(option => renderValue.includes(option.value))
|
|
41
|
+
}
|
|
42
|
+
return options.filter(option => String(option.value) === String(renderValue))
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...useCell,
|
|
47
|
+
showType,
|
|
48
|
+
showTags
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
</script>
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span class="vxe-render--inner" :class="{ 'form-render': rform, 'td-render': !rform }">
|
|
3
3
|
<template v-if="redit || isEditAll">
|
|
4
|
+
<span v-if="rprops.prefixText && rform" class="prefix">
|
|
5
|
+
<vxe-button v-if="prefixButton" v-bind="psButtonConfig" @click="vxeInputPrefixClick">{{ rprops.prefixText }}</vxe-button>
|
|
6
|
+
<span v-else @click="vxeInputPrefixClick">{{ rprops.prefixText }}</span>
|
|
7
|
+
</span>
|
|
4
8
|
<sh-tree v-model="renderValue" v-bind="rprops" :field="rkey" :value-data="rdata" :size="rsize" is-select @change="vxeTreeCallback"></sh-tree>
|
|
9
|
+
<span v-if="rprops.suffixText && rform" class="suffix">
|
|
10
|
+
<vxe-button v-if="suffixButton" v-bind="psButtonConfig" @click="vxeInputSuffixClick">{{ rprops.suffixText }}</vxe-button>
|
|
11
|
+
<span v-else @click="vxeInputSuffixClick">{{ rprops.suffixText }}</span>
|
|
12
|
+
</span>
|
|
5
13
|
</template>
|
|
6
14
|
<template v-else>
|
|
7
15
|
<span v-html="renderText"></span>
|
|
@@ -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
|
|
@@ -45,6 +47,11 @@ export default function (props, context, proxy) {
|
|
|
45
47
|
let endIndex = cnGroups.findIndex(cn => cn.fullText === billStart)
|
|
46
48
|
return cnGroups.slice(startIndex, endIndex)
|
|
47
49
|
})
|
|
50
|
+
const psButtonConfig = computed(() => {
|
|
51
|
+
return { disabled: props.rprops.disabled, size: props.rsize, status: 'primary' }
|
|
52
|
+
})
|
|
53
|
+
const prefixButton = computed(() => props.rprops.prefixType?.toLowerCase() === 'button')
|
|
54
|
+
const suffixButton = computed(() => props.rprops.suffixType?.toLowerCase() === 'button')
|
|
48
55
|
|
|
49
56
|
// 初始化数据
|
|
50
57
|
const initData = () => {
|
|
@@ -52,6 +59,22 @@ export default function (props, context, proxy) {
|
|
|
52
59
|
formatValueFun(keyValue)
|
|
53
60
|
}
|
|
54
61
|
|
|
62
|
+
// 输入框前缀点击事件
|
|
63
|
+
const vxeInputPrefixClick = () => {
|
|
64
|
+
if (props.rprops.disabled) return
|
|
65
|
+
if (rform.value) {
|
|
66
|
+
let { $form } = props.rparams
|
|
67
|
+
$form.context.emit('prefix-click', props.rparams)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// 输入框后缀点击事件
|
|
71
|
+
const vxeInputSuffixClick = () => {
|
|
72
|
+
if (props.rprops.disabled) return
|
|
73
|
+
if (rform.value) {
|
|
74
|
+
let { $form } = props.rparams
|
|
75
|
+
$form.context.emit('suffix-click', props.rparams)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
55
78
|
// 输入框变化
|
|
56
79
|
const vxeInputChange = async ({ value, $event }) => {
|
|
57
80
|
// 此操作火狐浏览器(bug(vxe):编辑后不触发渲染器的blur问题)触发edit-closed,故在edit-close重新赋值
|
|
@@ -154,6 +177,11 @@ export default function (props, context, proxy) {
|
|
|
154
177
|
isEditAll,
|
|
155
178
|
moneyUnitText,
|
|
156
179
|
billGroups,
|
|
180
|
+
psButtonConfig,
|
|
181
|
+
prefixButton,
|
|
182
|
+
suffixButton,
|
|
183
|
+
vxeInputPrefixClick,
|
|
184
|
+
vxeInputSuffixClick,
|
|
157
185
|
vxeInputChange,
|
|
158
186
|
vxeChangeCallBack,
|
|
159
187
|
vxeRadioCallBack,
|