spreadjs v14.0.9
问题描述:
1、在vue中spread使用vuex进行管理,进入项目初始化的时候绑定事件监听,这时可以监听到spread事件变动;
2、动态新增sheet后发现spread监听事件不起作用
监听代码:
- workbookInitialized: function (spread) {
- spread.fromJSON(this.ssjson);
- this.spreadConfig(spread);
- this.spread = spread;
- this.$store.commit("SET_SPREAD", this.spread);
- this.spreadListen(); //监听
- },
- spreadListen() {
- this.spread.bind(GC.Spread.Sheets.Events.ActiveSheetChanged, function (e, info) {
- console.log("ActiveSheetChanged:", info);
- } );
- this.spread.bind(GC.Spread.Sheets.Events.ValueChanged, function (e, info) {
- console.log("spread值改变:", info);
- });
- },
复制代码
动态添加sheet页代码:
- newSheets(needCreateSheets) {
- let json = this.$store.state.templateSheetJson;
- let spread = this.$store.state.spread;
- let sheetCount = spread.getSheetCount();
- spread.suspendEvent();
- needCreateSheets.forEach((value, index) => {
- let nameItem = this.checkList.find((item) => {
- return item.value === value;
- });
- let name = nameItem.text;
- json.name = name;
- let newSheet = new GC.Spread.Sheets.Worksheet(name);
- spread.addSheet(sheetCount + index, newSheet);
- //newSheet导入json("复制"模板)
- newSheet.fromJSON(json);
- //选择newSheet
- spread.setActiveSheetIndex(sheetCount + index);
- this.sheetsTag.push(value);
- });
- spread.suspendEvent();
- this.$store.commit("SET_SPREAD", spread);
- this.$store.commit("SET_SHEETS_TAG", this.sheetsTag);
- },
复制代码
具体代码见附件
spread组件代码路径:\src\components\common\spread\SpreadSheets.vue
动态新增sheet代码路径:\src\views\CCL\ColorFastness.vue
|
|