sh-view 2.6.3 → 2.6.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/README.md +70 -24
- package/package.json +1 -1
- package/packages/components/global-components/sh-table/components/sh-column.vue +68 -69
- package/packages/components/global-components/sh-table/js/useTable.js +12 -6
- package/packages/vxeTable/render/cell/vxe-render-table.vue +51 -51
- package/packages/vxeTable/render/mixin/cell-hooks.js +4 -1
package/README.md
CHANGED
|
@@ -1,39 +1,85 @@
|
|
|
1
1
|
# sh-view
|
|
2
2
|
|
|
3
3
|
#### 介绍
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
|
4
|
+
1. 基于vxe-table扩展,功能更强大,配置更便捷,内置18种渲染器,灵活配置,足以满足您的业务需求!
|
|
5
|
+
2. 完全兼容vxe-table原有组件及功能,完全可以自主扩展更多的自定义组件
|
|
7
6
|
|
|
8
|
-
####
|
|
9
|
-
|
|
7
|
+
#### 组件
|
|
8
|
+
自封装组件,不依赖其他ui框架
|
|
9
|
+
1. 默认全局安装:
|
|
10
|
+
ShAlert,
|
|
11
|
+
ShBadge,
|
|
12
|
+
ShCard,
|
|
13
|
+
ShCodeEditor,
|
|
14
|
+
ShCol,
|
|
15
|
+
ShCorner,
|
|
16
|
+
ShCountTo,
|
|
17
|
+
ShDrawer,
|
|
18
|
+
ShEmpty,
|
|
19
|
+
ShForm,
|
|
20
|
+
ShHeader,
|
|
21
|
+
ShIcon,
|
|
22
|
+
ShImage,
|
|
23
|
+
ShList,
|
|
24
|
+
ShLoading,
|
|
25
|
+
ShModal,
|
|
26
|
+
ShNoticebar,
|
|
27
|
+
ShPoptip,
|
|
28
|
+
ShProgress,
|
|
29
|
+
ShPullRefresh,
|
|
30
|
+
ShQuery,
|
|
31
|
+
ShResult,
|
|
32
|
+
ShRow,
|
|
33
|
+
ShSplit,
|
|
34
|
+
ShGrid,
|
|
35
|
+
ShTable,
|
|
36
|
+
ShTabs,
|
|
37
|
+
ShTag,
|
|
38
|
+
ShToolbar,
|
|
39
|
+
ShTree,
|
|
40
|
+
ShUpload,
|
|
41
|
+
ShWaterFall,
|
|
42
|
+
ShWaterMark
|
|
10
43
|
|
|
44
|
+
2. 手动安装(业务):
|
|
45
|
+
ShCronModal(cron表达式),
|
|
46
|
+
ShMarkdown(富文本编辑),
|
|
47
|
+
ShMenu(菜单、支持竖向、横向、收起)
|
|
11
48
|
|
|
12
49
|
#### 安装教程
|
|
50
|
+
版本:[vue](https://www.npmjs.com/package/vue) 3.x
|
|
51
|
+
```shell
|
|
52
|
+
npm install sh-tools sh-view@next
|
|
53
|
+
```
|
|
54
|
+
```javascript
|
|
55
|
+
import { createApp } from 'vue'
|
|
56
|
+
import ShView from 'sh-view'
|
|
13
57
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
3. xxxx
|
|
58
|
+
createApp(App).use(ShView).mount('#app')
|
|
59
|
+
```
|
|
17
60
|
|
|
18
61
|
#### 使用说明
|
|
19
62
|
|
|
20
|
-
1.
|
|
21
|
-
2.
|
|
22
|
-
3. xxxx
|
|
63
|
+
1. 暂无文档,请参考示例或者组件api
|
|
64
|
+
2. 作者QQ:577754811
|
|
23
65
|
|
|
24
|
-
#### 参与贡献
|
|
25
66
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
4. 新建 Pull Request
|
|
67
|
+
#### 功能计划
|
|
68
|
+
* [x] v2.6.4 基于 vxe4.+,包含vxe-table所有功能,扩展更强渲染器
|
|
69
|
+
* [ ] 下一阶段:独立vxe的日历组件,独立范围选择日期渲染器;低代码配置;基础sh-view的admin系统开源(包含低代码设计模板,及系统鉴权、路由守卫等)
|
|
30
70
|
|
|
31
71
|
|
|
32
|
-
####
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
72
|
+
#### 项目预览
|
|
73
|
+
<img alt="img.png" src="examples/assets/img/img.png" width="100%"/>
|
|
74
|
+
<img alt="img_1.png" src="examples/assets/img/img_1.png" width="49%"/>
|
|
75
|
+
<img alt="img_2.png" src="examples/assets/img/img_2.png" width="49%"/>
|
|
76
|
+
<img alt="img_3.png" src="examples/assets/img/img_3.png" width="49%"/>
|
|
77
|
+
<img alt="img_4.png" src="examples/assets/img/img_4.png" width="49%"/>
|
|
78
|
+
<img alt="img_5.png" src="examples/assets/img/img_5.png" width="49%"/>
|
|
79
|
+
<img alt="img_6.png" src="examples/assets/img/img_6.png" width="49%"/>
|
|
80
|
+
<img alt="img_7.png" src="examples/assets/img/img_7.png" width="49%"/>
|
|
81
|
+
<img alt="img_8.png" src="examples/assets/img/img_8.png" width="49%"/>
|
|
82
|
+
<img alt="img_9.png" src="examples/assets/img/img_9.png" width="49%"/>
|
|
83
|
+
<img alt="img_10.png" src="examples/assets/img/img_10.png" width="49%"/>
|
|
84
|
+
<img alt="img_11.png" src="examples/assets/img/img_11.png" width="49%"/>
|
|
85
|
+
<img alt="img_12.png" src="examples/assets/img/img_12.png" width="49%"/>
|
package/package.json
CHANGED
|
@@ -1,69 +1,68 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { computed, defineComponent, getCurrentInstance, h, inject, ref, resolveComponent, renderSlot } from 'vue'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
config.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<style scoped lang="scss"></style>
|
|
1
|
+
<script>
|
|
2
|
+
import { computed, defineComponent, getCurrentInstance, h, inject, ref, resolveComponent, renderSlot } from 'vue'
|
|
3
|
+
export default defineComponent({
|
|
4
|
+
name: 'ShColumn',
|
|
5
|
+
props: {
|
|
6
|
+
column: {
|
|
7
|
+
type: Object
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
setup(props, context) {
|
|
11
|
+
const { proxy } = getCurrentInstance()
|
|
12
|
+
const { $vUtils } = proxy
|
|
13
|
+
const shTable = inject('ShTableInstance')
|
|
14
|
+
|
|
15
|
+
const isGroup = computed(() => {
|
|
16
|
+
return proxy.hasChildren(props.column)
|
|
17
|
+
})
|
|
18
|
+
const columnConfig = computed(() => {
|
|
19
|
+
let renderObj = { name: props.column.renderName, props: props.column.renderProps }
|
|
20
|
+
let config = Object.assign({}, shTable.columnObjConfig, props.column)
|
|
21
|
+
if (props.column.readonly) {
|
|
22
|
+
config.cellRender = config.cellRender || renderObj
|
|
23
|
+
} else {
|
|
24
|
+
config.editRender = config.editRender || renderObj
|
|
25
|
+
}
|
|
26
|
+
if (config.renderName === '$vMoney' && props.column.renderProps.bill) {
|
|
27
|
+
config.filter = false
|
|
28
|
+
config.headerClassName += ' header-bill-cell'
|
|
29
|
+
}
|
|
30
|
+
if (config.filter === true || Number(config.filter) === 1) {
|
|
31
|
+
shTable.turnColumnItemFilters(config, renderObj.props)
|
|
32
|
+
}
|
|
33
|
+
return $vUtils.omit(config, ['children', 'renderName', 'renderProps', 'renderRequire', 'requireProps'])
|
|
34
|
+
})
|
|
35
|
+
const groupConfig = computed(() => {
|
|
36
|
+
return $vUtils.omit(columnConfig.value, ['cellRender', 'editRender'])
|
|
37
|
+
})
|
|
38
|
+
const renderVN = () => {
|
|
39
|
+
let columnSlots = {}
|
|
40
|
+
if (props.column.slots) {
|
|
41
|
+
Object.keys(props.column.slots).map(key => {
|
|
42
|
+
columnSlots[key] = shTable.slots[props.column.slots[key]]
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
if (isGroup.value) {
|
|
46
|
+
let childrenList = props.column.children.map(child => {
|
|
47
|
+
return h(resolveComponent('sh-column'), { column: child })
|
|
48
|
+
})
|
|
49
|
+
columnSlots.default = () => childrenList
|
|
50
|
+
return h(resolveComponent('vxe-colgroup'), { ...groupConfig.value }, columnSlots)
|
|
51
|
+
}
|
|
52
|
+
return h(resolveComponent('vxe-column'), { ...columnConfig.value }, columnSlots)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
isGroup,
|
|
57
|
+
columnConfig,
|
|
58
|
+
groupConfig,
|
|
59
|
+
renderVN
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
render() {
|
|
63
|
+
return this.renderVN()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<style scoped lang="scss"></style>
|
|
@@ -204,7 +204,7 @@ export default function (props, context, proxy, isGrid) {
|
|
|
204
204
|
let cellValue = $vUtils.get(row, property)
|
|
205
205
|
if (!$vUtils.isNone(cellValue)) {
|
|
206
206
|
let { rvalue, rtext } = $vUtils.formatRender(cellValue, property, row, rname, rprops, proxy)
|
|
207
|
-
$vUtils.set(row, property, visible
|
|
207
|
+
$vUtils.set(row, property, visible ? rtext : rvalue)
|
|
208
208
|
}
|
|
209
209
|
if (deleteXid) delete row._XID
|
|
210
210
|
})
|
|
@@ -302,11 +302,17 @@ export default function (props, context, proxy, isGrid) {
|
|
|
302
302
|
// 只对 edit-config 配置时有效,单元格编辑状态下被关闭时会触发该事件
|
|
303
303
|
const onEditClosed = params => {
|
|
304
304
|
// 此操作火狐浏览器(bug(vxe):编辑后不触发渲染器的blur问题)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
$vUtils.
|
|
309
|
-
|
|
305
|
+
const userAgent = navigator.userAgent
|
|
306
|
+
if (userAgent.indexOf('Firefox') !== -1) {
|
|
307
|
+
let { row, column } = params
|
|
308
|
+
let editModel = $vUtils.get(column, 'params.__RowEditModelValue')
|
|
309
|
+
if (editModel !== undefined) {
|
|
310
|
+
if (['$vMoney'].includes(column.rname) && !$vUtils.isNone(editModel)) editModel = $vUtils.multiply(editModel, column.rprops.moneyUnit || 1)
|
|
311
|
+
let { rvalue, rtext } = $vUtils.formatRender(editModel, column.property, row, column.rname, column.rprops, proxy, true)
|
|
312
|
+
editModel = rvalue
|
|
313
|
+
$vUtils.set(row, column.property, editModel)
|
|
314
|
+
delete column.params.__RowEditModelValue
|
|
315
|
+
}
|
|
310
316
|
}
|
|
311
317
|
emit('edit-closed', params)
|
|
312
318
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span class="vxe-render--inner" style="display: inline-grid; width: 100%">
|
|
3
|
-
<sh-table
|
|
4
|
-
ref="shTableRef"
|
|
5
|
-
:disabled="!redit && !isEditAll"
|
|
6
|
-
v-bind="rprops"
|
|
7
|
-
:size="rsize"
|
|
8
|
-
:data-sourse="renderValue"
|
|
9
|
-
@edit-closed="vxeInputCallback"
|
|
10
|
-
@toolbaroption="onToolbaroption"></sh-table>
|
|
11
|
-
</span>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script>
|
|
15
|
-
import { defineComponent, getCurrentInstance, ref } from 'vue'
|
|
16
|
-
import cellProps from '../mixin/cell-props'
|
|
17
|
-
import cellHooks from '../mixin/cell-hooks'
|
|
18
|
-
export default defineComponent({
|
|
19
|
-
name: 'VxeRenderTable',
|
|
20
|
-
props: cellProps,
|
|
21
|
-
setup(props, context) {
|
|
22
|
-
const { proxy } = getCurrentInstance()
|
|
23
|
-
const useCell = cellHooks(props, context, proxy)
|
|
24
|
-
const shTableRef = ref()
|
|
25
|
-
|
|
26
|
-
const fullData = () => {
|
|
27
|
-
return shTableRef.value.getFullData()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 输入框回调
|
|
31
|
-
const vxeInputCallback = ({ $table, row }) => {
|
|
32
|
-
driveBackData()
|
|
33
|
-
}
|
|
34
|
-
// 新增、删除行回调
|
|
35
|
-
const onToolbaroption = (code, data, $table) => {
|
|
36
|
-
driveBackData()
|
|
37
|
-
}
|
|
38
|
-
// 回填数据
|
|
39
|
-
const driveBackData = value => {
|
|
40
|
-
useCell.setRenderValue(fullData(), true)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...useCell,
|
|
45
|
-
shTableRef,
|
|
46
|
-
vxeInputCallback,
|
|
47
|
-
onToolbaroption
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<span class="vxe-render--inner" style="display: inline-grid; width: 100%">
|
|
3
|
+
<sh-table
|
|
4
|
+
ref="shTableRef"
|
|
5
|
+
:disabled="!redit && !isEditAll"
|
|
6
|
+
v-bind="rprops"
|
|
7
|
+
:size="rsize"
|
|
8
|
+
:data-sourse="renderValue"
|
|
9
|
+
@edit-closed="vxeInputCallback"
|
|
10
|
+
@toolbaroption="onToolbaroption"></sh-table>
|
|
11
|
+
</span>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { defineComponent, getCurrentInstance, ref } from 'vue'
|
|
16
|
+
import cellProps from '../mixin/cell-props'
|
|
17
|
+
import cellHooks from '../mixin/cell-hooks'
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
name: 'VxeRenderTable',
|
|
20
|
+
props: cellProps,
|
|
21
|
+
setup(props, context) {
|
|
22
|
+
const { proxy } = getCurrentInstance()
|
|
23
|
+
const useCell = cellHooks(props, context, proxy)
|
|
24
|
+
const shTableRef = ref()
|
|
25
|
+
|
|
26
|
+
const fullData = () => {
|
|
27
|
+
return shTableRef.value.getFullData({ deleteXid: true })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 输入框回调
|
|
31
|
+
const vxeInputCallback = ({ $table, row }) => {
|
|
32
|
+
driveBackData()
|
|
33
|
+
}
|
|
34
|
+
// 新增、删除行回调
|
|
35
|
+
const onToolbaroption = (code, data, $table) => {
|
|
36
|
+
driveBackData()
|
|
37
|
+
}
|
|
38
|
+
// 回填数据
|
|
39
|
+
const driveBackData = value => {
|
|
40
|
+
useCell.setRenderValue(fullData(), true)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...useCell,
|
|
45
|
+
shTableRef,
|
|
46
|
+
vxeInputCallback,
|
|
47
|
+
onToolbaroption
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
</script>
|
|
@@ -102,7 +102,10 @@ export default function (props, context, proxy) {
|
|
|
102
102
|
const setRenderValue = (value, isCall) => {
|
|
103
103
|
let cellValue = value || renderValue.value
|
|
104
104
|
if (!isCall) {
|
|
105
|
-
if (['$vMoney'].includes(props.rname) && !$vUtils.isNone(cellValue))
|
|
105
|
+
if (['$vMoney'].includes(props.rname) && !$vUtils.isNone(cellValue)) {
|
|
106
|
+
if (props.rprops.commafy) cellValue = String(cellValue).replace(',', '')
|
|
107
|
+
cellValue = $vUtils.multiply(cellValue, props.rprops.moneyUnit || 1)
|
|
108
|
+
}
|
|
106
109
|
let { rvalue, rtext } = formatValueFun(cellValue, true)
|
|
107
110
|
cellValue = rvalue
|
|
108
111
|
}
|