issue: customer communication contacts grid height.

change: replace schedule date control.
change: date validation from 1753-01-01 to 9999-12-31.
This commit is contained in:
2024-04-07 08:39:44 +08:00
parent 0ff48a0ac4
commit b6fe3e34f5
9 changed files with 66 additions and 16 deletions

View File

@ -22,9 +22,13 @@ export function createDateInput(min, max, element) {
date.type = 'date';
if (min != null) {
date.min = min;
} else {
date.min = '1753-01-01';
}
if (max != null) {
date.max = max;
} else {
date.max = '9999-12-31';
}
return date;
}

View File

@ -117,8 +117,10 @@ export class Dropdown {
* 选中某个条目
* @param selected 选中的值
* @param silence 是否静默选中,即不触发 {@linkcode onSelected} 事件
* @param ignoreCase 是否不区分大小写
* @returns 是否选中
*/
select(selected: string, silence?: boolean): void;
select(selected: string, silence?: boolean, ignoreCase?: boolean): boolean | undefined;
/**
* 选中条目列表
* @param selectedlist 选中的值的列表

View File

@ -281,18 +281,21 @@ export class Dropdown {
get selectedList() { return this._var.selectedList || [] }
select(selected, silence) {
select(selected, silence, ignoreCase) {
if (typeof selected !== 'string') {
selected = String(selected);
}
if (ignoreCase) {
selected = selected.toLowerCase();
}
if (this._var.lastSelected === selected) {
return false;
return;
}
this._var.lastSelected = selected;
const valuekey = this._var.options.valueKey;
const textkey = this._var.options.textKey;
const htmlkey = this._var.options.htmlKey;
let item = this.source.find(it => String(it[valuekey]) === selected);
let item = this.source.find(it => (ignoreCase ? String(it[valuekey]).toLowerCase() : String(it[valuekey])) === selected);
if (this._var.options.input) {
if (item == null) {
item = { [valuekey]: selected };
@ -322,7 +325,7 @@ export class Dropdown {
}
if (expanded) {
for (let li of this._var.container.querySelectorAll('li[data-value]')) {
if (li.dataset.value === selected) {
if ((ignoreCase ? li.dataset.value.toLowerCase() : li.dataset.value) === selected) {
li.classList.add('selected');
break;
}
@ -338,6 +341,7 @@ export class Dropdown {
if (!silence && typeof this.onSelected === 'function') {
this.onSelected(item);
}
return true;
}
selectlist(selectedlist, silence) {

View File

@ -445,8 +445,9 @@ export class GridDropdownColumn extends GridColumn {
* @param {any} val
* @param {GridItemWrapper} wrapper
* @param {GridColumnDefinition} col
* @param {Grid} grid
*/
static setValue(element, val, wrapper, col) {
static setValue(element, val, wrapper, col, grid) {
if (element.tagName !== 'DIV') {
let source = this._getSource(wrapper, col);
if (source instanceof Promise) {
@ -460,19 +461,42 @@ export class GridDropdownColumn extends GridColumn {
if (drop == null) {
return;
}
const ignoreCase = col.dropRestrictCase !== true;
if (drop.source == null || drop.source.length === 0) {
let source = this._getSource(wrapper, col);
if (source instanceof Promise) {
source.then(s => {
drop.source = s;
drop.select(val, true);
drop.select(val, true, ignoreCase);
})
return;
} else if (source != null) {
drop.source = source;
}
}
drop.select(val, true);
if (typeof val === 'string' && val !== '') {
const lVal = String(val).toLowerCase();
const item = drop.source.find(s => {
let v = s[col.dropOptions?.valueKey ?? 'value'];
if (ignoreCase) {
return String(v).toLowerCase() === lVal;
}
return v === val;
});
if (item == null) {
let text;
if (col.text == null && typeof col.filter === 'function') {
text = col.filter(wrapper.values, false, grid._var.refs.body);
} else {
text = val;
}
drop.source.push({
[col.dropOptions?.textKey ?? 'text']: text,
[col.dropOptions?.valueKey ?? 'value']: val
});
}
}
drop.select(val, true, ignoreCase);
}
/**

View File

@ -258,6 +258,7 @@ let r = lang;
* @property {boolean} [filterAsValue=false] - 列头过滤强制使用 `Value` 字段
* @property {GridItemSortCallback} [sortFilter] - 自定义列排序函数
* @property {DropdownOptions} [dropOptions] - 列为下拉列表类型时以该值设置下拉框的参数
* @property {boolean} [dropRestrictCase=false] - 下拉列表是否区分大小写
* @property {(GridSourceItem[] | Promise<GridSourceItem[]> | GridDropdownSourceCallback)} [source] - 列为下拉列表类型时以该值设置下拉列表数据源,支持返回异步对象,也支持调用函数返回
* @property {boolean} [sourceCache=false] - 下拉列表数据源是否缓存结果即行数据未发生变化时仅从source属性获取一次值
* @property {("fa-light" | "fa-regular" | "fa-solid")} [iconType=fa-light] - 列为图标类型时以该值设置图标样式
@ -1924,7 +1925,8 @@ export class Grid {
}
const it = this._var.currentSource[index];
// clear dropdown source cache
delete it.source;
// FIXME: 清除缓存会导致选中状态下动态数据源下拉列表显示为空
// delete it.source;
it.values = item;
if (this.sortIndex >= 0) {
this.sortColumn();
@ -4127,7 +4129,8 @@ export class Grid {
return;
}
const vals = this._var.currentSource[this._var.startIndex + index];
delete vals.source;
// FIXME: 清除缓存会导致选中状态下动态数据源下拉列表显示为空
// delete vals.source;
const item = vals.values;
if (item == null) {
return;