找回密码
 立即注册

QQ登录

只需一步,快速开始

Wilson.Zhang
超级版主   /  发表于:2024-9-4 09:31:13
11#
kelvinChen 发表于 2024-9-4 08:56
spread和designer都尝试进行销毁

看您提供的代码片段并无异常,销毁Designer后重新进入designerInitialized方法之前是否有可用的Designer实例呢?如果没有,需要先创建Designer实例,才能继续通过Designer获取Workbook。如果在重新进入designerInitialized方法前已创建可用的Designer实例,可能有其他业务代码影响,需要您提供一个能够复现该问题的完整demo,我们根据demo分析。
回复 使用道具 举报
kelvinChen
金牌服务用户   /  发表于:2024-9-4 10:26:38
12#
  1. <script>
  2. import GC from "@grapecity/spread-sheets";
  3. import {
  4.   seGetReportAllData,
  5.   seReportPublishing,
  6.   seGetRegularList,
  7.   seSaveReportSourceData,
  8.   seAddRegularItem,
  9.   seSaveReportStyleData,
  10.   getReportDataSource,
  11. } from "@/api/se-report-design";
  12. import dataConnectDia from "./se-report-compoment/dataConnectDia.vue";
  13. import localReRule from "@/utils/local-re-rule.js";
  14. import { checkRules, regRules } from "./ruleConfig.js";
  15. import { VerificationRules, MultipleChoiceVerification } from "./config";
  16. import { permissionVerification } from "@/utils/se-permission-verification";
  17. import { seGetSystemDictionary } from "@/api/se-admin/se-admin-data-manage/se-admin-dictionary.js";
  18. import dialogCom from "./compoment/dialogCom.vue"
  19. import axios from "axios";
  20. GC.Spread.Common.CultureManager.culture("zh-cn");
  21. this.GC = GC;
  22. let _this;
  23. export default {
  24.   components: { dataConnectDia,dialogCom },
  25.   name: "CreatReport",
  26.   data() {
  27.     return {
  28.       test:"11111",
  29.       styleInfo: { height: "800px", width: "100%", border: "solid black 1px" },
  30.       config: null,
  31.       designer: null,
  32.       dataTable: null,
  33.       spread: null,
  34.       sheets: null,
  35.       designerBindingPathSchema: null,
  36.       jsonStr: null,
  37.       // 配置
  38.       import_bindingSource: true,
  39.       import_noFormula: false,
  40.       import_noStyle: false,
  41.       import_rowHeaders: false,
  42.       import_columnHeaders: false,
  43.       import_donotrecalculateafterload: false,
  44.       noFormula: false,
  45.       noStyle: false,
  46.       SaveCustomRowHeaders: false,
  47.       SaveCustomColumnHeaders: false,

  48.       // 设计器编辑配置
  49.       designer2: null,
  50.       dataTable2: null,
  51.       spread2: null,

  52.       //自定义函数
  53.       customFunctions: {},

  54.       //当前数据源配置
  55.       curSource: {},

  56.       //loading状态更新
  57.       isLoading: true,

  58.       //审核点输入文字
  59.       auditpoints: "",
  60.       //填报要求文字
  61.       wordRequest: "",
  62.       curCellRow: "",
  63.       curCellCol: "",

  64.       sendRegOption: [],

  65.       dialogVisible: false,
  66.       regObj: {
  67.         995: {
  68.           name: "数字",
  69.           des: "数字",
  70.           re: /^(\-|\+)?\d+(\.\d+)?$/,
  71.         },
  72.         110000: {
  73.           name: "最少9个",
  74.           des: "最少9个选择",
  75.           max: 11,
  76.         },
  77.       },
  78.       isRequire: false, // 是否必填
  79.       regStatus: "选择", // 用于显示校验规则的状态
  80.       regOption: [], // 用于显示校验规则的选项列表
  81.       regDataObj: {
  82.         input: "",
  83.         name: "",
  84.         des: "",
  85.         select: "995",
  86.       },
  87.       // 用于输入正则校验规则的输入框的值
  88.       curCellReg: "",
  89.       //弹出框校验模式
  90.       diaMode: "reg", // reg正则   checkBox多选校验

  91.       checkOption: [], // 用于显示校验规则的选项列表
  92.       checkDataObj: {
  93.         min: "",
  94.         max: "",
  95.         name: "",
  96.         des: "",
  97.         select: "110000",
  98.       }, // 用于输入正则校验规则的输入框的值

  99.       //数据关联dia控制
  100.       dialogDataConnect: false,

  101.       //多选数据关联其他
  102.       multipleDataConnect: [],

  103.       //多选框添加的校验规则
  104.       checkRules: checkRules,
  105.       //正则添加的校验规则
  106.       regRule: regRules,
  107.       //动态尺寸
  108.       timer: false,
  109.       screenWidth: document.body.clientWidth,
  110.       permissionVerification: permissionVerification,
  111.       getAllUsedDataSourceArr: [],
  112.       reWriteDia: false,
  113.       reWriteSelect: "",
  114.       openInitPassDia: false,
  115.       lostBinging: [],
  116.       // 回填数据选择列表
  117.       backWriteList: [],
  118.       sourceList: [], //数据源列表
  119.       selectSourceView: "", //当前选择的数据源
  120.       sourceLocation: false, //当前查看数据源绑定对应单元格弹窗
  121.       sourceLocationList: [], //数据源绑定对应单元格列表
  122.       useSource: {}, // 存储当前数据源绑定的单元格
  123.       useDialog: false, //是否弹出框
  124.       showList: [], //当前数据源绑定的单元格列表
  125.     };
  126.   },
  127.   created() {
  128.     console.log(this.$route);
  129.     _this = this;
  130.   },
  131.   async mounted() {
  132.     window.addEventListener("resize", () => {
  133.       this.screenWidth = document.body.clientWidth;
  134.     });
  135.     _this.config = this.initRibbon();
  136.       let designer = new GC.Spread.Sheets.Designer.Designer(
  137.         document.getElementById("designer-content"),
  138.         _this.config
  139.       );
  140.       this.designerInitialized(designer);
  141.     // if (!this.designer) {
  142.       
  143.     // }
  144.     // 加载编辑数据
  145.     const { type, reportId } = this.$route.query;
  146.     if (type == "edit" && reportId) {
  147.       let styleRes = {};
  148.       // 字典数据
  149.       let strRes = {
  150.         $schema: "http://json-schema.org/draft-04/schema#",
  151.         properties: {},
  152.         type: "object",
  153.       };
  154.       //获取字典数据
  155.       let data = null;
  156.       if (this.$route.query.template) {
  157.         let res = await seGetSystemDictionary({
  158.           prefix: true,
  159.         });
  160.         data = res.data.data;
  161.       } else {
  162.         let res = await getReportDataSource(this.$route.query.projectId);
  163.         data = res.data.data;
  164.       }
  165.       // 固定的回填字段
  166.       this.backWriteList.push({
  167.         label: "社会统一编码",
  168.         value: "socialCode",
  169.       });
  170.       this.backWriteList.push({
  171.         label: "企业名称",
  172.         value: "businessName",
  173.       });
  174.       //获取报表样式与源数据
  175.       let {
  176.         data: {
  177.           data: { reportStyle, customDataFields },
  178.         },
  179.         status,
  180.       } = await seGetReportAllData(reportId);
  181.       if (status === 200) {
  182.         if (customDataFields) {
  183.           // 获取回填字段列表
  184.           customDataFields.forEach((item) => {
  185.             this.backWriteList.push({
  186.               label: item.cnName,
  187.               value: item.id,
  188.             });
  189.           });
  190.         }
  191.         if (reportStyle) {
  192.           //请求线上的数据,暂定是使用axios请求传来的url uploadType 0 代表本地 1 代表 阿里云 2 代表 天翼云
  193.           if (reportStyle.uploadType != 0 && reportStyle.filePath) {
  194.             await new Promise((resolve, reject) => {
  195.               axios.get(reportStyle.filePath).then((res) => {
  196.                 if (res.status == 200) {
  197.                   styleRes = res.data;
  198.                   resolve(res.data);
  199.                 } else {
  200.                   resolve("error");
  201.                 }
  202.               });
  203.             });
  204.           } else if (reportStyle.uploadType == 0 && reportStyle.reportJson) {
  205.             styleRes = JSON.parse(reportStyle.reportJson); //读取线下资源
  206.           }
  207.         }
  208.         let properties = {};
  209.         data.forEach((item) => {
  210.           if (item.dataFieldType !== "table") {
  211.             properties[item.name] = {
  212.               dataFieldType: item.dataFieldType,
  213.               type: item.type,
  214.               id: item.id,
  215.               properties: item.extra ? JSON.parse(item.extra) : null,
  216.             };
  217.           } else {
  218.             properties[item.name] = {
  219.               dataFieldType: item.dataFieldType,
  220.               type: item.type,
  221.               id: item.id,
  222.               items: item.extra ? JSON.parse(item.extra) : null,
  223.             };
  224.           }
  225.         });
  226.         strRes.properties = properties;
  227.         _this.curSource = properties;
  228.       }
  229.       this.initDesigner(styleRes, strRes);
  230.     }
  231.     this.isLoading = false;
  232.     this.listenCellEvent();
  233.     this.curCellCol = this.getActiveSheet().getSelections()[0].col;
  234.     this.curCellRow = this.getActiveSheet().getSelections()[0].row;
  235.     let curSourceList = JSON.parse(
  236.       _this.designer.getData("updatedTreeNode") ||
  237.         _this.designer.getData("oldTreeNodeFromJson")
  238.     ).properties;
  239.     this.sourceList = Object.keys(curSourceList).map((i) => ({
  240.       label: i,
  241.       value: i,
  242.     }));
  243.     this.useDialog = true
  244.   },
  245.   beforeDestroy(){
  246.    
  247.    
  248.     this.designer = null
  249.     console.log(this.designer,'------>');
  250.   },
  251.   methods: {
  252.     //获取spread 创建设计器实例
  253.     designerInitialized: function (designer) {
  254.       this.designer = designer;
  255.       designer.bind(
  256.         GC.Spread.Sheets.Designer.Events.FileLoaded,
  257.         (event, data) => {
  258.           this.spread = designer.getWorkbook();
  259.           this.listenCellEvent();
  260.         }
  261.       );
  262.       this.spread = designer.getWorkbook();
  263.       let json = this.spread.toJSON();
  264.       this.spread.options.newTabVisible = true;
  265.       this.spread.options.tabNavigationVisible = false;
  266.       this.spread.options.scrollbarMaxAlign = true;
  267.       this.spread.invalidateLayout();
  268.       this.spread.repaint();
  269.       this.initSpreadSheet();
  270.       this.getRegObj();
  271.     },
  272.     //初始化自定义Tab
  273.     initRibbon() {
  274.       _this.config = GC.Spread.Sheets.Designer.DefaultConfig;
  275.       let configTab = GC.Spread.Sheets.Designer.DefaultConfig;
  276.       if (configTab.ribbon[0].buttonGroups[7]) {
  277.         let editFirstElement =
  278.           configTab.ribbon[0].buttonGroups[7].commandGroup.children[0]
  279.             .children[2];
  280.         let edit = configTab.ribbon[0].buttonGroups[7];
  281.         edit.commandGroup = editFirstElement;
  282.         _this.config.ribbon[4].buttonGroups.push(edit);
  283.       }
  284.       // add new tab
  285.       let newTab = {
  286.         id: "operate",
  287.         text: "自定义",
  288.         buttonGroups: [],
  289.       };
  290.       if (
  291.         Array.isArray(_this.config && _this.config.ribbon) &&
  292.         !_this.config.ribbon.filter((d) => d && d.text === "自定义").length
  293.       ) {
  294.         _this.config.ribbon.unshift(newTab);
  295.         let dataSaveInfo = {};
  296.         if (
  297.           localStorage.getItem("se_oss_authority") &&
  298.           JSON.parse(localStorage.getItem("se_oss_authority")).indexOf(
  299.             "MY_REPORT_SUBMIT"
  300.           ) !== -1
  301.         ) {
  302.           dataSaveInfo.release = {
  303.             iconClass: "ribbon-button-save", //按钮的样式
  304.             text: "发布", //显示的文字
  305.             bigButton: true,
  306.             commandName: "reportRelease", //命令名称,需要全局唯一
  307.             execute: this.reportRelease, //对应执行内容的function
  308.           };
  309.         }
  310.         //创建按钮
  311.         dataSaveInfo = Object.assign(dataSaveInfo, {
  312.           exit: {
  313.             iconClass: "ribbon-button-save", //按钮的样式
  314.             text: "退出",
  315.             bigButton: true,
  316.             commandName: "exitReport",
  317.             execute: this.exitReport,
  318.           },
  319.           saveTemplateCommand: {
  320.             iconClass: "ribbon-button-save", //按钮的样式
  321.             text: "保存", //显示的文字
  322.             bigButton: true,
  323.             commandName: "saveDatas", //命令名称,需要全局唯一
  324.             execute: this.saveInfos, //对应执行内容的function
  325.           },
  326.           relateMutCheck: {
  327.             iconClass: "ribbon-button-save", //按钮的样式
  328.             text: "多选其他关联",
  329.             bigButton: true,
  330.             commandName: "relateMutCheck",
  331.             execute: this.relateMutCheck,
  332.           },
  333.           reWrite: {
  334.             iconClass: "ribbon-button-save", //按钮的样式
  335.             text: "自动回填", //显示的文字
  336.             bigButton: true,
  337.             commandName: "reWriteBtn", //命令名称,需要全局唯一
  338.             execute: this.reWriteBtn, //对应执行内容的function
  339.           },
  340.           overReWrite: {
  341.             iconClass: "ribbon-button-save", //按钮的样式
  342.             text: "取消自动回填", //显示的文字
  343.             bigButton: true,
  344.             commandName: "overReWriteBtn", //命令名称,需要全局唯一
  345.             execute: this.overReWriteBtn, //对应执行内容的function
  346.           },
  347.           childrenDropdown: {
  348.             commandName: "childrenDropdown",
  349.             text: "校验规则",
  350.             title: "Children",
  351.             iconClass: "ribbon-button-welcome",
  352.             bigButton: "true",
  353.             // direction: "vertical",
  354.           },
  355.           childrenDropdown2: {
  356.             title: "设置正则",
  357.             text: "设置正则",
  358.             iconClass: "ribbon-button-welcome",
  359.             commandName: "childrenDropdown2",
  360.             execute: function (context, propertyName, fontItalicChecked) {
  361.               _this.diaMode = "reg";
  362.               _this.dialogVisible = true;

  363.               // let spread = context.Spread; //获取工作簿
  364.               // let activeCell = _this.getCell(); //获取激活单元格
  365.               // let sheet = _this.getActiveSheet(); //获取工作表
  366.               // let style = new GC.Spread.Sheets.Style();
  367.               // style.locked = false;
  368.               // style.backColor = "#C3C3C3";
  369.               // sheet.setStyle(activeCell.row, activeCell.col, style);
  370.             },
  371.           },
  372.           ruleSource: {
  373.             title: "多选框校验",
  374.             text: "多选框校验",
  375.             iconClass: "ruleSource",
  376.             commandName: "ruleSource",
  377.             execute: this.ruleSources,
  378.           },
  379.           resetDataSourceList: {
  380.             title: "清除所选数据",
  381.             text: "清除所选数据",
  382.             iconClass: "resetDataSourceList",
  383.             commandName: "resetDataSourceList",
  384.             execute: this.resetDSList,
  385.           },
  386.         });

  387.         //将图标放入工具栏
  388.         if (
  389.           !_this.config.ribbon[0].buttonGroups[0] ||
  390.           (!(_this.config.ribbon[0].buttonGroups[0].label === "保存设计") &&
  391.             !_this.config.ribbon[0].buttonGroups.filter(
  392.               (d) => d.label === "保存设计"
  393.             ).length)
  394.         ) {
  395.           _this.config.ribbon[0].buttonGroups.unshift({
  396.             label: "常用操作",
  397.             thumbnailClass: "ribbon-thumbnail-spreadsettings",
  398.             commandGroup: {
  399.               children: [
  400.                 {
  401.                   direction: "vertical",
  402.                   commands: ["saveTemplateCommand"],
  403.                 },
  404.                 {
  405.                   type: "separator",
  406.                 },
  407.                 {
  408.                   direction: "vertical",
  409.                   commands: ["release"],
  410.                 },
  411.                 {
  412.                   type: "separator",
  413.                 },
  414.                 {
  415.                   direction: "vertical",
  416.                   commands: ["exit"],
  417.                 },
  418.                 {
  419.                   type: "separator",
  420.                 },
  421.                 {
  422.                   direction: "vertical",
  423.                   commands: ["relateMutCheck"],
  424.                 },
  425.                 {
  426.                   type: "separator",
  427.                 },
  428.                 {
  429.                   direction: "vertical",
  430.                   commands: ["reWrite"],
  431.                 },
  432.                 {
  433.                   type: "separator",
  434.                 },
  435.                 {
  436.                   direction: "vertical",
  437.                   commands: ["overReWrite"],
  438.                 },
  439.                 {
  440.                   type: "separator",
  441.                 },
  442.                 {
  443.                   command: "childrenDropdown", //父命令可以有自己的execute,点击执行;也可以没有,点击弹出children
  444.                   type: "dropdown",
  445.                   children: [
  446.                     // "childrenDropdown1",
  447.                     "childrenDropdown2",
  448.                     "ruleSource",
  449.                     // "resetDataSourceList",
  450.                   ],
  451.                 },
  452.                 {
  453.                   type: "separator",
  454.                 },
  455.               ],
  456.             },
  457.           });
  458.         }

  459.         _this.config.commandMap = {};
  460.         Object.assign(_this.config.commandMap, dataSaveInfo);
  461.       }

  462.       return _this.config;
  463.     },
  464.     // 初始化校验规则
  465.     initRule() {
  466.       VerificationRules.prototype =
  467.         new GC.Spread.CalcEngine.Functions.Function();
  468.       VerificationRules.prototype.evaluate = function (arg, type) {
  469.         // 自定义正则校验
  470.         if (arguments.length === 2 && !isNaN(type)) {
  471.           return _this.regObj[type].re.test(arg);
  472.         }
  473.         return "#VALUE!";
  474.       };
  475.       _this.customFunctions.VerificationRules = VerificationRules;
  476.       MultipleChoiceVerification.prototype =
  477.         new GC.Spread.CalcEngine.Functions.Function();
  478.       MultipleChoiceVerification.prototype.evaluate = function (arg, type) {
  479.         // 多选题数量校验
  480.         if (arguments.length === 2 && !isNaN(type)) {
  481.           let { min = 0, max = 100 } = _this.regObj[type];
  482.           return min < arg.length && arg.length < max;
  483.         }
  484.         return "#VALUE!";
  485.       };
  486.       _this.customFunctions.MultipleChoiceVerification =
  487.         MultipleChoiceVerification;
  488.     },
  489.     //初始化报表表格
  490.     initSpreadSheet() {
  491.       for (let i = 0; i < this.spread.getSheetCount(); i++) {
  492.         let sheet = this.spread.getSheet(i);
  493.         var len = sheet.tables.all().length;
  494.         var tmp = {};
  495.         for (var i = 0; i < len; i++) {
  496.           var bp = sheet.tables.all()[i].bindingPath();
  497.           tmp[bp] = [{}];
  498.         }
  499.       }
  500.       this.spread.resumePaint();
  501.     },
  502.     //初始化正则对象
  503.     initRegObj() {
  504.       this.regOption = [];
  505.       this.checkOption = [];
  506.       if (!this.regObj) return;
  507.       Object.keys(this.regObj).forEach((key) => {
  508.         if (key <= 100000) {
  509.           this.regOption.push({
  510.             code: key,
  511.             name: this.regObj[key].name || null,
  512.             des: this.regObj[key].des || null,
  513.             re: this.regObj[key].re || null,
  514.           });
  515.           this.sendRegOption.push({
  516.             code: key,
  517.             name: this.regObj[key].name || null,
  518.             des: this.regObj[key].des || null,
  519.             re: String(this.regObj[key].re) || null,
  520.           });
  521.         } else if (key <= 200000) {
  522.           this.checkOption.push({
  523.             code: key,
  524.             name: this.regObj[key].name || null,
  525.             des: this.regObj[key].des || null,
  526.             min: this.regObj[key].min || null,
  527.             max: this.regObj[key].max || null,
  528.           });
  529.           this.sendRegOption.push({
  530.             code: key,
  531.             name: this.regObj[key].name || null,
  532.             des: this.regObj[key].des || null,
  533.             min: this.regObj[key].min || null,
  534.             max: this.regObj[key].max || null,
  535.           });
  536.         }
  537.       });
  538.       if (!this.regOption[0]) {
  539.         this.regOption.push({
  540.           code: "995",
  541.           name: "无校验规则",
  542.           des: "无校验规则",
  543.           re: null,
  544.         });
  545.       }
  546.       if (!this.checkOption[0]) {
  547.         this.checkOption.push({
  548.           code: "110000",
  549.           name: "空",
  550.           des: "空",
  551.         });
  552.       }
  553.       console.log(this.regOption[0]);
  554.       this.regDataObj.select = this.regOption[0]
  555.         ? this.regOption[0].code
  556.         : null;
  557.       this.checkDataObj.select = this.checkOption[0]
  558.         ? this.checkOption[0].code
  559.         : null;
  560.     },
  561.     //保存时检测哪些数据源被使用
  562.     getAllUsedDataSource(json) {
  563.       this.getAllUsedDataSourceArr = [];
  564.       let ToJSON = json;
  565.       for (let i = 0; i < this.spread.getSheetCount(); i++) {
  566.         let sheet = this.spread.getSheet(i);
  567.         let curDataTable = ToJSON.sheets[sheet.name()].data.dataTable;
  568.         let curDataSourceTable = ToJSON.sheets[sheet.name()].tables;
  569.         if (!curDataTable) {
  570.           continue;
  571.         }

  572.         for (let j in curDataTable) {
  573.           if (curDataTable[j]) {
  574.             for (let k in curDataTable[j]) {
  575.               if (curDataTable[j][k].bindingPath) {
  576.                 this.getAllUsedDataSourceArr.push(
  577.                   curDataTable[j][k].bindingPath
  578.                 );
  579.               }
  580.             }
  581.           }
  582.         }

  583.         if (!curDataSourceTable) {
  584.           continue;
  585.         }
  586.         this.getAllUsedDataSourceArr.push(
  587.           ...curDataSourceTable.map((item) => {
  588.             return item.bindingPath;
  589.           })
  590.         );
  591.       }
  592.       this.getAllUsedDataSourceArr = Array.from(
  593.         new Set(this.getAllUsedDataSourceArr)
  594.       );
  595.     },
  596.     // 转换regOption到regObj
  597.     async handleOptionToRegObj(data) {
  598.       this.regObj = localReRule;
  599.       let regObj = {};
  600.       let similar = data.data;
  601.       if (!!similar && similar[0].des != "暂无数据请添加") {
  602.         similar.forEach((item) => {
  603.           regObj[item.code] = {
  604.             ...item,
  605.             reCode: item.code,
  606.           };
  607.           delete regObj[item.code].code;
  608.         });
  609.         this.regObj = regObj;
  610.       } else {
  611.         await seAddRegularItem([...localReRule]);
  612.         this.regObj.forEach((item) => {
  613.           regObj[item.code] = {
  614.             ...item,
  615.             reCode: item.code,
  616.           };
  617.           delete regObj[item.code].code;
  618.         });
  619.         this.regObj = regObj;
  620.       }
  621.       this.regObj[""] = {
  622.         des: "空",
  623.       };
  624.       this.initRegObj();
  625.       this.initRule();
  626.       this.listenSheetChange();
  627.     },
  628.     //获取正则对象
  629.     async getRegObj() {
  630.       let data = [];
  631.       let res = await seGetRegularList({
  632.         pageSize: 999,
  633.         current: 1,
  634.       });
  635.       // let res = {data:{data:[]}} //测试返回数据为是否为空
  636.       data = res.data || { data: [] };
  637.       if (!data.data[0]) {
  638.         this.handleOptionToRegObj({
  639.           data: [
  640.             { code: 995, des: "暂无数据请添加", name: "暂无数据请添加" },
  641.             { code: 110000, des: "暂无数据请添加", name: "暂无数据请添加" },
  642.           ],
  643.         });
  644.       } else {
  645.         this.handleOptionToRegObj(data);
  646.       }
  647.     },
  648.     // 退出报表编辑
  649.     exitReport() {
  650.       // console.log(1,this.designer);
  651.     // this.spread.destroy()
  652.       this.designer.destroy();
  653.       this.designer = null
  654.       console.log(this.designer,'--------<');
  655.       
  656.       this.$router.back();
  657.     },
  658.     // 对比新旧的数据源并且提示用户
  659.     handleDataSource() {
  660.       //如果本身没有数据源,直接通过
  661.       if (
  662.         !_this.designer.getData("updatedTreeNode") &&
  663.         !_this.designer.getData("oldTreeNodeFromJson")
  664.       ) { return true }
  665.         
  666.       let curDesignerBindingPathSchema = JSON.parse(
  667.         _this.designer.getData("updatedTreeNode") ||
  668.           _this.designer.getData("oldTreeNodeFromJson")
  669.       ).properties;
  670.       let recviceSourceKey = Object.keys(_this.curSource);
  671.       let curSourceKey = Object.keys(curDesignerBindingPathSchema);
  672.       let diffrentDir = [];

  673.       recviceSourceKey.forEach((oldKey) => {
  674.         if (curSourceKey.indexOf(oldKey) === -1 && !oldKey.startsWith("@") ) {
  675.           diffrentDir.push(oldKey);
  676.         }
  677.       });
  678.       debugger
  679.       let curBinding = this.handleDataTableReturn();
  680.       Object.keys(this.spread.toJSON().sheets).forEach(sheetName=>{
  681.         if(this.spread.toJSON().sheets[sheetName].tables && Array.isArray(this.spread.toJSON().sheets[sheetName].tables)){
  682.           this.spread.toJSON().sheets[sheetName].tables.forEach(table=>{
  683.           curBinding.push({
  684.             bindingPath:table.bindingPath,
  685.             col: table.col,
  686.             row: table.row,
  687.             sheetName: sheetName
  688.           })
  689.         })
  690.         }
  691.       })
  692.       this.lostBinging = [];
  693.       // let curBinding = this.handleDataTableReturn();
  694.       if (curBinding) {
  695.         curBinding.forEach((item) => {
  696.           if(!item.bindingPath) return
  697.           if (diffrentDir.indexOf(item.bindingPath) > -1) {
  698.             this.lostBinging.push(Object.assign(item,{
  699.               col:Number(item.col) +1,
  700.               row:Number(item.row)+ 1,
  701.             }));
  702.           }
  703.           if(item.bindingPath && item.bindingPath.startsWith("@") && recviceSourceKey.indexOf(item.bindingPath)== -1){
  704.             this.lostBinging.push(Object.assign(item,{
  705.               col:Number(item.col) +1,
  706.               row:Number(item.row)+ 1,
  707.             }));
  708.           }
  709.           if(item.bindingPath && curSourceKey.indexOf(item.bindingPath) == -1 && !item.bindingPath.startsWith("@")){
  710.             this.lostBinging.push(Object.assign(item,{
  711.               col:Number(item.col) +1,
  712.               row:Number(item.row)+ 1,
  713.             }));
  714.           }
  715.         });
  716.       }
  717.       if (this.lostBinging.length > 0) {
  718.         return false;
  719.       }
  720.       return true;
  721.     },
  722.     handleTest(){
  723.       this.handleAllSelectSourceView()
  724.     },
  725.     //保存点击事件,进行信息保存
  726.     saveInfos(type) {
  727.       this.jsonStr = JSON.stringify(_this.getAllSheetsData());
  728.       this.getAllUsedDataSource(JSON.parse(this.jsonStr));
  729.       // if (!this.handleDataSource()) {
  730.       //   this.$nextTick(()=>{
  731.       //     this.$message.error("该表引用了被删除字典,请修改后再保存");
  732.       //     _this.openInitPassDia = true;
  733.       //     console.log(this.lostBinging);
  734.          
  735.       //   })
  736.       //   return;
  737.       // }
  738.       // if (this.getActiveSheetData().data && !this.getActiveSheetData().data.dataTable) {
  739.       //   this.$message.error("当前报表内容为空,请添加后再保存");
  740.       //   return;
  741.       // }
  742.       // //判断回填是否设置了数据源
  743.       // if (!this.handleAutoFillData()) {
  744.       //   this.$message.error("自动回填没有设置数据源");
  745.       //   return;
  746.       // }
  747.       
  748.       //判断数据源是否被绑定两次
  749.       if (!this.handleAllSelectSourceView()) {
  750.         // if(typeof type != 'boolean' || !type) {
  751.          
  752.          
  753.         //   this.$refs.saveBtn.handleClick(true)
  754.         
  755.         // }
  756.         // console.log(,9999);
  757.         
  758.         // this.$refs.saveBtn.click()
  759.         // this.$message.error("数据源设置了两次");
  760.         // this.test = "6666666"
  761.         
  762.         // alert(this.test)
  763.         debugger
  764.         let _this = this
  765.         _this.useDialog = true;
  766.       //  setTimeout(()=>{
  767.         
  768.         
  769.       //  },300)
  770.       }
  771.       
  772.       this.saveInfoConfirm();
  773.     },
  774.     // 调用保存的接口
  775.     async saveInfoConfirm() {
  776.       
  777.       _this.designerBindingPathSchema =
  778.         _this.designer.getData("updatedTreeNode") ||
  779.         _this.designer.getData("oldTreeNodeFromJson");
  780.       let submitSource = [];
  781.       let source = JSON.parse(_this.designerBindingPathSchema);
  782.       if (source && source.properties) {
  783.         for (let i in source.properties) {
  784.           let curSourceKeys = Object.keys(_this.curSource);
  785.           let extra;
  786.           if (source.properties[i].dataFieldType !== "table") {
  787.             extra = source.properties[i].properties
  788.               ? source.properties[i].properties
  789.               : curSourceKeys.filter((item) => {
  790.                   if (item === i) return;
  791.                 })[0]
  792.               ? curSourceKeys.filter((item) => {
  793.                   if (item === i) return;
  794.                 })[0].properties
  795.               : null;
  796.           } else {
  797.             if (source.properties[i].items) {
  798.               extra = source.properties[i].items;
  799.             } else {
  800.               extra = null;
  801.             }
  802.           }
  803.           let children;
  804.           if (source.properties[i].dataFieldType == "table") {
  805.             if (source.properties[i].items) {
  806.               children = Object.keys(source.properties[i].items.properties);
  807.             }
  808.           } else if (source.properties[i].dataFieldType == "combox") {
  809.             if (source.properties[i].properties) {
  810.               children = Object.keys(source.properties[i].properties);
  811.             }
  812.           }

  813.           let curObj = {
  814.             name: i,
  815.             code: source.properties[i].dataFieldType.toUpperCase(),
  816.             dataFieldType: source.properties[i].dataFieldType,
  817.             type: source.properties[i].type,
  818.             id: curSourceKeys.filter((item) => {
  819.               if (item.name === i) return _this.curSource[item].id;
  820.             })[0]
  821.               ? curSourceKeys.filter((item) => {
  822.                   if (item.name === i) return _this.curSource[item].id;
  823.                 })[0].id
  824.               : null,
  825.             extra: JSON.stringify(extra),
  826.             children: children,
  827.           };
  828.           submitSource.push(curObj);
  829.         }
  830.       }
  831.       // 保存源数据与样式
  832.       try {
  833.         if (!this.$route.query.template)
  834.           await seSaveReportSourceData(
  835.             submitSource,
  836.             this.$route.query.projectId
  837.           );
  838.         let {
  839.           data: { resultCode },
  840.         } = await seSaveReportStyleData({
  841.           reportId: this.$route.query.reportId,
  842.           reportJson: this.jsonStr,
  843.           boundDictionaries: this.getAllUsedDataSourceArr,
  844.         });
  845.         resultCode !== 400
  846.           ? this.handleMessage("success", "保存报表设计成功")
  847.           : "";
  848.       } catch (e) {
  849.         this.$message.error("保存失败,请稍后重试");
  850.       }
  851.     },
  852.     handleAutoFillData() {
  853.       let isPass = true;
  854.     try{
  855.       for (let i = 0; i < this.spread.getSheetCount(); i++) {
  856.         let sheet = this.spread.getSheet(i);
  857.         let curData = _this.spread.toJSON().sheets[sheet.name()];
  858.         if (curData && curData.data && curData.data.dataTable) {
  859.           let curDataObj = curData.data.dataTable;
  860.           let rowList = Object.keys(curDataObj);
  861.           rowList.forEach((row) => {
  862.             let colList = Object.keys(curDataObj[row]);
  863.             colList.forEach((col) => {
  864.               if (
  865.                 curDataObj[row][col].tag &&
  866.                 curDataObj[row][col].tag.reWriteType &&
  867.                 !curDataObj[row][col].bindingPath
  868.               ) {
  869.                 isPass = false;
  870.               }
  871.             });
  872.           });
  873.         }
  874.       }
  875.     } catch(e) {
  876.       console.log(e);
  877.       
  878.     }
  879.       return isPass;
  880.     },
  881.     initDesigner(styleRes, strRes) {
  882.       var jsonOptions = {
  883.         includeBindingSource: true,
  884.         ignoreFormula: this.import_noFormula,
  885.         ignoreStyle: this.import_noStyle,
  886.         frozenColumnsAsRowHeaders: this.import_rowHeaders,
  887.         frozenRowsAsColumnHeaders: this.import_columnHeaders,
  888.         doNotRecalculateAfterLoad: this.import_donotrecalculateafterload,
  889.       };
  890.       this.spread.fromJSON(styleRes, jsonOptions);
  891.       let jsonStrRes =
  892.         typeof strRes == "string" ? strRes : JSON.stringify(strRes);
  893.       // 加载字段源
  894.       this.designer.setData("treeNodeFromJson", jsonStrRes);
  895.       this.designer.setData("oldTreeNodeFromJson", jsonStrRes);
  896.       setTimeout(() => {
  897.         _this.spread.refresh();
  898.       }, 500);
  899.     },
  900.     //查看当前的数据源绑定单元格
  901.     handleSelectSourceView() {
  902.       if (!this.selectSourceView) return;
  903.       let curData = this.handleDataTableReturn();
  904.       this.sourceLocation = true;
  905.       this.sourceLocationList = curData.filter((i) => {
  906.         if (this.selectSourceView == i.bindingPath) {
  907.           return Object.assign(i, { row: Number(i.row) + 1, col: Number(i.col) + 1 });
  908.         }
  909.       });
  910.     },
  911.     //判断当前的数据源是否被绑定两次
  912.     handleAllSelectSourceView() {
  913.       debugger
  914.       this.showList = []
  915.       this.useSource = []
  916.       let curSourceList = JSON.parse(
  917.         _this.designer.getData("updatedTreeNode") ||
  918.           _this.designer.getData("oldTreeNodeFromJson")
  919.       ).properties;
  920.       if(!curSourceList) return true
  921.       let curData = this.handleDataTableReturn();
  922.       let newSourceList = Object.keys(curSourceList);
  923.       
  924.       newSourceList.forEach((item) => {
  925.         curData.forEach((i) => {
  926.           if (item == i.bindingPath) {
  927.             if(this.useSource[item]){
  928.               this.useSource[item].push(Object.assign(i,{row:Number(i.row) + 1,col:Number(i.col) + 1}))
  929.             } else {
  930.               this.useSource[item] = [Object.assign(i,{row:Number(i.row) + 1,col:Number(i.col) + 1})]
  931.             }
  932.           }
  933.         });
  934.       });
  935.       
  936.       Object.keys(this.useSource).forEach((i) => {
  937.         if (this.useSource[i].length > 1) {
  938.           this.useSource[i].forEach(j=>{
  939.             this.showList.push(j)
  940.           })
  941.         }
  942.       });
  943.       console.log(this.useSource);
  944.       
  945.       if (this.showList.length > 0) {
  946.         
  947.         console.log("数据源不通过");
  948.         
  949.         return false;
  950.       } else {
  951.         return true;
  952.       }
  953.     },
  954.     //确定为保存,多个单元格设置同一个数据源
  955.     handleConfirmSource() {
  956.       this.saveInfoConfirm();
  957.       this.useDialog = false
  958.     },
  959.     // 获取当前单元格并设置逻辑
  960.     getCell() {
  961.       let cellObj = this.getCellCoordinate();
  962.       return cellObj;
  963.     },
  964.     //返回当前dataTable的扁平化数据
  965.     handleDataTableReturn() {
  966.       let sheetObjList = [];
  967.       let jsonStr = _this.spread.toJSON().sheets;
  968.       Object.keys(jsonStr).forEach((sheetName) => {
  969.         let curSheetDataTable = jsonStr[sheetName].data.dataTable;
  970.         if (!curSheetDataTable) return;
  971.         //获取行坐标
  972.         Object.keys(curSheetDataTable).forEach((row) => {
  973.           //获取列坐标
  974.           Object.keys(curSheetDataTable[row]).forEach((col) => {
  975.             let curCellObj = {
  976.               row: row,
  977.               col: col,
  978.               sheetName: sheetName,
  979.               tag: curSheetDataTable[row][col]
  980.                 ? curSheetDataTable[row][col].tag
  981.                 : {},
  982.               bindingPath: curSheetDataTable[row][col]
  983.                 ? curSheetDataTable[row][col].bindingPath
  984.                 : "",
  985.               style: curSheetDataTable[row][col]
  986.                 ? curSheetDataTable[row][col].style
  987.                 : {},
  988.               value: curSheetDataTable[row][col]
  989.                 ? curSheetDataTable[row][col].value
  990.                 : "",
  991.             };
  992.             sheetObjList.push(curCellObj);
  993.           });
  994.         });
  995.       });
  996.       return sheetObjList;
  997.     },
  998.     // 发布报表
  999.     reportRelease() {
  1000.       this.test = '999999'
  1001.       if (!this.getActiveSheetData().data.dataTable) {
  1002.         this.$message.error("当前报表内容为空,请添加后再发布");
  1003.         return;
  1004.       }
  1005.       seReportPublishing({
  1006.         reportId: this.$route.query.reportId,
  1007.       });
  1008.       this.$message.success("发布成功");
  1009.     },
  1010.     // 获取当前活动表对象
  1011.     getActiveSheet() {
  1012.       return this.spread.getActiveSheet();
  1013.     },
  1014.     // 获取选择单元格左边
  1015.     getCellCoordinate() {
  1016.       let activeSheet = this.spread.getActiveSheet();
  1017.       let activeSheetTab = this.spread.getActiveSheetTab();
  1018.       let selections = activeSheet.getSelections();
  1019.       const { col, row, colCount, rowCount } = selections[0];
  1020.       return { col, row, colCount, rowCount, activeSheet };
  1021.     },
  1022.     // 获取当前活动表数据
  1023.     getActiveSheetData() {
  1024.       return _this.spread.toJSON().sheets[this.getActiveSheet().name()];
  1025.     },
  1026.     getAllSheetsData() {
  1027.       return _this.spread.toJSON();
  1028.     },
  1029.     listenSheetChange() {
  1030.       // 监听sheet变化
  1031.       this.spread.bind(
  1032.         GC.Spread.Sheets.Events.SheetChanged,
  1033.         function (e, info) {
  1034.           if (info.propertyName === "insertSheet") {
  1035.             // 新增表重新绑定监听
  1036.             _this.listenCellEvent(_this.spread.getSheet(info.sheetIndex));
  1037.           } else if (info.propertyName === "isSelected" && info.newValue) {
  1038.             //切换表重新绑定监听
  1039.             _this.listenCellEvent(_this.spread.getSheet(info.sheetIndex));
  1040.           }
  1041.           // _this.listenCellEvent()
  1042.         }
  1043.       );
  1044.     },
  1045.     // 绑定单元格监听
  1046.     listenCellEvent(sheet = false) {
  1047.       let currentSheet = sheet || _this.spread.getActiveSheet();
  1048.       currentSheet.bind(
  1049.         GC.Spread.Sheets.Events.ValueChanged,
  1050.         function (e, info) {
  1051.           // 获取数据变化的单元格信息
  1052.           // 获取对应单元格绑定的数据源
  1053.           let bindPath = _this
  1054.             .getActiveSheet()
  1055.             .getBindingPath(info.row, info.col);
  1056.         }
  1057.       );
  1058.       currentSheet.bind(
  1059.         GC.Spread.Sheets.Events.SelectionChanged,
  1060.         function (e, info) {
  1061.           _this.curCellRow = info.newSelections[0].row;
  1062.           _this.curCellCol = info.newSelections[0].col;
  1063.           _this.getRuleDes();
  1064.           _this.getAuditpoints();
  1065.           _this.getWordRequest();
  1066.         }
  1067.       );
  1068.       currentSheet.bind(
  1069.         GC.Spread.Sheets.Events.TableRowsChanged,
  1070.         function (e, info) {
  1071.           for (let i = 0; i < _this.spread.getSheetCount(); i++) {
  1072.             let sheet = _this.spread.getSheet(i);
  1073.             sheet.tables.all().forEach((table) => {
  1074.               let dr = table.dataRange();
  1075.               sheet
  1076.                 .getRange(dr.row, dr.col, dr.rowCount, dr.colCount)
  1077.                 .locked(false);
  1078.               for (
  1079.                 let curRow = dr.row + 1;
  1080.                 curRow < dr.row + dr.rowCount;
  1081.                 curRow++
  1082.               ) {
  1083.                 sheet.copyTo(
  1084.                   dr.row,
  1085.                   dr.col,
  1086.                   curRow,
  1087.                   dr.col,
  1088.                   1,
  1089.                   dr.colCount,
  1090.                   GC.Spread.Sheets.CopyToOptions.style
  1091.                 );
  1092.               }
  1093.             });
  1094.           }
  1095.         }
  1096.       );
  1097.     },
  1098.     // 删除单元格绑定源
  1099.     deleteCell() {
  1100.       let cellObj = this.getCellCoordinate();
  1101.       cellObj.activeSheet.setBindingPath(cellObj.col, cellObj.row, undefined);
  1102.     },
  1103.     //关闭绑定数据弹窗
  1104.     closeDataDia() {
  1105.       this.dialogDataConnect = false;
  1106.     },
  1107.     //绑定数据单元格
  1108.     cellDataChange({ row, col, dataSource }) {
  1109.       this.setNewTag(
  1110.         {
  1111.           relateDataSource: dataSource,
  1112.         },
  1113.         row,
  1114.         col
  1115.       );
  1116.       this.closeDataDia();
  1117.     },
  1118.     //点击添加审核点和填写要求
  1119.     handleSubmitSearch(type = "auditpoints") {
  1120.       let settingObj = {};
  1121.       type === "auditpoints"
  1122.         ? (settingObj = {
  1123.             auditpoints: _this.auditpoints,
  1124.           })
  1125.         : (settingObj = {
  1126.             wordRequest: _this.wordRequest,
  1127.           });
  1128.       this.setNewTag(settingObj, this.curCellRow, this.curCellCol);
  1129.       this.handleMessage("success");
  1130.     },
  1131.     //设置cell的tag新属性
  1132.     setNewTag(setTagObj, row, col) {
  1133.       if (_this.getActiveSheet().getTag(row, col)) {
  1134.         _this
  1135.           .getActiveSheet()
  1136.           .setTag(
  1137.             Object.assign(_this.getActiveSheet().getTag(row, col), setTagObj)
  1138.           );
  1139.       } else {
  1140.         _this.getActiveSheet().setTag(row, col, setTagObj);
  1141.       }
  1142.     },
  1143.     //提示方法
  1144.     handleMessage(type, text) {
  1145.       if (type == "success") {
  1146.         this.$message.success(`${text || "保存成功"}`);
  1147.       } else {
  1148.         this.$message.error(`${text || "保存失败"}`);
  1149.       }
  1150.     },
  1151.     getRuleDes() {
  1152.       //获取正则校验描述
  1153.       try {
  1154.         // 读取规则描述
  1155.         _this.curCellReg =
  1156.           _this.regObj[
  1157.             _this.getActiveSheetData().data.dataTable[_this.curCellRow][
  1158.               _this.curCellCol
  1159.             ].tag.reCode
  1160.           ].des;
  1161.         // 读取是否必填
  1162.         _this.getActiveSheetData().data.dataTable[_this.curCellRow][
  1163.           _this.curCellCol
  1164.         ].tag.isRequire
  1165.           ? (_this.curCellReg += " - 必填 ")
  1166.           : "";
  1167.       } catch (e) {
  1168.         _this.curCellReg = "";
  1169.       }
  1170.     },
  1171.     getAuditpoints() {
  1172.       try {
  1173.         // 获取审核点数据
  1174.         _this.auditpoints =
  1175.           _this.getActiveSheetData().data.dataTable[_this.curCellRow][
  1176.             _this.curCellCol
  1177.           ].tag.auditpoints;
  1178.       } catch (e) {
  1179.         _this.auditpoints = "";
  1180.       }
  1181.     },
  1182.     getWordRequest() {
  1183.       try {
  1184.         // 获取填报要求数据
  1185.         _this.wordRequest =
  1186.           _this.getActiveSheetData().data.dataTable[_this.curCellRow][
  1187.             _this.curCellCol
  1188.           ].tag.wordRequest;
  1189.       } catch (e) {
  1190.         _this.wordRequest = "";
  1191.       }
  1192.     },
  1193.     //校验添加的新规则是否符合校验
  1194.     handleValidRule() {
  1195.       let valids;
  1196.       let mode;
  1197.       this.diaMode === "reg" ? (mode = "regDataObj") : (mode = "checkDataObj");
  1198.       this.$refs[mode].validate((valid) => {
  1199.         valids = valid;
  1200.       });
  1201.       return valids;
  1202.     },
  1203.     // 新建自定义正则校验
  1204.     async handleSubmitReg() {
  1205.       if (!this.handleValidRule()) return;
  1206.       let mode;
  1207.       this.diaMode === "reg" ? (mode = "regDataObj") : (mode = "checkDataObj");
  1208.       // this.$refs[mode].resetFields();
  1209.       if (this.diaMode === "reg") {
  1210.         _this.randomNumber = Math.floor(Math.random(new Date()) * 100000);
  1211.         if (
  1212.           this.regObj[_this.randomNumber] &&
  1213.           this.regObj[_this.randomNumber].re
  1214.         ) {
  1215.           handleSubmitReg();
  1216.           return;
  1217.         }
  1218.         await seAddRegularItem([
  1219.           {
  1220.             name: this.regDataObj.name,
  1221.             des: this.regDataObj.des,
  1222.             re: this.regDataObj.input,
  1223.             code: _this.randomNumber,
  1224.           },
  1225.           // ...localReRule,
  1226.         ]);
  1227.       } else if (this.diaMode === "checkBox") {
  1228.         _this.randomNumber = Math.floor(
  1229.           Math.random(new Date()) * 100000 + 100000
  1230.         );
  1231.         if (this.regObj[_this.randomNumber]) {
  1232.           handleSubmitReg();
  1233.           return;
  1234.         }
  1235.         await seAddRegularItem([
  1236.           {
  1237.             name: this.checkDataObj.name,
  1238.             des: this.checkDataObj.des,
  1239.             min: this.checkDataObj.min,
  1240.             max: this.checkDataObj.max,
  1241.             code: _this.randomNumber,
  1242.           },
  1243.           // ...localReRule,
  1244.         ]);
  1245.       }
  1246.       _this.regStatus = "选择";
  1247.       this.getRegObj();
  1248.       this.initRule();
  1249.     },
  1250.     // 绑定当前选择的正则到当前选择的单元格
  1251.     handleRegRuleAdd(isRequire) {
  1252.       if (isRequire) {
  1253.         this.setNewTag(
  1254.           {
  1255.             isRequire: true,
  1256.           },
  1257.           this.curCellRow,
  1258.           this.curCellCol
  1259.         );
  1260.       }
  1261.       if (this.diaMode === "reg") {
  1262.         this.setNewTag(
  1263.           {
  1264.             reCode: this.regDataObj.select,
  1265.           },
  1266.           this.curCellRow,
  1267.           this.curCellCol
  1268.         );
  1269.         _this.randomNumber = this.regDataObj.select;
  1270.       } else if (this.diaMode == "checkBox") {
  1271.         this.setNewTag(
  1272.           {
  1273.             reCode: this.checkDataObj.select,
  1274.           },
  1275.           this.curCellRow,
  1276.           this.curCellCol
  1277.         );
  1278.         _this.randomNumber = this.checkDataObj.select;
  1279.       }
  1280.       _this.getRuleDes();
  1281.       this.$message.success("添加成功!");
  1282.       this.dialogVisible = false;
  1283.     },
  1284.     //唤醒多选绑定框
  1285.     ruleSources() {
  1286.       if (!this.regObj[this.checkDataObj.select]) {
  1287.         this.regObj[""] = {
  1288.           des: "暂无校验",
  1289.           code: "",
  1290.           min: "",
  1291.           name: "暂无校验",
  1292.           max: "",
  1293.         };
  1294.         this.checkDataObj.select = "";
  1295.       }
  1296.       _this.diaMode = "checkBox";
  1297.       _this.dialogVisible = true;
  1298.     },
  1299.     //清空数据校验列表
  1300.     resetDSList() {},
  1301.     //多选框其他数据绑定(多选框绑定后,能使用正则校验对指定的其他单元格设置校验规则)
  1302.     relateMutCheck() {
  1303.       _this.multipleDataConnect.push({
  1304.         row: _this.curCellRow,
  1305.         col: _this.curCellCol,
  1306.       });
  1307.       try {
  1308.         if (
  1309.           !_this.getActiveSheetData().data.dataTable[
  1310.             _this.multipleDataConnect[0].row
  1311.           ][_this.multipleDataConnect[0].col].style.cellType.typeName == "12"
  1312.         ) {
  1313.           this.$message.error("请先选择多选框");
  1314.           _this.multipleDataConnect = [];
  1315.           return;
  1316.         }
  1317.       } catch (e) {
  1318.         _this.multipleDataConnect = [];
  1319.         _this.$message.error("请先选择多选框");
  1320.         return;
  1321.       }
  1322.       if (_this.multipleDataConnect.length == 2) {
  1323.         //多选框绑定
  1324.         _this.setNewTag(
  1325.           {
  1326.             relateRow: _this.multipleDataConnect[1].row,
  1327.             relateCol: _this.multipleDataConnect[1].col,
  1328.           },

  1329.           _this.multipleDataConnect[0].row,
  1330.           _this.multipleDataConnect[0].col
  1331.         );
  1332.         //被多选框绑定
  1333.         _this.setNewTag(
  1334.           {
  1335.             connectByRow: _this.multipleDataConnect[0].row,
  1336.             connectByCol: _this.multipleDataConnect[0].col,
  1337.           },
  1338.           _this.multipleDataConnect[1].row,
  1339.           _this.multipleDataConnect[1].col
  1340.         );
  1341.         this.getActiveSheet()
  1342.           .getCell(
  1343.             _this.multipleDataConnect[0].row,
  1344.             _this.multipleDataConnect[0].col
  1345.           )
  1346.           .backColor("#aed19c");
  1347.         this.getActiveSheet()
  1348.           .getCell(
  1349.             _this.multipleDataConnect[1].row,
  1350.             _this.multipleDataConnect[1].col
  1351.           )
  1352.           .backColor("#aed19c");

  1353.         this.$message.success(
  1354.           `成功关联(${_this.multipleDataConnect[0].row},${_this.multipleDataConnect[0].col})(${_this.multipleDataConnect[1].row},${_this.multipleDataConnect[1].col})`
  1355.         );
  1356.         _this.multipleDataConnect = [];
  1357.       } else {
  1358.         _this.$message.success(
  1359.           `已选择(${_this.curCellRow},${_this.curCellCol})`
  1360.         );
  1361.       }
  1362.     },
  1363.     //清除该单元格的数据绑定
  1364.     removeData({ row, col }) {
  1365.       _this.setNewTag(
  1366.         {
  1367.           relateDataSource: null,
  1368.         },
  1369.         row,
  1370.         col
  1371.       );
  1372.     },
  1373.     //关闭自定义校验选择框
  1374.     handleCancelDia(type) {
  1375.       type == "add" ? "" : (this.dialogVisible = false);
  1376.       (this.regDataObj = {
  1377.         input: "",
  1378.         name: "",
  1379.         des: "",
  1380.         select: "",
  1381.       }),
  1382.         (this.checkDataObj = {
  1383.           min: "",
  1384.           max: "",
  1385.           name: "",
  1386.           des: "",
  1387.           select: "",
  1388.         });
  1389.       this.checkDataObj.select;
  1390.       this.regObj;
  1391.       this.regStatus = "选择";
  1392.     },
  1393.     //清除绑定的自定义规则
  1394.     removeRule() {
  1395.       try {
  1396.         _this.getActiveSheetData().data.dataTable[this.curCellRow][
  1397.           this.curCellCol
  1398.         ].tag.reCode = null;
  1399.         _this.getActiveSheetData().data.dataTable[this.curCellRow][
  1400.           this.curCellCol
  1401.         ].tag.isRequire = false;
  1402.         this.$message.success("校验清除成功");
  1403.         this.dialogVisible = false;
  1404.       } catch (e) {}
  1405.     },
  1406.     //数据回填的方法设置
  1407.     reWriteBtn() {
  1408.       _this.reWriteDia = true;
  1409.     },
  1410.     //取消当前回填数据
  1411.     overReWriteBtn(){
  1412.       this.setNewTag(
  1413.         {
  1414.           reWriteType: null,
  1415.         },
  1416.         this.curCellRow,
  1417.         this.curCellCol
  1418.       );
  1419.       this.getActiveSheet()
  1420.         .getCell(Number(this.curCellRow), Number(this.curCellCol))
  1421.         .backColor("");
  1422.       this.$message.success("取消回填成功");
  1423.       this.reWriteSelect = "";
  1424.     },
  1425.     handleReWriteSubmit() {
  1426.       // 设置该单元格的回填信息
  1427.       this.setNewTag(
  1428.         {
  1429.           reWriteType: this.reWriteSelect,
  1430.         },
  1431.         this.curCellRow,
  1432.         this.curCellCol
  1433.       );
  1434.       this.getActiveSheet()
  1435.         .getCell(Number(this.curCellRow), Number(this.curCellCol))
  1436.         .backColor("#9ebddd");
  1437.       this.$message.success("设置回填成功,请设置该单元格数据源");
  1438.       this.reWriteDia = false;
  1439.       this.reWriteSelect = "";
  1440.     },
  1441.   },
  1442.   watch: {
  1443.     screenWidth: {
  1444.       immediate: true,
  1445.       handler: function (newVal) {
  1446.         // 为了避免频繁触发resize函数导致页面卡顿,使用定时器
  1447.         if (!this.timer) {
  1448.           this.screenWidth = newVal;
  1449.           this.timer = true;
  1450.           let _this = this;
  1451.           setTimeout(() => {
  1452.             document.getElementById("designer-content").style.width =
  1453.               newVal + "px";
  1454.             //在这里做有关浏览器变化时需要做的操作
  1455.             _this.spread.refresh();
  1456.             _this.timer = false;
  1457.           }, 500);
  1458.         }
  1459.       },
  1460.     },
  1461.   },
  1462.   beforeDestroy() {},
  1463. };
  1464. </script>
