/** * (non-PHPdoc) * @Description: setFormField(通过数据库字典生成list相关信息) * @param $listFieldVal array list文件配置字段信息 * @author yangxi 2014-12-12 * @see CommonAction::update() */ public function setFormInfo($modelname) { $formList = array(); //初始化存储表单元素数组 //获取form字段的组件信息 $formid = M('mis_dynamic_form_manage')->where("actionname= '" . $modelname . "'")->getfield('id'); if ($formid) { //$result=D("MisDynamicFormProperyAndSubView")->where("formid= '".$formid."'")->select(); $sql = "SELECT\n mis_dynamic_form_propery.`id` AS `id`,\n mis_dynamic_form_propery.`showoption` AS `showoption`,\n mis_dynamic_form_propery.`subimporttableobj` AS `subimporttableobj`,\n mis_dynamic_form_propery.`subimporttablefieldobj` AS `subimporttablefieldobj`,\n mis_dynamic_form_propery.`subimporttablefield2obj` AS `subimporttablefield2obj`,\n mis_dynamic_form_propery.`subimporttableobjcondition` AS `subimporttableobjcondition`,\n mis_dynamic_form_propery.`treedtable` AS `treedtable`,\n\t \t\t\t mis_dynamic_form_propery.`dateformat` AS `dateformat`,\n mis_dynamic_form_propery.`lookupfiledback` AS `lookupfiledback`,\n mis_dynamic_form_propery.`lookupgrouporg` AS `lookupgrouporg`,\n\t \t\t\t \t\t mis_dynamic_form_propery.`org` AS `org`,\n mis_dynamic_form_propery.`org1` AS `org1`,\n mis_dynamic_form_propery.`lookupurls` AS `lookupurls`,\t \t\t\t\t \t\t\t\n mis_dynamic_form_propery.`lookupmodel` AS `lookupmodel`,\n mis_dynamic_form_propery.`lookupshoworg` AS `lookupshoworg`,\n mis_dynamic_form_propery.`lookuporgval` AS `lookuporgval`,\t \t\t\t\t \t\t\t \t\t\t\n mis_dynamic_form_propery.`lookupconditions` AS `lookupconditions`,\n mis_dynamic_form_propery.`lookupchoice` AS `lookupchoice`,\n mis_dynamic_form_propery.`viewname` AS `viewname`,\n mis_dynamic_form_propery.`viewtype` AS `viewtype`,\t\n\t \t\t\t mis_dynamic_form_propery.`org` AS `org`,\n\t \t\t\t\t mis_dynamic_form_propery.`unit` AS `unit`,\t \t\t\t\t \t\t\t\t \t\t\t\n\t \t\t\t mis_dynamic_form_propery.`unitls` AS `unitls`,\n mis_dynamic_form_propery.`title` AS `title`,\n mis_dynamic_form_propery.`category` AS `category`,\n mis_dynamic_form_propery.`fieldname` AS `fieldname`,\n mis_dynamic_form_propery.`ids` AS `ids`,\n mis_dynamic_form_propery.`formid` AS `formid`,\n mis_dynamic_form_propery.`tplid` AS `tplid`,\n mis_dynamic_form_propery.`status` AS `status`,\n\t \t\t\t\t\t mis_dynamic_form_propery.`islock` AS `islock`,\n\t \t\t\t\t\t mis_dynamic_form_propery.`isrequired` AS `isrequired`,\n\t \t\t\t\n\t \t\t\tmis_dynamic_form_propery.`treedtable`\t\t\t\t\t\tAS `treedtable`,\n\t \t\t\tmis_dynamic_form_propery.`treevaluefield` AS `treevaluefield`,\n\t \t\t\tmis_dynamic_form_propery.`treeshowfield` AS `treeshowfield`,\n\t \t\t\tmis_dynamic_form_propery.`treeparentfield` AS `treeparentfield`,\n\t \t\t\tmis_dynamic_form_propery.`isnextend` \t\t\tAS `isnextend`,\n\t \t\t\tmis_dynamic_form_propery.`mulit` \t\t\t\tAS `mulit`,\n\t \t\t\tmis_dynamic_form_propery.`treeheight` \t\tAS `treeheight`,\n\t \t\t\tmis_dynamic_form_propery.`treewidth` \t\t\tAS `treewidth`,\n\t \t\t\t\n\t \t\t\t\t\tmis_dynamic_form_propery.`additionalconditions`\t\t\t\t\t\t\t\tAS `addconditions`,\n mis_dynamic_database_sub.`field` AS `field`,\n mis_dynamic_database_sub.`formid` AS `subformid`\n FROM mis_dynamic_form_propery mis_dynamic_form_propery\n LEFT JOIN mis_dynamic_database_sub mis_dynamic_database_sub\n ON mis_dynamic_form_propery.`ids` = mis_dynamic_database_sub.`id`\n WHERE mis_dynamic_form_propery.formid = " . $formid; //M('mis_dynamic_database_sub')->where("formid= '".$formid."'")->select(); $formList = $this->query($sql); // print_r($this->getLastSql());exit; // print_r($formList); // echo 123; foreach ($formList as $key => $val) { if (!empty($val['fieldname'])) { $temp = array(); //组件name,用来提交数据的 $temp["template_name"] = "datatable[#index#][table][" . $val['fieldname'] . "]"; $temp["template_data"] = ""; $temp["template_class"] = $val["isrequired"] ? "required" : ""; $temp["template_key"] = ""; $temp["is_readonly"] = $val["islock"] ? "" : "true"; switch ($val['category']) { case "text": $temp["template_key"] = "input"; $template_data = array(); //获取ORG参数 if (!empty($val['org'])) { $org = explode(".", $val['org']); $template_data["bindlookupname"] = $org[0]; $template_data["upclass"] = $org[1]; } if (!empty($val['unitls'])) { //存储的单位编码 $template_data["unitl"] = $val['unitls']; //获取单位编码中文名 $template_data["unitlname"] = getFieldBy($val['unitls'], 'danweidaima', 'danweimingchen', 'mis_system_unit'); } $temp["template_data"] = json_encode($template_data); //列是否统计 $temp["is_stats"] = false; //小数位数 $temp["stats_num"] = 2; break; case "select": //获取ORG参数 if (!empty($val['org'])) { $org = explode(".", $val['org']); $bindlookup = array("lookupname" => $org[0], "name" => $org[1]); $temp["bindlookup"] = json_encode($bindlookup); } /* * 下拉树配置 * */ if ($val['treedtable'] && $val['treevaluefield'] && $val['treeshowfield'] && $val['treeparentfield']) { $chkStyle = "radio"; // 单选,多选 if ($val["mulit"] == 1) { $chkStyle = "checkbox"; } $isnextend = $val['isnextend'] == 1 ? 1 : 0; // 获取下拉树的显示数据 $treeData = getControllbyHtml("table", array("type" => "select", "table" => $val['treedtable'], "id" => $val['treevaluefield'], "name" => $val['treeshowfield'], "showtype" => "1", "comboxtree" => "1", "parentid" => $val['treeparentfield'], "isnextend" => $isnextend)); $dataSouceArr = '{"treeconfig":' . '{"expandAll":false,' . '"checkEnable":true,' . '"chkStyle":"' . $chkStyle . '",' . '"radioType":"all",' . '"onClick":"S_NodeClick",' . '"onCheck":"S_NodeCheck"},' . '"treeheight":"' . $val['treeheight'] . '",' . '"treewidth":"' . $val['treewidth'] . '",' . '"treedata":' . $treeData . '}'; $temp["template_data"] = $dataSouceArr; $temp["template_key"] = "selecttree"; } else { $temp["template_key"] = "select"; $temp["template_data"] = "["; $abc = $this->getSelectSource($val); foreach ($abc as $skey => $sval) { $temp["template_data"] .= '{"value":"' . $skey . '","name":"' . $sval . '"},'; } //去掉最后一个, $temp["template_data"] = $abc ? substr($temp["template_data"], 0, -1) . "]" : $temp["template_data"] . "]"; //数据格式例子 //$temp["template_data"] = '[{"value":1,"name":"第一人"},{"value":2,"name":"第二人"}]'; } break; case "lookup": $temp["template_key"] = "lookup"; $abc = $this->getLookupSource($val); //upclass:查找带回显示字段,格式 string class="textInput enterIndex readonly into_table_new9122317_wrapperorgfandanbaocuoshibianhao11.name" class里 org.name //callback是回调函数 param是传递到lookupGeneral函数的参数,格式 string 例:param="field=orderno,pid,name,id&model=MisSaleProfession&newconditions=" //herf是请求地址 格式 string 例:href="/workarea/workstation/systemui/product/Admin/index.php/MisAutoDap/lookupGeneral" //hidden_data:隐藏的存入数据库字段的值 格式 :[{"upclass":"","name":"datatable[#index#][datatable1][sinianji]"}],其中upclass是查找带回存储字段,name是隐藏输入入框的name,[datatable1][sinianji]表名,字段名 $param = ""; //初始化参数 $param .= "lookupchoice=" . $val['lookupchoice']; //传Key值 unset($lookuporg0); unset($lookuporg1); $lookuporg0 = explode('.', $val['org']); $lookuporg1 = explode('.', $val['org1']); $bindlookupname = $lookuporg1[0] ? $lookuporg1[0] : $lookuporg0[0]; $param .= ''; // //lookup带回字段 // $param.="field=".$val['lookupfiledback']; // //lookup的模型对象 // $param.="&model=".$val['lookupmodel']; //过滤条件 ////////////////////////////////////////////////////////////////////////////////////////////// unset($conditionConfigJson); unset($appendCondtion); unset($additionalconditions); unset($formFiledList); unset($sysFieldList); unset($sysFieldFmt); unset($appendCondtionArr); unset($appendCondtionStr); unset($conditions); unset($formFiledFmt); $additionalconditions = $val['addconditions']; if ($additionalconditions) { $appendCondtion = unserialize(base64_decode($additionalconditions)); // proexp 表单字段列表 // sysexp 系统字段列表 $formFiledList = $appendCondtion['proexp']; $sysFieldList = $appendCondtion['sysexp']; // $formFiledFmt=array(); // $sysFieldFmt = array(); $sysFieldFmt = unserialize($sysFieldList) or array(); // 获取真实的表单字段名。 if ($formFiledList) { $formFiledListArr = unserialize($formFiledList) or array(); if (is_array($formFiledListArr) && count($formFiledListArr)) { $formFiledKey = array_keys($formFiledListArr); $properModel = M('mis_dynamic_form_propery'); $properMap['id'] = array('in', $formFiledKey); unset($fd); $fd = $properModel->where($properMap)->field('fieldname,id')->select(); if ($fd) { foreach ($fd as $k => $v) { // $fieldArr[] = $v['fieldname']; if ($formFiledListArr[$v['id']] == -1) { $formFiledFmt[$v['fieldname']] = $v['fieldname']; } else { $formFiledFmt[$v['fieldname']] = $formFiledListArr[$v['id']]; } } } } } if (is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = array_merge($sysFieldFmt, $formFiledFmt); } elseif (is_array($sysFieldFmt) && !is_array($formFiledFmt)) { $appendCondtionArr = $sysFieldFmt; } elseif (!is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = $formFiledFmt; } else { $appendCondtionArr = array(); } // 将条件转换为可用的sql where语句 $appendCondtionStr = arr2string($appendCondtionArr); logs($val['fieldname'] . $appendCondtionStr, 'rinidaye'); //$conditions = "{:getAppendCondition(\$vo ,$appendCondtionStr)}"; $conditions = getAppendCondition($vo, $appendCondtionArr); if (is_array($appendCondtionArr)) { unset($tempData); foreach ($appendCondtionArr as $k => $v) { $tempData[$v] = $k; } $conditionConfigJson = ',"condition":' . json_encode($tempData); } } //////////////////////////////////////////////////////////////////// $param .= "&newconditions=" . $conditions; $val['callback'] = "lookup_counter_check"; //herf路径 $herf = __APP__ . '/' . $modelname . '/' . $val['lookupurls']; $temp["template_data"] = '{"bindlookupname":"' . $bindlookupname . '","upclass":"' . $val['lookupshoworg'] . '","lporder":"' . $lookuporg1[1] . '","lpkey":"' . $val['lookupchoice'] . '","callback":"' . $val['callback'] . '","param":"' . $param . '","lookupname":"' . $val['lookupgrouporg'] . '","href":"' . $herf . '","hidden_data":[{"upclass":"' . $val['lookuporgval'] . '","lporder":"' . $lookuporg0[1] . '","name":"datatable[#index#][table][' . $val['fieldname'] . ']"}]' . $conditionConfigJson . '}'; break; case "date": $temp["template_key"] = "date"; //日期格式 if (empty($val['format'])) { $val['dateformat'] = "yyyy-MM-dd"; } else { $formatTemp = explode('@', $val['dateformat']); $val['dateformat'] = $formatTemp[0]; } $temp["template_data"] = '{"format":"' . $val['dateformat'] . '"}'; break; case "upload": $temp["template_key"] = "uploadfilenew"; $temp["template_data"] = '{"url":"__URL__/DT_uploadnew"}'; break; default: break; } $th_html = array(); foreach ($temp as $k => $v) { $th_html[] = $k . "='" . $v . "'"; } $th_html = implode(" ", $th_html); $val['datatable'] = $th_html; $list[$val["fieldname"]] = $val; } } } $this->SetRules($list, $modelname, $typename = "form"); }
/** * (non-PHPdoc) * @see Widget::render() * @param Array $data 参数集合 * $data[0] 当前显示数据,修改时使用 * $data[1] 用户参数集合 * $data[1]=>array( * [0]=>'样式参数' * [1]=>'组件配置参数' * ); * $param[0] = 'col require '; // 样式参数 * $param[1] = array( // 组件配置参数 * 'type'=>'table|selectlist',数据来源方式:table|selectlist * $parame * ); * * * 公用的属性 * $parame['readonly'] 组件是否只读 * $parame['targevent'] 绑定的事件 * $parame['names'] 组件name属性 * $parame['defaultcheckitem'] 默认选中项的值,只有在add时有效 * $parame['defaultval'] 外部传入首选项的值 * $parame['defaulttext'] 外部传入首选项的显示文本 * * // 表查询私有属性 * $parame['table'] 查询表名 * $parame['id'] 真实值字段名 * $parame['name'] 显示值字段名 * $parame['conditions'] 过滤条件 * * //当数据为树形查找的需要的参数 * $parame['parentid'] 上一级ID,当这个有值时表示下拉框为树形下拉。 * $parame['mulit'] 是否多选 true false false:单选 , true:多选 * $parame['isnextend'] 是否只能操作最下一级数据 true|false。 * * // selectlist 查询私有属性 * $parame['key'] 数据key值 * * {W:ShowSelect(array('1' , $param ))} */ public function render($data) { $param = $data[1]; $conf = $param[1]; $parame = $conf[0]; if (!is_array($param) || !is_array($conf)) { return "<error>组件配置信息缺失!</error>"; } $datatype = $conf['type']; $datatypeArr = array('table' => 'table', 'selectlist' => 'selectlist'); $type = $datatypeArr[$datatype]; if (!$type) { return "<error>未知数据来源:{$datatype},当前允许类型:" . join(',', $datatypeArr) . "</error>"; } //样式 $classStyle = $param[0]; //组件name属性 $fieldName = $parame['names']; //组件事件 $targevent = $parame['targevent']; //action名称 $actionName = $parame['actionName']; //默认选中项的值,只有在add时有效 $defaultcheckitem = $parame['defaultcheckitem']; //外部传入首选项的值 $defaultval = $parame['defaultval']; //外部传入首选项的显示文本 $defaulttext = $parame['defaulttext']; //查询表名 $table = $parame['table']; //真实值字段名 $id = $parame['id']; //显示值字段名 $name = $parame['name']; //过滤条件 $conditions = $parame['conditions']; $conditions = html_entity_decode($conditions); //父级id $parentid = $parame['parentid']; //是否多选 true false $mulit = $parame['mulit']; //是否末级操作 $isnextend = $parame['isnextend']; //数据key值 $key = $parame['key']; //是否编辑 $isedit = $parame['isedit']; // 树形-下拉高度 $treeheight = $parame['treeheight']; // 树形-是否对话框模式 $treedialog = $parame['treedialog'] ? 1 : 0; // 下拉框的返写标识 $dropbackkey = $parame['dropbackkey'] ? $parame['dropbackkey'] : $name; // 下拉框组件的默认选中项 $defaultcheckitem = $parame['defaultcheckitem']; // 将默认选中项设置到选中值中去,只对新增无漫游时有效。 $data[0] = $data[0] == '' && $defaultcheckitem ? $defaultcheckitem : $data[0]; $dropbackkeyStr = "dropbackkey=\"{$dropbackkey}\""; // 是否在子级勾取时自动勾取其父级 bynbmxkj@20150831 2338 // 其默认值最好为true,表示子级勾取后其父级也会被勾中, // 注意:在树的配置属性上默认子级勾取后父级勾中时其值一定要为 true 这个字符。不是php可认识的1。 $checkedSelfParent = "false"; if (empty($treeheight) || $treeheight == 0) { $treeheight = 150; } // 树形-下拉宽度 $treewidth = $parame['treewidth']; // if(empty($treewidth) || $treewidth==0){ // $treewidth = false; // } $nodeCheckFunc = "S_NodeCheck"; $nodeClickFunc = "S_NodeClick"; if ($mulit) { $nodeCheckFunc = "S_NodesCheck"; } $treewidthParame = ''; if (!empty($treewidth) || $treewidth != 0) { $treewidthParame = 'data-width="' . $treewidth . '"'; } // 是否为直接转出只读内容 $showtype = $parame['showtype']; if ($targevent) { //$tagEventSytr = 'on'.ucwords($targevent).'="'.$actionName.'_'.$fieldName.'_'.$targevent.'(this)"'; } if (!$isedit) { $readonlyStr = 'readonly="readonly"'; $classStyle .= " readonly "; } if ($mulit == 1) { $mulitType = 'checkbox'; } else { $mulitType = 'radio'; } if ($defaulttext) { $optionStr = '<option value="' . $defaultval . '">' . $defaulttext . '</option>'; } $ztreeId = "ztree_{$actionName}_{$fieldName}"; if ($isedit) { $ztreeId = "ztree_{$actionName}_{$fieldName}_edit"; } if ($showtype) { if ($conf['type'] == 'selectlist') { $html = '<span class="input_new">' . getControllbyHtml('selectlist', array('type' => 'select', 'key' => $key, 'conditions' => $conditions, 'selected' => $data[0], 'showtype' => $showtype)) . '</span>'; } else { $html = '<span class="input_new">' . getControllbyHtml('table', array('type' => 'select', 'table' => $table, 'id' => $id, 'name' => $name, 'conditions' => $conditions, 'selected' => $data[0], 'showtype' => $showtype)) . '</span>'; } return $html; } if ($conf['type'] == 'selectlist') { if ($key) { $html = <<<EOF \t\t\t<select {$tagEventSytr} {$readonlyStr} name="{$fieldName}" {$dropbackkeyStr} class=" {$classStyle} select2 select_elm "> \t\t\t{$optionStr} EOF; $html .= getControllbyHtml('selectlist', array('type' => 'select', 'key' => $key, 'conditions' => $conditions, 'selected' => $data[0])); $html .= <<<EOF \t\t\t</select> EOF; } } else { if ($parentid) { //添加-只能选择下拉框最后一级的特殊数据获取方式 @date:15-01-17 16:38:41 $model = D("MisSystemRecursion"); $model->__construct(); $treeDataCondition = ' status=1 '; if ($conditions) { $treeDataCondition .= ' and ' . $conditions; } $filterSouce = getCurrentUserDataRight(1, $table, $id, true); if ($filterSouce) { $dataFilterMaps = $filterSouce; // key($filterSouce)." in ('".join("','", reset($filterSouce))."')"; // 在需要时可以在此处加上过滤条件格式验证,防止异常。 $treeDataCondition .= ' and ' . $dataFilterMaps; } $treeDataCondition = str_replace(''', "'", $treeDataCondition); $treeSelectselect6Data = $model->modelShow($table, array('key' => 'id', 'pkey' => $parentid, 'conditions' => $treeDataCondition, 'fields' => "{$id},{$name}"), 0, 1); $treeSelectselect6DataTemp = ''; if ($defaulttext) { array_unshift($treeSelectselect6Data, array($id => $defaultval, $name => $defaulttext, $parentid => 0, 'nextEnd' => 1)); } $nameArr = ''; if ($data[0]) { $dataArr = explode(',', $data[0]); //查询显示数据 $ztreeModel = M($table); $ztreemap[$id] = array('in', $dataArr); $ztreeList = $ztreeModel->where($ztreemap)->select(); $ztreeName = array(); foreach ($ztreeList as $zk => $zval) { $ztreeName[] = $zval[$name]; } $nameArr = implode(',', $ztreeName); } foreach ($treeSelectselect6Data as $key => $value) { // id":1, "pId":0, "name":"基本元素" $tem = ''; $tem['id'] = $value['id']; $tem['key'] = $value[$id]; $tem['pId'] = $value[$parentid]; $tem['name'] = $value[$name]; if ($isnextend == '1' && $value['nextEnd'] == 0) { $tem['chkDisabled'] = true; } if ($isedit) { $dataArr = explode(',', $data[0]); if (in_array($value[$id], $dataArr)) { $tem['checked'] = true; } } $treeSelectselect6DataTemp[] = $tem; } //print_r($treeSelectselect6DataTemp); // 当前没得传显示数据,有首项显示数据 if ($isedit == '' && $defaulttext) { $nameVal = $defaulttext; $IdVal = $defaultval; } else { if ($data[0] == $defaultval) { $nameVal = $defaulttext; $IdVal = $defaultval; } else { $nameVal = $nameArr; $IdVal = $data[0]; } } $conboxtreeCls = 'comboxtree'; if (!$isedit) { $conboxtreeCls = ''; } else { $conboxtreeCls = 'comboxtree notreadonly'; } $ret = preg_match('/required/', $classStyle); $hiddenRequired = ''; if ($ret) { $hiddenRequired = 'required'; } $treeData = json_encode($treeSelectselect6DataTemp); $html = <<<EOF <input type="text" readonly="readonly" class="{$conboxtreeCls} {$classStyle} input_new" size="18" value="{$nameVal}" data-names="{$fieldName}" data-height="{$treeheight}" data-dialog="{$treedialog}" {$treewidthParame} data-tree="#{$ztreeId}" data-search="true" /> <input type="hidden" name="{$fieldName}" {$dropbackkeyStr} class="{$hiddenRequired}" value="{$IdVal}"/> <ul id="{$ztreeId}" class="ztree hide" attrs = '{"expandAll":false, "checkEnable":true, "chkStyle":"{$mulitType}", "radioType":"all", "onClick":"{$nodeClickFunc}", "onCheck":"{$nodeCheckFunc}","chkboxType":"{$checkedSelfParent}"}' nodes='{$treeData}'></ul> EOF; } else { $html = <<<EOF \t\t\t<select {$tagEventSytr} {$readonlyStr} name="{$fieldName}" {$dropbackkeyStr} class="{$classStyle} select2 select_elm"> \t\t\t\t{$optionStr} EOF; $html .= getControllbyHtml('table', array('type' => 'select', 'table' => $table, 'id' => $id, 'name' => $name, 'conditions' => $conditions, 'selected' => $data[0])); $html .= <<<EOF \t\t\t</select> EOF; } } return $html; }
/** * (non-PHPdoc) * @see Widget::render() * @param Array $data 参数集合 * $data[0] 当前显示数据,修改时使用 * $data[1] 用户参数集合 * $data[1]=>array( * [0]=>'样式参数' * [1]=>'组件配置参数' * ); * $param[0] = 'col require '; // 样式参数 * $param[1] = array( // 组件配置参数 * 'type'=>'table|selectlist',数据来源方式:table|selectlist * $parame * ); * * * 公用的属性 * $parame['readonly'] 组件是否只读 * $parame['targevent'] 绑定的事件 * $parame['names'] 组件name属性 * $parame['defaultcheckitem'] 默认选中项的值,只有在add时有效 * $parame['defaultval'] 外部传入首选项的值 * $parame['defaulttext'] 外部传入首选项的显示文本 * * // 表查询私有属性 * $parame['table'] 查询表名 * $parame['id'] 真实值字段名 * $parame['name'] 显示值字段名 * $parame['conditions'] 过滤条件 * * //当数据为树形查找的需要的参数 * $parame['parentid'] 上一级ID,当这个有值时表示下拉框为树形下拉。 * $parame['mulit'] 是否多选 true false false:单选 , true:多选 * $parame['isnextend'] 是否只能操作最下一级数据 true|false。 * * // selectlist 查询私有属性 * $parame['key'] 数据key值 * * {W:ShowSelect(array('1' , $param ))} */ public function render($data) { $param = $data[1]; $conf = $param[1]; $parame = $conf[0]; if (!is_array($param) || !is_array($conf)) { return "<error>组件配置信息缺失!</error>"; } $datatype = $conf['type']; $datatypeArr = array('table' => 'table', 'selectlist' => 'selectlist'); $type = $datatypeArr[$datatype]; if (!$type) { return "<error>未知数据来源:{$datatype},当前允许类型:" . join(',', $datatypeArr) . "</error>"; } //样式 $classStyle = $param[0]; //是否只读 $readonly = intval($parame['readonly']); $readonly = $readonly == 1 ? true : false; //组件name属性 $fieldName = $parame['names']; $fieldNameAppend = $parame['namesappend']; //组件事件 $targevent = $parame['targevent']; //action名称 $actionName = $parame['actionName']; //默认选中项的值,只有在add时有效 $defaultcheckitem = $parame['defaultcheckitem']; //外部传入首选项的值 $defaultval = $parame['defaultval']; //外部传入首选项的显示文本 $defaulttext = $parame['defaulttext']; //查询表名 $table = $parame['table']; //真实值字段名 $id = $parame['id']; //显示值字段名 $name = $parame['name']; //过滤条件 $conditions = $parame['conditions']; $conditions = html_entity_decode($conditions); //父级id $parentid = $parame['parentid']; //是否多选 true false $mulit = $parame['mulit']; //是否末级操作 $isnextend = $parame['isnextend']; //数据key值 $key = $parame['key']; //是否编辑 $isedit = $parame['isedit']; // 树形-下拉高度 $treeheight = $parame['treeheight']; if (empty($treeheight) || $treeheight == 0) { $treeheight = 150; } // 树形-下拉宽度 $treewidth = $parame['treewidth'] ? $parame['treewidth'] : 150; $treewidthParame = ''; if (!empty($treewidth) || $treewidth != 0) { $treewidthParame = 'data-width="' . $treewidth . '"'; } $dtCtP = 'data-comboxtype="dt"'; // 是否为直接转出只读内容 $showtype = $parame['showtype']; if ($targevent) { $tagEventSytr = 'on' . ucwords($targevent) . '="' . $actionName . '_' . $fieldName . '_' . $targevent . '(this)"'; } if ($readonly) { $readonlyStr = 'readonly="readonly"'; } if ($mulit == 1) { $mulitType = 'checkbox'; } else { $mulitType = 'radio'; } if ($defaulttext) { $optionStr = '<option value="' . $defaultval . '">' . $defaulttext . '</option>'; } $ztreeId = "ztree_{$actionName}_{$fieldNameAppend}"; if ($isedit) { $ztreeId = "ztree_{$actionName}_{$fieldNameAppend}_edit"; } //$ztreeId = str_replace('=', '',base64_encode($ztreeId)); if ($showtype) { if ($conf['type'] == 'selectlist') { $html = '<span class="input_new">' . getControllbyHtml('selectlist', array('type' => 'select', 'key' => $key, 'conditions' => $conditions, 'selected' => $data[0], 'showtype' => $showtype)) . '</span>'; } else { $html = '<span class="input_new">' . getControllbyHtml('table', array('type' => 'select', 'table' => $table, 'id' => $id, 'name' => $name, 'conditions' => $conditions, 'selected' => $data[0], 'showtype' => $showtype)) . '</span>'; } return $html; } if ($conf['type'] == 'selectlist') { if ($key) { $html = <<<EOF \t\t\t<select {$tagEventSytr} {$readonlyStr} name="{$fieldName}" class=" {$classStyle} select2 select_elm "> \t\t\t{$optionStr} EOF; $html .= getControllbyHtml('selectlist', array('type' => 'select', 'key' => $key, 'conditions' => $conditions, 'selected' => $data[0])); $html .= <<<EOF \t\t\t</select> EOF; } } else { if ($parentid) { //添加-只能选择下拉框最后一级的特殊数据获取方式 @date:15-01-17 16:38:41 $model = D("MisSystemRecursion"); $model->__construct(); $treeSelectselect6Data = $model->modelShow($table, array('key' => 'id', 'pkey' => $parentid, 'conditions' => $conditions, 'fields' => "{$id},{$name}"), 0, 1); $treeSelectselect6DataTemp = ''; if ($defaulttext) { array_unshift($treeSelectselect6Data, array($id => $defaultval, $name => $defaulttext, $parentid => 0, 'nextEnd' => 1)); } foreach ($treeSelectselect6Data as $key => $value) { // id":1, "pId":0, "name":"基本元素" $tem = ''; $tem['id'] = $value['id']; $tem['key'] = $value[$id]; $tem['pId'] = $value[$parentid]; $tem['name'] = $value[$name]; if ($isnextend == '1' && $value['nextEnd'] == 0) { $tem['chkDisabled'] = true; } if ($isedit) { $dataArr = explode(',', $data[0]); if (in_array($value[$id], $dataArr)) { $tem['checked'] = true; } } //查询显示数据 $ztreeModel = M($table); $ztreemap[$id] = array('in', $dataArr); $ztreeList = $ztreeModel->where($ztreemap)->select(); $ztreeName = array(); foreach ($ztreeList as $zk => $zval) { $ztreeName[] = $zval[$name]; } $nameArr = implode(',', $ztreeName); $treeSelectselect6DataTemp[] = $tem; } //print_r($treeSelectselect6DataTemp); // 当前没得传显示数据,有首项显示数据 if ($isedit == '' && $defaulttext) { $nameVal = $defaulttext; $IdVal = $defaultval; } else { if ($data[0] == $defaultval) { $nameVal = $defaulttext; $IdVal = $defaultval; } else { $nameVal = $nameArr; $IdVal = $data[0]; } } $conboxtreeCls = 'comboxtree'; // 编辑状态处理。nbmxkj@20160226 if (!$isedit) { $conboxtreeCls = ''; } else { $conboxtreeCls = 'comboxtree notreadonly'; } $treeData = json_encode($treeSelectselect6DataTemp); $dataNames = str_replace('#hide#', '', $fieldName); $html = <<<EOF \t\t\t\t<div class="list_input"> <input type="text" readonly="readonly" class="{$conboxtreeCls} {$classStyle} " size="18" value="{$nameVal}" data-names="{$dataNames}" data-height="{$treeheight}" data-tree="#{$ztreeId}" {$treewidthParame} {$dtCtP} data-search="true" /> <input type="hidden" name="{$fieldName}" value="{$IdVal}"/> <ul id="{$ztreeId}" class="ztree hide" attrs = '{"expandAll":false, "checkEnable":true, "chkStyle":"{$mulitType}", "radioType":"all", "onClick":"S_NodeClick", "onCheck":"S_NodeCheck"}' nodes='{$treeData}'></ul> \t\t</div> EOF; } else { $html = <<<EOF \t\t\t<select {$tagEventSytr} {$readonlyStr} name="{$fieldName}" class="{$classStyle} select2 select_elm"> \t\t\t\t{$optionStr} EOF; $html .= getControllbyHtml('table', array('type' => 'select', 'table' => $table, 'id' => $id, 'name' => $name, 'conditions' => $conditions, 'selected' => $data[0])); $html .= <<<EOF \t\t\t</select> EOF; } } return $html; }