Browse Source

Pull request #3410: 无jira refact:widget的xtype换下

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit 'de22cfdcf92113708d731f6708d20ebb2746d02c':
  无jira refact:widget的xtype换下
es6
treecat-罗群 2 years ago
parent
commit
dff2779ee8
  1. 57
      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. 60
      src/widget/date/calendar/picker.date.js
  5. 38
      src/widget/date/calendar/picker.year.js
  6. 59
      src/widget/date/calendar/popup.calendar.date.js
  7. 51
      src/widget/date/calendar/popup.month.js
  8. 28
      src/widget/date/calendar/popup.year.js
  9. 25
      src/widget/date/calendar/trigger.triangle.date.js
  10. 52
      src/widget/datepane/card.static.datepane.js
  11. 113
      src/widget/datepane/datepane.js
  12. 33
      src/widget/datetime/datetime.combo.js
  13. 65
      src/widget/datetime/datetime.popup.js
  14. 29
      src/widget/datetime/datetime.trigger.js
  15. 60
      src/widget/datetimepane/card.static.datetimepane.js
  16. 121
      src/widget/datetimepane/datetimepane.js
  17. 12
      src/widget/downlist/combo.downlist.js
  18. 14
      src/widget/downlist/group.downlist.js
  19. 16
      src/widget/downlist/item.downlist.js
  20. 23
      src/widget/downlist/item.downlistgroup.js
  21. 42
      src/widget/downlist/popup.downlist.js
  22. 61
      src/widget/dynamicdate/dynamicdate.caculate.js
  23. 235
      src/widget/dynamicdate/dynamicdate.card.js
  24. 130
      src/widget/dynamicdate/dynamicdate.combo.js
  25. 55
      src/widget/dynamicdate/dynamicdate.param.item.js
  26. 130
      src/widget/dynamicdate/dynamicdate.popup.js
  27. 110
      src/widget/dynamicdate/dynamicdate.trigger.js
  28. 132
      src/widget/dynamicdatetime/dynamicdatetime.combo.js
  29. 146
      src/widget/dynamicdatetime/dynamicdatetime.popup.js
  30. 97
      src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
  31. 165
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js
  32. 65
      src/widget/editor/editor.search.js
  33. 2
      src/widget/editor/editor.search.small.js
  34. 41
      src/widget/editor/editor.text.js
  35. 2
      src/widget/editor/editor.text.small.js
  36. 135
      src/widget/intervalslider/intervalslider.js
  37. 62
      src/widget/intervalslider/model.accuratecalculation.js
  38. 6
      src/widget/multilayerdownlist/combo.downlist.js
  39. 10
      src/widget/multilayerdownlist/popup.downlist.js
  40. 76
      src/widget/multilayerselecttree/multilayerselecttree.combo.js
  41. 14
      src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js
  42. 26
      src/widget/multilayerselecttree/multilayerselecttree.leveltree.js
  43. 12
      src/widget/multilayerselecttree/multilayerselecttree.popup.js
  44. 41
      src/widget/multilayerselecttree/multilayerselecttree.trigger.js
  45. 66
      src/widget/multilayersingletree/multilayersingletree.combo.js
  46. 14
      src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js
  47. 21
      src/widget/multilayersingletree/multilayersingletree.leveltree.js
  48. 12
      src/widget/multilayersingletree/multilayersingletree.popup.js
  49. 41
      src/widget/multilayersingletree/multilayersingletree.trigger.js
  50. 3
      src/widget/multiselect/check/multiselect.check.pane.js
  51. 16
      src/widget/multiselect/check/multiselect.display.js
  52. 22
      src/widget/multiselect/loader.js
  53. 72
      src/widget/multiselect/multiselect.combo.js
  54. 62
      src/widget/multiselect/multiselect.combo.nobar.js
  55. 95
      src/widget/multiselect/multiselect.insert.combo.js
  56. 83
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  57. 22
      src/widget/multiselect/multiselect.insert.trigger.js
  58. 46
      src/widget/multiselect/multiselect.loader.js
  59. 52
      src/widget/multiselect/multiselect.loader.nobar.js
  60. 20
      src/widget/multiselect/multiselect.popup.view.js
  61. 24
      src/widget/multiselect/multiselect.popup.view.nobar.js
  62. 11
      src/widget/multiselect/multiselect.trigger.js
  63. 14
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  64. 10
      src/widget/multiselect/search/multiselect.search.loader.js
  65. 13
      src/widget/multiselect/search/multiselect.search.pane.js
  66. 8
      src/widget/multiselect/trigger/button.checkselected.js
  67. 11
      src/widget/multiselect/trigger/editor.multiselect.js
  68. 24
      src/widget/multiselect/trigger/editor/editor.patch.js
  69. 37
      src/widget/multiselect/trigger/searcher.multiselect.insert.js
  70. 28
      src/widget/multiselect/trigger/searcher.multiselect.js
  71. 25
      src/widget/multiselect/trigger/switcher.checkselected.js
  72. 41
      src/widget/multiselectlist/multiselectlist.insert.js
  73. 41
      src/widget/multiselectlist/multiselectlist.insert.nobar.js
  74. 18
      src/widget/multiselectlist/multiselectlist.js
  75. 17
      src/widget/multiselecttree/multiselecttree.js
  76. 3
      src/widget/multiselecttree/multiselecttree.popup.js

57
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",
const el = extend(
{
type: ArrowNode.xtype,
height: 30,
text: item.text,
value: item.value,
open: isActive,
}, item.el);
},
item.el
);
const popup = extend({
const popup = extend(
{
animation: o.openMotion.animation,
animationDuring: o.openMotion.animationDuring,
}, item.popup);
},
item.popup
);
return extend({
type: "bi.expander",
return extend(
{
type: Expander.xtype,
cls,
isDefaultInit: o.isDefaultInit,
trigger: o.trigger,
listeners: [{
listeners: [
{
eventName: Expander.EVENT_EXPAND,
action: () => {
this._hideOtherExpander(item.value);
this.fireEvent(Collapse.EVENT_EXPAND, item.value);
},
}],
}, item, {
}
],
},
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,

60
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: [{
items: [
{
el: {
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
items: [this.left],
},
width: 24,
}, {
},
{
el: {
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
hgap: 10,
items: [this.year, this.month],
},
}, {
},
{
el: {
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
items: [this.right],
},
width: 24,
}],
},
],
});
this.setValue({
year: this._year,

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

@ -1,13 +1,13 @@
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);
@ -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: [{
items: [
{
el: {
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
items: [this.left],
},
width: 25,
}, {
type: "bi.center_adapt",
items: [{
},
{
type: CenterAdaptLayout.xtype,
items: [
{
el: this.year,
}],
}, {
},
],
},
{
el: {
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
items: [this.right],
},
width: 25,
}],
},
],
});
this.setValue(this._year);
}

