Browse Source

rebuild: flatpickr and dayjs

master
zhangchen 5 years ago
parent
commit
fe26e5cdb7
  1. 7
      gulpfile.js
  2. 1
      package.json
  3. 24
      src/controllers/cellDatePickerCtrl.js
  4. 33
      src/controllers/conditionformat.js
  5. 135
      src/controllers/dropCell.js
  6. 13
      src/controllers/server.js
  7. 647
      src/function/functionImplementation.js
  8. 6
      src/global/api.js
  9. 3
      src/global/datecontroll.js
  10. 13
      src/global/func_methods.js
  11. 421
      src/plugins/css/daterangepicker.css
  12. 97
      src/plugins/js/moment-msdate.js
  13. 1
      src/plugins/js/moment-timezone-with-data.min.js
  14. 7
      src/plugins/js/moment.min.js

7
gulpfile.js

@ -80,7 +80,7 @@ const paths = {
//plugins src
pluginsCss: ['src/plugins/css/*.css'],
plugins: ['src/plugins/*.css'],
css:['src/css/*.css'],
css:['src/css/*.css','node_modules/flatpickr/dist/themes/light.css'],
pluginsJs:[
'node_modules/jquery/dist/jquery.min.js',
//'src/plugins/js/jquery.min.js',
@ -88,12 +88,9 @@ const paths = {
'src/plugins/js/spectrum.min.js',
'src/plugins/js/jquery-ui.min.js',
'src/plugins/js/jquery.mousewheel.min.js',
'src/plugins/js/moment.min.js',
'src/plugins/js/moment-timezone-with-data.min.js',
'src/plugins/js/moment-msdate.js',
'src/plugins/js/numeral.min.js',
'src/plugins/js/html2canvas.min.js',
//'src/plugins/js/pako.min.js',
'src/plugins/js/pako.min.js',
'src/plugins/js/localforage.min.js',
'src/plugins/js/lodash.min.js',
'src/plugins/js/daterangepicker.js',

1
package.json

@ -30,6 +30,7 @@
"dependencies": {
"@babel/runtime": "^7.12.1",
"dayjs": "^1.9.4",
"flatpickr": "^4.6.6",
"jquery": "^3.5.1",
"jspdf": "^2.1.1",
"pako": "^1.0.11"

24
src/controllers/cellDatePickerCtrl.js

@ -1,6 +1,9 @@
import menuButton from './menuButton';
import formula from '../global/formula';
import Store from '../store';
import flatpickr from 'flatpickr'
import dayjs from "dayjs";
import {Mandarin} from "flatpickr/dist/l10n/zh"
const cellDatePickerCtrl = {
cellFocus: function(r, c, value){
@ -25,14 +28,21 @@ const cellDatePickerCtrl = {
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'));
flatpickr('#cellDatePickerBtn',{
locale: Mandarin,
dateFormat: "YYYY-MM-DD",
parseDate: (datestr, format) => {
return dayjs(datestr).toDate();
},
formatDate: (date, format, locale) => {
return dayjs(date).format(format);
},
onChange: function (selectedDates, dateStr, instance) {
console.log(selectedDates, dateStr)
$("#luckysheet-rich-text-editor").html(dateStr);
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
})
}
});
$("#cellDatePickerBtn").click();
},

33
src/controllers/conditionformat.js

@ -13,6 +13,7 @@ import sheetmanage from './sheetmanage';
import locale from '../locale/locale';
import {checkProtectionFormatCells} from './protection';
import Store from '../store';
import dayjs from 'dayjs'
//条件格式
const conditionformat = {
@ -2376,29 +2377,10 @@ const conditionformat = {
//日期选择插件
$('.ranges_1 ul').remove();
$('#' + id).find("#daterange-btn").daterangepicker({
ranges:
{
// [conditionformat_Text.all]: [moment(), moment().subtract(-1, 'days')],
[conditionformat_Text.yesterday]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
[conditionformat_Text.today]: [moment(), moment()],
// [conditionformat_Text.tomorrow]: [moment().subtract(-1, 'days'), moment().subtract(-1, 'days')],
[conditionformat_Text.lastWeek]: [moment(moment().subtract(1, 'week')).subtract(new Date().getDay() - 1, 'days'), moment().subtract(new Date().getDay(), 'days')],
[conditionformat_Text.thisWeek]: [moment().subtract(new Date().getDay() - 1, 'days'), moment().add(7 - new Date().getDay(), 'days')],
[conditionformat_Text.lastMonth]: [moment(moment().format('YYYY-MM')).subtract(1, 'month'), moment(moment().format('YYYY-MM')).subtract(1, 'day')],
[conditionformat_Text.thisMonth]: [moment().format('YYYY-MM'), moment(moment(moment().format('YYYY-MM')).add(1, 'month')).subtract(1, 'day')],
[conditionformat_Text.lastYear]: [moment(moment(moment().format('YYYY'))).subtract(1, 'years').format('YYYY'), moment(moment().format('YYYY')).subtract(1, 'day')],
[conditionformat_Text.thisYear]: [moment().format('YYYY'), moment(moment(moment().add(1, 'years')).format('YYYY')).subtract(1, 'day')],
[conditionformat_Text.last7days]: [moment().subtract(6, 'days'), moment()],
[conditionformat_Text.last30days]: [moment().subtract(29, 'days'), moment()]
// [conditionformat_Text.next7days]: [moment(),moment().subtract(-6, 'days')],
// [conditionformat_Text.next30days]: [moment(),moment().subtract(-29, 'days')],
// [conditionformat_Text.next60days]: [moment(),moment().subtract(-59, 'days'), ]
},
startDate: moment(),
endDate: moment()
},
function(start, end,label) {
$('#' + id).find("#daterange-btn").flatpickr({
mode: "range",
onChange:function(data,label) {
const [start, end] = data
//label:通过它来知道用户选择的是什么,传给后台进行相应的展示
let format1 = [
conditionformat_Text.yesterday,
@ -2420,10 +2402,11 @@ const conditionformat = {
$('#daterange-btn').val('');
}
else if(format1.indexOf(label) > -1){
$('#daterange-btn').val(start.format('YYYY/MM/DD'));
$('#daterange-btn').val(dayjs(start).format('YYYY/MM/DD'));
}
else if(format2.indexOf(label) > -1){
$('#daterange-btn').val(start.format('YYYY/MM/DD') + '-' + end.format('YYYY/MM/DD'));
$('#daterange-btn').val(dayjs(start).format('YYYY/MM/DD') + '-' + dayjs(end).format('YYYY/MM/DD'));
}
}
}
);

135
src/controllers/dropCell.js

@ -13,6 +13,7 @@ import { getSheetIndex } from '../methods/get';
import { getObjType, replaceHtml } from '../utils/util';
import Store from '../store';
import locale from '../locale/locale';
import dayjs from 'dayjs'
//选区下拉
const luckysheetDropCell = {
@ -1496,12 +1497,12 @@ const luckysheetDropCell = {
let judgeDate = _this.judgeDate(data);
if(judgeDate[0] && judgeDate[3]){
//日一样,月差为等差数列,以月差为step
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
applyData = _this.FillMonths(data, len, step);
}
else if(!judgeDate[0] && judgeDate[2]){
//日不一样,日差为等差数列,以日差为step
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "days");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "days");
applyData = _this.FillDays(data, len, step);
}
else{
@ -1727,7 +1728,7 @@ const luckysheetDropCell = {
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "days");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "days");
applyData = _this.FillDays(data, len, step);
}
else{
@ -1738,12 +1739,12 @@ const luckysheetDropCell = {
let judgeDate = _this.judgeDate(data);
if(judgeDate[0] && judgeDate[3]){
//日一样,且月差为等差数列,以月差为step
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
applyData = _this.FillMonths(data, len, step);
}
else if(!judgeDate[0] && judgeDate[2]){
//日不一样,且日差为等差数列,以日差为step
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "days");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "days");
applyData = _this.FillDays(data, len, step);
}
else{
@ -1767,12 +1768,12 @@ const luckysheetDropCell = {
for(let i = 1; i <= newLen; i++){
let d = $.extend(true, {}, data[0]);
let day = moment(d["m"]).add(i, "days").day();
let day = dayjs(d["m"]).add(i, "days").day();
if(day == 0 || day == 6){
continue;
}
let date = moment(d["m"]).add(step * i, "days").format("YYYY-MM-DD");
let date = dayjs(d["m"]).add(step * i, "days").format("YYYY-MM-DD");
d["m"] = date;
d["v"] = genarate(date)[2];
applyData.push(d);
@ -1783,28 +1784,28 @@ const luckysheetDropCell = {
}
}
else if(data.length == 2){
if(moment(data[1]["m"]).date() == moment(data[0]["m"]).date() && moment(data[1]["m"]).diff(moment(data[0]["m"]), "months") != 0){
if(dayjs(data[1]["m"]).date() == dayjs(data[0]["m"]).date() && dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months") != 0){
//日一样,且月差大于一月,以月差为step(若那天为休息日,则向前取最近的工作日)
if(direction == "up" || direction == "left"){
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
for(let i = 1; i <= len; i++){
let index = (i - 1) % data.length;
let d = $.extend(true, {}, data[index]);
let day = moment(data[data.length - 1]).add(step * i, "months").day(),
let day = dayjs(data[data.length - 1]).add(step * i, "months").day(),
date;
if(day == 0){
date = moment(data[data.length - 1]).add(step * i, "months").subtract(2, "days").format("YYYY-MM-DD");
date = dayjs(data[data.length - 1]).add(step * i, "months").subtract(2, "days").format("YYYY-MM-DD");
}
else if(day == 6){
date = moment(data[data.length - 1]).add(step * i, "months").subtract(1, "days").format("YYYY-MM-DD");
date = dayjs(data[data.length - 1]).add(step * i, "months").subtract(1, "days").format("YYYY-MM-DD");
}
else{
date = moment(data[data.length - 1]).add(step * i, "months").format("YYYY-MM-DD");
date = dayjs(data[data.length - 1]).add(step * i, "months").format("YYYY-MM-DD");
}
d["m"] = date;
@ -1814,7 +1815,7 @@ const luckysheetDropCell = {
}
else{
//日不一样
if(Math.abs(moment(data[1]["m"]).diff(moment(data[0]["m"]))) > 7){
if(Math.abs(dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]))) > 7){
//若日差大于7天,以一月为step(若那天是休息日,则向前取最近的工作日)
let step_month;
if(direction == "down" || direction == "right"){
@ -1832,19 +1833,19 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_month * num, "months").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_month * num, "months").diff(dayjs(d["m"]), "days");
}
let day = moment(d["m"]).add(step, "days").day(),
let day = dayjs(d["m"]).add(step, "days").day(),
date;
if(day == 0){
date = moment(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
}
else if(day == 6){
date = moment(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
}
else{
date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
}
d["m"] = date;
@ -1870,19 +1871,19 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_day * num, "days").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_day * num, "days").diff(dayjs(d["m"]), "days");
}
let day = moment(d["m"]).add(step, "days").day(),
let day = dayjs(d["m"]).add(step, "days").day(),
date;
if(day == 0){
date = moment(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
}
else if(day == 6){
date = moment(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
}
else{
date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
}
d["m"] = date;
@ -1900,22 +1901,22 @@ const luckysheetDropCell = {
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
for(let i = 1; i <= len; i++){
let index = (i - 1) % data.length;
let d = $.extend(true, {}, data[index]);
let day = moment(data[data.length - 1]["m"]).add(step * i, "months").day(),
let day = dayjs(data[data.length - 1]["m"]).add(step * i, "months").day(),
date;
if(day == 0){
date = moment(data[data.length - 1]["m"]).add(step * i, "months").subtract(2, "days").format("YYYY-MM-DD");
date = dayjs(data[data.length - 1]["m"]).add(step * i, "months").subtract(2, "days").format("YYYY-MM-DD");
}
else if(day == 6){
date = moment(data[data.length - 1]["m"]).add(step * i, "months").subtract(1, "days").format("YYYY-MM-DD");
date = dayjs(data[data.length - 1]["m"]).add(step * i, "months").subtract(1, "days").format("YYYY-MM-DD");
}
else{
date = moment(data[data.length - 1]["m"]).add(step * i, "months").format("YYYY-MM-DD");
date = dayjs(data[data.length - 1]["m"]).add(step * i, "months").format("YYYY-MM-DD");
}
d["m"] = date;
@ -1925,7 +1926,7 @@ const luckysheetDropCell = {
}
else if(!judgeDate[0] && judgeDate[2]){
//日不一样,且日差为等差数列
if(Math.abs(moment(data[1]["m"]).diff(moment(data[0]["m"]))) > 7){
if(Math.abs(dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]))) > 7){
//若日差大于7天,以一月为step(若那天是休息日,则向前取最近的工作日)
let step_month
if(direction == "down" || direction == "right"){
@ -1943,19 +1944,19 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_month * num, "months").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_month * num, "months").diff(dayjs(d["m"]), "days");
}
let day = moment(d["m"]).add(step, "days").day(),
let day = dayjs(d["m"]).add(step, "days").day(),
date;
if(day == 0){
date = moment(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
}
else if(day == 6){
date = moment(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
}
else{
date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
}
d["m"] = date;
@ -1981,19 +1982,19 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_day * num, "days").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_day * num, "days").diff(dayjs(d["m"]), "days");
}
let day = moment(d["m"]).add(step, "days").day(),
let day = dayjs(d["m"]).add(step, "days").day(),
date;
if(day == 0){
date = moment(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
}
else if(day == 6){
date = moment(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
}
else{
date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
}
d["m"] = date;
@ -2026,13 +2027,13 @@ const luckysheetDropCell = {
applyData = _this.FillMonths(data, len, step);
}
else if(data.length == 2){
if(moment(data[1]["m"]).date() == moment(data[0]["m"]).date() && moment(data[1]["m"]).diff(moment(data[0]["m"]), "months") != 0){
if(dayjs(data[1]["m"]).date() == dayjs(data[0]["m"]).date() && dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months") != 0){
//日一样,且月差大于一月,以月差为step
if(direction == "up" || direction == "left"){
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
applyData = _this.FillMonths(data, len, step);
}
else{
@ -2053,10 +2054,10 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_month * num, "months").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_month * num, "months").diff(dayjs(d["m"]), "days");
}
let date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
let date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
d["m"] = date;
d["v"] = genarate(date)[2];
applyData.push(d);
@ -2071,7 +2072,7 @@ const luckysheetDropCell = {
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
applyData = _this.FillMonths(data, len, step);
}
else if(!judgeDate[0] && judgeDate[2]){
@ -2092,10 +2093,10 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_month * num, "months").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_month * num, "months").diff(dayjs(d["m"]), "days");
}
let date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
let date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
d["m"] = date;
d["v"] = genarate(date)[2];
applyData.push(d);
@ -2125,13 +2126,13 @@ const luckysheetDropCell = {
applyData = _this.FillYears(data, len, step);
}
else if(data.length == 2){
if(moment(data[1]["m"]).date() == moment(data[0]["m"]).date() && moment(data[1]["m"]).month() == moment(data[0]["m"]).month() && moment(data[1]["m"]).diff(moment(data[0]["m"]), "years") != 0){
if(dayjs(data[1]["m"]).date() == dayjs(data[0]["m"]).date() && dayjs(data[1]["m"]).month() == dayjs(data[0]["m"]).month() && dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "years") != 0){
//日月一样,且年差大于一年,以年差为step
if(direction == "up" || direction == "left"){
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "years");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "years");
applyData = _this.FillYears(data, len, step);
}
else{
@ -2152,10 +2153,10 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_year * num, "years").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_year * num, "years").diff(dayjs(d["m"]), "days");
}
let date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
let date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
d["m"] = date;
d["v"] = genarate(date)[2];
applyData.push(d);
@ -2170,7 +2171,7 @@ const luckysheetDropCell = {
data.reverse();
}
let step = moment(data[1]["m"]).diff(moment(data[0]["m"]), "years");
let step = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "years");
applyData = _this.FillYears(data, len, step);
}
else if((judgeDate[0] && judgeDate[3]) || judgeDate[2]){
@ -2191,10 +2192,10 @@ const luckysheetDropCell = {
let num = Math.ceil(i / data.length);
if(index == 0){
step = moment(d["m"]).add(step_year * num, "years").diff(moment(d["m"]), "days");
step = dayjs(d["m"]).add(step_year * num, "years").diff(dayjs(d["m"]), "days");
}
let date = moment(d["m"]).add(step, "days").format("YYYY-MM-DD");
let date = dayjs(d["m"]).add(step, "days").format("YYYY-MM-DD");
d["m"] = date;
d["v"] = genarate(date)[2];
applyData.push(d);
@ -2387,7 +2388,7 @@ const luckysheetDropCell = {
let d = $.extend(true, {}, data[index]);
let date = update("yyyy-MM-dd", d["v"]);
date = moment(date).add(step * i, "days").format("YYYY-MM-DD");
date = dayjs(date).add(step * i, "days").format("YYYY-MM-DD");
d["v"] = genarate(date)[2];
d["m"] = update(d["ct"]["fa"], d["v"]);
@ -2405,7 +2406,7 @@ const luckysheetDropCell = {
let d = $.extend(true, {}, data[index]);
let date = update("yyyy-MM-dd", d["v"]);
date = moment(date).add(step * i, "months").format("YYYY-MM-DD");
date = dayjs(date).add(step * i, "months").format("YYYY-MM-DD");
d["v"] = genarate(date)[2];
d["m"] = update(d["ct"]["fa"], d["v"]);
@ -2423,7 +2424,7 @@ const luckysheetDropCell = {
let d = $.extend(true, {}, data[index]);
let date = update("yyyy-MM-dd", d["v"]);
date = moment(date).add(step * i, "years").format("YYYY-MM-DD");
date = dayjs(date).add(step * i, "years").format("YYYY-MM-DD");
d["v"] = genarate(date)[2];
d["m"] = update(d["ct"]["fa"], d["v"]);
@ -2705,31 +2706,31 @@ const luckysheetDropCell = {
isEqualDiffDays = true,
isEqualDiffMonths = true,
isEqualDiffYears = true;
let sameDay = moment(data[0]["m"]).date(),
sameMonth = moment(data[0]["m"]).month();
let equalDiffDays = moment(data[1]["m"]).diff(moment(data[0]["m"]), "days");
let equalDiffMonths = moment(data[1]["m"]).diff(moment(data[0]["m"]), "months");
let equalDiffYears = moment(data[1]["m"]).diff(moment(data[0]["m"]), "years");
let sameDay = dayjs(data[0]["m"]).date(),
sameMonth = dayjs(data[0]["m"]).month();
let equalDiffDays = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "days");
let equalDiffMonths = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "months");
let equalDiffYears = dayjs(data[1]["m"]).diff(dayjs(data[0]["m"]), "years");
for(let i = 1; i < data.length; i++){
//日是否一样
if(moment(data[i]["m"]).date() != sameDay){
if(dayjs(data[i]["m"]).date() != sameDay){
isSameDay = false;
}
//月是否一样
if(moment(data[i]["m"]).month() != sameMonth){
if(dayjs(data[i]["m"]).month() != sameMonth){
isSameMonth = false;
}
//日差是否是 等差数列
if(moment(data[i]["m"]).diff(moment(data[i - 1]["m"]), "days") != equalDiffDays){
if(dayjs(data[i]["m"]).diff(dayjs(data[i - 1]["m"]), "days") != equalDiffDays){
isEqualDiffDays = false;
}
//月差是否是 等差数列
if(moment(data[i]["m"]).diff(moment(data[i - 1]["m"]), "months") != equalDiffMonths){
if(dayjs(data[i]["m"]).diff(dayjs(data[i - 1]["m"]), "months") != equalDiffMonths){
isEqualDiffMonths = false;
}
//年差是否是 等差数列
if(moment(data[i]["m"]).diff(moment(data[i - 1]["m"]), "years") != equalDiffYears){
if(dayjs(data[i]["m"]).diff(dayjs(data[i - 1]["m"]), "years") != equalDiffYears){
isEqualDiffYears = false;
}
}

13
src/controllers/server.js

@ -11,6 +11,7 @@ import { getObjType, replaceHtml, getByteLen } from '../utils/util';
import { getSheetIndex } from '../methods/get';
import Store from '../store';
import locale from '../locale/locale';
import dayjs from "dayjs";
const server = {
gridKey: null,
@ -762,12 +763,12 @@ const server = {
let _this = this;
clearTimeout(_this.requestTimeOut);
//console.log(_this.requestlast, moment(), (_this.requestlast!=null && _this.requestlast.add(10, 'seconds').isBefore(moment()) ) );
if(!_this.requestLock && (_this.requestlast!=null && _this.requestlast.clone().add(1, 'seconds').isBefore(moment()) ) ){
//console.log(_this.requestlast, dayjs(), (_this.requestlast!=null && _this.requestlast.add(10, 'seconds').isBefore(dayjs()) ) );
if(!_this.requestLock && (_this.requestlast!=null && _this.requestlast.clone().add(1, 'seconds').isBefore(dayjs()) ) ){
_this.request();
}
// if(!_this.imageRequestLock && (_this.imageRequestLast==null || _this.imageRequestLast.clone().add(30, 'seconds').isBefore(moment()) ) ){
// if(!_this.imageRequestLock && (_this.imageRequestLast==null || _this.imageRequestLast.clone().add(30, 'seconds').isBefore(dayjs()) ) ){
// }
@ -804,7 +805,7 @@ const server = {
$.post(_this.updateUrl, { compress: iscommpress, gridKey: _this.gridKey, data: params }, function (data) {
let re = eval('('+ data +')')
if(re.status){
$("#luckysheet_info_detail_update").html("最近存档时间:"+ moment().format("M-D H:m:s"));
$("#luckysheet_info_detail_update").html("最近存档时间:"+ dayjs().format("M-D H:m:s"));
$("#luckysheet_info_detail_save").html("同步成功");
_this.clearcachelocaldata();
}
@ -812,7 +813,7 @@ const server = {
$("#luckysheet_info_detail_save").html("<span style='color:#ff2121'>同步失败</span>");
_this.restorecachelocaldata();
}
_this.requestlast = moment();
_this.requestlast = dayjs();
_this.requestLock = false;
});
}
@ -864,7 +865,7 @@ const server = {
$.post(_this.updateImageUrl, { compress: false, gridKey: _this.gridKey, data:data1 }, function (data) {
let re = eval('('+ data +')')
if(re.status){
imageRequestLast = moment();
imageRequestLast = dayjs();
}
else{
$("#luckysheet_info_detail_save").html("<span style='color:#ff2121'>网络不稳定</span>");

647
src/function/functionImplementation.js

File diff suppressed because it is too large

6
src/global/api.js

@ -37,7 +37,7 @@ import { createFilterOptions } from '../controllers/filter';
import controlHistory from '../controllers/controlHistory';
import { zoomRefreshView, zoomNumberDomBind } from '../controllers/zoom';
import dataVerificationCtrl from "../controllers/dataVerificationCtrl";
import dayjs from "dayjs";
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;
@ -3372,10 +3372,10 @@ export function setRangeConditionalFormatDefault(conditionName, conditionValue,
let v;
if(diff(v1, v2) > 0){
v = moment(v2).format("YYYY/MM/DD") + "-" + moment(v1).format("YYYY/MM/DD");
v = dayjs(v2).format("YYYY/MM/DD") + "-" + dayjs(v1).format("YYYY/MM/DD");
}
else{
v = moment(v1).format("YYYY/MM/DD") + "-" + moment(v2).format("YYYY/MM/DD");
v = dayjs(v1).format("YYYY/MM/DD") + "-" + dayjs(v2).format("YYYY/MM/DD");
}
conditionValue2.push(v);

3
src/global/datecontroll.js

@ -1,4 +1,5 @@
import { hasChinaword } from './validate';
import dayjs from 'dayjs'
function isdatetime(s) {
if (s == null || s.toString().length < 5) {
@ -49,7 +50,7 @@ function isdatetime(s) {
}
function diff(now, then) {
return moment(now).diff(moment(then));
return dayjs(now).diff(dayjs(then));
}
function isdatatypemulti(s) {

13
src/global/func_methods.js

@ -2,6 +2,7 @@ import { getObjType } from '../utils/util';
import { isRealNum, isRealNull, valueIsError } from './validate';
import { update } from './format';
import formula from './formula';
import dayjs from "dayjs";
const error = {
v: "#VALUE!", //错误的参数或运算符
@ -571,17 +572,17 @@ const func_methods = {
feb29Between: function(date1, date2){
let _this = this;
let year1 = moment(date1).year();
let mar1year1 = moment().set({ 'year': year1, 'month': 2, 'date': 1 });
let year1 = dayjs(date1).year();
let mar1year1 = dayjs().set({ 'year': year1, 'month': 2, 'date': 1 });
if (_this.isLeapYear(year1) && moment(date1) < moment(mar1year1) && moment(date2) >= moment(mar1year1)) {
if (_this.isLeapYear(year1) && dayjs(date1) < dayjs(mar1year1) && dayjs(date2) >= dayjs(mar1year1)) {
return true;
}
let year2 = moment(date2).year();
let mar1year2 = moment().set({ 'year': year2, 'month': 2, 'date': 1 });
let year2 = dayjs(date2).year();
let mar1year2 = dayjs().set({ 'year': year2, 'month': 2, 'date': 1 });
return (_this.isLeapYear(year2) && moment(date2) >= moment(mar1year2) && moment(date1) < moment(mar1year2));
return (_this.isLeapYear(year2) && dayjs(date2) >= dayjs(mar1year2) && dayjs(date1) < dayjs(mar1year2));
},
//SQL 查询
findResultIndex: function(database, criterias){

421
src/plugins/css/daterangepicker.css

@ -1,421 +0,0 @@
.daterangepicker {
display: none;
position: absolute;
color: inherit;
background: #fff;
border-radius: 4px;
width: 278px;
padding: 4px;
margin-top: 1px;
top: 100px;
left: 20px;
padding-bottom: 50px;
font-size: 14px;
border: 1px solid rgba(0,0,0,.15);
}
.daterangepicker table{
border-collapse: collapse;
border-spacing: 0;
}
.daterangepicker table td,.daterangepicker table th{
padding: 5px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.daterangepicker:before, .daterangepicker:after {
position: absolute;
display: inline-block;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.daterangepicker:before {
top: -7px;
border-right: 7px solid transparent;
border-left: 7px solid transparent;
border-bottom: 7px solid #ccc;
}
.daterangepicker:after {
top: -6px;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
border-left: 6px solid transparent;
}
.daterangepicker.opensleft:before {
right: 9px;
}
.daterangepicker.opensleft:after {
right: 10px;
}
.daterangepicker.openscenter:before {
left: 0;
right: 0;
width: 0;
margin-left: auto;
margin-right: auto;
}
.daterangepicker.openscenter:after {
left: 0;
right: 0;
width: 0;
margin-left: auto;
margin-right: auto;
}
.daterangepicker.opensright:before {
left: 9px;
}
.daterangepicker.opensright:after {
left: 10px;
}
.daterangepicker.dropup {
margin-top: -5px;
}
.daterangepicker.dropup:before {
top: initial;
bottom: -7px;
border-bottom: initial;
border-top: 7px solid #ccc;
}
.daterangepicker.dropup:after {
top: initial;
bottom: -6px;
border-bottom: initial;
border-top: 6px solid #fff;
}
.daterangepicker.dropdown-menu {
max-width: none;
z-index: 1000000;
}
.daterangepicker.single .ranges, .daterangepicker.single .calendar {
float: none;
}
.daterangepicker.show-calendar .calendar {
display: block;
}
.daterangepicker .calendar {
display: block;
max-width: 270px;
margin: 4px;
margin-top: -30px;
}
.daterangepicker .calendar.single .calendar-table {
border: none;
}
.daterangepicker .calendar th, .daterangepicker .calendar td {
white-space: nowrap;
text-align: center;
min-width: 32px;
}
.daterangepicker .calendar-table {
border: 1px solid #fff;
padding: 4px;
border-radius: 4px;
background: #fff;
}
.daterangepicker table {
width: 100%;
margin: 0;
}
.daterangepicker td, .daterangepicker th {
text-align: center;
width: 20px;
height: 20px;
line-height: 20px;
border-radius: 4px;
border: 1px solid transparent;
white-space: nowrap;
cursor: pointer;
}
.daterangepicker td.available:hover, .daterangepicker th.available:hover {
background: #eee;
}
.daterangepicker td.week, .daterangepicker th.week {
font-size: 80%;
color: #ccc;
}
.daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date {
background-color: #fff;
border-color: transparent;
color: #999;
}
.daterangepicker td.in-range {
background-color: #d9e3ff;
border-color: transparent;
color: #000;
border-radius: 0;
}
.daterangepicker td.start-date {
border-radius: 4px 0 0 4px;
}
.daterangepicker td.end-date {
border-radius: 0 4px 4px 0;
}
.daterangepicker td.start-date.end-date {
border-radius: 4px;
}
.daterangepicker td.active, .daterangepicker td.active:hover {
background-color: #477cff;
border-color: transparent;
color: #fff;
}
.daterangepicker th.month {
width: auto;
}
.daterangepicker td.disabled, .daterangepicker option.disabled {
color: #999;
cursor: not-allowed;
text-decoration: line-through;
}
.daterangepicker select.monthselect, .daterangepicker select.yearselect {
font-size: 12px;
padding: 1px;
height: auto;
margin: 0;
cursor: default;
vertical-align: top;
}
.daterangepicker select.monthselect {
margin-right: 2%;
width: 56%;
}
.daterangepicker select.yearselect {
width: 40%;
}
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
width: 50px;
margin-bottom: 0;
}
.daterangepicker .input-mini {
border: 1px solid #ccc;
border-radius: 4px;
color: #555;
height: 30px;
line-height: 30px;
display: block;
vertical-align: middle;
margin: 0 0 5px 0;
padding: 0 6px 0 0px;
width: 100%;
}
.daterangepicker .input-mini.active {
/*border: 1px solid #08c;
border-radius: 4px; */
}
.daterangepicker .daterangepicker_input {
position: relative;
}
.daterangepicker .daterangepicker_input input{
border:0;
color: #477cff;
}
.daterangepicker .daterangepicker_input i {
position: absolute;
left: 8px;
top: 8px;
}
.daterangepicker .calendar-time {
text-align: center;
margin: 5px auto;
line-height: 30px;
position: relative;
padding-left: 28px;
}
.daterangepicker .calendar-time select.disabled {
color: #ccc;
cursor: not-allowed;
}
.ranges {
font-size: 11px;
float: none;
margin: 4px;
text-align: left;
border-right: 1px solid #efeff0;
margin-right: 15px;
}
.ranges ul {
list-style: none;
margin: 0 auto;
padding: 0;
width: 100%;
}
.ranges li {
font-size: 12px;
/*background: #f5f5f5;*/
/*border: 1px solid #f5f5f5;*/
/*border-radius: 4px;*/
color: #72777a;
padding: 3px 12px;
height: 20px;
line-height: 14px;
margin-bottom: 8px;
cursor: pointer;
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.ranges li:hover {
/*background: #08c;
border: 1px solid #08c;*/
color: #6072FF;
}
.ranges li.active {
/*background: #08c;*/
border: 1px solid #efeff0;
color: #477cff;
}
@media (min-width: 564px) {
.daterangepicker {
width: auto;
}
.daterangepicker .ranges ul {
width: 120px;
}
.daterangepicker.single .ranges ul {
width: 100%;
}
.daterangepicker.single .calendar.left {
clear: none;
}
.daterangepicker.single .ranges, .daterangepicker.single .calendar {
float: left;
}
.daterangepicker .calendar.left {
clear: left;
margin-right: 0;
}
.daterangepicker .calendar.left .calendar-table {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.daterangepicker .calendar.right {
margin-left: 0;
}
.daterangepicker .calendar.right .calendar-table {
border-left: none;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.daterangepicker .left .daterangepicker_input {
padding-right: 12px;
}
.daterangepicker .calendar.left .calendar-table {
padding-right: 12px;
}
.daterangepicker .ranges, .daterangepicker .calendar {
float: left;
}
}
@media (min-width: 730px){
.daterangepicker .ranges {
width: auto;
float: left;
}
.daterangepicker .calendar.left {
clear: none;
}
}
.applyBtn,.cancelBtn{
padding: 0;
width: 60px;
height: 28px !important;
font-size: 12px;
}
.applyBtn{
border-color: #2196f3;
background-color: #2196f3;
color: #fff;
}
.cancelBtn{
background: #ffffff;
color: #666 !important;
border: 1px solid #d9dbdc;
}
.applyBtn:hover{
border-color: #2196f3 !important;
background-color: #2196f3 !important;
color: #fff !important;
}
.cancelBtn:hover{
background: #ffffff !important;
color: #666 !important;
border: 1px solid #d9dbdc !important;
}
.ranges_1 ul {
display: none;
}
.ranges_1 .range_inputs {
position: absolute;
bottom: 0;
margin-bottom: 15px;
right: 60px;
}
.calendar_1 {
position: absolute;
right: 340px;
bottom: 4px;
width: 125px;
}
.calendar_2 {
position: absolute;
right: 238px;
bottom: 4px;
width: 125px;
}
.line_date {
width: 100%;
height: 1px;
border-bottom: 1px solid #efeff0;
position: absolute;
bottom: 53px;
right: 0;
}
.line_date_2 {
width: 7px;
height: 1px;
border-bottom: 1px solid #477cff;
position: absolute;
bottom: 28px;
right: 380px;
}
.daterangepicker .all{
position: absolute;
bottom: 14px;
right: 282px;
width: 188px;
height: 30px;
line-height: 30px;
background-color: #ffffff;
color: #477cff;
display: none;
}
.daterangepicker .prev {
position: relative;
left: 33px;
}
.daterangepicker .next {
position: relative;
right: 33px;
}
.prev_year,.prev_month{
width: 30px;
height:30px;
position: relative;
display: inline-block;
line-height: 30px;
text-align: center;
}
.prev_year:hover,.prev_month:hover{
background: #eeeeee;
cursor: pointer;
}
.prev_year i,.prev_month i{
font-size: 16px;
color: #000;
}
.prev_year{
left: 15px;
top: 36px;
}
.prev_month{
left: 191px;
top: 36px;
}

97
src/plugins/js/moment-msdate.js

@ -1,97 +0,0 @@
'use strict';
(function(root, factory) {
/*global define*/
if (typeof define === 'function' && define.amd) {
define(['moment', 'moment-timezone'], factory); // AMD
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require('moment'), require('moment-timezone')); // Node
} else {
factory(root.moment, root.moment.tz); // Browser
}
}(this, function(moment, momentTimezone) {
var MINUTE_MILLISECONDS = 60 * 1000;
var DAY_MILLISECONDS = 86400000;
var MS_DAY_OFFSET = 25569;
var momentVersion = moment.version.split('.');
var major = +momentVersion[0];
var minor = +momentVersion[1];
if (major < 2 || (major === 2 && minor < 6)) {
throw new Error('moment-msdate requires Moment.js >= 2.6.0. You are using Moment.js ${moment.version}. See momentjs.com');
}
if (!momentTimezone || !moment.tz) {
throw new Error('moment-msdate requires moment-timezone.js. see momentjs.com/timezone');
}
var oaDateToTicks = function(oaDate) {
return ((oaDate - MS_DAY_OFFSET) * DAY_MILLISECONDS) + (oaDate >= 0.0 ? 0.5 : -0.5);
};
var ticksToOADate = function(ticks) {
return (ticks / DAY_MILLISECONDS) + MS_DAY_OFFSET;
};
/**
* @description takes an oaDate that is not in utc and converts it to a utc moment offset by a number of minutes
*
* @param {double} oaDate
* @param {string} offsetToUtcInMinutes
* @returns moment
*/
var fromOADateOffsetToUtcByMinutes = function(oaDate, offsetToUtcInMinutes) {
var offsetInTicks = offsetToUtcInMinutes * MINUTE_MILLISECONDS;
var ticks = oaDateToTicks(oaDate);
return moment(ticks + offsetInTicks).utc();
};
/**
* @description takes an oaDate that is not in utc and converts it to a utc moment offset by the specified timezone
*
* @param {double} oaDate
* @param {string} timezone
* @returns moment
*/
var fromOADateOffsetToUtcByTimezone = function(oaDate, timezone) {
if (!moment.tz.zone(timezone)) { throw new Error('timezone provided is not available in moment-timezone.js', 'moment-msdate.js', 59); }
var ticks = oaDateToTicks(oaDate);
var offset = moment(ticks).tz(timezone).utcOffset() * MINUTE_MILLISECONDS;
return moment.tz(ticks - offset, timezone).utc();
};
/**
* @description takes an oaDate that is in utc and converts it to a utc moment or takes an oaDate and an offset to utc and converts it to a utc moment. The offset can be an int representing the offset to utc in minutes or a string indicating the timezone of the oaDate.
*
* @param {double} oaDate
* @param {string=} {int=} offset
* @returns moment
*/
moment.fromOADate = function(oaDate, offset) {
if (isNaN(parseInt(oaDate, 10))) { throw new TypeError('fromOADate requires an oaDate that is not null or undefined', 'moment-msdate.js', 72); }
/* no offset */
if (!offset) { return fromOADateOffsetToUtcByMinutes(oaDate, 0); }
/* timezone */
var parsedOffset = parseInt(offset, 10);
if (isNaN(parsedOffset)) { return fromOADateOffsetToUtcByTimezone(oaDate, offset); }
/* minutes */
return fromOADateOffsetToUtcByMinutes(oaDate, parsedOffset);
};
/**
* @description converts a moment to a UTC OLE automation date represented as a double
*
* @returns {double}
*/
moment.fn.toOADate = function() {
var milliseconds = this.valueOf();
return ticksToOADate(milliseconds);
};
return moment;
}));

1
src/plugins/js/moment-timezone-with-data.min.js

File diff suppressed because one or more lines are too long

7
src/plugins/js/moment.min.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save