| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- Ext.define('saas.view.sys.invitation.DataList', {
- extend: 'Ext.grid.Panel',
- xtype: 'sys-invitation-datalist',
- controller: 'sys-invitation-datalist',
- viewModel: 'sys-invitation-datalist',
- autoScroll: true,
- frame:true,
- layout:'fit',
- dataUrl:'/api/commons/remind/apply/list',
-
- plugins: [{
- ptype: 'cellediting',
- clicksToEdit: 1
- }, {
- ptype: 'menuclipboard'
- }],
- tbar: [{
- width: 110,
- name: 're_applyname',
- xtype: 'textfield',
- emptyText : '姓名',
- enableKeyEvents: true,
- listeners: {
- keydown: {
- fn: function(th, e, eOpts) {
- if(e.keyCode == 13) {
- var grid = th.up('grid');
- grid.condition = grid.getConditions();
- grid.store.loadPage(1);
- }
- }
- }
- }
- },{
- width: 140,
- name: 're_status',
- emptyText : '批准状态',
- xtype: 'combobox',
- queryMode: 'local',
- displayField: 'display',
- valueField: 'value',
- editable:false,
- store: Ext.create('Ext.data.ArrayStore', {
- fields: ['display', 'value'],
- data: [
- ["全部", "ALL"],
- ["待批准", "2"],
- ["已批准", "1"],
- ["未批准", "0"]
- ]
- }),
- getCondition: function(value) {
- if(value == 'ALL') {
- return '1=1';
- }else {
- return 're_status=\'' + value + '\'';
- }
- },
- enableKeyEvents: true,
- listeners: {
- keydown: {
- fn: function(th, e, eOpts) {
- if(e.keyCode == 13) {
- var grid = th.up('grid');
- grid.condition = grid.getConditions();
- grid.store.loadPage(1);
- }
- }
- }
- }
- },{
- xtype:'button',
- text:'查询',
- listeners: {
- click:function(b){
- var grid = b.ownerCt.ownerCt;
- grid.condition = grid.getConditions();
- grid.store.loadPage(1);
- }
- }
- },'->',{
- xtype:'button',
- text:'刷新',
- listeners: {
- click: 'onRefresh'
- }
- }],
- columns : [{
- text : '批准',
- dataIndex : 'status',
- width:110,
- renderer:function(v,atr,rec,index){
- var grid = this;
- if(typeof(window.showWin)!='function'){
- window.showWin = function(x){
- var record = grid.store.getAt(x);
- grid.dialog = grid.add({
- xtype: 'sys-invitation-editwindow',
- bind: {
- title: '批准信息'
- },
- _parent:grid,
- record:record,
- session: true
- });
- grid.dialog.show();
- }
- }
- if(typeof(window.disagree)!='function'){
- window.disagree = function(x){
- grid.setLoading(true);
- var record = grid.store.getAt(x);
- var _params = {
- id:Number(record.get('id')),
- status:0,
- mobile:record.get('mobile')
- };
- saas.util.BaseUtil.request({
- url: '/api/commons/remind/apply/confirm',
- params: JSON.stringify(_params),
- method: 'POST',
- })
- .then(function(localJson) {
- grid.setLoading(false);
- if(localJson.success){
- saas.util.BaseUtil.showSuccessToast('保存成功');
- grid.store.load();
- }
- })
- .catch(function(e) {
- grid.setLoading(false);
- saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message);
- });
- }
- }
- if(v&&v!=''){
- if(v=='2'){
- return "<input type='button' value='批准' style='padding:2px;color:white;font-size:13px;cursor:pointer;height:22px;background-color: #35baf6;border-color: #35baf6;display: inline-block;cursor: pointer;text-align: center;border-radius: 3px;border: 1px solid transparent;' onClick='window.showWin(\""+index+"\")'></input>"+"<span style='font-size: 19px;'> | </span>"+
- "<input type='button' value='不批准' style='padding:2px;color:white;font-size:13px;cursor:pointer;height:22px;background-color: #35baf6;border-color: #35baf6;display: inline-block;cursor: pointer;text-align: center;border-radius: 3px;border: 1px solid transparent;' onClick='window.disagree(\""+index+"\")'></input>";
- }else if(v=='1'){
- return '已批准';
- }else if(v=='0'){
- return '未批准'
- }
- }
- return v;
- }
- },{
- text : 'id',
- hidden:true,
- dataIndex : 'id',
- xtype : 'numbercolumn',
- },{
- text : 'accountId',
- hidden:true,
- dataIndex : 'accountId',
- xtype : 'numbercolumn',
- },{
- text : '姓名',
- width : 90.0,
- dataIndex : 'username',
- },{
- text : '手机号码',
- dataIndex : 'mobile',
- width : 150.0,
- },{
- text : '岗位角色id',
- hidden:true,
- dataIndex : 'roles'
- },{
- text : '岗位角色',
- dataIndex : 'roleNames',
- width : 220.0,
- }],
- dbSearchFields: [],
- condition:'',
- initComponent: function() {
- var me = this;
- if(me.columns){
- var fields = me.columns.map(column => column.dataIndex);
- me.store = Ext.create('Ext.data.Store',{
- fields:fields,
- autoLoad: true,
- pageSize: 11,
- data: [],
- proxy: {
- timeout:8000,
- type: 'ajax',
- url: me.dataUrl,
- actionMethods: {
- read: 'GET'
- },
- reader: {
- type: 'json',
- rootProperty: 'data.list',
- totalProperty: 'data.total',
- },
- listeners: {
- exception: function(proxy, response, operation, eOpts) {
- if(operation.success) {
- if(response.timedout) {
- saas.util.BaseUtil.showErrorToast('请求超时');
- }
- }else {
- if(response.timedout) {
- saas.util.BaseUtil.showErrorToast('请求超时');
- }else{
- if(proxy.showPowerMessage){
- saas.util.BaseUtil.showErrorToast('查询失败:' + (response.responseJson?response.responseJson.message:'请求超时'));
- }
- }
- }
- }
- }
- },
- listeners: {
- beforeload: function (store, op) {
- var condition = me.condition;
- if (Ext.isEmpty(condition)) {
- condition = [];
- }
- var _localStorage = Ext.decode(sessionStorage.getItem('app-state-session'));
- var nowCompanyId = _localStorage.account.companyId;
- condition.push({
- type:'condition',
- value:"companyId="+nowCompanyId
- });
- Ext.apply(store.proxy.extraParams, {
- number: op._page,
- size: store.pageSize,
- condition: JSON.stringify(condition)
- });
- }
- }
- });
- Ext.apply(me, {
- dockedItems:[{
- xtype: 'pagingtoolbar',
- dock: 'bottom',
- displayInfo: true,
- store: me.store
- }]
- });
- }
- me.callParent(arguments);
- },
- listeners:{
- boxready: function(grid, width, height, eOpts) {
- var store = grid.getStore(),
- gridBodyBox = grid.body.dom.getBoundingClientRect(),
- gridBodyBoxHeight = gridBodyBox.height;
- var pageSize = Math.floor(gridBodyBoxHeight / 35);
- store.setPageSize(pageSize);
- }
- },
- getGridSelected:function(type){
- var isErrorSelect = false;
- var checkField = this.statusCodeField;
- var me = this,
- items = me.selModel.getSelection(),
- data = new Array() ;
- Ext.each(items, function(item, index){
- if(!Ext.isEmpty(item.data[me.idField])){
- var o = new Object();
- if(me.idField){
- o['id'] = item.data[me.idField];
- }
- if(me.codeField){
- o['code'] = item.data[me.codeField];
- }
- if(type&&type==item.data[checkField]){
- isErrorSelect = true
- }
- data.push(o);
- }
- });
- if(isErrorSelect){
- return false;
- }
- return data;
- },
- /**
- * 获得过滤条件
- */
- getConditions: function() {
- var me = this,
- tbar = me.getDockedItems()[0],
- items = Ext.Array.filter(tbar.items.items, function(item) {
- return !!item.name;
- }),
- conditions = [];
- for(var i = 0; i < items.length; i++) {
- var item = items[i];
- var field = item.name,
- func = item.getCondition,
- value = item.value,
- condition;
- if(value&&value!=''){
- if(typeof func == 'function') {
- condition = {
- type: 'condition',
- value: func(value)
- }
- }else {
- var type = item.fieldType || me.getDefaultFieldType(item),
- operation = item.operation || me.getDefaultFieldOperation(item),
- conditionValue = me.getConditionValue(item, value);
-
- if(!conditionValue) {
- continue;
- }
- condition = {
- type: type,
- field: field,
- operation: operation,
- value: conditionValue
- }
- }
- conditions.push(condition);
- }
- }
- return conditions;
- },
- /**
- * 只要arr1和arr2中存在相同项即返回真
- */
- isContainsAny: function (arr1, arr2) {
- for (var i = 0; i < arr2.length; i++) {
- var a2 = arr2[i];
- if (!!arr1.find(function (a1) {
- return a1 == a2
- })) {
- return true;
- }
- }
- return false;
- },
- getDefaultFieldType: function (field) {
- var me = this,
- xtypes = field.getXTypes().split('/'),
- type;
- if (me.isContainsAny(xtypes, ['numberfield'])) {
- type = 'number';
- } else if (me.isContainsAny(xtypes, ['datefield', 'condatefield', 'conmonthfield'])) {
- type = 'date';
- } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
- type = 'enum';
- } else if (me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
- type = 'enum';
- } else {
- type = 'string';
- }
- return type;
- },
- getDefaultFieldOperation: function (field) {
- var me = this,
- xtypes = field.getXTypes().split('/'),
- operation;
- if (me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
- operation = '=';
- } else if (me.isContainsAny(xtypes, ['condatefield', 'conmonthfield'])) {
- operation = 'between';
- } else if (me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
- operation = 'in';
- } else {
- operation = 'like';
- }
- return operation;
- },
- /**
- * 处理部分字段值
- */
- getConditionValue: function (field, value) {
- var me = this,
- xtypes = field.getXTypes().split('/'),
- conditionValue;
- if (me.isContainsAny(xtypes, ['datefield'])) {
- conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
- } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
- var from = value.from,
- to = value.to;
- conditionValue = from + ',' + to;
- } else if (me.isContainsAny(xtypes, ['condatefield'])) {
- var from = value.from,
- to = value.to;
- conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
- } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
- conditionValue = value;
- } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
- conditionValue = '\'' + value + '\'';
- } else if (me.isContainsAny(xtypes, ['multicombo'])) {
- conditionValue = value.map ? value.map(function (v) {
- return '\'' + v.value + '\'';
- }).join(',') : '';
- } else {
- conditionValue = value;
- }
- return conditionValue;
- }
- })
|