59
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,
},
@ -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: [{
return [
{
type: VerticalLayout.xtype,
items: [
{
el: this.calendar,
hgap: 12,
bgap: 7,
}],
}, {
type: "bi.absolute",
items: [{
}
],
},
{
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: "bi.layout",
type: Layout.xtype,
cls: "bi-split-top",
},
height: 1,
top: 40,
left: 0,
right: 0,
}],
}];
}
],
}
];
}
_checkMin() {

51
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({
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",
}
)
),
{
type: CenterAdaptLayout.xtype,
vgap: 2,
}],
}
],
value: o.value,
});
@ -66,9 +91,10 @@ 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) => {
items = map(items, (i, item) =>
map(item, (j, td) => {
return {
type: "bi.text_item",
type: TextItem.xtype,
cls: "bi-border-radius bi-list-item-select",
textAlign: "center",
whiteSpace: "nowrap",
@ -80,7 +106,8 @@ export class MonthPopup extends Widget {
text: td,
disabled: !contains(m, td),
};
}));
})
);
Widget.popContext();
return items;

28
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,
@ -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: {

25
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: [{
items: [
{
el: this.text,
rgap: 5,
}, {
type: "bi.icon_label",
},
{
type: IconLabel.xtype,
width: 16,
}],
}
],
});
}
@ -67,7 +70,5 @@ export class DateTriangleTrigger extends Trigger {
return this.item.getText();
}
getKey() {
}
getKey() {}
}

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

@ -1,14 +1,27 @@
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);
@ -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,
},

113
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,29 +30,37 @@ 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: [{
type: VTapeLayout.xtype,
items: [
{
el: {
type: "bi.linear_segment",
type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: 30,
items: createItems([{
items: createItems(
[
{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDatePane.Static,
}, {
},
{
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDatePane.Dynamic,
}], {
}
],
{
textAlign: "center",
}),
listeners: [{
}
),
listeners: [
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
let date;
@ -63,14 +85,16 @@ export class DynamicDatePane extends Widget {
}
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}],
}
],
ref: _ref => {
this.switcher = _ref;
},
},
height: o.supportDynamic ? 30 : 0,
}, {
type: "bi.tab",
},
{
type: Tab.xtype,
ref: _ref => {
this.dateTab = _ref;
},
@ -79,21 +103,24 @@ export class DynamicDatePane extends Widget {
switch (v) {
case DynamicDatePane.Static:
return {
type: "bi.static_date_pane_card",
type: StaticDatePaneCard.xtype,
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors,
listeners: [{
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.ymd = _ref;
},
@ -101,55 +128,69 @@ export class DynamicDatePane extends Widget {
case DynamicDatePane.Dynamic:
default:
return {
type: "bi.vtape",
items: [{
type: "bi.dynamic_date_card",
type: VTapeLayout.xtype,
items: [
{
type: DynamicDateCard.xtype,
min: o.minDate,
max: o.maxDate,
ref: _ref => {
this.dynamicPane = _ref;
},
}, {
},
{
el: {
type: "bi.center",
items: [{
type: "bi.text_button",
type: CenterLayout.xtype,
items: [
{
type: TextButton.xtype,
cls: "bi-high-light bi-border-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: 23,
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.setValue();
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
}
],
},
{
type: TextButton.xtype,
cls: "bi-border-left bi-high-light bi-border-top",
textHeight: 23,
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDatePopup.EVENT_CHANGE);
this.dynamicPane.checkValidation(true) &&
this.fireEvent(
DynamicDatePopup.EVENT_CHANGE
);
} else {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
}
},
}],
}],
}
],
}
],
},
height: 24,
}],
}
],
};
}
},
}],
}
],
};
}

