Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat(cell date picker): cell date picker and bug solve
Browse files Browse the repository at this point in the history
n
  • Loading branch information
wpxp123456 committed Oct 23, 2020
1 parent 0f90060 commit 2996ae9
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 21 deletions.
41 changes: 41 additions & 0 deletions src/controllers/cellDatePickerCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import menuButton from './menuButton';
import formula from '../global/formula';
import Store from '../store';

const cellDatePickerCtrl = {
cellFocus: function(r, c, value){
let row = Store.visibledatarow[r],
row_pre = r == 0 ? 0 : Store.visibledatarow[r - 1];
let col = Store.visibledatacolumn[c],
col_pre = c == 0 ? 0 : Store.visibledatacolumn[c - 1];

let margeset = menuButton.mergeborer(Store.flowdata, r, c);
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];

col = margeset.column[1];
col_pre = margeset.column[0];
}

$(".cell-date-picker").show().css({
width: col - col_pre + 1,
height: row - row_pre + 1,
left: col_pre,
top: row_pre
})

$("#cellDatePickerBtn").daterangepicker({
singleDatePicker: true,
startDate: moment(value),
endDate: moment(value)
}, function(start) {
$("#luckysheet-rich-text-editor").html(start.format('YYYY-MM-DD'));
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
})

$("#cellDatePickerBtn").click();
},
}

