Example #1
0
 public function init()
 {
     if (!isset($this->type)) {
         throw new CException('类型不能为空!');
     }
     $this->controllerId = $this->getController()->id;
     if (in_array($this->type, array('user'))) {
         //            $this->showOtherOrg = User::isInterfaceUser() && User::isIndependentUser() && !in_array($this->controllerId,Yii::app()->params['filter_models']) ? true : false;
         $this->showOtherOrg = User::isInterfaceUser() && Yii::app()->user->independent && !in_array($this->controllerId, Yii::app()->params['filter_models']) ? true : false;
     }
     if ($this->openType == 'window') {
         $this->_defaultConfig = array('user' => array('modal' => 'user', 'class' => 'User'), 'org' => array('modal' => 'org', 'class' => 'Org'), 'grade' => array('modal' => 'grade', 'class' => 'EduOrg'), 'class' => array('modal' => 'class', 'class' => 'EduOrg'), 'student' => array('modal' => 'student', 'class' => 'EduStudents'), 'classstudent' => array('modal' => 'classstudent', 'class' => 'EduStudents'), 'parents' => array('modal' => 'parents', 'class' => 'EduParents'), 'eduorg' => array('modal' => 'eduorg', 'class' => 'EduOrg'), 'teacher' => array('modal' => 'teacher', 'class' => 'EduTeacher'), 'stage' => array('modal' => 'stage', 'class' => 'EduOrg'), 'teacherclass' => array('modal' => 'teacherclass', 'class' => 'EduOrg'), 'role' => array('modal' => 'role', 'class' => 'TDbAuthManager'), 'position' => array('modal' => 'position', 'class' => 'Position'), 'table' => array('modal' => 'table'), 'form' => array('modal' => 'form'), 'doctype' => array('modal' => 'doctype', 'class' => 'DocType'), 'wfdf' => array('modal' => 'wfdf'), 'wfdfapp' => array('modal' => 'wfdfapp', 'class' => 'WfDfApplication'), 'address' => array('modal' => 'address', 'class' => 'Address'), 'wfuser' => array('modal' => 'wfuser', 'class' => 'User'), 'parase' => array('modal' => 'parase', 'class' => 'UserParase'));
     } else {
         $this->_defaultConfig = array('user' => array('modal' => $this->single == false ? 'selectuser' : 'selectsingleuser', 'class' => 'User'), 'grade' => array('modal' => $this->single == false ? 'selectgrade' : 'selectsinglegrade', 'class' => 'EduOrg'), 'class' => array('modal' => $this->single == false ? 'selectclass' : 'selectsingleclass', 'class' => 'EduOrg'), 'student' => array('modal' => $this->single == false ? 'selectstudent' : 'selectsinglestudent', 'class' => 'EduStudents'), 'teacher' => array('modal' => $this->single == false ? 'selectteacher' : 'selectsingteacher', 'class' => 'EdTeacher'), 'classstudent' => array('modal' => $this->single == false ? 'selectclassstudent' : 'selectsingleclassstudent', 'class' => 'EduStudents'), 'parents' => array('modal' => $this->single == false ? 'selectparents' : 'selectsingleparents', 'class' => 'EduParents'), 'eduorg' => array('modal' => $this->single == false ? 'selecteduorg' : 'selectsingleeduorg', 'class' => 'EduOrg'), 'org' => array('modal' => $this->single == false ? 'selectorg' : 'selectsingleorg', 'class' => 'Org'), 'stage' => array('modal' => $this->single == false ? 'selectstage' : 'selectsinglestage', 'class' => 'EduOrg'), 'teacherclass' => array('modal' => $this->single == false ? 'selectteacherclass' : 'selectsingleteacherclass', 'class' => 'EduOrg'), 'role' => array('modal' => 'selectrole', 'class' => 'TDbAuthManager'), 'position' => array('modal' => 'position', 'class' => 'Position'), 'table' => array('modal' => 'selecttable'), 'form' => array('modal' => 'selectform'), 'doctype' => array('modal' => 'selectdoctype', 'DocType'), 'wfdf' => array('modal' => 'selectwfdf'), 'wfdfapp' => array('modal' => 'selectwfdfapp', 'class' => 'WfDfApplication'), 'address' => array('modal' => 'selectaddress', 'class' => 'Address'), 'wfuser' => array('modal' => 'selectwfuser', 'class' => 'User'), 'parase' => array('modal' => 'selectparase', 'class' => 'UserParase'));
     }
     if (!isset($this->config)) {
         $this->config = $this->_defaultConfig[$this->type];
     }
     list($name, $id) = $this->resolveNameID();
     if (!isset($this->hiddenFieldHtmlOptions['name'])) {
         $this->hiddenFieldHtmlOptions['name'] = $name;
     }
     $this->textFieldHtmlOptions['id'] = $id . '_name';
     if (!isset($this->textFieldHtmlOptions['value'])) {
         if ($this->hasModel()) {
             $this->textFieldHtmlOptions['value'] = $this->model->{$this->attribute};
         } else {
             $this->textFieldHtmlOptions['value'] = $this->value;
         }
     }
     if ($this->codeValue) {
         $this->getNameMethod = 'getNameByNo';
     }
     if (isset($this->textFieldHtmlOptions['value']) && $this->getNameByMethod && method_exists($this->config['class'], $this->getNameMethod)) {
         $class = $this->config['class'];
         $this->textFieldHtmlOptions['value'] = call_user_func(array($class, $this->getNameMethod), $this->textFieldHtmlOptions['value']);
     }
     if (!isset($this->textFieldHtmlOptions['style'])) {
         $this->textFieldHtmlOptions['style'] = 'margin-bottom:0;';
     } else {
         $this->textFieldHtmlOptions['style'] .= 'margin-bottom:0;';
     }
     if (isset($this->style)) {
         $this->textFieldHtmlOptions['style'] .= $this->style;
     }
     if ($this->readOnly) {
         $this->textFieldHtmlOptions['readOnly'] = 'readOnly';
     }
     if ($this->setName) {
         $this->textFieldHtmlOptions['name'] = $id . '_name';
     } else {
         $this->textFieldHtmlOptions['name'] = '';
     }
     if (!$this->addFunction) {
         if ($this->openType == 'window') {
             $url = Yii::app()->createUrl('/portal/selector/' . $this->config['modal'], array_merge(array('fid' => $id, 'fname' => $id . '_name', 'single' => $this->single, 'codeValue' => $this->codeValue, 'controllerId' => $this->controllerId, 'showOtherOrg' => $this->showOtherOrg), $this->params));
             $this->addFunction = 'selectoropen("' . $url . '")';
         } else {
             $this->addFunction = 'vk_' . $this->config['modal'] . '("' . $id . '","' . $id . '_name' . '","' . $this->config['modal'] . '", ' . ($this->single ? 1 : 0) . ');';
         }
     }
     if (!$this->delFunction) {
         $this->delFunction = 'selectorclear("' . $id . '","' . $id . '_name' . '")';
     }
     if (!$this->addButtonOptions['label']) {
         $this->addButtonOptions['label'] = "选择";
     }
     if (!$this->addButtonOptions['size']) {
         $this->addButtonOptions['size'] = "mini";
     }
     if (!$this->addButtonOptions['htmlOptions']) {
         $this->addButtonOptions['htmlOptions'] = array('style' => 'vertical-align:bottom;margin-left:3px;');
     }
     if (!$this->addButtonOptions['htmlOptions']['onclick']) {
         $this->addButtonOptions['htmlOptions']['onclick'] = $this->addFunction;
     }
     if (!$this->delButtonOptions['label']) {
         $this->delButtonOptions['label'] = "清空";
     }
     if (!$this->delButtonOptions['size']) {
         $this->delButtonOptions['size'] = "mini";
     }
     if (!$this->delButtonOptions['htmlOptions']) {
         $this->delButtonOptions['htmlOptions'] = array('style' => 'vertical-align:bottom;margin-left:3px;');
     }
     if (!$this->delButtonOptions['htmlOptions']['onclick']) {
         $this->delButtonOptions['htmlOptions']['onclick'] = $this->delFunction;
     }
     //        if(!$this->addButtonOptions){
     //            $this->addButtonOptions = array(
     //                'label' => '选择',
     //                'size' => 'mini',
     //                'htmlOptions'=>array(
     //                    'style' => 'vertical-align:bottom;',
     //                    'onclick' => $this->addFunction,
     //                )
     //            );
     //        }
     //        if(!$this->delButtonOptions){
     //            $this->delButtonOptions = array(
     //                'label' => '清空',
     //                'size' => 'mini',
     //                'htmlOptions'=>array(
     //                    'style' => 'vertical-align:bottom;margin-left:3px;',
     //                    'onclick' => $this->delFunction,
     //                )
     //            );
     //        }
 }
