sh-view 2.1.0 → 2.2.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.
- package/package.json +9 -13
- package/packages/components/global-components/sh-alert/index.vue +175 -173
- package/packages/components/global-components/sh-badge/index.vue +57 -43
- package/packages/components/global-components/sh-card/index.vue +24 -16
- package/packages/components/global-components/sh-code-editor/index.vue +250 -260
- package/packages/components/global-components/sh-col/index.vue +44 -36
- package/packages/components/global-components/sh-corner/index.vue +230 -228
- package/packages/components/global-components/sh-count-to/index.vue +60 -51
- package/packages/components/global-components/sh-drawer/index.vue +209 -182
- package/packages/components/global-components/sh-drawer/scrollbar.js +44 -42
- package/packages/components/global-components/sh-empty/index.vue +0 -1
- package/packages/components/global-components/sh-form/form.vue +110 -0
- package/packages/components/global-components/sh-form/js/props.js +76 -63
- package/packages/components/global-components/sh-form/js/useForm.js +236 -0
- package/packages/components/global-components/sh-form/query.vue +70 -0
- package/packages/components/global-components/sh-header/index.vue +35 -50
- package/packages/components/global-components/sh-icon/css/index.scss +44 -0
- package/packages/components/global-components/sh-icon/index.vue +24 -11
- package/packages/components/global-components/sh-image/index.vue +47 -38
- package/packages/components/global-components/sh-list/index.vue +42 -37
- package/packages/components/global-components/sh-loading/index.vue +12 -8
- package/packages/components/global-components/sh-modal/index.vue +49 -40
- package/packages/components/global-components/sh-noticebar/index.vue +68 -54
- package/packages/components/global-components/sh-poptip/index.vue +247 -130
- package/packages/components/global-components/sh-progress/index.vue +71 -69
- package/packages/components/global-components/sh-pull-refresh/index.vue +156 -157
- package/packages/components/global-components/sh-result/index.vue +37 -28
- package/packages/components/global-components/sh-row/index.vue +21 -18
- package/packages/components/global-components/sh-split/index.vue +115 -109
- package/packages/components/global-components/sh-table/components/importModal.vue +95 -86
- package/packages/components/global-components/sh-table/components/sh-column.vue +54 -0
- package/packages/components/global-components/sh-table/{index.vue → grid.vue} +34 -145
- package/packages/components/global-components/sh-table/js/tableMethods.js +175 -0
- package/packages/components/global-components/sh-table/js/useTable.js +592 -0
- package/packages/components/global-components/sh-table/table.vue +269 -0
- package/packages/components/global-components/sh-tabs/index.vue +118 -93
- package/packages/components/global-components/sh-tag/index.vue +52 -51
- package/packages/components/global-components/sh-toolbar/index.vue +53 -47
- package/packages/components/global-components/sh-tree/components/table-tree.vue +152 -139
- package/packages/components/global-components/sh-tree/index.vue +218 -195
- package/packages/components/global-components/sh-tree/mixin/treeProps.js +118 -120
- package/packages/components/global-components/sh-upload/index.vue +308 -51
- package/packages/components/global-components/sh-water-fall/index.vue +4 -11
- package/packages/components/index.js +5 -3
- package/packages/components/other-components/sh-cron-modal/components/cron-content.vue +140 -129
- package/packages/components/other-components/sh-cron-modal/css/index.scss +0 -5
- package/packages/components/other-components/sh-cron-modal/index.vue +81 -67
- package/packages/components/other-components/sh-cron-modal/mixin/cron-emits.js +1 -0
- package/packages/components/other-components/sh-cron-modal/mixin/cron-hooks.js +179 -0
- package/packages/components/other-components/sh-cron-modal/mixin/cron-props.js +9 -0
- package/packages/components/other-components/sh-cron-modal/tabs/cron-day-box.vue +101 -92
- package/packages/components/other-components/sh-cron-modal/tabs/cron-hour-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-minute-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-month-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-second-box.vue +68 -56
- package/packages/components/other-components/sh-cron-modal/tabs/cron-week-box.vue +126 -115
- package/packages/components/other-components/sh-cron-modal/tabs/cron-year-box.vue +59 -46
- package/packages/components/other-components/sh-menu/index.vue +73 -60
- package/packages/components/other-components/sh-menu/menu-group-content.vue +71 -59
- package/packages/components/other-components/sh-menu/menu-item-content.vue +40 -30
- package/packages/components/other-components/sh-menu-card/index.vue +70 -64
- package/packages/components/other-components/sh-menu-card/menu-box.vue +50 -44
- package/packages/components/other-components/sh-preview/components/sh-excel.vue +182 -0
- package/packages/components/other-components/sh-preview/components/sh-word.vue +73 -0
- package/packages/components/other-components/sh-preview/index.vue +86 -85
- package/packages/components/other-components/sh-preview/js/data-hook.js +37 -0
- package/packages/components/other-components/sh-preview/js/data-props.js +11 -0
- package/packages/components/other-components/sh-system-tip/index.vue +28 -24
- package/packages/css/index.js +4 -4
- package/packages/directive/module/prevent-click.js +1 -1
- package/packages/directive/module/resize.js +11 -154
- package/packages/index.js +39 -39
- package/packages/mixin/index.js +86 -87
- package/packages/vxeTable/render/cell/vxe-render-checkbox.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +43 -36
- package/packages/vxeTable/render/cell/vxe-render-code.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-goption.vue +34 -24
- package/packages/vxeTable/render/cell/vxe-render-href.vue +21 -11
- package/packages/vxeTable/render/cell/vxe-render-img.vue +16 -10
- package/packages/vxeTable/render/cell/vxe-render-input.vue +83 -79
- package/packages/vxeTable/render/cell/vxe-render-money.vue +14 -6
- package/packages/vxeTable/render/cell/vxe-render-progress.vue +28 -19
- package/packages/vxeTable/render/cell/vxe-render-radio.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +43 -36
- package/packages/vxeTable/render/cell/vxe-render-select.vue +44 -36
- package/packages/vxeTable/render/cell/vxe-render-switch.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -78
- package/packages/vxeTable/render/cell/vxe-render-textarea.vue +14 -5
- package/packages/vxeTable/render/cell/vxe-render-time.vue +23 -13
- package/packages/vxeTable/render/cell/vxe-render-tree.vue +23 -27
- package/packages/vxeTable/render/cell/vxe-render-upload.vue +11 -7
- package/packages/vxeTable/render/filters/vxe-filter-input.vue +25 -43
- package/packages/vxeTable/render/footer/vxe-footer-input.vue +23 -13
- package/packages/vxeTable/render/footer/vxe-footer-money.vue +30 -20
- package/packages/vxeTable/render/globalRenders.jsx +1 -1
- package/packages/vxeTable/render/header/vxe-header-money.vue +31 -21
- package/packages/vxeTable/render/mixin/cell-hooks.js +162 -0
- package/packages/vxeTable/render/mixin/cell-props.js +23 -0
- package/packages/vxeTable/render/mixin/filter-hooks.js +28 -0
- package/packages/components/global-components/sh-form/components/form-item.vue +0 -25
- package/packages/components/global-components/sh-form/css/index.scss +0 -55
- package/packages/components/global-components/sh-form/index.vue +0 -114
- package/packages/components/global-components/sh-form/js/methods.js +0 -146
- package/packages/components/global-components/sh-form/mixin/defaultData.js +0 -32
- package/packages/components/global-components/sh-icon/css/default/index.scss +0 -27
- package/packages/components/global-components/sh-icon/css/font/index.scss +0 -16
- package/packages/components/global-components/sh-icon/icon-default.vue +0 -32
- package/packages/components/global-components/sh-icon/icon-font.vue +0 -32
- package/packages/components/global-components/sh-poptip/popper.js +0 -115
- package/packages/components/global-components/sh-query/index.vue +0 -317
- package/packages/components/global-components/sh-table/js/methods.js +0 -549
- package/packages/components/global-components/sh-table/mixin/defaultData.js +0 -94
- package/packages/components/global-components/sh-upload/js/mixin.js +0 -257
- package/packages/components/other-components/sh-cron-modal/mixin/cron-box.js +0 -169
- package/packages/vxeTable/render/mixin/cell-mixin.js +0 -195
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.svg → ionicons.svg} +0 -0
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.ttf → ionicons.ttf} +0 -0
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff → ionicons.woff} +0 -0
- /package/packages/components/global-components/sh-icon/css/default/{fonts/ionicons.woff2 → ionicons.woff2} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.js → iconfont.js} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.json → iconfont.json} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.ttf → iconfont.ttf} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff → iconfont.woff} +0 -0
- /package/packages/components/global-components/sh-icon/css/font/{fonts/iconfont.woff2 → iconfont.woff2} +0 -0
- /package/packages/{assets/css → css}/animated.scss +0 -0
- /package/packages/{assets/css → css}/loader.scss +0 -0
- /package/packages/{assets/css → css}/main.scss +0 -0
- /package/packages/{assets/css → css}/theme.scss +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="sh-tag" :class="classes" :style="[borderStyle, backgroundStyle]" @click.stop="check">
|
|
3
3
|
<span v-if="type === 'dot'" class="sh-tag-other"><span class="sh-tag-dot" :style="[backgroundStyle]"></span></span>
|
|
4
|
-
<span class="sh-tag-text" :
|
|
4
|
+
<span class="sh-tag-text" :style="[fontStyle]"><slot></slot></span>
|
|
5
5
|
<a v-if="closable" class="sh-tag-other sh-tag-close" :style="[borderStyle]" @click="close">
|
|
6
6
|
<slot name="close"><sh-icon type="ios-close"></sh-icon></slot>
|
|
7
7
|
</a>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
|
+
import { defineComponent, computed, getCurrentInstance, ref, watch, onBeforeMount } from 'vue'
|
|
12
13
|
const colorMap = {
|
|
13
14
|
default: 'var(-vxe-table-header-background-color)',
|
|
14
15
|
primary: 'var(--vxe-primary-color)',
|
|
@@ -22,7 +23,7 @@ const fontColorMap = {
|
|
|
22
23
|
const borderColorMap = {
|
|
23
24
|
default: 'null'
|
|
24
25
|
}
|
|
25
|
-
export default {
|
|
26
|
+
export default defineComponent({
|
|
26
27
|
name: 'ShTag',
|
|
27
28
|
props: {
|
|
28
29
|
closable: {
|
|
@@ -57,61 +58,61 @@ export default {
|
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
60
|
emits: ['change', 'close'],
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
colorIn()
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
backgroundStyle() {
|
|
82
|
-
if (this.isCustom) return { backgroundColor: this.colorRgb, color: '#fff' }
|
|
83
|
-
return { backgroundColor: this.$vUtils.lighten(this.colorIn, this.opacity) }
|
|
84
|
-
},
|
|
85
|
-
classes() {
|
|
61
|
+
setup(props, context) {
|
|
62
|
+
const { proxy } = getCurrentInstance()
|
|
63
|
+
const { $vUtils } = proxy
|
|
64
|
+
const { emit, slots } = context
|
|
65
|
+
|
|
66
|
+
const isChecked = ref(props.checked)
|
|
67
|
+
const colorIn = computed(() => props.color || 'default')
|
|
68
|
+
const colorRgb = computed(() => colorMap[colorIn.value] || $vUtils.lighten(colorIn.value))
|
|
69
|
+
const isCustom = computed(() => !!colorMap[colorIn.value])
|
|
70
|
+
const fontStyle = computed(() => {
|
|
71
|
+
return { color: isCustom.value && !props.type ? fontColorMap[colorIn.value] || '#fff' : colorRgb.value }
|
|
72
|
+
})
|
|
73
|
+
const borderStyle = computed(() => {
|
|
74
|
+
return { borderWidth: '1px', borderStyle: 'solid', borderColor: borderColorMap[colorIn.value] || colorRgb.value }
|
|
75
|
+
})
|
|
76
|
+
const backgroundStyle = computed(() => {
|
|
77
|
+
if (isCustom.value) return { backgroundColor: colorRgb.value, color: '#fff' }
|
|
78
|
+
return { backgroundColor: $vUtils.lighten(colorIn.value, props.opacity) }
|
|
79
|
+
})
|
|
80
|
+
const classes = computed(() => {
|
|
86
81
|
return {
|
|
87
|
-
[`${
|
|
88
|
-
[`${
|
|
89
|
-
[`closable`]:
|
|
90
|
-
[`checked`]:
|
|
91
|
-
[`checkable`]:
|
|
82
|
+
[`${props.size}`]: !!props.size,
|
|
83
|
+
[`${props.type}`]: !!props.type,
|
|
84
|
+
[`closable`]: props.closable,
|
|
85
|
+
[`checked`]: isChecked.value,
|
|
86
|
+
[`checkable`]: props.checkable
|
|
92
87
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const close = event => {
|
|
91
|
+
emit('close', event, props.name)
|
|
96
92
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
const check = () => {
|
|
94
|
+
if (!props.checkable) return
|
|
95
|
+
isChecked.value = !isChecked.value
|
|
96
|
+
emit('change', isChecked.value, props.name)
|
|
101
97
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
|
|
99
|
+
watch(
|
|
100
|
+
() => props.checked,
|
|
101
|
+
value => {
|
|
102
|
+
isChecked.value = val
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
classes,
|
|
108
|
+
borderStyle,
|
|
109
|
+
backgroundStyle,
|
|
110
|
+
fontStyle,
|
|
111
|
+
check,
|
|
112
|
+
close
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
|
-
}
|
|
115
|
+
})
|
|
115
116
|
</script>
|
|
116
117
|
|
|
117
118
|
<style scoped lang="scss">
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script>
|
|
28
|
-
|
|
28
|
+
import { defineComponent, computed, getCurrentInstance, ref, watch, onBeforeMount } from 'vue'
|
|
29
|
+
export default defineComponent({
|
|
29
30
|
name: 'ShToolbar',
|
|
30
31
|
props: {
|
|
31
32
|
modelValue: {
|
|
@@ -89,67 +90,72 @@ export default {
|
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
emits: ['update:modelValue', 'left', 'right', 'tool'],
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
setup(props, context) {
|
|
94
|
+
const { proxy } = getCurrentInstance()
|
|
95
|
+
const { $vUtils } = proxy
|
|
96
|
+
const { emit, slots } = context
|
|
97
|
+
|
|
98
|
+
const leftActive = ref(props.modelValue)
|
|
99
|
+
|
|
100
|
+
const leftBtns = computed(() => {
|
|
99
101
|
let lBtns = []
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
lBtns = leftContain.map(item => {
|
|
103
|
-
return leftConfig.find(btn => btn.code === item)
|
|
104
|
-
})
|
|
102
|
+
if (props.leftContain && Array.isArray(props.leftContain)) {
|
|
103
|
+
lBtns = props.leftContain.map(item => props.leftConfig.find(btn => btn.code === item))
|
|
105
104
|
}
|
|
106
105
|
return lBtns
|
|
107
|
-
}
|
|
108
|
-
rightBtns() {
|
|
106
|
+
})
|
|
107
|
+
const rightBtns = computed(() => {
|
|
109
108
|
let rBtns = []
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
rBtns = rightConfig
|
|
109
|
+
if (props.rightConfig && Array.isArray(props.rightConfig)) {
|
|
110
|
+
rBtns = props.rightConfig
|
|
113
111
|
}
|
|
114
|
-
let leftCode = leftBtns.find(btn => btn.value === leftActive)
|
|
115
|
-
if (relation && leftCode) {
|
|
112
|
+
let leftCode = leftBtns.value.find(btn => btn.value === leftActive.value)
|
|
113
|
+
if (props.relation && leftCode) {
|
|
116
114
|
rBtns = rBtns.filter(item => item.code && item.code.split(',').includes(leftCode.code))
|
|
117
115
|
}
|
|
118
116
|
return rBtns
|
|
119
|
-
}
|
|
120
|
-
toolBtns() {
|
|
117
|
+
})
|
|
118
|
+
const toolBtns = computed(() => {
|
|
121
119
|
let toolBtns = []
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
toolBtns = toolsContain.map(item => {
|
|
125
|
-
return toolsConfig.find(btn => btn.code === item)
|
|
126
|
-
})
|
|
120
|
+
if (props.toolsContain && Array.isArray(props.toolsContain)) {
|
|
121
|
+
toolBtns = props.toolsContain.map(item => props.toolsConfig.find(btn => btn.code === item))
|
|
127
122
|
}
|
|
128
123
|
return toolBtns
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const handleLeftBtn = ({ label }) => {
|
|
127
|
+
let btnObj = props.leftConfig.find(item => item.value === label)
|
|
128
|
+
emitValue()
|
|
129
|
+
emit('left', label, btnObj)
|
|
129
130
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
modelValue(nv, ov) {
|
|
133
|
-
this.leftActive = nv
|
|
131
|
+
const handleRightBtn = btn => {
|
|
132
|
+
emit('right', btn.value, btn)
|
|
134
133
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
const handleToolBtn = btn => {
|
|
135
|
+
emit('tool', btn)
|
|
136
|
+
}
|
|
137
|
+
const emitValue = () => {
|
|
138
|
+
emit('update:modelValue', leftActive.value)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
watch(
|
|
142
|
+
() => props.modelValue,
|
|
143
|
+
nv => {
|
|
144
|
+
leftActive.value = nv
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
leftActive,
|
|
150
|
+
toolBtns,
|
|
151
|
+
leftBtns,
|
|
152
|
+
rightBtns,
|
|
153
|
+
handleToolBtn,
|
|
154
|
+
handleLeftBtn,
|
|
155
|
+
handleRightBtn
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
|
-
}
|
|
158
|
+
})
|
|
153
159
|
</script>
|
|
154
160
|
|
|
155
161
|
<style lang="scss">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<vxe-grid
|
|
3
3
|
v-if="treeServerComplate && !queryErrorText"
|
|
4
|
-
ref="
|
|
4
|
+
ref="tableRef"
|
|
5
5
|
:key="renderKey"
|
|
6
6
|
:class="{ 'sh-vxe-tree-table': true, 'is--hidecheck': globalConfig.checkHide }"
|
|
7
7
|
v-bind="tableConfigIn"
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script>
|
|
22
|
+
import { defineComponent, computed, getCurrentInstance, ref, watch, onMounted } from 'vue'
|
|
22
23
|
// 树组件表格默认配置
|
|
23
24
|
const tableConfigDefault = {
|
|
24
25
|
autoResize: true,
|
|
@@ -44,105 +45,73 @@ const tableConfigDefault = {
|
|
|
44
45
|
gt: 20
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
|
|
48
48
|
import mixinProps from '../mixin/treeProps'
|
|
49
|
-
export default {
|
|
49
|
+
export default defineComponent({
|
|
50
50
|
name: 'TableTree',
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
emits: ['select', 'datacall'],
|
|
54
|
-
data() {
|
|
55
|
-
return {
|
|
56
|
-
// 树公共属性
|
|
57
|
-
renderKey: 1,
|
|
58
|
-
filterData: null,
|
|
59
|
-
filterChangeDebounce: this.$vUtils.debounce(this.handleMyTableFilter, 500),
|
|
60
|
-
treeServerComplate: false,
|
|
61
|
-
treeLoading: false,
|
|
62
|
-
treeData: this.options,
|
|
63
|
-
treeValue: [],
|
|
64
|
-
queryCacheParams: null,
|
|
65
|
-
queryErrorText: null
|
|
66
|
-
}
|
|
51
|
+
props: {
|
|
52
|
+
...mixinProps
|
|
67
53
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
emits: ['select', 'datacall'],
|
|
55
|
+
setup(props, context) {
|
|
56
|
+
const { proxy } = getCurrentInstance()
|
|
57
|
+
const { $vUtils, $http, $vxePluginNames } = proxy
|
|
58
|
+
const { emit, slots } = context
|
|
59
|
+
|
|
60
|
+
const tableRef = ref()
|
|
61
|
+
const renderKey = ref(1)
|
|
62
|
+
const filterData = ref(null)
|
|
63
|
+
const treeServerComplate = ref(false)
|
|
64
|
+
const treeLoading = ref(false)
|
|
65
|
+
const treeData = ref(props.options)
|
|
66
|
+
const treeValue = ref([])
|
|
67
|
+
const queryCacheParams = ref(null)
|
|
68
|
+
const queryErrorText = ref(null)
|
|
69
|
+
|
|
70
|
+
const checkWidth = computed(() => {
|
|
71
|
+
return props.globalConfig.columns ? props.globalConfig?.defaultWidth || 150 : '100%'
|
|
72
|
+
})
|
|
73
|
+
const checkColumnProps = computed(() => {
|
|
74
|
+
let resultProps = { field: props.labelField, width: checkWidth.value, type: props.multiple ? 'checkbox' : 'radio', treeNode: true, slots: { default: 'treeNodeCell' } }
|
|
75
|
+
resultProps.title = props.labelTitle || props.multiple ? '全部' : ''
|
|
75
76
|
return resultProps
|
|
76
|
-
}
|
|
77
|
-
tableProps() {
|
|
77
|
+
})
|
|
78
|
+
const tableProps = computed(() => {
|
|
78
79
|
return {
|
|
79
|
-
height:
|
|
80
|
-
size:
|
|
81
|
-
loading:
|
|
82
|
-
data:
|
|
83
|
-
columns: [
|
|
80
|
+
height: props.isSelect ? '230px' : props.height,
|
|
81
|
+
size: props.size,
|
|
82
|
+
loading: props.loading || treeLoading.value,
|
|
83
|
+
data: filterData.value || treeData.value,
|
|
84
|
+
columns: [checkColumnProps.value].concat(props.globalConfig?.columns || [])
|
|
84
85
|
}
|
|
85
|
-
}
|
|
86
|
-
tableConfigIn() {
|
|
86
|
+
})
|
|
87
|
+
const tableConfigIn = computed(() => {
|
|
87
88
|
let resultConfig = {
|
|
88
|
-
rowConfig: { isCurrent: false, keyField:
|
|
89
|
-
radioConfig: { checkRowKey:
|
|
90
|
-
checkboxConfig: { checkRowKeys:
|
|
91
|
-
treeConfig: { rowField:
|
|
89
|
+
rowConfig: { isCurrent: false, keyField: props.nodeKey },
|
|
90
|
+
radioConfig: { checkRowKey: props.modelValue[0], labelField: props.labelField, checkMethod: tableCheckMethods },
|
|
91
|
+
checkboxConfig: { checkRowKeys: props.modelValue, labelField: props.labelField, checkMethod: tableCheckMethods },
|
|
92
|
+
treeConfig: { rowField: props.nodeKey },
|
|
92
93
|
editConfig: { enabled: false }
|
|
93
94
|
}
|
|
94
|
-
resultConfig =
|
|
95
|
-
if (
|
|
96
|
-
if (
|
|
95
|
+
resultConfig = $vUtils.merge(resultConfig, tableConfigDefault, props.globalConfig)
|
|
96
|
+
if (props.multiple) {
|
|
97
|
+
if (props.globalConfig.hasAll) resultConfig.showHeader = true
|
|
97
98
|
resultConfig.radioConfig = null
|
|
98
99
|
} else {
|
|
99
100
|
resultConfig.checkboxConfig = null
|
|
100
101
|
}
|
|
101
|
-
return Object.assign(resultConfig,
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
modelValue() {
|
|
106
|
-
this.initSelection(true)
|
|
107
|
-
},
|
|
108
|
-
filterText: {
|
|
109
|
-
handler(newvalue, oldValue) {
|
|
110
|
-
this.filterChangeDebounce(newvalue)
|
|
111
|
-
},
|
|
112
|
-
deep: true,
|
|
113
|
-
immediate: true
|
|
114
|
-
},
|
|
115
|
-
options: {
|
|
116
|
-
handler(newvalue, oldValue) {
|
|
117
|
-
this.treeData = newvalue
|
|
118
|
-
},
|
|
119
|
-
deep: true,
|
|
120
|
-
immediate: true
|
|
121
|
-
},
|
|
122
|
-
treeData: {
|
|
123
|
-
handler(newvalue, oldValue) {
|
|
124
|
-
this.$emit('datacall', newvalue)
|
|
125
|
-
},
|
|
126
|
-
immediate: true
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
mounted() {
|
|
130
|
-
this.initMounted()
|
|
131
|
-
},
|
|
132
|
-
methods: {
|
|
133
|
-
tableRef() {
|
|
134
|
-
return this.$refs.vxeTreeTable
|
|
135
|
-
},
|
|
136
|
-
async initMounted() {
|
|
102
|
+
return Object.assign(resultConfig, tableProps.value)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const initMounted = async () => {
|
|
137
106
|
// 初始化获取服务配置数据
|
|
138
|
-
await
|
|
139
|
-
|
|
140
|
-
}
|
|
107
|
+
await getServerConfigDataSourse()
|
|
108
|
+
initSelection()
|
|
109
|
+
}
|
|
141
110
|
// 获取请求配置数据
|
|
142
|
-
async
|
|
143
|
-
const { serverConfig, serverParams, parseParams, queryCacheParams, serverCache, valueData, globalConfig, multiple, nodeKey, labelField
|
|
111
|
+
const getServerConfigDataSourse = async () => {
|
|
112
|
+
const { serverConfig, serverParams, parseParams, queryCacheParams, serverCache, valueData, globalConfig, multiple, nodeKey, labelField } = props
|
|
144
113
|
if (!serverConfig.url) {
|
|
145
|
-
|
|
114
|
+
treeServerComplate.value = true
|
|
146
115
|
return true
|
|
147
116
|
}
|
|
148
117
|
let params = $vUtils.clone(serverParams, true)
|
|
@@ -155,14 +124,14 @@ export default {
|
|
|
155
124
|
}
|
|
156
125
|
})
|
|
157
126
|
if (!$vUtils.isEqual(queryCacheParams, params)) {
|
|
158
|
-
|
|
127
|
+
treeServerComplate.value = false
|
|
159
128
|
}
|
|
160
|
-
if (serverCache &&
|
|
129
|
+
if (serverCache && treeServerComplate.value) {
|
|
161
130
|
return true
|
|
162
131
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
132
|
+
queryErrorText.value = null
|
|
133
|
+
queryCacheParams.value = params
|
|
134
|
+
treeLoading.value = true
|
|
166
135
|
let reqOptions = {
|
|
167
136
|
baseURL: serverConfig.baseURL
|
|
168
137
|
}
|
|
@@ -171,110 +140,154 @@ export default {
|
|
|
171
140
|
let treeRes = await $http[method](serverConfig.url, params, reqOptions)
|
|
172
141
|
if (treeRes && [10000, 100000].includes(+treeRes.code)) {
|
|
173
142
|
let treeAllNode = globalConfig?.hasAll && !multiple ? [{ [nodeKey]: 0, [labelField]: '全部', isleaf: 1, code: '' }] : []
|
|
174
|
-
let
|
|
143
|
+
let treeResData = treeAllNode.concat(treeRes.data)
|
|
175
144
|
if (globalConfig?.treeConfig?.transform) {
|
|
176
|
-
|
|
145
|
+
treeResData = $vUtils.toTreeArray(treeResData, { clear: true })
|
|
177
146
|
}
|
|
178
|
-
|
|
147
|
+
treeData.value = treeResData
|
|
179
148
|
} else {
|
|
180
149
|
throw new Error(`树节点信息获取失败:${treeRes?.message}`)
|
|
181
150
|
}
|
|
182
151
|
} catch (e) {
|
|
183
|
-
|
|
152
|
+
queryErrorText.value = e.message || e
|
|
184
153
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
initSelection
|
|
189
|
-
let { modelValue,
|
|
190
|
-
let nodeKey =
|
|
154
|
+
treeLoading.value = false
|
|
155
|
+
treeServerComplate.value = true
|
|
156
|
+
}
|
|
157
|
+
const initSelection = isWatch => {
|
|
158
|
+
let { modelValue, isSelect } = props
|
|
159
|
+
let nodeKey = props.nodeKey || 'id'
|
|
191
160
|
setTimeout(() => {
|
|
192
|
-
if (!tableRef
|
|
193
|
-
if (
|
|
194
|
-
if (!$vUtils.isEqual(modelValue, treeValue))
|
|
161
|
+
if (!tableRef.value || !modelValue?.length) return
|
|
162
|
+
if (isWatch) {
|
|
163
|
+
if (!$vUtils.isEqual(modelValue, treeValue.value)) renderKey.value++
|
|
195
164
|
} else {
|
|
196
|
-
tableRef
|
|
165
|
+
tableRef.value.scrollToRow({ [nodeKey]: modelValue[0] })
|
|
197
166
|
}
|
|
198
167
|
})
|
|
199
|
-
}
|
|
168
|
+
}
|
|
200
169
|
// 单选框变化
|
|
201
|
-
onRadioChange
|
|
202
|
-
let nodeKey =
|
|
170
|
+
const onRadioChange = obj => {
|
|
171
|
+
let nodeKey = props.nodeKey || 'id'
|
|
203
172
|
let { newValue } = obj
|
|
204
173
|
let selectedKeys = []
|
|
205
174
|
if (newValue && (newValue[nodeKey] || newValue[nodeKey] === 0)) {
|
|
206
175
|
selectedKeys.push(newValue[nodeKey])
|
|
207
176
|
}
|
|
208
|
-
|
|
209
|
-
}
|
|
177
|
+
treeSelectedChange(selectedKeys, newValue ? [newValue] : [], obj)
|
|
178
|
+
}
|
|
210
179
|
// 复选框变化
|
|
211
|
-
onSelectionChange
|
|
212
|
-
let nodeKey =
|
|
180
|
+
const onSelectionChange = obj => {
|
|
181
|
+
let nodeKey = props.nodeKey || 'id'
|
|
213
182
|
let { records = [] } = obj
|
|
214
183
|
let selectedKeys = []
|
|
215
184
|
if (Array.isArray(records) && records.length > 0) {
|
|
216
185
|
selectedKeys = records.map(item => item[nodeKey])
|
|
217
186
|
}
|
|
218
|
-
|
|
219
|
-
}
|
|
187
|
+
treeSelectedChange(selectedKeys, records, obj)
|
|
188
|
+
}
|
|
220
189
|
// 树变化提交
|
|
221
|
-
treeSelectedChange(selectedKeys, selectedRows, obj) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
190
|
+
const treeSelectedChange = (selectedKeys, selectedRows, obj) => {
|
|
191
|
+
treeValue.value = selectedKeys
|
|
192
|
+
emit('select', selectedKeys, selectedRows, obj)
|
|
193
|
+
}
|
|
225
194
|
// 全局搜索过滤事件
|
|
226
|
-
handleMyTableFilter
|
|
227
|
-
const
|
|
228
|
-
const { treeData, labelField, labelFormat, $vUtils, $vxePluginNames, tableRef } = this
|
|
195
|
+
const handleMyTableFilter = text => {
|
|
196
|
+
const { labelField, labelFormat } = props
|
|
229
197
|
let filterText = $vUtils.toValueString(text).trim().toLowerCase()
|
|
230
|
-
let
|
|
198
|
+
let searchData = null
|
|
231
199
|
if (filterText) {
|
|
232
200
|
let noSearchArr = ['$vGlobalOption', '$vImg', '$vCheckbox', '$vRadio', '$vUpload', '$vCode', 'seq', 'checkbox', 'radio']
|
|
233
201
|
const searchProps = [{ rkey: labelField, format: labelFormat }]
|
|
234
|
-
let tableColumnsAll = tableRef
|
|
202
|
+
let tableColumnsAll = tableRef.value.getColumns()
|
|
235
203
|
tableColumnsAll.forEach(col => {
|
|
236
204
|
let renderObj = col.cellRender || col.editRender || col.itemRender
|
|
237
205
|
if (col.property && renderObj && renderObj.name && !noSearchArr.includes(renderObj.name) && !noSearchArr.includes(col.type)) {
|
|
238
206
|
searchProps.push({ rkey: col.property, rname: renderObj.name, rprops: Object.assign({}, renderObj.props, col.rprops) })
|
|
239
207
|
}
|
|
240
208
|
})
|
|
241
|
-
|
|
209
|
+
searchData = $vUtils.searchTree(treeData.value, row => {
|
|
242
210
|
return searchProps.some(item => {
|
|
243
211
|
let cellValue = item.format ? $vUtils.format(item.format, row) : $vUtils.get(row, item.rkey)
|
|
244
212
|
if ($vxePluginNames.expendRenders && $vxePluginNames.expendRenders.includes(item.rname)) {
|
|
245
|
-
let { rtext } = $vUtils.formatRender(cellValue, item.rkey, row, item.rname, item.rprops,
|
|
213
|
+
let { rtext } = $vUtils.formatRender(cellValue, item.rkey, row, item.rname, item.rprops, proxy)
|
|
246
214
|
return String(rtext).toLowerCase().indexOf(filterText) > -1
|
|
247
215
|
}
|
|
248
216
|
return $vUtils.trim(cellValue).toLowerCase().indexOf(filterText) > -1
|
|
249
217
|
})
|
|
250
218
|
})
|
|
251
219
|
}
|
|
252
|
-
if (
|
|
220
|
+
if (filterData.value === null && !filterText) {
|
|
253
221
|
return
|
|
254
222
|
}
|
|
255
|
-
|
|
256
|
-
if (filterData && filterData.length > 0) {
|
|
257
|
-
tableRef
|
|
223
|
+
filterData.value = searchData
|
|
224
|
+
if (filterData.value && filterData.value.length > 0) {
|
|
225
|
+
tableRef.value.setTreeExpand(filterData.value[0], true)
|
|
258
226
|
}
|
|
259
|
-
}
|
|
227
|
+
}
|
|
260
228
|
// 获取选中的数据
|
|
261
|
-
getSelectionData() {
|
|
262
|
-
return
|
|
263
|
-
}
|
|
264
|
-
tableCheckMethods({ row }) {
|
|
265
|
-
if (
|
|
229
|
+
const getSelectionData = () => {
|
|
230
|
+
return tableRef.value.getCheckboxRecords()
|
|
231
|
+
}
|
|
232
|
+
const tableCheckMethods = ({ row }) => {
|
|
233
|
+
if (props.isLeaf && !props.multiple) {
|
|
266
234
|
return +row.isleaf === 1 || +row.isLeaf === 1
|
|
267
235
|
}
|
|
268
236
|
return true
|
|
269
|
-
}
|
|
270
|
-
getTreeNodeCellContent({ row, column }) {
|
|
271
|
-
if (
|
|
272
|
-
return
|
|
237
|
+
}
|
|
238
|
+
const getTreeNodeCellContent = ({ row, column }) => {
|
|
239
|
+
if (props.labelFormat) {
|
|
240
|
+
return $vUtils.format(props.labelFormat, row)
|
|
241
|
+
}
|
|
242
|
+
return $vUtils.get(row, column.property)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const filterChangeDebounce = $vUtils.debounce(handleMyTableFilter, 500)
|
|
246
|
+
|
|
247
|
+
watch(
|
|
248
|
+
() => props.modelValue,
|
|
249
|
+
() => {
|
|
250
|
+
initSelection(true)
|
|
273
251
|
}
|
|
274
|
-
|
|
252
|
+
)
|
|
253
|
+
watch(
|
|
254
|
+
() => props.filterText,
|
|
255
|
+
nv => {
|
|
256
|
+
filterChangeDebounce(nv)
|
|
257
|
+
},
|
|
258
|
+
{ deep: true, immediate: true }
|
|
259
|
+
)
|
|
260
|
+
watch(
|
|
261
|
+
() => props.options,
|
|
262
|
+
nv => {
|
|
263
|
+
treeData.value = nv
|
|
264
|
+
},
|
|
265
|
+
{ immediate: true }
|
|
266
|
+
)
|
|
267
|
+
watch(
|
|
268
|
+
() => treeData.value,
|
|
269
|
+
nv => {
|
|
270
|
+
emit('datacall', nv)
|
|
271
|
+
},
|
|
272
|
+
{ immediate: true }
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
onMounted(() => {
|
|
276
|
+
initMounted()
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
tableRef,
|
|
281
|
+
renderKey,
|
|
282
|
+
treeServerComplate,
|
|
283
|
+
queryErrorText,
|
|
284
|
+
tableConfigIn,
|
|
285
|
+
onRadioChange,
|
|
286
|
+
onSelectionChange,
|
|
287
|
+
getTreeNodeCellContent
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
|
-
}
|
|
290
|
+
})
|
|
278
291
|
</script>
|
|
279
292
|
|
|
280
293
|
<style lang="scss" scoped></style>
|