|
@ -37,6 +37,7 @@ import { createFilterOptions } from '../controllers/filter'; |
|
|
import controlHistory from '../controllers/controlHistory'; |
|
|
import controlHistory from '../controllers/controlHistory'; |
|
|
import { zoomRefreshView, zoomNumberDomBind } from '../controllers/zoom'; |
|
|
import { zoomRefreshView, zoomNumberDomBind } from '../controllers/zoom'; |
|
|
import dataVerificationCtrl from "../controllers/dataVerificationCtrl"; |
|
|
import dataVerificationCtrl from "../controllers/dataVerificationCtrl"; |
|
|
|
|
|
import imageCtrl from '../controllers/imageCtrl'; |
|
|
import dayjs from "dayjs"; |
|
|
import dayjs from "dayjs"; |
|
|
import {getRangetxt } from '../methods/get'; |
|
|
import {getRangetxt } from '../methods/get'; |
|
|
const IDCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i; |
|
|
const IDCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i; |
|
@ -5865,6 +5866,292 @@ export function deleteDataVerification(options = {}) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 在指定的工作表中指定单元格位置插入图片 |
|
|
|
|
|
* @param {String} src 图片src |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Number} options.order 工作表下标;默认值为当前工作表下标 |
|
|
|
|
|
* @param {Number} options.rowIndex 要插入图片的单元格行下标;默认为0 |
|
|
|
|
|
* @param {Number} options.colIndex 要插入图片的单元格列下标;默认为0 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function insertImage(src, options = {}){ |
|
|
|
|
|
let { |
|
|
|
|
|
order = getSheetIndex(Store.currentSheetIndex), |
|
|
|
|
|
rowIndex, |
|
|
|
|
|
colIndex, |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
let file = Store.luckysheetfile[order]; |
|
|
|
|
|
|
|
|
|
|
|
if(file == null){ |
|
|
|
|
|
return tooltip.info("The order parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(file.index == Store.currentSheetIndex){ |
|
|
|
|
|
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; |
|
|
|
|
|
|
|
|
|
|
|
if(rowIndex == null){ |
|
|
|
|
|
rowIndex = last.row_focus || 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rowIndex < 0){ |
|
|
|
|
|
rowIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rowIndex > Store.visibledatarow.length){ |
|
|
|
|
|
rowIndex = Store.visibledatarow.length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(colIndex == null){ |
|
|
|
|
|
colIndex = last.column_focus || 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(colIndex < 0){ |
|
|
|
|
|
colIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(colIndex > Store.visibledatacolumn.length){ |
|
|
|
|
|
colIndex = Store.visibledatacolumn.length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let left = colIndex == 0 ? 0 : Store.visibledatacolumn[colIndex - 1]; |
|
|
|
|
|
let top = rowIndex == 0 ? 0 : Store.visibledatarow[rowIndex - 1]; |
|
|
|
|
|
|
|
|
|
|
|
let image = new Image(); |
|
|
|
|
|
image.onload = function(){ |
|
|
|
|
|
let width = image.width, |
|
|
|
|
|
height = image.height; |
|
|
|
|
|
|
|
|
|
|
|
let img = { |
|
|
|
|
|
src: src, |
|
|
|
|
|
left: left, |
|
|
|
|
|
top: top, |
|
|
|
|
|
originWidth: width, |
|
|
|
|
|
originHeight: height |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
imageCtrl.addImgItem(img); |
|
|
|
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
image.src = src; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
let images = file.images || {}; |
|
|
|
|
|
let config = file.config; |
|
|
|
|
|
let zoomRatio = file.zoomRatio || 1; |
|
|
|
|
|
|
|
|
|
|
|
let rowheight = file.row; |
|
|
|
|
|
let visibledatarow = file.visibledatarow || []; |
|
|
|
|
|
if(visibledatarow.length === 0){ |
|
|
|
|
|
let rh_height = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (let r = 0; r < rowheight; r++) { |
|
|
|
|
|
let rowlen = Store.defaultrowlen; |
|
|
|
|
|
|
|
|
|
|
|
if (config["rowlen"] != null && config["rowlen"][r] != null) { |
|
|
|
|
|
rowlen = config["rowlen"][r]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (config["rowhidden"] != null && config["rowhidden"][r] != null) { |
|
|
|
|
|
visibledatarow.push(rh_height); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rh_height += Math.round((rowlen + 1) * zoomRatio); |
|
|
|
|
|
|
|
|
|
|
|
visibledatarow.push(rh_height); //行的临时长度分布
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let colwidth = file.column; |
|
|
|
|
|
let visibledatacolumn = file.visibledatacolumn || []; |
|
|
|
|
|
if(visibledatacolumn.length === 0){ |
|
|
|
|
|
let ch_width = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (let c = 0; c < colwidth; c++) { |
|
|
|
|
|
let firstcolumnlen = Store.defaultcollen; |
|
|
|
|
|
|
|
|
|
|
|
if (config["columnlen"] != null && config["columnlen"][c] != null) { |
|
|
|
|
|
firstcolumnlen = config["columnlen"][c]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(config["colhidden"] != null && config["colhidden"][c] != null){ |
|
|
|
|
|
visibledatacolumn.push(ch_width); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ch_width += Math.round((firstcolumnlen + 1)*zoomRatio); |
|
|
|
|
|
|
|
|
|
|
|
visibledatacolumn.push(ch_width);//列的临时长度分布
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rowIndex == null){ |
|
|
|
|
|
rowIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rowIndex < 0){ |
|
|
|
|
|
rowIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(rowIndex > visibledatarow.length){ |
|
|
|
|
|
rowIndex = visibledatarow.length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(colIndex == null){ |
|
|
|
|
|
colIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(colIndex < 0){ |
|
|
|
|
|
colIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(colIndex > visibledatacolumn.length){ |
|
|
|
|
|
colIndex = visibledatacolumn.length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let left = colIndex == 0 ? 0 : visibledatacolumn[colIndex - 1]; |
|
|
|
|
|
let top = rowIndex == 0 ? 0 : visibledatarow[rowIndex - 1]; |
|
|
|
|
|
|
|
|
|
|
|
let image = new Image(); |
|
|
|
|
|
image.onload = function(){ |
|
|
|
|
|
let img = { |
|
|
|
|
|
src: src, |
|
|
|
|
|
left: left, |
|
|
|
|
|
top: top, |
|
|
|
|
|
originWidth: image.width, |
|
|
|
|
|
originHeight: image.height |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let width, height; |
|
|
|
|
|
let max = 400; |
|
|
|
|
|
|
|
|
|
|
|
if(img.originHeight < img.originWidth){ |
|
|
|
|
|
height = Math.round(img.originHeight * (max / img.originWidth)); |
|
|
|
|
|
width = max; |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
width = Math.round(img.originWidth * (max / img.originHeight)); |
|
|
|
|
|
height = max; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let imgItem = $.extend(true, {}, imageCtrl.imgItem); |
|
|
|
|
|
imgItem.src = img.src; |
|
|
|
|
|
imgItem.originWidth = img.originWidth; |
|
|
|
|
|
imgItem.originHeight = img.originHeight; |
|
|
|
|
|
imgItem.default.width = width; |
|
|
|
|
|
imgItem.default.height = height; |
|
|
|
|
|
imgItem.default.left = img.left; |
|
|
|
|
|
imgItem.default.top = img.top; |
|
|
|
|
|
imgItem.crop.width = width; |
|
|
|
|
|
imgItem.crop.height = height; |
|
|
|
|
|
|
|
|
|
|
|
let id = imageCtrl.generateRandomId(); |
|
|
|
|
|
images[id] = imgItem; |
|
|
|
|
|
|
|
|
|
|
|
file.images = images; |
|
|
|
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
image.src = src; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除指定工作表中的图片 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Number} options.order 工作表下标;默认值为当前工作表下标 |
|
|
|
|
|
* @param {String | Array} options.idList 要删除图片的id集合,也可为字符串`"all"`,all为所有的字符串;默认为`"all"` |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function deleteImage(options = {}){ |
|
|
|
|
|
let { |
|
|
|
|
|
order = getSheetIndex(Store.currentSheetIndex), |
|
|
|
|
|
idList = 'all', |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
let file = Store.luckysheetfile[order]; |
|
|
|
|
|
|
|
|
|
|
|
if(file == null){ |
|
|
|
|
|
return tooltip.info("The order parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let images = file.images; |
|
|
|
|
|
|
|
|
|
|
|
if(images == null){ |
|
|
|
|
|
return tooltip.info("The worksheet has no pictures to delete.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(idList != 'all' && getObjType(idList) != 'array'){ |
|
|
|
|
|
return tooltip.info("The idList parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(getObjType(idList) == 'array'){ |
|
|
|
|
|
idList.forEach(item => { |
|
|
|
|
|
delete images[item]; |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
images = null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
file.images = images; |
|
|
|
|
|
|
|
|
|
|
|
if(file.index == Store.currentSheetIndex){ |
|
|
|
|
|
if(imageCtrl.currentImgId != null && (idList == 'all' || idList.includes(imageCtrl.currentImgId))){ |
|
|
|
|
|
$("#luckysheet-modal-dialog-activeImage").hide(); |
|
|
|
|
|
$("#luckysheet-modal-dialog-cropping").hide(); |
|
|
|
|
|
$("#luckysheet-modal-dialog-slider-imageCtrl").hide(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
imageCtrl.images = images; |
|
|
|
|
|
imageCtrl.allImagesShow(); |
|
|
|
|
|
imageCtrl.init(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取指定工作表的图片配置 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Number} options.order 工作表下标;默认值为当前工作表下标 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function getImageOption(options = {}){ |
|
|
|
|
|
let { |
|
|
|
|
|
order = getSheetIndex(Store.currentSheetIndex), |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
let file = Store.luckysheetfile[order]; |
|
|
|
|
|
|
|
|
|
|
|
if(file == null){ |
|
|
|
|
|
return tooltip.info("The order parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(function(){ |
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
}, 1) |
|
|
|
|
|
|
|
|
|
|
|
return file.images; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* data => celldata ,data二维数组数据转化成 {r, c, v}格式一维数组 |
|
|
* data => celldata ,data二维数组数据转化成 {r, c, v}格式一维数组 |
|
|
* |
|
|
* |
|
|