sh-view 2.8.9 → 2.8.11

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.8.9",
3
+ "version": "2.8.11",
4
4
  "description": "基于vxe-table二次封装,更包含Alert,Badge,Card,CodeEditor,Col,Corner,CountTo,Drawer,Empty,Form,Header,Icon,List,Loading,Modal,Noticebar,Poptip,Progress,PullRefresh,Query,Result,Row,Split,Grid,Table,Tabs,Tag,Toolbar,Tree,Upload,WaterFall,WaterMark等丰富组件库",
5
5
  "main": "packages/index.js",
6
6
  "typings": "types/index.d.ts",
@@ -82,10 +82,6 @@
82
82
  <template #empty>
83
83
  <sh-empty :icon="emptyIcon" :content="emptyText"></sh-empty>
84
84
  </template>
85
- <template v-for="slot in tableSlots" #[slot]="scope">
86
- <!-- 以之前的名字命名插槽,同时把数据原样绑定 -->
87
- <slot :name="slot" v-bind="scope"></slot>
88
- </template>
89
85
  </vxe-grid>
90
86
  <!--导入弹窗-->
91
87
  <importModal v-if="importBindConfig.modalConfig.modelValue" v-bind="importBindConfig" @confirm="setImportData"></importModal>
@@ -252,7 +252,6 @@ export default {
252
252
  type: Boolean, // 表格是否可编辑,默认不可编辑
253
253
  default: true
254
254
  },