export default cellDatePickerCtrl;
3 changes: 3 additions & 0 deletions src/controllers/constant.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/controllers/dataVerificationCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,16 @@ const dataVerificationCtrl = {
if(type == 'dropdown'){
let list = _this.getDropdownList(value1);

if(!list.includes(cellValue)){
return false;
let result = false;

for(let i = 0; i < list.length; i++){
if(list[i] == cellValue){
result = true;
break;
}
}

return result;
}
else if(type == 'checkbox'){

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,10 @@ const selection = {
delete value["f"];
delete value["spl"];

if(value.ct && value.ct.t == 'inlineStr'){
delete value.ct;
}

if(getObjType(x[c]) == "object"){

}
Expand Down
9 changes: 9 additions & 0 deletions src/controllers/updateCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import luckysheetFreezen from './freezen';
import menuButton from './menuButton';
import conditionformat from './conditionformat';
import alternateformat from './alternateformat';
import cellDatePickerCtrl from './cellDatePickerCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import {checkProtectionLocked,checkProtectionCellHidden} from './protection';
import { chatatABC } from '../utils/util';
Expand All @@ -26,6 +27,9 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
return;
}



//数据验证
if(dataVerificationCtrl.dataVerification != null && dataVerificationCtrl.dataVerification[row_index1 + '_' + col_index1] != null){
let dataVerificationItem = dataVerificationCtrl.dataVerification[row_index1 + '_' + col_index1];
if(dataVerificationItem.type == 'dropdown'){
Expand Down Expand Up @@ -227,6 +231,11 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
$("#luckysheet-input-box").css(input_postition);
$("#luckysheet-rich-text-editor").css(inputContentScale);

//日期
if(d[row_index1][col_index1] && d[row_index1][col_index1].ct && d[row_index1][col_index1].ct.t == 'd'){
cellDatePickerCtrl.cellFocus(row_index1, col_index1, d[row_index1][col_index1].m);
}

formula.rangetosheet = Store.currentSheetIndex;
formula.createRangeHightlight();
formula.rangeResizeTo = $("#luckysheet-rich-text-editor");
Expand Down
7 changes: 5 additions & 2 deletions src/css/luckysheet-core.css
Original file line number Diff line number Diff line change
Expand Up @@ -7060,8 +7060,11 @@ fieldset[disabled] .btn-danger.focus {
.luckysheet-modal-dialog-image .luckysheet-modal-dialog-content, #luckysheet-modal-dialog-activeImage .luckysheet-modal-dialog-content{
background: none;
}


/* 单元格日期选择 */
.cell-date-picker{
position: absolute;
display: none;
}
/* 数据验证 */
#luckysheet-dataVerification-dialog{
user-select: none;
Expand Down
38 changes: 21 additions & 17 deletions src/global/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const IDCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3
* @param {Number} options.order 工作表索引;默认值为当前工作表索引
*/
export function getCellValue(row, column, options = {}) {
if (row == null && column == null) {
if (!isRealNum(row) || !isRealNum(column)) {
return tooltip.info('Arguments row or column cannot be null or undefined.', '')
}
let curSheetOrder = getSheetIndex(Store.currentSheetIndex);
Expand Down Expand Up @@ -97,7 +97,7 @@ export function getCellValue(row, column, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function setCellValue(row, column, value, options = {}) {
if (getObjType(row) != "number" || getObjType(column) != "number") {
if (!isRealNum(row) || !isRealNum(column)) {
return tooltip.info('The row or column parameter is invalid.', '');
}

Expand Down Expand Up @@ -208,7 +208,7 @@ export function setCellValue(row, column, value, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function clearCell(row, column, options = {}) {
if (row == null || column == null) {
if (!isRealNum(row) || !isRealNum(column)) {
return tooltip.info('Arguments row and column cannot be null or undefined.', '')
}

Expand Down Expand Up @@ -267,7 +267,7 @@ export function deleteCell(move, row, column, options = {}) {
return tooltip.info('Arguments move cannot be null or undefined and its value must be \'left\' or \'up\'', '')
}

if (row == null || column == null) {
if (!isRealNum(row) || !isRealNum(column)) {
return tooltip.info('Arguments row and column cannot be null or undefined.', '')
}

Expand Down Expand Up @@ -304,7 +304,7 @@ export function deleteCell(move, row, column, options = {}) {
* @param {Function} options.success 操作结束的回调函数, callback参数为改变后的cell对象
*/
export function setCellFormat(row, column, attr, value, options = {}) {
if (row == null && column == null) {
if (!isRealNum(row) || !isRealNum(column)) {
return tooltip.info('Arguments row or column cannot be null or undefined.', '')
}

Expand Down Expand Up @@ -890,6 +890,10 @@ export function setBothFrozen(isRange, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function insertRowOrColumn(type, index = 0, options = {}) {
if(!isRealNum(index)){
return tooltip.info('The index parameter is invalid.', '');
}

let curSheetOrder = getSheetIndex(Store.currentSheetIndex);
let {
number = 1,
Expand Down Expand Up @@ -965,7 +969,7 @@ export function insertColumn(column = 0, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function deleteRowOrColumn(type, startIndex, endIndex, options = {}) {
if (startIndex == null || endIndex == null) {
if (!isRealNum(startIndex) || !isRealNum(endIndex)) {
return tooltip.info('Please enter the index for deleting rows or columns correctly.', '')
}

Expand Down Expand Up @@ -1023,7 +1027,7 @@ export function deleteColumn(columnStart, columnEnd, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function hideRowOrColumn(type, startIndex, endIndex, options = {}) {
if (startIndex == null || endIndex == null) {
if (!isRealNum(startIndex) || !isRealNum(endIndex)) {
return tooltip.info('Please enter the index for deleting rows or columns correctly.', '')
}

Expand Down Expand Up @@ -1081,7 +1085,7 @@ export function hideRowOrColumn(type, startIndex, endIndex, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function showRowOrColumn(type, startIndex, endIndex, options = {}) {
if (startIndex == null || endIndex == null) {
if (!isRealNum(startIndex) || !isRealNum(endIndex)) {
return tooltip.info('Please enter the index for deleting rows or columns correctly.', '')
}

Expand Down Expand Up @@ -4303,7 +4307,7 @@ export function matrixCalculation(type, number, options = {}) {
return tooltip.info('The type parameter is invalid.', '')
}

if(number.toString() == "NaN"){
if(!isRealNum(number)){
return tooltip.info('The number parameter is invalid.', '')
}

Expand Down Expand Up @@ -4558,7 +4562,7 @@ export function setSheetCopy(options = {}) {
targetOrder = order + 1;
}

if(getObjType(targetOrder) != 'number'){
if(!isRealNum(targetOrder)){
return tooltip.info("The targetOrder parameter is invalid.", "");
}

Expand All @@ -4576,7 +4580,7 @@ export function setSheetCopy(options = {}) {
}

let afterObj = $("#luckysheet-sheets-item" + copyindex);
if(getObjType(targetOrder) == 'number'){
if(isRealNum(targetOrder)){
afterObj = $("#luckysheet-sheets-item" + Store.luckysheetfile[targetOrder - 1].index);
}

Expand Down Expand Up @@ -4695,7 +4699,7 @@ export function setSheetShow(options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function setSheetActive(order, options = {}) {
if(order == null || getObjType(order) != 'number' || Store.luckysheetfile[order] == null){
if(order == null || !isRealNum(order) || Store.luckysheetfile[order] == null){
return tooltip.info("The order parameter is invalid.", "");
}

Expand Down Expand Up @@ -4973,7 +4977,7 @@ export function setSheetOrder(orderList, options = {}) {
* @param {Function} options.success 操作结束的回调函数
*/
export function setSheetZoom(zoom, options = {}) {
if(getObjType(zoom) != 'number' && (zoom < 0.1 || zoom > 4)){
if(!isRealNum(zoom) || zoom < 0.1 || zoom > 4){
return tooltip.info("The zoom parameter is invalid.", "");
}

Expand Down Expand Up @@ -5118,14 +5122,14 @@ export function scroll(options = {}){
} = {...options}

if(scrollLeft != null){
if(getObjType(scrollLeft) != 'number'){
if(!isRealNum(scrollLeft)){
return tooltip.info("The scrollLeft parameter is invalid.", "");
}

$("#luckysheet-scrollbar-x").scrollLeft(scrollLeft);
}
else if(targetColumn != null){
if(getObjType(targetColumn) != 'number'){
if(!isRealNum(targetColumn)){
return tooltip.info("The targetColumn parameter is invalid.", "");
}

Expand All @@ -5137,14 +5141,14 @@ export function scroll(options = {}){


if(scrollTop != null){
if(getObjType(scrollTop) != 'number'){
if(!isRealNum(scrollTop)){
return tooltip.info("The scrollTop parameter is invalid.", "");
}

$("#luckysheet-scrollbar-y").scrollTop(scrollTop);
}
else if(targetRow != null){
if(getObjType(targetRow) != 'number'){
if(!isRealNum(targetRow)){
return tooltip.info("The targetRow parameter is invalid.", "");
}

Expand Down

0 comments on commit 2996ae9

Please sign in to comment.