sh-view 2.2.0 → 2.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sh-view",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "基于vxe-table二次封装",
5
5
  "main": "packages/index.js",
6
6
  "scripts": {
@@ -123,6 +123,7 @@ export default function (props, context, proxy, isForm) {
123
123
  formItemsArr.forEach(item => {
124
124
  item.visible = true
125
125
  item.itemRender.props.disabled = false
126
+ item.slots = undefined
126
127
  })
127
128
  }
128
129
  formOriginItems.value = $vUtils.clone(formItemsArr, true)
@@ -1,14 +1,5 @@
1
- <template>
2
- <vxe-colgroup v-if="isGroup" v-bind="groupConfig">
3
- <template v-for="(child, childIndex) in column.children" :key="childIndex">
4
- <sh-column :column="child"></sh-column>
5
- </template>
6
- </vxe-colgroup>
7
- <vxe-column v-else v-bind="columnConfig"></vxe-column>
8
- </template>
9
-
10
1
  <script>
11
- import { computed, defineComponent, getCurrentInstance, inject, ref } from 'vue'
2
+ import { computed, defineComponent, getCurrentInstance, h, inject, ref, resolveComponent, renderSlot } from 'vue'
12
3
  import { turnColumnItemFilters } from '../js/tableMethods'
13
4
  export default defineComponent({
14
5
  name: 'ShColumn',
@@ -41,12 +32,32 @@ export default defineComponent({
41
32
  const groupConfig = computed(() => {
42
33
  return $vUtils.omit(columnConfig.value, ['children', 'cellRender', 'editRender'])
43
34
  })
35
+ const renderVN = () => {
36
+ let columnSlots = {}
37
+ if (props.column.slots) {
38
+ Object.keys(props.column.slots).map(key => {
39
+ columnSlots[key] = shTable.slots[props.column.slots[key]]
40
+ })
41
+ }
42
+ if (isGroup.value) {
43
+ let childrenList = props.column.children.map(child => {
44
+ return h(resolveComponent('sh-column'), { column: child })
45
+ })
46
+ columnSlots.default = () => childrenList
47
+ return h(resolveComponent('vxe-colgroup'), { ...groupConfig.value }, columnSlots)
48
+ }
49
+ return h(resolveComponent('vxe-column'), { ...columnConfig.value }, columnSlots)
50
+ }
44
51
 
45
52
  return {
46
53
  isGroup,
47
54
  columnConfig,
48
- groupConfig
55
+ groupConfig,
56
+ renderVN
49
57
  }
58
+ },
59
+ render() {
60
+ return this.renderVN()
50
61
  }
51
62
  })
52
63
  </script>
@@ -76,7 +76,7 @@ export const turnColumnItemFilters = (column, props) => {
76
76
  case '$vCheckgroup':
77
77
  case '$vRadiogroup':
78
78
  case '$vSwitch':
79
- column.filters = Array.isArray(columnRender.props && columnRender.props.options) ? columnRender.props.options : false
79
+ column.filters = Array.isArray(columnRender.props && columnRender.props.options) ? columnRender.props.options : []
80
80
  column.filterMultiple = true
81
81
  break
82
82
  case '$vInput':
@@ -125,10 +125,6 @@
125
125
  <template #empty>
126
126
  <sh-empty :icon="emptyIcon" :content="emptyText"></sh-empty>
127
127
  </template>
128
- <template v-for="slot in tableSlots" #[slot]="scope">
129
- <!-- 以之前的名字命名插槽,同时把数据原样绑定 -->
130
- <slot :name="slot" v-bind="scope"></slot>
131
- </template>
132
128
  </vxe-table>
133
129
  <div v-if="isFootSlot" ref="footSlotRef" v-resize="handleResize" class="sh-table-foot"><slot name="foot"></slot></div>
134
130
  <div v-if="isPagerSlot" ref="pagerSlotRef" v-resize="handleResize" class="sh-table-pager">
@@ -230,7 +226,8 @@ export default defineComponent({
230
226
 
231
227
  provide('ShTableInstance', {
232
228
  columnObjConfig: useTableHooks.tableColumnObjConfig,
233
- turnColumnItemFilters: useTableHooks.turnColumnItemFilters
229
+ turnColumnItemFilters: useTableHooks.turnColumnItemFilters,
230
+ slots: useTableHooks.slots
234
231
  })
235
232
 
236
233
  const handleResize = e => {