export default {
name: "FillReport",
components: {
ReportHistoryAudit,
},
filters: {
stringFilter(value) {
if (
value &&
typeof value == "string" &&
value.indexOf("undefined") > -1
) {
value = value.replace("undefined", "公式校验");
}
return value;
},
},
data: function () {
return {
//校验是否通过
isPass: true,
//是否进行过校验
isCheck: false,
isShowCompare: false,
editTable: true,
styleRes: null,
styleInfo: { height: "800px", width: "100%", border: "solid black 1px" },
config: null,
designer: null,
dataTable: null,
spread: null,
designerBindingPathSchema: null,
jsonStr: null,
// 配置
import_bindingSource: true,
import_noFormula: false,
import_noStyle: false,
import_rowHeaders: false,
import_columnHeaders: false,
import_donotrecalculateafterload: false,
noFormula: false,
noStyle: false,
SaveCustomRowHeaders: false,
SaveCustomColumnHeaders: false,
//是否已打开对照表
isShowCompare: false,
// 报表填写
spread3: null,
dataTable3: null,
resDataSource: null,
resSource: null,
//编辑报表
spread4: null,
// 设计器编辑配置
designer2: null,
dataTable2: null,
spread2: null,
//填报要求文字
wordRequest: "",
// 审核点内容
auditpoints: null,
curCellRow: "",
curCellCol: "",
//审核意见
auditWord: "",
// 当前cell的校验规则
curCellReg: "",
//校验规则对象 (暂定小于1000为文字正则 1000 - 2000 为多选条件)
regObj: localReRule,
//发送后端的校验对象
sendRuleObjArray: [],
// 自定义函数
customFunctions: {},
//存放审核意见对象
auditWordObj: {},
emptyList: {},
//报表id
editAnswerId: null,
//报表组
versionGroupId: null,
//回答的id
answerId: null,
pid: "",
aid: "",
handleState: "",
inProgressReviewId: "",
auditHistoryData: "",
newTableStyle: {},
// 回填数据列表
reWriteList: [],
//对照表的数据
fatherList: [],
// 选择对比的报表id
fatherId: "",
// 测试含有说明时的校验
randonList: {
// 0:{
// 0:""
// }
},
// 说明
random: "",
passForMula: [], //可以不校验的公式格子
templateFormula:[],
templateRge:[]
};
},
created() {
_this = this;
this.pid = this.$route.query.projectId || "";
this.aid = this.$route.query.answerId || "";
this.inProgressReviewId = this.$route.query.inProgressReviewId || "";
this.handleState = this.$route.query.handleState || "";
},
mounted() {
this.handleIsEnd();
this.handleFatherList();
this.initDesigner3("designer-container", "", "edit");
let timer = setTimeout(() => {
this.handleGetAuditWord();
this.getRandonList();
this.handleReWriteData();
clearTimeout(timer);
}, 1000);
},
methods: {
// 请求父项目关联项目
async handleFatherList() {
if (this.$route.query && this.$route.query.reportId) {
let res = await seGetFatherList(this.$route.query.reportId);
this.fatherList = res.data.data.map((i) => ({
value: i.id,
label: i.reportName,
}));
}
},
handleTableAddRowUnlock() {
if (!this.spread3) return;
let oldOpenMenu = this.spread3.contextMenu.onOpenMenu;
this.spread3.contextMenu.onOpenMenu = function (
menuData,
itemsDataForShown,
hitInfo,
spread
) {
oldOpenMenu.apply(this, arguments);
itemsDataForShown.forEach((element, index) => {
//去除复制按钮和粘贴按钮
if (element.name == "gc.spread.copy") {
itemsDataForShown.splice(index, 10);
}
if (element.name === "gc.spread.tableInsert") {
element.subMenu.forEach((element) => {
if (
element.text.indexOf("列") == -1 &&
element.text.indexOf("上") == -1
) {
element.disable = false;
}
});
}
});
};
},
//获取spread3 填报报表实例方案二
initDesigner3: async function (
id,
reportIds = "",
type = "edit",
oldData = {}
) {
try {
let spread = new GC.Spread.Sheets.Workbook(id);
spread.options.newTabVisible = false;
//禁用复制粘贴功能
spread
.commandManager()
.setShortcutKey(null, 67, true, false, false, false);
spread
.commandManager()
.setShortcutKey(
null,
GC.Spread.Commands.Key.v,
true,
false,
false,
false
);
if (type === "edit") {
this.spread3 = spread;
} else {
this.spread2 = spread;
}
const reportId = reportIds || this.$route.query.reportId;
let styleRes = {};
//获取报表样式和回填数据
let {
data: { data },
status,
} = await seGetReportAllDatas(reportId);
this.reWriteList = data.fieldValues ? data.fieldValues : [];
if (localStorage.getItem("userInfo")) {
let userInfo = JSON.parse(localStorage.getItem("userInfo"));
this.reWriteList.push({
definition: {
id: "socialCode",
},
value: userInfo.loginName,
});
this.reWriteList.push({
definition: {
id: "businessName",
},
value: userInfo.name,
});
}
this.versionGroupId = data.reportAnswer
? data.reportAnswer.versionGroupId
: null;
this.editAnswerId = data.reportAnswer ? data.reportAnswer.id : null;
//这个接口需要返回answerid
this.answerId = data.userAnswerId ? data.userAnswerId : null;
this.$route.query.versionGroupId = this.versionGroupId
? this.versionGroupId
: this.$route.query.versionGroupId;
let reportStyle = data.reportStyle;
// this.logics = data.logics
this.getRegObj(data.logics);
if (status === 200) {
if (reportStyle) {
//请求线上的数据,暂定是使用axios请求传来的url
if (reportStyle.uploadType && reportStyle.filePath) {
await new Promise((resolve, reject) => {
axios.get(reportStyle.filePath).then((res) => {
if (res.status == 200) {
styleRes = res.data;
resolve(res.data);
} else {
resolve("error");
}
});
});
} else if (
typeof reportStyle.uploadType == "number" &&
reportStyle.uploadType == 0 &&
reportStyle.reportJson
) {
styleRes = JSON.parse(reportStyle.reportJson); //读取线下资源
}
}
}
// 获取填报数据
// this.handleTableInit(styleRes.sheets);
//多表初始化未成功
let fillData = "";
// 获取填报数据
if (this.$route.query.answerId || this.answerId) {
//这里需要区分对比表单还是填写表单的答案
let { data } = await seGetReportAnswerData({
answerId: this.answerId || this.$route.query.answerId,
reportId: reportIds || this.$route.query.reportId,
perm: "view",
});
let newReportStyle = data.data.reportAnswerStyle;
if (newReportStyle) {
await new Promise((resolve, reject) => {
axios.get(newReportStyle.filePath).then((res) => {
if (res.status == 200) {
// _this.answerStyle = res.data
_this.newTableStyle = res.data;
resolve(res);
} else {
resolve("error");
}
});
});
}
let _answerJson =
data.data &&
data.data.reportAnswer &&
data.data.reportAnswer.reportAnswerJson &&
data.data.reportAnswer.reportAnswerJson.answerJson;
fillData = (_answerJson && JSON.parse(_answerJson)) || "";
this.versionGroupId = data.reportAnswer
? data.reportAnswer.versionGroupId
: null;
this.$route.query.versionGroupId = this.versionGroupId
? this.versionGroupId
: this.$route.query.versionGroupId;
} else {
fillData = oldData || "";
}
if (type === "edit") {
this.styleRes = styleRes;
}
this.initRule();
this.initDesigner(
_this.handleNewStyle(_this.newTableStyle, styleRes),
fillData,
type
);
this.handleTableAddRowUnlock();
//获取最新和全部的审核意见
console.log(fillData, "fillData");
console.log(styleRes, "styleRes");
} catch (e) {
console.log(e, "error");
}
},
handleNewStyle(res, styleRes) {
let newSheetName = Object.keys(res);
if (!styleRes || !res) return styleRes;
Object.keys(styleRes.sheets).forEach((sheetName) => {
if (newSheetName.indexOf(sheetName) >= 0) {
let curSheetItem = styleRes.sheets[sheetName];
let objSheetItem = res[sheetName];
let tableName = Object.keys(objSheetItem);
curSheetItem.data.dataTable = objSheetItem.dataTable;
curSheetItem.tables.forEach((table, index) => {
if (tableName.indexOf(table.bindingPath) >= 0) {
curSheetItem.tables[index].rowCount =
objSheetItem[table.bindingPath];
curSheetItem.tables[index].rowFilter.range.rowCount =
objSheetItem[table.bindingPath] - 1;
}
});
}
});
return styleRes;
},
//选择对照表
handleSelect(e) {
e ? this.handleShowTable(e) : this.handleCloseShowTable();
},
//获取说明列表
async getRandonList() {
if (this.answerId || this.aid || this.$route.query.answerId) {
let res = await seGetRandonList(
this.answerId || this.aid || this.$route.query.answerId
);
if (res.data && res.data.data) {
try {
this.randonList = JSON.parse(res.data.data);
} catch (e) {}
}
}
},
//点击展示对照表
handleShowTable(id) {
//保存已经填写的数据
let allSheetsDataList = {};
for (let i = 0; i < this.spread3.getSheetCount(); i++) {
let sheet = this.spread3.getSheet(i);
if (sheet.getDataSource()) {
let data = sheet.getDataSource().getSource();
allSheetsDataList[sheet.name()] = {
data: data,
};
}
}
this.editTable = false;
let div = document.createElement("div");
div.setAttribute("id", "show-container");
div.style.minWidth = "50%";
div.style.height = "calc(85vh - 54px)";
this.$refs.excelArea.appendChild(div);
this.initDesigner3("show-container", id, "show");
// this.spread3.refresh()
setTimeout(() => {
this.editTable = true;
});
setTimeout(() => {
this.initDesigner3("designer-container", "", "edit", allSheetsDataList);
_this.isShowCompare = true;
}, 500);
},
//关闭对照列表同时保留已经填写的数据
handleCloseShowTable() {
this.$refs.excelArea.removeChild(
document.getElementById("show-container")
);
_this.isShowCompare = false;
this.spread3.refresh();
},
// 获取当前活动表对象
getActiveSheet() {
return this.spread3.getActiveSheet();
},
// 获取当前活动表数据
getActiveSheetData() {
return _this.spread3.toJSON().sheets[this.getActiveSheet().name()];
},
//获取初始reg对象
async getRegObj(similar) {
// let {data} = await seGetRegularList()
this.regObj = localReRule;
let regObj = {};
// let similar = data.data
if (similar) {
similar.forEach((item) => {
regObj[item.code] = {
...item,
reCode: item.code,
re:
item.re && new RegExp(item.re.replace("/", "").replace("/", "")),
};
delete regObj[item.code].code;
});
} else {
this.regObj.forEach((item) => {
regObj[item.code] = {
...item,
reCode: item.code,
re:
item.re && new RegExp(item.re.replace("/", "").replace("/", "")),
};
delete regObj[item.code].code;
});
}
this.regObj = regObj;
},
//新增table的新样式替换旧样式
handleNewTableStyle(styleRes) {
let newStyle = JSON.parse("{}");
if (styleRes && newStyle) {
Object.keys(newStyle).forEach((newKey) => {
Object.keys(styleRes.sheets).forEach((sheetKey) => {
if (newKey === sheetKey) {
styleRes.sheets[sheetKey].data.dataTable =
newStyle[newKey].dataTable;
styleRes.sheets[sheetKey].tables.forEach((tableItem, index) => {
let tableName = Object.keys(newStyle[newKey]);
if (tableName.indexOf(tableItem.bindingPath) > -1) {
styleRes.sheets[sheetKey].tables[index].rowCount =
newStyle[newKey][tableItem.bindingPath];
styleRes.sheets[sheetKey].tables[
index
].rowFilter.range.rowCount =
newStyle[newKey][tableItem.bindingPath] - 1;
}
});
}
});
});
}
return styleRes;
},
// 初始化填报页面
initDesigner(styleRes, fillData, type) {
let spread;
type === "edit" ? (spread = this.spread3) : (spread = this.spread2);
let data = {};
// let answerJson = JSON.parse('{"Sheet1":{"data":{"测试table":[{},{},{},{},{},{}],"测试默认table":[{},{},{}]}}}')
// fillData = answerJson
// styleRes = this.handleNewTableStyle(styleRes) || styleRes
spread.fromJSON(styleRes);
if (
this.$route.query &&
this.$route.query.type === "edit" &&
type === "edit"
) {
this.handleDataLock(spread, styleRes.sheets, false);
} else {
this.handleDataLock(spread, styleRes.sheets, true);
}
// spread.fromJSON(styleRes);3
for (let i = 0; i < spread.getSheetCount(); i++) {
let sheet = spread.getSheet(i);
this.listenCellEvent(sheet);
sheet.tables.all().forEach((table) => {
let dr = table.dataRange();
let path = table.bindingPath();
if (path && !data[path]) {
data[path] = [];
for (let i = 0; i < dr.rowCount; i++) {
data[path].push({});
}
}
if (this.$route.query.type === "edit" && type == "edit") {
sheet
.getRange(dr.row, dr.col, dr.rowCount, dr.colCount)
.locked(false);
} else {
console.log("show");
sheet
.getRange(dr.row, dr.col, dr.rowCount, dr.colCount)
.locked(true);
}
for (
let curRow = dr.row + 1;
curRow < dr.row + dr.rowCount;
curRow++
) {
sheet.copyTo(
dr.row,
dr.col,
curRow,
dr.col,
1,
dr.colCount,
GC.Spread.Sheets.CopyToOptions.style
);
}
});
let source = fillData[sheet.name()]
? new GC.Spread.Sheets.Bindings.CellBindingSource(
fillData[sheet.name()].data
)
: new GC.Spread.Sheets.Bindings.CellBindingSource(data);
sheet.setDataSource(source);
data = {}; // 重置数据源
}
//隐藏公式表
if (
this.$route.query.type &&
this.$route.query.type != "audit" &&
this.$route.query.type != "audit2"
) {
let formulaSheet =
spread.getSheetFromName("_formula") ||
spread.getSheetFromName("隐藏公式表") ||
null;
setTimeout(() => {
if (!formulaSheet) return;
formulaSheet.visible(false);
}, 100);
}
},
//是否该问卷已结束或者为设计中
handleIsEnd() {
this.$route.query.state && this.$route.query.state == 2
? this.$message.error("报表收集已结束,请退出答题")
: "";
this.$route.query.state && this.$route.query.state == 0
? this.$message.error("报表收集尚未开始,请退出答题")
: "";
},
//报表初始化或者切换时,对非数据源数据锁定
handleDataLock(spread, sheets, type = false) {
let sheetKey = Object.keys(sheets);
if (this.spread3) {
this.spread3.options.newTabVisible = false;
this.spread3.suspendPaint();
} else if (this.spread2) {
this.spread2.options.newTabVisible = false;
this.spread2.suspendPaint();
}
// this.spread3 ? (this.spread3.options.newTabVisible = false) : "";
// this.spread2 ? (this.spread2.options.newTabVisible = false) : "";
// 获取当前激活工作表名称
if (!sheets) return;
Array.isArray(Object.keys(sheets)) &&
Object.keys(sheets).forEach((item, index) => {
let curSheet = spread.getSheetFromName(sheetKey[index]);
for (let i in sheets[item].data["dataTable"]) {
spread.getSheetFromName(sheetKey[index]).options.isProtected = true;
spread.getSheetFromName(sheetKey[index]).options.protectionOptions =
{
allowSelectLockedCells: true,
allowSelectUnlockedCells: true,
allowInsertRows: false,
allowInsertColumns: false,
allowOutlineRows: false,
allowOutlineColumns: false,
};
for (let j in sheets[item].data["dataTable"][i]) {
if (curSheet.getBindingPath(Number(i), Number(j))) {
curSheet.getCell(Number(i), Number(j)).locked(type);
curSheet.getCell(Number(i), Number(j)).backColor("#f0f3c6");
}
}
}
});
if (this.spread3) {
// this.spread3.options.newTabVisible = false
this.spread3.resumePaint();
} else if (this.spread2) {
// this.spread2.options.newTabVisible = false
this.spread2.resumePaint();
}
},
//表格锁定设置
handleTableInit(sheets) {
for (let i in sheets) {
if (sheets[i].tables) {
sheets[i].tables.forEach((item) => {
let colStart = item.col;
let colCount = item.colCount;
let rowStart = item.row;
let rowCount = item.rowCount;
for (let j = 0; j < rowCount; j++) {
for (let k = 0; k < colCount; k++) {
if (
sheets[i].data.dataTable &&
sheets[i].data.dataTable[rowStart + j] &&
sheets[i].data.dataTable[rowStart + j][colStart + k] &&
sheets[i].data.dataTable[rowStart + j][colStart + k].style
) {
Object.assign(
sheets[i].data.dataTable[rowStart + j][colStart + k].style,
{ locked: true }
);
}
if (
sheets[i].data.dataTable &&
sheets[i].data.dataTable[rowStart + j] &&
sheets[i].data.dataTable[rowStart + j][colStart + k]
) {
sheets[i].data.dataTable[rowStart + j][colStart + k].style = {
locked: false,
};
} else if (
sheets[i].data.dataTable &&
sheets[i].data.dataTable[rowStart + j]
) {
sheets[i].data.dataTable[rowStart + j][colStart + k] = {
style: { locked: false },
value: "",
};
} else if (sheets[i].data.dataTable) {
sheets[i].data.dataTable[rowStart + j] = {};
sheets[i].data.dataTable[rowStart + j][colStart + k] = {};
sheets[i].data.dataTable[rowStart + j][colStart + k] = {
style: { locked: false },
value: "",
};
}
}
}
});
}
}
},
//返回当前dataTable的扁平化数据
handleDataTableReturn() {
let sheetObjList = [];
let jsonStr = this.spread3.toJSON().sheets;
Object.keys(jsonStr).forEach((sheetName) => {
let curSheetDataTable = jsonStr[sheetName].data.dataTable;
if (!curSheetDataTable) return;
//获取行坐标
Object.keys(curSheetDataTable).forEach((row) => {
//获取列坐标
Object.keys(curSheetDataTable[row]).forEach((col) => {
let curCellObj = {
row: row,
col: col,
sheetName: sheetName,
tag: curSheetDataTable[row][col]
? curSheetDataTable[row][col].tag
: {},
bindingPath: curSheetDataTable[row][col]
? curSheetDataTable[row][col].bindingPath
: "",
style: curSheetDataTable[row][col]
? curSheetDataTable[row][col].style
: {},
value: curSheetDataTable[row][col]
? curSheetDataTable[row][col].value
: "",
};
sheetObjList.push(curCellObj);
});
});
});
return sheetObjList;
},
//回填信息组装
handleReWriteData() {
let dataTable = this.handleDataTableReturn();
let reWriteValue = "";
dataTable.forEach((cellItem) => {
if (cellItem.tag && cellItem.tag.reWriteType) {
let curCell = this.spread3
.getSheetFromName(cellItem.sheetName)
.getCell(Number(cellItem.row), Number(cellItem.col));
let filterList = [];
this.reWriteList.forEach((item) => {
if (cellItem.tag.reWriteType == item.definition.id) {
filterList.push(item);
}
});
reWriteValue = filterList[0] ? filterList[0].value : "";
if (!curCell.value()) {
curCell.value(reWriteValue);
}
}
});
},
//组装传来的审核意见
handleInitAudit(commentsArr) {
if (!commentsArr) return;
let dataTable = this.handleDataTableReturn();
let getCellArr = [];
dataTable.forEach((cellItem) => {
commentsArr.forEach((commentItem) => {
if (cellItem.bindingPath == commentItem.dictName) {
getCellArr.push(cellItem);
let location = `${cellItem.row}_${cellItem.col}`;
this.auditWordObj[location] = commentItem.comment;
}
});
});
return getCellArr;
},
//获取以往的审核意见
async handleGetAuditWord() {
if (
this.$route.query.type == "audit" ||
this.$route.query.type == "audit2" ||
this.$route.query.type == "view"
) {
if (!this.pid || !this.aid) return;
//获取一审的意见,添加到二审
let secondAudit = await seGetAuditWordAll(this.pid, this.aid);
if (secondAudit.status == 200 && secondAudit.data) {
if (!secondAudit.data[0]) return;
let { comments } = secondAudit.data[0];
this.handleInitAudit(comments);
}
//只有上次保存审核意见后才能获取
if (
(this.handleState == 1 || this.handleState == 2) &&
this.inProgressReviewId != "null"
) {
let auditLast = await seGetAuditWord(this.pid, this.aid);
if (auditLast.status == 200 && auditLast.data) {
let { comments } = auditLast.data;
this.handleInitAudit(comments);
}
}
//获取历史意见
if (this.versionGroupId || this.$route.query.versionGroupId != null) {
let newGroupId = this.$route.query.versionGroupId;
if (!newGroupId || newGroupId == " ") return;
let auditWordHistory = await seGetAuditWordHistory(
this.pid,
newGroupId
);
this.auditHistoryData = auditWordHistory;
}
}
//获取驳回的意见
if (this.$route.query.type == "edit") {
let aid = this.$route.query.answerId || this.answerId;
if (!aid) return;
let res = await seGetAuditWordBack(aid);
let dataAudit = res.data.data;
let resultCode = res.data.resultCode;
if (resultCode === 200) {
try {
let lastComment = dataAudit.reportAnswer.reviewRecords[0].comments;
if (!lastComment) return;
let cellArr = this.handleInitAudit(lastComment);
cellArr.forEach((cell) => {
this.spread3
.getSheetFromName(cell.sheetName)
.getCell(Number(cell.row), Number(cell.col))
.backColor("#e7a6a6");
});
this.spread3.getSheetFromName();
} catch (e) {}
}
}
},
//审核方法
async handleAudit(type, auditTime) {
let comments = [];
let curSheetDataTable = this.handleDataTableReturn();
let AudioWorldLocation = Object.keys(this.auditWordObj);
// 抽取审核意见形成数组
curSheetDataTable.forEach((cellData) => {
if (cellData.bindingPath) {
AudioWorldLocation.forEach((location) => {
let row = location.split("_")[0];
let col = location.split("_")[1];
if (cellData.row == row && cellData.col == col) {
comments.push({
comment: this.auditWordObj[location],
dictName: cellData.bindingPath,
});
}
});
}
});
if (type === "audit" || type === "audit2") {
let auditObject = {
comments,
result: "APPROVED",
stage: auditTime,
};
//保存后的审核意见修改
if (
this.inProgressReviewId != "null" &&
(this.handleState == 1 || this.handleState == 2)
) {
let res = await seEditAuditWord(
this.pid,
this.aid,
this.inProgressReviewId,
auditObject
);
}
//新增审核意见
else if (this.handleState == 1 || this.handleState == 2) {
let res = await seSendAuditWord(this.pid, this.aid, auditObject);
}
this.$message.success("审核通过");
this.$router.push({
path: "/se/admin/project/report-management",
query: {
projectId: this.$route.query.projectId,
tabName: "DataAuditing",
},
});
} else if (type === "noPass") {
let auditObject = {
comments,
result: "REJECTED",
stage: auditTime,
};
if (
this.inProgressReviewId != "null" &&
(this.handleState == 1 || this.handleState == 2)
) {
let {
data: { resultCode, resultMsg },
} = await seEditAuditWord(
this.pid,
this.aid,
this.inProgressReviewId,
auditObject
);
resultCode == 200
? this.$message.error("审核不通过")
: this.$message.error(resultMsg);
} else {
let res = await seSendAuditWord(this.pid, this.aid, auditObject);
}
// this.$message.error( "审核不通过");
this.$router.push({
path: "/se/admin/project/report-management",
query: {
projectId: this.$route.query.projectId,
tabName: "DataAuditing",
},
});
} else if (type === "saveWord") {
let { data, status } = await seSendAuditWord(this.pid, this.aid, {
comments,
result: null,
stage: auditTime,
});
if (status === 200) {
this.inProgressReviewId = data.id;
this.versionGroupId = data.versionGroupId;
this.$message.success("保存审核意见成功");
} else {
this.$message.error("保存审核意见失败");
}
}
},
//查看历史审核意见
handleViewHistoryAudit() {
this.$refs.reportHistoryAudit.openDia(this.auditHistoryData);
},
//暂存填写数据
handleTempSaveData() {
this.sendData(seSaveReportData, "save");
},
async handlePass() {
// this.passForMula = []
_this.isPass = true;
this.emptyList = {};
this.spread3.suspendPaint();
await this.handleTempRegInit()
await this.handleFormulaInit();
await this.getForMulaPass();
this.validateCell();
this.validateCellOfficial();
this.spread3.resumePaint();
this.isCheck = true;
_this.isPass
? this.$message.success("校验通过")
: this.$message.error("校验不通过");
// 提交报表说明对象
this.handleRandonListSubmit();
},
handleTempRegInit(){
return new Promise((resolve,reject)=>{
if(this.templateRge){
this.templateRge.forEach((item,index)=>{
let dataArr = item.split('-')
let sheetName = dataArr[0]
let row = dataArr[1]
let col = dataArr[2]
let templateRegObj = JSON.parse(dataArr[3])
let curTag = this.spread3
.getSheetFromName(sheetName).getTag(Number(row),Number(col))
this.spread3
.getSheetFromName(sheetName).setTag(Number(row),Number(col),Object.assign(curTag,templateRegObj))
this.templateRge.splice(index,1)
})
resolve()
} else {
resolve()
}
})
},
handleRandonListSubmit() {
this.randonList;
},
/**保存填报数据 */
handleSubmitData() {
if (!this.isCheck) return this.$message.error("请先校验数据");
this.$confirm("提交后不能修改,是否确认提交", "提交", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
setTimeout(() => {
if (_this.isPass) {
this.sendData(seSubmitReportData);
} else {
this.$message.error("校验不通过,请更改答案");
}
}, 500);
})
.catch(() => {
this.$message.info("已取消提交");
});
},
//发送当前答案数据到后台
async sendData(API, mode = "") {
let {
data: { data },
} = await seGetReportAllDatas(this.$route.query.reportId);
this.editAnswerId = data.reportAnswer
? data.reportAnswer.id
: this.editAnswerId;
let allSheetsDataList = {};
this.resSource = this.spread3
.getActiveSheet()
.getDataSource()
.getSource();
console.log("this.resData=====================>", this.resSource);
for (let i = 0; i < this.spread3.getSheetCount(); i++) {
let sheet = this.spread3.getSheet(i);
if (sheet.getDataSource()) {
let data = sheet.getDataSource().getSource();
allSheetsDataList[sheet.name()] = {
data: data,
};
}
}
console.log("新的答案数据", {
reportId: this.$route.query.reportId,
answerJson: JSON.stringify(allSheetsDataList),
editAnswerId: this.editAnswerId,
versionGroupId: this.versionGroupId,
//传新增的table行
answerStyle: JSON.stringify(this.newTableStyle),
});
debugger
API({
reportId: this.$route.query.reportId,
answerJson: JSON.stringify(allSheetsDataList),
editAnswerId: this.editAnswerId,
versionGroupId: this.versionGroupId,
//传新增的table行
answerStyle: JSON.stringify(_this.newTableStyle),
cellDescription: JSON.stringify(this.randonList),
})
.then((res) => {
let _data = res.data || {};
this.editAnswerId = _data.data.id;
this.versionGroupId = _data.data.versionGroupId;
this.$message.success("保存成功");
if (mode !== "save") {
this.$router.back();
}
})
.catch((e) => {
this.$message.error(null);
});
},
handleFormulaInit(){
return new Promise((resolve,reject)=>{
if(this.templateFormula){
this.templateFormula.forEach((item,index)=>{
let dataArr = item.split('-')
let sheetName = dataArr[0]
let row = dataArr[1]
let col = dataArr[2]
let formula = dataArr[3]
this.spread3
.getSheetFromName(sheetName).setFormula(row,col,formula)
this.templateFormula.splice(index,1)
})
resolve()
} else {
resolve()
}
})
// this.spread3
// .getSheetFromName
},
// 校验是否存在空
handleIsEmpty() {
let emptyKeys = Object.keys(this.emptyList);
if (!emptyKeys[0]) return;
let dv = GC.Spread.Sheets.DataValidation.createTextLengthValidator(
GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.greaterThan,
"0",
"10"
);
dv.ignoreBlank(false);
emptyKeys.forEach((keys) => {
this.emptyList[keys].data.forEach((item) => {
this.spread3
.getSheetFromName(keys)
.setDataValidator(
Number(item[0]),
Number(item[1]),
dv,
GC.Spread.Sheets.SheetArea.viewport
);
});
});
_this.isPass = false;
this.spread3.options.highlightInvalidData = true;
},
handleauditAdvice() {
this.setNewTag(
{ auditWord: this.auditWord },
this.curCellRow,
this.curCellCol
);
this.$message.success("设置审核意见成功");
},
//设置cell的tag新属性
setNewTag(setTagObj, row, col) {
if (_this.getActiveSheet().getTag(row, col)) {
_this
.getActiveSheet()
.setTag(
row,
col,
Object.assign(_this.getActiveSheet().getTag(row, col), setTagObj)
);
} else {
_this.getActiveSheet().setTag(row, col, setTagObj);
}
},
// 绑定单元格监听
listenCellEvent(sheet) {
sheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e, info) {
_this.curCellRow = info.newSelections[0].row;
_this.curCellCol = info.newSelections[0].col;
//获取使用官方工具设置的校验规则(必须在设置时写明所设置的校验描述否则无法读取)
//获取校验规则描述
_this.getRuleDesc();
_this.getAuditPoints();
_this.getWordRequest();
_this.getAuditWord();
_this.getRandom();
});
sheet.bind(GC.Spread.Sheets.Events.ValueChanged, function (e, info) {
_this.getRelateInfo();
_this.setRelateCell();
});
//添加table
sheet.bind(GC.Spread.Sheets.Events.TableRowsChanged, function (e, info) {
for (let i = 0; i < _this.spread3.getSheetCount(); i++) {
let sheet = _this.spread3.getSheet(i);
sheet.tables.all().forEach((table) => {
let dr = table.dataRange();
if (_this.$route.query.type === "edit") {
sheet
.getRange(dr.row, dr.col, dr.rowCount, dr.colCount)
.locked(false);
} else {
sheet
.getRange(dr.row, dr.col, dr.rowCount, dr.colCount)
.locked(true);
}
for (
let curRow = dr.row + 1;
curRow < dr.row + dr.rowCount;
curRow++
) {
sheet.copyTo(
dr.row,
dr.col,
curRow,
dr.col,
1,
dr.colCount,
GC.Spread.Sheets.CopyToOptions.style
);
}
});
}
let curTableName = info.table.name();
let addRow = info.row;
let addount = info.count;
let curTableData = null;
sheet.tables.resize();
_this.getActiveSheetData().tables.forEach((table) => {
if (table.name == curTableName) {
curTableData = table;
let colCount = curTableData.colCount;
let rowCount = curTableData.rowCount;
let startRow = curTableData.row;
let startCol = curTableData.col;
let firstLineStyle = [];
let data =
_this.spread3.toJSON().sheets[_this.getActiveSheet().name()].data;
let newRow = startRow + rowCount - 1;
let oldRow = startRow + rowCount - 2;
try {
for (let i = startCol; i < startCol + colCount; i++) {
if (_this.getActiveSheet().getTag(oldRow, i)) {
_this
.getActiveSheet()
.setTag(
newRow,
i,
Object.assign(
_this.getActiveSheet().getTag(oldRow, i),
{}
)
);
}
}
if (_this.newTableStyle[_this.getActiveSheet().name()]) {
if (
!_this.newTableStyle[_this.getActiveSheet().name()].dataTable
) {
_this.newTableStyle[_this.getActiveSheet().name()].dataTable =
{};
}
if (
!_this.newTableStyle[_this.getActiveSheet().name()][
curTableData.bindingPath
]
) {
_this.newTableStyle[_this.getActiveSheet().name()][
curTableData.bindingPath
] = "";
}
} else {
_this.newTableStyle[_this.getActiveSheet().name()] = {};
}
} catch (e) {}
//新增的行数,包括表头
try {
_this.newTableStyle[_this.getActiveSheet().name()][
curTableData.bindingPath
] = rowCount;
_this.newTableStyle[_this.getActiveSheet().name()].dataTable =
_this.getActiveSheetData().data.dataTable;
} catch (e) {
console.log(e, "newTable");
}
}
});
});
},
//设置当前单元格说明
handleSubmitRandom() {
let curSheet = this.getActiveSheet().name();
if (
this.randonList[curSheet] &&
this.randonList[curSheet][this.curCellRow] &&
this.randonList[curSheet][this.curCellRow][this.curCellCol]
) {
this.randonList[curSheet][this.curCellRow][this.curCellCol] =
this.random.trim();
} else if (
this.randonList[curSheet] &&
this.randonList[curSheet][this.curCellRow]
) {
this.randonList[curSheet][this.curCellRow] = Object.assign(
this.randonList[curSheet][this.curCellRow],
{
[this.curCellCol]: this.random.trim(),
}
);
} else if (this.randonList[curSheet]) {
this.randonList[curSheet] = Object.assign(this.randonList[curSheet], {
[this.curCellRow]: {
[this.curCellCol]: this.random.trim(),
},
});
} else {
this.randonList = Object.assign(this.randonList, {
[curSheet]: {
[this.curCellRow]: {
[this.curCellCol]: this.random.trim(),
},
},
});
}
this.$message.success(
`已设置单元格(${this.curCellRow},${this.curCellCol})说明`
);
},
// 获取当前单元格的说明
getRandom() {
let curSheet = this.getActiveSheet().name()
if (this.randonList) {
if (
this.randonList[curSheet] &&
this.randonList[curSheet][this.curCellRow] &&
this.randonList[curSheet][this.curCellRow][this.curCellCol]
) {
this.random = this.randonList[curSheet][this.curCellRow][this.curCellCol];
return;
}
}
this.random = " ";
},
// 获取当前单元格的校验规则
getCurCellReg() {},
// 获取校验描述描述(自定义,官方,公式)
getRuleDesc() {
_this.curCellReg = " ";
try {
let currentCell = _this
.getActiveSheet()
.getCell(_this.curCellRow, _this.curCellCol);
let rangeStr = GC.Spread.Sheets.CalcEngine.rangeToFormula(currentCell)
.split("$")
.join("");
// 获取官方校验的描述
_this.getActiveSheetData().validations.forEach((item) => {
if (item.ranges == rangeStr) {
if (!_this.curCellReg) {
_this.curCellReg = "公式关联";
} else {
_this.curCellReg = item.inputMessage;
}
}
});
} catch (e) {}
try {
if (
// 获取自定义校验信息
_this.regObj[
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].tag.reCode
].des
) {
//获取自定义正则校验的描述
_this.curCellReg =
_this.regObj[
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].tag.reCode
].des;
}
} catch (e) {}
try {
//获取公式校验的公式
if (
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].formula
) {
_this.curCellReg =
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].formula;
}
} catch (e) {}
//获取是否必填
try {
_this.curCellReg ? _this.curCellReg : "";
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].tag.isRequire
? (_this.curCellReg += " - 必填 ")
: "";
} catch (e) {}
},
//获取当前单元格审核点
getAuditPoints() {
try {
// 获取审核点
_this.auditpoints =
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].tag.auditpoints;
} catch (e) {
_this.auditpoints = "";
}
},
//获取当前单元格审核意见
getAuditWord() {
try {
// 获取审核该单元格的审核意见(审核模块用)
_this.getAuditWords(_this.curCellRow, _this.curCellCol);
} catch (e) {
_this.auditWord = "";
}
},
getWordRequest() {
//获取填表要求
try {
_this.wordRequest =
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].tag.wordRequest;
} catch (e) {
_this.wordRequest = "";
}
},
//获取回填信息函数
getRelateInfo() {
//数据回填(企业->社会代码)
try {
// 后期根据接口替换回填的数据
let currentValue = _this
.getActiveSheet()
.getValue(_this.curCellRow, _this.curCellCol);
let relateDataSource = _this
.getActiveSheet()
.getTag(_this.curCellRow, _this.curCellCol).relateDataSource;
if (!relateDataSource) return;
let sheetsKeys = Object.keys(_this.spread3.toJSON().sheets);
let sheets = _this.spread3.toJSON().sheets;
sheetsKeys.forEach((item) => {
let curDataTable = sheets[item].data.dataTable;
let rowKeys = Object.keys(curDataTable);
rowKeys.forEach((row) => {
let colKeys = Object.keys(curDataTable[row]);
colKeys.forEach((col) => {
if (
curDataTable[row][col] &&
curDataTable[row][col].bindingPath == relateDataSource
) {
_this.spread3
.getSheetFromName(item)
.setValue(row, col, currentValue);
}
});
});
});
} catch (e) {}
},
//多选关联指定其他单元格设置必填(多选框的最后一个value必须值为 其他 或者 other)
setRelateCell() {
try {
if (
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
].style.cellType.typeName == "12"
) {
let curCellData =
_this.getActiveSheetData().data.dataTable[_this.curCellRow][
_this.curCellCol
];
_this.setNewTag(
{ isRequire: null },
curCellData.tag.relateRow,
curCellData.tag.relateCol
);
_this
.getActiveSheet()
.getCell(curCellData.tag.relateRow, curCellData.tag.relateCol)
.backColor("");
_this
.getActiveSheet()
.getValue(_this.curCellRow, _this.curCellCol)
.forEach((item) => {
if (item == "其他" || item == "other") {
let reCode =
_this.getActiveSheetData().data.dataTable[
curCellData.tag.relateRow
][curCellData.tag.relateCol].tag.reCode;
_this
.getActiveSheet()
.getCell(curCellData.tag.relateRow, curCellData.tag.relateCol)
.backColor("#aed19c");
_this.setNewTag(
{ isRequire: true, reCode: reCode || 2 },
curCellData.tag.relateRow,
curCellData.tag.relateCol
);
}
});
}
} catch (e) {
// console.log(e);
}
},
// 提交审核
handleSubmitAudit() {
this.auditWordObj[this.curCellRow + "_" + this.curCellCol] =
this.auditWord;
this.$message.success("提交成功");
},
getAuditWords(row, col) {
let keys = Object.keys(this.auditWordObj);
for (let i = 0; i < keys.length; i++) {
let arr = keys[i].split("_");
if (arr[0] == row && arr[1] == col) {
this.auditWord = this.auditWordObj[keys[i]];
break;
} else {
this.auditWord = "";
}
}
},
// 官方校验验证
validateCellOfficial() {
let spread = this.spread3;
spread.suspendPaint();
try {
for (let i = 0; i < spread.getSheetCount(); i++) {
let sheet = spread.getSheet(i);
let sheetName = spread.getSheet(i).name();
let sheetObj = spread.toJSON().sheets[sheetName];
if (sheetObj.validations) {
sheetObj.validations.forEach((items) => {
if (items.condition && items.condition.formula) {
let row = items.condition.ranges[0].row;
let col = items.condition.ranges[0].col;
if (this.passForMula.indexOf(`${row}-${col}`) == -1) {
if (
!sheet.isValid(row, col, sheet.getValue(row, col)) && sheetObj.getFormula &&
sheetObj.getFormula(row, col)
) {
;
_this.isPass = false;
}
}
}
});
}
}
} catch (e) {
// console.log(e, "error");
}
spread.resumePaint();
},
getForMulaPass() {
let isUpdate = false;
let spread = this.spread3;
return new Promise((resolve,reject)=>{
try {
for (let i = 0; i < this.spread3.getSheetCount(); i++) {
let sheet = this.spread3.getSheet(i);
let curDataTable =
this.spread3.toJSON().sheets[sheet.name()].data.dataTable;
if (!curDataTable) {
continue;
} else {
if (!isUpdate) {
this.passForMula = [];
isUpdate = true;
}
}
let rowKey = Object.keys(curDataTable);
rowKey.forEach((row) => {
let colKey = Object.keys(curDataTable[row]);
colKey.forEach((col) => {
//正则跳过检测
if (this.randonList[sheet.name()] && this.randonList[sheet.name()][row] && this.randonList[sheet.name()][row][col]) {
if(sheet.getTag(Number(row),Number(col)).reCode){
this.templateRge.push(`${sheet.name()}-${row}-${col}-${JSON.stringify(
{
reCode: sheet.getTag(Number(row),Number(col)).reCode || null,
isRequire : sheet.getTag(Number(row),Number(col)).isRequire || null,
}
)
}`)
sheet.setTag(Number(row),Number(col),Object.assign(sheet.getTag(Number(row),Number(col)),{
reCode: null,
isRequire: null
}))
sheet.setDataValidator(Number(row),Number(col),1,1,null)
}
};
//含有说明可以跳过检测公式
sheet.getPrecedents(Number(row), Number(col)).forEach((item) => {
let curSheet = spread.getSheetFromName(item.sheetName);
let curSheetName = curSheet.name()
if (
this.randonList[curSheetName]&&
this.randonList[curSheetName][item.row] &&
this.randonList[curSheetName][item.row][item.col]
) {
this.passForMula.push(`${row}-${col}`);
curSheet.getFormula(Number(row), Number(col));
;
if (
curSheet.getFormula(Number(row), Number(col))
) {
this.templateFormula.push(`${curSheet.name()}-${row}-${col}-${curSheet.getFormula(Number(row), Number(col))}`)
curSheet.setFormula(
Number(row),
Number(col),
null
);
curSheet.setValue(
Number(row),
Number(col),
true
);
}
}
});
});
});
}
resolve()
} catch (e) {
// console.log(e, "error");
resolve(e)
}
})
},
// 自定义校验方法
validateCell() {
let spread = this.spread3;
spread.suspendPaint();
try {
for (let i = 0; i < this.spread3.getSheetCount(); i++) {
let sheet = this.spread3.getSheet(i);
sheet.addCustomFunction(
new _this.customFunctions.VerificationRules()
);
sheet.addCustomFunction(
new _this.customFunctions.MultipleChoiceVerification()
);
let curDataTable =
this.spread3.toJSON().sheets[sheet.name()].data.dataTable;
if (!curDataTable) {
continue;
}
let rowKey = Object.keys(curDataTable);
rowKey.forEach((row) => {
let colKey = Object.keys(curDataTable[row]);
colKey.forEach((col) => {
//含有说明可以跳过检测
if (this.randonList[sheet.name()] && this.randonList[sheet.name()][row] && this.randonList[sheet.name()][row][col]) return
if (
curDataTable[row][col].formula &&
typeof curDataTable[row][col].value == "boolean"
) {
// 查看被依赖单元格
// console.log(sheet.getDependents(row,col));
;
let formulaRandom = false;
let regCode = "";
Object.keys(this.regObj).forEach((item) => {
if (
this.regObj[item].name == "布尔值校验" ||
this.regObj[item].des == "布尔值校验"
) {
regCode = Number(this.regObj[item].reCode);
}
});
if (!sheet.getValue(row, col)) {
//单元格是否含有说明,有说明不能进行校验
let isRandom = false;
sheet
.getPrecedents(Number(row), Number(col))
.forEach((item) => {
let curSheet = spread.getSheetFromName(item.sheetName);
let curSheetName = curSheet.name()
if (
this.randonList[curSheetName] &&
this.randonList[curSheetName][item.row] &&
this.randonList[curSheetName][item.row][item.col]
) {
sheet
.getPrecedents(Number(row), Number(col))
.forEach((items) => {
this.passForMula.push(`${items.row}-${items.col}`);
});
isRandom = true;
formulaRandom = true;
this.passForMula.push(`${row}-${col}`);
this.getActiveSheet().setTag(
item.row,
item.col,
Object.assign(curSheet.getTag(item.row, item.col), {
isRequire: false,
reCode: null,
})
);
this.getActiveSheet().setTag(
Number(row),
Number(col),
Object.assign(
curSheet.getTag(Number(row), Number(col)),
{
isRequire: false,
reCode: null,
}
)
);
}
if (!isRandom) {
if (curSheet.getTag(item.row, item.col)) {
curSheet.setTag(
item.row,
item.col,
Object.assign(curSheet.getTag(item.row, item.col), {
isRequire: true,
})
);
} else {
curSheet.setTag(item.row, item.col, {
isRequire: true,
});
}
let regCode = "";
;
this.handleRuleAdd(
Number(item.row),
Number(item.col),
this.spread3,
curSheet,
regCode
);
}
});
} else if (sheet.getValue(row, col)) {
let isRandom = false;
sheet
.getPrecedents(Number(row), Number(col))
.forEach((item) => {
let curSheet = spread.getSheetFromName(item.sheetName);
let curSheetName = curSheet.name()
if (
this.randonList[curSheetName] &&
this.randonList[curSheetName][item.row] &&
this.randonList[curSheetName][item.row][item.col]
) {
sheet
.getPrecedents(Number(row), Number(col))
.forEach((items) => {
this.passForMula.push(`${items.row}-${items.col}`);
});
isRandom = true;
formulaRandom = true;
this.passForMula.push(`${row}-${col}`);
this.getActiveSheet().setTag(
item.row,
item.col,
Object.assign(curSheet.getTag(item.row, item.col), {
isRequire: false,
reCode: null,
})
);
this.getActiveSheet().setTag(
Number(row),
Number(col),
Object.assign(
curSheet.getTag(Number(row), Number(col)),
{
isRequire: false,
reCode: null,
}
)
);
}
if (!isRandom) {
if (curSheet.getTag(item.row, item.col)) {
curSheet.setTag(
item.row,
item.col,
Object.assign(curSheet.getTag(item.row, item.col), {
isRequire: false,
})
);
} else {
curSheet.setTag(item.row, item.col, {
isRequire: false,
});
}
let regCode = "";
Object.keys(this.regObj).forEach((item) => {
if (
this.regObj[item].name == "必填校验" ||
this.regObj[item].des == "必填校验"
) {
regCode = Number(this.regObj[item].reCode);
}
});
;
this.handleRuleAdd(
Number(item.row),
Number(item.col),
this.spread3,
curSheet,
regCode
);
}
});
}
;
formulaRandom
? ""
: this.handleRuleAdd(Number(row), Number(col), this.spread3, sheet, regCode);
// console.log(sheet.getValue(row, col));
} else if (
curDataTable[row][col].tag &&
curDataTable[row][col].tag.reCode
) {
;
this.handleRuleAdd(
Number(row),
Number(col),
this.spread3,
sheet,
curDataTable[row][col].tag.reCode
);
}
});
});
}
_this.handleIsEmpty();
} catch (e) {
// console.log(e, "error");
}
spread.resumePaint();
},
handleRuleAdd(row, col, spread = this.spread3, sheet, reCode) {
let currentCell = sheet.getCell(row, col);
let rangeStr = GC.Spread.Sheets.CalcEngine.rangeToFormula(currentCell); // 获取当前单元格的字符串坐标
//设置校验规则
let nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(
GC.Spread.Sheets.ConditionalFormatting.ConditionType.formulaCondition
);
nCondition.customValueType(
GC.Spread.Sheets.ConditionalFormatting.CustomValueType.formula
);
if (this.passForMula.indexOf(`${row}-${col}`) != -1) return;
// 小于100000为正则 小于200000为多选 2为必填校验
if (
!sheet.getValue(row, col) &&
sheet.getTag(row, col) &&
sheet.getTag(row, col).isRequire
) {
;
if (this.emptyList[sheet.name()]) {
this.emptyList[sheet.name()].data.push([row, col]);
} else {
this.emptyList[sheet.name()] = {
data: [[row, col]],
};
}
} else {
;
if (reCode < 100000) {
;
nCondition.formula(`VerificationRules( ${rangeStr} , ${reCode})`);
} else if (reCode < 200000) {
nCondition.formula(
`MultipleChoiceVerification( ${rangeStr} , ${reCode})`
);
}
let validator =
new GC.Spread.Sheets.DataValidation.DefaultDataValidator(nCondition);
validator.type(GC.Spread.Sheets.DataValidation.CriteriaType.custom);
currentCell.validator(validator); // 为当前单元格设置数据验证
}
spread.options.highlightInvalidData = true;
},
//初始化校验函数
initRule() {
VerificationRules.prototype =
new GC.Spread.CalcEngine.Functions.Function();
MultipleChoiceVerification.prototype =
new GC.Spread.CalcEngine.Functions.Function();
// 正则
VerificationRules.prototype.evaluate = function (arg, type) {
;
if (arguments.length === 2 && !isNaN(type) && type) {
if (_this.isPass && _this.regObj[type].re.test(arg) == false) {
;
_this.isPass = false;
}
return _this.regObj[type].re.test(arg);
}
return "#VALUE!";
};
//多选
MultipleChoiceVerification.prototype.evaluate = function (arg, type) {
if (arguments.length === 2 && !isNaN(type)) {
let { min = 0, max = 100 } = _this.regObj[type];
return min <= arg.length && arg.length <= max;
}
return "#VALUE!";
};
_this.customFunctions.MultipleChoiceVerification =
MultipleChoiceVerification;
_this.customFunctions.VerificationRules = VerificationRules;
},
},
};
这是script的代码,我在点击单元格时,对sheet的数据进行循环,获取需要的信息,会不会是因为取得次数太多,导致了性能下降 |