fix: field path

This commit is contained in:
chenos 2023-03-23 14:04:53 +08:00
parent 972e05bac0
commit c43930fa7c
3 changed files with 19 additions and 2 deletions

View File

@ -5,6 +5,20 @@ export class DateField extends Field {
get dataType() {
return DataTypes.DATE(3);
}
getProps() {
return this.options?.uiSchema?.['x-component-props'] || {};
}
isDateOnly() {
const props = this.getProps();
return !props.showTime;
}
isGMT() {
const props = this.getProps();
return props.gmt || !props.showTime;
}
}
export interface DateFieldOptions extends BaseColumnFieldOptions {

View File

@ -135,6 +135,7 @@ export default class FilterParser {
path: skipPrefix,
fullName,
fieldName,
fieldPath: `${this.collection.name}.${fullName}`,
model: this.model,
});
break;

View File

@ -1,5 +1,5 @@
import { Op } from 'sequelize';
import moment, { MomentInput } from 'moment';
import { Op } from 'sequelize';
function stringToDate(value: string): Date {
return moment(value).toDate();
}
@ -9,7 +9,9 @@ function getNextDay(value: MomentInput): Date {
}
export default {
$dateOn(value) {
$dateOn(value, ctx) {
// const field = ctx.db.getFieldByPath(ctx.fieldPath);
// console.log(field.isDateOnly());
return {
[Op.and]: [{ [Op.gte]: stringToDate(value) }, { [Op.lt]: getNextDay(value) }],
};