Example #2
0
 public function init()
 {
     $this->controllerId = $this->getController()->id;
     if (in_array(strtolower($this->type), array('user'))) {
         //            $this->showOtherOrg = User::isInterfaceUser() && User::isIndependentUser() && !in_array($this->controllerId, Yii::app()->params['filter_models']) ? true : false;
         $this->showOtherOrg = User::isInterfaceUser() && Yii::app()->user->independent && !in_array($this->controllerId, Yii::app()->params['filter_models']) ? true : false;
     }
     switch (strtolower($this->type)) {
         case 'otherorg':
             $this->modal_id = 'selectotherorg';
             $this->header = '选择外部组织机构';
             $this->view_name = 'core.views.selector.otherorg';
             $this->scriptFile = 'selector/otherorg.js';
             break;
         case 'user':
             $this->modal_id = $this->single == false ? 'selectuser' : 'selectsingleuser';
             $this->header = '选择人员';
             $this->placeholder = '按名字或者拼音缩写搜索...';
             $this->view_name = $this->single == false ? 'core.views.selector.user' : 'core.views.selector.singleuser';
             $this->scriptFile = $this->single == false ? 'selector/user.js' : 'selector/singleuser.js';
             break;
         case 'wfuser':
             $this->modal_id = 'selectwfuser';
             $this->header = '选择人员';
             $this->placeholder = '按名字或者拼音缩写搜索...';
             $this->view_name = 'core.views.selector.wfuser';
             $this->scriptFile = 'selector/wfuser.js';
             break;
         case 'org':
             $this->modal_id = $this->single == false ? 'selectorg' : 'selectsingleorg';
             $this->header = '选择部门';
             $this->placeholder = '搜索部门';
             $this->view_name = $this->single == false ? 'core.views.selector.org' : 'core.views.selector.singleorg';
             $this->scriptFile = $this->single == false ? 'selector/org.js' : 'selector/singleorg.js';
             break;
         case 'role':
             $this->modal_id = 'selectrole';
             $this->header = '选择角色';
             $this->placeholder = '搜索角色';
             $this->view_name = 'core.views.selector.role';
             $this->scriptFile = 'selector/role.js';
             break;
         case 'table':
             $this->modal_id = 'selecttable';
             $this->header = '选择表';
             $this->placeholder = '搜索表名';
             $this->view_name = 'core.views.selector.table';
             $this->scriptFile = 'selector/table.js';
             break;
         case 'form':
             $this->modal_id = 'selectform';
             $this->header = '选择表单';
             $this->placeholder = '搜索表单';
             $this->view_name = 'core.views.selector.form';
             $this->scriptFile = 'selector/form.js';
             break;
         case 'wfdf':
             $this->modal_id = 'selectwfdf';
             $this->header = '选择流程';
             $this->placeholder = '搜索流程';
             $this->view_name = 'core.views.selector.wfdf';
             $this->scriptFile = 'selector/wfdf.js';
             break;
         case 'doctype':
             $this->modal_id = 'selectdoctype';
             $this->header = '选择公文类型';
             $this->placeholder = '搜索公文类型';
             $this->view_name = 'core.views.selector.doctype';
             $this->scriptFile = 'selector/doctype.js';
             break;
         case 'address':
             $this->modal_id = 'selectaddress';
             $this->header = '选择通讯录人员';
             $this->placeholder = '搜索通讯录人员';
             $this->view_name = 'core.views.selector.address';
             $this->scriptFile = 'selector/address.js';
             break;
         case 'parase':
             $this->modal_id = 'selectparase';
             $this->header = '选择常用语';
             $this->placeholder = '搜索常用语';
             $this->view_name = 'core.views.selector.parase';
             $this->scriptFile = 'selector/parase.js';
             break;
         case 'opinion':
             $this->modal_id = 'selectopinion';
             $this->header = '选择流程意见';
             $this->placeholder = '搜索流程意见';
             $this->view_name = 'core.views.selector.opinion';
             $this->scriptFile = 'selector/opinion.js';
             break;
         default:
             break;
     }
     parent::init();
 }