255
- customLayout: Boolean,
256
255
  columnObj: {
257
256
  type: Object,
258
257
  default() {
@@ -32,7 +32,7 @@ export const columnDefaultFilterMethod = ({ column, $columnIndex }) => {
32
32
  }
33
33
 
34
34
  // 默认求底部计算方法(已改用footer渲染器,其他需要自行计算)
35
- export const tableFooterCompute = (columns, fullData, computeType, typeObj = {}) => {
35
+ export const tableFooterCompute = (columns, tableData, computeType, typeObj = {}) => {
36
36
  const { emptyText = '', name, data = {} } = typeObj
37
37
  let computeName = name || ''
38
38
  if (!computeName) {
@@ -58,9 +58,9 @@ export const tableFooterCompute = (columns, fullData, computeType, typeObj = {})
58
58
  let footerValue = data[column.property] || emptyText
59
59
  if (renderName === '$vMoney' || renderProps.calculate) {
60
60
  if (computeType === 'subTotal') {
61
- footerValue = $vUtils.sum(fullData, column.property)
61
+ footerValue = $vUtils.sum(tableData, column.property)
62
62
  } else if (computeType === 'mean') {
63
- footerValue = $vUtils.mean(fullData, column.property)
63
+ footerValue = $vUtils.mean(tableData, column.property)
64
64
  }
65
65
  }
66
66
  return footerValue
@@ -103,12 +103,21 @@ export const getFieldRules = (ori, rules) => {
103
103
  }
104
104
  }
105
105
  // 转换生成新表头数据
106
- export const getTransfarFields = (oriArr = [], columnObj, isSearch) => {
106
+ export const getTransfarFields = (oriArr = [], { slots, columnObj, isSearch }) => {
107
107
  let rules = {}
108
108
  let columnsFlatArr = []
109
109
  let formItemsArr = []
110
110
  let columnsArr = $vUtils.mapTree(oriArr, ori => {
111
- let tar = Object.assign({}, columnObj, ori)
111
+ let slotObj = {}
112
+ // 将插槽转换为函数式
113
+ if (slots && ori.slots) {
114
+ Object.keys(ori.slots).forEach(slotKey => {
115
+ if ($vUtils.isString(ori.slots[slotKey])) {
116
+ $vUtils.set(slotObj, `slots.${slotKey}`, slots[ori.slots[slotKey]])
117
+ }
118
+ })
119
+ }
120
+ let tar = Object.assign({}, columnObj, ori, slotObj)
112
121
  if (ori.children && ori.children.length > 0) {
113
122
  tar.sortable = false
114
123
  tar.filter = false
@@ -168,7 +168,7 @@ export default function (props, context, proxy, isGrid) {
168
168
  })
169
169
  const tableFilterConfig = computed(() => Object.assign({ clearable: true, type: 'search', placeholder: '全局关键字搜索' }, tableVmConfig.value))
170
170
  const tableSlots = computed(() => {
171
- let disSlots = ['head', 'form', 'formLeft', 'formRight', 'toolbar', 'toolbarLeft', 'toolbarRight', 'pagerLeft', 'pagerRight']
171
+ let disSlots = ['top', 'head', 'foot', 'form', 'toolbar', 'formLeft', 'formRight', 'toolbarLeft', 'toolbarRight', 'pagerLeft', 'pagerRight']
172
172
  return Object.keys(slots).filter(key => !disSlots.includes(key))
173
173
  })
174
174
  const tableBindConfig = computed(() => {
@@ -231,13 +231,12 @@ export default function (props, context, proxy, isGrid) {
231
231
  }
232
232
 
233
233
  // 默认求底部绑定方法vxe
234
- const tableFooterMethod = ({ columns }) => {
234
+ const tableFooterMethod = ({ columns, data }) => {
235
235
  const { footerCalculate } = props
236
- const fullData = getFullData()
237
236
  let footerData = []
238
237
  let footerCalculateList = footerCalculate.calculate || []
239
238
  footerCalculateList.forEach(computeType => {
240
- footerData.push(tableFooterCompute(columns, fullData, computeType, footerCalculate[computeType]))
239
+ footerData.push(tableFooterCompute(columns, data, computeType, footerCalculate[computeType]))
241
240
  })
242
241
  return footerData
243
242
  }
@@ -260,7 +259,7 @@ export default function (props, context, proxy, isGrid) {
260
259
  selectionRows.value = selections
261
260
  }
262
261
  const updateExpended = () => {
263
- if (tableRef.value && tableTreeConfig.value.expandAll) {
262
+ if (tableRef.value && tableTreeConfig.value && tableTreeConfig.value.expandAll) {
264
263
  setTimeout(() => {
265
264
  tableRef.value.setAllTreeExpand(true)
266
265
  })
@@ -405,7 +404,7 @@ export default function (props, context, proxy, isGrid) {
405
404
 
406
405
  // 初始化生成新表头数据
407
406
  const initTableColumns = () => {
408
- let transResult = getTransfarFields(props.columns, tableColumnObjConfig.value, tableGlobalConfig.value.search)
407
+ let transResult = getTransfarFields(props.columns, { slots, columnObj: tableColumnObjConfig.value, isSearch: tableGlobalConfig.value.search })
409
408
  tableColumnsFlat.value = transResult.columnsFlatArr
410
409
  tableFormItems.value = transResult.formItemsArr
411
410
  tableColumnsFixed.value = transResult.columnsArr
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div ref="tableWrapRef" class="sh-vxe-table" :class="{ 'sh-table-ghost': tableGlobalConfig.ghost, 'is--loading': tableBindConfig.loading }" :style="{ height: wrapHeight }">
2
+ <div ref="tableWrapRef" v-resize="handleResize" class="sh-vxe-table" :class="{ 'sh-table-ghost': tableGlobalConfig.ghost, 'is--loading': tableBindConfig.loading }" :style="{ height: wrapHeight }">
3
3
  <div v-if="isTopSlot" ref="topSlotRef" v-resize="handleResize" class="sh-table-top"><slot name="top"></slot></div>
4
4
  <div v-if="isFormSlot" ref="formSlotRef" v-resize="handleResize" class="sh-table-form">
5
5
  <slot name="form">
@@ -68,9 +68,6 @@
68
68
  @toolbar-button-click="onToolbarButtonClick"
69
69
  @toolbar-tool-click="onToolbarToolClick"
70
70
  @option-click="handleGoptionClick">
71
- <template v-if="customLayout">
72
- <slot></slot>
73
- </template>
74
71
  <template #empty>
75
72
  <sh-empty :icon="emptyIcon" :content="emptyText"></sh-empty>
76
73
  </template>