33
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,7 +36,9 @@ export class DateTimeCombo extends Single {
super._init(...arguments);
const opts = this.options;
const date = getDate();
this.storeValue = isNotNull(opts.value) ? opts.value : {
this.storeValue = isNotNull(opts.value)
? opts.value
: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
@ -42,7 +47,7 @@ export class DateTimeCombo extends Single {
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,
@ -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],

65
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: [{
type: VTapeLayout.xtype,
items: [
{
el: this.dateCombo,
}, {
},
{
el: {
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
cls: "bi-split-top",
items: [{
type: "bi.dynamic_date_time_select",
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({
return extend(
{
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
}, this.timeSelect.getValue());
},
this.timeSelect.getValue()
);
}
}

29
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: [{
items: [
{
el: this.text,
}, {
},
{
el: createWidget(),
width: this._const.iconWidth,
}],
}
],
});
this.setValue(o.value);
}

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

@ -1,14 +1,28 @@
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);
@ -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: [{
items: [
{
el: this.datePicker,
height: 40,
}, this.calendar, {
},
this.calendar,
{
el: {
type: "bi.dynamic_date_time_select",
type: DynamicDateTimeSelect.xtype,
cls: "bi-split-top",
ref: _ref => {
ref: (_ref) => {
this.timeSelect = _ref;
},
listeners: [{
listeners: [
{
eventName: DynamicDateTimeSelect.EVENT_CONFIRM,
action: () => {
this.selectedTime = extend(this.calendar.getValue(), this.timeSelect.getValue());
this.fireEvent("EVENT_CHANGE");
},
}],
},
],
},
height: 40,
}],
},
],
});
createWidget({
type: "bi.absolute",
type: AbsoluteLayout.xtype,
element: this,
items: [{
items: [
{
el: {
type: "bi.layout",
type: Layout.xtype,
cls: "bi-split-top",
},
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,
},

121
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",
@ -24,23 +38,31 @@ export class DynamicDateTimePane extends Widget {
const o = this.options;
return {
type: "bi.vtape",
items: [{
type: VTapeLayout.xtype,
items: [
{
el: {
type: "bi.linear_segment",
type: LinearSegment.xtype,
invisible: !o.supportDynamic,
cls: "bi-split-bottom",
height: 30,
items: createItems([{
items: createItems(
[
{
text: i18nText("BI-Multi_Date_YMD"),
value: DynamicDateTimePane.Static,
}, {
},
{
text: i18nText("BI-Basic_Dynamic_Title"),
value: DynamicDateTimePane.Dynamic,
}], {
}
],
{
textAlign: "center",
}),
listeners: [{
}
),
listeners: [
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
const value = this.switcher.getValue()[0];
@ -65,14 +87,16 @@ export class DynamicDateTimePane extends Widget {
}
this.fireEvent(DynamicDateTimePane.EVENT_CHANGE);
},
}],
}
],
ref: _ref => {
this.switcher = _ref;
},
},
height: o.supportDynamic ? 30 : 0,
}, {
type: "bi.tab",
},
{
type: Tab.xtype,
ref: _ref => {
this.dateTab = _ref;
},
@ -81,21 +105,24 @@ export class DynamicDateTimePane extends Widget {
switch (v) {
case DynamicDateTimePane.Static:
return {
type: "bi.static_date_time_pane_card",
type: StaticDateTimePaneCard.xtype,
min: o.minDate,
max: o.maxDate,
behaviors: o.behaviors,
listeners: [{
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.ymd = _ref;
},
@ -103,55 +130,69 @@ export class DynamicDateTimePane extends Widget {
case DynamicDateTimePane.Dynamic:
default:
return {
type: "bi.vtape",
items: [{
type: "bi.dynamic_date_card",
type: VTapeLayout.xtype,
items: [
{
type: DynamicDateCard.xtype,
min: o.minDate,
max: o.maxDate,
ref: _ref => {
this.dynamicPane = _ref;
},
}, {
},
{
el: {
type: "bi.center",
items: [{
type: "bi.text_button",
type: CenterLayout.xtype,
items: [
{
type: TextButton.xtype,
cls: "bi-high-light bi-border-top",
shadow: true,
text: i18nText("BI-Basic_Clear"),
textHeight: 23,
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.setValue();
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
}
],
},
{
type: TextButton.xtype,
cls: "bi-border-left bi-high-light bi-border-top",
textHeight: 23,
shadow: true,
text: i18nText("BI-Basic_OK"),
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
const type = this.dateTab.getSelect();
if (type === DynamicDateCombo.Dynamic) {
this.dynamicPane.checkValidation(true) && this.fireEvent(DynamicDatePane.EVENT_CHANGE);
this.dynamicPane.checkValidation(true) &&
this.fireEvent(
DynamicDatePane.EVENT_CHANGE
);
} else {
this.fireEvent(DynamicDatePane.EVENT_CHANGE);
}
},
}],
}],
}
],
}
],
},
height: 24,
}],
}
],
};
}
},
}],
}
],
};
}

12
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);
@ -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();
},
}

14
src/widget/downlist/group.downlist.js

