10金币
本帖最后由 KD尤 于 2021-11-24 10:08 编辑
<template>
<div>
<div class='block' style='margin-bottom: 10px'>
<el-button style='margin-left:15px' type='primary' @click='query'>查询</el-button>
<el-button style='margin-left:15px' type='success' @click='add'>增加</el-button>
<el-button style='margin-left:15px' type='warning' @click='save'>保存</el-button>
<!-- <el-button style='margin-left:15px' type='danger' @click='imputExcelALL'>全局导入EXCEL</el-button>-->
<!-- <el-button style='margin-left:15px' type='danger' @click='imputExcel'>增量导入EXCEL</el-button>-->
</div>
<gc-spread-sheets :hostClass="hostClass" @workbookInitialized="initSpread">
<gc-worksheet :dataSource="tableData">
<gc-column :headerText="'ID'" :dataField="'sid'" :width='150'></gc-column>
<gc-column :headerText="'标题'" :dataField="'title'" :width='150'></gc-column>
<gc-column :headerText="'图标'" :dataField="'icon'" :width='150'></gc-column>
<gc-column :headerText="'路径'" :dataField="'path'" :width='150'></gc-column>
<gc-column :headerText="'是否可见'" :dataField="'visiable'" :cellType="comboBoxCellType" :width='150'></gc-column>
<gc-column :headerText="'菜单级别'" :dataField="'jb'" :width='150'></gc-column>
<gc-column :headerText="'是否包含子菜单'" :dataField="'sfsub'" :width='150'></gc-column>
<gc-column :headerText="'角色'" :dataField="'js'" :width='150'></gc-column>
<gc-column :headerText="'备注'" :dataField="'bz'" :autofit=true></gc-column>
</gc-worksheet>
</gc-spread-sheets>
</div>
</template>
<script>
import GC from '@grapecity/spread-sheets'
export default {
data () {
return {
spread: null,
hostClass: 'spread-host',
tableData: []
}
},
computed: {
comboBoxCellType () {
const cellType = new GC.Spread.Sheets.CellTypes.ComboBox()
cellType.items([
{ text: 'true', value: 'true' },
{ text: 'false', value: 'false' }])
return cellType
}
},
methods: {
initSpread: function (spread) {
this.spread = spread
const worksheet = this.spread.getActiveSheet()
worksheet.setColumnWidth(0, 50.0, GC.Spread.Sheets.SheetArea.rowHeader)
worksheet.setRowHeight(0, 25.0, GC.Spread.Sheets.SheetArea.colHeader)
this.query()
},
query () {
try {
this.postRequest('/loadmenuqx').then(resp => {
if (resp) {
this.tableData = resp.obj
}
})
} catch (e) {
this.tableData = []
}
},
add () {
const worksheet = this.spread.getActiveSheet()
worksheet.addRows(worksheet.getRowCount(), 1)
},
save () {
}
}
}
</script>
<style>
.spread-host {
width: 100%;
height: 750px;
}
</style>
query 改变了gc-worksheet :dataSource绑定的tableData后, worksheet.setColumnWidth(0, 50.0, GC.Spread.Sheets.SheetArea.rowHeader) worksheet.setRowHeight(0, 25.0, GC.Spread.Sheets.SheetArea.colHeader)上面两句和gc-column 里的:cellType="comboBoxCellType",都失效了请教个解决办法,谢谢
|
最佳答案
查看完整内容
如果是想给列头设置值,可以用下面的代码
sheet.setValue(0,2,"ColumnHeader", GC.Spread.Sheets.SheetArea.colHeader);
|