复制代码
回复 使用道具 举报
kelvinChen
金牌服务用户   /  发表于:2024-9-4 10:48:38
13#
经过测试,第二次进入的报表也是使用了第一次的designer,能否在每一进入sheet都使用新的designer,达到刷新的效果
回复 使用道具 举报
kelvinChen
金牌服务用户   /  发表于:2024-9-4 10:58:02
14#
或者说,为什么我在退出报表的时候使用了destory方法,下次再进入还是引用被destory的designer,不是被销毁了吗
回复 使用道具 举报
kelvinChen
金牌服务用户   /  发表于:2024-9-4 11:41:22
15#
当前每一次进入我都会创建新的designer,但是只有无论创建了多少designer,都只会使用第一次创建的,无论我退出的时候有没有调用销毁designer
回复 使用道具 举报
kelvinChen
金牌服务用户   /  发表于:2024-9-4 11:46:17
16#
这是在app.vue引入的,是不是引入出现什么问题
import "@grapecity/spread-sheets-designer-resources-cn";
import "@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css";
import "@grapecity/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css";
import "@grapecity/spread-sheets-designer-vue";
import GC from "@grapecity/spread-sheets";
// import * as GC from '@grapecity/spread-sheets';
import "@grapecity/spread-sheets-print";
import "@grapecity/spread-sheets-shapes";
// import "@grapecity/spread-sheets-slicers";
import "@grapecity/spread-sheets-tablesheet";
// import "@grapecity/spread-sheets-ganttsheet";
// import "@grapecity/spread-sheets-formula-panel";
import "@grapecity/spread-sheets-io";
import '@grapecity/spread-sheets-resources-zh';
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:2024-9-4 14:16:35
17#
kelvinChen 发表于 2024-9-4 11:46
这是在app.vue引入的,是不是引入出现什么问题
import "@grapecity/spread-sheets-designer-resources-cn" ...

我们根据您提供的代码片段分析,这需要一些时间,请您耐心等候。
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:2024-9-4 16:22:10
18#
kelvinChen 发表于 2024-9-4 09:30
测试第二次进入保存左边弹窗不出现,右边按钮能出现弹窗,猜测是否第二次进入的时候,左边的报表和右边的 ...

因为您销毁的是Designer,所以销毁将清空原Designer资源占用的区域,而右侧面板是独立于Designer自定义的dom元素,因此不受影响。
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:2024-9-4 16:32:50
19#
您好!您的代码中包含了很多项目内的资源,未提供给我们,我们无法直接运行这些代码,也未能复现问题。我们分析了这些代码片段,未发现异常处,我们从中抽取了设置ribbon的代码,以模拟您定义的退出销毁功能,可以正常销毁且重建Designer,您可以参考附件中的demo了解详情。
为了解决您的问题,请问您是否方便将复现问题的代码单独汇集成可直接运行的demo文件呢,只需要复现问题即可,当前代码片段缺少运行资源。

销毁Designer.html

13.75 KB, 下载次数: 4

回复 使用道具 举报
kelvinChen
金牌服务用户   /  发表于:2024-9-5 15:48:48
20#
目前已经解决
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部