|
@@ -865,6 +865,15 @@ const SpreadJsObj = {
|
|
|
sheet.getParent().focus();
|
|
|
sheet.showRow(index, spreadNS.VerticalPosition.center);
|
|
|
},
|
|
|
+ locateData: function (sheet, data) {
|
|
|
+ if (!sheet.zh_data) { return }
|
|
|
+ const index = sheet.zh_data.indexOf(data);
|
|
|
+ const sels = sheet.getSelections();
|
|
|
+ sheet.setSelection(index, sels[0].col, 1, 1);
|
|
|
+ SpreadJsObj.reloadRowsBackColor(sheet, [index, sels[0].row]);
|
|
|
+ sheet.getParent().focus();
|
|
|
+ sheet.showRow(index, spreadNS.VerticalPosition.center);
|
|
|
+ },
|
|
|
saveTopAndSelect: function (sheet, cacheKey) {
|
|
|
const sel = sheet.getSelections()[0];
|
|
|
const top = sheet.getViewportTopRow(1);
|
|
@@ -1693,16 +1702,20 @@ const SpreadJsObj = {
|
|
|
}
|
|
|
|
|
|
};
|
|
|
- proto.paint = function (canvas, value, x, y, w, h, style, options) {
|
|
|
- const col = options.sheet.zh_setting.cols[options.col];
|
|
|
+ proto.getActiveImage = function(sheet, iRow, iCol) {
|
|
|
+ const col = sheet.zh_setting.cols[iCol];
|
|
|
|
|
|
- const sortData = SpreadJsObj.getSortData(options.sheet);
|
|
|
- const data = sortData ? sortData[options.row] : null;
|
|
|
+ const sortData = SpreadJsObj.getSortData(sheet);
|
|
|
+ const data = sortData ? sortData[iRow] : null;
|
|
|
let showImage = true;
|
|
|
if (col.showImage && Object.prototype.toString.apply(col.showImage) === "[object Function]") {
|
|
|
showImage = col.showImage(data);
|
|
|
}
|
|
|
- const img = showImage ? this.getImage(options.sheet, options.row, options.col) : null;
|
|
|
+ const img = showImage ? this.getImage(sheet, iRow, iCol) : null;
|
|
|
+ return [col, img];
|
|
|
+ };
|
|
|
+ proto.paint = function (canvas, value, x, y, w, h, style, options) {
|
|
|
+ const [col, img] = this.getActiveImage(options.sheet, options.row, options.col);
|
|
|
|
|
|
const indent = col.indent ? col.indent : 10;
|
|
|
if (style.hAlign === spreadNS.HorizontalAlign.right) {
|
|
@@ -1802,15 +1815,8 @@ const SpreadJsObj = {
|
|
|
注释部分以进入鼠标进入图片,点击图片为基准更新图片,鼠标快速移动时,可能失效
|
|
|
*/
|
|
|
proto.processMouseDown = function (hitinfo) {
|
|
|
- const col = options.sheet.zh_setting.cols[hitinfo.col];
|
|
|
-
|
|
|
- const sortData = SpreadJsObj.getSortData(hitinfo.sheet);
|
|
|
- const data = sortData ? sortData[hitinfo.row] : null;
|
|
|
- let showImage = true;
|
|
|
- if (col.showImage && Object.prototype.toString.apply(col.showImage) === "[object Function]") {
|
|
|
- showImage = col.showImage(data);
|
|
|
- }
|
|
|
- const img = showImage ? this.getImage(hitinfo.sheet, hitinfo.row, hitinfo.col) : null;
|
|
|
+ const [col, img] = this.getActiveImage(hitinfo.sheet, hitinfo.row, hitinfo.col);
|
|
|
+ if (!img) return;
|
|
|
|
|
|
const halfX = img.width / 2, halfY = img.height / 2;
|
|
|
const indent = col.indent ? col.indent : 10;
|
|
@@ -1826,15 +1832,8 @@ const SpreadJsObj = {
|
|
|
}
|
|
|
};
|
|
|
proto.processMouseUp = function (hitinfo) {
|
|
|
- const col = options.sheet.zh_setting.cols[hitinfo.col];
|
|
|
-
|
|
|
- const sortData = SpreadJsObj.getSortData(hitinfo.sheet);
|
|
|
- const data = sortData ? sortData[hitinfo.row] : null;
|
|
|
- let showImage = true;
|
|
|
- if (col.showImage && Object.prototype.toString.apply(col.showImage) === "[object Function]") {
|
|
|
- showImage = col.showImage(data);
|
|
|
- }
|
|
|
- const img = showImage ? this.getImage(hitinfo.sheet, hitinfo.row, hitinfo.col) : null;
|
|
|
+ const [col, img] = this.getActiveImage(hitinfo.sheet, hitinfo.row, hitinfo.col);
|
|
|
+ if (!img) return;
|
|
|
|
|
|
const halfX = img.width / 2, halfY = img.height / 2;
|
|
|
const indent = col.indent ? col.indent : 10;
|
|
@@ -1856,15 +1855,8 @@ const SpreadJsObj = {
|
|
|
}
|
|
|
};
|
|
|
proto.processMouseMove = function (hitinfo) {
|
|
|
- const col = options.sheet.zh_setting.cols[hitinfo.col];
|
|
|
-
|
|
|
- const sortData = SpreadJsObj.getSortData(hitinfo.sheet);
|
|
|
- const data = sortData ? sortData[hitinfo.row] : null;
|
|
|
- let showImage = true;
|
|
|
- if (col.showImage && Object.prototype.toString.apply(col.showImage) === "[object Function]") {
|
|
|
- showImage = col.showImage(data);
|
|
|
- }
|
|
|
- const img = showImage ? this.getImage(hitinfo.sheet, hitinfo.row, hitinfo.col) : null;
|
|
|
+ const [col, img] = this.getActiveImage(hitinfo.sheet, hitinfo.row, hitinfo.col);
|
|
|
+ if (!img) return;
|
|
|
|
|
|
const halfX = img.width / 2, halfY = img.height / 2;
|
|
|
const indent = col.indent ? col.indent : 10;
|