|
|
@@ -2,9 +2,15 @@
|
|
|
* Created by zhouy on 2018/10/17.
|
|
|
*/
|
|
|
Ext.define('saas.view.core.form.DataMultiCombo', {
|
|
|
- extend: 'Ext.form.field.Trigger',
|
|
|
+ extend: 'Ext.form.field.Tag',
|
|
|
alias: 'widget.datamulticombo',
|
|
|
- editable : false,
|
|
|
+ displayField: 'display',
|
|
|
+ valueField: 'value',
|
|
|
+ createNewOnEnter: true,
|
|
|
+ createNewOnBlur: true,
|
|
|
+ filterPickList: true,
|
|
|
+ queryMode: 'local',
|
|
|
+ publishes: 'value',
|
|
|
matchFieldWidth: true,
|
|
|
autoScroll:true,
|
|
|
value: [],
|
|
|
@@ -36,167 +42,19 @@ Ext.define('saas.view.core.form.DataMultiCombo', {
|
|
|
datas.push(o);
|
|
|
});
|
|
|
}else{
|
|
|
- saas.util.BaseUtil.showErrorToast('下拉框读取数据为空!');
|
|
|
+ saas.util.BaseUtil.showErrorToast('岗位数据为空,请维护角色列表!');
|
|
|
}
|
|
|
me.datas = datas;
|
|
|
+ me.store=Ext.create('Ext.data.Store', {
|
|
|
+ fields: ['display','value'],
|
|
|
+ data : datas
|
|
|
+ });
|
|
|
},
|
|
|
failure: function (response, opts) {
|
|
|
- saas.util.BaseUtil.showErrorToast('上传失败: ' + response.responseText);
|
|
|
+ saas.util.BaseUtil.showErrorToast('读取岗位失败: ' + response.responseText);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
me.callParent(arguments);
|
|
|
- },
|
|
|
- listeners:{
|
|
|
- afterrender:function(f){
|
|
|
- // this.mon(f.el,{
|
|
|
- // mouseover: this.onMouseOver,
|
|
|
- // mouseleave:this.onMouseLeave,
|
|
|
- // scope:this
|
|
|
- // });
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- onMouseOver:function(){
|
|
|
- this.showMenu();
|
|
|
- },
|
|
|
- onMouseLeave:function(a,b,c){
|
|
|
- this.hideMenu(a.parentEvent?a:b);//el光标离开第二个参数为Event对象
|
|
|
- },
|
|
|
- onTriggerClick:function(){
|
|
|
- this.showMenu();
|
|
|
- },
|
|
|
- getMenu: function() {
|
|
|
- var me = this;
|
|
|
-
|
|
|
- if (!me.menu) {
|
|
|
-
|
|
|
- me.menu = Ext.create('Ext.menu.Menu',{
|
|
|
- style:'max-height: 195px;overflow-y:scroll;',
|
|
|
- hideOnParentHide: false,
|
|
|
- items: me.getMenuItems(),
|
|
|
- listeners:{
|
|
|
- mouseleave:me.onMouseLeave,
|
|
|
- scope:me,
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- return me.menu;
|
|
|
- },
|
|
|
- getMenuItems:function(){
|
|
|
- var me = this,
|
|
|
- i = 0,
|
|
|
- item,
|
|
|
- items = me.datas,
|
|
|
- itemsLn = me.datas.length,
|
|
|
- menuItems = [],
|
|
|
- value = me.value;
|
|
|
- if(value=='') value = []
|
|
|
- for (; i < itemsLn; i++) {
|
|
|
- item = items[i];
|
|
|
- var checked = !!value.find(function(v) {
|
|
|
- return v.value == item[1];
|
|
|
- });
|
|
|
- menuItem = new Ext.menu.CheckItem({
|
|
|
- text: item[0],
|
|
|
- checked: checked,
|
|
|
- checkValue:item[1],
|
|
|
- hideOnClick: false,
|
|
|
- checkHandler: this.onCheckChange,
|
|
|
- scope: this
|
|
|
- });
|
|
|
- menuItems.push(menuItem);
|
|
|
- }
|
|
|
- return menuItems.length ? menuItems : null;
|
|
|
- },
|
|
|
- onCheckChange:function(checkItem, checked){
|
|
|
- var items=this.menu.items.items,
|
|
|
- checkedItems = [];
|
|
|
- Ext.Array.each(items,function(item){
|
|
|
- if(item.checked){
|
|
|
- checkedItems.push({
|
|
|
- text: item.text,
|
|
|
- value: item.checkValue
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- this.setValue(checkedItems);
|
|
|
- },
|
|
|
-
|
|
|
- setValue: function(items) {
|
|
|
- var me = this, rawV = '',
|
|
|
- datas = me.datas,
|
|
|
- menu = me.menu,
|
|
|
- items = items==null?[]:items;
|
|
|
- if(!Ext.isArray(items)) {
|
|
|
- if(items&&items.indexOf(',')>0){
|
|
|
- items = items.split(',')
|
|
|
- }else{
|
|
|
- items = [items]
|
|
|
- }
|
|
|
- }
|
|
|
- items.map(function(item, index) {
|
|
|
- if(Ext.isString(item)) {
|
|
|
- var data = datas.find(function(d) {
|
|
|
- return d[0] == item;
|
|
|
- });
|
|
|
- items[index] = {
|
|
|
- text: data[0],
|
|
|
- value: data[1]
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- rawV = items.map(function(item) {
|
|
|
- return item.text
|
|
|
- }).join(',');
|
|
|
- this.setRawValue(rawV);
|
|
|
- this.value = items;
|
|
|
- if(menu) {
|
|
|
- Ext.Array.each(menu.items.items, function(item) {
|
|
|
- item.setChecked(!!items.find(function(i) {
|
|
|
- return i.value == item.checkValue;
|
|
|
- }));
|
|
|
- });
|
|
|
- }
|
|
|
- this.publishState('value', items);
|
|
|
- },
|
|
|
-
|
|
|
- showMenu: function (e, menu) {
|
|
|
- menu = menu || this.getMenu();
|
|
|
- /**
|
|
|
- * menu上边框样式待处理
|
|
|
- * */
|
|
|
- if (menu) {
|
|
|
- if (menu.isVisible()) {
|
|
|
- menu.focus();
|
|
|
- } else {
|
|
|
- menu.autoFocus = true;
|
|
|
- if(this.matchFieldWidth){
|
|
|
- menu.setWidth(this.bodyEl.getWidth());
|
|
|
- }
|
|
|
- if (menu.isMenu) {
|
|
|
- menu.showBy(this.inputEl, this.getMenuAlign(),[-1, 0]);
|
|
|
- } else if (menu.isViewportMenu) {
|
|
|
- menu.setDisplayed(!menu.getDisplayed());
|
|
|
- } else {
|
|
|
- menu.show();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- hideMenu: function(b) {
|
|
|
- if (this.hasVisibleMenu()) {
|
|
|
- var target=b.parentEvent.relatedTarget;
|
|
|
- if(target){
|
|
|
- if(!((target.className && target.className.indexOf('x-menu')!=-1) || (target.name && target.name.indexOf(this.name)!=-1))){
|
|
|
- this.menu.hide();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return this;
|
|
|
- },
|
|
|
- hasVisibleMenu: function() {
|
|
|
- var menu = this.menu;
|
|
|
- return menu && menu.rendered && menu.isVisible();
|
|
|
}
|
|
|
});
|