| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- /**
- * Created by zhouy on 2018/10/18.
- */
- Ext.define('saas.view.sys.account.AddWindow', {
- extend: 'saas.view.document.kind.ChildForm',
- xtype: 'sys-account-addwindow',
- dataKind:'accountadd',//类型标识
- height: 325,
- belong:{
- columns:[{
- dataIndex:'realname',
- },{
- dataIndex: 'mobile',
- },{
- dataIndex: 'email',
- }],
- reqUrl: '/api/account/account/register/add',
- },
- etc:{
- accountadd:{
- items:[{
- xtype: 'fieldcontainer',
- layout: 'column',
- items: [{
- beforeLabelTextTpl: "<font color=\"red\" style=\"position:relative; top:2px;right:2px; font-weight: bolder;\">*</font>",
- xtype:'textfield',
- fieldLabel: '手机号码',
- name: 'mobile',
- hideTrigger:true,
- allowBlank:false,
- maxLength: 30,
- columnWidth:0.7,
- regex:/^1(3|4|5|7|8|9)\d{9}$/,
- regexText:'请输入正确的手机号码',
- listeners:{
- change:function(f,a,b){
- if(a==''){
- f._lastCheckValue = ''
- }
- },
- blur:function(f,a,b,c){
- var form = f.ownerCt;
- if(f.value&&f.value!=''&&f.isValid()&&f._lastCheckValue!=f.value){
- f._lastCheckValue = f.value;
- form.setLoading(true);
- Ext.Ajax.request({
- url: '/api/account/account/checkMobile?mobile='+f.value,
- method: 'GET',
- headers:{
- 'Access-Control-Allow-Origin': '*',
- "Content-Type": 'application/json;charset=UTF-8',
- },
- success: function (response) {
- form.setLoading(false);
- var localJson = Ext.decode(response.responseText);
- if(localJson.success){
- f.hasRegister = localJson.data.hasRegister;
- if(localJson.data.hasRegister){
- f.ownerCt.down('[name=hasAccount]').show();
- f.ownerCt.down('[name=noAccount]').hide();
- }else{
- f.ownerCt.down('[name=hasAccount]').hide();
- f.ownerCt.down('[name=noAccount]').show();
- }
- }else{
- saas.util.BaseUtil.showErrorToast('校验失败:'+localJson.message);
- f.setValue('');
- f.ownerCt.down('[name=hasAccount]').hide();
- f.ownerCt.down('[name=noAccount]').hide();
- }
- },
- failure: function (response) {
- if(response.responseText){
- var localJson = Ext.decode(response.responseText);
- saas.util.BaseUtil.showErrorToast('校验失败:'+localJson.message);
- f.setValue('');
- }else{
- saas.util.BaseUtil.showErrorToast('手机号校验接口连接超时');
- f.setValue('');
- }
- }
- });
- }
- }
- }
- },{
- hidden:true,
- name:'hasAccount',
- xtype:'button',
- cls:'x-btn-showicon',
- style:'background:#fff;border:none;padding:7px 0 7px 0;',
- text:'已注册优软云',
- icon:'resources/images/default/toast_over.png',
- columnWidth:0.3,
- },{
- name:'noAccount',
- hidden:true,
- xtype:'button',
- cls:'x-btn-showicon',
- style:'background:#fff;border:none;padding:7px 0 7px 0;',
- text:'未注册优软云',
- icon:'resources/images/default/toast_close.png',
- columnWidth:0.3,
- }]
- },{
- xtype:'textfield',
- fieldLabel: '真实姓名',
- name: 'realname',
- // regex:/^[\u4e00-\u9fa5]+$/,
- // regexText:'请输入汉字',
- allowBlank:false,
- maxLength: 30,
- columnWidth:0.5
- },{
- xtype:'textfield',
- fieldLabel: '邮箱',
- name: 'email',
- allowBlank:true,
- beforeLabelTextTpl: "",
- regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
- regexText:'请输入正确的邮箱',
- maxLength: 30,
- listeners:{
- blur:function(f,a,b,c){
- var form = f.ownerCt;
- if(f.value&&f.value!=''&&f.isValid()&&f._lastCheckValue!=f.value){
- form.setLoading(true);
- Ext.Ajax.request({
- url: '/api/account/account/checkEmail?email='+f.value,
- method: 'GET',
- headers:{
- 'Access-Control-Allow-Origin': '*',
- "Content-Type": 'application/json;charset=UTF-8'
- },
- success: function (response) {
- form.setLoading(false);
- var localJson = Ext.decode(response.responseText);
- if(localJson.success){
- if(!localJson.data){
- f._lastCheckValue = f.value;
- saas.util.BaseUtil.showSuccessToast('校验成功:邮箱未注册');
- }else{
- saas.util.BaseUtil.showErrorToast('校验失败:该邮箱已被注册');
- f.setValue('');
- }
- }else{
- saas.util.BaseUtil.showErrorToast('校验失败:'+localJson.message);
- }
- },
- failure: function (response) {
- if(response.responseText){
- var localJson = Ext.decode(response.responseText);
- saas.util.BaseUtil.showErrorToast('校验失败:'+localJson.message);
- }else{
- saas.util.BaseUtil.showErrorToast('邮箱校验接口连接超时');
- }
- }
- });
- }
- }
- }
- },{
- xtype:'datamulticombo',
- dataUrl:'/api/account/role/list',
- fieldLabel: '岗位角色',
- name: 'roleIds',
- allowBlank:false,
- },{
- margin:'5 0 0 0',
- xtype:'displayfield',
- fieldLabel: '注意事项',
- beforeLabelTextTpl: "",
- value:'添加的账户拥有访问系统的权限,请勿随意添加',
- fieldStyle:'color:#999;margin-top: 9px;',
- lableStyle:'color: #f16161;'
- }]
- }
- },
- onSave:function(){
- var me = this;
- var belong = this.belong;
- me.setLoading(true);
- var form=this.down('form');
- var params = {};
- var names = belong.columns.map(column => column.dataIndex);
- Ext.Array.each(names,function(name) {
- if(name){
- var dataField = form.down('[name='+name+']');
- if(dataField&&dataField.value){
- params[name] = dataField.value;
- }
- if(dataField.name=='mobile'){
- params['hasRegister'] = dataField.hasRegister;
- }
- }
- });
- //更改参数
- var o = '';
- var dataField = form.down('[name=roleIds]');
- Ext.Array.each(dataField.value,function(item) {
- o+=item+','
- });
- o = o.substring(0,o.length-1);
- params['username'] = params['mobile'];
- params['type'] = 1;
- params['roleIds'] = o;
- //保存接口
- saas.util.BaseUtil.request({
- url: belong.reqUrl,
- params: JSON.stringify(params),
- method: 'POST'
- })
- .then(function(localJson) {
- me.setLoading(false);
- if(localJson.success){
- form.ownerCt._parent.store.load();
- saas.util.BaseUtil.showSuccessToast('保存成功');
- form.ownerCt.close();
- }
- })
- .catch(function(e) {
- me.setLoading(false);
- saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message);
- });
- }
- });
|