@@ -887,7 +887,7 @@ window.ComponentLine = class {
887
887
this . DOM . addEventListener ( "contextmenu" , ( e ) => {
888
888
e . preventDefault ( ) ;
889
889
} ) ;
890
- this . format_settings = { } ;
890
+ this . flatpickr_settings = { } ;
891
891
this . COLUMNS = columns ;
892
892
this . DATA = data ;
893
893
this . OPTIONS = Object . assign ( {
@@ -907,8 +907,6 @@ window.ComponentLine = class {
907
907
this . makeBody ( ) ;
908
908
/*foot*/
909
909
this . makeFoot ( foot ) ;
910
- /*datetime*/
911
- this . datepicker ( ) ;
912
910
/*sort*/
913
911
if ( this . OPTIONS . sortable ) this . sortable ( ) ;
914
912
}
@@ -940,19 +938,7 @@ window.ComponentLine = class {
940
938
foot . append ( td ) ;
941
939
break ;
942
940
case 'datetime' :
943
- let format ;
944
- switch ( val . format ) {
945
- case 1 :
946
- format = 'YYYY-MM-DD' ;
947
- break ;
948
- case 2 :
949
- format = 'YYYY' ;
950
- break ;
951
- default :
952
- format = 'YYYY-MM-DD HH:mm:ss' ;
953
- break ;
954
- }
955
- this . format_settings [ column ] = format ;
941
+ this . flatpickr_settings [ column ] = val . config ;
956
942
style = val . style ? `${ val . style } ` : '' ;
957
943
foot . insertAdjacentHTML ( 'beforeend' , `<th style="position: relative;overflow: unset;${ style } "><input class="dlp dlp-input datetime-${ column } " data-column="${ column } "/></th>` ) ;
958
944
break ;
@@ -971,6 +957,11 @@ window.ComponentLine = class {
971
957
_component . imgDelay ( `${ this . NAME } -${ column } -img` , 200 , zoom ) ;
972
958
} ) ;
973
959
}
960
+ if ( val . type === 'datetime' || val . insert_type === 'datetime' ) {
961
+ setTimeout ( ( ) => {
962
+ document . querySelectorAll ( `#${ this . NAME } input.datetime-${ column } ` ) . flatpickr ( this . flatpickr_settings [ column ] ) ;
963
+ } ) ;
964
+ }
974
965
}
975
966
head += '<th class="operate-column" style="width: 48px;"></th></tr>' ;
976
967
foot . insertAdjacentHTML ( 'beforeend' , '<th class="insert_handel operate-column" style="width: 48px;"><div></div></th></tr>' ) ;
@@ -1096,7 +1087,6 @@ window.ComponentLine = class {
1096
1087
this . DATA . push ( insert ) ;
1097
1088
this . DATA_INPUT . value = JSON . stringify ( this . DATA ) ;
1098
1089
this . TBODY_DOM . scrollTop = this . TBODY_DOM . scrollHeight ;
1099
- this . datepicker ( ) ;
1100
1090
} , false ) ;
1101
1091
this . TABLE_DOM . querySelector ( '.insert_handel div' ) . appendChild ( i ) ;
1102
1092
}
@@ -1129,19 +1119,7 @@ window.ComponentLine = class {
1129
1119
input . setAttribute ( 'class' , `dlp dlp-input datetime-${ column } ` ) ;
1130
1120
input . setAttribute ( 'data-column' , column ) ;
1131
1121
input . value = value ;
1132
- let format ;
1133
- switch ( settings . format ) {
1134
- case 1 :
1135
- format = 'YYYY-MM-DD' ;
1136
- break ;
1137
- case 2 :
1138
- format = 'YYYY' ;
1139
- break ;
1140
- default :
1141
- format = 'YYYY-MM-DD HH:mm:ss' ;
1142
- break ;
1143
- }
1144
- this . format_settings [ column ] = format ;
1122
+
1145
1123
input . addEventListener ( 'blur' , ( ) => {
1146
1124
let key = this . searchChildrenDomIndex ( input . parentNode . parentNode ) ;
1147
1125
let column = input . getAttribute ( 'data-column' ) ;
@@ -1152,6 +1130,9 @@ window.ComponentLine = class {
1152
1130
} , false ) ;
1153
1131
td . appendChild ( input ) ;
1154
1132
td . style . position = 'relative' ;
1133
+ setTimeout ( ( ) => {
1134
+ input . flatpickr ( settings . config ) ;
1135
+ } ) ;
1155
1136
break ;
1156
1137
case 'select' :
1157
1138
td . append ( this . menuMake ( column , value , settings . options , settings . options_limit , settings . name ) ) ;
@@ -1327,17 +1308,6 @@ window.ComponentLine = class {
1327
1308
} ) ;
1328
1309
}
1329
1310
1330
- datepicker ( ) {
1331
- if ( typeof jQuery != 'undefined' ) {
1332
- setTimeout ( ( ) => {
1333
- for ( let col in this . format_settings ) {
1334
- let format = this . format_settings [ col ] ;
1335
- $ ( `#${ this . NAME } input.datetime-${ col } ` ) . datetimepicker ( { "format" : format , "locale" : "zh-CN" } ) ;
1336
- }
1337
- } ) ;
1338
- }
1339
- }
1340
-
1341
1311
searchChildrenDomIndex ( dom ) {
1342
1312
let i = 0 ;
1343
1313
while ( ( dom = dom . previousSibling ) != null ) i ++ ;
0 commit comments