Browse Source

无jira refact:widget的xtype换下

es6
Treecat 1 year ago
parent
commit
de22cfdcf9
  1. 99
      src/widget/collapse/collapse.js
  2. 17
      src/widget/date/calendar/combo.month.date.js
  3. 17
      src/widget/date/calendar/combo.year.date.js
  4. 80
      src/widget/date/calendar/picker.date.js
  5. 58
      src/widget/date/calendar/picker.year.js
  6. 81
      src/widget/date/calendar/popup.calendar.date.js
  7. 87
      src/widget/date/calendar/popup.month.js
  8. 30
      src/widget/date/calendar/popup.year.js
  9. 31
      src/widget/date/calendar/trigger.triangle.date.js
  10. 58
      src/widget/datepane/card.static.datepane.js
  11. 291
      src/widget/datepane/datepane.js
  12. 49
      src/widget/datetime/datetime.combo.js
  13. 89
      src/widget/datetime/datetime.popup.js
  14. 35
      src/widget/datetime/datetime.trigger.js
  15. 100
      src/widget/datetimepane/card.static.datetimepane.js
  16. 297
      src/widget/datetimepane/datetimepane.js
  17. 14
      src/widget/downlist/combo.downlist.js
  18. 110
      src/widget/downlist/group.downlist.js
  19. 10
      src/widget/downlist/index.js
  20. 238
      src/widget/downlist/item.downlist.js
  21. 251
      src/widget/downlist/item.downlistgroup.js
  22. 580
      src/widget/downlist/popup.downlist.js
  23. 75
      src/widget/dynamicdate/dynamicdate.caculate.js
  24. 481
      src/widget/dynamicdate/dynamicdate.card.js
  25. 468
      src/widget/dynamicdate/dynamicdate.combo.js
  26. 137
      src/widget/dynamicdate/dynamicdate.param.item.js
  27. 288
      src/widget/dynamicdate/dynamicdate.popup.js
  28. 156
      src/widget/dynamicdate/dynamicdate.trigger.js
  29. 480
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  30. 320
      src/widget/dynamicdatetime/dynamicdatetime.popup.js
  31. 249
      src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
  32. 211
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js
  33. 93
      src/widget/editor/editor.search.js
  34. 4
      src/widget/editor/editor.search.small.js
  35. 41
      src/widget/editor/editor.text.js
  36. 4
      src/widget/editor/editor.text.small.js
  37. 4
      src/widget/intervalslider/index.js
  38. 151
      src/widget/intervalslider/intervalslider.js
  39. 86
      src/widget/intervalslider/model.accuratecalculation.js
  40. 6
      src/widget/multilayerdownlist/combo.downlist.js
  41. 38
      src/widget/multilayerdownlist/popup.downlist.js
  42. 78
      src/widget/multilayerselecttree/multilayerselecttree.combo.js
  43. 14
      src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js
  44. 42
      src/widget/multilayerselecttree/multilayerselecttree.leveltree.js
  45. 12
      src/widget/multilayerselecttree/multilayerselecttree.popup.js
  46. 41
      src/widget/multilayerselecttree/multilayerselecttree.trigger.js
  47. 68
      src/widget/multilayersingletree/multilayersingletree.combo.js
  48. 14
      src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js
  49. 37
      src/widget/multilayersingletree/multilayersingletree.leveltree.js
  50. 12
      src/widget/multilayersingletree/multilayersingletree.popup.js
  51. 41
      src/widget/multilayersingletree/multilayersingletree.trigger.js
  52. 3
      src/widget/multiselect/check/multiselect.check.pane.js
  53. 22
      src/widget/multiselect/check/multiselect.display.js
  54. 50
      src/widget/multiselect/loader.js
  55. 124
      src/widget/multiselect/multiselect.combo.js
  56. 112
      src/widget/multiselect/multiselect.combo.nobar.js
  57. 173
      src/widget/multiselect/multiselect.insert.combo.js
  58. 155
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  59. 56
      src/widget/multiselect/multiselect.insert.trigger.js
  60. 60
      src/widget/multiselect/multiselect.loader.js
  61. 76
      src/widget/multiselect/multiselect.loader.nobar.js
  62. 36
      src/widget/multiselect/multiselect.popup.view.js
  63. 34
      src/widget/multiselect/multiselect.popup.view.nobar.js
  64. 57
      src/widget/multiselect/multiselect.trigger.js
  65. 14
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  66. 16
      src/widget/multiselect/search/multiselect.search.loader.js
  67. 13
      src/widget/multiselect/search/multiselect.search.pane.js
  68. 8
      src/widget/multiselect/trigger/button.checkselected.js
  69. 11
      src/widget/multiselect/trigger/editor.multiselect.js
  70. 24
      src/widget/multiselect/trigger/editor/editor.patch.js
  71. 37
      src/widget/multiselect/trigger/searcher.multiselect.insert.js
  72. 28
      src/widget/multiselect/trigger/searcher.multiselect.js
  73. 25
      src/widget/multiselect/trigger/switcher.checkselected.js
  74. 53
      src/widget/multiselectlist/multiselectlist.insert.js
  75. 53
      src/widget/multiselectlist/multiselectlist.insert.nobar.js
  76. 24
      src/widget/multiselectlist/multiselectlist.js
  77. 17
      src/widget/multiselecttree/multiselecttree.js
  78. 3
      src/widget/multiselecttree/multiselecttree.popup.js

99
src/widget/collapse/collapse.js

