function paramToString(v) {
return v == null ? null : v.toString();
}
function main(spreadsheetReport, ruleName, params) {
if (ruleName != "跳转") return;
var value = params[0][0];
var obj = {
name: "产品类别",
value,
value
};
jumpTo(spreadsheetReport, obj);
changeColor(spreadsheetReport);
addFont(spreadsheetReport, value);
};
//设置参数并刷新
function jumpTo(spreadsheetReport, obj) {
var paramsInfo = [];
//将参数放入参数数组
paramsInfo.push(obj);
//设置当前参数值
if (paramsInfo.length > 0) spreadsheetReport.setParamsInfo(paramsInfo);
//电子表格做局部刷新
spreadsheetReport.doAjaxRefresh();
};
//在产品类别后添加对应类别名称并设置红色字体
function addFont(spreadsheetReport, value) {
var lastTd = spreadsheetReport.getCell(1, 11);
var span = lastTd.getElementsByTagName("SPAN")[0];
if (!span) {
span = document.createElement("SPAN");
lastTd.appendChild(span);
}
span.innerText = "";
span.innerText = value;
span.style.color = "red";
}
//恢复上一个被修改字体的颜色并改变当前点击字体的颜色
function changeColor(spreadsheetReport) {
//恢复原来的颜色
if (spreadsheetReport.highlightCurrentCellLinkPosition) {
var td = spreadsheetReport.getCell(spreadsheetReport.highlightCurrentCellLinkPosition.row, spreadsheetReport.highlightCurrentCellLinkPosition.column);
var list = td.getElementsByTagName("SPAN");
for (var i = 0; i < list.length; i++) {
list[i].style.color = list[i]._color;
}
}
//设置颜色
var td = spreadsheetReport.getCell(spreadsheetReport.currentCellLinkPosition.row, spreadsheetReport.currentCellLinkPosition.column);
var list = td.getElementsByTagName("SPAN");
for (var i = 0; i < list.length; i++) {
list[i]._color = list[i].style.color;
list[i].style.color = "red"; //指定颜色,可以使用#AABBCC 这样的字符串声明RGB
}
//保留当前位置
spreadsheetReport.highlightCurrentCellLinkPosition = spreadsheetReport.currentCellLinkPosition;
}