附件是设计的模板,这是我写的代码,有按照你说的方式去写,但是复制的时候还是没有验证。还有复制的时候会报错误
是什么原因呢
- <style scoped>
- </style>
- <template>
- <div class="router-content">
- <div class="layout-content">
- <div :id="spreadParams.domId" style="width:100%; height:800px;border: 1px solid gray;"></div>
- </div>
- </div>
- </template>
- <script type="text/ecmascript-6">
- export default {
- name: 'fillDetailTest',
- data() {
- return{
- spreadParams: {
- domId: 'ss',
- sheetCount: 1,
- spread: null,
- },
- }
- },
- mounted() {
- let spread = new GC.Spread.Sheets.Workbook(
- document.getElementById(this.spreadParams.domId),
- { sheetCount: this.spreadParams.sheetCount });
- spread.options.allowContextMenu = false;
- spread.options.allowUserDragFill = false; //关闭拖拽
- spread.options.defaultDragFillType = 3;//只复制值
- spread.options.allowCopyPasteExcelStyle = false;
- spread.options.highlightInvalidData = true; //验证
- this.$.getJSON("static/data/demo/网点-现金收付业务.ssjson", "", (resp) => {
- spread.fromJSON(resp);
- var sheet = spread.getActiveSheet();
- sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
-
- let cellDataAtEnter = null;
- let validateStatus = true;
- sheet.bind(GC.Spread.Sheets.Events.EditStarting, (error, info) => {
- if (!validateStatus) {
- info.cancel = true;
- return false;
- }
- cellDataAtEnter = sheet.getValue(info.row,info.col);
- });
- sheet.bind(GC.Spread.Sheets.Events.ValidationError, (error, info) => {
- validateStatus = false;
- sheet.setValue(info.row, info.col, cellDataAtEnter || null);
- const errorTitle = info.validator.errorTitle();
- const errorMessage = info.validator.errorMessage();
- alert(errorMessage);
- // this.$Modal.error({
- // title: errorTitle,
- // content: errorMessage,
- // onOk: () => {sheet.setValue(info.row, info.col, cellDataAtEnter || null);validateStatus=true;},
- // onCancel: () => {}
- // });
- });
- let spreadData = {};
- sheet.setDataSource(new GC.Spread.Sheets.Bindings.CellBindingSource(spreadData));
- });
-
- },
- }
- </script>
复制代码
|
|