@ -1,11 +1,23 @@
import { shortcut, Widget, map, extend, isFunction, contains, each, isKey, isNotEmptyArray } from "@/core";
import {
VerticalLayout,
shortcut,
Widget,
map,
extend,
isFunction,
contains,
each,
isKey,
isNotEmptyArray
} from "@/core";
import { ArrowNode } from "@/case";
import { Expander } from "@/base";
@shortcut()
export class Collapse extends Widget {
static xtype = "bi.collapse"
static xtype = "bi.collapse";
static EVENT_EXPAND = "EVENT_EXPAND"
static EVENT_EXPAND = "EVENT_EXPAND";
props = {
baseCls: "bi-collapse",
@ -30,10 +42,9 @@ export class Collapse extends Widget {
this.expanders = {};
return {
type: "bi.vertical",
type: VerticalLayout.xtype,
cls: collapseCls,
items: this._getItems(this.options.items),
};
}
@ -44,46 +55,58 @@ export class Collapse extends Widget {
const isActive = contains(this._getCurrentValue(o.value), item.value);
const cls = o.ghost || index === 0 ? "" : "bi-border-top";
const el = extend({
type: "bi.arrow_group_node",
height: 30,
text: item.text,
value: item.value,
open: isActive,
}, item.el);
const popup = extend({
animation: o.openMotion.animation,
animationDuring: o.openMotion.animationDuring,
}, item.popup);
return extend({
type: "bi.expander",
cls,
isDefaultInit: o.isDefaultInit,
trigger: o.trigger,
listeners: [{
eventName: Expander.EVENT_EXPAND,
action: () => {
this._hideOtherExpander(item.value);
this.fireEvent(Collapse.EVENT_EXPAND, item.value);
},
}],
}, item, {
el,
popup,
ref: _ref => {
isFunction(item.ref) && item.ref(_ref);
this.expanders[item.value] = _ref;
const el = extend(
{
type: ArrowNode.xtype,
height: 30,
text: item.text,
value: item.value,
open: isActive,
},
});
item.el
);
const popup = extend(
{
animation: o.openMotion.animation,
animationDuring: o.openMotion.animationDuring,
},
item.popup
);
return extend(
{
type: Expander.xtype,
cls,
isDefaultInit: o.isDefaultInit,
trigger: o.trigger,
listeners: [
{
eventName: Expander.EVENT_EXPAND,
action: () => {
this._hideOtherExpander(item.value);
this.fireEvent(Collapse.EVENT_EXPAND, item.value);
},
}
],
},
item,
{
el,
popup,
ref: _ref => {
isFunction(item.ref) && item.ref(_ref);
this.expanders[item.value] = _ref;
},
}
);
});
}
_hideOtherExpander(expandKey) {
if (this.options.accordion) {
each(this.expanders, (key, expander) => {
key !== (`${expandKey}`) && expander.hideView();
key !== `${expandKey}` && expander.hideView();
});
}
}

17
src/widget/date/calendar/combo.month.date.js

@ -1,6 +1,7 @@
import { shortcut, extend, createWidget } from "@/core";
import { Trigger, Combo } from "@/base";
import { DateTriangleTrigger } from "./trigger.triangle.date";
import { MonthPopup } from "./popup.month";
import { Combo, Trigger } from "@/base";
import { VerticalLayout, shortcut, extend, createWidget } from "@/core";
/**
* 日期控件中的月份下拉框
@ -11,9 +12,9 @@ import { MonthPopup } from "./popup.month";
*/
@shortcut()
export class MonthDateCombo extends Trigger {
static xtype = "bi.month_date_combo"
static xtype = "bi.month_date_combo";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@ -28,11 +29,11 @@ export class MonthDateCombo extends Trigger {
const o = this.options;
this.trigger = createWidget({
type: "bi.date_triangle_trigger",
type: DateTriangleTrigger.xtype,
});
this.popup = createWidget({
type: "bi.month_popup",
type: MonthPopup.xtype,
allowMonths: o.allowMonths,
behaviors: o.behaviors,
});
@ -44,7 +45,7 @@ export class MonthDateCombo extends Trigger {
});
this.combo = createWidget({
type: "bi.combo",
type: Combo.xtype,
offsetStyle: "center",
container: o.container,
element: this,
@ -55,7 +56,7 @@ export class MonthDateCombo extends Trigger {
minWidth: 100,
stopPropagation: false,
el: {
type: "bi.vertical",
type: VerticalLayout.xtype,
hgap: 6,
vgap: 5,
items: [this.popup],

17
src/widget/date/calendar/combo.year.date.js

@ -1,6 +1,7 @@
import { shortcut, extend, createWidget } from "@/core";
import { Trigger, Combo } from "@/base";
import { DateTriangleTrigger } from "./trigger.triangle.date";
import { YearPopup } from "./popup.year";
import { Combo, Trigger } from "@/base";
import { shortcut, extend, createWidget } from "@/core";
/**
* 年份下拉框
@ -11,10 +12,10 @@ import { YearPopup } from "./popup.year";
*/
@shortcut()
export class YearDateCombo extends Trigger {
static xtype = "bi.year_date_combo"
static xtype = "bi.year_date_combo";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@ -32,11 +33,11 @@ export class YearDateCombo extends Trigger {
const o = this.options;
this.trigger = createWidget({
type: "bi.date_triangle_trigger",
type: DateTriangleTrigger.xtype,
});
this.popup = createWidget({
type: "bi.year_popup",
type: YearPopup.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@ -50,7 +51,7 @@ export class YearDateCombo extends Trigger {
});
this.combo = createWidget({
type: "bi.combo",
type: Combo.xtype,
offsetStyle: "center",
element: this,
container: o.container,

80
src/widget/date/calendar/picker.date.js

@ -1,7 +1,23 @@
import { shortcut, Widget, extend, createWidget, contains, isNull, getDate, filter, range, checkDateVoid, parseDateTime, parseInt, print } from "@/core";
import { IconButton } from "@/base";
import { YearDateCombo } from "./combo.year.date";
import { MonthDateCombo } from "./combo.month.date";
import {
HTapeLayout,
CenterAdaptLayout,
shortcut,
Widget,
extend,
createWidget,
contains,
isNull,
getDate,
filter,
range,
checkDateVoid,
parseDateTime,
parseInt,
print
} from "@/core";
/**
* Created by GUY on 2015/9/7.
@ -10,10 +26,10 @@ import { MonthDateCombo } from "./combo.month.date";
*/
@shortcut()
export class DatePicker extends Widget {
static xtype = "bi.date_picker"
static xtype = "bi.date_picker";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
@ -32,7 +48,7 @@ export class DatePicker extends Widget {
this._year = getDate().getFullYear();
this._month = getDate().getMonth() + 1;
this.left = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: "pre-page-h-font",
width: 24,
height: 24,
@ -40,13 +56,13 @@ export class DatePicker extends Widget {
this.left.on(IconButton.EVENT_CHANGE, () => {
if (this._month === 1) {
this.setValue({
year: (this.year.getValue() - 1) || (getDate().getFullYear() - 1),
year: this.year.getValue() - 1 || getDate().getFullYear() - 1,
month: 12,
});
} else {
this.setValue({
year: this.year.getValue() || getDate().getFullYear(),
month: (this.month.getValue() - 1) || getDate().getMonth(),
month: this.month.getValue() - 1 || getDate().getMonth(),
});
}
this.fireEvent(DatePicker.EVENT_CHANGE);
@ -55,7 +71,7 @@ export class DatePicker extends Widget {
});
this.right = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: "next-page-h-font",
width: 24,
height: 24,
@ -64,13 +80,13 @@ export class DatePicker extends Widget {
this.right.on(IconButton.EVENT_CHANGE, () => {
if (this._month === 12) {
this.setValue({
year: (this.year.getValue() + 1) || (getDate().getFullYear() + 1),
year: this.year.getValue() + 1 || getDate().getFullYear() + 1,
month: 1,
});
} else {
this.setValue({
year: this.year.getValue() || getDate().getFullYear(),
month: (this.month.getValue() + 1) || (getDate().getMonth() + 2),
month: this.month.getValue() + 1 || getDate().getMonth() + 2,
});
}
this.fireEvent(DatePicker.EVENT_CHANGE);
@ -79,7 +95,7 @@ export class DatePicker extends Widget {
});
this.year = createWidget({
type: "bi.year_date_combo",
type: YearDateCombo.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@ -95,7 +111,7 @@ export class DatePicker extends Widget {
this.fireEvent(DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
});
this.month = createWidget({
type: "bi.month_date_combo",
type: MonthDateCombo.xtype,
behaviors: o.behaviors,
allowMonths: this._getAllowMonths(),
});
@ -111,27 +127,31 @@ export class DatePicker extends Widget {
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
items: [{
el: {
type: "bi.center_adapt",
items: [this.left],
items: [
{
el: {
type: CenterAdaptLayout.xtype,
items: [this.left],
},
width: 24,
},
width: 24,
}, {
el: {
type: "bi.center_adapt",
hgap: 10,
items: [this.year, this.month],
{
el: {
type: CenterAdaptLayout.xtype,
hgap: 10,
items: [this.year, this.month],
},
},
}, {
el: {
type: "bi.center_adapt",
items: [this.right],
{
el: {
type: CenterAdaptLayout.xtype,
items: [this.right],
},
width: 24,
},
width: 24,
}],
],
});
this.setValue({
year: this._year,
@ -147,7 +167,7 @@ export class DatePicker extends Widget {
month = defaultMonth || allowMonth[0];
}
this.month.setValue(month);
return month;
}

58
src/widget/date/calendar/picker.year.js

@ -1,17 +1,17 @@
import { shortcut, Widget, extend, createWidget, getDate, parseDateTime } from "@/core";
import { IconButton } from "@/base";
import { YearDateCombo } from "./combo.year.date";
import { HTapeLayout, CenterAdaptLayout, shortcut, Widget, extend, createWidget, getDate, parseDateTime } from "@/core";
import { IconButton } from "@/base";
@shortcut()
export class YearPicker extends Widget {
static xtype = "bi.year_picker"
static xtype = "bi.year_picker";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-year-picker",
behaviors: {},
@ -53,7 +53,7 @@ export class YearPicker extends Widget {
});
this.year = createWidget({
type: "bi.year_date_combo",
type: YearDateCombo.xtype,
min: o.min,
behaviors: o.behaviors,
max: o.max,
@ -68,26 +68,32 @@ export class YearPicker extends Widget {
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
items: [{
el: {
type: "bi.center_adapt",
items: [this.left],
items: [
{
el: {
type: CenterAdaptLayout.xtype,
items: [this.left],
},
width: 25,
},
width: 25,
}, {
type: "bi.center_adapt",
items: [{
el: this.year,
}],
}, {
el: {
type: "bi.center_adapt",
items: [this.right],
{
type: CenterAdaptLayout.xtype,
items: [
{
el: this.year,
},
],
},
width: 25,
}],
{
el: {
type: CenterAdaptLayout.xtype,
items: [this.right],
},
width: 25,
},
],
});
this.setValue(this._year);
}
@ -96,7 +102,7 @@ export class YearPicker extends Widget {
const o = this.options;
const valid = this._year > parseDateTime(o.min, "%Y-%X-%d").getFullYear();
this.left.setEnable(valid);
return valid;
}
@ -104,7 +110,7 @@ export class YearPicker extends Widget {
const o = this.options;
const valid = this._year < parseDateTime(o.max, "%Y-%X-%d").getFullYear();
this.right.setEnable(valid);
return valid;
}

81
src/widget/date/calendar/popup.calendar.date.js

@ -1,7 +1,18 @@
import { shortcut, Widget, createWidget, bind, getDate, each, isNotEmptyString } from "@/core";
import { Navigation } from "@/base";
import { Calendar } from "@/case";
import { DatePicker } from "./picker.date";
import { Navigation } from "@/base";
import {
VerticalLayout,
AbsoluteLayout,
Layout,
shortcut,
Widget,
createWidget,
bind,
getDate,
each,
isNotEmptyString
} from "@/core";
/**
* Created by GUY on 2015/9/7.
@ -10,7 +21,7 @@ import { DatePicker } from "./picker.date";
*/
@shortcut()
export class DateCalendarPopup extends Widget {
static xtype = "bi.date_calendar_popup"
static xtype = "bi.date_calendar_popup";
props = {
baseCls: "bi-date-calendar-popup",
@ -19,14 +30,13 @@ export class DateCalendarPopup extends Widget {
selectedTime: null,
};
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_createNav(v) {
const date = Calendar.getDateJSONByPage(v);
const calendar = createWidget({
type: "bi.calendar",
type: Calendar.xtype,
logic: {
dynamic: true,
},
@ -37,7 +47,7 @@ export class DateCalendarPopup extends Widget {
// BI-45616 此处为确定当前应该展示哪个年月对应的Calendar, day不是关键数据, 给1号就可
day: 1,
});
return calendar;
}
@ -54,7 +64,7 @@ export class DateCalendarPopup extends Widget {
day: this._day,
};
this.datePicker = createWidget({
type: "bi.date_picker",
type: DatePicker.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@ -65,13 +75,11 @@ export class DateCalendarPopup extends Widget {
logic: {
dynamic: true,
},
type: "bi.navigation",
type: Navigation.xtype,
tab: this.datePicker,
cardCreator: bind(this._createNav, this),
afterCardCreated () {
},
afterCardCreated() {},
afterCardShow: () => {
this.calendar.setValue(this.selectedTime);
@ -94,26 +102,33 @@ export class DateCalendarPopup extends Widget {
this.fireEvent(DateCalendarPopup.EVENT_CHANGE);
});
return [{
type: "bi.vertical",
items: [{
el: this.calendar,
hgap: 12,
bgap: 7,
}],
}, {
type: "bi.absolute",
items: [{
el: {
type: "bi.layout",
cls: "bi-split-top",
},
height: 1,
top: 40,
left: 0,
right: 0,
}],
}];
return [
{
type: VerticalLayout.xtype,
items: [
{
el: this.calendar,
hgap: 12,
bgap: 7,
}
],
},
{
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: Layout.xtype,
cls: "bi-split-top",
},
height: 1,
top: 40,
left: 0,
right: 0,
}
],
}
];
}
_checkMin() {

87
src/widget/date/calendar/popup.month.js

@ -1,4 +1,20 @@
import { shortcut, Widget, extend, Controller, createWidget, Events, createItems, toPix, map, contains, getDate, LogicFactory, parseInt } from "@/core";
import { ButtonGroup, TextItem } from "@/base";
import {
CenterAdaptLayout,
shortcut,
Widget,
extend,
Controller,
createWidget,
Events,
createItems,
toPix,
map,
contains,
getDate,
LogicFactory,
parseInt
} from "@/core";
/**
* 月份展示面板
@ -9,9 +25,9 @@ import { shortcut, Widget, extend, Controller, createWidget, Events, createItems
*/
@shortcut()
export class MonthPopup extends Widget {
static xtype = "bi.month_popup"
static xtype = "bi.month_popup";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@ -27,21 +43,30 @@ export class MonthPopup extends Widget {
this.selectedMonth = getDate().getMonth() + 1;
this.month = createWidget({
type: "bi.button_group",
type: ButtonGroup.xtype,
element: this,
behaviors: o.behaviors,
items: createItems(this._getItems(o.allowMonths), {}),
layouts: [LogicFactory.createLogic("table", extend({
dynamic: true,
}, {
columns: 2,
rows: 6,
columnSize: [1 / 2, 1 / 2],
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
})), {
type: "bi.center_adapt",
vgap: 2,
}],
layouts: [
LogicFactory.createLogic(
"table",
extend(
{
dynamic: true,
},
{
columns: 2,
rows: 6,
columnSize: [1 / 2, 1 / 2],
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1,
}
)
),
{
type: CenterAdaptLayout.xtype,
vgap: 2,
}
],
value: o.value,
});
@ -66,21 +91,23 @@ export class MonthPopup extends Widget {
items.push(month.slice(6, 8));
items.push(month.slice(8, 10));
items.push(month.slice(10, 12));
items = map(items, (i, item) => map(item, (j, td) => {
return {
type: "bi.text_item",
cls: "bi-border-radius bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
width: 30,
value: td,
text: td,
disabled: !contains(m, td),
};
}));
items = map(items, (i, item) =>
map(item, (j, td) => {
return {
type: TextItem.xtype,
cls: "bi-border-radius bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
once: false,
forceSelected: true,
height: toPix(BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, 1),
width: 30,
value: td,
text: td,
disabled: !contains(m, td),
};
})
);
Widget.popContext();
return items;

30
src/widget/date/calendar/popup.year.js

@ -1,6 +1,18 @@
import { shortcut, Widget, extend, createWidget, isKey, Controller, bind, isNotNull, isNotEmptyString, getDate, parseInt } from "@/core";
import { Navigation } from "@/base";
import { YearCalendar } from "@/case";
import { IconButton, Navigation } from "@/base";
import {
shortcut,
Widget,
extend,
createWidget,
isKey,
Controller,
bind,
isNotNull,
isNotEmptyString,
getDate,
parseInt
} from "@/core";
/**
* 年份展示面板
@ -11,9 +23,9 @@ import { YearCalendar } from "@/case";
*/
@shortcut()
export class YearPopup extends Widget {
static xtype = "bi.year_popup"
static xtype = "bi.year_popup";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@ -29,7 +41,7 @@ export class YearPopup extends Widget {
y = this._year;
const calendar = createWidget({
type: "bi.year_calendar",
type: YearCalendar.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@ -39,7 +51,7 @@ export class YearPopup extends Widget {
year: y + v * 12,
});
calendar.setValue(this._year);
return calendar;
}
@ -50,7 +62,7 @@ export class YearPopup extends Widget {
this.selectedYear = this._year = getDate().getFullYear();
this.backBtn = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: "pre-page-h-font",
width: 24,
height: 24,
@ -58,7 +70,7 @@ export class YearPopup extends Widget {
});
this.preBtn = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: "next-page-h-font",
width: 24,
height: 24,
@ -66,7 +78,7 @@ export class YearPopup extends Widget {
});
this.navigation = createWidget({
type: "bi.navigation",
type: Navigation.xtype,
element: this,
single: true,
logic: {

31
src/widget/date/calendar/trigger.triangle.date.js

@ -1,5 +1,5 @@
import { shortcut, extend, createWidget } from "@/core";
import { Trigger } from "@/base";
import { Label, IconLabel, Trigger } from "@/base";
import { VerticalAdaptLayout, shortcut, extend, createWidget } from "@/core";
/**
* 日期控件中的年份或月份trigger
@ -10,7 +10,7 @@ import { Trigger } from "@/base";
*/
@shortcut()
export class DateTriangleTrigger extends Trigger {
static xtype = "bi.date_triangle_trigger"
static xtype = "bi.date_triangle_trigger";
_const = {
height: 24,
@ -30,7 +30,7 @@ export class DateTriangleTrigger extends Trigger {
const o = this.options,
c = this._const;
this.text = createWidget({
type: "bi.label",
type: Label.xtype,
cls: "list-item-text",
textAlign: "right",
text: o.text,
@ -39,15 +39,18 @@ export class DateTriangleTrigger extends Trigger {
});
createWidget({
type: "bi.vertical_adapt",
type: VerticalAdaptLayout.xtype,
element: this,
items: [{
el: this.text,
rgap: 5,
}, {
type: "bi.icon_label",
width: 16,
}],
items: [
{
el: this.text,
rgap: 5,
},
{
type: IconLabel.xtype,
width: 16,
}
],
});
}
@ -67,7 +70,5 @@ export class DateTriangleTrigger extends Trigger {
return this.item.getText();
}
getKey() {
}
getKey() {}
}

58
src/widget/datepane/card.static.datepane.js

@ -1,18 +1,31 @@
import { shortcut, Widget, extend, createWidget, bind, isNull, each, isNotEmptyString, getDate, getMonthDays } from "@/core";
import { DatePicker, DateCalendarPopup } from "../date/calendar";
import { Calendar } from "@/case";
import { Navigation } from "@/base";
import {
VTapeLayout,
AbsoluteLayout,
Layout,
shortcut,
Widget,
extend,
createWidget,
bind,
isNull,
each,
isNotEmptyString,
getDate,
getMonthDays
} from "@/core";
import { Calendar } from "@/case";
@shortcut()
export class StaticDatePaneCard extends Widget {
static xtype = "bi.static_date_pane_card";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW =
"EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-date-pane",
min: "1900-01-01", // 最小日期
@ -35,16 +48,14 @@ export class StaticDatePaneCard extends Widget {
};
this.datePicker = createWidget({
type: "bi.date_picker",
type: DatePicker.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
});
this.datePicker.on(DatePicker.EVENT_CHANGE, () => {
const value = this.datePicker.getValue();
const monthDay = getMonthDays(
getDate(value.year, value.month - 1, 1)
);
const monthDay = getMonthDays(getDate(value.year, value.month - 1, 1));
let day = this.selectedTime.day || 0;
if (day > monthDay) {
day = monthDay;
@ -54,27 +65,20 @@ export class StaticDatePaneCard extends Widget {
month: value.month,
};
day !== 0 && (this.selectedTime.day = day);
this.calendar.setSelect(
Calendar.getPageByDateJSON(this.selectedTime)
);
this.calendar.setSelect(Calendar.getPageByDateJSON(this.selectedTime));
this.calendar.setValue(this.selectedTime);
day !== 0 && this.fireEvent(DateCalendarPopup.EVENT_CHANGE);
});
this.datePicker.on(
DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
() => {
this.fireEvent(
StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW
);
}
);
this.datePicker.on(DatePicker.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW, () => {
this.fireEvent(StaticDatePaneCard.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
});
this.calendar = createWidget({
direction: "custom",
// logic: {
// dynamic: false
// },
type: "bi.navigation",
type: Navigation.xtype,
tab: this.datePicker,
cardCreator: bind(this._createNav, this),
});
@ -87,7 +91,7 @@ export class StaticDatePaneCard extends Widget {
this.setValue(o.selectedTime);
createWidget({
type: "bi.vtape",
type: VTapeLayout.xtype,
element: this,
items: [
{
@ -100,12 +104,12 @@ export class StaticDatePaneCard extends Widget {
});
createWidget({
type: "bi.absolute",
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: "bi.layout",
type: Layout.xtype,
cls: "bi-split-top",
},
height: 1,
@ -120,7 +124,7 @@ export class StaticDatePaneCard extends Widget {
_createNav(v) {
const date = Calendar.getDateJSONByPage(v);
const calendar = createWidget({
type: "bi.calendar",
type: Calendar.xtype,
logic: {
dynamic: false,
},
@ -130,13 +134,13 @@ export class StaticDatePaneCard extends Widget {
month: date.month,
day: this.selectedTime.day,
});
return calendar;
}
_getNewCurrentDate() {
const today = getDate();
return {
year: today.getFullYear(),
month: today.getMonth() + 1,

291
src/widget/datepane/datepane.js

@ -1,6 +1,20 @@
import { shortcut, Widget, createItems, i18nText, isEmptyObject, isNull, isEmptyString, isNotEmptyObject, getDate } from "@/core";
import { ButtonGroup, TextButton } from "@/base";
import { DynamicDateHelper, DynamicDateCombo, DynamicDatePopup } from "../dynamicdate";
import {
VTapeLayout,
CenterLayout,
shortcut,
Widget,
createItems,
i18nText,
isEmptyObject,
isNull,
isEmptyString,
isNotEmptyObject,
getDate
} from "@/core";
import { LinearSegment } from "@/case";
import { Tab, TextButton, ButtonGroup } from "@/base";
import { StaticDatePaneCard } from "./card.static.datepane";
import { DynamicDateCard, DynamicDateHelper, DynamicDateCombo, DynamicDatePopup } from "../dynamicdate";
@shortcut()
export class DynamicDatePane extends Widget {
@ -16,140 +30,167 @@ export class DynamicDatePane extends Widget {
minDate: "1900-01-01",
maxDate: "2099-12-31",
supportDynamic: true,
}
};
render() {
const o = this.options;
return {
type: "bi.vtape",
items: [{
el: {
type: "bi.linear_segment",
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: 30,
items: createItems([{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDatePane.Static,
}, {
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDatePane.Dynamic,
}], {
textAlign: "center",
}),
listeners: [{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
let date;
const value = this.switcher.getValue()[0];
this.dateTab.setSelect(value);
switch (value) {
case DynamicDatePane.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
break;
case DynamicDatePane.Dynamic:
this.dynamicPane.setValue({
year: 0,
});
break;
default:
break;
type: VTapeLayout.xtype,
items: [
{
el: {
type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: 30,
items: createItems(
[
{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDatePane.Static,
},
{
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDatePane.Dynamic,
}
],
{
textAlign: "center",
}
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}],
ref: _ref => {
this.switcher = _ref;
},
},
height: o.supportDynamic ? 30 : 0,
}, {
type: "bi.tab",
ref: _ref => {
this.dateTab = _ref;
},
showIndex: DynamicDatePane.Static,
cardCreator: v => {
switch (v) {
case DynamicDatePane.Static:
return {
type: "bi.static_date_pane_card",
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors,
listeners: [{
eventName: "EVENT_CHANGE",
),
listeners: [
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
let date;
const value = this.switcher.getValue()[0];
this.dateTab.setSelect(value);
switch (value) {
case DynamicDatePane.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
break;
case DynamicDatePane.Dynamic:
this.dynamicPane.setValue({
year: 0,
});
break;
default:
break;
}
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}, {
eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
action: () => {
this.fireEvent(DynamicDatePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}],
ref: _ref => {
this.ymd = _ref;
},
};
case DynamicDatePane.Dynamic:
default:
return {
type: "bi.vtape",
items: [{
type: "bi.dynamic_date_card",
}
],
ref: _ref => {
this.switcher = _ref;
},
},
height: o.supportDynamic ? 30 : 0,
},
{
type: Tab.xtype,
ref: _ref => {
this.dateTab = _ref;
},
showIndex: DynamicDatePane.Static,
cardCreator: v => {
switch (v) {
case DynamicDatePane.Static:
return {
type: StaticDatePaneCard.xtype,
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors,
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
},
{
eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
action: () => {
this.fireEvent(DynamicDatePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}
],
ref: _ref => {
this.dynamicPane = _ref;
this.ymd = _ref;
},
}, {
el: {
type: "bi.center",
items: [{
type: "bi.text_button",
cls: "bi-high-light bi-border-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: 23,
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.setValue();
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
cls: "bi-border-left bi-high-light bi-border-top",
textHeight: 23,
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDatePopup.EVENT_CHANGE);
} else {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
};
case DynamicDatePane.Dynamic:
default:
return {
type: VTapeLayout.xtype,
items: [
{
type: DynamicDateCard.xtype,
min: o.minDate,
max: o.maxDate,
ref: _ref => {
this.dynamicPane = _ref;
},
},
{
el: {
type: CenterLayout.xtype,
items: [
{
type: TextButton.xtype,
cls: "bi-high-light bi-border-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: 23,
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.setValue();
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}
],
},
{
type: TextButton.xtype,
cls: "bi-border-left bi-high-light bi-border-top",
textHeight: 23,
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(
DynamicDatePopup.EVENT_CHANGE
);
} else {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
}
},
}
],
}
},
}],
}],
},
height: 24,
}],
};
}
},
}],
],
},
height: 24,
}
],
};
}
},
}
],
};
}
@ -212,7 +253,7 @@ export class DynamicDatePane extends Widget {
getValue() {
const type = this.dateTab.getSelect();
return {
type,
value: type === DynamicDatePane.Static ? this.dateTab.getValue() : this.dynamicPane.getValue(),

49
src/widget/datetime/datetime.combo.js

@ -1,10 +1,11 @@
import { shortcut, extend, getDate, isNotNull, createWidget } from "@/core";
import { Single, Combo, IconButton } from "@/base";
import { DateTimeTrigger } from "./datetime.trigger";
import { DateTimePopup } from "./datetime.popup";
import { Combo, IconButton, Single } from "@/base";
import { HTapeLayout, shortcut, extend, getDate, isNotNull, createWidget } from "@/core";
@shortcut()
export class DateTimeCombo extends Single {
static xtype = "bi.date_time_combo"
static xtype = "bi.date_time_combo";
constants = {
popupHeight: 290,
@ -14,14 +15,16 @@ export class DateTimeCombo extends Single {
iconWidth: 24,
};
static EVENT_CANCEL = "EVENT_CANCEL"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_CANCEL = "EVENT_CANCEL";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig(conf) {
return extend(super._defaultConfig(...arguments), {
baseCls: `bi-date-time-combo bi-focus-shadow ${conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
baseCls: `bi-date-time-combo bi-focus-shadow ${
conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
}`,
width: 200,
height: 24,
minDate: "1900-01-01",
@ -33,16 +36,18 @@ export class DateTimeCombo extends Single {
super._init(...arguments);
const opts = this.options;
const date = getDate();
this.storeValue = isNotNull(opts.value) ? opts.value : {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
};
this.storeValue = isNotNull(opts.value)
? opts.value
: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds(),
};
this.trigger = createWidget({
type: "bi.date_time_trigger",
type: DateTimeTrigger.xtype,
height: opts.height,
min: opts.minDate,
max: opts.maxDate,
@ -50,7 +55,7 @@ export class DateTimeCombo extends Single {
});
this.popup = createWidget({
type: "bi.date_time_popup",
type: DateTimePopup.xtype,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
@ -70,7 +75,7 @@ export class DateTimeCombo extends Single {
this.fireEvent(DateTimeCombo.EVENT_CONFIRM);
});
this.combo = createWidget({
type: "bi.combo",
type: Combo.xtype,
container: opts.container,
toggle: false,
isNeedAdjustHeight: false,
@ -83,7 +88,7 @@ export class DateTimeCombo extends Single {
stopPropagation: false,
},
// DEC-4250 和复选下拉一样,点击不收起
hideChecker (e) {
hideChecker(e) {
return triggerBtn.element.find(e.target).length === 0;
},
});
@ -93,7 +98,7 @@ export class DateTimeCombo extends Single {
});
const triggerBtn = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-font",
width: this.constants.iconWidth,
height: opts.height,
@ -107,7 +112,7 @@ export class DateTimeCombo extends Single {
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
columnSize: ["", this.constants.iconWidth],
element: this,
items: [this.combo, triggerBtn],

89
src/widget/datetime/datetime.popup.js

@ -1,14 +1,26 @@
import { shortcut, Widget, extend, createWidget, i18nText, isNull, getDate } from "@/core";
import { TextButton } from "@/base";
import { DateCalendarPopup } from "../date/calendar";
import {
GridLayout,
VTapeLayout,
CenterAdaptLayout,
shortcut,
Widget,
extend,
createWidget,
i18nText,
isNull,
getDate
} from "@/core";
import { DynamicDateTimeSelect } from "../dynamicdatetime";
@shortcut()
export class DateTimePopup extends Widget {
static xtype = "bi.date_time_popup"
static xtype = "bi.date_time_popup";
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
static BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
static BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
static CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
@ -22,7 +34,7 @@ export class DateTimePopup extends Widget {
super._init(...arguments);
const opts = this.options;
this.cancelButton = createWidget({
type: "bi.text_button",
type: TextButton.xtype,
cls: "multidate-popup-button bi-border-top bi-border-right",
shadow: true,
text: i18nText("BI-Basic_Cancel"),
@ -32,7 +44,7 @@ export class DateTimePopup extends Widget {
});
this.okButton = createWidget({
type: "bi.text_button",
type: TextButton.xtype,
cls: "multidate-popup-button bi-border-top",
shadow: true,
text: i18nText("BI-Basic_OK"),
@ -42,7 +54,7 @@ export class DateTimePopup extends Widget {
});
this.dateCombo = createWidget({
type: "bi.date_calendar_popup",
type: DateCalendarPopup.xtype,
behaviors: opts.behaviors,
min: this.options.min,
max: this.options.max,
@ -52,32 +64,36 @@ export class DateTimePopup extends Widget {
});
this.dateButton = createWidget({
type: "bi.grid",
items: [
[this.cancelButton, this.okButton]
],
type: GridLayout.xtype,
items: [[this.cancelButton, this.okButton]],
});
createWidget({
element: this,
type: "bi.vtape",
items: [{
el: this.dateCombo,
}, {
el: {
type: "bi.center_adapt",
cls: "bi-split-top",
items: [{
type: "bi.dynamic_date_time_select",
ref: _ref => {
this.timeSelect = _ref;
},
}],
type: VTapeLayout.xtype,
items: [
{
el: this.dateCombo,
},
height: 50,
}, {
el: this.dateButton,
height: 30,
}],
{
el: {
type: CenterAdaptLayout.xtype,
cls: "bi-split-top",
items: [
{
type: DynamicDateTimeSelect.xtype,
ref: _ref => {
this.timeSelect = _ref;
},
}
],
},
height: 50,
},
{
el: this.dateButton,
height: 30,
}
],
});
this.setValue(opts.value);
}
@ -112,10 +128,13 @@ export class DateTimePopup extends Widget {
}
getValue() {
return extend({
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
}, this.timeSelect.getValue());
return extend(
{
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
},
this.timeSelect.getValue()
);
}
}

35
src/widget/datetime/datetime.trigger.js

@ -1,19 +1,9 @@
import {
shortcut,
extend,
createWidget,
isNull,
getDate,
print
} from "@/core";
import {
Trigger
} from "@/base";
import { Label, Trigger } from "@/base";
import { HTapeLayout, shortcut, extend, createWidget, isNull, getDate, print } from "@/core";
@shortcut()
export class DateTimeTrigger extends Trigger {
static xtype = "bi.date_time_trigger"
static xtype = "bi.date_time_trigger";
_const = {
hgap: 4,
@ -35,7 +25,7 @@ export class DateTimeTrigger extends Trigger {
const o = this.options,
c = this._const;
this.text = createWidget({
type: "bi.label",
type: Label.xtype,
textAlign: "left",
height: o.height,
width: o.width,
@ -43,14 +33,17 @@ export class DateTimeTrigger extends Trigger {
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
items: [{
el: this.text,
}, {
el: createWidget(),
width: this._const.iconWidth,
}],
items: [
{
el: this.text,
},
{
el: createWidget(),
width: this._const.iconWidth,
}
],
});
this.setValue(o.value);
}

100
src/widget/datetimepane/card.static.datetimepane.js

@ -1,18 +1,32 @@
import { shortcut, Widget, extend, getDate, createWidget, bind, isNull, each, isNotEmptyString, getMonthDays } from "@/core";
import { DatePicker, DateCalendarPopup } from "../date/calendar";
import { Calendar } from "@/case";
import { Navigation } from "@/base";
import {
VTapeLayout,
AbsoluteLayout,
Layout,
shortcut,
Widget,
extend,
getDate,
createWidget,
bind,
isNull,
each,
isNotEmptyString,
getMonthDays
} from "@/core";
import { Calendar } from "@/case";
import { DynamicDateTimeSelect } from "../dynamicdatetime/dynamicdatetime.timeselect";
@shortcut()
export class StaticDateTimePaneCard extends Widget {
static xtype = "bi.static_date_time_pane_card"
static xtype = "bi.static_date_time_pane_card";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-date-time-pane",
min: "1900-01-01", // 最小日期
@ -35,7 +49,7 @@ export class StaticDateTimePaneCard extends Widget {
};
this.datePicker = createWidget({
type: "bi.date_picker",
type: DatePicker.xtype,
behaviors: o.behaviors,
min: o.min,
max: o.max,
@ -66,7 +80,7 @@ export class StaticDateTimePaneCard extends Widget {
// logic: {
// dynamic: false
// },
type: "bi.navigation",
type: Navigation.xtype,
tab: this.datePicker,
cardCreator: bind(this._createNav, this),
});
@ -78,44 +92,52 @@ export class StaticDateTimePaneCard extends Widget {
});
createWidget({
type: "bi.vtape",
type: VTapeLayout.xtype,
element: this,
hgap: 10,
items: [{
el: this.datePicker,
height: 40,
}, this.calendar, {
el: {
type: "bi.dynamic_date_time_select",
cls: "bi-split-top",
ref: _ref => {
this.timeSelect = _ref;
},
listeners: [{
eventName: DynamicDateTimeSelect.EVENT_CONFIRM,
action: () => {
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
this.fireEvent("EVENT_CHANGE");
items: [
{
el: this.datePicker,
height: 40,
},
this.calendar,
{
el: {
type: DynamicDateTimeSelect.xtype,
cls: "bi-split-top",
ref: (_ref) => {
this.timeSelect = _ref;
},
}],
listeners: [
{
eventName: DynamicDateTimeSelect.EVENT_CONFIRM,
action: () => {
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
this.fireEvent("EVENT_CHANGE");
},
},
],
},
height: 40,
},
height: 40,
}],
],
});
createWidget({
type: "bi.absolute",
type: AbsoluteLayout.xtype,
element: this,
items: [{
el: {
type: "bi.layout",
cls: "bi-split-top",
items: [
{
el: {
type: Layout.xtype,
cls: "bi-split-top",
},
height: 1,
top: 40,
left: 0,
right: 0,
},
height: 1,
top: 40,
left: 0,
right: 0,
}],
],
});
this.setValue(o.selectedTime);
}
@ -123,7 +145,7 @@ export class StaticDateTimePaneCard extends Widget {
_createNav(v) {
const date = Calendar.getDateJSONByPage(v);
const calendar = createWidget({
type: "bi.calendar",
type: Calendar.xtype,
logic: {
dynamic: false,
},
@ -133,13 +155,13 @@ export class StaticDateTimePaneCard extends Widget {
month: date.month,
day: this.selectedTime.day,
});
return calendar;
}
_getNewCurrentDate() {
const today = getDate();
return {
year: today.getFullYear(),
month: today.getMonth() + 1,

297
src/widget/datetimepane/datetimepane.js

@ -1,17 +1,31 @@
import { shortcut, Widget, createItems, i18nText, isNull, isEmptyObject, isEmptyString, isNotEmptyObject, getDate } from "@/core";
import { ButtonGroup, TextButton } from "@/base";
import {
VTapeLayout,
CenterLayout,
shortcut,
Widget,
createItems,
i18nText,
isNull,
isEmptyObject,
isEmptyString,
isNotEmptyObject,
getDate
} from "@/core";
import { LinearSegment } from "@/case";
import { Tab, TextButton, ButtonGroup } from "@/base";
import { StaticDateTimePaneCard } from "./card.static.datetimepane";
import { DynamicDateCard, DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
import { DynamicDatePane } from "../datepane";
import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
@shortcut()
export class DynamicDateTimePane extends Widget {
static xtype = "bi.dynamic_date_time_pane"
static xtype = "bi.dynamic_date_time_pane";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
static Static = 1
static Dynamic = 2
static Static = 1;
static Dynamic = 2;
props = {
baseCls: "bi-dynamic-date-pane",
@ -22,136 +36,163 @@ export class DynamicDateTimePane extends Widget {
render() {
const o = this.options;
return {
type: "bi.vtape",
items: [{
el: {
type: "bi.linear_segment",
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: 30,
items: createItems([{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateTimePane.Static,
}, {
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateTimePane.Dynamic,
}], {
textAlign: "center",
}),
listeners: [{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
const value = this.switcher.getValue()[0];
let date;
this.dateTab.setSelect(value);
switch (value) {
case DynamicDateTimePane.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
break;
case DynamicDateTimePane.Dynamic:
this.dynamicPane.setValue({
year: 0,
});
break;
default:
break;
type: VTapeLayout.xtype,
items: [
{
el: {
type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: 30,
items: createItems(
[
{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateTimePane.Static,
},
{
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateTimePane.Dynamic,
}
],
{
textAlign: "center",
}
this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
},
}],
ref: _ref => {
this.switcher = _ref;
},
},
height: o.supportDynamic ? 30 : 0,
}, {
type: "bi.tab",
ref: _ref => {
this.dateTab = _ref;
},
showIndex: DynamicDateTimePane.Static,
cardCreator: v => {
switch (v) {
case DynamicDateTimePane.Static:
return {
type: "bi.static_date_time_pane_card",
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors,
listeners: [{
eventName: "EVENT_CHANGE",
),
listeners: [
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
const value = this.switcher.getValue()[0];
let date;
this.dateTab.setSelect(value);
switch (value) {
case DynamicDateTimePane.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
break;
case DynamicDateTimePane.Dynamic:
this.dynamicPane.setValue({
year: 0,
});
break;
default:
break;
}
this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
},
}, {
eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
action: () => {
this.fireEvent(DynamicDateTimePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}],
ref: _ref => {
this.ymd = _ref;
},
};
case DynamicDateTimePane.Dynamic:
default:
return {
type: "bi.vtape",
items: [{
type: "bi.dynamic_date_card",
}
],
ref: _ref => {
this.switcher = _ref;
},
},
height: o.supportDynamic ? 30 : 0,
},
{
type: Tab.xtype,
ref: _ref => {
this.dateTab = _ref;
},
showIndex: DynamicDateTimePane.Static,
cardCreator: v => {
switch (v) {
case DynamicDateTimePane.Static:
return {
type: StaticDateTimePaneCard.xtype,
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors,
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
},
},
{
eventName: "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW",
action: () => {
this.fireEvent(DynamicDateTimePane.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}
],
ref: _ref => {
this.dynamicPane = _ref;
this.ymd = _ref;
},
}, {
el: {
type: "bi.center",
items: [{
type: "bi.text_button",
cls: "bi-high-light bi-border-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: 23,
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.setValue();
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
cls: "bi-border-left bi-high-light bi-border-top",
textHeight: 23,
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDatePane.EVENT_CHANGE);
} else {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
};
case DynamicDateTimePane.Dynamic:
default:
return {
type: VTapeLayout.xtype,
items: [
{
type: DynamicDateCard.xtype,
min: o.minDate,
max: o.maxDate,
ref: _ref => {
this.dynamicPane = _ref;
},
},
{
el: {
type: CenterLayout.xtype,
items: [
{
type: TextButton.xtype,
cls: "bi-high-light bi-border-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: 23,
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.setValue();
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}
],
},
{
type: TextButton.xtype,
cls: "bi-border-left bi-high-light bi-border-top",
textHeight: 23,
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(
DynamicDatePane.EVENT_CHANGE
);
} else {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
}
},
}
],
}
},
}],
}],
},
height: 24,
}],
};
}
},
}],
],
},
height: 24,
}
],
};
}
},
}
],
};
}

14
src/widget/downlist/combo.downlist.js

@ -3,7 +3,6 @@ import { DownListPopup } from "./popup.downlist";
import { Combo } from "@/base";
import { IconTrigger } from "@/case";
function transformItems(items) {
if (!items) return items;
let result = cloneDeep(items);
@ -26,7 +25,7 @@ function transformItems(items) {
}
});
});
return result;
}
@ -93,21 +92,14 @@ export class DownListCombo extends Widget {
{
eventName: DownListPopup.EVENT_CHANGE,
action: value => {
this.fireEvent(
DownListCombo.EVENT_CHANGE,
value
);
this.fireEvent(DownListCombo.EVENT_CHANGE, value);
this.downlistcombo.hideView();
},
},
{
eventName: DownListPopup.EVENT_SON_VALUE_CHANGE,
action: (value, fatherValue) => {
this.fireEvent(
DownListCombo.EVENT_SON_VALUE_CHANGE,
value,
fatherValue
);
this.fireEvent(DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
this.downlistcombo.hideView();
},
}

110
src/widget/downlist/group.downlist.js

@ -1,62 +1,56 @@
import {
shortcut,
Widget,
extend,
createWidget,
Controller,
Events
} from "@/core";
import { ButtonTree } from "@/base";
import { VerticalLayout, shortcut, Widget, extend, createWidget, Controller, Events } from "@/core";
@shortcut()
export class DownListGroup extends Widget {
static xtype = "bi.down_list_group";
constants = { iconCls: "check-mark-ha-font" };
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-down-list-group",
items: [
{
el: {},
}
],
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.downlistgroup = createWidget({
element: this,
type: "bi.button_tree",
items: o.items,
chooseType: 0, // 0单选,1多选
layouts: [
{
type: "bi.vertical",
hgap: 0,
vgap: 0,
}
],
value: o.value,
});
this.downlistgroup.on(Controller.EVENT_CHANGE, (type, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, ...args);
if (type === Events.CLICK) {
this.fireEvent(DownListGroup.EVENT_CHANGE, type, ...args);
}
});
}
getValue() {
return this.downlistgroup.getValue();
}
setValue(v) {
this.downlistgroup.setValue(v);
}
static xtype = "bi.down_list_group";
constants = { iconCls: "check-mark-ha-font" };
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls: "bi-down-list-group",
items: [
{
el: {},
}
],
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.downlistgroup = createWidget({
element: this,
type: ButtonTree.xtype,
items: o.items,
chooseType: 0, // 0单选,1多选
layouts: [
{
type: VerticalLayout.xtype,
hgap: 0,
vgap: 0,
}
],
value: o.value,
});
this.downlistgroup.on(Controller.EVENT_CHANGE, (type, ...args) => {
this.fireEvent(Controller.EVENT_CHANGE, type, ...args);
if (type === Events.CLICK) {
this.fireEvent(DownListGroup.EVENT_CHANGE, type, ...args);
}
});
}
getValue() {
return this.downlistgroup.getValue();
}
setValue(v) {
this.downlistgroup.setValue(v);
}
}

10
src/widget/downlist/index.js

@ -1,5 +1,5 @@
export { DownListGroup } from "./group.downlist";
export { DownListItem } from "./item.downlist";
export { DownListGroupItem } from "./item.downlistgroup";
export { DownListPopup } from "./popup.downlist";
export { DownListCombo } from "./combo.downlist";
export { DownListGroup } from "./group.downlist";
export { DownListItem } from "./item.downlist";
export { DownListGroupItem } from "./item.downlistgroup";
export { DownListPopup } from "./popup.downlist";
export { DownListCombo } from "./combo.downlist";

238
src/widget/downlist/item.downlist.js

@ -1,125 +1,121 @@
import { shortcut, extend, createWidget, isPlainObject, LogicFactory, Direction } from "@/core";
import { BasicButton } from "@/base";
import { Label, Icon, BasicButton } from "@/base";
import { CenterAdaptLayout, shortcut, extend, createWidget, isPlainObject, LogicFactory, Direction } from "@/core";
@shortcut()
export class DownListItem extends BasicButton {
static xtype = "bi.down_list_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-down-list-item bi-list-item-active",
cls: "",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
logic: {
dynamic: true,
},
selected: false,
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0,
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height,
});
const icon = isPlainObject(o.icon)
? o.icon
: {
type: "bi.icon",
width: o.iconWidth,
height: o.iconHeight,
};
this.icon = createWidget({
type: "bi.center_adapt",
width: 36,
height: o.height,
items: [
{
el: icon,
}
],
});
createWidget(
extend(
{
element: this,
},
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(Direction.Left),
extend(o.logic, {
items: LogicFactory.createLogicItemsByDirection(
Direction.Left,
this.icon,
this.text
),
})
)
)
);
}
setValue() {
if (!this.isReadOnly()) {
this.text.setValue(...arguments);
}
}
getValue() {
return this.text.getValue();
}
setText() {
this.text.setText(...arguments);
}
getText() {
return this.text.getText();
}
doClick() {
super.doClick(...arguments);
if (this.isValid()) {
this.fireEvent(DownListItem.EVENT_CHANGE, this.getValue(), this);
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
static xtype = "bi.down_list_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-down-list-item bi-list-item-active",
cls: "",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
logic: {
dynamic: true,
},
selected: false,
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0,
});
}
_init() {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: Label.xtype,
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height,
});
const icon = isPlainObject(o.icon)
? o.icon
: {
type: Icon.xtype,
width: o.iconWidth,
height: o.iconHeight,
};
this.icon = createWidget({
type: CenterAdaptLayout.xtype,
width: 36,
height: o.height,
items: [
{
el: icon,
}
],
});
createWidget(
extend(
{
element: this,
},
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(Direction.Left),
extend(o.logic, {
items: LogicFactory.createLogicItemsByDirection(Direction.Left, this.icon, this.text),
})
)
)
);
}
setValue() {
if (!this.isReadOnly()) {
this.text.setValue(...arguments);
}
}
getValue() {
return this.text.getValue();
}
setText() {
this.text.setText(...arguments);
}
getText() {
return this.text.getText();
}
doClick() {
super.doClick(...arguments);
if (this.isValid()) {
this.fireEvent(DownListItem.EVENT_CHANGE, this.getValue(), this);
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
doHighLight() {
this.text.doHighLight(...arguments);
}
unHighLight() {
this.text.unHighLight(...arguments);
}
}

251
src/widget/downlist/item.downlistgroup.js

@ -1,4 +1,7 @@
import { Label, IconButton, BasicButton } from "@/base";
import {
CenterAdaptLayout,
HorizontalFillLayout,
shortcut,
extend,
createWidget,
@ -10,132 +13,130 @@ import {
first,
BlankSplitChar
} from "@/core";
import { BasicButton } from "@/base";
@shortcut()
export class DownListGroupItem extends BasicButton {
static xtype = "bi.down_list_group_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-down-list-group-item`,
logic: {
dynamic: false,
},
// invalid: true,
iconCls1: "dot-e-font",
icon: "",
iconCls2: "pull-right-e-font",
});
}
render() {
const o = this.options;
this.text = createWidget({
type: "bi.label",
cls: "list-group-item-text",
textAlign: "left",
text: o.text,
value: o.value,
height: o.height,
});
if (isPlainObject(o.icon)) {
this.icon1 = createWidget({
width: 36,
height: o.height,
type: "bi.center_adapt",
items: [o.icon],
});
} else {
this.icon1 = createWidget({
type: "bi.icon_button",
cls: o.iconCls1,
width: 36,
height: o.height,
iconHeight: o.iconHeight,
iconWidth: 36,
disableSelected: true,
selected: this._digest(o.value),
});
}
this.icon2 = createWidget({
type: "bi.icon_button",
cls: o.iconCls2,
width: 24,
forceNotSelected: true,
});
this.element.hover(
() => {
if (this.isEnabled()) {
this.hover();
}
},
() => {
if (this.isEnabled()) {
this.dishover();
}
}
);
return {
type: "bi.horizontal_fill",
columnSize: [36, "fill", 24],
items: [this.icon1, this.text, this.icon2],
};
}
_getLevel() {
const child = first(this.options.childValues);
return isNotNull(child) ? (`${child}`).split(BlankSplitChar).length : 0;
}
_digest(v) {
const o = this.options;
v = isArray(v) ? v : [v];
const level = this._getLevel();
return any(v, (idx, value) => contains(
o.childValues,
(`${value}`).split(BlankSplitChar).slice(0, level).join(BlankSplitChar)
));
}
hover() {
super.hover(...arguments);
this.icon1.element.addClass("hover");
this.icon2.element.addClass("hover");
}
dishover() {
super.dishover(...arguments);
this.icon1.element.removeClass("hover");
this.icon2.element.removeClass("hover");
}
doClick() {
super.doClick(...arguments);
if (this.isValid()) {
this.fireEvent(DownListGroupItem.EVENT_CHANGE, this.getValue());
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
setValue(v) {
this.icon1.setSelected && this.icon1.setSelected(this._digest(v));
}
static xtype = "bi.down_list_group_item";
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-down-list-group-item`,
logic: {
dynamic: false,
},
// invalid: true,
iconCls1: "dot-e-font",
icon: "",
iconCls2: "pull-right-e-font",
});
}
render() {
const o = this.options;
this.text = createWidget({
type: Label.xtype,
cls: "list-group-item-text",
textAlign: "left",
text: o.text,
value: o.value,
height: o.height,
});
if (isPlainObject(o.icon)) {
this.icon1 = createWidget({
width: 36,
height: o.height,
type: CenterAdaptLayout.xtype,
items: [o.icon],
});
} else {
this.icon1 = createWidget({
type: IconButton.xtype,
cls: o.iconCls1,
width: 36,
height: o.height,
iconHeight: o.iconHeight,
iconWidth: 36,
disableSelected: true,
selected: this._digest(o.value),
});
}
this.icon2 = createWidget({
type: IconButton.xtype,
cls: o.iconCls2,
width: 24,
forceNotSelected: true,
});
this.element.hover(
() => {
if (this.isEnabled()) {
this.hover();
}
},
() => {
if (this.isEnabled()) {
this.dishover();
}
}
);
return {
type: HorizontalFillLayout.xtype,
columnSize: [36, "fill", 24],
items: [this.icon1, this.text, this.icon2],
};
}
_getLevel() {
const child = first(this.options.childValues);
return isNotNull(child) ? `${child}`.split(BlankSplitChar).length : 0;
}
_digest(v) {
const o = this.options;
v = isArray(v) ? v : [v];
const level = this._getLevel();
return any(v, (idx, value) =>
contains(o.childValues, `${value}`.split(BlankSplitChar).slice(0, level).join(BlankSplitChar))
);
}
hover() {
super.hover(...arguments);
this.icon1.element.addClass("hover");
this.icon2.element.addClass("hover");
}
dishover() {
super.dishover(...arguments);
this.icon1.element.removeClass("hover");
this.icon2.element.removeClass("hover");
}
doClick() {
super.doClick(...arguments);
if (this.isValid()) {
this.fireEvent(DownListGroupItem.EVENT_CHANGE, this.getValue());
}
}
doRedMark() {
this.text.doRedMark(...arguments);
}
unRedMark() {
this.text.unRedMark(...arguments);
}
setValue(v) {
this.icon1.setSelected && this.icon1.setSelected(this._digest(v));
}
}

580
src/widget/downlist/popup.downlist.js

@ -1,4 +1,7 @@
import { ButtonTree, Pane } from "@/base";
import {
VerticalLayout,
Layout,
shortcut,
extend,
createWidget,
@ -13,320 +16,315 @@ import {
some,
deepClone
} from "@/core";
import { Pane, ButtonTree } from "@/base";
import { DownListGroup } from "./group.downlist";
@shortcut()
export class DownListPopup extends Pane {
static xtype = "bi.down_list_popup";
static xtype = "bi.down_list_popup";
constants = {
nextIcon: "pull-right-e-font",
height: 24,
iconHeight: 12,
iconWidth: 12,
hgap: 0,
vgap: 0,
border: 1,
};
constants = {
nextIcon: "pull-right-e-font",
height: 24,
iconHeight: 12,
iconWidth: 12,
hgap: 0,
vgap: 0,
border: 1,
};
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
chooseType: Selection.Multi,
});
}
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
_init() {
super._init(...arguments);
this.singleValues = [];
this.childValueMap = {};
this.fatherValueMap = {};
this.items = [];
const o = this.options,
children = this._createPopupItems(o.items);
this.popup = createWidget({
type: "bi.button_tree",
items: createItems(
children,
{},
{
adjustLength: -2,
}
),
layouts: [
{
type: "bi.vertical",
hgap: this.constants.hgap,
vgap: this.constants.vgap,
}
],
value: this._digest(o.value),
chooseType: o.chooseType,
});
return extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
chooseType: Selection.Multi,
});
}
this.popup.on(ButtonTree.EVENT_CHANGE, (value, object) => {
let changedValue = value;
if (isNotNull(this.childValueMap[value])) {
changedValue = this.childValueMap[value];
this.fireEvent(
DownListPopup.EVENT_SON_VALUE_CHANGE,
changedValue,
this.fatherValueMap[value]
);
} else {
this.fireEvent(DownListPopup.EVENT_CHANGE, changedValue, object);
}
_init() {
super._init(...arguments);
this.singleValues = [];
this.childValueMap = {};
this.fatherValueMap = {};
this.items = [];
const o = this.options,
children = this._createPopupItems(o.items);
this.popup = createWidget({
type: ButtonTree.xtype,
items: createItems(
children,
{},
{
adjustLength: -2,
}
),
layouts: [
{
type: VerticalLayout.xtype,
hgap: this.constants.hgap,
vgap: this.constants.vgap,
}
],
value: this._digest(o.value),
chooseType: o.chooseType,
});
if (!contains(this.singleValues, changedValue)) {
const item = this.getValue();
const result = [];
each(item, (i, valueObject) => {
if (valueObject.value !== changedValue) {
result.push(valueObject);
}
});
this.setValue(result);
}
});
this.popup.on(ButtonTree.EVENT_CHANGE, (value, object) => {
let changedValue = value;
if (isNotNull(this.childValueMap[value])) {
changedValue = this.childValueMap[value];
this.fireEvent(DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, this.fatherValueMap[value]);
} else {
this.fireEvent(DownListPopup.EVENT_CHANGE, changedValue, object);
}
createWidget({
type: "bi.vertical",
element: this,
items: [this.popup],
vgap: 5,
});
}
if (!contains(this.singleValues, changedValue)) {
const item = this.getValue();
const result = [];
each(item, (i, valueObject) => {
if (valueObject.value !== changedValue) {
result.push(valueObject);
}
});
this.setValue(result);
}
});
_createPopupItems(items) {
const result = [];
// 不能修改populate进来的item的引用
each(items, (i, it) => {
const item_done = {
type: "bi.down_list_group",
items: [],
};
createWidget({
type: VerticalLayout.xtype,
element: this,
items: [this.popup],
vgap: 5,
});
}
const storeItem = [];
_createPopupItems(items) {
const result = [];
// 不能修改populate进来的item的引用
each(items, (i, it) => {
const item_done = {
type: DownListGroup.xtype,
items: [],
};
each(it, (i, sourceItem) => {
const item = extend({}, sourceItem);
if (isNotEmptyArray(sourceItem.children) && !isEmpty(sourceItem.el)) {
item.type = "bi.combo_group";
// popup未初始化返回的是options中的value, 在经过buttontree的getValue concat之后,无法区分值来自options
// 还是item自身, 这边控制defaultInit为true来避免这个问题
item.isDefaultInit = true;
item.cls = "down-list-group";
item.trigger = "hover";
item.isNeedAdjustWidth = false;
item.el = sourceItem.el;
item.el.title = sourceItem.el.title || sourceItem.el.text;
item.el.type = "bi.down_list_group_item";
item.el.logic = {
dynamic: true,
};
item.el.height =
sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT;
item.el.iconCls2 = this.constants.nextIcon;
item.popup = {
lgap: 1,
el: {
type: "bi.button_tree",
chooseType: 0,
layouts: [
{
type: "bi.vertical",
}
],
},
innerVgap: 5,
maxHeight: 378,
};
this._createChildren(item, sourceItem);
} else {
item.type = sourceItem.type || "bi.down_list_item";
item.title = sourceItem.title || sourceItem.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true,
};
}
const el_done = {};
el_done.el = item;
item_done.items.push(el_done);
storeItem.push(item);
});
if (this._isGroup(item_done.items)) {
each(item_done.items, (i, item) => {
this.singleValues.push(item.el.value);
});
}
const storeItem = [];
result.push(item_done);
this.items.push(storeItem);
if (this._needSpliter(i, items.length)) {
const spliter_container = createWidget({
type: "bi.vertical",
items: [
{
el: {
type: "bi.layout",
cls: "bi-down-list-spliter bi-split-top cursor-pointer",
height: 0,
},
}
],
cls: "bi-down-list-spliter-container cursor-pointer",
vgap: 5,
hgap: 12,
});
result.push(spliter_container);
}
});
return result;
}
each(it, (i, sourceItem) => {
const item = extend({}, sourceItem);
if (isNotEmptyArray(sourceItem.children) && !isEmpty(sourceItem.el)) {
item.type = "bi.combo_group";
// popup未初始化返回的是options中的value, 在经过buttontree的getValue concat之后,无法区分值来自options
// 还是item自身, 这边控制defaultInit为true来避免这个问题
item.isDefaultInit = true;
item.cls = "down-list-group";
item.trigger = "hover";
item.isNeedAdjustWidth = false;
item.el = sourceItem.el;
item.el.title = sourceItem.el.title || sourceItem.el.text;
item.el.type = "bi.down_list_group_item";
item.el.logic = {
dynamic: true,
};
item.el.height = sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT;
item.el.iconCls2 = this.constants.nextIcon;
item.popup = {
lgap: 1,
el: {
type: ButtonTree.xtype,
chooseType: 0,
layouts: [
{
type: VerticalLayout.xtype,
}
],
},
innerVgap: 5,
maxHeight: 378,
};
this._createChildren(item, sourceItem);
} else {
item.type = sourceItem.type || "bi.down_list_item";
item.title = sourceItem.title || sourceItem.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true,
};
}
const el_done = {};
el_done.el = item;
item_done.items.push(el_done);
storeItem.push(item);
});
if (this._isGroup(item_done.items)) {
each(item_done.items, (i, item) => {
this.singleValues.push(item.el.value);
});
}
_createChildren(targetItem, sourceItem) {
targetItem.el.childValues = [];
targetItem.items = targetItem.children = [];
each(sourceItem.children, (i, child) => {
const item = extend({}, child);
const fatherValue = deepClone(targetItem.el.value);
const childValue = deepClone(item.value);
this.singleValues.push(item.value);
item.type = item.type || "bi.down_list_item";
item.extraCls = " child-down-list-item";
item.title = item.title || item.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true,
};
item.father = fatherValue;
item.childValue = item.value;
this.fatherValueMap[this._createChildValue(fatherValue, childValue)] =
fatherValue;
this.childValueMap[this._createChildValue(fatherValue, childValue)] =
childValue;
item.value = this._createChildValue(fatherValue, childValue);
targetItem.el.childValues.push(item.value);
targetItem.items.push(item);
});
}
result.push(item_done);
this.items.push(storeItem);
if (this._needSpliter(i, items.length)) {
const spliter_container = createWidget({
type: VerticalLayout.xtype,
items: [
{
el: {
type: Layout.xtype,
cls: "bi-down-list-spliter bi-split-top cursor-pointer",
height: 0,
},
}
],
cls: "bi-down-list-spliter-container cursor-pointer",
vgap: 5,
hgap: 12,
});
result.push(spliter_container);
}
});
_isGroup(i) {
return i.length > 1;
}
return result;
}
_needSpliter(i, itemLength) {
return i < itemLength - 1;
}
_createChildren(targetItem, sourceItem) {
targetItem.el.childValues = [];
targetItem.items = targetItem.children = [];
each(sourceItem.children, (i, child) => {
const item = extend({}, child);
const fatherValue = deepClone(targetItem.el.value);
const childValue = deepClone(item.value);
this.singleValues.push(item.value);
item.type = item.type || "bi.down_list_item";
item.extraCls = " child-down-list-item";
item.title = item.title || item.text;
item.textRgap = 10;
item.isNeedAdjustWidth = false;
item.logic = {
dynamic: true,
};
item.father = fatherValue;
item.childValue = item.value;
this.fatherValueMap[this._createChildValue(fatherValue, childValue)] = fatherValue;
this.childValueMap[this._createChildValue(fatherValue, childValue)] = childValue;
item.value = this._createChildValue(fatherValue, childValue);
targetItem.el.childValues.push(item.value);
targetItem.items.push(item);
});
}
_createChildValue(fatherValue, childValue) {
return fatherValue + BI.BlankSplitChar + childValue;
}
_isGroup(i) {
return i.length > 1;
}
_digest(valueItem) {
const valueArray = [];
each(valueItem, (i, item) => {
let value;
if (isNotNull(item.childValue)) {
value = this._createChildValue(item.value, item.childValue);
} else {
value = item.value;
}
valueArray.push(value);
});
return valueArray;
}
_needSpliter(i, itemLength) {
return i < itemLength - 1;
}
_checkValues(values) {
const value = [];
each(this.items, (idx, itemGroup) => {
each(itemGroup, (id, item) => {
if (isNotNull(item.children)) {
const childValues = map(item.children, "value");
const v = joinValue(childValues, values[idx]);
if (isNotEmptyString(v)) {
value.push(v);
}
} else {
if (item.value === values[idx][0]) {
value.push(values[idx][0]);
}
}
});
});
return value;
_createChildValue(fatherValue, childValue) {
return fatherValue + BI.BlankSplitChar + childValue;
}
function joinValue(sources, targets) {
let value = "";
some(sources, (idx, s) => some(targets, (id, t) => {
if (s === t) {
value = s;
return true;
}
}));
return value;
}
}
_digest(valueItem) {
const valueArray = [];
each(valueItem, (i, item) => {
let value;
if (isNotNull(item.childValue)) {
value = this._createChildValue(item.value, item.childValue);
} else {
value = item.value;
}
valueArray.push(value);
});
populate(items) {
super.populate(...arguments);
this.items = [];
this.childValueMap = {};
this.fatherValueMap = {};
this.singleValues = [];
const children = this._createPopupItems(items);
const popupItem = createItems(
children,
{},
{
adjustLength: -2,
}
);
this.popup.populate(popupItem);
}
return valueArray;
}
setValue(valueItem) {
this.popup.setValue(this._digest(valueItem));
}
_checkValues(values) {
const value = [];
each(this.items, (idx, itemGroup) => {
each(itemGroup, (id, item) => {
if (isNotNull(item.children)) {
const childValues = map(item.children, "value");
const v = joinValue(childValues, values[idx]);
if (isNotEmptyString(v)) {
value.push(v);
}
} else {
if (item.value === values[idx][0]) {
value.push(values[idx][0]);
}
}
});
});
_getValue() {
const v = [];
each(this.popup.getAllButtons(), (i, item) => {
i % 2 === 0 && v.push(item.getValue());
});
return v;
}
return value;
getValue() {
const result = [];
const values = this._checkValues(this._getValue());
each(values, (i, value) => {
const valueItem = {};
if (isNotNull(this.childValueMap[value])) {
const fartherValue = this.fatherValueMap[value];
valueItem.childValue = this.childValueMap[value];
valueItem.value = fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
function joinValue(sources, targets) {
let value = "";
some(sources, (idx, s) =>
some(targets, (id, t) => {
if (s === t) {
value = s;
return true;
}
})
);
return value;
}
}
populate(items) {
super.populate(...arguments);
this.items = [];
this.childValueMap = {};
this.fatherValueMap = {};
this.singleValues = [];
const children = this._createPopupItems(items);
const popupItem = createItems(
children,
{},
{
adjustLength: -2,
}
);
this.popup.populate(popupItem);
}
setValue(valueItem) {
this.popup.setValue(this._digest(valueItem));
}
_getValue() {
const v = [];
each(this.popup.getAllButtons(), (i, item) => {
i % 2 === 0 && v.push(item.getValue());
});
return v;
}
getValue() {
const result = [];
const values = this._checkValues(this._getValue());
each(values, (i, value) => {
const valueItem = {};
if (isNotNull(this.childValueMap[value])) {
const fartherValue = this.fatherValueMap[value];
valueItem.childValue = this.childValueMap[value];
valueItem.value = fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
}

75
src/widget/dynamicdate/dynamicdate.caculate.js

@ -1,53 +1,86 @@
import { isNotNull, parseInt, getDate, i18nText, size, getOffsetQuarter, getOffsetMonth, getOffsetDate, getLastDateOfMonth, getWeekStartDate, getWeekEndDate, getQuarterStartDate, getQuarterEndDate, print } from "@/core";
import {
isNotNull,
parseInt,
getDate,
i18nText,
size,
getOffsetQuarter,
getOffsetMonth,
getOffsetDate,
getLastDateOfMonth,
getWeekStartDate,
getWeekEndDate,
getQuarterStartDate,
getQuarterEndDate,
print
} from "@/core";
import { DynamicDateCard } from "./dynamicdate.card";
export const DynamicDateHelper = {
getCalculation (obj) {
getCalculation(obj) {
const date = getDate();
return this.getCalculationByDate(date, obj);
},
getDescription (obj) {
getDescription(obj) {
let value = "";
let endText = "";
if (isNotNull(obj.year)) {
if (parseInt(obj.year) !== 0) {
value += Math.abs(obj.year) + i18nText("BI-Basic_Year") + (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.year) +
i18nText("BI-Basic_Year") +
(obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Year"), obj.position);
}
if (isNotNull(obj.quarter)) {
if (parseInt(obj.quarter) !== 0) {
value += Math.abs(obj.quarter) + i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.quarter) +
i18nText("BI-Basic_Single_Quarter") +
(obj.quarter < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Single_Quarter"), obj.position);
}
if (isNotNull(obj.month)) {
if (parseInt(obj.month) !== 0) {
value += Math.abs(obj.month) + i18nText("BI-Basic_Month") + (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.month) +
i18nText("BI-Basic_Month") +
(obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Month"), obj.position);
}
if (isNotNull(obj.week)) {
if (parseInt(obj.week) !== 0) {
value += Math.abs(obj.week) + i18nText("BI-Basic_Week") + (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.week) +
i18nText("BI-Basic_Week") +
(obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Week"), obj.position);
}
if (isNotNull(obj.day)) {
if (parseInt(obj.day) !== 0) {
value += Math.abs(obj.day) + i18nText("BI-Basic_Day") + (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.day) +
i18nText("BI-Basic_Day") +
(obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = size(obj) === 1 ? getPositionText(i18nText("BI-Basic_Month"), obj.position) : "";
}
if (isNotNull(obj.workDay) && parseInt(obj.workDay) !== 0) {
value += Math.abs(obj.workDay) + i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.workDay) +
i18nText("BI-Basic_Work_Day") +
(obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
return value + endText;
function getPositionText (baseText, position) {
function getPositionText(baseText, position) {
switch (position) {
case DynamicDateCard.OFFSET.BEGIN:
return baseText + i18nText("BI-Basic_Begin_Start");
@ -60,9 +93,9 @@ export const DynamicDateHelper = {
}
},
getCalculationByDate (date, obj) {
getCalculationByDate(date, obj) {
if (isNotNull(obj.year)) {
date = getDate((date.getFullYear() + parseInt(obj.year)), date.getMonth(), date.getDate());
date = getDate(date.getFullYear() + parseInt(obj.year), date.getMonth(), date.getDate());
}
if (isNotNull(obj.quarter)) {
date = getOffsetQuarter(date, parseInt(obj.quarter));
@ -97,23 +130,29 @@ export const DynamicDateHelper = {
return getDate(date.getFullYear(), date.getMonth(), date.getDate());
},
getBeginDate (date, obj) {
getBeginDate(date, obj) {
if (isNotNull(obj.day)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), date.getMonth(), 1) : getDate(date.getFullYear(), date.getMonth(), (getLastDateOfMonth(date)).getDate());
return obj.position === DynamicDateCard.OFFSET.BEGIN
? getDate(date.getFullYear(), date.getMonth(), 1)
: getDate(date.getFullYear(), date.getMonth(), getLastDateOfMonth(date).getDate());
}
if (isNotNull(obj.week)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getWeekStartDate(date) : getWeekEndDate(date);
}
if (isNotNull(obj.month)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), date.getMonth(), 1) : getDate(date.getFullYear(), date.getMonth(), (getLastDateOfMonth(date)).getDate());
return obj.position === DynamicDateCard.OFFSET.BEGIN
? getDate(date.getFullYear(), date.getMonth(), 1)
: getDate(date.getFullYear(), date.getMonth(), getLastDateOfMonth(date).getDate());
}
if (isNotNull(obj.quarter)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getQuarterStartDate(date) : getQuarterEndDate(date);
}
if (isNotNull(obj.year)) {
return obj.position === DynamicDateCard.OFFSET.BEGIN ? getDate(date.getFullYear(), 0, 1) : getDate(date.getFullYear(), 11, 31);
return obj.position === DynamicDateCard.OFFSET.BEGIN
? getDate(date.getFullYear(), 0, 1)
: getDate(date.getFullYear(), 11, 31);
}
return date;
},
};

481
src/widget/dynamicdate/dynamicdate.card.js

@ -1,12 +1,33 @@
import { shortcut, Widget, i18nText, createItems, each, isNotNull, map, has, bind, last, extend, checkDateVoid, isNull, isNotEmptyString, parseDateTime, any } from "@/core";
import { ButtonGroup, Bubbles } from "@/base";
import { MultiSelectItem } from "@/case";
import {
VerticalLayout,
FloatLeftLayout,
VerticalAdaptLayout,
shortcut,
Widget,
i18nText,
createItems,
each,
isNotNull,
map,
has,
bind,
last,
extend,
checkDateVoid,
isNull,
isNotEmptyString,
parseDateTime,
any
} from "@/core";
import { Label, ButtonGroup, Bubbles } from "@/base";
import { MultiSelectItem, TextValueCombo } from "@/case";
import { DynamicDateParamItem } from "./dynamicdate.param.item";
import { DynamicDateHelper } from "./dynamicdate.caculate";
@shortcut()
export class DynamicDateCard extends Widget {
static xtype = "bi.dynamic_date_card";
static TYPE = {
YEAR: 1,
QUARTER: 2,
@ -27,132 +48,168 @@ export class DynamicDateCard extends Widget {
render() {
this.position = DynamicDateCard.OFFSET.CURRENT;
return {
type: "bi.vertical",
items: [{
el: {
type: "bi.label",
text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left",
lgap: 10,
},
tgap: 10,
bgap: 5,
}, {
type: "bi.button_group",
ref: _ref => {
this.checkgroup = _ref;
type: VerticalLayout.xtype,
items: [
{
el: {
type: Label.xtype,
text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left",
lgap: 10,
},
tgap: 10,
bgap: 5,
},
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI,
lgap: 4,
value: [DynamicDateCard.TYPE.YEAR],
items: createItems([{
text: i18nText("BI-Basic_Year"),
value: DynamicDateCard.TYPE.YEAR,
}, {
text: i18nText("BI-Basic_Single_Quarter"),
value: DynamicDateCard.TYPE.QUARTER,
}, {
text: i18nText("BI-Basic_Month"),
value: DynamicDateCard.TYPE.MONTH,
}, {
text: i18nText("BI-Basic_Week"),
value: DynamicDateCard.TYPE.WEEK,
}, {
text: i18nText("BI-Basic_Day"),
value: DynamicDateCard.TYPE.DAY,
}], {
type: "bi.multi_select_item",
logic: {
dynamic: true,
{
type: ButtonGroup.xtype,
ref: _ref => {
this.checkgroup = _ref;
},
iconWrapperWidth: 26,
}),
layouts: [{
type: "bi.left",
rgap: 4,
}],
listeners: [{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
const value = this.checkgroup.getValue();
if (value.length !== 0) {
this.workDayBox.setSelected(false);
}
const plainValue = {};
each(this.resultPane.getAllButtons(), (idx, button) => {
const value = button.getValue();
if (isNotNull(value.dateType)) {
plainValue[value.dateType] = {
value: value.value,
offset: value.offset,
};
}
});
this.resultPane.populate(this._getParamJson(map(this.checkgroup.getValue(), (idx, v) => {
const obj = {
dateType: v,
};
if (has(plainValue, v)) {
obj.value = plainValue[v].value;
obj.offset = plainValue[v].offset;
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI,
lgap: 4,
value: [DynamicDateCard.TYPE.YEAR],
items: createItems(
[
{
text: i18nText("BI-Basic_Year"),
value: DynamicDateCard.TYPE.YEAR,
},
{
text: i18nText("BI-Basic_Single_Quarter"),
value: DynamicDateCard.TYPE.QUARTER,
},
{
text: i18nText("BI-Basic_Month"),
value: DynamicDateCard.TYPE.MONTH,
},
{
text: i18nText("BI-Basic_Week"),
value: DynamicDateCard.TYPE.WEEK,
},
{
text: i18nText("BI-Basic_Day"),
value: DynamicDateCard.TYPE.DAY,
}
return obj;
})));
this.position = DynamicDateCard.OFFSET.CURRENT;
this.fireEvent("EVENT_CHANGE");
},
}],
}, {
type: "bi.vertical_adapt",
lgap: 2,
items: [{
el: {
type: "bi.multi_select_item",
iconWrapperWidth: 26,
ref: _ref => {
this.workDayBox = _ref;
},
logic: {
dynamic: true,
},
text: i18nText("BI-Basic_Work_Day"),
value: DynamicDateCard.TYPE.WORK_DAY,
listeners: [{
eventName: MultiSelectItem.EVENT_CHANGE,
],
{
type: MultiSelectItem.xtype,
logic: {
dynamic: true,
},
iconWrapperWidth: 26,
}
),
layouts: [
{
type: FloatLeftLayout.xtype,
rgap: 4,
}
],
listeners: [
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
if (this.workDayBox.isSelected()) {
this.checkgroup.setValue();
const value = this.checkgroup.getValue();
if (value.length !== 0) {
this.workDayBox.setSelected(false);
}
this.resultPane.populate(this.workDayBox.isSelected() ? this._getParamJson([{
dateType: DynamicDateCard.TYPE.WORK_DAY,
}]) : []);
const plainValue = {};
each(this.resultPane.getAllButtons(), (idx, button) => {
const value = button.getValue();
if (isNotNull(value.dateType)) {
plainValue[value.dateType] = {
value: value.value,
offset: value.offset,
};
}
});
this.resultPane.populate(
this._getParamJson(
map(this.checkgroup.getValue(), (idx, v) => {
const obj = {
dateType: v,
};
if (has(plainValue, v)) {
obj.value = plainValue[v].value;
obj.offset = plainValue[v].offset;
}
return obj;
})
)
);
this.position = DynamicDateCard.OFFSET.CURRENT;
this.fireEvent("EVENT_CHANGE");
},
}],
},
}],
ref: _ref => {
this.workDay = _ref;
}
],
},
}, {
type: "bi.button_group",
items: this._getParamJson([{
dateType: DynamicDateCard.TYPE.YEAR,
}]),
ref: _ref => {
this.resultPane = _ref;
{
type: VerticalAdaptLayout.xtype,
lgap: 2,
items: [
{
el: {
type: MultiSelectItem.xtype,
iconWrapperWidth: 26,
ref: _ref => {
this.workDayBox = _ref;
},
logic: {
dynamic: true,
},
text: i18nText("BI-Basic_Work_Day"),
value: DynamicDateCard.TYPE.WORK_DAY,
listeners: [
{
eventName: MultiSelectItem.EVENT_CHANGE,
action: () => {
if (this.workDayBox.isSelected()) {
this.checkgroup.setValue();
}
this.resultPane.populate(
this.workDayBox.isSelected()
? this._getParamJson([
{
dateType: DynamicDateCard.TYPE.WORK_DAY,
}
])
: []
);
this.position = DynamicDateCard.OFFSET.CURRENT;
this.fireEvent("EVENT_CHANGE");
},
}
],
},
}
],
ref: _ref => {
this.workDay = _ref;
},
},
layouts: [{
type: "bi.vertical",
bgap: 10,
hgap: 10,
}],
}],
{
type: ButtonGroup.xtype,
items: this._getParamJson([
{
dateType: DynamicDateCard.TYPE.YEAR,
}
]),
ref: _ref => {
this.resultPane = _ref;
},
layouts: [
{
type: VerticalLayout.xtype,
bgap: 10,
hgap: 10,
}
],
}
],
};
}
@ -160,22 +217,25 @@ export class DynamicDateCard extends Widget {
const items = map(values, (idx, value) => {
return {
el: {
type: "bi.dynamic_date_param_item",
type: DynamicDateParamItem.xtype,
validationChecker: bind(this._checkDate, this),
dateType: value.dateType,
value: value.value,
offset: value.offset,
listeners: [{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
}, {
eventName: "EVENT_INPUT_CHANGE",
action () {
Bubbles.hide("dynamic-date-error");
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.fireEvent("EVENT_CHANGE");
},
},
}],
{
eventName: "EVENT_INPUT_CHANGE",
action() {
Bubbles.hide("dynamic-date-error");
},
}
],
},
tgap: idx === 0 ? 5 : 0,
};
@ -185,7 +245,7 @@ export class DynamicDateCard extends Widget {
const comboItems = this._getText(DynamicDateCard.TYPE.MONTH);
comboItems[0].text = i18nText("BI-Basic_Empty");
items.push({
type: "bi.text_value_combo",
type: TextValueCombo.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
items: comboItems,
container: null,
@ -193,19 +253,25 @@ export class DynamicDateCard extends Widget {
ref: _ref => {
this.textValueCombo = _ref;
},
listeners: [{
eventName: "EVENT_CHANGE",
action: () => {
this.position = this.textValueCombo.getValue()[0];
this.textValueCombo.setValue(this.position);
this.fireEvent("EVENT_CHANGE");
},
}],
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.position = this.textValueCombo.getValue()[0];
this.textValueCombo.setValue(this.position);
this.fireEvent("EVENT_CHANGE");
},
}
],
});
} else {
if (values.length !== 0 && last(values).dateType !== DynamicDateCard.TYPE.DAY && last(values).dateType !== DynamicDateCard.TYPE.WORK_DAY) {
if (
values.length !== 0 &&
last(values).dateType !== DynamicDateCard.TYPE.DAY &&
last(values).dateType !== DynamicDateCard.TYPE.WORK_DAY
) {
items.push({
type: "bi.text_value_combo",
type: TextValueCombo.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
container: null,
items: this._getText(last(values).dateType),
@ -213,14 +279,16 @@ export class DynamicDateCard extends Widget {
ref: _ref => {
this.textValueCombo = _ref;
},
listeners: [{
eventName: "EVENT_CHANGE",
action: () => {
this.position = this.textValueCombo.getValue()[0];
this.textValueCombo.setValue(this.position);
this.fireEvent("EVENT_CHANGE");
},
}],
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this.position = this.textValueCombo.getValue()[0];
this.textValueCombo.setValue(this.position);
this.fireEvent("EVENT_CHANGE");
},
}
],
});
}
}
@ -238,50 +306,66 @@ export class DynamicDateCard extends Widget {
_getText(lastValue) {
switch (lastValue) {
case DynamicDateCard.TYPE.YEAR:
return [{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
}, {
text: i18nText("BI-Basic_Year_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
}, {
text: i18nText("BI-Basic_Year_End"),
value: DynamicDateCard.OFFSET.END,
}];
return [
{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
},
{
text: i18nText("BI-Basic_Year_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
},
{
text: i18nText("BI-Basic_Year_End"),
value: DynamicDateCard.OFFSET.END,
}
];
case DynamicDateCard.TYPE.QUARTER:
return [{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
}, {
text: i18nText("BI-Basic_Quarter_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
}, {
text: i18nText("BI-Basic_Quarter_End"),
value: DynamicDateCard.OFFSET.END,
}];
return [
{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
},
{
text: i18nText("BI-Basic_Quarter_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
},
{
text: i18nText("BI-Basic_Quarter_End"),
value: DynamicDateCard.OFFSET.END,
}
];
case DynamicDateCard.TYPE.MONTH:
return [{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
}, {
text: i18nText("BI-Basic_Month_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
}, {
text: i18nText("BI-Basic_Month_End"),
value: DynamicDateCard.OFFSET.END,
}];
return [
{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
},
{
text: i18nText("BI-Basic_Month_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
},
{
text: i18nText("BI-Basic_Month_End"),
value: DynamicDateCard.OFFSET.END,
}
];
case DynamicDateCard.TYPE.WEEK:
default:
return [{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
}, {
text: i18nText("BI-Basic_Week_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
}, {
text: i18nText("BI-Basic_Week_End"),
value: DynamicDateCard.OFFSET.END,
}];
return [
{
text: i18nText("BI-Basic_Current_Day"),
value: DynamicDateCard.OFFSET.CURRENT,
},
{
text: i18nText("BI-Basic_Week_Begin"),
value: DynamicDateCard.OFFSET.BEGIN,
},
{
text: i18nText("BI-Basic_Week_End"),
value: DynamicDateCard.OFFSET.END,
}
];
}
}
@ -297,22 +381,22 @@ export class DynamicDateCard extends Widget {
const valueMap = {};
switch (value.dateType) {
case DynamicDateCard.TYPE.YEAR:
valueMap.year = (value.offset === 0 ? -value.value : +value.value);
valueMap.year = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.QUARTER:
valueMap.quarter = (value.offset === 0 ? -value.value : +value.value);
valueMap.quarter = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.MONTH:
valueMap.month = (value.offset === 0 ? -value.value : +value.value);
valueMap.month = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.WEEK:
valueMap.week = (value.offset === 0 ? -value.value : +value.value);
valueMap.week = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.DAY:
valueMap.day = (value.offset === 0 ? -value.value : +value.value);
valueMap.day = value.offset === 0 ? -value.value : +value.value;
break;
case DynamicDateCard.TYPE.WORK_DAY:
valueMap.workDay = (value.offset === 0 ? -value.value : +value.value);
valueMap.workDay = value.offset === 0 ? -value.value : +value.value;
break;
default:
break;
@ -320,7 +404,7 @@ export class DynamicDateCard extends Widget {
if (isNull(value.dateType)) {
valueMap.position = this.position || DynamicDateCard.OFFSET.CURRENT;
}
return valueMap;
}
@ -382,7 +466,7 @@ export class DynamicDateCard extends Widget {
}
if (this.workDayBox.isSelected()) {
const value = buttons[0].getValue();
valueMap.workDay = (value.offset === 0 ? -value.value : +value.value);
valueMap.workDay = value.offset === 0 ? -value.value : +value.value;
}
return valueMap;
@ -393,7 +477,8 @@ export class DynamicDateCard extends Widget {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
return i18nText("BI-Basic_Date_Range_Error",
return i18nText(
"BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),

468
src/widget/dynamicdate/dynamicdate.combo.js

@ -1,33 +1,45 @@
import { shortcut, getDate, toPix, isEqual, isNotEmptyString, isEmptyString, isNotNull, isNotEmptyObject, checkDateVoid } from "@/core";
import { Single, Combo } from "@/base";
import {
AbsoluteLayout,
HorizontalFillLayout,
shortcut,
getDate,
toPix,
isEqual,
isNotEmptyString,
isEmptyString,
isNotNull,
isNotEmptyObject,
checkDateVoid,
} from "@/core";
import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTrigger } from "./dynamicdate.trigger";
import { DynamicDatePopup } from "./dynamicdate.popup";
@shortcut()
export class DynamicDateCombo extends Single {
static xtype = "bi.dynamic_date_combo"
static xtype = "bi.dynamic_date_combo";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
static Static = 1;
static Dynamic = 2;
constants = {
popupHeight: 259,
popupWidth: 270,
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
}
};
props = {
baseCls: "bi-dynamic-date-combo",
@ -56,200 +68,222 @@ export class DynamicDateCombo extends Single {
const border = opts.simple ? 1 : 2;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
container: opts.container,
ref: _ref => {
this.combo = _ref;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: "bi.horizontal_fill",
columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: toPix(opts.height, border),
height: toPix(opts.height, border),
ref: _ref => {
this.changeIcon = _ref;
},
},
}, {
type: "bi.dynamic_date_trigger",
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
iconWidth: toPix(opts.height, border),
type: Combo.xtype,
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
container: opts.container,
ref: (_ref) => {
this.combo = _ref;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
el: {
type: HorizontalFillLayout.xtype,
columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
value: opts.value,
ref: _ref => {
this.trigger = _ref;
},
listeners: [{
eventName: DynamicDateTrigger.EVENT_KEY_DOWN,
action: (...args) => {
if (this.combo.isViewVisible()) {
this.combo.hideView();
}
this.fireEvent(DynamicDateCombo.EVENT_KEY_DOWN, ...args);
},
}, {
eventName: DynamicDateTrigger.EVENT_STOP,
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
}, {
eventName: DynamicDateTrigger.EVENT_FOCUS,
action: () => {
this.storeTriggerValue = this.trigger.getKey();
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
this.fireEvent(DynamicDateCombo.EVENT_FOCUS);
},
}, {
eventName: DynamicDateTrigger.EVENT_BLUR,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BLUR);
},
}, {
eventName: DynamicDateTrigger.EVENT_ERROR,
action: () => {
this.storeValue = {
type: DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
items: [
{
el: {
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
width: toPix(opts.height, border),
height: toPix(opts.height, border),
ref: (_ref) => {
this.changeIcon = _ref;
},
};
this.combo.element.addClass("error");
this.fireEvent(DynamicDateCombo.EVENT_ERROR);
},
}, {
eventName: DynamicDateTrigger.EVENT_VALID,
action: () => {
this.storeValue = this.trigger.getValue();
this.combo.element.removeClass("error");
this.fireEvent(DynamicDateCombo.EVENT_VALID);
},
}, {
eventName: DynamicDateTrigger.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_CHANGE);
},
}, {
eventName: DynamicDateTrigger.EVENT_CONFIRM,
action: () => {
const dateStore = this.storeTriggerValue;
const dateObj = this.trigger.getKey();
if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
return;
}
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
this.storeValue = this.trigger.getValue();
this.setValue(this.trigger.getValue());
} else if (isEmptyString(dateObj)) {
this.storeValue = null;
this.trigger.setValue();
}
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}],
}],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: "bi.dynamic_date_popup",
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: _ref => {
this.popup = _ref;
},
listeners: [{
eventName: DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
}, {
eventName: DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({
type: DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
{
type: DynamicDateTrigger.xtype,
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
format: opts.format,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
iconWidth: toPix(opts.height, border),
height: toPix(opts.height, border),
value: opts.value,
ref: (_ref) => {
this.trigger = _ref;
},
listeners: [
{
eventName: DynamicDateTrigger.EVENT_KEY_DOWN,
action: (...args) => {
if (this.combo.isViewVisible()) {
this.combo.hideView();
}
this.fireEvent(DynamicDateCombo.EVENT_KEY_DOWN, ...args);
},
},
});
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}, {
eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
if (this._checkValue(value)) {
this.setValue(value);
}
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
{
eventName: DynamicDateTrigger.EVENT_STOP,
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
},
{
eventName: DynamicDateTrigger.EVENT_FOCUS,
action: () => {
this.storeTriggerValue = this.trigger.getKey();
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
this.fireEvent(DynamicDateCombo.EVENT_FOCUS);
},
},
{
eventName: DynamicDateTrigger.EVENT_BLUR,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BLUR);
},
},
{
eventName: DynamicDateTrigger.EVENT_ERROR,
action: () => {
this.storeValue = {
type: DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
},
};
this.combo.element.addClass("error");
this.fireEvent(DynamicDateCombo.EVENT_ERROR);
},
},
{
eventName: DynamicDateTrigger.EVENT_VALID,
action: () => {
this.storeValue = this.trigger.getValue();
this.combo.element.removeClass("error");
this.fireEvent(DynamicDateCombo.EVENT_VALID);
},
},
{
eventName: DynamicDateTrigger.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_CHANGE);
},
},
{
eventName: DynamicDateTrigger.EVENT_CONFIRM,
action: () => {
const dateStore = this.storeTriggerValue;
const dateObj = this.trigger.getKey();
if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
return;
}
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
this.storeValue = this.trigger.getValue();
this.setValue(this.trigger.getValue());
} else if (isEmptyString(dateObj)) {
this.storeValue = null;
this.trigger.setValue();
}
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
],
},
}, {
eventName: DynamicDatePopup.EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: DynamicDatePopup.xtype,
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: (_ref) => {
this.popup = _ref;
},
}, {
eventName: DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
listeners: [
{
eventName: DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({
type: DynamicDateCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
},
});
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
if (this._checkValue(value)) {
this.setValue(value);
}
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDatePopup.EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
},
],
},
},
// // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
// hideChecker: function (e) {
// return self.triggerBtn.element.find(e.target).length === 0;
// },
listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
this.popup.setMinDate(opts.minDate);
this.popup.setMaxDate(opts.maxDate);
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
},
},
],
},
// // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
// hideChecker: function (e) {
// return self.triggerBtn.element.find(e.target).length === 0;
// },
listeners: [{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setMinDate(opts.minDate);
this.popup.setMaxDate(opts.maxDate);
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
top: 0,
left: 0,
right: 0,
bottom: 0,
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}],
],
};
}
@ -263,16 +297,16 @@ export class DynamicDateCombo extends Single {
type = v.type;
}
switch (type) {
case DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
case DynamicDateCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - this.options.simple ? 1 : 2;
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
}
@ -280,20 +314,18 @@ export class DynamicDateCombo extends Single {
const o = this.options;
let value;
switch (v.type) {
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
value = v.value || {};
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
value = v.value || {};
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
}
}
_defaultState() {
}
_defaultState() {}
setMinDate(minDate) {
const o = this.options;

137
src/widget/dynamicdate/dynamicdate.param.item.js

@ -1,19 +1,20 @@
import { shortcut, Widget, toPix, isNaturalNumber, i18nText } from "@/core";
import { DynamicDateCard } from "./dynamicdate.card";
import { HTapeLayout, shortcut, Widget, toPix, isNaturalNumber, i18nText } from "@/core";
import { SignEditor, TextValueCombo } from "@/case";
import { Label } from "@/base";
import { DynamicDateCard } from "./dynamicdate.card";
@shortcut()
export class DynamicDateParamItem extends Widget {
static xtype = "bi.dynamic_date_param_item"
static xtype = "bi.dynamic_date_param_item";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_INPUT_CHANGE = "EVENT_INPUT_CHANGE"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_INPUT_CHANGE = "EVENT_INPUT_CHANGE";
props() {
return {
baseCls: "bi-dynamic-date-param-item",
dateType: DynamicDateCard.TYPE.YEAR,
validationChecker () {
validationChecker() {
return true;
},
value: 0,
@ -24,67 +25,79 @@ export class DynamicDateParamItem extends Widget {
render() {
const o = this.options;
return {
type: "bi.htape",
items: [{
el: {
type: "bi.sign_editor",
cls: "bi-border bi-focus-shadow bi-border-radius",
height: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2),
validationChecker (v) {
return isNaturalNumber(v);
},
value: o.value,
ref: _ref => {
this.editor = _ref;
},
errorText () {
return i18nText("BI-Please_Input_Natural_Number");
},
allowBlank: false,
listeners: [{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
type: HTapeLayout.xtype,
items: [
{
el: {
type: SignEditor.xtype,
cls: "bi-border bi-focus-shadow bi-border-radius",
height: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2),
validationChecker(v) {
return isNaturalNumber(v);
},
}, {
eventName: SignEditor.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_INPUT_CHANGE);
value: o.value,
ref: _ref => {
this.editor = _ref;
},
}],
},
width: 60,
}, {
el: {
type: "bi.label",
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
text: this._getText(),
errorText() {
return i18nText("BI-Please_Input_Natural_Number");
},
allowBlank: false,
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
},
},
{
eventName: SignEditor.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_INPUT_CHANGE);
},
}
],
},
width: 60,
},
width: o.dateType === DynamicDateCard.TYPE.WORK_DAY ? 60 : 20,
}, {
type: "bi.text_value_combo",
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
items: [{
text: i18nText("BI-Basic_Front"),
value: 0,
}, {
text: i18nText("BI-Basic_Behind"),
value: 1,
}],
ref: _ref => {
this.offsetCombo = _ref;
{
el: {
type: Label.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
text: this._getText(),
},
width: o.dateType === DynamicDateCard.TYPE.WORK_DAY ? 60 : 20,
},
container: null,
value: o.offset,
listeners: [{
eventName: TextValueCombo.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
{
type: TextValueCombo.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
items: [
{
text: i18nText("BI-Basic_Front"),
value: 0,
},
{
text: i18nText("BI-Basic_Behind"),
value: 1,
}
],
ref: _ref => {
this.offsetCombo = _ref;
},
}],
}],
container: null,
value: o.offset,
listeners: [
{
eventName: TextValueCombo.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
},
}
],
}
],
};
}
@ -111,7 +124,7 @@ export class DynamicDateParamItem extends Widget {
text = i18nText("BI-Basic_Work_Day");
break;
}
return text;
}

288
src/widget/dynamicdate/dynamicdate.popup.js

@ -1,16 +1,33 @@
import { shortcut, Widget, createWidget, i18nText, toPix, createItems, isNull, isEmptyObject, isEmptyString, getDate, checkDateVoid, print } from "@/core";
import { DynamicDateCombo } from "./dynamicdate.combo";
import {
VerticalLayout,
GridLayout,
shortcut,
Widget,
createWidget,
i18nText,
toPix,
createItems,
isNull,
isEmptyObject,
isEmptyString,
getDate,
checkDateVoid,
print
} from "@/core";
import { TextButton, Tab } from "@/base";
import { LinearSegment } from "@/case";
import { DynamicDateCard } from "./dynamicdate.card";
import { DateCalendarPopup } from "../date/calendar";
import { DynamicDateCombo } from "./dynamicdate.combo";
import { DynamicDateHelper } from "./dynamicdate.caculate";
@shortcut()
export class DynamicDatePopup extends Widget {
static xtype = "bi.dynamic_date_popup"
static xtype = "bi.dynamic_date_popup";
constants = {
tabHeight: 40,
}
};
props = {
baseCls: "bi-dynamic-date-popup",
@ -18,11 +35,11 @@ export class DynamicDatePopup extends Widget {
supportDynamic: true,
};
static EVENT_CHANGE = "EVENT_CHANGE"
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_init() {
super._init(...arguments);
@ -32,72 +49,86 @@ export class DynamicDatePopup extends Widget {
};
createWidget({
element: this,
type: "bi.vertical",
items: [{
el: this._getTabJson(),
}, {
el: {
type: "bi.grid",
items: [
[{
type: "bi.text_button",
cls: "bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
text: i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(),
ref: _ref => {
this.todayButton = _ref;
},
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE);
type: VerticalLayout.xtype,
items: [
{
el: this._getTabJson(),
},
{
el: {
type: GridLayout.xtype,
items: [
[
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}
],
},
}],
}, {
type: "bi.text_button",
cls: "bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
}
{
type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true,
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
text: i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(),
ref: _ref => {
this.todayButton = _ref;
},
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE);
},
}
],
},
}],
}]
],
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
},
}],
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
}
},
}
],
}
]
],
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
},
}
],
});
this.setValue(opts.value);
}
_getTabJson() {
const o = this.options;
return {
type: "bi.tab",
type: Tab.xtype,
logic: {
dynamic: true,
},
@ -105,32 +136,40 @@ export class DynamicDatePopup extends Widget {
this.dateTab = _ref;
},
tab: {
type: "bi.linear_segment",
type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: this.constants.tabHeight,
items: createItems([{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateCombo.Static,
}, {
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateCombo.Dynamic,
}], {
textAlign: "center",
}),
items: createItems(
[
{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateCombo.Static,
},
{
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateCombo.Dynamic,
}
],
{
textAlign: "center",
}
),
},
cardCreator: v => {
switch (v) {
case DynamicDateCombo.Dynamic:
return {
type: "bi.dynamic_date_card",
type: DynamicDateCard.xtype,
cls: "dynamic-date-pane",
listeners: [{
eventName: "EVENT_CHANGE",
action: () => {
this._setInnerValue(this.year, v);
},
}],
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this._setInnerValue(this.year, v);
},
}
],
min: this.options.min,
max: this.options.max,
ref: _ref => {
@ -140,56 +179,61 @@ export class DynamicDatePopup extends Widget {
case DynamicDateCombo.Static:
default:
return {
type: "bi.date_calendar_popup",
type: DateCalendarPopup.xtype,
behaviors: o.behaviors,
min: this.options.min,
max: this.options.max,
listeners: [{
eventName: DateCalendarPopup.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.EVENT_CHANGE);
},
}, {
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
listeners: [
{
eventName: DateCalendarPopup.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.EVENT_CHANGE);
},
},
}],
{
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDatePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}
],
ref: _ref => {
this.ymd = _ref;
},
};
}
},
listeners: [{
eventName: Tab.EVENT_CHANGE,
action: () => {
const v = this.dateTab.getSelect();
let date;
switch (v) {
case DynamicDateCombo.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this._setInnerValue();
break;
case DynamicDateCombo.Dynamic:
default:
if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
listeners: [
{
eventName: Tab.EVENT_CHANGE,
action: () => {
const v = this.dateTab.getSelect();
let date;
switch (v) {
case DynamicDateCombo.Static:
date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this._setInnerValue();
break;
case DynamicDateCombo.Dynamic:
default:
if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
});
}
this._setInnerValue();
break;
}
this._setInnerValue();
break;
}
},
}],
},
}
],
};
}
@ -212,7 +256,7 @@ export class DynamicDatePopup extends Widget {
_checkTodayValid() {
const o = this.options;
const today = getDate();
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}

156
src/widget/dynamicdate/dynamicdate.trigger.js

@ -1,13 +1,32 @@
import { shortcut, i18nText, createWidget, isKey, checkDateLegal, parseDateTime, bind, isNotNull, isNotEmptyString, isEqual, isEmptyObject, getDate, isEmptyString, isNull, each, checkDateVoid, print } from "@/core";
import { Trigger } from "@/base";
import { SignEditor } from "@/case";
import {
HTapeLayout,
AbsoluteLayout,
shortcut,
i18nText,
createWidget,
isKey,
checkDateLegal,
parseDateTime,
bind,
isNotNull,
isNotEmptyString,
isEqual,
isEmptyObject,
getDate,
isEmptyString,
isNull,
each,
checkDateVoid,
print
} from "@/core";
import { IconButton, Text, Trigger } from "@/base";
import { DynamicDateCombo } from "./dynamicdate.combo";
import { DynamicDateHelper } from "./dynamicdate.caculate";
@shortcut()
export class DynamicDateTrigger extends Trigger {
static xtype = "bi.dynamic_date_trigger"
static xtype = "bi.dynamic_date_trigger";
_const = {
hgap: 4,
@ -19,16 +38,16 @@ export class DynamicDateTrigger extends Trigger {
iconWidth: 24,
};
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_START = "EVENT_START"
static EVENT_STOP = "EVENT_STOP"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_START = "EVENT_START";
static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
props() {
return {
@ -49,21 +68,25 @@ export class DynamicDateTrigger extends Trigger {
c = this._const;
this.storeTriggerValue = "";
this.editor = createWidget({
type: "bi.sign_editor",
type: SignEditor.xtype,
simple: o.simple,
height: o.height,
validationChecker: v => {
const formatStr = this._getStandardDateStr(v);
const date = formatStr.match(/\d+/g);
!isKey(o.format) && this._autoAppend(v, date);
return this._dateCheck(formatStr) && checkDateLegal(formatStr) && this._checkVoid({
year: date[0] | 0,
month: date[1] | 0,
day: date[2] | 0,
});
return (
this._dateCheck(formatStr) &&
checkDateLegal(formatStr) &&
this._checkVoid({
year: date[0] | 0,
month: date[1] | 0,
day: date[2] | 0,
})
);
},
quitChecker () {
quitChecker() {
return false;
},
hgap: c.hgap,
@ -74,11 +97,14 @@ export class DynamicDateTrigger extends Trigger {
let str = "";
if (!isKey(o.format)) {
if (!this._dateCheck(v)) {
str = this.editor.isEditing() ? i18nText("BI-Date_Trigger_Error_Text") : i18nText("BI-Year_Trigger_Invalid_Text");
str = this.editor.isEditing()
? i18nText("BI-Date_Trigger_Error_Text")
: i18nText("BI-Year_Trigger_Invalid_Text");
} else {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
str = i18nText("BI-Basic_Date_Range_Error",
str = i18nText(
"BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
@ -144,34 +170,40 @@ export class DynamicDateTrigger extends Trigger {
this.fireEvent(DynamicDateTrigger.EVENT_CHANGE);
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
columnSize: ["", this._const.iconWidth],
items: [{
el: this.editor,
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
width: this._const.iconWidth,
},
width: this._const.iconWidth,
}],
});
!o.allowEdit && createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.text",
title: bind(this._getTitle, this),
items: [
{
el: this.editor,
},
left: 0,
right: o.iconWidth,
top: 0,
bottom: 0,
}],
{
el: {
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-font",
width: this._const.iconWidth,
},
width: this._const.iconWidth,
}
],
});
!o.allowEdit &&
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: Text.xtype,
title: bind(this._getTitle, this),
},
left: 0,
right: o.iconWidth,
top: 0,
bottom: 0,
}
],
});
this.setValue(o.value);
}
@ -189,15 +221,15 @@ export class DynamicDateTrigger extends Trigger {
date = getDate();
date = DynamicDateHelper.getCalculation(value);
dateStr = print(date, this._getFormatString());
return isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
return isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
case DynamicDateCombo.Static:
default:
if (isNull(value) || isNull(value.day)) {
return "";
}
return print(getDate(value.year, (value.month - 1), value.day), this._getFormatString());
return print(getDate(value.year, value.month - 1, value.day), this._getFormatString());
}
}
@ -248,10 +280,12 @@ export class DynamicDateTrigger extends Trigger {
}
_dateCheck(date) {
return print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
return (
print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
);
}
_checkVoid(obj) {
@ -280,16 +314,20 @@ export class DynamicDateTrigger extends Trigger {
_yearCheck(v) {
const date = print(parseDateTime(v, this._getFormatString()), this._const.compareFormat);
return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
}
_monthCheck(v) {
const date = parseDateTime(v, this._getFormatString());
const dateStr = print(date, this._const.compareFormat);
return (date.getMonth() >= 0 && (print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v ||
print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max;
return (
date.getMonth() >= 0 &&
(print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v || print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v) &&
dateStr >= this.options.min &&
dateStr <= this.options.max
);
}
_setInnerValue(date) {
@ -322,7 +360,7 @@ export class DynamicDateTrigger extends Trigger {
this.editor.setState("");
this.editor.setValue("");
} else {
const dateStr = print(getDate(value.year, (value.month - 1), value.day), this._getFormatString());
const dateStr = print(getDate(value.year, value.month - 1, value.day), this._getFormatString());
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
}

480
src/widget/dynamicdatetime/dynamicdatetime.combo.js

@ -1,15 +1,27 @@
import { shortcut, getDate, toPix, isEqual, isNotEmptyString, isEmptyString, isNotNull, isNotEmptyObject, checkDateVoid } from "@/core";
import { Single, Combo } from "@/base";
import {
AbsoluteLayout,
HorizontalFillLayout,
shortcut,
getDate,
toPix,
isEqual,
isNotEmptyString,
isEmptyString,
isNotNull,
isNotEmptyObject,
checkDateVoid
} from "@/core";
import { Combo, IconButton, Single } from "@/base";
import { DynamicDateTimeTrigger } from "./dynamicdatetime.trigger";
import { DynamicDateTimePopup } from "./dynamicdatetime.popup";
import { DynamicDateCombo } from "../dynamicdate";
@shortcut()
export class DynamicDateTimeCombo extends Single {
static xtype = "bi.dynamic_date_time_combo"
static xtype = "bi.dynamic_date_time_combo";
static Static = 1
static Dynamic = 2
static Static = 1;
static Dynamic = 2;
constants = {
popupHeight: 259,
@ -17,7 +29,7 @@ export class DynamicDateTimeCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
}
};
props = {
baseCls: "bi-dynamic-date--time-combo",
@ -34,16 +46,15 @@ export class DynamicDateTimeCombo extends Single {
isNeedAdjustWidth: false,
};
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_init() {
super._init(...arguments);
@ -57,208 +68,231 @@ export class DynamicDateTimeCombo extends Single {
const border = opts.simple ? 1 : 2;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
destroyWhenHide: true,
container: opts.container,
ref: _ref => {
this.combo = _ref;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: "bi.horizontal_fill",
columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
items: [{
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth,
height: toPix(opts.height, border),
ref: _ref => {
this.changeIcon = _ref;
},
},
}, {
type: "bi.dynamic_date_time_trigger",
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
iconWidth: this.constants.iconWidth,
type: Combo.xtype,
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
destroyWhenHide: true,
container: opts.container,
ref: (_ref) => {
this.combo = _ref;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: HorizontalFillLayout.xtype,
columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
value: opts.value,
ref: _ref => {
this.trigger = _ref;
},
listeners: [{
eventName: DynamicDateTimeTrigger.EVENT_KEY_DOWN,
action: (...args) => {
if (this.combo.isViewVisible()) {
this.combo.hideView();
}
this.fireEvent(DynamicDateTimeCombo.EVENT_KEY_DOWN, ...args);
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_STOP,
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
action: () => {
this.combo.toggle();
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_FOCUS,
action: () => {
this.storeTriggerValue = this.trigger.getKey();
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
this.fireEvent(DynamicDateTimeCombo.EVENT_FOCUS);
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_BLUR,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BLUR);
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_ERROR,
action: () => {
this.storeValue = {
type: DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
items: [
{
el: {
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth,
height: toPix(opts.height, border),
ref: (_ref) => {
this.changeIcon = _ref;
},
};
this.combo.element.addClass("error");
this.fireEvent(DynamicDateTimeCombo.EVENT_ERROR);
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_VALID,
action: () => {
this.storeValue = this.trigger.getValue();
this.combo.element.removeClass("error");
this.fireEvent(DynamicDateTimeCombo.EVENT_VALID);
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_CHANGE);
},
},
}, {
eventName: DynamicDateTimeTrigger.EVENT_CONFIRM,
action: () => {
const dateStore = this.storeTriggerValue;
const dateObj = this.trigger.getKey();
if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
return;
}
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
this.storeValue = this.trigger.getValue();
this.setValue(this.trigger.getValue());
} else if (isEmptyString(dateObj)) {
this.storeValue = null;
this.trigger.setValue();
}
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
}],
}],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: "bi.dynamic_date_time_popup",
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: _ref => {
this.popup = _ref;
},
listeners: [{
eventName: DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
}, {
eventName: DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({
type: DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: 0,
minute: 0,
second: 0,
{
type: DynamicDateTimeTrigger.xtype,
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
allowEdit: opts.allowEdit,
watermark: opts.watermark,
format: opts.format,
iconWidth: this.constants.iconWidth,
height: toPix(opts.height, border),
value: opts.value,
ref: (_ref) => {
this.trigger = _ref;
},
listeners: [
{
eventName: DynamicDateTimeTrigger.EVENT_KEY_DOWN,
action: (...args) => {
if (this.combo.isViewVisible()) {
this.combo.hideView();
}
this.fireEvent(DynamicDateTimeCombo.EVENT_KEY_DOWN, ...args);
},
},
});
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
}, {
eventName: DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
if (this._checkValue(value)) {
this.setValue(value);
}
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
{
eventName: DynamicDateTimeTrigger.EVENT_STOP,
action: () => {
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
action: () => {
this.combo.toggle();
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_FOCUS,
action: () => {
this.storeTriggerValue = this.trigger.getKey();
if (!this.combo.isViewVisible()) {
this.combo.showView();
}
this.fireEvent(DynamicDateTimeCombo.EVENT_FOCUS);
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_BLUR,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BLUR);
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_ERROR,
action: () => {
this.storeValue = {
type: DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
},
};
this.combo.element.addClass("error");
this.fireEvent(DynamicDateTimeCombo.EVENT_ERROR);
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_VALID,
action: () => {
this.storeValue = this.trigger.getValue();
this.combo.element.removeClass("error");
this.fireEvent(DynamicDateTimeCombo.EVENT_VALID);
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_CHANGE);
},
},
{
eventName: DynamicDateTimeTrigger.EVENT_CONFIRM,
action: () => {
const dateStore = this.storeTriggerValue;
const dateObj = this.trigger.getKey();
if (this.combo.isViewVisible() || isEqual(dateObj, dateStore)) {
return;
}
if (isNotEmptyString(dateObj) && !isEqual(dateObj, dateStore)) {
this.storeValue = this.trigger.getValue();
this.setValue(this.trigger.getValue());
} else if (isEmptyString(dateObj)) {
this.storeValue = null;
this.trigger.setValue();
}
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
],
},
}, {
eventName: DynamicDateTimePopup.EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: DynamicDateTimePopup.xtype,
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: (_ref) => {
this.popup = _ref;
},
}, {
eventName: DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
listeners: [
{
eventName: DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
action: () => {
this.setValue();
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
action: () => {
const date = getDate();
this.setValue({
type: DynamicDateTimeCombo.Static,
value: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
hour: 0,
minute: 0,
second: 0,
},
});
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
if (this._checkValue(value)) {
this.setValue(value);
}
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDateTimePopup.EVENT_CHANGE,
action: () => {
this.setValue(this.popup.getValue());
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
},
{
eventName: DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
},
],
},
},
listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
this.popup.setMinDate(opts.minDate);
this.popup.setMaxDate(opts.maxDate);
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
},
},
],
// // DEC-4250 和复选下拉一样,点击不收起
// hideChecker: function (e) {
// return self.triggerBtn.element.find(e.target).length === 0;
// }
},
listeners: [{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setMinDate(opts.minDate);
this.popup.setMaxDate(opts.maxDate);
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
// // DEC-4250 和复选下拉一样,点击不收起
// hideChecker: function (e) {
// return self.triggerBtn.element.find(e.target).length === 0;
// }
top: 0,
left: 0,
right: 0,
bottom: 0,
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}],
],
};
}
@ -272,16 +306,16 @@ export class DynamicDateTimeCombo extends Single {
type = v.type;
}
switch (type) {
case DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
case DynamicDateTimeCombo.Dynamic:
this.changeIcon.setVisible(true);
// this.comboWrapper.attr("items")[0].width = o.height - (this.options.simple ? 1 : 2);
// this.comboWrapper.resize();
break;
default:
// this.comboWrapper.attr("items")[0].width = 0;
// this.comboWrapper.resize();
this.changeIcon.setVisible(false);
break;
}
}
@ -289,12 +323,12 @@ export class DynamicDateTimeCombo extends Single {
const o = this.options;
const value = v.value || {};
switch (v.type) {
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
case DynamicDateCombo.Dynamic:
return isNotEmptyObject(v.value);
case DynamicDateCombo.Static:
return !checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0];
default:
return true;
}
}

320
src/widget/dynamicdatetime/dynamicdatetime.popup.js

@ -1,17 +1,35 @@
import { shortcut, Widget, createWidget, toPix, i18nText, createItems, print, isNull, isEmptyObject, isEmptyString, getDate, checkDateVoid, extend } from "@/core";
import { DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
import {
VerticalLayout,
GridLayout,
shortcut,
Widget,
createWidget,
toPix,
i18nText,
createItems,
print,
isNull,
isEmptyObject,
isEmptyString,
getDate,
checkDateVoid,
extend
} from "@/core";
import { TextButton, Tab } from "@/base";
import { LinearSegment } from "@/case";
import { DynamicDateCard, DynamicDateCombo, DynamicDateHelper } from "../dynamicdate";
import { DateCalendarPopup } from "../date/calendar";
import { DynamicDateTimeSelect } from "./dynamicdatetime.timeselect";
import { DynamicDateTimeCombo } from "./dynamicdatetime.combo";
@shortcut()
export class DynamicDateTimePopup extends Widget {
static xtype = "bi.dynamic_date_time_popup"
static xtype = "bi.dynamic_date_time_popup";
constants = {
tabHeight: 40,
buttonHeight: 24,
}
};
props = {
baseCls: "bi-dynamic-date-time-popup",
@ -19,11 +37,11 @@ export class DynamicDateTimePopup extends Widget {
supportDynamic: true,
};
static EVENT_CHANGE = "EVENT_CHANGE"
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"
static EVENT_CHANGE = "EVENT_CHANGE";
static BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
static BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
static BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
_init() {
super._init(...arguments);
@ -33,72 +51,86 @@ export class DynamicDateTimePopup extends Widget {
};
createWidget({
element: this,
type: "bi.vertical",
items: [{
el: this._getTabJson(),
}, {
el: {
type: "bi.grid",
items: [
[{
type: "bi.text_button",
cls: "bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Clear"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE);
type: VerticalLayout.xtype,
items: [
{
el: this._getTabJson(),
},
{
el: {
type: GridLayout.xtype,
items: [
[
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_Clear"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}
],
},
}],
}, {
type: "bi.text_button",
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(),
ref: _ref => {
this.todayButton = _ref;
},
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE);
{
type: TextButton.xtype,
cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(),
ref: _ref => {
this.todayButton = _ref;
},
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE);
},
}
],
},
}],
}, {
type: "bi.text_button",
cls: "bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
}
},
}],
}]
],
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
},
}],
{
type: TextButton.xtype,
cls: "bi-high-light bi-split-top",
textHeight: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 1),
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) &&
this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
} else {
this.fireEvent(DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
}
},
}
],
}
]
],
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
},
}
],
});
this.setValue(opts.value);
}
_getTabJson() {
const o = this.options;
return {
type: "bi.tab",
type: Tab.xtype,
logic: {
dynamic: true,
},
@ -106,32 +138,40 @@ export class DynamicDateTimePopup extends Widget {
this.dateTab = _ref;
},
tab: {
type: "bi.linear_segment",
type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: this.constants.tabHeight,
items: createItems([{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateCombo.Static,
}, {
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateCombo.Dynamic,
}], {
textAlign: "center",
}),
items: createItems(
[
{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateCombo.Static,
},
{
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateCombo.Dynamic,
}
],
{
textAlign: "center",
}
),
},
cardCreator: v => {
switch (v) {
case DynamicDateCombo.Dynamic:
return {
type: "bi.dynamic_date_card",
type: DynamicDateCard.xtype,
cls: "dynamic-date-pane",
listeners: [{
eventName: "EVENT_CHANGE",
action: () => {
this._setInnerValue(this.year, v);
},
}],
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this._setInnerValue(this.year, v);
},
}
],
ref: _ref => {
this.dynamicPane = _ref;
},
@ -141,63 +181,70 @@ export class DynamicDateTimePopup extends Widget {
case DynamicDateCombo.Static:
default:
return {
type: "bi.vertical",
items: [{
type: "bi.date_calendar_popup",
behaviors: o.behaviors,
min: this.options.min,
max: this.options.max,
ref: _ref => {
this.ymd = _ref;
},
listeners: [{
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}],
}, {
el: {
type: "bi.dynamic_date_time_select",
cls: "bi-split-top",
type: VerticalLayout.xtype,
items: [
{
type: DateCalendarPopup.xtype,
behaviors: o.behaviors,
min: this.options.min,
max: this.options.max,
ref: _ref => {
this.timeSelect = _ref;
this.ymd = _ref;
},
height: 40,
listeners: [
{
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}
],
},
}],
{
el: {
type: DynamicDateTimeSelect.xtype,
cls: "bi-split-top",
ref: _ref => {
this.timeSelect = _ref;
},
height: 40,
},
}
],
};
}
},
listeners: [{
eventName: Tab.EVENT_CHANGE,
action: () => {
const v = this.dateTab.getSelect();
const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
switch (v) {
case DynamicDateCombo.Static:
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this.timeSelect.setValue();
this._setInnerValue();
break;
case DynamicDateCombo.Dynamic:
default:
if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
listeners: [
{
eventName: Tab.EVENT_CHANGE,
action: () => {
const v = this.dateTab.getSelect();
const date = DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
switch (v) {
case DynamicDateCombo.Static:
this.ymd.setValue({
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
});
this.timeSelect.setValue();
this._setInnerValue();
break;
case DynamicDateCombo.Dynamic:
default:
if (this.storeValue && this.storeValue.type === DynamicDateCombo.Dynamic) {
this.dynamicPane.setValue(this.storeValue.value);
} else {
this.dynamicPane.setValue({
year: 0,
});
}
this._setInnerValue();
break;
}
this._setInnerValue();
break;
}
},
}],
},
}
],
};
}
@ -220,7 +267,7 @@ export class DynamicDateTimePopup extends Widget {
_checkTodayValid() {
const o = this.options;
const today = getDate();
return !!checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0];
}
@ -276,10 +323,13 @@ export class DynamicDateTimePopup extends Widget {
getValue() {
const type = this.dateTab.getSelect();
return {
type,
value: type === DynamicDateTimeCombo.Static ? extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue(),
value:
type === DynamicDateTimeCombo.Static
? extend(this.ymd.getValue(), this.timeSelect.getValue())
: this.dynamicPane.getValue(),
};
}
}

249
src/widget/dynamicdatetime/dynamicdatetime.timeselect.js

@ -1,15 +1,28 @@
import { shortcut, Widget, isNaturalNumber, parseInt, isNumeric, i18nText, isNull, isEmptyString } from "@/core";
import {
CenterAdaptLayout,
VerticalAdaptLayout,
shortcut,
Widget,
isNaturalNumber,
parseInt,
isNumeric,
i18nText,
isNull,
isEmptyString
} from "@/core";
import { NumberEditor } from "../numbereditor/number.editor";
import { Label } from "@/base";
import { SignEditor } from "@/case";
@shortcut()
export class DynamicDateTimeSelect extends Widget {
static xtype = "bi.dynamic_date_time_select"
static xtype = "bi.dynamic_date_time_select";
static HOUR = 1
static MINUTE = 2
static SECOND = 3
static HOUR = 1;
static MINUTE = 2;
static SECOND = 3;
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CONFIRM = "EVENT_CONFIRM";
props = {
baseCls: "bi-date-time-select",
@ -17,111 +30,133 @@ export class DynamicDateTimeSelect extends Widget {
render() {
return {
type: "bi.center_adapt",
items: [{
type: "bi.vertical_adapt",
items: [{
el: {
type: "bi.number_editor",
ref: _ref => {
this.hour = _ref;
},
validationChecker (v) {
return isNaturalNumber(v) && parseInt(v) < 24;
type: CenterAdaptLayout.xtype,
items: [
{
type: VerticalAdaptLayout.xtype,
items: [
{
el: {
type: NumberEditor.xtype,
ref: _ref => {
this.hour = _ref;
},
validationChecker(v) {
return isNaturalNumber(v) && parseInt(v) < 24;
},
errorText(v) {
if (isNumeric(v)) {
return i18nText("BI-Basic_Input_From_To_Number", "\"00-23\"");
}
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.hour.getValue();
this._checkHour(value);
this.hour.setValue(this._formatValueToDoubleDigit(value));
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
},
},
{
eventName: SignEditor.EVENT_CHANGE,
action: () => {
const value = this._autoSwitch(
this.hour.getValue(),
DynamicDateTimeSelect.HOUR
);
this.hour.setValue(value);
},
}
],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
},
errorText (v) {
if (isNumeric(v)) {
return i18nText("BI-Basic_Input_From_To_Number", "\"00-23\"");
}
return i18nText("BI-Numerical_Interval_Input_Data");
{
type: Label.xtype,
text: ":",
width: 20,
},
listeners: [{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.hour.getValue();
this._checkHour(value);
this.hour.setValue(this._formatValueToDoubleDigit(value));
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
{
type: NumberEditor.xtype,
ref: _ref => {
this.minute = _ref;
},
}, {
eventName: SignEditor.EVENT_CHANGE,
action: () => {
const value = this._autoSwitch(this.hour.getValue(), DynamicDateTimeSelect.HOUR);
this.hour.setValue(value);
validationChecker(v) {
return isNaturalNumber(v) && parseInt(v) < 60;
},
}],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
}, {
type: "bi.label",
text: ":",
width: 20,
}, {
type: "bi.number_editor",
ref: _ref => {
this.minute = _ref;
},
validationChecker (v) {
return isNaturalNumber(v) && parseInt(v) < 60;
},
errorText (v) {
if (isNumeric(v)) {
return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
}
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.minute.getValue();
this._checkMinute(value);
this.minute.setValue(this._formatValueToDoubleDigit(value), DynamicDateTimeSelect.MINUTE);
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
errorText(v) {
if (isNumeric(v)) {
return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
}
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.minute.getValue();
this._checkMinute(value);
this.minute.setValue(
this._formatValueToDoubleDigit(value),
DynamicDateTimeSelect.MINUTE
);
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
},
},
{
eventName: SignEditor.EVENT_CHANGE,
action: () => {
const value = this._autoSwitch(this.getValue(), DynamicDateTimeSelect.MINUTE);
this.minute.setValue(value);
},
}
],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
}, {
eventName: SignEditor.EVENT_CHANGE,
action: () => {
const value = this._autoSwitch(this.getValue(), DynamicDateTimeSelect.MINUTE);
this.minute.setValue(value);
{
type: Label.xtype,
text: ":",
width: 20,
},
}],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}, {
type: "bi.label",
text: ":",
width: 20,
}, {
type: "bi.number_editor",
ref: _ref => {
this.second = _ref;
},
validationChecker (v) {
return isNaturalNumber(v) && parseInt(v) < 60;
},
errorText (v) {
if (isNumeric(v)) {
return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
{
type: NumberEditor.xtype,
ref: _ref => {
this.second = _ref;
},
validationChecker(v) {
return isNaturalNumber(v) && parseInt(v) < 60;
},
errorText(v) {
if (isNumeric(v)) {
return i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
}
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.second.getValue();
this._checkSecond(value);
this.second.setValue(this._formatValueToDoubleDigit(value));
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
},
}
],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.second.getValue();
this._checkSecond(value);
this.second.setValue(this._formatValueToDoubleDigit(value));
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
},
}],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}],
}],
],
}
],
};
}
@ -176,7 +211,7 @@ export class DynamicDateTimeSelect extends Widget {
break;
}
}
return value;
}
@ -188,7 +223,7 @@ export class DynamicDateTimeSelect extends Widget {
if (value < 10) {
value = `0${value}`;
}
return value;
}
@ -197,7 +232,7 @@ export class DynamicDateTimeSelect extends Widget {
v.hour = this._formatValueToDoubleDigit(v.hour) || "00";
v.minute = this._formatValueToDoubleDigit(v.minute) || "00";
v.second = this._formatValueToDoubleDigit(v.second) || "00";
return v;
}

211
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -1,11 +1,34 @@
import { shortcut, i18nText, createWidget, isKey, checkDateLegal, parseDateTime, bind, isNotNull, isNotEmptyString, isEqual, isEmptyObject, isEmptyString, isNull, getDate, each, isNumeric, checkDateVoid, parseInt, size, print } from "@/core";
import { Trigger } from "@/base";
import { SignEditor } from "@/case";
import {
HTapeLayout,
AbsoluteLayout,
shortcut,
i18nText,
createWidget,
isKey,
checkDateLegal,
parseDateTime,
bind,
isNotNull,
isNotEmptyString,
isEqual,
isEmptyObject,
isEmptyString,
isNull,
getDate,
each,
isNumeric,
checkDateVoid,
parseInt,
size,
print
} from "@/core";
import { IconButton, Text, Trigger } from "@/base";
import { DynamicDateCombo, DynamicDateCard, DynamicDateHelper } from "../dynamicdate";
@shortcut()
export class DynamicDateTimeTrigger extends Trigger {
static xtype = "bi.dynamic_date_time_trigger"
static xtype = "bi.dynamic_date_time_trigger";
_const = {
hgap: 4,
@ -17,16 +40,16 @@ export class DynamicDateTimeTrigger extends Trigger {
iconWidth: 24,
};
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_START = "EVENT_START"
static EVENT_STOP = "EVENT_STOP"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_START = "EVENT_START";
static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
props() {
return {
@ -47,21 +70,25 @@ export class DynamicDateTimeTrigger extends Trigger {
c = this._const;
this.storeTriggerValue = "";
this.editor = createWidget({
type: "bi.sign_editor",
type: SignEditor.xtype,
simple: o.simple,
height: o.height,
validationChecker: v => {
const formatStr = this._getStandardDateStr(v);
const date = formatStr.match(/\d+/g);
!isKey(o.format) && this._autoAppend(v, date);
return this._dateCheck(formatStr) && checkDateLegal(formatStr) && this._checkVoid({
year: date[0] | 0,
month: date[1] | 0,
day: date[2] | 0,
});
return (
this._dateCheck(formatStr) &&
checkDateLegal(formatStr) &&
this._checkVoid({
year: date[0] | 0,
month: date[1] | 0,
day: date[2] | 0,
})
);
},
quitChecker () {
quitChecker() {
return false;
},
hgap: c.hgap,
@ -72,11 +99,14 @@ export class DynamicDateTimeTrigger extends Trigger {
let str = "";
if (!isKey(o.format)) {
if (!this._dateCheck(v)) {
str = this.editor.isEditing() ? i18nText("BI-Date_Trigger_Error_Text") : i18nText("BI-Year_Trigger_Invalid_Text");
str = this.editor.isEditing()
? i18nText("BI-Date_Trigger_Error_Text")
: i18nText("BI-Year_Trigger_Invalid_Text");
} else {
const start = parseDateTime(o.min, "%Y-%X-%d");
const end = parseDateTime(o.max, "%Y-%X-%d");
str = i18nText("BI-Basic_Date_Range_Error",
str = i18nText(
"BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
@ -140,34 +170,40 @@ export class DynamicDateTimeTrigger extends Trigger {
this.fireEvent(DynamicDateTimeTrigger.EVENT_CHANGE);
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
columnSize: ["", this._const.iconWidth],
items: [{
el: this.editor,
}, {
el: {
type: "bi.icon_button",
cls: "bi-trigger-icon-button date-font",
items: [
{
el: this.editor,
},
width: o.iconWidth,
}],
{
el: {
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-font",
},
width: o.iconWidth,
}
],
});
!o.allowEdit && createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.text",
title: bind(this._getTitle, this),
},
left: 0,
right: o.iconWidth,
top: 0,
bottom: 0,
}],
});
!o.allowEdit &&
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: Text.xtype,
title: bind(this._getTitle, this),
},
left: 0,
right: o.iconWidth,
top: 0,
bottom: 0,
}
],
});
this.setValue(o.value);
}
@ -185,15 +221,24 @@ export class DynamicDateTimeTrigger extends Trigger {
switch (type) {
case DynamicDateCombo.Dynamic:
return isEmptyString(text) ? dateStr : (`${text}:${dateStr}`);
return isEmptyString(text) ? dateStr : `${text}:${dateStr}`;
case DynamicDateCombo.Static:
default:
if (isNull(value) || isNull(value.day)) {
return "";
}
return print(getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
value.second || 0), this._getFormatString());
return print(
getDate(
value.year,
value.month - 1,
value.day,
value.hour || 0,
value.minute || 0,
value.second || 0
),
this._getFormatString()
);
}
}
@ -251,7 +296,7 @@ export class DynamicDateTimeTrigger extends Trigger {
if (isNotEmptyString(suffixString)) {
dateString += ` ${suffixString}`;
}
return dateString;
}
@ -260,15 +305,16 @@ export class DynamicDateTimeTrigger extends Trigger {
}
_dateCheck(date) {
return print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
return (
print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date
);
}
_checkVoid(obj) {
@ -297,16 +343,20 @@ export class DynamicDateTimeTrigger extends Trigger {
_yearCheck(v) {
const date = print(parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
return print(parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
}
_monthCheck(v) {
const date = parseDateTime(v, "%Y-%X-%d");
const dateStr = print(date, "%Y-%X-%d");
return (date.getMonth() > 0 && (print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v ||
print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max;
return (
date.getMonth() > 0 &&
(print(parseDateTime(v, "%Y-%X"), "%Y-%X") === v || print(parseDateTime(v, "%Y-%x"), "%Y-%x") === v) &&
dateStr >= this.options.min &&
dateStr <= this.options.max
);
}
_setInnerValue(date) {
@ -320,38 +370,56 @@ export class DynamicDateTimeTrigger extends Trigger {
let endText = "";
if (isNotNull(obj.year)) {
if (parseInt(obj.year) !== 0) {
value += Math.abs(obj.year) + i18nText("BI-Basic_Year") + (obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.year) +
i18nText("BI-Basic_Year") +
(obj.year < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Year"), obj.position);
}
if (isNotNull(obj.quarter)) {
if (parseInt(obj.quarter) !== 0) {
value += Math.abs(obj.quarter) + i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.quarter) +
i18nText("BI-Basic_Single_Quarter") +
(obj.quarter < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Single_Quarter"), obj.position);
}
if (isNotNull(obj.month)) {
if (parseInt(obj.month) !== 0) {
value += Math.abs(obj.month) + i18nText("BI-Basic_Month") + (obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.month) +
i18nText("BI-Basic_Month") +
(obj.month < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Month"), obj.position);
}
if (isNotNull(obj.week)) {
if (parseInt(obj.week) !== 0) {
value += Math.abs(obj.week) + i18nText("BI-Basic_Week") + (obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.week) +
i18nText("BI-Basic_Week") +
(obj.week < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = getPositionText(i18nText("BI-Basic_Week"), obj.position);
}
if (isNotNull(obj.day)) {
if (parseInt(obj.day) !== 0) {
value += Math.abs(obj.day) + i18nText("BI-Basic_Day") + (obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.day) +
i18nText("BI-Basic_Day") +
(obj.day < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
endText = size(obj) === 1 ? getPositionText(i18nText("BI-Basic_Month"), obj.position) : "";
}
if (isNotNull(obj.workDay) && parseInt(obj.workDay) !== 0) {
value += Math.abs(obj.workDay) + i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
value +=
Math.abs(obj.workDay) +
i18nText("BI-Basic_Work_Day") +
(obj.workDay < 0 ? i18nText("BI-Basic_Front") : i18nText("BI-Basic_Behind"));
}
return value + endText;
function getPositionText(baseText, position) {
@ -400,8 +468,17 @@ export class DynamicDateTimeTrigger extends Trigger {
this.editor.setState("");
this.editor.setValue("");
} else {
const dateStr = print(getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
value.second || 0), this._getFormatString());
const dateStr = print(
getDate(
value.year,
value.month - 1,
value.day,
value.hour || 0,
value.minute || 0,
value.second || 0
),
this._getFormatString()
);
this.editor.setState(dateStr);
this.editor.setValue(dateStr);
}

93
src/widget/editor/editor.search.js

@ -1,35 +1,50 @@
import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, toPix, isKey, Controller, Events, HTapeLayout, isEndWithBlank } from "@/core";
import {
shortcut,
Widget,
extend,
i18nText,
emptyFn,
createWidget,
toPix,
isKey,
Controller,
Events,
HTapeLayout,
isEndWithBlank
} from "@/core";
import { IconButton, Editor, IconLabel } from "@/base";
@shortcut()
export class SearchEditor extends Widget {
static xtype = "bi.search_editor"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_CLICK = "EVENT_CLICK"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_SPACE = "EVENT_SPACE"
static EVENT_BACKSPACE = "EVENT_BACKSPACE"
static EVENT_CLEAR = "EVENT_CLEAR"
static EVENT_START = "EVENT_START"
static EVENT_PAUSE = "EVENT_PAUSE"
static EVENT_STOP = "EVENT_STOP"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_ENTER = "EVENT_ENTER"
static EVENT_RESTRICT = "EVENT_RESTRICT"
static EVENT_REMOVE = "EVENT_REMOVE"
static EVENT_EMPTY = "EVENT_EMPTY"
static xtype = "bi.search_editor";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_SPACE = "EVENT_SPACE";
static EVENT_BACKSPACE = "EVENT_BACKSPACE";
static EVENT_CLEAR = "EVENT_CLEAR";
static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_REMOVE = "EVENT_REMOVE";
static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `bi-search-editor bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
baseCls: `bi-search-editor bi-focus-shadow ${
config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
}`,
height: 24,
errorText: "",
watermark: i18nText("BI-Basic_Search"),
@ -72,20 +87,21 @@ export class SearchEditor extends Widget {
element: this,
height: toPix(o.height, o.simple ? 1 : 2),
type: HTapeLayout.xtype,
items: [{
el: {
type: IconLabel.xtype,
cls: "search-font",
items: [
{
el: {
type: IconLabel.xtype,
cls: "search-font",
},
width: 24,
},
{
el: this.editor,
},
width: 24,
},
{
el: this.editor,
},
{
el: this.clear,
width: 24,
}
{
el: this.clear,
width: 24,
}
],
});
this.editor.on(Controller.EVENT_CHANGE, (...args) => {
@ -115,7 +131,6 @@ export class SearchEditor extends Widget {
this.fireEvent(SearchEditor.EVENT_BACKSPACE);
});
this.editor.on(Editor.EVENT_VALID, () => {
this.fireEvent(SearchEditor.EVENT_VALID);
});
@ -185,7 +200,7 @@ export class SearchEditor extends Widget {
if (isEndWithBlank(val)) {
return keywords.concat([" "]);
}
return keywords;
}

4
src/widget/editor/editor.search.small.js

@ -3,11 +3,11 @@ import { SearchEditor } from "./editor.search";
@shortcut()
export class SmallSearchEditor extends SearchEditor {
static xtype = "bi.small_search_editor"
static xtype = "bi.small_search_editor";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-small-search-editor`,
height: 20,

41
src/widget/editor/editor.text.js

@ -3,30 +3,30 @@ import { Editor } from "@/base";
@shortcut()
export class TextEditor extends Widget {
static xtype = "bi.text_editor"
static xtype = "bi.text_editor";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_CLICK = "EVENT_CLICK"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_SPACE = "EVENT_SPACE"
static EVENT_BACKSPACE = "EVENT_BACKSPACE"
static EVENT_START = "EVENT_START"
static EVENT_PAUSE = "EVENT_PAUSE"
static EVENT_STOP = "EVENT_STOP"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_ENTER = "EVENT_ENTER"
static EVENT_RESTRICT = "EVENT_RESTRICT"
static EVENT_REMOVE = "EVENT_REMOVE"
static EVENT_EMPTY = "EVENT_EMPTY"
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_SPACE = "EVENT_SPACE";
static EVENT_BACKSPACE = "EVENT_BACKSPACE";
static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_REMOVE = "EVENT_REMOVE";
static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: `bi-text-editor bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border"}`,
hgap: 4,
@ -97,7 +97,6 @@ export class TextEditor extends Widget {
this.fireEvent(TextEditor.EVENT_BACKSPACE);
});
this.editor.on(Editor.EVENT_VALID, () => {
this.element.removeClass("error");
this.fireEvent(TextEditor.EVENT_VALID);

4
src/widget/editor/editor.text.small.js

@ -3,11 +3,11 @@ import { TextEditor } from "./editor.text";
@shortcut()
export class SmallTextEditor extends TextEditor {
static xtype = "bi.small_text_editor"
static xtype = "bi.small_text_editor";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-small-text-editor`,
height: 20,

4
src/widget/intervalslider/index.js

@ -1,2 +1,2 @@
export { AccurateCalculationModel } from "./model.accuratecalculation";
export { IntervalSlider } from "./intervalslider";
export { AccurateCalculationModel } from "./model.accuratecalculation";
export { IntervalSlider } from "./intervalslider";

151
src/widget/intervalslider/intervalslider.js

@ -1,4 +1,6 @@
import {
VerticalFillLayout,
HorizontalLayout,
shortcut,
createWidget,
toPix,
@ -32,7 +34,7 @@ export class IntervalSlider extends Single {
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24,
}
};
props = {
baseCls: "bi-interval-slider bi-slider-track",
digit: false,
@ -84,9 +86,7 @@ export class IntervalSlider extends Single {
});
this.labelOne.element.hover(
() => {
this.labelOne.element
.removeClass("bi-border")
.addClass("bi-border");
this.labelOne.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.labelOne.element.removeClass("bi-border");
@ -100,12 +100,7 @@ export class IntervalSlider extends Single {
const significantPercent = parseFloat(percent.toFixed(1)); // 分成1000份
this._setSliderOnePosition(significantPercent);
this._setBlueTrack();
this._checkLabelPosition(
oldValueOne,
this.valueTwo,
this.valueOne,
this.valueTwo
);
this._checkLabelPosition(oldValueOne, this.valueTwo, this.valueOne, this.valueTwo);
this.fireEvent(IntervalSlider.EVENT_CHANGE);
});
@ -120,9 +115,7 @@ export class IntervalSlider extends Single {
});
this.labelTwo.element.hover(
() => {
this.labelTwo.element
.removeClass("bi-border")
.addClass("bi-border");
this.labelTwo.element.removeClass("bi-border").addClass("bi-border");
},
() => {
this.labelTwo.element.removeClass("bi-border");
@ -136,12 +129,7 @@ export class IntervalSlider extends Single {
const significantPercent = parseFloat(percent.toFixed(1));
this._setSliderTwoPosition(significantPercent);
this._setBlueTrack();
this._checkLabelPosition(
this.valueOne,
oldValueTwo,
this.valueOne,
this.valueTwo
);
this._checkLabelPosition(this.valueOne, oldValueTwo, this.valueOne, this.valueTwo);
this.fireEvent(IntervalSlider.EVENT_CHANGE);
});
@ -156,7 +144,7 @@ export class IntervalSlider extends Single {
this._setVisible(false);
return {
type: "bi.vertical_fill",
type: VerticalFillLayout.xtype,
rowSize: [30, 30],
items: [
this._createLabelWrapper(),
@ -165,7 +153,7 @@ export class IntervalSlider extends Single {
items: [
{
el: {
type: "bi.horizontal",
type: HorizontalLayout.xtype,
horizontalAlign: "stretch",
verticalAlign: "middle",
columnSize: ["fill"],
@ -198,22 +186,12 @@ export class IntervalSlider extends Single {
this._setSliderOnePosition(significantPercent);
this.labelOne.setValue(v);
this.valueOne = v;
this._checkLabelPosition(
oldValueOne,
oldValueTwo,
v,
this.valueTwo
);
this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo);
} else {
this._setSliderTwoPosition(significantPercent);
this.labelTwo.setValue(v);
this.valueTwo = v;
this._checkLabelPosition(
oldValueOne,
oldValueTwo,
this.valueOne,
v
);
this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v);
}
this._setBlueTrack();
}
@ -221,9 +199,7 @@ export class IntervalSlider extends Single {
_rePosBySizeAfterStop(size, isLeft) {
const percent = (size * 100) / this._getGrayTrackLength();
const significantPercent = parseFloat(percent.toFixed(1));
isLeft
? this._setSliderOnePosition(significantPercent)
: this._setSliderTwoPosition(significantPercent);
isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
}
_draggable(widget, isLeft) {
@ -232,7 +208,7 @@ export class IntervalSlider extends Single {
offset = 0,
defaultSize = 0;
const mouseMoveTracker = new MouseMoveTracker(
(deltaX => {
deltaX => {
if (mouseMoveTracker.isDragging()) {
startDrag = true;
offset += deltaX;
@ -240,8 +216,8 @@ export class IntervalSlider extends Single {
widget.element.addClass("dragging");
this._rePosBySizeAfterMove(size, isLeft);
}
}),
(() => {
},
() => {
if (startDrag === true) {
size = optimizeSize(size);
this._rePosBySizeAfterStop(size, isLeft);
@ -253,7 +229,7 @@ export class IntervalSlider extends Single {
widget.element.removeClass("dragging");
mouseMoveTracker.releaseMouseMoves();
this.fireEvent(IntervalSlider.EVENT_CHANGE);
}),
},
window
);
widget.element.on("mousedown", function (event) {
@ -270,7 +246,7 @@ export class IntervalSlider extends Single {
_createLabelWrapper() {
const c = this._constant;
return {
el: {
type: VerticalLayout.xtype,
@ -308,7 +284,7 @@ export class IntervalSlider extends Single {
_createSliderWrapper() {
return {
el: {
type: "bi.horizontal",
type: HorizontalLayout.xtype,
horizontalAlign: "stretch",
verticalAlign: "middle",
items: [
@ -340,7 +316,7 @@ export class IntervalSlider extends Single {
_createTrackWrapper() {
return createWidget({
type: "bi.horizontal",
type: HorizontalLayout.xtype,
cls: "track-wrapper",
horizontalAlign: "stretch",
verticalAlign: "middle",
@ -375,7 +351,7 @@ export class IntervalSlider extends Single {
const o = this.options;
let valid = false;
// 像90.这样的既不属于整数又不属于小数,是不合法的值
let dotText = (`${v}`).split(".")[1];
let dotText = `${v}`.split(".")[1];
// eslint-disable-next-line no-empty
if (isEmptyString(dotText)) {
} else {
@ -390,7 +366,7 @@ export class IntervalSlider extends Single {
}
}
}
return valid;
}
@ -421,9 +397,7 @@ export class IntervalSlider extends Single {
(oldValueOne <= oldValueTwo && valueOne > valueTwo) ||
(oldValueOne >= oldValueTwo && valueOne < valueTwo)
) {
const isSliderOneLeft =
parseFloat(this.labelOne.getValue()) <
parseFloat(this.labelTwo.getValue());
const isSliderOneLeft = parseFloat(this.labelOne.getValue()) < parseFloat(this.labelTwo.getValue());
this._resetLabelPosition(!isSliderOneLeft);
}
}
@ -475,11 +449,7 @@ export class IntervalSlider extends Single {
}
_setErrorText() {
const errorText = i18nText(
"BI-Basic_Please_Enter_Number_Between",
this.min,
this.max
);
const errorText = i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max);
this.labelOne.setErrorText(errorText);
this.labelTwo.setErrorText(errorText);
}
@ -500,27 +470,13 @@ export class IntervalSlider extends Single {
const mul = this.calculation.accurateMultiplication(sub, percent);
const div = this.calculation.accurateDivisionTenExponent(mul, 2);
if (this.precision < 0) {
const value = parseFloat(
this.calculation.accurateAddition(div, this.min)
);
const reduceValue = Math.round(
this.calculation.accurateDivisionTenExponent(
value,
-this.precision
)
);
return this.calculation.accurateMultiplication(
reduceValue,
Math.pow(10, -this.precision)
);
const value = parseFloat(this.calculation.accurateAddition(div, this.min));
const reduceValue = Math.round(this.calculation.accurateDivisionTenExponent(value, -this.precision));
return this.calculation.accurateMultiplication(reduceValue, Math.pow(10, -this.precision));
}
return parseFloat(
this.calculation
.accurateAddition(div, this.min)
.toFixed(this.precision)
);
return parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
}
_getPercentByValue(v) {
@ -541,11 +497,11 @@ export class IntervalSlider extends Single {
arr = pre.split("e");
const decimalPartLength = size(arr[0].split(".")[1]);
const sciencePartLength = parseInt(arr[1].substring(1));
return decimalPartLength - sciencePartLength;
}
arr = pre.split(".");
return arr.length > 1 ? arr[1].length : 0;
}
@ -556,20 +512,16 @@ export class IntervalSlider extends Single {
if (value >= this.max) {
return this.max;
}
return value;
}
_setEnable(b) {
super._setEnable.apply(this, [b]);
if (b) {
this.blueTrack.element
.removeClass("disabled-blue-track")
.addClass("blue-track");
this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
} else {
this.blueTrack.element
.removeClass("blue-track")
.addClass("disabled-blue-track");
this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
}
}
@ -577,7 +529,7 @@ export class IntervalSlider extends Single {
if (this.valueOne <= this.valueTwo) {
return { min: this.valueOne, max: this.valueTwo };
}
return { min: this.valueTwo, max: this.valueOne };
}
@ -602,22 +554,14 @@ export class IntervalSlider extends Single {
const o = this.options;
let valueOne = parseFloat(v.min);
let valueTwo = parseFloat(v.max);
valueOne =
o.digit === false
? valueOne
: parseFloat(valueOne.toFixed(o.digit));
valueTwo =
o.digit === false
? valueTwo
: parseFloat(valueTwo.toFixed(o.digit));
valueOne = o.digit === false ? valueOne : parseFloat(valueOne.toFixed(o.digit));
valueTwo = o.digit === false ? valueTwo : parseFloat(valueTwo.toFixed(o.digit));
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne =
this.valueOne <= this.valueTwo ? valueOne : valueTwo;
this.valueOne = this.valueOne <= this.valueTwo ? valueOne : valueTwo;
}
if (this._checkValidation(valueTwo)) {
this.valueTwo =
this.valueOne <= this.valueTwo ? valueTwo : valueOne;
this.valueTwo = this.valueOne <= this.valueTwo ? valueTwo : valueOne;
}
if (valueOne < this.min) {
this.valueOne = this.min;
@ -648,20 +592,9 @@ export class IntervalSlider extends Single {
(isNumeric(this.valueOne) || isNotEmptyString(this.valueOne)) &&
(isNumeric(this.valueTwo) || isNotEmptyString(this.valueTwo))
) {
this.labelOne.setValue(
o.digit === false
? this.valueOne
: parseFloat(this.valueOne).toFixed(o.digit)
);
this.labelTwo.setValue(
o.digit === false
? this.valueTwo
: parseFloat(this.valueTwo).toFixed(o.digit)
);
this._setAllPosition(
this._getPercentByValue(this.valueOne),
this._getPercentByValue(this.valueTwo)
);
this.labelOne.setValue(o.digit === false ? this.valueOne : parseFloat(this.valueOne).toFixed(o.digit));
this.labelTwo.setValue(o.digit === false ? this.valueTwo : parseFloat(this.valueTwo).toFixed(o.digit));
this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
} else {
this.labelOne.setValue(this.min);
this.labelTwo.setValue(this.max);

86
src/widget/intervalslider/model.accuratecalculation.js

@ -16,7 +16,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < n; i++) {
magnitude += "0";
}
return parseInt(magnitude);
}
@ -24,8 +24,7 @@ export class AccurateCalculationModel extends Widget {
if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
return;
}
let magnitudeDiff =
stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
let magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
let needAddZero;
if (magnitudeDiff > 0) {
needAddZero = stringNumber2;
@ -54,7 +53,7 @@ export class AccurateCalculationModel extends Widget {
numDecimal = numStrArray[1];
numDecimalLength = numStrArray[1].length;
}
return {
numInteger,
numDecimal,
@ -67,27 +66,16 @@ export class AccurateCalculationModel extends Widget {
const stringNumber1 = this._stringNumberFactory(num1);
const stringNumber2 = this._stringNumberFactory(num2);
// 整数部分计算
let integerResult =
parseInt(stringNumber1.numInteger) -
parseInt(stringNumber2.numInteger);
let integerResult = parseInt(stringNumber1.numInteger) - parseInt(stringNumber2.numInteger);
// 小数部分
this._formatDecimal(stringNumber1, stringNumber2);
const decimalMaxLength = getDecimalMaxLength(
stringNumber1,
stringNumber2
);
const decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
let decimalResultTemp;
let decimalResult;
if (
parseInt(stringNumber1.numDecimal) >=
parseInt(stringNumber2.numDecimal)
) {
decimalResultTemp = (
parseInt(stringNumber1.numDecimal) -
parseInt(stringNumber2.numDecimal)
).toString();
if (parseInt(stringNumber1.numDecimal) >= parseInt(stringNumber2.numDecimal)) {
decimalResultTemp = (parseInt(stringNumber1.numDecimal) - parseInt(stringNumber2.numDecimal)).toString();
decimalResult = addZero(decimalResultTemp, decimalMaxLength);
} else {
// 否则借位
@ -101,14 +89,14 @@ export class AccurateCalculationModel extends Widget {
decimalResult = addZero(decimalResultTemp, decimalMaxLength);
}
const result = `${integerResult}.${decimalResult}`;
return parseFloat(result);
function getDecimalMaxLength(num1, num2) {
if (num1.numDecimal.length >= num2.numDecimal.length) {
return num1.numDecimal.length;
}
return num2.numDecimal.length;
}
@ -117,7 +105,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < diff; i++) {
resultTemp = `0${resultTemp}`;
}
return resultTemp;
}
}
@ -127,30 +115,22 @@ export class AccurateCalculationModel extends Widget {
const stringNumber1 = this._stringNumberFactory(num1);
const stringNumber2 = this._stringNumberFactory(num2);
// 整数部分计算
let integerResult =
parseInt(stringNumber1.numInteger) +
parseInt(stringNumber2.numInteger);
let integerResult = parseInt(stringNumber1.numInteger) + parseInt(stringNumber2.numInteger);
// 小数部分
this._formatDecimal(stringNumber1, stringNumber2);
let decimalResult = (
parseInt(stringNumber1.numDecimal) +
parseInt(stringNumber2.numDecimal)
).toString();
let decimalResult = (parseInt(stringNumber1.numDecimal) + parseInt(stringNumber2.numDecimal)).toString();
if (decimalResult !== "0") {
if (decimalResult.length <= stringNumber1.numDecimal.length) {
decimalResult = addZero(
decimalResult,
stringNumber1.numDecimal.length
);
decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length);
} else {
integerResult++; // 进一
decimalResult = decimalResult.slice(1);
}
}
const result = `${integerResult}.${decimalResult}`;
return parseFloat(result);
function addZero(resultTemp, length) {
@ -158,7 +138,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < diff; i++) {
resultTemp = `0${resultTemp}`;
}
return resultTemp;
}
}
@ -168,33 +148,25 @@ export class AccurateCalculationModel extends Widget {
const stringNumber1 = this._stringNumberFactory(num1);
const stringNumber2 = this._stringNumberFactory(num2);
// 整数部分计算
const integerResult =
parseInt(stringNumber1.numInteger) *
parseInt(stringNumber2.numInteger);
const integerResult = parseInt(stringNumber1.numInteger) * parseInt(stringNumber2.numInteger);
// num1的小数和num2的整数
const dec1Int2 = this._accurateDivisionTenExponent(
parseInt(stringNumber1.numDecimal) *
parseInt(stringNumber2.numInteger),
parseInt(stringNumber1.numDecimal) * parseInt(stringNumber2.numInteger),
stringNumber1.numDecimalLength
);
// num1的整数和num2的小数
const int1dec2 = this._accurateDivisionTenExponent(
parseInt(stringNumber1.numInteger) *
parseInt(stringNumber2.numDecimal),
parseInt(stringNumber1.numInteger) * parseInt(stringNumber2.numDecimal),
stringNumber2.numDecimalLength
);
// 小数*小数
const dec1dec2 = this._accurateDivisionTenExponent(
parseInt(stringNumber1.numDecimal) *
parseInt(stringNumber2.numDecimal),
parseInt(stringNumber1.numDecimal) * parseInt(stringNumber2.numDecimal),
stringNumber1.numDecimalLength + stringNumber2.numDecimalLength
);
return this._accurateAddition(
this._accurateAddition(
this._accurateAddition(integerResult, dec1Int2),
int1dec2
),
this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2),
dec1dec2
);
}
@ -204,18 +176,14 @@ export class AccurateCalculationModel extends Widget {
const stringNumber = this._stringNumberFactory(num);
let integerResult, partDecimalResult;
if (stringNumber.numInteger.length > n) {
integerResult = stringNumber.numInteger.slice(
0,
stringNumber.numInteger.length - n
);
integerResult = stringNumber.numInteger.slice(0, stringNumber.numInteger.length - n);
partDecimalResult = stringNumber.numInteger.slice(-n);
} else {
integerResult = "0";
partDecimalResult = addZero(stringNumber.numInteger, n);
}
const result =
`${integerResult}.${partDecimalResult}${stringNumber.numDecimal}`;
const result = `${integerResult}.${partDecimalResult}${stringNumber.numDecimal}`;
return parseFloat(result);
function addZero(resultTemp, length) {
@ -223,7 +191,7 @@ export class AccurateCalculationModel extends Widget {
for (let i = 0; i < diff; i++) {
resultTemp = `0${resultTemp}`;
}
return resultTemp;
}
}
@ -233,7 +201,7 @@ export class AccurateCalculationModel extends Widget {
if (num1 >= num2) {
return this._accurateSubtraction(num1, num2);
}
return -this._accurateSubtraction(num2, num1);
}
if (num1 >= 0 && num2 < 0) {
@ -246,7 +214,7 @@ export class AccurateCalculationModel extends Widget {
if (num1 >= num2) {
return this._accurateSubtraction(-num2, -num1);
}
return this._accurateSubtraction(-num1, -num2);
}
}
@ -285,7 +253,7 @@ export class AccurateCalculationModel extends Widget {
if (num1 >= 0) {
return this._accurateDivisionTenExponent(num1, n);
}
return -this._accurateDivisionTenExponent(-num1, n);
}
}

6
src/widget/multilayerdownlist/combo.downlist.js

@ -1,5 +1,5 @@
import { shortcut, Widget, extend, createWidget } from "@/core";
import { MultiLayerDownListPopup } from "./popup.downlist";
import { shortcut, Widget, extend, createWidget } from "@/core";
import { Combo } from "@/base";
import { IconTrigger } from "@/case";
@ -29,13 +29,13 @@ export class MultiLayerDownListCombo extends Widget {
super._init(...arguments);
const o = this.options;
this.popupview = createWidget({
type: "bi.multi_layer_down_list_popup",
type: MultiLayerDownListPopup.xtype,
items: o.items,
chooseType: o.chooseType,
value: o.value,
});
this.popupview.on(MultiLayerDownListPopup.EVENT_CHANGE, value => {
this.popupview.on(MultiLayerDownListPopup.EVENT_CHANGE, (value) => {
this.fireEvent(MultiLayerDownListCombo.EVENT_CHANGE, value);
this.downlistcombo.hideView();
});

38
src/widget/multilayerdownlist/popup.downlist.js

@ -40,7 +40,7 @@ export class MultiLayerDownListPopup extends Pane {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: "bi-down-list-popup",
items: [],
@ -82,7 +82,7 @@ export class MultiLayerDownListPopup extends Pane {
if (isNotNull(self.childValueMap[value])) {
changedValue = self.childValueMap[value];
const fatherValue = self.fatherValueMap[value];
const fatherArrayValue = (`${fatherValue}`).split(BlankSplitChar);
const fatherArrayValue = `${fatherValue}`.split(BlankSplitChar);
self.fireEvent(
MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE,
changedValue,
@ -193,7 +193,7 @@ export class MultiLayerDownListPopup extends Pane {
result.push(spliter_container);
}
});
return result;
}
@ -252,7 +252,7 @@ export class MultiLayerDownListPopup extends Pane {
if (isArray(fatherValue)) {
fValue = fatherValue.join(BlankSplitChar);
}
return fValue + BlankSplitChar + childValue;
}
@ -268,7 +268,7 @@ export class MultiLayerDownListPopup extends Pane {
}
valueArray.push(value);
});
return valueArray;
}
@ -289,19 +289,21 @@ export class MultiLayerDownListPopup extends Pane {
}
});
});
return value;
function joinValue(sources, targets) {
let value = "";
some(sources, (idx, s) => some(targets, (id, t) => {
if (s === t) {
value = s;
return true;
}
}));
some(sources, (idx, s) =>
some(targets, (id, t) => {
if (s === t) {
value = s;
return true;
}
})
);
return value;
}
@ -314,7 +316,7 @@ export class MultiLayerDownListPopup extends Pane {
} else {
children.push(item.value);
}
return children;
}
}
@ -346,7 +348,7 @@ export class MultiLayerDownListPopup extends Pane {
each(this.popup.getAllButtons(), (i, item) => {
i % 2 === 0 && v.push(item.getValue());
});
return v;
}
@ -359,14 +361,14 @@ export class MultiLayerDownListPopup extends Pane {
if (isNotNull(self.childValueMap[value])) {
const fartherValue = self.fatherValueMap[value];
valueItem.childValue = self.childValueMap[value];
const fatherArrayValue = (`${fartherValue}`).split(BlankSplitChar);
const fatherArrayValue = `${fartherValue}`.split(BlankSplitChar);
valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue;
} else {
valueItem.value = value;
}
result.push(valueItem);
});
return result;
}
}

78
src/widget/multilayerselecttree/multilayerselecttree.combo.js

@ -1,14 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
isKey,
toPix,
AbsoluteLayout,
nextTick,
isArray
} from "@/core";
import { shortcut, Widget, extend, emptyFn, isKey, toPix, AbsoluteLayout, nextTick, isArray } from "@/core";
import { SingleTreeTrigger } from "../singletree/singletree.trigger";
import { MultiLayerSelectTreePopup } from "./multilayerselecttree.popup";
import { Combo } from "@/base";
@ -121,8 +111,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
itemsCreator: o.itemsCreator,
items: o.items,
ref(_ref) {
self.trigger &&
self.trigger.getSearcher().setAdapter(_ref);
self.trigger && self.trigger.getSearcher().setAdapter(_ref);
},
listeners: [
{
@ -130,13 +119,8 @@ export class MultiLayerSelectTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_CHANGE
);
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CHANGE);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue());
},
}
],
@ -157,9 +141,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@ -198,45 +180,32 @@ export class MultiLayerSelectTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_CHANGE
);
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM,
self.combo.getValue()
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CHANGE);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CLICK_ITEM, self.combo.getValue());
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_FOCUS,
action() {
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_FOCUS
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_FOCUS);
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_BLUR,
action() {
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_BLUR
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_BLUR);
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_SEARCHING,
action() {
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_SEARCHING
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiLayerSelectTreeTrigger.EVENT_STOP,
action() {
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_STOP
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_STOP);
},
},
{
@ -245,9 +214,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
const value = self.trigger.getSearcher().getKeyword();
self.combo.setValue([value]);
self.combo.hideView();
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_CHANGE
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_CHANGE);
},
}
],
@ -259,9 +226,8 @@ export class MultiLayerSelectTreeCombo extends Widget {
// 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return o.container &&
self.trigger.getSearcher().isSearching() &&
self.trigger.getSearcher().getView().element.find(e.target)
.length > 0
self.trigger.getSearcher().isSearching() &&
self.trigger.getSearcher().getView().element.find(e.target).length > 0
? false
: self.triggerBtn?.element.find(e.target).length === 0;
},
@ -275,9 +241,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
self.fireEvent(
MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW
);
self.fireEvent(MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@ -321,9 +285,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
}
getSearcher() {
return this.trigger
? this.trigger.getSearcher()
: this.textTrigger.getTextor();
return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor();
}
clear() {
@ -339,9 +301,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
}
setTipType(v) {
this.trigger
? this.trigger.setTipType(v)
: this.textTrigger.setTipType(v);
this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v);
}
populate(items) {
@ -361,8 +321,6 @@ export class MultiLayerSelectTreeCombo extends Widget {
}
setWaterMark(v) {
this.trigger
? this.trigger.setWaterMark(v)
: this.textTrigger.setWaterMark(v);
this.trigger ? this.trigger.setWaterMark(v) : this.textTrigger.setWaterMark(v);
}
}

14
src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js

@ -59,9 +59,7 @@ export class MultiLayerSelectTreeInsertSearchPane extends Widget {
{
eventName: MultiLayerSelectLevelTree.EVENT_CHANGE,
action() {
self.fireEvent(
MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE
);
self.fireEvent(MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
},
}
],
@ -84,10 +82,7 @@ export class MultiLayerSelectTreeInsertSearchPane extends Widget {
self.addNotMatchTip = _ref;
},
handler() {
self.fireEvent(
MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
o.keywordGetter()
);
self.fireEvent(MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
},
},
this.tree
@ -98,10 +93,7 @@ export class MultiLayerSelectTreeInsertSearchPane extends Widget {
setKeyword(keyword) {
const showTip = isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip &&
this.addNotMatchTip.setText(
i18nText("BI-Basic_Click_To_Add_Text", keyword)
);
showTip && this.addNotMatchTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
}
getValue() {

42
src/widget/multilayerselecttree/multilayerselecttree.leveltree.js

@ -66,11 +66,7 @@ export class MultiLayerSelectLevelTree extends Pane {
}
node.keyword = node.keyword || keyword;
extend.pNode = pNode;
if (
node.isParent === true ||
node.parent === true ||
isNotEmptyArray(node.children)
) {
if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = true;
defaults(node, extend);
@ -112,10 +108,10 @@ export class MultiLayerSelectLevelTree extends Pane {
items: this._formatItems(Tree.transformToTreeFormat(nodes), 0),
itemsCreator(op, callback) {
op.times === 1 &&
!op.node &&
nextTick(() => {
self.loading();
});
!op.node &&
nextTick(() => {
self.loading();
});
o.itemsCreator(op, ob => {
hasNext = ob.hasNext;
op.times === 1 && !op.node && self._populate(ob.items);
@ -128,10 +124,10 @@ export class MultiLayerSelectLevelTree extends Pane {
);
self.setValue(self.storeValue);
op.times === 1 &&
!op.node &&
nextTick(() => {
self.loaded();
});
!op.node &&
nextTick(() => {
self.loaded();
});
});
},
value: o.value,
@ -141,10 +137,7 @@ export class MultiLayerSelectLevelTree extends Pane {
isDefaultInit: o.itemsCreator !== emptyFn,
el: {
type: ButtonTree.xtype,
chooseType:
o.chooseType === Selection.None
? Selection.None
: Selection.Default, // 不使用buttontree内部getValue逻辑
chooseType: o.chooseType === Selection.None ? Selection.None : Selection.Default, // 不使用buttontree内部getValue逻辑
behaviors: o.behaviors,
layouts: [
{
@ -161,10 +154,7 @@ export class MultiLayerSelectLevelTree extends Pane {
self.fireEvent(Controller.EVENT_CHANGE, arguments);
if (type === Events.CLICK) {
self.setValue(value);
self.fireEvent(
MultiLayerSelectLevelTree.EVENT_CHANGE,
arguments
);
self.fireEvent(MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
}
});
@ -184,9 +174,7 @@ export class MultiLayerSelectLevelTree extends Pane {
this._populate(nodes);
isNull(nodes)
? this.tree.populate()
: this.tree.populate(
this._formatItems(Tree.transformToTreeFormat(nodes), 0)
);
: this.tree.populate(this._formatItems(Tree.transformToTreeFormat(nodes), 0));
}
setValue(v) {
@ -199,11 +187,7 @@ export class MultiLayerSelectLevelTree extends Pane {
}
getValue() {
return isArray(this.storeValue)
? this.storeValue
: isNull(this.storeValue)
? []
: [this.storeValue];
return isArray(this.storeValue) ? this.storeValue : isNull(this.storeValue) ? [] : [this.storeValue];
}
getAllLeaves() {

12
src/widget/multilayerselecttree/multilayerselecttree.popup.js

@ -1,14 +1,4 @@
import {
shortcut,
Widget,
extend,
i18nText,
emptyFn,
createWidget,
Controller,
VerticalLayout,
isArray
} from "@/core";
import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, Controller, VerticalLayout, isArray } from "@/core";
import { MultiLayerSelectLevelTree } from "./multilayerselecttree.leveltree";
@shortcut()

41
src/widget/multilayerselecttree/multilayerselecttree.trigger.js

@ -75,9 +75,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
self.editor = this;
},
defaultText: o.defaultText,
text: isKey(o.value)
? this._digest(o.value)
: o.text,
text: isKey(o.value) ? this._digest(o.value) : o.text,
value: o.value,
height: o.height,
tipText: "",
@ -86,25 +84,19 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
{
eventName: StateEditor.EVENT_FOCUS,
action() {
self.fireEvent(
MultiLayerSelectTreeTrigger.EVENT_FOCUS
);
self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_FOCUS);
},
},
{
eventName: StateEditor.EVENT_BLUR,
action() {
self.fireEvent(
MultiLayerSelectTreeTrigger.EVENT_BLUR
);
self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_BLUR);
},
},
{
eventName: StateEditor.EVENT_CHANGE,
action() {
self.fireEvent(
MultiLayerSelectTreeTrigger.EVENT_SEARCHING
);
self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_SEARCHING);
},
}
],
@ -126,15 +118,10 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
cls: "bi-card",
listeners: [
{
eventName:
MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
eventName: MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action() {
self.options.text = self
.getSearcher()
.getKeyword();
self.fireEvent(
MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM
);
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
},
}
],
@ -146,8 +133,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
const keyword = obj.keyword;
if (o.itemsCreator === BI.emptyFn) {
callback(self._getSearchItems(keyword));
o.allowInsertValue &&
self.popup.setKeyword(keyword);
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -156,9 +142,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
{
eventName: Searcher.EVENT_CHANGE,
action() {
self.fireEvent(
MultiLayerSelectTreeTrigger.EVENT_CHANGE
);
self.fireEvent(MultiLayerSelectTreeTrigger.EVENT_CHANGE);
},
}
],
@ -184,12 +168,7 @@ export class MultiLayerSelectTreeTrigger extends Trigger {
const items = [];
this.tree.traverse(node => {
const find = Func.getSearchResult(
self.tree.isRoot(node)
? []
: concat(
[node.text],
o.allowSearchValue ? [node.value] : []
),
self.tree.isRoot(node) ? [] : concat([node.text], o.allowSearchValue ? [node.value] : []),
keyword
);
if (find.find.length > 0 || find.match.length > 0) {

68
src/widget/multilayersingletree/multilayersingletree.combo.js

@ -1,14 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
isKey,
toPix,
AbsoluteLayout,
nextTick,
isArray
} from "@/core";
import { shortcut, Widget, extend, emptyFn, isKey, toPix, AbsoluteLayout, nextTick, isArray } from "@/core";
import { SingleTreeTrigger } from "../singletree/singletree.trigger";
import { MultiLayerSingleTreePopup } from "./multilayersingletree.popup";
import { Combo } from "@/base";
@ -47,9 +37,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
o = this.options;
const cls =
(o.simple
? "bi-border-bottom bi-focus-shadow "
: "bi-border bi-border-radius bi-focus-shadow ") +
(o.simple ? "bi-border-bottom bi-focus-shadow " : "bi-border bi-border-radius bi-focus-shadow ") +
(isKey(o.status) ? `status-${o.status}` : "");
const baseConfig = this._getBaseConfig();
@ -121,8 +109,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
itemsCreator: o.itemsCreator,
items: o.items,
ref(_ref) {
self.trigger &&
self.trigger.getSearcher().setAdapter(_ref);
self.trigger && self.trigger.getSearcher().setAdapter(_ref);
},
listeners: [
{
@ -130,9 +117,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_CHANGE
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_CHANGE);
},
}
],
@ -153,9 +138,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@ -193,41 +176,31 @@ export class MultiLayerSingleTreeCombo extends Widget {
action() {
self.setValue(this.getValue());
self.combo.hideView();
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_CHANGE
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_CHANGE);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_FOCUS,
action() {
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_FOCUS
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_FOCUS);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_BLUR,
action() {
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_BLUR
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_BLUR);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_SEARCHING,
action() {
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_SEARCHING
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_SEARCHING);
},
},
{
eventName: MultiLayerSingleTreeTrigger.EVENT_STOP,
action() {
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_STOP
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_STOP);
},
},
{
@ -236,9 +209,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
const value = self.trigger.getSearcher().getKeyword();
self.combo.setValue([value]);
self.combo.hideView();
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_CHANGE
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_CHANGE);
},
}
],
@ -250,9 +221,8 @@ export class MultiLayerSingleTreeCombo extends Widget {
// 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return o.container &&
self.trigger.getSearcher().isSearching() &&
self.trigger.getSearcher().getView().element.find(e.target)
.length > 0
self.trigger.getSearcher().isSearching() &&
self.trigger.getSearcher().getView().element.find(e.target).length > 0
? false
: self.triggerBtn?.element.find(e.target).length === 0;
},
@ -266,9 +236,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action() {
self.fireEvent(
MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW
);
self.fireEvent(MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW);
},
}
],
@ -303,9 +271,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
}
getSearcher() {
return this.trigger
? this.trigger.getSearcher()
: this.textTrigger.getTextor();
return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor();
}
setValue(v) {
@ -326,9 +292,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
}
setTipType(v) {
this.trigger
? this.trigger.setTipType(v)
: this.textTrigger.setTipType(v);
this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v);
}
populate(items) {

14
src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js

@ -59,9 +59,7 @@ export class MultiLayerSingleTreeInsertSearchPane extends Widget {
{
eventName: MultiLayerSingleLevelTree.EVENT_CHANGE,
action() {
self.fireEvent(
MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE
);
self.fireEvent(MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
},
}
],
@ -84,10 +82,7 @@ export class MultiLayerSingleTreeInsertSearchPane extends Widget {
self.addNotMatchTip = _ref;
},
handler() {
self.fireEvent(
MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
o.keywordGetter()
);
self.fireEvent(MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
},
},
this.tree
@ -98,10 +93,7 @@ export class MultiLayerSingleTreeInsertSearchPane extends Widget {
setKeyword(keyword) {
const showTip = isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip &&
this.addNotMatchTip.setText(
i18nText("BI-Basic_Click_To_Add_Text", keyword)
);
showTip && this.addNotMatchTip.setText(i18nText("BI-Basic_Click_To_Add_Text", keyword));
}
getValue() {

37
src/widget/multilayersingletree/multilayersingletree.leveltree.js

@ -66,11 +66,7 @@ export class MultiLayerSingleLevelTree extends Pane {
}
node.keyword = node.keyword || keyword;
extend.pNode = pNode;
if (
node.isParent === true ||
node.parent === true ||
isNotEmptyArray(node.children)
) {
if (node.isParent === true || node.parent === true || isNotEmptyArray(node.children)) {
extend.type = BasicTreeNode.xtype;
extend.selectable = false;
defaults(node, extend);
@ -112,10 +108,10 @@ export class MultiLayerSingleLevelTree extends Pane {
value: o.value,
itemsCreator(op, callback) {
op.times === 1 &&
!op.node &&
nextTick(() => {
self.loading();
});
!op.node &&
nextTick(() => {
self.loading();
});
o.itemsCreator(op, ob => {
hasNext = ob.hasNext;
op.times === 1 && !op.node && self._populate(ob.items);
@ -128,10 +124,10 @@ export class MultiLayerSingleLevelTree extends Pane {
);
self.setValue(self.storeValue);
op.times === 1 &&
!op.node &&
nextTick(() => {
self.loaded();
});
!op.node &&
nextTick(() => {
self.loaded();
});
});
},
@ -140,10 +136,7 @@ export class MultiLayerSingleLevelTree extends Pane {
isDefaultInit: o.itemsCreator !== emptyFn,
el: {
type: ButtonTree.xtype,
chooseType:
o.chooseType === Selection.None
? Selection.None
: Selection.Default, // 不使用buttontree内部getValue逻辑
chooseType: o.chooseType === Selection.None ? Selection.None : Selection.Default, // 不使用buttontree内部getValue逻辑
behaviors: o.behaviors,
layouts: [
{
@ -180,9 +173,7 @@ export class MultiLayerSingleLevelTree extends Pane {
this._populate(nodes);
isNull(nodes)
? this.tree.populate()
: this.tree.populate(
this._formatItems(Tree.transformToTreeFormat(nodes), 0)
);
: this.tree.populate(this._formatItems(Tree.transformToTreeFormat(nodes), 0));
}
setValue(v) {
@ -195,11 +186,7 @@ export class MultiLayerSingleLevelTree extends Pane {
}
getValue() {
return isArray(this.storeValue)
? this.storeValue
: isNull(this.storeValue)
? []
: [this.storeValue];
return isArray(this.storeValue) ? this.storeValue : isNull(this.storeValue) ? [] : [this.storeValue];
}
getAllLeaves() {

12
src/widget/multilayersingletree/multilayersingletree.popup.js

@ -1,14 +1,4 @@
import {
shortcut,
Widget,
extend,
i18nText,
emptyFn,
createWidget,
Controller,
VerticalLayout,
isArray
} from "@/core";
import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, Controller, VerticalLayout, isArray } from "@/core";
import { MultiLayerSingleLevelTree } from "./multilayersingletree.leveltree";
@shortcut()

41
src/widget/multilayersingletree/multilayersingletree.trigger.js

@ -75,9 +75,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
self.editor = this;
},
defaultText: o.defaultText,
text: isKey(o.value)
? this._digest(o.value)
: o.text,
text: isKey(o.value) ? this._digest(o.value) : o.text,
value: o.value,
height: o.height,
tipText: "",
@ -86,25 +84,19 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
{
eventName: StateEditor.EVENT_FOCUS,
action() {
self.fireEvent(
MultiLayerSingleTreeTrigger.EVENT_FOCUS
);
self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_FOCUS);
},
},
{
eventName: StateEditor.EVENT_BLUR,
action() {
self.fireEvent(
MultiLayerSingleTreeTrigger.EVENT_BLUR
);
self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_BLUR);
},
},
{
eventName: StateEditor.EVENT_CHANGE,
action() {
self.fireEvent(
MultiLayerSingleTreeTrigger.EVENT_SEARCHING
);
self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_SEARCHING);
},
}
],
@ -126,15 +118,10 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
cls: "bi-card",
listeners: [
{
eventName:
MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
eventName: MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action() {
self.options.text = self
.getSearcher()
.getKeyword();
self.fireEvent(
MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM
);
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
},
}
],
@ -146,8 +133,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
const keyword = obj.keyword;
if (o.itemsCreator === BI.emptyFn) {
callback(self._getSearchItems(keyword));
o.allowInsertValue &&
self.popup.setKeyword(keyword);
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -156,9 +142,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
{
eventName: Searcher.EVENT_CHANGE,
action() {
self.fireEvent(
MultiLayerSingleTreeTrigger.EVENT_CHANGE
);
self.fireEvent(MultiLayerSingleTreeTrigger.EVENT_CHANGE);
},
}
],
@ -184,12 +168,7 @@ export class MultiLayerSingleTreeTrigger extends Trigger {
const items = [];
this.tree.traverse(node => {
const find = Func.getSearchResult(
self.tree.isRoot(node)
? []
: concat(
[node.text],
o.allowSearchValue ? [node.value] : []
),
self.tree.isRoot(node) ? [] : concat([node.text], o.allowSearchValue ? [node.value] : []),
keyword
);
if (find.find.length > 0 || find.match.length > 0) {

3
src/widget/multiselect/check/multiselect.check.pane.js

@ -6,7 +6,8 @@ import {
createWidget,
map,
i18nText,
VerticalAdaptLayout, VTapeLayout
VerticalAdaptLayout,
VTapeLayout
} from "@/core";
import { TextButton, Label } from "@/base";
import { DisplaySelectedList } from "./multiselect.display";

22
src/widget/multiselect/check/multiselect.display.js

@ -1,11 +1,4 @@
import {
shortcut,
extend,
emptyFn,
createWidget,
VerticalLayout,
createItems
} from "@/core";
import { shortcut, extend, emptyFn, createWidget, VerticalLayout, createItems } from "@/core";
import { Pane, ButtonGroup, Loader, IconTextItem } from "@/base";
import { ListPane } from "@/case";
@ -51,7 +44,7 @@ export class DisplaySelectedList extends Pane {
}
],
},
itemsCreator (options, callback) {
itemsCreator(options, callback) {
if (options.times === 1) {
cacheItems = [];
}
@ -61,7 +54,7 @@ export class DisplaySelectedList extends Pane {
cacheItems = cacheItems.slice(100);
self.hasNext = cacheItems.length > 0;
callback(self._createItems(renderedItems));
return;
}
@ -70,15 +63,12 @@ export class DisplaySelectedList extends Pane {
const firstItemsCount = 100 + (ob.items.length % 100);
if (ob.items.length > 100) {
cacheItems = ob.items.slice(firstItemsCount);
self.hasNext =
firstItemsCount !== ob.items.length;
self.hasNext = firstItemsCount !== ob.items.length;
}
callback(
self._createItems(ob.items.slice(0, firstItemsCount))
);
callback(self._createItems(ob.items.slice(0, firstItemsCount)));
});
},
hasNext () {
hasNext() {
return self.hasNext;
},
});

50
src/widget/multiselect/loader.js

@ -1,3 +1,4 @@
import { LoadingBar, ButtonGroup, Loader } from "@/base";
import {
shortcut,
Widget,
@ -17,7 +18,6 @@ import {
isArray,
each
} from "@/core";
import { ButtonGroup, Loader } from "@/base";
@shortcut()
export class MultiSelectInnerLoader extends Widget {
@ -103,21 +103,18 @@ export class MultiSelectInnerLoader extends Widget {
],
value: o.value,
});
this.button_group.on(
Controller.EVENT_CHANGE,
function (type, value, obj) {
if (type === Events.CLICK) {
const node = self.cachGroup.getNodeByValue(value);
if (node) {
node.setSelected(obj.isSelected());
}
}
self.fireEvent(Controller.EVENT_CHANGE, arguments);
if (type === Events.CLICK) {
self.fireEvent(Loader.EVENT_CHANGE, obj);
this.button_group.on(Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === Events.CLICK) {
const node = self.cachGroup.getNodeByValue(value);
if (node) {
node.setSelected(obj.isSelected());
}
}
);
self.fireEvent(Controller.EVENT_CHANGE, arguments);
if (type === Events.CLICK) {
self.fireEvent(Loader.EVENT_CHANGE, obj);
}
});
const renderEngine = Widget._renderEngine;
Widget.registerRenderEngine(BI.Element.renderEngine);
@ -140,7 +137,7 @@ export class MultiSelectInnerLoader extends Widget {
this.next = createWidget(
extend(
{
type: "bi.loading_bar",
type: LoadingBar.xtype,
},
o.next
)
@ -159,12 +156,12 @@ export class MultiSelectInnerLoader extends Widget {
});
o.isDefaultInit &&
isEmpty(o.items) &&
nextTick(
bind(function () {
o.isDefaultInit && isEmpty(o.items) && this._populate();
}, this)
);
isEmpty(o.items) &&
nextTick(
bind(function () {
o.isDefaultInit && isEmpty(o.items) && this._populate();
}, this)
);
}
hasNext() {
@ -218,10 +215,7 @@ export class MultiSelectInnerLoader extends Widget {
return false;
}
this.options.items = (items || []).slice(
0,
100 + ((items || []).length % 100)
);
this.options.items = (items || []).slice(0, 100 + ((items || []).length % 100));
this.times = 1;
this.count = 0;
this.count += items.length;
@ -247,11 +241,7 @@ export class MultiSelectInnerLoader extends Widget {
Widget.registerRenderEngine(BI.Element.renderEngine);
this.cachGroup.populate.call(this.cachGroup, items, keyword);
Widget.registerRenderEngine(renderEngine);
this.button_group.populate.call(
this.button_group,
items.slice(0, firstItemsCount),
keyword
);
this.button_group.populate.call(this.button_group, items.slice(0, firstItemsCount), keyword);
}
}

124
src/widget/multiselect/multiselect.combo.js

@ -1,3 +1,4 @@
import { MultiSelectPopupView } from "./multiselect.popup.view";
import {
shortcut,
extend,
@ -23,12 +24,11 @@ import {
values,
filter,
contains,
isNull
isNull,
} from "@/core";
import { Single, Combo } from "@/base";
import { TriggerIconButton } from "@/case";
import { MultiSelectTrigger } from "./multiselect.trigger";
import { MultiSelectPopupView } from "./multiselect.popup.view";
import { MultiSelectCheckSelectedSwitcher } from "./trigger/switcher.checkselected";
@shortcut()
@ -125,28 +125,25 @@ export class MultiSelectCombo extends Single {
self._setStartValue("");
self.fireEvent(MultiSelectCombo.EVENT_STOP);
});
this.trigger.on(
MultiSelectTrigger.EVENT_SEARCHING,
keywords => {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
self._dataChange = true;
});
}
self.fireEvent(MultiSelectCombo.EVENT_SEARCHING);
this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, (keywords) => {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
self._dataChange = true;
});
}
);
self.fireEvent(MultiSelectCombo.EVENT_SEARCHING);
});
this.trigger.on(MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof BI.MultiSelectBar) {
@ -162,14 +159,11 @@ export class MultiSelectCombo extends Single {
}
self._dataChange = true;
});
this.trigger.on(
MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
() => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
}
);
this.trigger.on(MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(MultiSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@ -184,7 +178,7 @@ export class MultiSelectCombo extends Single {
el: this.trigger,
adjustLength: 1,
popup: {
type: "bi.multi_select_popup_view",
type: MultiSelectPopupView.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@ -215,7 +209,7 @@ export class MultiSelectCombo extends Single {
self.setValue();
self._defaultState();
},
}
},
],
itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight,
@ -256,8 +250,7 @@ export class MultiSelectCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self._dataChange &&
self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
}
});
@ -284,41 +277,30 @@ export class MultiSelectCombo extends Single {
itemsCreator: bind(this._itemsCreator4Trigger, this),
value: this.storeValue,
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
this.updateSelectedValue(self.storeValue);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(Events.VIEW, b => {
this.numberCounter.on(Events.VIEW, (b) => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
});
this.trigger.element.click(e => {
this.trigger.element.click((e) => {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
@ -349,7 +331,7 @@ export class MultiSelectCombo extends Single {
right: o.height,
top: 0,
height: o.height,
}
},
],
});
}
@ -396,7 +378,7 @@ export class MultiSelectCombo extends Single {
type: MultiSelectCombo.REQ_GET_ALL_DATA,
keywords,
},
ob => {
(ob) => {
const values = map(ob.items, "value");
digest(values);
}
@ -436,8 +418,7 @@ export class MultiSelectCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(tempMap[v]);
self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@ -452,15 +433,14 @@ export class MultiSelectCombo extends Single {
keywords: [this.trigger.getKey()],
selectedValues: filter(this.storeValue.value, (_i, v) => !contains(res.value, v)),
},
ob => {
(ob) => {
const items = map(ob.items, "value");
const selectedMap = self._makeMap(self.storeValue.value);
const notSelectedMap = self._makeMap(res.value);
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
self.storeValue.assist &&
self.storeValue.assist.push(selectedMap[items[i]]);
self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@ -481,8 +461,7 @@ export class MultiSelectCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
self._dataChange &&
self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@ -506,8 +485,7 @@ export class MultiSelectCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(map[v]);
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});

112
src/widget/multiselect/multiselect.combo.nobar.js

@ -23,7 +23,9 @@ import {
values,
filter,
contains,
isNull, pushDistinct, Selection
isNull,
pushDistinct,
Selection
} from "@/core";
import { Single, Combo } from "@/base";
import { MultiSelectBar, TriggerIconButton } from "@/case";
@ -126,27 +128,24 @@ export class MultiSelectNoBarCombo extends Single {
self.fireEvent(MultiSelectNoBarCombo.EVENT_STOP);
});
this.trigger.on(
MultiSelectTrigger.EVENT_SEARCHING,
keywords => {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
self._dataChange = true;
});
}
this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, keywords => {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (BI.endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
self._dataChange = true;
});
}
);
});
this.trigger.on(MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof MultiSelectBar) {
@ -161,14 +160,11 @@ export class MultiSelectNoBarCombo extends Single {
self._dataChange = true;
self.fireEvent(MultiSelectNoBarCombo.EVENT_CLICK_ITEM);
});
this.trigger.on(
MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
() => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
}
);
this.trigger.on(MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(MultiSelectTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
@ -198,9 +194,7 @@ export class MultiSelectNoBarCombo extends Single {
self._adjust(() => {
assertShowValue();
});
self.fireEvent(
MultiSelectNoBarCombo.EVENT_CLICK_ITEM
);
self.fireEvent(MultiSelectNoBarCombo.EVENT_CLICK_ITEM);
},
},
{
@ -260,8 +254,7 @@ export class MultiSelectNoBarCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self._dataChange &&
self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
}
});
@ -291,39 +284,28 @@ export class MultiSelectNoBarCombo extends Single {
value: o.value,
},
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
this.updateSelectedValue(self.storeValue);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
});
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
@ -466,8 +448,7 @@ export class MultiSelectNoBarCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(tempMap[v]);
self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@ -489,8 +470,7 @@ export class MultiSelectNoBarCombo extends Single {
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
self.storeValue.assist &&
self.storeValue.assist.push(selectedMap[items[i]]);
self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@ -511,8 +491,7 @@ export class MultiSelectNoBarCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
self._dataChange &&
self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectNoBarCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@ -536,8 +515,7 @@ export class MultiSelectNoBarCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(map[v]);
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});

173
src/widget/multiselect/multiselect.insert.combo.js

@ -1,3 +1,5 @@
import { MultiSelectInsertTrigger } from "./multiselect.insert.trigger";
import { MultiSelectPopupView } from "./multiselect.popup.view";
import {
shortcut,
extend,
@ -24,11 +26,12 @@ import {
values,
filter,
contains,
isNull, endWith, pushDistinct, Selection
isNull,
endWith,
pushDistinct,
Selection
} from "@/core";
import { Single, Combo, Msg } from "@/base";
import { MultiSelectInsertTrigger } from "./multiselect.insert.trigger";
import { MultiSelectPopupView } from "./multiselect.popup.view";
import { MultiSelectBar, TriggerIconButton } from "@/case";
import { MultiSelectCheckSelectedSwitcher } from "./trigger/switcher.checkselected";
@ -88,7 +91,7 @@ export class MultiSelectInsertCombo extends Single {
this.requesting = false;
this.trigger = createWidget({
type: "bi.multi_select_insert_trigger",
type: MultiSelectInsertTrigger.xtype,
allowEdit: o.allowEdit,
height: toPix(o.height, o.simple ? 1 : 2),
text: o.text,
@ -127,72 +130,54 @@ export class MultiSelectInsertCombo extends Single {
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_PAUSE, function () {
self._addItem(assertShowValue, true);
self.fireEvent(
MultiSelectInsertCombo.EVENT_ADD_ITEM,
this.getSearcher().getKeyword()
);
self.fireEvent(MultiSelectInsertCombo.EVENT_ADD_ITEM, this.getSearcher().getKeyword());
});
this.trigger.on(
MultiSelectInsertTrigger.EVENT_SEARCHING,
function (keywords) {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
self._dataChange = true;
});
this.getSearcher().getKeywordsLength() > 2000 &&
Msg.alert(
i18nText("BI-Basic_Prompt"),
i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
);
}
self.fireEvent(MultiSelectInsertCombo.EVENT_SEARCHING);
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_CHANGE,
function (value, obj) {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
this.trigger.on(MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
});
} else {
self._join(this.getValue(), () => {
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
});
}
self._dataChange = true;
}
self._dataChange = true;
});
this.getSearcher().getKeywordsLength() > 2000 &&
Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
() => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
self.fireEvent(MultiSelectInsertCombo.EVENT_SEARCHING);
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
});
} else {
self._join(this.getValue(), () => {
assertShowValue();
self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
});
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_COUNTER_CLICK,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self._dataChange = true;
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
});
this.combo = createWidget({
type: Combo.xtype,
@ -202,7 +187,7 @@ export class MultiSelectInsertCombo extends Single {
adjustLength: 1,
container: o.container,
popup: {
type: "bi.multi_select_popup_view",
type: MultiSelectPopupView.xtype,
ref() {
self.popup = this;
self.trigger.setAdapter(this);
@ -217,9 +202,7 @@ export class MultiSelectInsertCombo extends Single {
self._adjust(() => {
assertShowValue();
});
self.fireEvent(
MultiSelectInsertCombo.EVENT_CLICK_ITEM
);
self.fireEvent(MultiSelectInsertCombo.EVENT_CLICK_ITEM);
},
},
{
@ -276,8 +259,7 @@ export class MultiSelectInsertCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self._dataChange &&
self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
}
});
@ -304,39 +286,28 @@ export class MultiSelectInsertCombo extends Single {
itemsCreator: bind(this._itemsCreator4Trigger, this),
value: o.value,
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
this.updateSelectedValue(self.storeValue);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
});
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
@ -467,8 +438,7 @@ export class MultiSelectInsertCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(tempMap[v]);
self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@ -490,8 +460,7 @@ export class MultiSelectInsertCombo extends Single {
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
self.storeValue.assist &&
self.storeValue.assist.push(selectedMap[items[i]]);
self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@ -512,8 +481,7 @@ export class MultiSelectInsertCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
self._dataChange &&
self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectInsertCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@ -538,8 +506,7 @@ export class MultiSelectInsertCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(map[v]);
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});

155
src/widget/multiselect/multiselect.insert.combo.nobar.js

@ -24,7 +24,10 @@ import {
values,
filter,
contains,
isNull, endWith, pushDistinct, Selection
isNull,
endWith,
pushDistinct,
Selection
} from "@/core";
import { Single, Combo, Msg } from "@/base";
import { MultiSelectInsertTrigger } from "./multiselect.insert.trigger";
@ -116,69 +119,51 @@ export class MultiSelectInsertNoBarCombo extends Single {
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_PAUSE, function () {
self._addItem(assertShowValue, true);
self.fireEvent(
MultiSelectInsertNoBarCombo.EVENT_ADD_ITEM,
this.getSearcher().getKeyword()
);
self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_ADD_ITEM, this.getSearcher().getKeyword());
});
this.trigger.on(
MultiSelectInsertTrigger.EVENT_SEARCHING,
function (keywords) {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
}
self._dataChange = true;
});
this.getSearcher().getKeywordsLength() > 2000 &&
Msg.alert(
i18nText("BI-Basic_Prompt"),
i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
);
}
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_CHANGE,
function (value, obj) {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
this.trigger.on(MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, () => {
if (endWith(lastKeyword, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
});
} else {
self._join(this.getValue(), () => {
self.combo.populate();
self._setStartValue("");
} else {
self.combo.setValue(self.storeValue);
assertShowValue();
});
}
self._dataChange = true;
}
self._dataChange = true;
});
this.getSearcher().getKeywordsLength() > 2000 &&
Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand"));
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
() => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
});
} else {
self._join(this.getValue(), () => {
assertShowValue();
});
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_COUNTER_CLICK,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
self._dataChange = true;
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, () => {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
});
this.combo = createWidget({
type: Combo.xtype,
@ -261,8 +246,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self._dataChange &&
self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
}
});
@ -292,39 +276,28 @@ export class MultiSelectInsertNoBarCombo extends Single {
value: o.value,
},
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,
() => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
this.updateSelectedValue(self.storeValue);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
);
});
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(Events.VIEW, b => {
nextTick(() => {
// 自动调整宽度
self.trigger.refreshPlaceHolderWidth(
b === true ? self.numberCounter.element.outerWidth() + 8 : 0
);
self.trigger.refreshPlaceHolderWidth(b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
});
});
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW,
() => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
}
);
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW, () => {
nextTick(() => {
// 收起时自动调整宽度
self.trigger.refreshPlaceHolderWidth(0);
});
});
this.trigger.element.click(e => {
if (self.trigger.element.find(e.target).length > 0) {
@ -455,8 +428,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
const v = obj.value;
if (isNotNull(tempMap[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(tempMap[v]);
self.storeValue.assist && self.storeValue.assist.push(tempMap[v]);
delete tempMap[v];
}
});
@ -478,8 +450,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
const newItems = [];
each(items, (i, item) => {
if (isNotNull(selectedMap[items[i]])) {
self.storeValue.assist &&
self.storeValue.assist.push(selectedMap[items[i]]);
self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
delete selectedMap[items[i]];
}
if (isNull(notSelectedMap[items[i]])) {
@ -500,8 +471,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
function adjust() {
if (self.wants2Quit === true) {
self._dataChange &&
self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
self._dataChange && self.fireEvent(MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
@ -525,8 +495,7 @@ export class MultiSelectInsertNoBarCombo extends Single {
each(res.assist, (i, v) => {
if (isNotNull(map[v])) {
change = true;
self.storeValue.assist &&
self.storeValue.assist.push(map[v]);
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});

56
src/widget/multiselect/multiselect.insert.trigger.js

@ -1,12 +1,4 @@
import {
shortcut,
extend,
emptyFn,
createWidget,
Layout,
HTapeLayout,
AbsoluteLayout
} from "@/core";
import { shortcut, extend, emptyFn, createWidget, Layout, HTapeLayout, AbsoluteLayout } from "@/core";
import { Trigger, Text } from "@/base";
import { MultiSelectInsertSearcher } from "./trigger/searcher.multiselect.insert";
@ -69,15 +61,9 @@ export class MultiSelectInsertTrigger extends Trigger {
this.searcher.on(MultiSelectInsertSearcher.EVENT_PAUSE, () => {
self.fireEvent(MultiSelectInsertTrigger.EVENT_PAUSE);
});
this.searcher.on(
MultiSelectInsertSearcher.EVENT_SEARCHING,
function () {
self.fireEvent(
MultiSelectInsertTrigger.EVENT_SEARCHING,
arguments
);
}
);
this.searcher.on(MultiSelectInsertSearcher.EVENT_SEARCHING, function () {
self.fireEvent(MultiSelectInsertTrigger.EVENT_SEARCHING, arguments);
});
this.searcher.on(MultiSelectInsertSearcher.EVENT_STOP, () => {
self.fireEvent(MultiSelectInsertTrigger.EVENT_STOP);
});
@ -115,24 +101,24 @@ export class MultiSelectInsertTrigger extends Trigger {
});
!o.allowEdit &&
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: Text.xtype,
title() {
return self.searcher.getState();
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: Text.xtype,
title() {
return self.searcher.getState();
},
},
},
left: 0,
right: 24,
top: 0,
bottom: 0,
}
],
});
left: 0,
right: 24,
top: 0,
bottom: 0,
}
],
});
}
refreshPlaceHolderWidth(width) {

60
src/widget/multiselect/multiselect.loader.js

@ -11,7 +11,10 @@ import {
Controller,
delay,
isNotNull,
Selection, Direction, LogicFactory, pushDistinct
Selection,
Direction,
LogicFactory,
pushDistinct
} from "@/core";
import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case";
import { MultiSelectInnerLoader } from "./loader";
@ -56,9 +59,7 @@ export class MultiSelectLoader extends Widget {
toolbar: {
type: MultiSelectBar.xtype,
cls: "bi-list-item-active",
height:
this.options.itemHeight ||
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 36,
},
el: extend(
@ -74,13 +75,12 @@ export class MultiSelectLoader extends Widget {
itemsCreator(op, callback) {
const startValue = self._startValue;
self.storeValue &&
(op = extend(op || {}, {
selectedValues:
isKey(startValue) &&
self.storeValue.type === Selection.Multi
? self.storeValue.value.concat(startValue)
: self.storeValue.value,
}));
(op = extend(op || {}, {
selectedValues:
isKey(startValue) && self.storeValue.type === Selection.Multi
? self.storeValue.value.concat(startValue)
: self.storeValue.value,
}));
opts.itemsCreator(op, ob => {
hasNext = ob.hasNext;
let firstItems = [];
@ -92,16 +92,11 @@ export class MultiSelectLoader extends Widget {
text: txt,
value: v,
title: txt,
selected:
self.storeValue.type === Selection.Multi,
selected: self.storeValue.type === Selection.Multi,
};
});
if (
isKey(self._startValue) &&
!contains(self.storeValue.value, self._startValue)
) {
const txt =
opts.valueFormatter(startValue) || startValue;
if (isKey(self._startValue) && !contains(self.storeValue.value, self._startValue)) {
const txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
@ -111,18 +106,12 @@ export class MultiSelectLoader extends Widget {
}
firstItems = self._createItems(json);
}
callback(
firstItems.concat(self._createItems(ob.items)),
ob.keyword || ""
);
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) {
isKey(startValue) &&
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, startValue)
: pushDistinct(
self.storeValue.value,
startValue
));
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, startValue)
: pushDistinct(self.storeValue.value, startValue));
self.setValue(self.storeValue);
}
op.times === 1 && self._scrollToTop();
@ -140,9 +129,7 @@ export class MultiSelectLoader extends Widget {
element: this,
},
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(
Direction.Top
),
LogicFactory.createLogicTypeByDirection(Direction.Top),
extend(
{
scrolly: true,
@ -150,10 +137,7 @@ export class MultiSelectLoader extends Widget {
},
opts.logic,
{
items: LogicFactory.createLogicItemsByDirection(
Direction.Top,
this.button_group
),
items: LogicFactory.createLogicItemsByDirection(Direction.Top, this.button_group),
}
)
)
@ -176,9 +160,7 @@ export class MultiSelectLoader extends Widget {
type: MultiSelectItem.xtype,
logic: this.options.logic,
cls: "bi-list-item-active",
height:
this.options.itemHeight ||
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected,
iconWrapperWidth: 36,
...item,

76
src/widget/multiselect/multiselect.loader.nobar.js

@ -81,44 +81,28 @@ export class MultiSelectNoBarLoader extends Widget {
itemsCreator(op, callback) {
const startValue = self._startValue;
self.storeValue &&
(op = extend(op || {}, {
selectedValues:
isKey(startValue) &&
self.storeValue.type === Selection.Multi
? self.storeValue.value.concat(
startValue
)
: self.storeValue.value,
}));
(op = extend(op || {}, {
selectedValues:
isKey(startValue) && self.storeValue.type === Selection.Multi
? self.storeValue.value.concat(startValue)
: self.storeValue.value,
}));
opts.itemsCreator(op, ob => {
hasNext = ob.hasNext;
let firstItems = [];
if (op.times === 1 && self.storeValue) {
const json = map(
self.storeValue.value,
(i, v) => {
const txt = opts.valueFormatter(v) || v;
return {
text: txt,
value: v,
title: txt,
selected:
self.storeValue.type ===
Selection.Multi,
};
}
);
if (
isKey(self._startValue) &&
!contains(
self.storeValue.value,
self._startValue
)
) {
const txt =
opts.valueFormatter(startValue) ||
startValue;
const json = map(self.storeValue.value, (i, v) => {
const txt = opts.valueFormatter(v) || v;
return {
text: txt,
value: v,
title: txt,
selected: self.storeValue.type === Selection.Multi,
};
});
if (isKey(self._startValue) && !contains(self.storeValue.value, self._startValue)) {
const txt = opts.valueFormatter(startValue) || startValue;
json.unshift({
text: txt,
value: startValue,
@ -128,21 +112,12 @@ export class MultiSelectNoBarLoader extends Widget {
}
firstItems = self._createItems(json);
}
callback(
firstItems.concat(self._createItems(ob.items)),
ob.keyword || ""
);
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
if (op.times === 1 && self.storeValue) {
isKey(startValue) &&
(self.storeValue.type === Selection.All
? remove(
self.storeValue.value,
startValue
)
: pushDistinct(
self.storeValue.value,
startValue
));
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, startValue)
: pushDistinct(self.storeValue.value, startValue));
self.setValue(self.storeValue);
}
op.times === 1 && self._scrollToTop();
@ -178,9 +153,7 @@ export class MultiSelectNoBarLoader extends Widget {
type: MultiSelectItem.xtype,
cls: "bi-list-item-active",
logic: this.options.logic,
height:
this.options.itemHeight ||
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 36,
...item,
...this.options.itemFormatter(item),
@ -237,6 +210,5 @@ export class MultiSelectNoBarLoader extends Widget {
this.button_group.element.css({ "max-height": toPix(h) });
}
resetWidth() {
}
resetWidth() {}
}

36
src/widget/multiselect/multiselect.popup.view.js

@ -1,11 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText
} from "@/core";
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { MultiPopupView } from "@/case";
import { MultiSelectLoader } from "./multiselect.loader";
@ -60,23 +53,18 @@ export class MultiSelectPopupView extends Widget {
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => {
self.fireEvent(MultiSelectPopupView.EVENT_CHANGE);
});
this.popupView.on(
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
index => {
switch (index) {
case 0:
self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CLEAR);
break;
case 1:
self.fireEvent(
MultiSelectPopupView.EVENT_CLICK_CONFIRM
);
break;
default:
break;
}
this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
switch (index) {
case 0:
self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CLEAR);
break;
case 1:
self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CONFIRM);
break;
default:
break;
}
);
});
}
isAllSelected() {

34
src/widget/multiselect/multiselect.popup.view.nobar.js

@ -1,11 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText
} from "@/core";
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText } from "@/core";
import { MultiPopupView } from "@/case";
import { MultiSelectNoBarLoader } from "./multiselect.loader.nobar";
@ -60,23 +53,16 @@ export class MultiSelectNoBarPopupView extends Widget {
this.popupView.on(MultiPopupView.EVENT_CHANGE, () => {
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CHANGE);
});
this.popupView.on(
MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,
index => {
switch (index) {
case 0:
self.fireEvent(
MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR
);
break;
case 1:
self.fireEvent(
MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM
);
break;
}
this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
switch (index) {
case 0:
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR);
break;
case 1:
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM);
break;
}
);
});
}
setStartValue(v) {

57
src/widget/multiselect/multiselect.trigger.js

@ -1,13 +1,4 @@
import {
shortcut,
extend,
emptyFn,
createWidget,
isFunction,
Layout,
HTapeLayout,
AbsoluteLayout
} from "@/core";
import { shortcut, extend, emptyFn, createWidget, isFunction, Layout, HTapeLayout, AbsoluteLayout } from "@/core";
import { Trigger, Text } from "@/base";
import { MultiSelectSearcher } from "./trigger/searcher.multiselect";
@ -103,30 +94,30 @@ export class MultiSelectTrigger extends Trigger {
});
!o.allowEdit &&
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: Text.xtype,
title() {
/** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */
const state = self.searcher.getState();
if (isFunction(state)) {
return state();
}
return state;
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [
{
el: {
type: Text.xtype,
title() {
/** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */
const state = self.searcher.getState();
if (isFunction(state)) {
return state();
}
return state;
},
},
},
left: 0,
right: 24,
top: 0,
bottom: 0,
}
],
});
left: 0,
right: 24,
top: 0,
bottom: 0,
}
],
});
}
refreshPlaceHolderWidth(width) {

14
src/widget/multiselect/search/multiselect.search.insert.pane.js

@ -1,12 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
i18nText,
Controller, VerticalFillLayout
} from "@/core";
import { shortcut, Widget, extend, emptyFn, createWidget, i18nText, Controller, VerticalFillLayout } from "@/core";
import { Label } from "@/base";
import { MultiSelectSearchLoader } from "./multiselect.search.loader";
@ -78,9 +70,7 @@ export class MultiSelectSearchInsertPane extends Widget {
}
setKeyword(keyword) {
this.addNotMatchTip.setText(
i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword)
);
this.addNotMatchTip.setText(i18nText("BI-Basic_Press_Enter_To_Add_Text", keyword));
}
isAllSelected() {

16
src/widget/multiselect/search/multiselect.search.loader.js

@ -77,9 +77,9 @@ export class MultiSelectSearchLoader extends Widget {
},
itemsCreator(op, callback) {
self.storeValue &&
(op = extend(op || {}, {
selectedValues: self.storeValue.value,
}));
(op = extend(op || {}, {
selectedValues: self.storeValue.value,
}));
opts.itemsCreator(op, ob => {
const keyword = (ob.keyword = opts.keywordGetter());
hasNext = ob.hasNext;
@ -91,11 +91,7 @@ export class MultiSelectSearchLoader extends Widget {
const context = {
tipText: ob.tipText,
};
callback(
firstItems.concat(self._createItems(ob.items)),
keyword,
context
);
callback(firstItems.concat(self._createItems(ob.items)), keyword, context);
if (op.times === 1 && self.storeValue) {
self.setValue(self.storeValue);
}
@ -123,9 +119,7 @@ export class MultiSelectSearchLoader extends Widget {
logic: {
dynamic: false,
},
height:
this.options.itemHeight ||
BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected,
cls: "bi-list-item-active",
iconWrapperWidth: 36,

13
src/widget/multiselect/search/multiselect.search.pane.js

@ -1,12 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
Controller,
AbsoluteLayout
} from "@/core";
import { shortcut, Widget, extend, emptyFn, createWidget, Controller, AbsoluteLayout } from "@/core";
import { MultiSelectSearchLoader } from "./multiselect.search.loader";
@shortcut()
@ -71,8 +63,7 @@ export class MultiSelectSearchPane extends Widget {
return this.loader.isAllSelected();
}
hasMatched() {
}
hasMatched() {}
setValue(v) {
this.loader.setValue(v);

8
src/widget/multiselect/trigger/button.checkselected.js

@ -44,10 +44,7 @@ export class MultiSelectCheckSelectedButton extends Single {
});
this.numberCounter.on(TextButton.EVENT_CHANGE, function () {
self.fireEvent(
MultiSelectCheckSelectedButton.EVENT_CHANGE,
arguments
);
self.fireEvent(MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
});
this.numberCounter.element.hover(
@ -119,6 +116,5 @@ export class MultiSelectCheckSelectedButton extends Single {
this._populate(this._assertValue(this.options.value));
}
getValue() {
}
getValue() {}
}

11
src/widget/multiselect/trigger/editor.multiselect.js

@ -1,13 +1,4 @@
import {
shortcut,
Widget,
extend,
i18nText,
createWidget,
Controller,
isEmptyString,
isEmptyArray
} from "@/core";
import { shortcut, Widget, extend, i18nText, createWidget, Controller, isEmptyString, isEmptyArray } from "@/core";
import { StateEditor } from "@/case";
import { SelectPatchEditor } from "./editor/editor.patch";

24
src/widget/multiselect/trigger/editor/editor.patch.js

@ -8,7 +8,8 @@ import {
contains,
isKey,
Events,
trim, replaceAll
trim,
replaceAll
} from "@/core";
import { Editor, TextAreaEditor } from "@/base";
import { StateEditor } from "@/case";
@ -79,20 +80,14 @@ export class SelectPatchEditor extends Widget {
{
eventName: Editor.EVENT_FOCUS,
action() {
self.fireEvent(
SelectPatchEditor.EVENT_FOCUS,
arguments
);
self.fireEvent(SelectPatchEditor.EVENT_FOCUS, arguments);
},
},
{
eventName: Editor.EVENT_BLUR,
action() {
self._start = false;
self.fireEvent(
SelectPatchEditor.EVENT_BLUR,
arguments
);
self.fireEvent(SelectPatchEditor.EVENT_BLUR, arguments);
},
}
],
@ -119,18 +114,11 @@ export class SelectPatchEditor extends Widget {
if (
!this._start ||
!isKey(this._lastValue) ||
(this._pause === true &&
this._trimValue(this._lastValue) !==
this._trimValue(value))
(this._pause === true && this._trimValue(this._lastValue) !== this._trimValue(value))
) {
this._start = true;
this._pause = false;
this.fireEvent(
Controller.EVENT_CHANGE,
Events.STARTEDIT,
this.getValue(),
this
);
this.fireEvent(Controller.EVENT_CHANGE, Events.STARTEDIT, this.getValue(), this);
}
}
if (this._trimValue(this._lastValue) !== this._trimValue(value)) {

37
src/widget/multiselect/trigger/searcher.multiselect.insert.js

@ -1,15 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
i18nText,
createWidget,
isNotNull,
isEmptyArray,
size,
each
} from "@/core";
import { shortcut, Widget, extend, emptyFn, i18nText, createWidget, isNotNull, isEmptyArray, size, each } from "@/core";
import { MultiSelectEditor } from "./editor.multiselect";
import { Searcher } from "@/base";
import { MultiSelectSearchInsertPane } from "../search/multiselect.search.insert.pane";
@ -121,9 +110,7 @@ export class MultiSelectInsertSearcher extends Widget {
const keywords = this.getKeywords();
self.fireEvent(
MultiSelectInsertSearcher.EVENT_SEARCHING,
keywords.length > 2000
? keywords.slice(0, 2000).concat([BI.BlankSplitChar])
: keywords.slice(0, 2000)
keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000)
);
});
if (isNotNull(o.value)) {
@ -146,9 +133,7 @@ export class MultiSelectInsertSearcher extends Widget {
getKeywordsLength() {
const keywords = this.editor.getKeywords();
return keywords[keywords.length - 1] === BI.BlankSplitChar
? keywords.length - 1
: keywords.length;
return keywords[keywords.length - 1] === BI.BlankSplitChar ? keywords.length - 1 : keywords.length;
}
getKeyword() {
@ -184,13 +169,9 @@ export class MultiSelectInsertSearcher extends Widget {
state = "";
each(ob.assist, (i, v) => {
if (i === 0) {
state +=
`${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
state +=
`,${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
@ -204,13 +185,9 @@ export class MultiSelectInsertSearcher extends Widget {
state = "";
each(ob.value, (i, v) => {
if (i === 0) {
state +=
`${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
state +=
`,${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);

28
src/widget/multiselect/trigger/searcher.multiselect.js

@ -1,14 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
i18nText,
createWidget,
isNotNull,
size,
each
} from "@/core";
import { shortcut, Widget, extend, emptyFn, i18nText, createWidget, isNotNull, size, each } from "@/core";
import { MultiSelectEditor } from "./editor.multiselect";
import { Searcher } from "@/base";
import { MultiSelectSearchPane } from "../search/multiselect.search.pane";
@ -175,13 +165,9 @@ export class MultiSelectSearcher extends Widget {
state = "";
each(ob.assist, (i, v) => {
if (i === 0) {
state +=
`${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
state +=
`,${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);
@ -195,13 +181,9 @@ export class MultiSelectSearcher extends Widget {
state = "";
each(ob.value, (i, v) => {
if (i === 0) {
state +=
`${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
} else {
state +=
`,${
v === null ? "" : o.valueFormatter(`${v}`) || v}`;
state += `,${v === null ? "" : o.valueFormatter(`${v}`) || v}`;
}
});
this.editor.setState(state);

25
src/widget/multiselect/trigger/switcher.checkselected.js

@ -1,12 +1,4 @@
import {
shortcut,
Widget,
extend,
emptyFn,
createWidget,
Events,
nextTick
} from "@/core";
import { shortcut, Widget, extend, emptyFn, createWidget, Events, nextTick } from "@/core";
import { Switcher } from "@/base";
import { MultiSelectCheckSelectedButton } from "./button.checkselected";
import { MultiSelectCheckPane } from "../check/multiselect.check.pane";
@ -68,19 +60,13 @@ export class MultiSelectCheckSelectedSwitcher extends Widget {
masker: o.masker,
});
this.switcher.on(Switcher.EVENT_TRIGGER_CHANGE, () => {
self.fireEvent(
MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE
);
self.fireEvent(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
});
this.switcher.on(Switcher.EVENT_BEFORE_POPUPVIEW, () => {
self.fireEvent(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW
);
self.fireEvent(MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
});
this.switcher.on(Switcher.EVENT_AFTER_HIDEVIEW, () => {
self.fireEvent(
MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW
);
self.fireEvent(MultiSelectCheckSelectedSwitcher.EVENT_AFTER_HIDEVIEW);
});
this.switcher.on(Switcher.EVENT_AFTER_POPUPVIEW, function () {
const me = this;
@ -115,8 +101,7 @@ export class MultiSelectCheckSelectedSwitcher extends Widget {
this.button.setValue(v);
}
getValue() {
}
getValue() {}
populate(items) {
this.switcher.populate.apply(this.switcher, arguments);

53
src/widget/multiselectlist/multiselectlist.insert.js

@ -25,7 +25,8 @@ import {
values,
filter,
contains,
isNull, VerticalFillLayout
isNull,
VerticalFillLayout
} from "@/core";
import { Single, Searcher } from "@/base";
import { MultiSelectBar } from "@/case";
@ -34,7 +35,6 @@ import { MultiSelectLoader } from "../multiselect/multiselect.loader";
import { MultiSelectSearchInsertPane } from "../multiselect/search/multiselect.search.insert.pane";
import { SearchEditor } from "@/widget/editor/editor.search";
@shortcut()
export class MultiSelectInsertList extends Single {
static xtype = "bi.multi_select_insert_list";
@ -62,9 +62,9 @@ export class MultiSelectInsertList extends Single {
function assertShowValue() {
isKey(self._startValue) &&
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, self._startValue)
: pushDistinct(self.storeValue.value, self._startValue));
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, self._startValue)
: pushDistinct(self.storeValue.value, self._startValue));
// self.trigger.setValue(self.storeValue);
}
@ -152,14 +152,10 @@ export class MultiSelectInsertList extends Single {
eventName: Searcher.EVENT_PAUSE,
action() {
let keywords = self._getKeywords();
if (
keywords[keywords.length - 1] === BI.BlankSplitChar
) {
if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
const keyword = isEmptyArray(keywords)
? ""
: keywords[keywords.length - 1];
const keyword = isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
self._join(
{
type: Selection.Multi,
@ -167,10 +163,7 @@ export class MultiSelectInsertList extends Single {
},
() => {
if (self.storeValue.type === Selection.Multi) {
pushDistinct(
self.storeValue.value,
keyword
);
pushDistinct(self.storeValue.value, keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
@ -178,9 +171,7 @@ export class MultiSelectInsertList extends Single {
assertShowValue();
self.adapter.populate();
self._setStartValue("");
self.fireEvent(
MultiSelectInsertList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
}
);
self._showAdapter();
@ -203,17 +194,13 @@ export class MultiSelectInsertList extends Single {
self.adapter.setValue(self.storeValue);
assertShowValue();
}
self.fireEvent(
MultiSelectInsertList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
});
self._getKeywordsLength() > 2000 &&
BI.Msg.alert(
i18nText("BI-Basic_Prompt"),
i18nText(
"BI-Basic_Too_Much_Value_Get_Two_Thousand"
)
);
BI.Msg.alert(
i18nText("BI-Basic_Prompt"),
i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
);
}
},
},
@ -223,16 +210,12 @@ export class MultiSelectInsertList extends Single {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
self.fireEvent(
MultiSelectInsertList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
});
} else {
self._join(this.getValue(), () => {
assertShowValue();
self.fireEvent(
MultiSelectInsertList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertList.EVENT_CHANGE);
});
}
},
@ -279,9 +262,7 @@ export class MultiSelectInsertList extends Single {
keywords = keywords.concat([BI.BlankSplitChar]);
}
return keywords.length > 2000
? keywords.slice(0, 2000).concat([BI.BlankSplitChar])
: keywords.slice(0, 2000);
return keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000);
}
_getKeywordsLength() {

53
src/widget/multiselectlist/multiselectlist.insert.nobar.js

@ -25,7 +25,8 @@ import {
values,
filter,
contains,
isNull, VTapeLayout
isNull,
VTapeLayout
} from "@/core";
import { Single, Searcher, Msg } from "@/base";
import { MultiSelectBar } from "@/case";
@ -34,7 +35,6 @@ import { MultiSelectNoBarLoader } from "../multiselect/multiselect.loader.nobar"
import { MultiSelectSearchInsertPane } from "../multiselect/search/multiselect.search.insert.pane";
import { SearchEditor } from "../editor/editor.search";
@shortcut()
export class MultiSelectInsertNoBarList extends Single {
static xtype = "bi.multi_select_insert_no_bar_list";
@ -64,9 +64,9 @@ export class MultiSelectInsertNoBarList extends Single {
function assertShowValue() {
isKey(self._startValue) &&
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, self._startValue)
: pushDistinct(self.storeValue.value, self._startValue));
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, self._startValue)
: pushDistinct(self.storeValue.value, self._startValue));
// self.trigger.setValue(self.storeValue);
}
@ -155,14 +155,10 @@ export class MultiSelectInsertNoBarList extends Single {
eventName: Searcher.EVENT_PAUSE,
action() {
let keywords = self._getKeywords();
if (
keywords[keywords.length - 1] === BI.BlankSplitChar
) {
if (keywords[keywords.length - 1] === BI.BlankSplitChar) {
keywords = keywords.slice(0, keywords.length - 1);
}
const keyword = isEmptyArray(keywords)
? ""
: keywords[keywords.length - 1];
const keyword = isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
self._join(
{
type: Selection.Multi,
@ -170,10 +166,7 @@ export class MultiSelectInsertNoBarList extends Single {
},
() => {
if (self.storeValue.type === Selection.Multi) {
pushDistinct(
self.storeValue.value,
keyword
);
pushDistinct(self.storeValue.value, keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
@ -181,9 +174,7 @@ export class MultiSelectInsertNoBarList extends Single {
assertShowValue();
self.adapter.populate();
self._setStartValue("");
self.fireEvent(
MultiSelectInsertNoBarList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
}
);
},
@ -205,17 +196,13 @@ export class MultiSelectInsertNoBarList extends Single {
self.adapter.setValue(self.storeValue);
assertShowValue();
}
self.fireEvent(
MultiSelectInsertNoBarList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
});
self._getKeywordsLength() > 2000 &&
Msg.alert(
i18nText("BI-Basic_Prompt"),
i18nText(
"BI-Basic_Too_Much_Value_Get_Two_Thousand"
)
);
Msg.alert(
i18nText("BI-Basic_Prompt"),
i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")
);
}
},
},
@ -225,16 +212,12 @@ export class MultiSelectInsertNoBarList extends Single {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
self.fireEvent(
MultiSelectInsertNoBarList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
});
} else {
self._join(this.getValue(), () => {
assertShowValue();
self.fireEvent(
MultiSelectInsertNoBarList.EVENT_CHANGE
);
self.fireEvent(MultiSelectInsertNoBarList.EVENT_CHANGE);
});
}
},
@ -285,9 +268,7 @@ export class MultiSelectInsertNoBarList extends Single {
keywords = keywords.concat([BI.BlankSplitChar]);
}
return keywords.length > 2000
? keywords.slice(0, 2000).concat([BI.BlankSplitChar])
: keywords.slice(0, 2000);
return keywords.length > 2000 ? keywords.slice(0, 2000).concat([BI.BlankSplitChar]) : keywords.slice(0, 2000);
}
_getKeywordsLength() {

24
src/widget/multiselectlist/multiselectlist.js

@ -24,7 +24,8 @@ import {
values,
filter,
contains,
isNull, VTapeLayout
isNull,
VTapeLayout
} from "@/core";
import { Searcher } from "@/base";
import { MultiSelectBar } from "@/case";
@ -33,7 +34,6 @@ import { MultiSelectSearchPane } from "../multiselect/search/multiselect.search.
import { SelectPatchEditor } from "../multiselect/trigger/editor/editor.patch";
import { SearchEditor } from "../editor/editor.search";
@shortcut()
export class MultiSelectList extends Widget {
static xtype = "bi.multi_select_list";
@ -61,9 +61,9 @@ export class MultiSelectList extends Widget {
function assertShowValue() {
isKey(self._startValue) &&
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, self._startValue)
: pushDistinct(self.storeValue.value, self._startValue));
(self.storeValue.type === Selection.All
? remove(self.storeValue.value, self._startValue)
: pushDistinct(self.storeValue.value, self._startValue));
// self.trigger.setValue(self.storeValue);
}
@ -365,18 +365,12 @@ export class MultiSelectList extends Widget {
}
function adjust() {
if (
self.storeValue.type === Selection.All &&
self.storeValue.value.length >= self._count
) {
if (self.storeValue.type === Selection.All && self.storeValue.value.length >= self._count) {
self.storeValue = {
type: Selection.Multi,
value: [],
};
} else if (
self.storeValue.type === Selection.Multi &&
self.storeValue.value.length >= self._count
) {
} else if (self.storeValue.type === Selection.Multi && self.storeValue.value.length >= self._count) {
self.storeValue = {
type: Selection.All,
value: [],
@ -421,9 +415,7 @@ export class MultiSelectList extends Widget {
return this.adapter.isAllSelected();
}
resize() {
}
resize() {}
setValue(v) {
this.storeValue = v || {};

17
src/widget/multiselecttree/multiselecttree.js

@ -1,11 +1,5 @@
import {
shortcut,
extend,
emptyFn,
createWidget,
nextTick,
AbsoluteLayout
} from "@/core";
import { MultiTreeSearchPane } from "../multitree/trigger/multi.tree.search.pane";
import { VerticalFillLayout, shortcut, extend, emptyFn, createWidget, nextTick, AbsoluteLayout } from "@/core";
import { Single, Searcher } from "@/base";
import { MultiSelectTreePopup } from "./multiselecttree.popup";
@ -47,7 +41,7 @@ export class MultiSelectTree extends Single {
// 搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = createWidget({
type: "bi.multi_tree_search_pane",
type: MultiTreeSearchPane.xtype,
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter() {
return self.searcher.getKeyword();
@ -121,7 +115,7 @@ export class MultiSelectTree extends Single {
});
createWidget({
type: "bi.vertical_fill",
type: VerticalFillLayout.xtype,
element: this,
items: [
{
@ -159,8 +153,7 @@ export class MultiSelectTree extends Single {
this.adapter.setVisible(false);
}
resize() {
}
resize() {}
setSelectedValue(v) {
this.storeValue.value = v || {};

3
src/widget/multiselecttree/multiselecttree.popup.js

@ -10,8 +10,7 @@ export class MultiSelectTreePopup extends Widget {
_defaultConfig() {
return extend(super._defaultConfig(...arguments), {
baseCls:
"bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: emptyFn,
});
}

Loading…
Cancel
Save