@ -1,11 +1,5 @@
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 {
@ -32,12 +26,12 @@ export class DownListGroup extends Widget {
this.downlistgroup = createWidget({
element: this,
type: "bi.button_tree",
type: ButtonTree.xtype,
items: o.items,
chooseType: 0, // 0单选,1多选
layouts: [
{
type: "bi.vertical",
type: VerticalLayout.xtype,
hgap: 0,
vgap: 0,
}

16
src/widget/downlist/item.downlist.js

@ -1,5 +1,5 @@
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 {
@ -31,7 +31,7 @@ export class DownListItem extends BasicButton {
super._init(...arguments);
const o = this.options;
this.text = createWidget({
type: "bi.label",
type: Label.xtype,
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
@ -47,13 +47,13 @@ export class DownListItem extends BasicButton {
const icon = isPlainObject(o.icon)
? o.icon
: {
type: "bi.icon",
type: Icon.xtype,
width: o.iconWidth,
height: o.iconHeight,
};
this.icon = createWidget({
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
width: 36,
height: o.height,
items: [
@ -71,11 +71,7 @@ export class DownListItem extends BasicButton {
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(Direction.Left),
extend(o.logic, {
items: LogicFactory.createLogicItemsByDirection(
Direction.Left,
this.icon,
this.text
),
items: LogicFactory.createLogicItemsByDirection(Direction.Left, this.icon, this.text),
})
)
)

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

@ -1,4 +1,7 @@
import { Label, IconButton, BasicButton } from "@/base";
import {
CenterAdaptLayout,
HorizontalFillLayout,
shortcut,
extend,
createWidget,
@ -10,7 +13,6 @@ import {
first,
BlankSplitChar
} from "@/core";
import { BasicButton } from "@/base";
@shortcut()
export class DownListGroupItem extends BasicButton {
@ -36,7 +38,7 @@ export class DownListGroupItem extends BasicButton {
render() {
const o = this.options;
this.text = createWidget({
type: "bi.label",
type: Label.xtype,
cls: "list-group-item-text",
textAlign: "left",
text: o.text,
@ -48,12 +50,12 @@ export class DownListGroupItem extends BasicButton {
this.icon1 = createWidget({
width: 36,
height: o.height,
type: "bi.center_adapt",
type: CenterAdaptLayout.xtype,
items: [o.icon],
});
} else {
this.icon1 = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: o.iconCls1,
width: 36,
height: o.height,
@ -65,7 +67,7 @@ export class DownListGroupItem extends BasicButton {
}
this.icon2 = createWidget({
type: "bi.icon_button",
type: IconButton.xtype,
cls: o.iconCls2,
width: 24,
forceNotSelected: true,
@ -85,7 +87,7 @@ export class DownListGroupItem extends BasicButton {
);
return {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: [36, "fill", 24],
items: [this.icon1, this.text, this.icon2],
};
@ -94,7 +96,7 @@ export class DownListGroupItem extends BasicButton {
_getLevel() {
const child = first(this.options.childValues);
return isNotNull(child) ? (`${child}`).split(BlankSplitChar).length : 0;
return isNotNull(child) ? `${child}`.split(BlankSplitChar).length : 0;
}
_digest(v) {
@ -102,10 +104,9 @@ export class DownListGroupItem extends BasicButton {
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)
));
return any(v, (idx, value) =>
contains(o.childValues, `${value}`.split(BlankSplitChar).slice(0, level).join(BlankSplitChar))
);
}
hover() {

42
src/widget/downlist/popup.downlist.js

@ -1,4 +1,7 @@
import { ButtonTree, Pane } from "@/base";
import {
VerticalLayout,
Layout,
shortcut,
extend,
createWidget,
@ -13,7 +16,7 @@ import {
some,
deepClone
} from "@/core";
import { Pane, ButtonTree } from "@/base";
import { DownListGroup } from "./group.downlist";
@shortcut()
export class DownListPopup extends Pane {
@ -51,7 +54,7 @@ export class DownListPopup extends Pane {
const o = this.options,
children = this._createPopupItems(o.items);
this.popup = createWidget({
type: "bi.button_tree",
type: ButtonTree.xtype,
items: createItems(
children,
{},
@ -61,7 +64,7 @@ export class DownListPopup extends Pane {
),
layouts: [
{
type: "bi.vertical",
type: VerticalLayout.xtype,
hgap: this.constants.hgap,
vgap: this.constants.vgap,
}
@ -74,11 +77,7 @@ export class DownListPopup extends Pane {
let changedValue = value;
if (isNotNull(this.childValueMap[value])) {
changedValue = this.childValueMap[value];
this.fireEvent(
DownListPopup.EVENT_SON_VALUE_CHANGE,
changedValue,
this.fatherValueMap[value]
);
this.fireEvent(DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, this.fatherValueMap[value]);
} else {
this.fireEvent(DownListPopup.EVENT_CHANGE, changedValue, object);
}
@ -96,7 +95,7 @@ export class DownListPopup extends Pane {
});
createWidget({
type: "bi.vertical",
type: VerticalLayout.xtype,
element: this,
items: [this.popup],
vgap: 5,
@ -108,7 +107,7 @@ export class DownListPopup extends Pane {
// 不能修改populate进来的item的引用
each(items, (i, it) => {
const item_done = {
type: "bi.down_list_group",
type: DownListGroup.xtype,
items: [],
};
@ -130,17 +129,16 @@ export class DownListPopup extends Pane {
item.el.logic = {
dynamic: true,
};
item.el.height =
sourceItem.el.height || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT;
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",
type: ButtonTree.xtype,
chooseType: 0,
layouts: [
{
type: "bi.vertical",
type: VerticalLayout.xtype,
}
],
},
@ -172,11 +170,11 @@ export class DownListPopup extends Pane {
this.items.push(storeItem);
if (this._needSpliter(i, items.length)) {
const spliter_container = createWidget({
type: "bi.vertical",
type: VerticalLayout.xtype,
items: [
{
el: {
type: "bi.layout",
type: Layout.xtype,
cls: "bi-down-list-spliter bi-split-top cursor-pointer",
height: 0,
},
@ -211,10 +209,8 @@ export class DownListPopup extends Pane {
};
item.father = fatherValue;
item.childValue = item.value;
this.fatherValueMap[this._createChildValue(fatherValue, childValue)] =
fatherValue;
this.childValueMap[this._createChildValue(fatherValue, childValue)] =
childValue;
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);
@ -270,13 +266,15 @@ export class DownListPopup extends Pane {
function joinValue(sources, targets) {
let value = "";
some(sources, (idx, s) => some(targets, (id, t) => {
some(sources, (idx, s) =>
some(targets, (id, t) => {
if (s === t) {
value = s;
return true;
}
}));
})
);
return value;
}

61
src/widget/dynamicdate/dynamicdate.caculate.js

@ -1,4 +1,19 @@
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 = {
@ -13,36 +28,54 @@ export const DynamicDateHelper = {
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;
@ -62,7 +95,7 @@ export const DynamicDateHelper = {
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));
@ -99,19 +132,25 @@ export const DynamicDateHelper = {
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;

235
src/widget/dynamicdate/dynamicdate.card.js

@ -1,6 +1,27 @@
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()
@ -29,51 +50,65 @@ export class DynamicDateCard extends Widget {
this.position = DynamicDateCard.OFFSET.CURRENT;
return {
type: "bi.vertical",
items: [{
type: VerticalLayout.xtype,
items: [
{
el: {
type: "bi.label",
type: Label.xtype,
text: i18nText("BI-Multi_Date_Relative_Current_Time"),
textAlign: "left",
lgap: 10,
},
tgap: 10,
bgap: 5,
}, {
type: "bi.button_group",
},
{
type: ButtonGroup.xtype,
ref: _ref => {
this.checkgroup = _ref;
},
chooseType: ButtonGroup.CHOOSE_TYPE_MULTI,
lgap: 4,
value: [DynamicDateCard.TYPE.YEAR],
items: createItems([{
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",
}
],
{
type: MultiSelectItem.xtype,
logic: {
dynamic: true,
},
iconWrapperWidth: 26,
}),
layouts: [{
type: "bi.left",
}
),
layouts: [
{
type: FloatLeftLayout.xtype,
rgap: 4,
}],
listeners: [{
}
],
listeners: [
{
eventName: ButtonGroup.EVENT_CHANGE,
action: () => {
const value = this.checkgroup.getValue();
@ -91,7 +126,9 @@ export class DynamicDateCard extends Widget {
};
}
});
this.resultPane.populate(this._getParamJson(map(this.checkgroup.getValue(), (idx, v) => {
this.resultPane.populate(
this._getParamJson(
map(this.checkgroup.getValue(), (idx, v) => {
const obj = {
dateType: v,
};
@ -101,17 +138,22 @@ export class DynamicDateCard extends Widget {
}
return obj;
})));
})
)
);
this.position = DynamicDateCard.OFFSET.CURRENT;
this.fireEvent("EVENT_CHANGE");
},
}],
}, {
type: "bi.vertical_adapt",
}
],
},
{
type: VerticalAdaptLayout.xtype,
lgap: 2,
items: [{
items: [
{
el: {
type: "bi.multi_select_item",
type: MultiSelectItem.xtype,
iconWrapperWidth: 26,
ref: _ref => {
this.workDayBox = _ref;
@ -121,38 +163,53 @@ export class DynamicDateCard extends Widget {
},
text: i18nText("BI-Basic_Work_Day"),
value: DynamicDateCard.TYPE.WORK_DAY,
listeners: [{
listeners: [
{
eventName: MultiSelectItem.EVENT_CHANGE,
action: () => {
if (this.workDayBox.isSelected()) {
this.checkgroup.setValue();
}
this.resultPane.populate(this.workDayBox.isSelected() ? this._getParamJson([{
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;
},
}, {
type: "bi.button_group",
items: this._getParamJson([{
},
{
type: ButtonGroup.xtype,
items: this._getParamJson([
{
dateType: DynamicDateCard.TYPE.YEAR,
}]),
}
]),
ref: _ref => {
this.resultPane = _ref;
},
layouts: [{
type: "bi.vertical",
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: [{
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: [{
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: [{
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 [{
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 [{
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 [{
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 [{
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;
@ -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(),

130
src/widget/dynamicdate/dynamicdate.combo.js

@ -1,22 +1,34 @@
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;
@ -27,7 +39,7 @@ export class DynamicDateCombo extends Single {
comboAdjustHeight: 1,
border: 1,
iconWidth: 24,
}
};
props = {
baseCls: "bi-dynamic-date-combo",
@ -56,13 +68,14 @@ export class DynamicDateCombo extends Single {
const border = opts.simple ? 1 : 2;
return {
type: "bi.absolute",
items: [{
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: "bi.combo",
type: Combo.xtype,
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
container: opts.container,
ref: _ref => {
ref: (_ref) => {
this.combo = _ref;
},
toggle: false,
@ -70,21 +83,23 @@ export class DynamicDateCombo extends Single {
isNeedAdjustWidth: opts.isNeedAdjustWidth,
destroyWhenHide: true,
el: {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
items: [{
items: [
{
el: {
type: "bi.icon_button",
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
width: toPix(opts.height, border),
height: toPix(opts.height, border),
ref: _ref => {
ref: (_ref) => {
this.changeIcon = _ref;
},
},
}, {
type: "bi.dynamic_date_trigger",
},
{
type: DynamicDateTrigger.xtype,
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
@ -94,10 +109,11 @@ export class DynamicDateCombo extends Single {
iconWidth: toPix(opts.height, border),
height: toPix(opts.height, border),
value: opts.value,
ref: _ref => {
ref: (_ref) => {
this.trigger = _ref;
},
listeners: [{
listeners: [
{
eventName: DynamicDateTrigger.EVENT_KEY_DOWN,
action: (...args) => {
if (this.combo.isViewVisible()) {
@ -105,14 +121,16 @@ export class DynamicDateCombo extends Single {
}
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();
@ -121,12 +139,14 @@ export class DynamicDateCombo extends Single {
}
this.fireEvent(DynamicDateCombo.EVENT_FOCUS);
},
}, {
},
{
eventName: DynamicDateTrigger.EVENT_BLUR,
action: () => {
this.fireEvent(DynamicDateCombo.EVENT_BLUR);
},
}, {
},
{
eventName: DynamicDateTrigger.EVENT_ERROR,
action: () => {
this.storeValue = {
@ -139,19 +159,22 @@ export class DynamicDateCombo extends Single {
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;
@ -169,29 +192,33 @@ export class DynamicDateCombo extends Single {
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}],
}],
},
],
},
],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: "bi.dynamic_date_popup",
type: DynamicDatePopup.xtype,
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: _ref => {
ref: (_ref) => {
this.popup = _ref;
},
listeners: [{
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();
@ -206,7 +233,8 @@ export class DynamicDateCombo extends Single {
this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
@ -216,26 +244,30 @@ export class DynamicDateCombo extends Single {
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: [{
listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setMinDate(opts.minDate);
@ -243,13 +275,15 @@ export class DynamicDateCombo extends Single {
this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
},
],
},
top: 0,
left: 0,
right: 0,
bottom: 0,
}],
},
],
};
}
@ -291,9 +325,7 @@ export class DynamicDateCombo extends Single {
}
}
_defaultState() {
}
_defaultState() {}
setMinDate(minDate) {
const o = this.options;

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

@ -1,13 +1,14 @@
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 {
@ -26,10 +27,11 @@ export class DynamicDateParamItem extends Widget {
const o = this.options;
return {
type: "bi.htape",
items: [{
type: HTapeLayout.xtype,
items: [
{
el: {
type: "bi.sign_editor",
type: SignEditor.xtype,
cls: "bi-border bi-focus-shadow bi-border-radius",
height: toPix(BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT, 2),
validationChecker(v) {
@ -43,48 +45,59 @@ export class DynamicDateParamItem extends Widget {
return i18nText("BI-Please_Input_Natural_Number");
},
allowBlank: false,
listeners: [{
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
},
}, {
},
{
eventName: SignEditor.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_INPUT_CHANGE);
},
}],
}
],
},
width: 60,
}, {
},
{
el: {
type: "bi.label",
type: Label.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
text: this._getText(),
},
width: o.dateType === DynamicDateCard.TYPE.WORK_DAY ? 60 : 20,
}, {
type: "bi.text_value_combo",
},
{
type: TextValueCombo.xtype,
height: BI.SIZE_CONSANTS.TOOL_BAR_HEIGHT,
items: [{
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: [{
listeners: [
{
eventName: TextValueCombo.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateParamItem.EVENT_CHANGE);
},
}],
}],
}
],
}
],
};
}

130
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,27 +49,33 @@ export class DynamicDatePopup extends Widget {
};
createWidget({
element: this,
type: "bi.vertical",
items: [{
type: VerticalLayout.xtype,
items: [
{
el: this._getTabJson(),
}, {
},
{
el: {
type: "bi.grid",
type: GridLayout.xtype,
items: [
[{
type: "bi.text_button",
[
{
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: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
}
],
},
{
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),
@ -61,34 +84,42 @@ export class DynamicDatePopup extends Widget {
ref: _ref => {
this.todayButton = _ref;
},
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
}
],
},
{
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: [{
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);
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);
}
@ -97,7 +128,7 @@ export class DynamicDatePopup extends Widget {
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([{
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: [{
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this._setInnerValue(this.year, v);
},
}],
}
],
min: this.options.min,
max: this.options.max,
ref: _ref => {
@ -140,28 +179,32 @@ 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: [{
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: [{
listeners: [
{
eventName: Tab.EVENT_CHANGE,
action: () => {
const v = this.dateTab.getSelect();
@ -189,7 +232,8 @@ export class DynamicDatePopup extends Widget {
break;
}
},
}],
}
],
};
}

110
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,7 +68,7 @@ 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 => {
@ -57,11 +76,15 @@ export class DynamicDateTrigger extends Trigger {
const date = formatStr.match(/\d+/g);
!isKey(o.format) && this._autoAppend(v, date);
return this._dateCheck(formatStr) && checkDateLegal(formatStr) && this._checkVoid({
return (
this._dateCheck(formatStr) &&
checkDateLegal(formatStr) &&
this._checkVoid({
year: date[0] | 0,
month: date[1] | 0,
day: date[2] | 0,
});
})
);
},
quitChecker() {
return false;
@ -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,33 +170,39 @@ export class DynamicDateTrigger extends Trigger {
this.fireEvent(DynamicDateTrigger.EVENT_CHANGE);
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
columnSize: ["", this._const.iconWidth],
items: [{
items: [
{
el: this.editor,
}, {
},
{
el: {
type: "bi.icon_button",
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-font",
width: this._const.iconWidth,
},
width: this._const.iconWidth,
}],
}
],
});
!o.allowEdit && createWidget({
type: "bi.absolute",
!o.allowEdit &&
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [{
items: [
{
el: {
type: "bi.text",
type: Text.xtype,
title: bind(this._getTitle, this),
},
left: 0,
right: o.iconWidth,
top: 0,
bottom: 0,
}],
}
],
});
this.setValue(o.value);
}
@ -190,14 +222,14 @@ export class DynamicDateTrigger extends Trigger {
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) {
@ -288,8 +322,12 @@ export class DynamicDateTrigger extends Trigger {
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);
}

132
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,35 +68,38 @@ export class DynamicDateTimeCombo extends Single {
const border = opts.simple ? 1 : 2;
return {
type: "bi.absolute",
items: [{
type: AbsoluteLayout.xtype,
items: [
{
el: {
type: "bi.combo",
type: Combo.xtype,
cls: `${opts.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
destroyWhenHide: true,
container: opts.container,
ref: _ref => {
ref: (_ref) => {
this.combo = _ref;
},
toggle: false,
isNeedAdjustHeight: opts.isNeedAdjustHeight,
isNeedAdjustWidth: opts.isNeedAdjustWidth,
el: {
type: "bi.horizontal_fill",
type: HorizontalFillLayout.xtype,
columnSize: [this.constants.iconWidth, "fill"],
height: toPix(opts.height, border),
items: [{
items: [
{
el: {
type: "bi.icon_button",
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-change-h-font",
width: this.constants.iconWidth,
height: toPix(opts.height, border),
ref: _ref => {
ref: (_ref) => {
this.changeIcon = _ref;
},
},
}, {
type: "bi.dynamic_date_time_trigger",
},
{
type: DynamicDateTimeTrigger.xtype,
simple: opts.simple,
min: opts.minDate,
max: opts.maxDate,
@ -95,10 +109,11 @@ export class DynamicDateTimeCombo extends Single {
iconWidth: this.constants.iconWidth,
height: toPix(opts.height, border),
value: opts.value,
ref: _ref => {
ref: (_ref) => {
this.trigger = _ref;
},
listeners: [{
listeners: [
{
eventName: DynamicDateTimeTrigger.EVENT_KEY_DOWN,
action: (...args) => {
if (this.combo.isViewVisible()) {
@ -106,19 +121,22 @@ export class DynamicDateTimeCombo extends Single {
}
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();
@ -127,12 +145,14 @@ export class DynamicDateTimeCombo extends Single {
}
this.fireEvent(DynamicDateTimeCombo.EVENT_FOCUS);
},
}, {
},
{
eventName: DynamicDateTimeTrigger.EVENT_BLUR,
action: () => {
this.fireEvent(DynamicDateTimeCombo.EVENT_BLUR);
},
}, {
},
{
eventName: DynamicDateTimeTrigger.EVENT_ERROR,
action: () => {
this.storeValue = {
@ -145,19 +165,22 @@ export class DynamicDateTimeCombo extends Single {
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;
@ -175,29 +198,33 @@ export class DynamicDateTimeCombo extends Single {
this._checkDynamicValue(this.storeValue);
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
}],
}],
},
],
},
],
},
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: {
type: "bi.dynamic_date_time_popup",
type: DynamicDateTimePopup.xtype,
width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic,
behaviors: opts.behaviors,
min: opts.minDate,
max: opts.maxDate,
ref: _ref => {
ref: (_ref) => {
this.popup = _ref;
},
listeners: [{
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();
@ -215,7 +242,8 @@ export class DynamicDateTimeCombo extends Single {
this.combo.hideView();
this.fireEvent(DynamicDateTimeCombo.EVENT_CONFIRM);
},
}, {
},
{
eventName: DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
action: () => {
const value = this.popup.getValue();
@ -225,22 +253,26 @@ export class DynamicDateTimeCombo extends Single {
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: [{
listeners: [
{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.popup.setMinDate(opts.minDate);
@ -248,7 +280,8 @@ export class DynamicDateTimeCombo extends Single {
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;
@ -258,7 +291,8 @@ export class DynamicDateTimeCombo extends Single {
left: 0,
right: 0,
bottom: 0,
}],
},
],
};
}

146
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,27 +51,33 @@ export class DynamicDateTimePopup extends Widget {
};
createWidget({
element: this,
type: "bi.vertical",
items: [{
type: VerticalLayout.xtype,
items: [
{
el: this._getTabJson(),
}, {
},
{
el: {
type: "bi.grid",
type: GridLayout.xtype,
items: [
[{
type: "bi.text_button",
[
{
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: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
}
],
},
{
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,
@ -62,34 +86,42 @@ export class DynamicDateTimePopup extends Widget {
ref: _ref => {
this.todayButton = _ref;
},
listeners: [{
listeners: [
{
eventName: TextButton.EVENT_CHANGE,
action: () => {
this.fireEvent(DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE);
},
}],
}, {
type: "bi.text_button",
}
],
},
{
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: [{
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);
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);
}
@ -98,7 +130,7 @@ export class DynamicDateTimePopup extends Widget {
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([{
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: [{
listeners: [
{
eventName: "EVENT_CHANGE",
action: () => {
this._setInnerValue(this.year, v);
},
}],
}
],
ref: _ref => {
this.dynamicPane = _ref;
},
@ -141,35 +181,41 @@ export class DynamicDateTimePopup extends Widget {
case DynamicDateCombo.Static:
default:
return {
type: "bi.vertical",
items: [{
type: "bi.date_calendar_popup",
type: VerticalLayout.xtype,
items: [
{
type: DateCalendarPopup.xtype,
behaviors: o.behaviors,
min: this.options.min,
max: this.options.max,
ref: _ref => {
this.ymd = _ref;
},
listeners: [{
listeners: [
{
eventName: DateCalendarPopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW,
action: () => {
this.fireEvent(DynamicDateTimePopup.EVENT_BEFORE_YEAR_MONTH_POPUPVIEW);
},
}],
}, {
}
],
},
{
el: {
type: "bi.dynamic_date_time_select",
type: DynamicDateTimeSelect.xtype,
cls: "bi-split-top",
ref: _ref => {
this.timeSelect = _ref;
},
height: 40,
},
}],
}
],
};
}
},
listeners: [{
listeners: [
{
eventName: Tab.EVENT_CHANGE,
action: () => {
const v = this.dateTab.getSelect();
@ -197,7 +243,8 @@ export class DynamicDateTimePopup extends Widget {
break;
}
},
}],
}
],
};
}
@ -279,7 +326,10 @@ export class DynamicDateTimePopup extends Widget {
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(),
};
}
}

97
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,12 +30,14 @@ export class DynamicDateTimeSelect extends Widget {
render() {
return {
type: "bi.center_adapt",
items: [{
type: "bi.vertical_adapt",
items: [{
type: CenterAdaptLayout.xtype,
items: [
{
type: VerticalAdaptLayout.xtype,
items: [
{
el: {
type: "bi.number_editor",
type: NumberEditor.xtype,
ref: _ref => {
this.hour = _ref;
},
@ -36,7 +51,8 @@ export class DynamicDateTimeSelect extends Widget {
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [{
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.hour.getValue();
@ -44,22 +60,29 @@ export class DynamicDateTimeSelect extends Widget {
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);
const value = this._autoSwitch(
this.hour.getValue(),
DynamicDateTimeSelect.HOUR
);
this.hour.setValue(value);
},
}],
}
],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
},
}, {
type: "bi.label",
},
{
type: Label.xtype,
text: ":",
width: 20,
}, {
type: "bi.number_editor",
},
{
type: NumberEditor.xtype,
ref: _ref => {
this.minute = _ref;
},
@ -73,29 +96,37 @@ export class DynamicDateTimeSelect extends Widget {
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [{
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.minute.getValue();
this._checkMinute(value);
this.minute.setValue(this._formatValueToDoubleDigit(value), DynamicDateTimeSelect.MINUTE);
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,
}, {
type: "bi.label",
},
{
type: Label.xtype,
text: ":",
width: 20,
}, {
type: "bi.number_editor",
},
{
type: NumberEditor.xtype,
ref: _ref => {
this.second = _ref;
},
@ -109,7 +140,8 @@ export class DynamicDateTimeSelect extends Widget {
return i18nText("BI-Numerical_Interval_Input_Data");
},
listeners: [{
listeners: [
{
eventName: SignEditor.EVENT_CONFIRM,
action: () => {
const value = this.second.getValue();
@ -117,11 +149,14 @@ export class DynamicDateTimeSelect extends Widget {
this.second.setValue(this._formatValueToDoubleDigit(value));
this.fireEvent(DynamicDateTimeSelect.EVENT_CONFIRM);
},
}],
}
],
width: 60,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
}],
}],
}
],
}
],
};
}

165
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,7 +70,7 @@ 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 => {
@ -55,11 +78,15 @@ export class DynamicDateTimeTrigger extends Trigger {
const date = formatStr.match(/\d+/g);
!isKey(o.format) && this._autoAppend(v, date);
return this._dateCheck(formatStr) && checkDateLegal(formatStr) && this._checkVoid({
return (
this._dateCheck(formatStr) &&
checkDateLegal(formatStr) &&
this._checkVoid({
year: date[0] | 0,
month: date[1] | 0,
day: date[2] | 0,
});
})
);
},
quitChecker() {
return false;
@ -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,33 +170,39 @@ export class DynamicDateTimeTrigger extends Trigger {
this.fireEvent(DynamicDateTimeTrigger.EVENT_CHANGE);
});
createWidget({
type: "bi.htape",
type: HTapeLayout.xtype,
element: this,
columnSize: ["", this._const.iconWidth],
items: [{
items: [
{
el: this.editor,
}, {
},
{
el: {
type: "bi.icon_button",
type: IconButton.xtype,
cls: "bi-trigger-icon-button date-font",
},
width: o.iconWidth,
}],
}
],
});
!o.allowEdit && createWidget({
type: "bi.absolute",
!o.allowEdit &&
createWidget({
type: AbsoluteLayout.xtype,
element: this,
items: [{
items: [
{
el: {
type: "bi.text",
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()
);
}
}
@ -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) {
@ -305,8 +351,12 @@ export class DynamicDateTimeTrigger extends Trigger {
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,36 +370,54 @@ 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;
@ -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);
}

65
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,7 +87,8 @@ export class SearchEditor extends Widget {
element: this,
height: toPix(o.height, o.simple ? 1 : 2),
type: HTapeLayout.xtype,
items: [{
items: [
{
el: {
type: IconLabel.xtype,
cls: "search-font",
@ -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);
});

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

@ -3,7 +3,7 @@ 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);

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

@ -3,26 +3,26 @@ import { Editor } from "@/base";
@shortcut()
export class TextEditor extends Widget {
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 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";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
@ -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);

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

@ -3,7 +3,7 @@ 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);

135
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) {
@ -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 {
@ -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
)
);
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 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) {
@ -563,13 +519,9 @@ export class IntervalSlider extends Single {
_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");
}
}
@ -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);

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

@ -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;
@ -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 {
// 否则借位
@ -127,23 +115,15 @@ 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);
@ -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,17 +176,13 @@ 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);

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();
});

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

@ -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,
@ -294,13 +294,15 @@ export class MultiLayerDownListPopup extends Pane {
function joinValue(sources, targets) {
let value = "";
some(sources, (idx, s) => some(targets, (id, t) => {
some(sources, (idx, s) =>
some(targets, (id, t) => {
if (s === t) {
value = s;
return true;
}
}));
})
);
return value;
}
@ -359,7 +361,7 @@ 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;

76
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);
},
}
],
@ -260,8 +227,7 @@ export class MultiLayerSelectTreeCombo extends Widget {
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return o.container &&
self.trigger.getSearcher().isSearching() &&
self.trigger.getSearcher().getView().element.find(e.target)
.length > 0
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() {

26
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);
@ -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) {

66
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);
},
}
],
@ -251,8 +222,7 @@ export class MultiLayerSingleTreeCombo extends Widget {
// 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪
return o.container &&
self.trigger.getSearcher().isSearching() &&
self.trigger.getSearcher().getView().element.find(e.target)
.length > 0
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() {

21
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);
@ -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";

16
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";
@ -70,12 +63,9 @@ 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() {

22
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,9 +103,7 @@ export class MultiSelectInnerLoader extends Widget {
],
value: o.value,
});
this.button_group.on(
Controller.EVENT_CHANGE,
function (type, value, obj) {
this.button_group.on(Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === Events.CLICK) {
const node = self.cachGroup.getNodeByValue(value);
if (node) {
@ -116,8 +114,7 @@ export class MultiSelectInnerLoader extends Widget {
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
)
@ -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);
}
}

72
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,9 +125,7 @@ export class MultiSelectCombo extends Single {
self._setStartValue("");
self.fireEvent(MultiSelectCombo.EVENT_STOP);
});
this.trigger.on(
MultiSelectTrigger.EVENT_SEARCHING,
keywords => {
this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, (keywords) => {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
@ -145,8 +143,7 @@ export class MultiSelectCombo extends Single {
});
}
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,
() => {
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,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
});
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,
() => {
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];
}
});

62
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,9 +128,7 @@ export class MultiSelectNoBarCombo extends Single {
self.fireEvent(MultiSelectNoBarCombo.EVENT_STOP);
});
this.trigger.on(
MultiSelectTrigger.EVENT_SEARCHING,
keywords => {
this.trigger.on(MultiSelectTrigger.EVENT_SEARCHING, keywords => {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
@ -145,8 +145,7 @@ export class MultiSelectNoBarCombo extends Single {
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,
() => {
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,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
});
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,
() => {
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];
}
});

95
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,14 +130,9 @@ 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) {
this.trigger.on(MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
@ -151,18 +149,12 @@ export class MultiSelectInsertCombo extends Single {
self._dataChange = true;
});
this.getSearcher().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"));
}
self.fireEvent(MultiSelectInsertCombo.EVENT_SEARCHING);
}
);
});
this.trigger.on(
MultiSelectInsertTrigger.EVENT_CHANGE,
function (value, obj) {
this.trigger.on(MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
@ -175,24 +167,17 @@ export class MultiSelectInsertCombo extends Single {
});
}
self._dataChange = true;
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
() => {
});
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,
() => {
});
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,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
});
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,
() => {
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];
}
});

83
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,14 +119,9 @@ 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) {
this.trigger.on(MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
const lastKeyword = last(keywords);
keywords = initial(keywords || []);
if (keywords.length > 0) {
@ -140,17 +138,11 @@ export class MultiSelectInsertNoBarCombo extends Single {
self._dataChange = true;
});
this.getSearcher().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"));
}
}
);
});
this.trigger.on(
MultiSelectInsertTrigger.EVENT_CHANGE,
function (value, obj) {
this.trigger.on(MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof MultiSelectBar) {
self._joinAll(this.getValue(), () => {
assertShowValue();
@ -161,24 +153,17 @@ export class MultiSelectInsertNoBarCombo extends Single {
});
}
self._dataChange = true;
}
);
this.trigger.on(
MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,
() => {
});
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,
() => {
});
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,
() => {
this.numberCounter.on(MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, () => {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
}
);
this.numberCounter.on(
MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,
function () {
});
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,
() => {
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];
}
});

22
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);
});

46
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(
@ -76,8 +77,7 @@ export class MultiSelectLoader extends Widget {
self.storeValue &&
(op = extend(op || {}, {
selectedValues:
isKey(startValue) &&
self.storeValue.type === Selection.Multi
isKey(startValue) && self.storeValue.type === Selection.Multi
? self.storeValue.value.concat(startValue)
: self.storeValue.value,
}));
@ -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
));
: 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,

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

@ -83,42 +83,26 @@ export class MultiSelectNoBarLoader extends Widget {
self.storeValue &&
(op = extend(op || {}, {
selectedValues:
isKey(startValue) &&
self.storeValue.type === Selection.Multi
? self.storeValue.value.concat(
startValue
)
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 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,
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,
@ -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
));
? 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() {}
}

20
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 => {
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
);
self.fireEvent(MultiSelectPopupView.EVENT_CLICK_CONFIRM);
break;
default:
break;
}
}
);
});
}
isAllSelected() {

24
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 => {
this.popupView.on(MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, index => {
switch (index) {
case 0:
self.fireEvent(
MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR
);
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR);
break;
case 1:
self.fireEvent(
MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM
);
self.fireEvent(MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM);
break;
}
}
);
});
}
setStartValue(v) {

11
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";

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() {

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

@ -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);

41
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";
@ -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,16 +194,12 @@ 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"
)
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() {

41
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";
@ -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,16 +196,12 @@ 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"
)
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() {

18
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";
@ -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