/**
  * @Title: createModel
  * @Description: todo(生成Model代码)
  * @param array $fieldData 组件属性列表
  * @param string $modelname 控制器名称
  * @param boolean $add 是否覆盖现有文件,默认为false:需要覆盖
  * @param boolean $isaudit 是否带审批流,默认为false:不带审批流
  * @author quqiang
  * @date 2014-8-21 上午10:11:34
  * @throws
  */
 protected function createModel($fieldData, $modelname, $add = false, $isaudit = false)
 {
     logs('C:' . __CLASS__ . ' L:' . __LINE__ . "model生成 modelname:{$modelname}");
     // 1.获取到当前Action的组件配置文件信息
     /*		$model = D('Autoform');
     		$dir = '/autoformconfig/';
     		$path = $dir.$this->nodeName.'.php';
     		$model->setPath($path);
     */
     // 所有节点的字段组件配置信息 从物理文件中获取内容  已废弃
     // $allControllConfig = $model->getAllControllConfig();
     // 从数据库中获取节点信息
     $formid = getFieldBy($this->nodeName, "actionname", "id", "mis_dynamic_form_manage");
     $formfieldSql = "SELECT mas.tablename , sub.* FROM mis_dynamic_database_sub AS sub LEFT JOIN mis_dynamic_database_mas AS mas " . "ON sub.masid = mas.id " . "WHERE sub.formid={$formid}";
     $misDynamicDatabaseSubObj = M('mis_dynamic_database_sub');
     $fieldData = $misDynamicDatabaseSubObj->query($formfieldSql);
     logs('C:' . __CLASS__ . ' L:' . __LINE__ . ' model生成数据查询sql:' . $misDynamicDatabaseSubObj->getLastSql());
     $fieldData = $this->getAllControllConfig($formid);
     logs('C:' . __CLASS__ . ' L:' . __LINE__ . ' model生成数据:' . $this->pw_var_export($temp), date('Y-m-d', time()) . '_data.log');
     $publicProperty = $this->publicProperty;
     $primaryTableName = $this->getTrueTableName();
     /**
      *		表数组,基础为二维.
      * 	0=>主表信息
      * 	1=>所有从表的信息
      */
     $tablenameArr = array();
     // 按真实表名分离数组
     foreach ($fieldData as $key => $value) {
         if ($primaryTableName == $value['tablename']) {
             // 分离主表
             $tablenameArr[0][$value['tablename']][] = $value;
         } else {
             // 分离从表
             $tablenameArr[1][$value['tablename']][] = $value;
         }
     }
     // 生成主表的model信息
     foreach ($tablenameArr[0] as $key => $value) {
         // 当前真实表名与Model名
         logs('多表 主表生成时节点:' . $this->nodeName);
         logs('C:' . __CLASS__ . ' L:' . __LINE__ . "多表 主表生成时节点:{$this->nodeName}");
         $modelname = createRealModelName($this->nodeName);
         //ucfirst($key);
         logs('C:' . __CLASS__ . ' L:' . __LINE__ . "多表 主表model名:{$modelname}");
         $truetablename = strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $key), "_"));
         logs('C:' . __CLASS__ . ' L:' . __LINE__ . "多表 主表 真实表名:{$truetablename}");
         $this->createOrderModel($value, $modelname, $truetablename, $add, $isaudit);
     }
     //从表MODEL生成
     foreach ($tablenameArr[1] as $key => $value) {
         // 当前真实表名与Model名
         if ($key != ':0') {
             $modelname = createRealModelName($key);
             //ucfirst($key);
             logs('C:' . __CLASS__ . ' L:' . __LINE__ . "多表 子表model名:{$modelname}");
             $truetablename = strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $key), "_"));
             logs('C:' . __CLASS__ . ' L:' . __LINE__ . "多表 子表 真实表名:{$truetablename}");
             $this->createOrderModel($value, $modelname, $truetablename, $add, $isaudit, true);
         }
     }
     // 生成数据表格的model
     // 获取当前表单中的数据表格
     $sql = "SELECT \n  CONCAT(m.tablename, '_sub_', p.fieldname) AS datatablename,\n  IF(\n    p.title <> '' \n    OR p.title <> NULL,\n    p.title,\n    p.fieldname\n  ) AS title,\n  d.*\nFROM\n  `mis_dynamic_form_propery` AS p \n  LEFT JOIN mis_dynamic_database_mas AS m \n    ON p.formid = m.formid \n   LEFT JOIN \n   `mis_dynamic_form_datatable` AS d\n   ON \n   d.`propertyid`=p.id\nWHERE p.formid ={$formid}\n  AND p.category = 'datatable' \n  AND m.`isprimary` = 1 \n\t\t";
     $obj = M();
     $datatableData = $obj->query($sql);
     foreach ($datatableData as $k => $v) {
         $temp[$v['datatablename']][] = $v;
     }
     foreach ($temp as $k => $v) {
         $modelname = createRealModelName($k);
         //ucfirst($key);
         $this->createDatatableModel($v, $modelname, $k, false, true, true);
     }
 }
    /**
     * @Title: getControl
     * @Description: todo(将组件属性生成组件实际html代码)
     *
     * @param array $controllProperty
     *        	组件信息
     * @param boolean $isedit
     *        	是否是编辑,默认flase:新增
     * @param boolean $isreturnvalue
     *        	是否直接显示值
     * @param boolean $special
     * @author quqiang
     *         @date 2014-8-21 上午10:12:43
     * @throws
     *
     */
    private function getControl($controllProperty, $isedit = false, $isreturnvalue = false, $special = true)
    {
        // 重新取得当前文件的list配置文件
        if ($this->nodeName) {
            $path = DConfig_PATH . "/Models/" . $this->nodeName . "/list.inc.php";
            $detailList = (require $path);
            $this->datalist = $detailList;
        }
        // print_r($this->datalist);
        // if($_POST['nodename']=='MisAutoPvb'){
        // print_r($detailList);
        // }
        if (!is_array($controllProperty)) {
            return '';
        }
        $property = $this->getProperty($controllProperty['catalog']);
        if ($controllProperty[$property['checkfunc']['name']]) {
            $chtml = $controllProperty[$property['checkfunc']['name']];
        }
        $readonly = 0;
        $readonlyStr = '';
        $islockHtml = '<div class="display_none {$classNodeSettingArr[\'' . $controllProperty[$property['fields']['name']] . '\']}">$viewval</div>';
        if (!$controllProperty[$property['islock']['name']]) {
            $chtml .= " readonly";
            $readonly = 1;
            $readonlyStr = "readonly=\"readonly\" ";
        }
        $html = '';
        if ($controllProperty['catalog'] == 'tablabel') {
            $prefTag = "\t\t\t<label class=\"label_new\">" . $controllProperty[$property['title']['name']] . "</label>\r\n\t\t\t\t\t\t\t\t";
        } else {
            $prefTag = "\t\t\t<label class=\"label_new\">{\$fields[\"" . $controllProperty[$property['fields']['name']] . "\"]}:</label>\r\n\t\t\t\t\t\t\t\t";
        }
        $org = '';
        if ($controllProperty[$property['org']['name']]) {
            $org = $controllProperty[$property['org']['name']];
        }
        $required = '';
        // 必填验证
        if ($controllProperty[$property['requiredfield']['name']]) {
            $required = 'required';
        }
        $dropback = "dropback=\"{$controllProperty[$property['dropback']['name']]}\"";
        $chtml = $required . ' ' . $chtml;
        // 读取当前list.inc.php文件
        switch ($controllProperty['catalog']) {
            case 'text':
                // 绑定事件
                $tagEvent = $controllProperty[$property['tagevent']['name']];
                // 获取事件名
                $calculate = $controllProperty[$property['calculate']['name']];
                // 获取事件名
                $tagEventSytr = '';
                if ($tagEvent) {
                    $tagEventSytr = 'on' . ucwords($tagEvent) . '="' . $this->nodeName . '_' . $controllProperty[$property['fields']['name']] . '_' . $tagEvent . '(this);"';
                }
                $tagEventSytr = $dropback . ' ' . $tagEventSytr;
                $valStr = '';
                $unitChangeStr = '';
                if ($isedit) {
                    $unitl = $controllProperty[$property['unitl']['name']];
                    $unitls = $controllProperty[$property['unitls']['name']];
                    if ($unitl && $unitls) {
                        $unitChangeStr = "|unitExchange=###,{$unitl},{$unitls},2";
                    }
                    $valStr = "{\$vo['{$controllProperty[$property['fields']['name']]}']{$unitChangeStr}}";
                }
                if (!$isreturnvalue) {
                    $unitlsStr = '';
                    $unitlsPanelStart = '';
                    $unitlsPanelEnd = '';
                    $unitlsCls = '';
                    $uFStr = '';
                    $defaultCls = 'input_new ';
                    if ($controllProperty[$property['unitls']['name']]) {
                        $unitlsPanelStart = "<div class=\"tml-input-unit\">";
                        $unitlsPanelEnd = '</div>';
                        $unitlsStr = "<span class=\"icon_elm icon_unit\" title=\"{$this->untils[$controllProperty[$property['unitls']['name']]]}\">{$this->untils[$controllProperty[$property['unitls']['name']]]}</span>";
                        // $unitlsCls=' unitlpase ';
                        $defaultCls .= ' half_angle_input';
                        // $uFStr=" unitl=\"{$controllProperty[$property['unitls']['name']]}\" ";
                    }
                    $unitlsCls .= $defaultCls;
                    // checkfor 属性设置
                    // checkfor 当 $controllProperty[$property['checkfortable']['name']] 指定了表名,
                    // $controllProperty[$property['checkforshow']['name']] 显示字段
                    // $controllProperty[$property['checkforbindd']['name']] 绑定真实值
                    // 单换算功能 不能与checkfor功能同用,原因为:checkfor会生成hidden标签,单们换算也会生成hidden无法赋值。
                    /*
                     * if($controllProperty[$property['unitls']['name']]){
                     * $html="\r\n\t\t\t\t\t{$prefTag}<input $tagEventSytr type=\"text\" {$readonlyStr} unitl=\"{$controllProperty[$property['unitls']['name']]}\" name=\"".
                     * $controllProperty[$property['fields']['name']]."\" class=\"input_new {$org} {$unitlsCls} unitlpase {$chtml}\" value=\"".($isedit?"{\$vo['".
                     * $controllProperty[$property['fields']['name']]."']}":'')."\">";
                     * }else{ 单位与checkfor 不共用
                     */
                    if ($controllProperty[$property['checkfortable']['name']]) {
                        $insert = $controllProperty[$property['checkforbindd']['name']] ? htmlspecialchars("insert=\"" . $controllProperty[$property['checkforbindd']['name']] . "\"") : '';
                        // 隐藏域绑定字段名
                        $show = $controllProperty[$property['checkforshow']['name']] ? htmlspecialchars("show=\"" . $controllProperty[$property['checkforshow']['name']] . "\"") : '';
                        // 显示字段名
                        $table = $controllProperty[$property['checkfortable']['name']] ? htmlspecialchars("checkfor=\"" . $controllProperty[$property['checkfortable']['name']] . "\"") : '';
                        // checkfor查询表
                        $orderby = $controllProperty[$property['checkfororderby']['name']] ? htmlspecialchars("order=\"" . $controllProperty[$property['checkfororderby']['name']] . "\"") : '';
                        // 排序条件
                        $iswrite = $controllProperty[$property['checkforiswrite']['name']] ? htmlspecialchars("iswrite=\"" . $controllProperty[$property['checkforiswrite']['name']] . "\"") : '';
                        // 是否清除未找到内容
                        $fileds = $controllProperty[$property['checkfororfields']['name']] ? htmlspecialchars("fields=\"array(" . $controllProperty[$property['checkfororfields']['name']] . ");\"") : '';
                        // 查看字段
                        $map = $controllProperty[$property['checkformap']['name']] ? htmlspecialchars("newconditions=\"" . $controllProperty[$property['checkformap']['name']] . "\"") : '';
                        // 过滤条件
                        $org = '';
                        // 时当前文本框 没得name属性,
                        if ($controllProperty[$property['checkforbindd']['name']]) {
                            $iswrite = '';
                            $hiden = "<input type=\"hidden\" {$uFStr} name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"" . ($isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : '') . "\">";
                            $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$controllProperty[$property['checkforbindd']['name']]}','{$controllProperty[$property['checkforshow']['name']]}','{$controllProperty[$property['checkfortable']['name']]}'}" : '';
                            $html = "\r\n\t\t\t\t\t{$prefTag}{$hiden}\r\n<input {$tagEventSytr} type=\"text\" {$readonlyStr}  class=\"{$org} input_new {$unitlsCls} checkByInput {$chtml}\" \r\n" . "{$table} \r\n" . "{$insert} \r\n" . "{$show} \r\n" . "{$map} \r\n" . "{$orderby} \r\n" . "{$fileds} \r\n" . "{$iswrite} autocomplete=\"on\" value=\"" . $viewval . "\">";
                            // id:{$controllProperty[$property['checkforbindd']['name']]}
                            $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                        } else {
                            $viewval = $valStr;
                            $html = "\r\n\t\t\t\t\t{$prefTag}<input {$uFStr} {$tagEventSytr} type=\"text\" {$readonlyStr} name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$org} {$unitlsCls} input_new {$chtml}\" value=\"" . $viewval . "\">";
                            $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                        }
                    } else {
                        $viewval = $valStr;
                        $html = "\r\n\t\t\t\t\t{$prefTag}<input {$uFStr} {$tagEventSytr} type=\"text\" {$readonlyStr} name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$org} {$unitlsCls} input_new {$chtml}\" value=\"" . $valStr . "\">";
                        $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                    }
                    // }
                } else {
                    /* 查看页面单位转换 */
                    $unitChangeStr = '';
                    $unitl = $controllProperty[$property['unitl']['name']];
                    $unitls = $controllProperty[$property['unitls']['name']];
                    if ($unitl && $unitls) {
                        $unitChangeStr = "|unitExchange=###,{$unitl},{$unitls},3";
                    }
                    $valStr = "{\$vo['{$controllProperty[$property['fields']['name']]}']{$unitChangeStr}}";
                    /**
                     * **************
                     */
                    if ($controllProperty[$property['checkfortable']['name']]) {
                        if ($controllProperty[$property['checkforbindd']['name']]) {
                            // id : {$controllProperty[$property['checkforbindd']['name']]}
                            $viewval = '';
                            $html = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$controllProperty[$property['checkforbindd']['name']]}','{$controllProperty[$property['checkforshow']['name']]}','{$controllProperty[$property['checkfortable']['name']]}'}";
                        } else {
                            $viewval = '';
                            $html = $valStr;
                            // "{\$vo['".$controllProperty[$property['fields']['name']]."']}";
                        }
                    } else {
                        $viewval = '';
                        $html = $valStr;
                        // "{\$vo['".$controllProperty[$property['fields']['name']]."']}";
                    }
                    // $viewval= '';
                    // $islockHtml='';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html = $unitlsPanelStart . htmlspecialchars_decode($html) . $unitlsStr . $unitlsPanelEnd . $islockHtml;
                break;
            case 'password':
                if (!$isreturnvalue) {
                    $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : '';
                    $html = "<input type=\"password\" class=\" input_new\" name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"" . $viewval . "\" />";
                    $html = $prefTag . $html;
                } else {
                    $viewval = '********';
                    $html = $viewval;
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'hiddens':
                if (!$isreturnvalue) {
                    $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : '';
                    $html = "<input type=\"hidden\" class=\"{$org} input_new\" name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"" . $viewval . "\" />";
                } else {
                    $func = "";
                    foreach ($detailList as $dkey => $dval) {
                        if ($dval['name'] == $controllProperty[$property['fields']['name']]) {
                            if ($dval['func']) {
                                $func .= $dval['func'][0][0];
                                if ($dval['func'][0][0] = "getFieldBy") {
                                    $func .= "=";
                                }
                            }
                            if ($dval['funcdata']) {
                                $func .= "'" . $dval['funcdata'][0][0][1];
                                if ($dval['funcdata'][0][0][2]) {
                                    $func .= "','" . $dval['funcdata'][0][0][2] . "','" . $dval['funcdata'][0][0][3] . "'}";
                                } else {
                                    $func .= "'}";
                                }
                            }
                        }
                    }
                    if ($func) {
                        $viewval = '';
                        $html = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|" . $func;
                    } else {
                        $viewval = '';
                        $html = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}";
                    }
                    // $viewval = '';
                    // $islockHtml='';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'tablabel':
                // $html="\r\n\t\t\t\t\t{$prefTag}\r\n<input class=\"{$org} nbm_tablabel\" value=\"\" type=\"text\" readonly=\"readonly\" disabled=\"disabled\" />";
                // $html="\r\n\t\t\t\t\t{$prefTag}\r\n<input class=\"{$org} nbm_tablabel input_new \" value=\"\" type=\"text\" readonly=\"readonly\" disabled=\"disabled\" />";
                $html = "\r\n\t\t\t\t\t{$prefTag}\r\n<input class=\"{$org}  input_new nbm_tablabel\" value=\"\" type=\"text\" readonly=\"readonly\" disabled=\"disabled\" />";
                if ($isreturnvalue) {
                    // $viewval='';
                    // $islockHtml = '';
                }
                $viewval = '';
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'subtitles':
                $html = "\r\n\t\t\t\t\t";
                $style = "style=\"";
                if ($controllProperty[$property['aligntype']['name']]) {
                    $style .= "text-align:" . $controllProperty[$property['aligntype']['name']] . ";";
                } else {
                    $style .= "text-align:{$property['aligntype']['default']};";
                }
                if ($controllProperty[$property['backgroundcolor']['name']]) {
                    $style .= "background:#" . $controllProperty[$property['backgroundcolor']['name']] . ";";
                } else {
                    $style .= "background:#{$property['backgroundcolor']['default']};";
                }
                if ($controllProperty[$property['fontcolor']['name']]) {
                    $style .= "color:#" . $controllProperty[$property['fontcolor']['name']] . ";";
                } else {
                    $style .= "color:#{$property['fontcolor']['default']};";
                }
                if ($controllProperty[$property['fontsize']['name']]) {
                    $style .= "font-size:" . $controllProperty[$property['fontsize']['name']] . "px;";
                } else {
                    $style .= "font-size:{$property['fontsize']['default']}px;";
                }
                if ($controllProperty[$property['fontheight']['name']]) {
                    $style .= "line-height:" . $controllProperty[$property['fontheight']['name']] . "px;";
                } else {
                    $style .= "line-height:{$property['fontheight']['default']}px;";
                }
                if ($controllProperty[$property['fontweight']['name']]) {
                    $style .= "font-weight:" . $controllProperty[$property['fontweight']['name']] . ";";
                } else {
                    $style .= "font-weight:{$property['fontweight']['default']};";
                }
                $style .= "\"";
                $viewval = $controllProperty[$property['title']['name']];
                $html .= "<div class=\"fieldset_legend_toggle side-catalog-text side-catalog-firstanchor\" {$style}>" . "{$viewval}" . "</div>";
                if ($isreturnvalue) {
                    // $viewval='';
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'fiexdtext':
                $html = "\r\n\t\t\t\t\t";
                $style = "style=\"";
                if ($controllProperty[$property['aligntype']['name']]) {
                    $style .= "text-align:" . $controllProperty[$property['aligntype']['name']] . ";";
                } else {
                    $style .= "text-align:{$property['aligntype']['default']};";
                }
                if ($controllProperty[$property['backgroundcolor']['name']]) {
                    $style .= "background:#" . $controllProperty[$property['backgroundcolor']['name']] . ";";
                } else {
                    $style .= "background:#{$property['backgroundcolor']['default']};";
                }
                if ($controllProperty[$property['fontcolor']['name']]) {
                    $style .= "color:#" . $controllProperty[$property['fontcolor']['name']] . ";";
                } else {
                    $style .= "color:#{$property['fontcolor']['default']};";
                }
                if ($controllProperty[$property['fontsize']['name']]) {
                    $style .= "font-size:" . $controllProperty[$property['fontsize']['name']] . "px;";
                } else {
                    $style .= "font-size:{$property['fontsize']['default']}px;";
                }
                if ($controllProperty[$property['fontheight']['name']]) {
                    $style .= "line-height:" . $controllProperty[$property['fontheight']['name']] . "px;";
                } else {
                    $style .= "line-height:{$property['fontheight']['default']}px;";
                }
                /*
                 * 高度影响 页面显示效果
                 * if($controllProperty[$property['contentheight']['name']]){
                 * $style .="height:".$controllProperty[$property['contentheight']['name']]."px;";
                 * }else{
                 * $style .="height:12px;";
                 * }
                 */
                if ($controllProperty[$property['fontweight']['name']]) {
                    $style .= "font-weight:" . $controllProperty[$property['fontweight']['name']] . ";";
                } else {
                    $style .= "font-weight:{$property['fontweight']['default']};";
                }
                // $style .="background:#".$controllProperty[$property['backgroundcolor']['name']]?$controllProperty[$property['backgroundcolor']['name']]:"fff".";";
                // $style .="color:#".$controllProperty[$property['fontcolor']['name']]?$controllProperty[$property['fontcolor']['name']]:'333'.";";
                // $style .="font-size:".$controllProperty[$property['fontsize']['name']]?$controllProperty[$property['fontsize']['name']]:'12' ."px;";
                // $style .="line-height:".$controllProperty[$property['fontheight']['name']]?$controllProperty[$property['fontheight']['name']]:'12'."px;";
                // $style .="height:".$controllProperty[$property['contentheight']['name']]?$controllProperty[$property['contentheight']['name']]:'12'."px;";
                // $style .="font-weight:".$controllProperty[$property['fontweight']['name']]?$controllProperty[$property['fontweight']['name']]:"400".";\"";
                // "border:1px solid #d8d8d8;".
                $style .= "\"";
                // tml-form-text
                $viewval = $controllProperty[$property['title']['name']];
                $html .= "<span class=\"block\" {$style}>{$viewval}</span>";
                if ($isreturnvalue) {
                    // $viewval='';
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'select':
                // 是否只读
                $readonly = $controllProperty[$property['islock']['name']];
                // 绑定的事件
                $targevent = $controllProperty[$property['tagevent']['name']];
                // 数据字段名
                $filedName = $controllProperty[$property['fields']['name']];
                // 组件标题
                $filedTitle = $controllProperty[$property['title']['name']];
                // 默认选中项的值
                $defaultcheckitem = $controllProperty[$property['defaultcheckitem']['name']];
                // 外部传入首选项的值
                $defaultval = $controllProperty[$property['defaultval']['name']];
                // 外部传入首选项的显示文本
                $defaulttext = $controllProperty[$property['defaulttext']['name']];
                // Action名称
                $ActionName = $this->nodeName;
                // 直接显示内容的控制阀
                $isshowresoult = $controllProperty[$property['isshowresoult']['name']];
                // 下拉返回唯一标识
                $dropbackkey = $controllProperty[$property['dropbackkey']['name']];
                $conditions = '';
                // 数据来源方式:table|selectlist
                if ($controllProperty[$property['showoption']['name']]) {
                    $type = 'selectlist';
                    $key = $controllProperty[$property['showoption']['name']];
                } else {
                    if ($controllProperty[$property['subimporttableobj']['name']] || $controllProperty[$property['treedtable']['name']]) {
                        $conditions = $controllProperty[$property['conditions']['name']];
                        $type = 'table';
                        if ($controllProperty[$property['subimporttableobj']['name']]) {
                            // 查询表名
                            $tableName = $controllProperty[$property['subimporttableobj']['name']];
                            // 值字段名
                            $tableVal = $controllProperty[$property['subimporttablefield2obj']['name']];
                            // 显示字段名
                            $tableText = $controllProperty[$property['subimporttablefieldobj']['name']];
                        } elseif ($controllProperty[$property['treedtable']['name']]) {
                            // 查询表名
                            $tableName = $controllProperty[$property['treedtable']['name']];
                            // 值字段名
                            $tableVal = $controllProperty[$property['treevaluefield']['name']];
                            // 显示字段名
                            $tableText = $controllProperty[$property['treeshowfield']['name']];
                            $parentid = $controllProperty[$property['treeparentfield']['name']];
                            // 是否末级操作
                            $mulit = $controllProperty[$property['mulit']['name']];
                            // 是否多选
                            $isnextend = $controllProperty[$property['isnextend']['name']];
                            // 树形-下拉高度
                            $treeheight = $controllProperty[$property['treeheight']['name']];
                            // 树形-下拉宽度
                            $treewidth = $controllProperty[$property['treewidth']['name']];
                            // 树形-是否对话框模式
                            $treedialog = $controllProperty[$property['isdialog']['name']] ? true : false;
                        }
                    }
                }
                // 组件外样式
                $content_cls = "col_" . $controllProperty[$property['titlepercent']['name']] . "_" . $controllProperty[$property['contentpercent']['name']] . " form_group_lay field_" . $controllProperty[$property['fields']['name']];
                $paramArr = '';
                if ($isedit) {
                    $paramArr .= "array(\$vo['{$controllProperty[$property['fields']['name']]}']";
                } else {
                    $paramArr .= "array(''";
                }
                // 拼接class 属性
                $cls = $chtml . ' ' . $org;
                // 拼接组件配置参数
                $subassembly = '';
                $subassembly .= "array('readonly'=>'{$readonly}','targevent'=>'{$targevent}','actionName'=>'{$ActionName}','names'=>'{$filedName}','defaultcheckitem'=>'{$defaultcheckitem}','defaultval'=>'{$defaultval}','defaulttext'=>'{$defaulttext}','table'=>'{$tableName}', 'id'=>'{$tableVal}','name'=>'{$tableText}','conditions'=>'{$conditions}','parentid'=>'{$parentid}','mulit'=>'{$mulit}','isnextend'=>'{$isnextend}','treeheight'=>'{$treeheight}','treewidth'=>'{$treewidth}','treedialog'=>'{$treedialog}','key'=>'{$key}','isedit'=>'{$isedit}','showtype'=>'{$isshowresoult}','dropbackkey'=>'{$dropbackkey}')";
                $param = '';
                $param .= "{$paramArr},array('{$cls}',array('type'=>'{$type}',{$subassembly})))";
                if (!$isreturnvalue) {
                    $viewval = '';
                    $html = "\r\n\t\t\t\t\t{$prefTag}";
                    if ($isedit) {
                        if ($readonly) {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowSelect',{$param})}";
                        } else {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowSelect',{$param})}";
                        }
                    } else {
                        $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowSelect',{$param})}";
                    }
                    if ($controllProperty[$property['subimporttableobj']['name']]) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['subimporttablefield2obj']['name']]}'" . ",'{$controllProperty[$property['subimporttablefieldobj']['name']]}'," . "'{$controllProperty[$property['subimporttableobj']['name']]}'}";
                        // 普通表数据
                        // $html=$viewval;
                    } elseif ($controllProperty[$property['treedtable']['name']]) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['treevaluefield']['name']]}'" . ",'{$controllProperty[$property['treeshowfield']['name']]}'," . "'{$controllProperty[$property['treedtable']['name']]}'}";
                        // 树形数据
                        // $html=$viewval;
                    } else {
                        $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistValue='{$controllProperty[$property['showoption']['name']]}'}";
                        // selectlist数据
                        // $html=$viewval;
                    }
                } else {
                    if ($controllProperty[$property['subimporttableobj']['name']]) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['subimporttablefield2obj']['name']]}'" . ",'{$controllProperty[$property['subimporttablefieldobj']['name']]}'," . "'{$controllProperty[$property['subimporttableobj']['name']]}'}";
                        // 普通表数据
                        $html = $viewval;
                    } elseif ($controllProperty[$property['treedtable']['name']]) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['treevaluefield']['name']]}'" . ",'{$controllProperty[$property['treeshowfield']['name']]}'," . "'{$controllProperty[$property['treedtable']['name']]}'}";
                        // 树形数据
                        $html = $viewval;
                    } else {
                        $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistValue='{$controllProperty[$property['showoption']['name']]}'}";
                        // selectlist数据
                        $html = $viewval;
                    }
                    // $viewval='';
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'checkbox':
                $checked = "";
                $tagEvent = $controllProperty[$property['tagevent']['name']];
                // 获取事件名
                $conditions = '';
                $tagEventSytr = '';
                if ($tagEvent) {
                    $tagEventSytr = 'on' . ucwords($tagEvent) . '="' . $this->nodeName . '_' . $controllProperty[$property['fields']['name']] . '_' . $tagEvent . '(this)"';
                }
                $html = "\r\n\t\t\t\t\t{$prefTag}";
                if (!$isreturnvalue) {
                    $viewval = '';
                    if ($controllProperty[$property['subimporttableobj']['name']]) {
                        $conditions = $controllProperty[$property['conditions']['name']];
                        $html .= "{:getControllbyHtml('table',array('type'=>'checkbox','names'=>'{$controllProperty[$property['fields']['name']]}[]','targevent'=>'{$tagEventSytr}','table'=>'{$controllProperty[$property['subimporttableobj']['name']]}','id'=>'{$controllProperty[$property['subimporttablefield2obj']['name']]}','name'=>'{$controllProperty[$property['subimporttablefieldobj']['name']]}','conditions'=>'{$conditions}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}";
                    } else {
                        $html .= "{:getControllbyHtml('selectlist',array('type'=>'checkbox','names'=>'{$controllProperty[$property['fields']['name']]}[]','targevent'=>'{$tagEventSytr}','key'=>'{$controllProperty[$property['showoption']['name']]}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}";
                    }
                } else {
                    if ($controllProperty[$property['subimporttableobj']['name']]) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|excelTplidTonameAppend=" . "'{$controllProperty[$property['subimporttablefield2obj']['name']]}'," . "'{$controllProperty[$property['subimporttablefieldobj']['name']]}'" . ",'{$controllProperty[$property['subimporttableobj']['name']]}'}";
                        $html = $viewval;
                    } else {
                        $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistByName='{$controllProperty[$property['showoption']['name']]}'}";
                        $html = $viewval;
                    }
                    $viewval = '';
                    $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'radio':
                $checked = "";
                $conditions = '';
                $tagEvent = $controllProperty[$property['tagevent']['name']];
                // 获取事件名
                $tagEventSytr = '';
                if ($tagEvent) {
                    $tagEventSytr = 'on' . ucwords($tagEvent) . '="' . $this->nodeName . '_' . $controllProperty[$property['fields']['name']] . '_' . $tagEvent . '(this)"';
                }
                if (!$isreturnvalue) {
                    $html = "\r\n\t\t\t\t\t{$prefTag}";
                    if ($controllProperty[$property['subimporttableobj']['name']]) {
                        $conditions = $controllProperty[$property['conditions']['name']];
                        $html .= "{:getControllbyHtml('table',array('type'=>'radio','targevent'=>'{$tagEventSytr}','names'=>'{$controllProperty[$property['fields']['name']]}','table'=>'{$controllProperty[$property['subimporttableobj']['name']]}','id'=>'{$controllProperty[$property['subimporttablefield2obj']['name']]}','name'=>'{$controllProperty[$property['subimporttablefieldobj']['name']]}','conditions'=>'{$conditions}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}";
                    } else {
                        $html .= "{:getControllbyHtml('selectlist',array('type'=>'radio','targevent'=>'{$tagEventSytr}','names'=>'{$controllProperty[$property['fields']['name']]}','key'=>'{$controllProperty[$property['showoption']['name']]}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}";
                    }
                } else {
                    if ($controllProperty[$property['subimporttableobj']['name']]) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['subimporttablefield2obj']['name']]}'" . ",'{$controllProperty[$property['subimporttablefieldobj']['name']]}'," . "'{$controllProperty[$property['subimporttableobj']['name']]}'}";
                        $html = $viewval;
                    } else {
                        $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistValue='{$controllProperty[$property['showoption']['name']]}'}";
                        $html = $viewval;
                    }
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'textarea':
                $html = '';
                $richBoxCls = '';
                if ($controllProperty[$property['isrichbox']['name']]) {
                    $richBoxCls = 'ueditor';
                }
                if (!$isreturnvalue) {
                    $rows = 4;
                    $cols = 100;
                    if ($controllProperty[$property['rows']['name']]) {
                        $rows = $controllProperty[$property['rows']['name']];
                    }
                    if ($controllProperty[$property['cols']['name']]) {
                        $cols = $controllProperty[$property['cols']['name']];
                    }
                    $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : '';
                    $val = "";
                    if ($viewval) {
                        $textareahtml = "<if condition=\"\$vo['" . $controllProperty[$property['fields']['name']] . "']\">{\$vo['" . $controllProperty[$property['fields']['name']] . "']}<else/>" . $controllProperty[$property['defaultval']['name']] . "</if>";
                    } else {
                        $textareahtml = "";
                    }
                    $html = "\r\n\t\t\t\t\t{$prefTag}<textarea  {$readonlyStr} cols=\"{$cols}\" rows=\"{$rows}\" class=\"{$chtml} text_area {$richBoxCls} {$org}\" name=\"" . $controllProperty[$property['fields']['name']] . "\">" . $textareahtml . "</textarea>";
                    // .$islockHtml;
                } else {
                    if ($controllProperty[$property['isrichbox']['name']]) {
                        $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|richtext2str}";
                    } else {
                        $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']}";
                    }
                    $html = $viewval;
                    // $islockHtml = '';
                    // $viewval = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                if ($controllProperty[$property['isrichbox']['name']]) {
                    $islockHtml = '';
                }
                $html .= $islockHtml;
                break;
            case 'date':
                $style = "";
                $format = '';
                $format1 = '';
                $formatSouce = '';
                if ($controllProperty[$property['format']['name']]) {
                    $formatSouce = $controllProperty[$property['format']['name']];
                } else {
                    $formatSouce = $property['format']['default'];
                }
                if ($formatSouce) {
                    $temp = '';
                    $temp = explode('@', $formatSouce);
                    $format = "format=\"{dateFmt:'" . $temp[0] . "'}\"";
                    if ($temp[1]) {
                        $format1 = "='{$temp[1]}'";
                    }
                }
                if (!$isreturnvalue) {
                    // 直接显示内容的控制阀
                    $isshowresoult = $controllProperty[$property['isshowresoult']['name']];
                    $dateControllCls = '';
                    $dateJsEventTag = ' Wdate js-wdate';
                    $a = 'js-inputCheckDate';
                    // 只读
                    if (!$controllProperty[$property['islock']['name']]) {
                        $a = '';
                        $dateJsEventTag = '';
                        $dateControllCls = $chtml;
                    }
                    if ($isedit) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|transtime{$format1}}";
                        $html = "\r\n\t\t\t\t\t{$prefTag}";
                        if ($isshowresoult) {
                            $html .= "\r\n\t\t\t\t\t<span class=\"input_new\">{$viewval}</span>";
                        } else {
                            $html .= "\r\n\t\t\t\t\t<div  class=\"tml-input-calendar\">\r\n\t\t\t\t\t<input type=\"text\" name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$required} {$org} input_new half_angle_input {$dateJsEventTag} input_left {$dateControllCls}\" {$format}  {$readonlyStr} value=\"{$viewval}\"/>";
                            $html .= "\r\n\t\t\t\t\t<a href=\"javascript:;\" class=\"icon_elm icon-calendar {$a} \"></a>";
                            $html .= "\r\n\t\t\t\t</div>";
                        }
                    } else {
                        $viewval = '';
                        $html = "\r\n\t\t\t\t\t{$prefTag}";
                        if ($isshowresoult) {
                            $html .= "\r\n\t\t\t\t\t<span class=\"input_new\">{$viewval}</span>";
                        } else {
                            $html .= "\r\n\t\t\t\t\t<div  class=\"tml-input-calendar\">\r\n\t\t\t\t\t<input type=\"text\" name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$required} {$org} input_new half_angle_input {$dateJsEventTag} input_left {$dateControllCls}\" {$format} {$readonlyStr} value=\"{$viewval}\"/>";
                            $html .= "\r\n\t\t\t\t\t<a href=\"javascript:;\" class=\"icon_elm icon-calendar {$a} \"></a>";
                        }
                        $html .= "\r\n\t\t\t\t</div>";
                    }
                } else {
                    $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|transtime{$format1}}";
                    $html = $viewval;
                    // $islockHtml = '';
                    // $viewval= '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'checkfor':
                break;
            case 'lookup':
                $html = '';
                if (!$isreturnvalue) {
                    $lookupchoice = $controllProperty[$property['lookupchoice']['name']];
                    $lookupObj = D('LookupObj');
                    $lookupDetail = $lookupObj->GetLookupDetail($lookupchoice);
                    $model = $lookupDetail['mode'];
                    $orgchar = $lookupDetail['filed'] ? $lookupDetail['filed'] : 'name';
                    $orgval = $lookupDetail['val'] ? $lookupDetail['val'] : 'id';
                    if (1 == $lookupDetail['viewtype'] && $orgval != $orgchar) {
                        $configObj = D('MisSystemDataviewMasView');
                        $viewConfig = $configObj->getViewConf($lookupDetail['viewname']);
                        $searchField = $viewConfig[$orgval]['searchField'];
                        $orderModelArr = explode('.', $searchField);
                        if ($orderModelArr[0] && $searchField) {
                            $tempModel = D($orderModelArr[0]);
                        }
                    } else {
                        $tempModel = D($model);
                    }
                    // 当lookup配置中的存储值与显示一致时不需要做值转换。nbmxkj@20150608 1610
                    $viewval = $isedit ? $orgval == $orgchar ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : '';
                    $html = "\r\n\t\t\t\t\t\t{$prefTag}";
                } else {
                    $func = "";
                    // 处理子表及主表的lookup值转换 , modify by nbmxkj at 20150127 20
                    // *****注意:func 与 funcdata 数组项一定要个数对应。****
                    foreach ($this->datalist as $dkey => $dval) {
                        if ($dval['name'] == $controllProperty[$property['fields']['name']]) {
                            $count = count($dval['func'][0]);
                            if ($dval['func']) {
                                $func .= $dval['func'][0][$count - 1];
                                // if($dval['func'][0][0]="getFieldBy"){
                                $func .= "=";
                                // }
                            }
                            if ($dval['funcdata']) {
                                $func .= "'" . $dval['funcdata'][0][$count - 1][1];
                                if ($dval['funcdata'][0][$count - 1][1]) {
                                    $func .= "','" . $dval['funcdata'][0][$count - 1][2] . "','" . $dval['funcdata'][0][$count - 1][3] . "'}";
                                } else {
                                    $func .= "'}";
                                }
                            }
                        }
                    }
                    if ($func) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|" . $func;
                    } else {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}";
                    }
                }
                $html .= "\r\n\t\t\t\t\t\t\t\t{:W('Lookup',array('1',\$vo,'{$controllProperty[$property['id']['name']]}','{$isedit}','{$isreturnvalue}'))}";
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= "\r\n\t\t\t\t\t\t\t\t" . $islockHtml;
                break;
            case 'lookupsuper':
                if (!$isreturnvalue) {
                    // 获取lookup key值 动态加载lookup配置
                    $lookupchoice = $controllProperty[$property['lookupchoice']['name']];
                    $lookupObj = D('LookupObj');
                    $lookupDetail = $lookupObj->GetLookupDetail($lookupchoice);
                    $model = $lookupDetail['mode'];
                    $urls = $lookupDetail['url'];
                    $lookupgroup = $controllProperty[$property['lookupgroup']['name']];
                    $orgchar = $lookupDetail['filed'] ? $lookupDetail['filed'] : 'name';
                    $orgval = $lookupDetail['val'] ? $lookupDetail['val'] : 'id';
                    $orgLookuoVal = $controllProperty[$property['org1']['name']];
                    // 显示绑定
                    $orgLookupText = $controllProperty[$property['org']['name']];
                    // 值绑定
                    $title = "{\$fields[\"" . $controllProperty[$property['fields']['name']] . "\"]}";
                    $view = '';
                    if ($lookupDetail['viewname']) {
                        $view = '&viewname=' . $lookupDetail['viewname'];
                    }
                    if ($lookupDetail['dt']) {
                        $dtcon = '&lookuptodatatable=2';
                    }
                    $conditions = '';
                    $checkformodel = $lookupDetail['checkformodel'];
                    // checkfor的org显示字段
                    $checkfororgchar = $detailList['field'] ? $detailList['field'] : $orgchar;
                    // lookup的org值字段
                    // lookup的值反写
                    $textCounterCheck = '';
                    // 显示文本的反写 text
                    $valCounterCheck = '';
                    // 值的反写 value
                    // lporder 从外部lookup中取值字段
                    // lpkey 当前lookup的key
                    // lpfor 往哪个东西里写值
                    // lpself 当前项的字段名称
                    if ($orgLookuoVal) {
                        unset($temp);
                        $temp = explode('.', $orgLookuoVal);
                        $valCounterCheck = "callback=\"lookup_counter_check\" lpkey=\"{$lookupchoice}\" lpfor=\"{$lookupgroup}.{$orgchar}\" lpself=\"{$orgval}\" lporder=\"{$temp[1]}\"";
                    }
                    if ($orgLookupText) {
                        unset($temp);
                        $temp = explode('.', $orgLookupText);
                        $textCounterCheck = "callback=\"lookup_counter_check\" lpkey=\"{$lookupchoice}\" lpfor=\"{$lookupgroup}.{$orgval}\" lpself=\"{$orgchar}\" lporder=\"{$temp[1]}\"";
                    }
                    // checkfor的列表显示字段
                    $checkfororgshowfield = $detailList['checkfororgshowfield'] ? $detailList['checkfororgshowfield'] : '';
                    // $urls = $controllProperty[$property['geturls']['name']];
                    // $lookupgroup = $controllProperty[$property['lookupgroup']['name']];
                    // $filedback = $controllProperty[$property['filedback']['name']];
                    // $model = $controllProperty[$property['model']['name']];
                    // $checkformodel = $controllProperty[$property['checkformodel']['name']];
                    // $orgchar = $controllProperty[$property['lookuporg']['name']]?$controllProperty[$property['lookuporg']['name']]:'name';
                    // $orgval = $controllProperty[$property['lookuporgval']['name']]?$controllProperty[$property['lookuporgval']['name']]:'id';
                    // checkfor的org显示字段
                    // $checkfororgchar = $controllProperty[$property['checkfororg']['name']]?$controllProperty[$property['checkfororg']['name']]:$orgchar;
                    // checkfororfields
                    // checkfor显示字段
                    // $checkfororgshowfield = $controllProperty[$property['checkfororgshowfield']['name']]?$controllProperty[$property['checkfororgshowfield']['name']]:'';
                    // $conditions = $controllProperty[$property['conditions']['name']]; // auditState,3;status,1;ischange,0
                    // $title = "{\$fields[\"".$controllProperty[$property['fields']['name']]."\"]}";
                    $val = '';
                    $tempModel = D($model);
                    $html = "\r\n\t\t\t\t\t\t{$prefTag}<div class=\"tml-input-lookupSuper\">";
                    if ($readonly) {
                        // checkfor 文本框 $checkfororgchar
                        $html .= "\r\n\t\t\t\t\t\t<input type=\"text\" class=\"{$lookupgroup}.{$checkfororgchar} {$chtml} lookupSuper_input input_new half_angle_input\" autocomplete=\"off\" readonly=\"readonly\"  value=\"" . ($isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : '') . "\" />";
                    } else {
                        // $html .="\r\n\t\t\t\t\t\t<input type=\"text\" class=\"{$lookupgroup}.{$checkfororgchar} {$chtml} \" autocomplete=\"off\" value=\"".($isedit?"{\$vo['".$controllProperty[$property['fields']['name']]."']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}":'')."\" />";
                        if ($checkfororgshowfield) {
                            $fileds = "array(" . $checkfororgshowfield . ");";
                        } else {
                            $fileds = '';
                        }
                        $html .= "\r\n\t\t\t\t\t\t<input type=\"text\" " . "autocomplete=\"off\" " . "checkfor=\"{$checkformodel}\" " . "insert=\"{$orgval}\" " . "show=\"{$checkfororgchar}\" " . "name=\"{$checkfororgchar}\" " . "newconditions=\"{$conditions}\" " . "fields=\"{$fileds}\" " . "other " . "value=\"" . ($isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='id','{$orgchar}','{$tempModel->getTableName()}'}" : '') . "\" " . "class=\"{$lookupgroup}.{$checkfororgchar} checkByInput lookupSuper_input input_new half_angle_input {$chtml}\">";
                    }
                    // checkfor 文本框的隐藏域
                    $html .= "\r\n\t\t\t\t\t\t<input type=\"hidden\" class=\"{$lookupgroup}.{$orgval}\" name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"{\$vo['" . $controllProperty[$property['fields']['name']] . "']}\" />";
                    if ($readonly) {
                        // 只读情况
                        $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : '';
                        // lookup 触发按钮
                        $html .= "\r\n\t\t\t\t\t\t<a class=\"icon_elm mid_icon_elm icon-plus\"></a>";
                        // looup 默认显示框
                        $html .= "<input type=\"text\" readonly=\"readonly\" class=\"{$lookupgroup}.{$orgchar} input_new square_input readonly valid\"\tcheck_key=\"othername\" name=\"{$lookupgroup}{$orgchar}\" value=\"" . $viewval . "\">";
                        // 清空 lookup 按钮
                        $html .= "\r\n\t\t\t\t\t\t<a title=\"清空信息\" class=\"icon_elm icon-trash\"  href=\"javascript:void(0);\"></a>";
                    } else {
                        $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : '';
                        // lookup 触发按钮
                        $html .= "\r\n\t\t\t\t\t\t<a class=\"icon_elm mid_icon_elm icon-plus\" param=\"lookupchioce={$lookupchioce}&newconditions={$conditions}{$view}{$dtcon}\" href=\"__URL__/{$urls}\" lookupGroup=\"{$lookupgroup}\" ></a>";
                        // $title
                        // looup 默认显示框
                        $html .= "<input type=\"text\" readonly=\"readonly\" class=\"{$lookupgroup}.{$orgchar} textInput input_new square_input readonly valid\"\tcheck_key=\"{$orgchar}\" name=\"{$lookupgroup}{$orgchar}\" value=\"" . $viewval . "\">";
                        // 清空 lookup 按钮
                        // $html .="\r\n\t\t\t\t\t\t<a title=\"清空信息\" class=\"input-addon input-addon-recycle\" href=\"javascript:void(0);\" onclick=\"clearInput('{$checkfororgchar},{$controllProperty[$property['fields']['name']]},{$lookupgroup}{$orgchar}');\"></a>";
                        $html .= "\r\n\t\t\t\t\t\t<a title=\"清空信息\" class=\"icon_elm icon-trash\"  href=\"javascript:void(0);\" onclick=\"clearOrg('{$lookupgroup}');\"></a>";
                    }
                    $html .= "\r\n\t\t\t\t\t\t</div>";
                } else {
                    // $html="{\$vo['".$controllProperty[$property['fields']['name']]."']}";
                    $func = "";
                    // 处理子表及主表的lookup值转换 , modify by nbmxkj at 20150127 20
                    // *****注意:func 与 funcdata 数组项一定要个数对应。****
                    foreach ($this->datalist as $dkey => $dval) {
                        if ($dval['name'] == $controllProperty[$property['fields']['name']]) {
                            $count = count($dval['func'][0]);
                            if ($dval['func']) {
                                $func .= $dval['func'][0][$count - 1];
                                // if($dval['func'][0][0]="getFieldBy"){
                                $func .= "=";
                                // }
                            }
                            if ($dval['funcdata']) {
                                $func .= "'" . $dval['funcdata'][0][$count - 1][1];
                                if ($dval['funcdata'][0][$count - 1][1]) {
                                    $func .= "','" . $dval['funcdata'][0][$count - 1][2] . "','" . $dval['funcdata'][0][$count - 1][3] . "'}";
                                } else {
                                    $func .= "'}";
                                }
                            }
                        }
                    }
                    if ($func) {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|" . $func;
                        $html = $viewval;
                    } else {
                        $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}";
                        $html = $viewval;
                    }
                    // $viewval='';
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'upload':
                // 数据字段名
                $filedName = $controllProperty[$property['fields']['name']];
                // 组件标题
                $filedTitle = $controllProperty[$property['title']['name']];
                // 上传数量
                $uploadNum = $controllProperty[$property['uploadnum']['name']];
                // 上传类型
                $uploadType = $controllProperty[$property['uploadtype']['name']];
                $param = 'array("0"=>$uploadarry["' . $filedName . '"],"1"=>' . $filedName . ',"2"=>$fields[' . $filedName . '],"3"=>"' . $uploadNum . '","4"=>"' . $uploadType . '")';
                $viewval = '';
                if (!$isreturnvalue) {
                    if ($isedit) {
                        if ($readonly) {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUpload',{$param})}";
                        } else {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUpload',{$param})}";
                        }
                    } else {
                        $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUpload',{$param})}";
                    }
                } else {
                    $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUploadView',{$param})}";
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'userselect':
                $viewval = '';
                if (!$isreturnvalue) {
                    if ($isedit) {
                        if ($readonly) {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUserSelect',\$attarry)}" . $islockHtml;
                        } else {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUserSelect',\$attarry)}" . $islockHtml;
                        }
                    } else {
                        $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUserSelect')}";
                    }
                } else {
                    // 视图模式
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'areainfo':
                $viewval = '';
                // 数据字段名
                $filedName = $controllProperty[$property['fields']['name']];
                // 组件标题
                $filedTitle = $controllProperty[$property['title']['name']];
                // 组件外样式
                $content_cls = "col_" . $controllProperty[$property['titlepercent']['name']] . "_" . $controllProperty[$property['contentpercent']['name']] . " form_group_lay field_" . $controllProperty[$property['fields']['name']];
                $param = 'array("0"=>$areainfoarry["' . $filedName . '"],"1"=>' . $filedName . ',"2"=>$fields[' . $filedName . '],"3"=>"' . $content_cls . '","5"=>"' . $required . '")';
                $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}";
                if (!$isreturnvalue) {
                    if ($isedit) {
                        if ($readonly) {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowArea',{$param})}" . $islockHtml;
                        } else {
                            $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowArea',{$param})}" . $islockHtml;
                        }
                    } else {
                        $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowArea',{$param})}";
                    }
                } else {
                    $html = $viewval;
                    // $viewval='';
                    // $islockHtml = '';
                }
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            case 'datatable':
                $viewval = '';
                $titles = <<<EOF
\t
\t\t\t\t<if condition="\$fields['{$controllProperty[$property['fields']['name']]}']">
\t\t\t\t<div class="into_table_title">{\$fields["{$controllProperty[$property['fields']['name']]}"]}</div>
\t\t\t\t</if>
EOF;
                /* 获取字段信息 */
                $filedTag = $property['fieldlist']['name'];
                // 获取配置信息中的标识名称
                // 获取所有节点
                $configPath = $controllProperty;
                $controlName = $controlTag = $controllProperty[$property['fields']['name']];
                // 组件唯一标识 datatable8,......
                $tableName = $this->tableName . '_sub_' . $controlTag;
                $namses = "datatable[#index#][{$controlName}]";
                if ($configPath) {
                    $innerTableFieldInfo = $configPath[$filedTag];
                    // 获取到内嵌表字段设置信息
                }
                $innerTableFieldInfoObj = json_decode(htmlspecialchars_decode($innerTableFieldInfo), true);
                // 得到字段信息json对象数据
                usort($innerTableFieldInfoObj, function ($a, $b) {
                    $al = $a['fieldsort'];
                    $bl = $b['fieldsort'];
                    if ($al == $bl) {
                        return 0;
                    }
                    return $al < $bl ? -1 : 1;
                });
                $innerTableFieldInfoObj = json_decode(json_encode($innerTableFieldInfoObj));
                // 修改及展示 页面组件列表
                $showandeditfieldlist = '';
                $filedList = "";
                $filedList .= "<th style='width:40px;' template_key=\"serial\" >";
                $filedList .= "\t\t\t\t序号";
                $filedList .= "\t\t\t</th>";
                $count = 0;
                $nameKey = '';
                foreach ($innerTableFieldInfoObj as $key => $val) {
                    if ($val->fieldshow == 1) {
                        // 0 允许编辑, 1:不可编辑
                        $isDatatableEdit = intval($val->isedit) ? false : true;
                        $editStatusConfig = '';
                        if (!$isDatatableEdit) {
                            $editStatusConfig = 'is_readonly=true';
                        }
                        $dt_readonly = "";
                        $class_readonly = "";
                        $int_readonly = 1;
                        if ($editStatusConfig) {
                            // 内嵌表控件不可编辑
                            $dt_readonly = "readonly='readonly'";
                            $class_readonly = "readonly";
                            $int_readonly = 0;
                        }
                        $nameKey = "template_controll={$val->fieldname}";
                        switch ($val->fieldshowtype) {
                            case 'text':
                                //查询公式
                                $misDynamicFormDatatableModel = M('mis_dynamic_form_datatable');
                                $datatablemap['id'] = $val->fieldid;
                                $datatableList = $misDynamicFormDatatableModel->where($datatablemap)->find();
                                $validdigit = $datatableList['validdigit'] ? $datatableList['validdigit'] : 2;
                                $fieldname = $datatableList['fieldname'];
                                $calculate = $datatableList['calculate'];
                                $subassembly = $datatableList['subassembly'];
                                $subassemblyArr = explode(',', $subassembly);
                                $formulaType = $datatableList['type'];
                                $formulaJindu = $datatableList['jindu'];
                                //替换id
                                $inputString = "";
                                $FormulArr = array();
                                foreach ($subassemblyArr as $sk => $sval) {
                                    $propertymap['id'] = $sval;
                                    $properyList = $misDynamicFormDatatableModel->where($propertymap)->find();
                                    $name = $properyList['fieldname'];
                                    $FormulArr[$sval] = $name;
                                }
                                // @todo
                                $calculateString = preg_replace_callback('/(\\[(.*?)\\])+/', function ($callbackParame) use($FormulArr) {
                                    return '[' . $FormulArr[$callbackParame[2]] . ']';
                                }, $calculate);
                                $config = '';
                                $orgConfigVal = '';
                                $dataConfig = '';
                                if ($val->fieldshowtypeconfig) {
                                    $config = unserialize(base64_decode($val->fieldshowtypeconfig));
                                }
                                $curCls = '';
                                if (is_array($config)) {
                                    // 将组件属性转换为html代码
                                    $dataConfig = $config['parame'];
                                    // 获取select的配置项
                                    if (!$controllProperty['ganshe_datatable'] && $config['required']) {
                                        $curCls .= ' required ';
                                    }
                                    if ($config['checktype']) {
                                        $curCls .= $config['checktype'];
                                    }
                                }
                                $orgSet = '';
                                if (is_array($dataConfig)) {
                                    $orgConfigVal = $dataConfig[0];
                                    if ($orgConfigVal) {
                                        $orgSet = $orgConfigVal;
                                    }
                                }
                                $untilsCls = '';
                                $unit = $config['baseuntils'];
                                // 基础单位
                                $untils = $config['untils'];
                                // 显示单位
                                $tempData = '';
                                $template_data = '';
                                $orgshowfield = '';
                                logs('org set ::' . $orgSet);
                                if ($orgSet) {
                                    $orgshowfield = str_replace('org', "org{\$key}", $orgSet);
                                    $temp = explode('.', $orgSet);
                                    if (is_array($temp)) {
                                        $template_data['bindlookupname'] = $temp[0];
                                        $template_data['upclass'] = $temp[1];
                                    }
                                }
                                if ($untils && $unit) {
                                    $template_data['unitl'] = $config['untils'];
                                    $template_data['unitlname'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $config['untilschar']));
                                }
                                // 添加统计功能
                                // is_stats="true" 统计控制
                                //
                                $stats_num = 'stats_num=\\"2\\"';
                                // 统计时的小数有效位数
                                $is_stats = '';
                                // 统计状态
                                $edit_count_str = '';
                                // 编辑时统计数据
                                $edit_count_cls = '';
                                // 统计的标识样式
                                $y_num = "";
                                if ($datatableList['calculate']) {
                                    $edit_calculate_cls = ' calc ';
                                    // 计算样式
                                    $template_data['formula'] = $calculateString;
                                    $template_data['stats_num'] = $validdigit;
                                    $template_data['formulaType'] = $formulaType;
                                    $template_data['formulaJindu'] = $formulaJindu;
                                }
                                if ($val->fieldcount == 1) {
                                    $is_stats = ' is_stats="true" ';
                                    $edit_count_str = " y_num=\"{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},2}\"";
                                    $edit_count_cls = ' into_table_tj_input ';
                                    $stats_num = $datatableList['stats_num'] ? "stats_num=\"{$datatableList['stats_num']}\"" : $stats_num;
                                    //"stats_num=\"{$config['stats_num']}\""; // 指定有效位数。
                                    if ($unit && $untils) {
                                        $y_num = "y_num='{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},2}'";
                                    } else {
                                        $y_num = "y_num='{\$item[{$val->fieldname}]}'";
                                    }
                                }
                                if (is_array($template_data)) {
                                    $tempData = "template_data='" . _urldecode(json_encode($template_data)) . "'";
                                }
                                if ($untils && $unit) {
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>";
                                    $showandeditfieldlist .= <<<EOF
\t\t\t
\t\t\t\t\t\t\t\t\t<div class="list_group_lay" style="display: none;">
\t\t\t\t\t\t\t\t\t\t<div class="list_public_lay">
\t\t\t\t\t\t\t\t\t\t\t<input type="text" {$y_num} {$dt_readonly} class="{$class_readonly} {$orgshowfield} {$edit_calculate_cls}  {$edit_count_cls} {$curCls} list_unit_input list_public_input" {$edit_count_str} disabled="disabled" name="#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]" value="{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},2}">
\t\t\t\t\t\t\t\t\t\t\t<span class="list_icon_elm_unit" title="{$config['untilschar']}">{$config['untilschar']}
\t\t\t\t\t\t\t\t\t\t\t</span>
\t\t\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t\t<span class="datatable_show_val">{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},3}</span>
EOF;
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>";
                                } else {
                                    $showandeditfieldlist .= <<<EOF
\t\t\t\t\t\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t\t\t\t\t<div class="list_group_lay" style="display: none;">
\t\t\t\t\t\t\t\t\t\t\t<input type="text" {$dt_readonly} {$y_num} class="list_input {$class_readonly} {$edit_calculate_cls}  {$untilsCls} {$orgshowfield} {$edit_count_cls} {$curCls}" disabled="disabled" name="#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]" {$untils} value="{\$item[{$val->fieldname}]}" />
\t\t\t\t\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t\t\t\t\t<span class="datatable_show_val">{\$item[{$val->fieldname}]}</span>
\t\t\t\t\t\t\t\t\t\t\t\t</td>
EOF;
                                }
                                // 统计绑定表头文本框字段
                                $bindhz = "";
                                if ($val->countassignment && $val->fieldcount) {
                                    $bindhz = "bindhz=\"{$val->countassignment}\"";
                                }
                                $filedList .= "\r\n<th {$bindhz} style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"input\" template_name=\"{$namses}[{$val->fieldname}]\" {$tempData} {$stats_num}";
                                $filedList .= "\r\n{$is_stats} {$editStatusConfig}\ttemplate_class=\"{$untilsCls} {$curCls}\" {$nameKey}>";
                                // unitlpase
                                $filedList .= "\r\n{$val->fieldtitle}";
                                $filedList .= "\r\n</th>";
                                // logs($filedList);
                                break;
                            case 'select':
                                unset($template_data);
                                /*
                                 * template_key="select"
                                 * template_data='[{"value":1,"name":"第一人"},{"value":2,"name":"第二人"}]'
                                 * template_class="code"
                                 */
                                $config = '';
                                if ($val->fieldshowtypeconfig) {
                                    $config = unserialize(base64_decode($val->fieldshowtypeconfig));
                                }
                                $curCls = '';
                                if (is_array($config)) {
                                    // 将组件属性转换为html代码
                                    $lookupConfig = $config['datasouceparame'];
                                    // 获取select的配置项
                                    $lookuptolookupconfig = $config['lookto'];
                                    $dateConfig = $config['parame'];
                                    // 获取select的配置项
                                    if (!$controllProperty['ganshe_datatable'] && $config['required']) {
                                        $curCls .= ' required ';
                                    }
                                    if ($config['checktype']) {
                                        $curCls .= $config['checktype'];
                                    }
                                }
                                // 下拉组件org效果
                                $orgSet = '';
                                if (is_array($dateConfig)) {
                                    $orgConfigVal = $dateConfig['org'];
                                    if ($orgConfigVal) {
                                        $orgSet = $orgConfigVal;
                                    }
                                }
                                if ($orgSet) {
                                    $orgshowfield = str_replace('org', "org{\$key}", $orgSet);
                                    $temp = explode('.', $orgSet);
                                    if (is_array($temp)) {
                                        $template_data['bindlookupname'] = $temp[0];
                                        $template_data['upclass'] = $temp[1];
                                    }
                                }
                                $dateOrgConfig = '';
                                // 对现有DB数据编辑时的 org 属性解析。
                                $orgshowfield = '';
                                if ($orgSet) {
                                    $orgshowfield = str_replace('org', "org{\$key}", $orgSet);
                                    $temp = explode('.', $orgSet);
                                    if (is_array($temp)) {
                                        $template_data['lookupname'] = $temp[0];
                                        $template_data['name'] = $temp[1];
                                    }
                                    $dateOrgConfig = 'bindlookup=\'' . json_encode($template_data) . '\'';
                                }
                                $dataSouceArr = '';
                                $getControllbyHtmlStr = "";
                                if ($lookuptolookupconfig[0]) {
                                    // 如果有lookup带回
                                    $l = array();
                                    foreach ($innerTableFieldInfoObj as $k => $v) {
                                        if ($k == $lookuptolookupconfig[0]) {
                                            $l = unserialize(base64_decode($v->fieldshowtypeconfig));
                                        }
                                    }
                                    $lookmodel = D("LookupObj");
                                    $lookuplist = $lookmodel->GetLookupDetail($l['parame'][0]);
                                    // $lookupParame['lpkey'] = reset($lookupConfig);//$l['parame'][0];
                                    $lookupParame['lporder'] = $l[$lookuptolookupconfig[1]];
                                    // $lookupobjmodel = D("lookupObj");
                                    // $c = reset($lookupConfig);
                                    // $lookuplist = $lookupobjmodel->GetLookupDetail($c);
                                    // $lookupParame['lpfor'] = $lookuplist['val'];
                                    // $lookupParame['lpself'] = $lookuplist['field'];
                                    // lporder 从外部lookup中取值字段
                                    // lpkey 当前lookup的key ?
                                    // lpfor 往哪个东西里写值
                                    // lpself 当前项的字段名称
                                }
                                $template_key = "select";
                                if ($config['datasouce'] == 0) {
                                    // 数据源为 select list
                                    $selectInc = $lookupConfig[0];
                                    // lookup时
                                    if ($lookupParame['lporder']) {
                                        $selectInc = $lookupParame['lporder'];
                                    }
                                    $getControllbyHtmlStr = '{:getControllbyHtml("selectlist",array("type"=>"select","key"=>"' . $selectInc . '"))}';
                                    if ($selectInc) {
                                        $selectlistData = $this->getSelectList($selectInc);
                                        if (is_array($selectlistData[$selectInc])) {
                                            foreach ($selectlistData[$selectInc] as $selk => $selv) {
                                                $temp['value'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $selk));
                                                $temp['name'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $selv));
                                                $dataSouceArr[] = $temp;
                                            }
                                        }
                                        $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td><div style='display: none;' class='list_group_lay'>";
                                        $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<select class=\"list_select2 {$class_readonly} {$orgshowfield} {$curCls} \" data-placeholder=\"没有可用数据\"";
                                        $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\">";
                                        $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:getControllbyHtml('selectlist',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'key'=>'{$selectInc}','selected'=>\$item['{$val->fieldname}']))}";
                                        $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</select></div><span class='datatable_show_val'>{:getControllbyHtml('selectlist',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'key'=>'{$selectInc}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>";
                                        $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>";
                                    }
                                } else {
                                    // 数据源为 table
                                    if ($lookupConfig[0] && $lookupConfig[1] && $lookupConfig[2]) {
                                        if ($lookupConfig['treeparentfield']) {
                                            $template_key = "selecttree";
                                            // 设置为树形结构
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div style='display: none;' class='list_group_lay'>";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:W('ShowSelectDT',array(\$item['{$val->fieldname}'], array(' {$curCls} ',array('type'=>'table',array('readonly'=>'1','targevent'=>'','actionName'=>'{$this->nodeName}','names'=>\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\",'defaultcheckitem'=>'','defaultval'=>'','defaulttext'=>'','table'=>'{$lookupConfig[0]}', 'id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','conditions'=>'','parentid'=>'{$lookupConfig['treeparentfield']}','mulit'=>'{$lookupConfig['mulit']}','isnextend'=>'{$lookupConfig['isnextend']}','treeheight'=>'{$lookupConfig['treeheight']}','treewidth'=>'{$lookupConfig['treewidth']}','key'=>'','isedit'=>'{$int_readonly}','showtype'=>'0','namesappend'=>'{$val->fieldname}#index#')))))}";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</div><span class='datatable_show_val'>{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>{$lookupConfig[0]},'id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>";
                                            $chkStyle = "radio";
                                            if ($lookupConfig["mulit"] == 1) {
                                                $chkStyle = "checkbox";
                                            }
                                            $isnextend = $lookupConfig['isnextend'] == 1 ? 1 : 0;
                                            $dataSouceArr = '{"treeconfig":' . '{"expandAll":false,' . '"checkEnable":true,' . '"chkStyle":"' . $chkStyle . '",' . '"radioType":"all",' . '"onClick":"S_NodeClick",' . '"onCheck":"S_NodeCheck"},' . '"treeheight":"' . $lookupConfig['treeheight'] . '",' . '"treewidth":"' . $lookupConfig['treewidth'] . '",' . '"treedata":<?php ' . 'echo getControllbyHtml(' . '"table",' . 'array("type"=>"select",' . '"table"=>"' . $lookupConfig[0] . '",' . '"id"=>"' . $lookupConfig[2] . '",' . '"name"=>"' . $lookupConfig[1] . '",' . '"showtype"=>"1",' . '"comboxtree"=>"1",' . '"parentid"=>"' . $lookupConfig['treeparentfield'] . '",' . '"isnextend"=>' . $isnextend . ')); ' . '?>}';
                                        } else {
                                            $obj = M($lookupConfig[0]);
                                            $data = $obj->field("{$lookupConfig[1]} , {$lookupConfig['2']}")->select();
                                            $getControllbyHtmlStr = '{:getControllbyHtml("table",array("type"=>"select","table"=>"' . $lookupConfig[0] . '","id"=>"' . $lookupConfig[2] . '","name"=>"' . $lookupConfig[1] . '"))}';
                                            if ($data) {
                                                foreach ($data as $dk => $dv) {
                                                    $temp['value'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $dv[$lookupConfig[2]]));
                                                    $temp['name'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $dv[$lookupConfig[1]]));
                                                    $dataSouceArr[] = $temp;
                                                }
                                            }
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div style='display: none;' class='list_group_lay'><select class=\"list_select2 {$class_readonly} {$orgshowfield} {$curCls} \" data-placeholder=\"没有可用数据\"";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\">";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}']))}";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</select></div><span class='datatable_show_val'>{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>";
                                            $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>";
                                        }
                                    }
                                }
                                if (empty($getControllbyHtmlStr) && is_array($dataSouceArr)) {
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div style='display: none;' class='list_group_lay'><select class=\"list_select2 {$class_readonly} {$orgshowfield} {$curCls} \" data-placeholder=\"没有可用数据\"";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\">";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}']))}";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</select></div><span class='datatable_show_val'>{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>";
                                }
                                $template_data = $dataSouceArr;
                                if (is_array($dataSouceArr)) {
                                    $template_data = urldecode(json_encode($dataSouceArr));
                                }
                                // select绑定表头下拉框字段
                                $bindGroup = "";
                                if ($config["selectassignment"]) {
                                    $bindGroup = "bindGroup=\"{$config['selectassignment']}\"";
                                }
                                $filedList .= "\r\n\t\t\t<th {$bindGroup} style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key='{$template_key}' template_name=\"{$namses}[{$val->fieldname}]\"  {$dateOrgConfig}";
                                $filedList .= "\r\n\t\t\ttemplate_data='{$template_data}' {$editStatusConfig}";
                                $filedList .= "\r\n\t\t\ttemplate_html='{$getControllbyHtmlStr}'";
                                $filedList .= "\r\n\t\t\ttemplate_class=\" {$curCls} \"  {$nameKey}>";
                                $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}";
                                $filedList .= "\r\n\t\t\t</th>";
                                break;
                            case 'date':
                                $config = '';
                                if ($val->fieldshowtypeconfig) {
                                    $config = unserialize(base64_decode($val->fieldshowtypeconfig));
                                }
                                $curCls = '';
                                if (is_array($config)) {
                                    // 将组件属性转换为html代码
                                    $dateConfig = $config['parame'];
                                    // 获取select的配置项
                                    if (!$controllProperty['ganshe_datatable'] && $config['required']) {
                                        $curCls .= ' required ';
                                    }
                                    if ($config['checktype']) {
                                        $curCls .= $config['checktype'];
                                    }
                                }
                                $format = $dateConfig['0'] ? $dateConfig['0'] : 'yyyy-MM-dd';
                                $format1 = '';
                                switch ($format) {
                                    case 'yyyy-MM-dd':
                                        $format1 = "='Y-m-d'";
                                        break;
                                    case 'yyyy-MM-dd HH:mm':
                                        $format1 = "='Y-m-d H:i'";
                                        break;
                                    case 'yyyy-MM':
                                        $format1 = "='Y-m'";
                                        break;
                                    case 'MM-dd':
                                        $format1 = "='m-d'";
                                        break;
                                    case 'yyyy':
                                        $format1 = "='Y'";
                                        break;
                                    case 'MM':
                                        $format1 = "='m'";
                                        break;
                                    case 'dd':
                                        $format1 = "='d'";
                                        break;
                                    case 'HH:mm':
                                        $format1 = "='H:i'";
                                        break;
                                    default:
                                        break;
                                }
                                // 日期组件org效果
                                $orgSet = '';
                                if (is_array($dateConfig)) {
                                    $orgConfigVal = $dateConfig['org'];
                                    if ($orgConfigVal) {
                                        $orgSet = $orgConfigVal;
                                    }
                                }
                                $dateOrgConfig = '';
                                // 对现有DB数据编辑时的 org 属性解析。
                                $orgshowfield = '';
                                if ($orgSet) {
                                    unset($template_data);
                                    $orgshowfield = str_replace('org', "org{\$key}", $orgSet);
                                    $temp = explode('.', $orgSet);
                                    if (is_array($temp)) {
                                        $template_data['lookupname'] = $temp[0];
                                        $template_data['name'] = $temp[1];
                                    }
                                    $dateOrgConfig = 'bindlookup=' . json_encode($template_data);
                                }
                                //
                                $filedList .= "\r\n\t\t\t<th style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"date\" template_name=\"{$namses}[{$val->fieldname}]\" {$dateOrgConfig} ";
                                $filedList .= "\r\n\t\t\ttemplate_data='{\"format\":\"{$format}\"}' {$editStatusConfig}";
                                $filedList .= "\r\n\t\t\ttemplate_class=\" {$curCls} \"  {$nameKey}>";
                                $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}";
                                $filedList .= "\r\n\t\t\t</th>";
                                $showandeditfieldlist .= <<<EOF
\t
\t\t\t\t\t\t\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t\t\t\t\t\t<div class="list_group_lay" style='display: none;'>
\t\t\t\t\t\t\t\t\t\t\t\t<input type="text" {$dt_readonly} disabled="disabled" name="#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]" class="Wdate js-wdate list_input {$orgshowfield} {$class_readonly}  {$curCls} " format="{dateFmt:'{$format}'}" value="{\$item.{$val->fieldname}|transTime{$format1}}">
\t\t\t\t\t\t\t\t\t\t\t\t</div>
\t\t\t\t\t\t\t\t\t\t\t\t<span class='datatable_show_val'>{\$item.{$val->fieldname}|transTime{$format1}}</span>
\t\t\t\t\t\t\t\t\t\t\t\t</td>
EOF;
                                break;
                            case 'uploadfilenew':
                                $config = '';
                                if ($val->fieldshowtypeconfig) {
                                    $config = unserialize(base64_decode($val->fieldshowtypeconfig));
                                }
                                $filedList .= "\r\n\t\t\t<th style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"uploadfilenew\" template_name=\"{$namses}[{$val->fieldname}]\" ";
                                $filedList .= "\r\n\t\t\ttemplate_data='{\"url\":\"__URL__/DT_uploadnew\"}' {$editStatusConfig} ";
                                $filedList .= "\r\n\t\t\ttemplate_class=\"\"  {$nameKey}>";
                                $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}";
                                $filedList .= "\r\n\t\t\t</th>";
                                $uploadFileType = '';
                                if ($isreturnvalue || $editStatusConfig) {
                                    $uploadFileType = 'rel_type="view"';
                                }
                                $fileattlist = $this->getDTAttachedRecordList($tableid, $tablename = '', $subid = 0, $fieldname);
                                $tableModelname = createRealModelName($tableName);
                                $showandeditfieldlist .= <<<EOF
\t\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t<div class="list_group_lay">
\t\t\t\t\t\t\t<div class="js_privyIndex">
\t\t\t\t\t\t\t<a
\t\t\t\t\t\t\ttitle="附件管理"
\t\t\t\t\t\t\tclass="tml_task_btn"
\t\t\t\t\t\t\tstyle="padding:3px 10px;"
\t\t\t\t\t\t\thref="javascript:;"
\t\t\t\t\t\t\tid="DT_upload_{$val->fieldname}#index#"
\t\t\t\t\t\t\trel_index="#index#"
\t\t\t\t\t\t\trel_url="__URL__/DT_uploadnew"
\t\t\t\t\t\t\trel_subid="{\$item['id']}"
\t\t\t\t\t\t\trel_fieldname = "{$val->fieldname}"
\t\t\t\t\t\t\trel_tablename = "{$tableModelname}"
\t\t\t\t\t\t\trel_tableid = "{\$vo['id']}"
\t\t\t\t\t\t\t\t\t\t\t{$uploadFileType}
\t\t\t\t\t\t\t\t\t\t\trel_name="datatable[#index#][{$controlTag}][{$val->fieldname}]"
\t\t\t\t\t\t\t\t\t\t\t\tonclick="DTopenFile(this)">
\t\t\t\t\t\t\t\t\t\t\t\t\t\t附件管理(<span class="attached_count">{\$item.id|getDTCount=\$vo['id'],'{$tableModelname}',###,'{$val->fieldname}'}</span>)
\t\t\t\t\t\t\t\t\t\t\t\t\t\t</a></div></div>
\t\t\t\t\t\t\t\t\t\t\t\t\t\t</td>
EOF;
                                break;
                            case 'lookup':
                                $lookupParame = '';
                                $config = '';
                                $parme = '';
                                $lookupurl = '';
                                $callbackFileds = '';
                                $modelName = '';
                                $conditionsStr = '';
                                $showFiled = '';
                                $valField = '';
                                $lookupConfig = '';
                                $orgval = '';
                                $appendCondtionStr = '';
                                $appendCondtionArr = array();
                                if ($val->fieldshowtypeconfig) {
                                    $config = unserialize(base64_decode($val->fieldshowtypeconfig));
                                }
                                $curCls = '';
                                if (is_array($config)) {
                                    // 将组件属性转换为html代码
                                    $lookupConfig = $config['parame'];
                                    // 获取lookup等特殊组件的配置项
                                    $lookuptolookupconfig = $config['ltol'];
                                    if (!$controllProperty['ganshe_datatable'] && $config['required']) {
                                        $curCls .= ' required ';
                                    }
                                    if ($config['checktype']) {
                                        $curCls .= $config['checktype'];
                                    }
                                }
                                $dataTableEventControll = $config['fieldname'];
                                if ($lookupConfig[0]) {
                                    // 用户配置了lookup前置对象
                                    // 获取指定项的lookup配置内容
                                    $lookupConfigData = $this->lookuoconfig(false, true);
                                    $lookupConfigData = $lookupConfigData[reset($lookupConfig)];
                                    // fields 带回字段列表
                                    // url 请求地址
                                    // mode 处理Model
                                    // filed 显示字段
                                    // val 值字段
                                    // condition 过滤条件
                                    $lookupurl = '__URL__/' . $lookupConfigData['url'];
                                    // 请求地址
                                    $callbackFileds = "{$lookupConfigData['fields']}";
                                    // 带回字段列表
                                    $modelName = "{$lookupConfigData['mode']}";
                                    // 处理Model
                                    $lookupConfigData['filed'] = $lookupConfigData['filed'] ? $lookupConfigData['filed'] : 'name';
                                    $showFiled = "{$lookupConfigData['filed']}";
                                    // 显示字段
                                    $lookupConfigData['val'] = $lookupConfigData['val'] ? $lookupConfigData['val'] : "id";
                                    $valField = "{$lookupConfigData['val']}";
                                    // 值字段
                                    if (1 == $lookupConfigData['viewtype']) {
                                        $configObj = D('MisSystemDataviewMasView');
                                        $viewConfig = $configObj->getViewConf($lookupConfigData['viewname']);
                                        $searchField = $viewConfig[$valField]['searchField'];
                                        $orderModelArr = explode('.', $searchField);
                                        if ($orderModelArr[0] && $searchField) {
                                            $tempModel = D($orderModelArr[0]);
                                        }
                                    } else {
                                        $tempModel = D($lookupConfigData['mode']);
                                    }
                                    $modelName = $tempModel->getTableName();
                                    // throw new NullDataExcetion(var_dump($modelName));
                                    $conditionsStr = '';
                                    // $lookupConfigData['condition'] ? preg_replace("/'/", '&#39;', $lookupConfigData['condition']).' and ' : '';
                                    // $parme[]="field={$lookupConfigData['fields']}";
                                    // $parme[]="model={$lookupConfigData['mode']}";
                                    // //////////////////////////////////////////////////////////////////////////////////////
                                    // lookup附加条件处理
                                    $appendCondtion = '';
                                    $sysFieldFmt = '';
                                    $sysFieldList = '';
                                    $formFiledList = '';
                                    $fd = '';
                                    $formFiledListArr = '';
                                    $formFiledFmt = '';
                                    $appendCondtionArr = '';
                                    $appendCondtionStr = '';
                                    // iscontrollchange
                                    // {:getAppendCondition($vo,'wenbenkuang,createtime')}
                                    $appendCondtion = $config['dateconditions'];
                                    // 附加条件设置信息
                                    logs($dataTableEventControll . '::::' . arr2string($appendCondtion), 'fffffffffffffffffffff');
                                    if ($appendCondtion) {
                                        $appendCondtion = unserialize(base64_decode($appendCondtion));
                                        // 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);
                                                $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();
                                        }
                                        $appendCondtionStr = arr2string($appendCondtionArr);
                                        $appendCondtionStr = "<?php echo getAppendCondition(\$vo,{$appendCondtionStr}) ?>";
                                    }
                                    $parme[] = "lookupchoice=" . reset($lookupConfig) . '&type=dt';
                                    $parme[] = "newconditions={$conditionsStr}{$appendCondtionStr}";
                                    // getAppendCondition
                                    if ($lookuptolookupconfig[0]) {
                                        // 如果有lookup带回lookup
                                        $ll = array();
                                        // lporder 从外部lookup中取值字段
                                        $lookupParame1['lporder'] = "ORG" . $lookuptolookupconfig[0];
                                        // lpkey 当前lookup的key
                                        $lookupParame1['lpkey'] = reset($lookupConfig);
                                        // lporder 从外部lookup中取值字段
                                        // lpkey 当前lookup的key ?
                                        // lpfor 往哪个东西里写值
                                        // lpself 当前项的字段名称
                                    }
                                }
                                $orgval = $lookupConfig[1];
                                // ? $lookupConfig[1] : 'org_'.$val->fieldname.rand(1, 100);
                                $onEditParame = '';
                                $paramStr = '';
                                if (is_array($parme)) {
                                    $paramStr = join('&', $parme);
                                    $onEditParame = join('&', $parme);
                                }
                                // 拼接lookup参数
                                $lookupParame['upclass'] = $showFiled;
                                $lookupParame['callback'] = 'lookup_counter_check';
                                //'lookupDataToCell';
                                $lookupParame['param'] = $paramStr;
                                $lookupParame['condition'] = array_flip($appendCondtionArr);
                                // $appendCondtionArr;//
                                $lookupParame['lookupname'] = $orgval;
                                $lookupParame['href'] = $lookupurl;
                                $lookupParame['hidden_data'] = array(array('upclass' => $valField, 'name' => "{$namses}[{$val->fieldname}]"));
                                // 回写 lookup中指定的值字段名。当前字段名。lookup->lookup
                                if ($lookuptolookupconfig[0]) {
                                    $lookupParame['bindlookupname'] = 'org' . $lookuptolookupconfig[0];
                                    $lookupParame['lporder'] = $lookuptolookupconfig[1];
                                    //$lookupParame1 ['lporder'];
                                    $lookupParame['lpkey'] = $lookupParame1['lpkey'];
                                    $lookupParame['hidden_data'] = array(array('upclass' => $valField, 'name' => "{$namses}[{$val->fieldname}]", "lporder" => $lookuptolookupconfig[1]));
                                }
                                $filedList .= "\r\n\t\t\t<th style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"lookup\" \r\n ";
                                $filedList .= "\r\n \t\t\ttemplate_name=\"\" \r\n ";
                                $filedList .= "\r\n\t\ttemplate_data='" . urldecode(json_encode($lookupParame)) . "' {$editStatusConfig} \r\n";
                                $filedList .= "\r\n\t\t\ttemplate_class=\" {$curCls} \"  {$nameKey}>";
                                $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}";
                                $filedList .= "\r\n\t\t\t</th>";
                                // org 没设定哦。
                                $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>";
                                $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div class='list_group_lay' style='display: none;'><div class=\"list_public_lay\">";
                                $lookupvaluechange = '';
                                if ($valField && $showFiled && $modelName) {
                                    $lookupvaluechange = "{\$item.{$val->fieldname}|getFieldBy='{$valField}','{$showFiled}','{$modelName}'}";
                                } else {
                                    $lookupvaluechange = "{\$item.{$val->fieldname}}";
                                }
                                if ($editStatusConfig) {
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"text\" callback=\"\" class=\"list_public_input list_lookup_input readonly org{\$key}{$val->fieldname}.{$showFiled} \" readonly=\"readonly\" value=\"{$lookupvaluechange}\">";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" class=\"org{\$key}{$val->fieldname}.{$valField} {$curCls}\" disabled=\"disabled\" name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\" value=\"{\$item.{$val->fieldname}}\">";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a class=\"list_icon_elm list_mid_icon_elm icon-plus\"></a>";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a title=\"清空信息\" class=\"list_icon_elm icon-trash\" href=\"javascript:void(0);\"></a>";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</div></div>";
                                } else {
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"text\" callback=\"\" class=\"list_public_input list_lookup_input readonly org{\$key}{$val->fieldname}.{$showFiled} \" readonly=\"readonly\" value=\"{$lookupvaluechange}\">";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" class=\"org{\$key}{$val->fieldname}.{$valField} {$curCls}\" disabled=\"disabled\" name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\" value=\"{\$item.{$val->fieldname}}\">";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a class=\"list_icon_elm list_mid_icon_elm icon-plus\" param=\"{$onEditParame}\" href=\"{$lookupurl}\" lookupgroup=\"org{\$key}{$val->fieldname}\" autocomplete=\"off\"></a>";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a title=\"清空信息\" class=\"list_icon_elm icon-trash\" href=\"javascript:void(0);\" onclick=\"clearOrg('org{\$key}{$val->fieldname}');\"></a>";
                                    $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</div></div>";
                                }
                                $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<span class='datatable_show_val'>{$lookupvaluechange}</span>";
                                $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>";
                                break;
                        }
                        $count++;
                    }
                }
                // logs($count);
                // table 组件的操作类型设置@20141211 nbmxkj
                $tableoprate = '';
                $container = '';
                $containerend = '';
                $oprateItem = '';
                $dataTableModelName = createRealModelName($tableName);
                $tableOprateTitle = <<<EOF
\t\t\t\t<th style='width:90px;' template_data='{"table":"{$controlName}","post_table":"{$tableName}","post_url":"__URL__/onesave","del_url":"__URL__/delsubinfo/delmodel/{$dataTableModelName}"}' template_key="action">操作</th>
EOF;
                $tableOprateContent = <<<EOF
\t
\t\t\t\t<td {$oprateItem}>
\t\t\t\t\t\t<input type="hidden" name="#hide#datatable[#index#][{$controlTag}][id]" value="{\$item.id}" />
\t\t\t\t\t\t<button title="删除" type="button" class="into_table_new_trash_tr into_table_btn itb_del" del_url="__URL__/delsubinfo/delmodel/{$dataTableModelName}" del_id="{\$item.id}" del_table="{$tableName}"  nbmonclick="del_sub_info('{$this->nodeName}','{$tableName}',{\$item.id},this)">
\t\t\t\t\t\t<span class="icon-remove"></span></button>
\t\t\t\t\t\t<button post_id="{\$item.id}" post_url="__URL__/onesave" post_id="{\$item.id}" post_table="{$tableName}" rel_type="edit" class="save_row_btn" type="button" title="编辑"><span class="icon-pencil"></span></button>
\t\t\t\t\t</td>
EOF;
                if ($isreturnvalue) {
                    $tableoprate = 'view';
                    $tableOprateContent = '';
                    $tableOprateTitle = '';
                    // $container='<div class="temp_cell_right">';
                    // $containerend='</div>';
                    $oprateItem = 'style="display:none"';
                } else {
                    if ($isedit) {
                        $tableoprate = 'edit';
                    } else {
                        $tableoprate = 'add';
                    }
                }
                $datatableID = 'dt_' . $controlName . rand_string() . '_' . $tableoprate;
                $orgTag = $controllProperty[$property['org']['name']];
                // 获取数据表格的数据带回绑定标识
                $dataTableCallBackFunc = 'nbm_datatable_callback';
                $datatableLookupInsertDataTag = '';
                if ($orgTag) {
                    // 取得组件记录的ID值。
                    $propertyid = $controllProperty[$property['id']['name']];
                    // 从这个表中得到对应关系 。 `mis_dynamic_form_indatatable`
                    // datafieldname:当前这个数据表格的字段名。
                    // datainfieldname:这个是 带回数据表格中取值的字段名。
                    // 允许组合方式:{datafieldname:datainfieldname},
                    // datafieldname: a, b , c ,d
                    // datainfieldname: e , f ,g ,h
                    // {a:e},{b:e},{c:e}
                    // 在需要回绑表时将数据的key带回数据的表名)查询出来。即当前表关联信息中记录的表
                    $relationData = $controllProperty[$property['dtlookup']['name']];
                    $relationData = unserialize(base64_decode($relationData));
                    $relationDataTableName = key($relationData);
                    $relation = reset($relationData);
                    $relation = $relation['list'];
                    $relation = json_encode($relation);
                    // dtkey: 从哪个表中的得数据。
                    // dtid:当前这个数据表格的ID值
                    // dtrelation:字段对应关系
                    $datatableLookupInsertDataTag = <<<EOF
\t\t\t\t\t\t\t
\t\t\t\t\t\t<input style="display:none;" type="text" value="datatableinsert" class="{$orgTag}.datatable_data" dtrelation='{$relation}' dtkey="{$relationDataTableName}" dtid="{$datatableID}" callback="{$dataTableCallBackFunc}" />
EOF;
                }
                $temp = <<<EOF
\t
\t\t\t\t\t\t\t\t\t\t\t\t{$container}
\t\t\t\t\t\t\t\t\t\t\t\t<div class="into_table_lay">
\t\t\t\t\t\t\t\t\t\t\t\t{$datatableLookupInsertDataTag}
\t\t\t\t\t\t\t\t\t\t\t\t{$titles}
\t\t\t\t\t\t\t\t\t\t\t\t<table class="into_table_new nbm_data_table" table_data='{"formModel":"{$this->nodeName}","datatableModel":"{$dataTableModelName}","importUrl":"__APP__/MisImportExcel/misimportexceladd"}' id="{$datatableID}" table_type="{$tableoprate}">
\t\t\t\t\t\t\t\t\t\t\t\t<thead>
\t\t\t\t\t\t\t\t\t\t\t\t<tr class="thead_tr">
\t\t\t\t\t\t\t\t\t\t\t\t{$filedList}
\t\t\t\t\t\t\t\t\t\t\t\t{$tableOprateTitle}
\t\t\t\t\t\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t\t\t\t\t\t</thead>
\t\t\t\t\t\t\t\t\t\t\t\t<tbody cellpadding="0" cellspacing="1">
EOF;
                /**
                 * *************现有数据的修改展示*****************************
                 */
                $temp .= <<<EOF
\t
\t\t\t\t\t\t\t\t\t\t\t\t{~\$key=0;}
\t\t\t\t\t\t\t\t\t\t\t\t<volist name="innerTabelObj{$controlTag}Data" id="item">
\t\t\t\t\t\t\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t\t\t\t\t\t<td>
\t\t\t\t\t\t\t\t\t\t\t\t<span class="serial_number">
\t\t\t\t\t\t\t\t\t\t\t\t{\$key+1}
\t\t\t\t\t\t\t\t\t\t\t\t</span>
\t\t\t\t\t\t\t\t\t\t\t\t</td>
\t\t\t\t\t\t\t\t\t\t\t\t<!-- 现有数据 -->
\t\t\t\t\t\t\t\t\t\t\t\t{$showandeditfieldlist}
\t\t\t\t\t\t\t\t\t\t\t\t{$tableOprateContent}
\t\t\t\t\t\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t\t\t\t\t\t{~\$key++}
\t\t\t\t\t\t\t\t\t\t\t\t</volist>
EOF;
                /**
                 * *****************现有数据呈现end*************************
                 */
                $temp .= "\t</tbody>";
                /*
                 * $temp .="	<tfoot>";
                 * $temp .="		<tr>";
                 * $temp .="			<td colspan=\"".($count+2)."\">";
                 * $temp .="				<span class=\"right\">";
                 * $temp .="					<input class=\"add_col_input\" type=\"text\" />";
                 * $temp .="					<a class=\"add_col_btn\" href=\"#\">";
                 * $temp .="						新增行";
                 * $temp .="					</a>";
                 * $temp .="				</span>";
                 * $temp .="			</td>";
                 * $temp .="		</tr>";
                 * $temp .="	</tfoot>";
                 */
                $temp .= "</table></div>{$containerend}";
                $html = $temp;
                $islockHtml = parameReplace('$viewval', $viewval, $islockHtml);
                $html .= $islockHtml;
                break;
            default:
                $html = '';
        }
        return $html;
    }
Ejemplo n.º 3
0
 /**
  * @Title: onesave
  * @Description: todo(子表单条数据保存)  
  * @author 王昭侠
  * @date 2015-07-23 17:42:56
  * @parame $_POST['table'] 表名
  * @parame $_POST['id'] 数据ID值
  * @parame $_POST['masid'] 数据父表ID值
  * @throws
  */
 function onesave()
 {
     $table = $_REQUEST['post_table'];
     $id = intval($_REQUEST['post_id']);
     $masid = intval($_REQUEST['post_mas_id']);
     if ($table && !empty($_POST['datatable'])) {
         $model = D(createRealModelName($table));
         $insertData = array();
         // 数据添加缓存集合
         $updateData = array();
         // 数据修改缓存集合
         if ($_POST['datatable']) {
             foreach ($_POST['datatable'] as $key => $val) {
                 foreach ($val as $k => $v) {
                     if ($id) {
                         $updateData[$k][] = $v;
                     } else {
                         $v["masid"] = $masid;
                         $insertData[$k][] = $v;
                     }
                 }
             }
         }
         //数据处理
         if ($insertData) {
             foreach ($insertData as $k => $v) {
                 foreach ($v as $key => $val) {
                     $id = $model->add($val);
                 }
             }
         }
         if ($updateData) {
             foreach ($updateData as $k => $v) {
                 foreach ($v as $key => $val) {
                     $model->save($val);
                 }
             }
         }
         $this->success('保存成功', true, $id);
     }
 }
 /**
  * 收集删除数据
  * @Title: collecttodata
  * @Description: todo(收集删除数据)
  *
  * @author quqiang
  *         @date 2015年7月14日 下午2:46:42
  * @throws
  *
  */
 function collecttodata()
 {
     $basepath = ROOT . '/Dynamicconf/truncate';
     deldir($basepath);
     mk_dir($basepath);
     $obj = M('mis_dynamic_form_manage');
     $map['isrecord'] = 0;
     $data = $obj->where($map)->select();
     /**
      * 动态表单删除文件数据收集流程:
      * 1:action、model、view、actionExtend、modelExtend、模板文件
      * 2:销毁动态配置下的Models项、Sytem下的listInc
      * 3:获取所有需要清除的表,主表、子表、内嵌表
      */
     /**
      * 单文件删除列表
      *
      * @var unknown_type
      */
     $destriyFileList = array();
     /**
      * 文件夹删除列表
      *
      * @var unknown_type
      */
     $destriyFolderList = array();
     /**
      * 要删除的action名称,可以用于node节点删除
      */
     $actionList = array();
     /**
      * 要删除的Model名称
      */
     $modelList = array();
     foreach ($data as $k => $v) {
         $actionName = $v['actionname'];
         if ($actionName) {
             // 1
             // action , actionExtend
             $destriyFileList[] = LIB_PATH . "Action/" . $actionName . "Action.class.php";
             $destriyFileList[] = LIB_PATH . "Action/" . $actionName . "ExtendAction.class.php";
             // Model , ModelExtend , View
             $destriyFileList[] = LIB_PATH . "Model/" . $actionName . "Model.class.php";
             $destriyFileList[] = LIB_PATH . "Model/" . $actionName . "ExtendModel.class.php";
             $destriyFileList[] = LIB_PATH . "Model/" . $actionName . "ViewModel.class.php";
             // 模板文件目录
             $destriyFolderList[] = TMPL_PATH . C('DEFAULT_THEME') . '/' . $actionName;
             // 2
             // Models , 组件配置文件
             $dir = '/autoformconfig/';
             $destriyFolderList[] = C('DYNAMIC_PATH') . '/Models/' . $actionName;
             $destriyFileList[] = C('DYNAMIC_PATH') . '/autoformconfig/' . $actionName . '.php';
             // 要移除的action列表
             $actionList[] = $actionName;
         }
     }
     $modelList = $actionList;
     $model = M();
     // 3
     // 内嵌表名
     $dtNameSql = "SELECT\n\t\t\t\tCONCAT(mas.`tablename` , '_sub_' , pro.`fieldname` ) AS dtname\n\t\t\tFROM\n\t\t\t  mis_dynamic_form_manage AS ma \n\t\t\t  LEFT JOIN \n\t\t\t  `mis_dynamic_database_mas` AS mas\n\t\t\t  ON\n\t\t\t  ma.`id` = mas.`formid`\n\t\t\t  LEFT JOIN mis_dynamic_form_propery AS pro \n\t\t\t    ON ma.`id` = pro.`formid` \n\t\t\tWHERE ma.`isrecord` = 0 \n\t\t\t  AND pro.`category` = 'datatable' \n\t\t\t  ";
     // 实际使用表,按子表、非复用表、复用表 顺序排序
     $needDelteSql = "SELECT \n\t\t\t  mas.tablename\n\t\t\tFROM\n\t\t\t  `mis_dynamic_form_manage` AS ma \n\t\t\t  LEFT JOIN `mis_dynamic_database_mas` AS mas \n\t\t\t    ON ma.`id` = mas.`formid` \n\t\t\tWHERE ma.`isrecord` = 0 \n\t\t\t  AND mas.`tablename` IS NOT NULL \n\t\t\tORDER BY mas.`isprimary` ASC,\n\t\t\t  mas.`ischoise` ASC ";
     $needDeleteDatatableData = $model->query($dtNameSql);
     $needDeleteTableData = $model->query($needDelteSql);
     // 获取当前库中的所有表
     $sql = "SHOW TABLES;";
     $allTable = $model->query($sql);
     unset($temp);
     foreach ($allTable as $k => $v) {
         $temp[] = reset($v);
     }
     $allTable = $temp;
     // 处理数据表删除列表数据
     $needDeleteDatatableDataTemp = $needDeleteDatatableData;
     $needDeleteDatatableData = '';
     foreach ($needDeleteDatatableDataTemp as $k => $v) {
         if (in_array($v['dtname'], $allTable)) {
             // 只记录在库的内嵌表
             $destriyFileList[] = LIB_PATH . "Model/" . createRealModelName($v['dtname']) . "Model.class.php";
             $needDeleteDatatableData[] = $v['dtname'];
         }
     }
     $needDeleteTableDataTemp = $needDeleteTableData;
     $needDeleteTableData = '';
     foreach ($needDeleteTableDataTemp as $k => $v) {
         if (in_array($v['tablename'], $allTable)) {
             // 只记录在库的业务表
             $needDeleteTableData[] = $v['tablename'];
         }
     }
     $needDeleteTableData = array_unique($needDeleteTableData);
     $needDeleteDatatableData = array_unique($needDeleteDatatableData);
     file_put_contents($basepath . '/file.log', join(',', $destriyFileList));
     file_put_contents($basepath . '/folder.log', join(',', $destriyFolderList));
     file_put_contents($basepath . '/dt.log', join(',', $needDeleteDatatableData));
     file_put_contents($basepath . '/table.log', join(',', $needDeleteTableData));
     file_put_contents($basepath . '/action.log', join(chr(13) . chr(10), $actionList));
 }
Ejemplo n.º 5
0
 public function _after_update()
 {
     //修改当前节点的前置节点
     $linkid = $_REQUEST['id'];
     $linkInfo = $_REQUEST['predecessorid'];
     $MisSystemFlowLinkModel = D("MisSystemFlowLink");
     $MisSystemFlowLinkModel->setLinkWork($linkid, $linkInfo, 1);
     $MisSystemFlowWorkModel = D('MisSystemFlowWork');
     if ($_REQUEST['predecessorid']) {
         //存在前置任务,则对数据字段进行修改
         $MisSystemFlowWorkModel->where("id = " . $_REQUEST['id'])->setField("issubtask", 1);
     } else {
         //不存在存在前置任务,则对数据字段进行修改
         $MisSystemFlowWorkModel->where("id = " . $_REQUEST['id'])->setField("issubtask", 0);
     }
     $MisSystemFlowWorkModel->pJAccesslist2($_POST['formobj'], $linkid);
     $this->lookupinserttinfo($_POST['id']);
     // 内嵌表数据添加处理		// 内嵌表数据添加处理
     $datatablefiexname = "mis_system_flow_form_sub_";
     $insertData = array();
     // 数据添加缓存集合
     $updateData = array();
     // 数据修改缓存集合
     if ($_POST['datatable']) {
         foreach ($_POST['datatable'] as $key => $val) {
             foreach ($val as $k => $v) {
                 if ($v['id'] || $_REQUEST[$datatablefiexname . $k]) {
                     $updateData[$k][] = $v;
                 } else {
                     $insertData[$k][] = $v;
                 }
             }
         }
     }
     //数据处理
     if ($insertData) {
         foreach ($insertData as $k => $v) {
             $nqname = createRealModelName($datatablefiexname . $k);
             $model = D($nqname);
             $uploadfile = array();
             foreach ($v as $key => $val) {
                 if (C('TOKEN_NAME')) {
                     $val[C('TOKEN_NAME')] = $_POST[C('TOKEN_NAME')];
                 }
                 $val['masid'] = $_POST["id"];
                 $val = $model->create($val);
                 $insertId = $model->add($val);
                 /*
                  * _over_insert 方法,为静默插入生单。
                  */
                 $this->_over_insert($nqname, $insertId);
                 //处理内嵌表带附件信息数据
                 foreach ($val as $kk => $vv) {
                     if (is_array($vv)) {
                         $uploadfile[$kk . $key . $k]["file"] = $vv;
                         $uploadfile[$kk . $key . $k]["tableid"] = $_POST["id"];
                         $uploadfile[$kk . $key . $k]["subid"] = $insertId;
                         $uploadfile[$kk . $key . $k]["tablename"] = createRealModelName($datatablefiexname . $k);
                         $uploadfile[$kk . $key . $k]["fieldname"] = $kk;
                     }
                 }
             }
             if ($uploadfile) {
                 $this->DT_swf_upload($uploadfile);
             }
         }
     }
     if ($updateData) {
         foreach ($updateData as $k => $v) {
             $nqname = createRealModelName($datatablefiexname . $k);
             $model = D($nqname);
             $uploadfile = array();
             foreach ($v as $key => $val) {
                 if (C('TOKEN_NAME')) {
                     $val[C('TOKEN_NAME')] = $_POST[C('TOKEN_NAME')];
                 }
                 $val = $model->create($val);
                 $model->save($val);
             }
         }
     }
 }
    /**
     * @Title: createBaseArchives
     * @Description: todo(生成基础档案Action)
     * @param boolean $isaudit	是否为审批
     * @param boolean $isinitExtendAction  是否对扩展action做初始化处理
     * @author quqiang
     * @date 2014-11-18 下午07:09:06
     * @throws
     */
    function createBaseArchivesLsit($cotrollname, $isaudit = false, $isinitExtendAction = false)
    {
        logs('我要生成acationqk::::' . $cotrollname);
        // 1.获取到当前Action的组件配置文件信息
        $model = D('Autoform');
        $dir = '/autoformconfig/';
        $path = $dir . $this->nodeName . '.php';
        $model->setPath($path);
        // 获取所有节点信息
        //$allNodeconfig = $model->getAllControllConfig(); // 物理文件
        $allNodeconfig = $this->getAllControllConfig();
        $fieldData['visibility'] = $allNodeconfig;
        $cotrollname = ucfirst($cotrollname);
        $actionPath = LIB_PATH . "Action/" . $cotrollname . "Action.class.php";
        $actionExtendPath = LIB_PATH . "Action/" . $cotrollname . "ExtendAction.class.php";
        $extendphpcode .= "<?php\r\n/**";
        $extendphpcode .= "\r\n * @Title: {$cotrollname}Action";
        $extendphpcode .= "\r\n * @Package package_name";
        $extendphpcode .= "\r\n * @Description: todo(动态表单_扩展类。本类为用户代码注入入口,系统一旦生成将不再重复生成。";
        $extendphpcode .= "\r * \t\t\t\t\t\t但当用户选为组合表单方案后会更新该文件,请做好备份)";
        $extendphpcode .= "\r\n * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n * @company Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d";
        $extendphpcode .= "\r\n * @copyright 本文件归属于Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d";
        $extendphpcode .= "\r\n * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n * @version V1.0";
        $extendphpcode .= "\r\n*/";
        $extendphpcode .= "\r\nclass ";
        $phpcode .= "<?php\r\n/**";
        $phpcode .= "\r\n * @Title: {$cotrollname}Action";
        $phpcode .= "\r\n * @Package package_name";
        $phpcode .= "\r\n * @Description: todo(动态表单_自动生成-" . $this->nodeTitle . ")";
        $phpcode .= "\r\n * @author " . $_SESSION['loginUserName'];
        $phpcode .= "\r\n * @company Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d";
        $phpcode .= "\r\n * @copyright 本文件归属于Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d";
        $phpcode .= "\r\n * @date " . date('Y-m-d H:i:s');
        $phpcode .= "\r\n * @version V1.0";
        $phpcode .= "\r\n*/";
        $phpcode .= "\r\nclass ";
        if ($isaudit) {
            $jcc = "CommonAuditAction";
        } else {
            $jcc = "CommonAction";
        }
        $extendsCC = $cotrollname . "ExtendAction";
        $extendphpcode .= $cotrollname . "ExtendAction extends " . $jcc . " {\r\n";
        $phpcode .= $cotrollname . "Action extends " . $extendsCC . " {\r\n";
        $phpcode .= "\tpublic function _filter(&\$map){";
        //start filter
        $phpcode .= "\r\n\t\tif (\$_SESSION[\"a\"] != 1){\r\n\t\t\t\$map['status']=array(\"gt\",-1);";
        $phpcode .= "\r\n\t\t}";
        $phpcode .= "\r\n\t\t\$this->_extend_filter(\$map);";
        $phpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_filter";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展前置index函数)";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws ";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_filter() {";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_before_index";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展前置index函数)";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws ";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_before_index() {";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_before_edit";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展的前置编辑函数)";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws ";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_before_edit(){";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_before_insert";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展的前置添加函数)";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws ";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_before_insert(){";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_before_update";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展前置修改函数)  ";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_before_update(){";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_after_edit";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展后置编辑函数)";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws ";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_after_edit(&\$vo){";
        $extendphpcode .= "\r\n\t\tif(\$_GET['viewtype']=='view'){";
        $extendphpcode .= "\r\n\t\t\t\$this->display('formview');";
        $extendphpcode .= "\r\n\t\t\texit;";
        $extendphpcode .= "\r\n\t\t}";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_after_list";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展前置List)";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws ";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_after_list(){";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_after_insert";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展后置insert函数)  ";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_after_insert(\$id){";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_before_add";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展前置add函数)  ";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_before_add(&\$vo){";
        $extendphpcode .= "\r\n\t\t\$this->getFormIndexLoad(\$vo);";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_before_delete";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展前置删除函数)  ";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_before_delete(){";
        $extendphpcode .= "\r\n\t}";
        $extendphpcode .= "\r\n\t/**";
        $extendphpcode .= "\r\n\t * @Title: _extend_after_update";
        $extendphpcode .= "\r\n\t * @Description: todo(扩展后置update函数)  ";
        $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $extendphpcode .= "\r\n\t * @throws";
        $extendphpcode .= "\r\n\t*/";
        $extendphpcode .= "\r\n\tfunction _extend_after_update(){";
        $extendphpcode .= "\r\n\t}";
        // 重写父类index函数--为多表操作所做的修改 屈强@20141125 1712
        $index = "";
        $index .= "\r\n\t/**";
        $index .= "\r\n\t * @Title: index";
        $index .= "\r\n\t * @Description: todo(重写父类index函数)";
        $index .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $index .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $index .= "\r\n\t * @throws ";
        $index .= "\r\n\t*/";
        $index .= "\r\n\tfunction index(){";
        $index .= <<<EOF
\t\t
\t\t\$name=\$this->getActionName();
\t\t\$listnewall =\$this->getDateSoure(\$name);
\t\tif(!\$listnewall['list']){
\t\t//不存在则读取当前表orderno当树形菜单
\t\t\t\$model=D(\$name);
\t\t\t\$listnewall['list']=\$model->where("status=1")->field("orderno,id,name,parentid")->select();
\t\t\t\$listnewall['field']="id";
\t\t\t\$listnewall['fielter']="id";
\t\t\t
\t\t}
\t\t\$listnew=array();
\t\tforeach(\$listnewall['list'] as \$k=>\$v){
\t\t\t\$listnew[\$k]['name'] = "(".\$v['orderno'].")".\$v['name'];
\t\t\t\$listnew[\$k][\$listnewall['fielter']]=\$v[\$listnewall['fielter']]?\$v[\$listnewall['fielter']]:\$v['id'];
\t\t\t\$listnew[\$k]['parentid']=\$v['parentid'];
\t\t\t\$listnew[\$k]['id']=\$v['id'];
\t\t}
\t\t\$param['rel']="{$this->nodeName}view";
\t\t\$param['url']="__URL__/index/jump/1/hy/#".\$listnewall['fielter']."#";
\t\t\$treemiso[]=array(
\t\t\t\t'id'=>0,
\t\t\t\t'pId'=>0,
\t\t\t\t'url'=>'__URL__/index/jump/1',
\t\t\t\t'target'=>'ajax',
\t\t\t\t'rel'=>"{$this->nodeName}view",
\t\t\t\t'name'=>'{$this->nodeTitle}',
\t\t\t\t'title'=>'{$this->nodeTitle}',
\t\t\t\t'open'=>true,
\t\t\t\t'isParent'=>true,
\t\t);
\t\t\$treearr = \$this->getTree(\$listnew,\$param,\$treemiso);
\t\t\$this->assign("treearr",\$treearr);
\t\t\t\t\t\t
\t\t\t\t\t\t
\t\t//列表过滤器,生成查询Map对象
\t\t\$map = \$this->_search ();\t\t\t\t
\t\t\$name=\$this->getActionName();\t\t\t\t
\t\tif(\$_REQUEST['hy']){
\t\t\t//构造检索条件
\t\t\t\$map[\$listnewall['field']] = \$_REQUEST['hy'];
\t\t\t\$this->assign("hy",\$_REQUEST['hy']);
\t\t}
\t\tif (! empty ( \$name )) {
\t\t\t\$qx_name=\$name;
\t\t\tif(substr(\$name, -4)=="View"){
\t\t\t\t\$qx_name = substr(\$name,0, -4);
\t\t\t}
\t\t\t//验证浏览及权限
\t\t\tif( !isset(\$_SESSION['a']) ){
\t\t\t\t\$map=D('User')->getAccessfilter(\$qx_name,\$map);
\t\t\t}
\t\t\t//列表页排序 ---开始-----2015-08-06 15:07 write by xyz
\t\t\tif(\$_REQUEST['orderField']&&strpos(strtolower(\$_REQUEST['orderField']),' asc')===false&&strpos(strtolower(strpos(\$_REQUEST['orderField'])),' desc')===false){
\t\t\t\t\$this->_list ( \$name, \$map);
\t\t\t}else{
\t\t\t\t\$sortsorder = '';
\t\t\t\t\$sortsmap['modelname'] = \$name;
\t\t\t\t\$sortsmap['sortsorder'] = array("gt",0);
\t\t\t\t//管理员读公共设置
\t\t\t\tif(\$_SESSION['a']){
\t\t\t\t\t\$listincModel = M("mis_system_public_listinc");
\t\t\t\t\t\$sortslist = \$listincModel->where(\$sortsmap)->order("sortsorder")->select();
\t\t\t\t}else{
\t\t\t\t\t//个人先读个人设置、没有再读公共设置
\t\t\t\t\t\$sortsmap['userid'] = \$_SESSION [C ( 'USER_AUTH_KEY' )];
\t\t\t\t\t\$listincModel = M("mis_system_private_listinc");
\t\t\t\t\t\$sortslist = \$listincModel->where(\$sortsmap)->order("sortsorder")->select();
\t\t\t\t\tif(empty(\$sortslist)){
\t\t\t\t\t\tunset(\$sortsmap['userid']);
\t\t\t\t\t\t\$listincModel = M("mis_system_public_listinc");
\t\t\t\t\t\t\$sortslist = \$listincModel->where(\$sortsmap)->order("sortsorder")->select();
\t\t\t\t\t}
\t\t\t\t}
\t\t\t\t//如果在设置里有相关数据、提取排序字段组合order by
\t\t\t\tif(\$sortslist){
\t\t\t\t\tforeach(\$sortslist as \$k=>\$v){
\t\t\t\t\t\t\$sortsorder .= \$v['fieldname'].' '.\$v['sortstype'].',';
\t\t\t\t\t}
\t\t\t\t\t\$sortsorder = substr(\$sortsorder,0,-1);
\t\t\t\t}
\t\t\t\t//列表页排序 ---结束-----
\t\t\t\t\$this->_list ( \$name, \$map,'', false,'','',\$sortsorder);
\t\t\t}
\t\t\t\t
\t\t\t\t
\t\t}
\t\t\t\t\t\t
\t\t\t\t\t\t
\t\t\$scdmodel = D('SystemConfigDetail');
\t\t//扩展工具栏操作
\t\t\$toolbarextension = \$scdmodel->getDetail(\$name,true,'toolbar');
\t\tif (\$toolbarextension) {
\t\t\t\$this->assign ( 'toolbarextension', \$toolbarextension );
\t\t}
\t\t\$detailList = \$scdmodel->getDetail(\$name);
\t\tif (\$detailList) {
\t\t\t\$this->assign ( 'detailList', \$detailList );
\t\t}\t\t
\t\tif(\$_REQUEST['jump'] == 1){
\t\t\t\$this->display("indexview");
\t\t}else{
\t\t\t\$this->display();
\t\t}
EOF;
        $index .= "\r\n\t}";
        // beforindex
        $before_index = '';
        $before_index .= "\r\n\t/**";
        $before_index .= "\r\n\t * @Title: _before_index";
        $before_index .= "\r\n\t * @Description: todo(前置index函数)";
        $before_index .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $before_index .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $before_index .= "\r\n\t * @throws ";
        $before_index .= "\r\n\t*/";
        $before_index .= "\r\n\tfunction _before_index() {";
        // 默认生成 前置函数
        $before_edit = '';
        $before_edit .= "\r\n\t/**";
        $before_edit .= "\r\n\t * @Title: _before_edit";
        $before_edit .= "\r\n\t * @Description: todo(前置编辑函数)";
        $before_edit .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $before_edit .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $before_edit .= "\r\n\t * @throws ";
        $before_edit .= "\r\n\t*/";
        $before_edit .= "\r\n\tfunction _before_edit(){";
        $before_insert = '';
        $before_insert .= "\r\n\t/**";
        $before_insert .= "\r\n\t * @Title: _before_insert";
        $before_insert .= "\r\n\t * @Description: todo(前置添加函数)";
        $before_insert .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $before_insert .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $before_insert .= "\r\n\t * @throws ";
        $before_insert .= "\r\n\t*/";
        $before_insert .= "\r\n\tfunction _before_insert(){";
        $before_update = '';
        $before_update .= "\r\n\t/**";
        $before_update .= "\r\n\t * @Title: _before_update";
        $before_update .= "\r\n\t * @Description: todo(前置修改函数)  ";
        $before_update .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $before_update .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $before_update .= "\r\n\t * @throws";
        $before_update .= "\r\n\t*/";
        $before_update .= "\r\n\tfunction _before_update(){";
        $before_delete = '';
        $before_delete .= "\r\n\t/**";
        $before_delete .= "\r\n\t * @Title: _before_update";
        $before_delete .= "\r\n\t * @Description: todo(前置删除函数)  ";
        $before_delete .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $before_delete .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $before_delete .= "\r\n\t * @throws";
        $before_delete .= "\r\n\t*/";
        $before_delete .= "\r\n\tfunction _before_delete(){";
        // 重写父类编辑函数--为多表操作所做的修改 屈强@20141008 15:53
        $edit = '';
        $edit .= "\r\n\t/**";
        $edit .= "\r\n\t * @Title: edit";
        $edit .= "\r\n\t * @Description: todo(重写父类编辑函数)";
        $edit .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $edit .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $edit .= "\r\n\t * @throws ";
        $edit .= "\r\n\t*/";
        $edit .= "\r\n\tfunction edit(\$isdisplay=1){";
        $edit .= "\r\n\t\t\$mainTab = '{$this->tableName}';";
        $edit .= "\r\n\t\t//获取当前控制器名称";
        $edit .= "\r\n\t\t\$name=\$this->getActionName();";
        $edit .= "\r\n\t\t\$model = D(\"{$this->nodeName}View\");";
        $edit .= "\r\n\t\t//获取当前主键";
        $edit .= "\r\n\t\t\$map[\$mainTab.'.id']=\$_REQUEST['id'];";
        $edit .= "\r\n\t\t\$vo = \$model->where(\$map)->find();";
        $edit .= "\r\n\t\tif(!\$vo){";
        $edit .= "\r\n\t\t\$this->getFormIndexLoad(\$vo);";
        $edit .= "\r\n\t\t}";
        // 		$edit .="\r\n\t\tif(empty(\$vo)){";
        // 		$edit .="\r\n\t\t\t\$this->display (\"Public:404\");";
        // 		$edit .="\r\n\t\t\texit;";
        // 		$edit .="\r\n\t\t}";
        $edit .= "\r\n\t\tif (method_exists ( \$this, '_filter' )) {";
        $edit .= "\r\n\t\t\t\$this->_filter ( \$map );";
        $edit .= "\r\n\t\t}";
        $edit .= "\r\n\t\t//读取动态配制";
        $edit .= "\r\n\t\t\$this->getSystemConfigDetail(\$name);";
        $edit .= "\r\n\t\t//扩展工具栏操作";
        $edit .= "\r\n\t\t\$scdmodel = D('SystemConfigDetail');";
        $edit .= "\r\n\t\t// 上一条数据ID";
        $edit .= "\r\n\t\t\$map['id'] = array(\"lt\",\$id);";
        $edit .= "\r\n\t\t\$updataid = \$model->where(\$map)->order('id desc')->getField('id');";
        $edit .= "\r\n\t\t\$this->assign(\"updataid\",\$updataid);";
        $edit .= "\r\n\t\t// 下一条数据ID";
        $edit .= "\r\n\t\t\$map['id'] = array(\"gt\",\$id);";
        $edit .= "\r\n\t\t\$downdataid = \$model->where(\$map)->getField('id');";
        $edit .= "\r\n\t\t\$this->assign(\"downdataid\",\$downdataid);";
        $edit .= "\r\n\t\t//lookup带参数查询";
        $edit .= "\r\n\t\t\$module=A(\$name);";
        $edit .= "\r\n\t\tif (method_exists(\$module,\"_after_edit\")) {";
        $edit .= "\r\n\t\t\tcall_user_func(array(\$module,\"_after_edit\"),\$vo);";
        $edit .= "\r\n\t\t}";
        $edit .= "\r\n\t\t\$this->assign( 'vo', \$vo );";
        $edit .= "\r\n\t\tif(\$isdisplay)";
        $edit .= "\r\n\t\t\$this->display ();";
        $edit .= "\r\n\t}";
        //////////////////////////////////////////////////////////////////
        /*
         * 不要重写父类中的edit函数
         */
        $edit = '';
        /////////////////////////////////////////////////////////////////////
        // 默认生成后置函数
        $after_edit = '';
        $after_list = '';
        $after_insert = '';
        $before_add = '';
        $after_update = '';
        // 删除子表数据
        $delChildData = '';
        $is_create_del_child = false;
        $is_create_opraete_child = false;
        $is_create_modify_child = false;
        $is_create_insert_child = false;
        //控制地址组件修改代码生成
        $isArea = false;
        // 实例化MODE
        $model_code = '';
        $is_include_model = false;
        $after_edit .= "\r\n\t/**";
        $after_edit .= "\r\n\t * @Title: _after_edit";
        $after_edit .= "\r\n\t * @Description: todo(后置编辑函数)";
        $after_edit .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $after_edit .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $after_edit .= "\r\n\t * @throws ";
        $after_edit .= "\r\n\t*/";
        $after_edit .= "\r\n\tfunction _after_edit(\$vo){";
        $after_list .= "\r\n\t/**";
        $after_list .= "\r\n\t * @Title: _after_list";
        $after_list .= "\r\n\t * @Description: todo(前置List)";
        $after_list .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $after_list .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $after_list .= "\r\n\t * @throws ";
        $after_list .= "\r\n\t*/";
        $after_list .= "\r\n\tfunction _after_list(){";
        $after_insert .= "\r\n\t/**";
        $after_insert .= "\r\n\t * @Title: _after_insert";
        $after_insert .= "\r\n\t * @Description: todo(后置insert函数)  ";
        $after_insert .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $after_insert .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $after_insert .= "\r\n\t * @throws";
        $after_insert .= "\r\n\t*/";
        $after_insert .= "\r\n\tfunction _after_insert(\$id){";
        $before_add .= "\r\n\t/**";
        $before_add .= "\r\n\t * @Title: _before_add";
        $before_add .= "\r\n\t * @Description: todo(前置add函数)  ";
        $before_add .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $before_add .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $before_add .= "\r\n\t * @throws";
        $before_add .= "\r\n\t*/";
        $before_add .= "\r\n\tfunction _before_add(){";
        $after_update .= "\r\n\t/**";
        $after_update .= "\r\n\t * @Title: _after_update";
        $after_update .= "\r\n\t * @Description: todo(后置update函数)  ";
        $after_update .= "\r\n\t * @author " . $_SESSION['loginUserName'];
        $after_update .= "\r\n\t * @date " . date('Y-m-d H:i:s');
        $after_update .= "\r\n\t * @throws";
        $after_update .= "\r\n\t*/";
        $after_update .= "\r\n\tfunction _after_update(){";
        /**
         * 步骤:
         * 1。先源数据 $filedData['visibility'] 中的项按表名['tablename']分组。
         * 2。区分出主从表,主表的文件名用当前action名命名,从表以直接表名命名。
         * 3。遍历分组后的数据,依次生成Model文件。
         *
         *		表数组,基础为二维.
         * 	0=>主表信息
         * 	1=>所有从表的信息
         */
        /*	处理子表错误,子表不做数据添加 会导致修改 视图查询数据若用户只勾取部分表字段 引起的查询不出数据。
         * 处理方式为:取出当前action的所有子表 都生成 添加与修改都 做处理
         **/
        $curTabData = $this->getDataBaseConf();
        $curTabData = $curTabData['cur'];
        foreach ($curTabData['datebase'] as $key => $val) {
            if (!$val['isprimay']) {
                $after_update .= "\r\n\t\t//添加子表数据处理--" . $_SESSION['loginUserName'] . '@' . date('Y-m-d H:i:s');
                $after_update .= "\r\n\t\t\${$key}Mode = D('" . createRealModelName($key) . "');";
                $after_update .= "\r\n\t\t\${$key}Data = \${$key}Mode->create();";
                $after_update .= "\r\n\t\tunset(\${$key}Data['id']);";
                $after_update .= "\r\n\t\tif(\${$key}Data){";
                $after_update .= "\r\n\t\t\tif(\${$key}Mode->where('masid='.\${$key}Data['masid'])->find())";
                $after_update .= "\r\n\t\t\t\t\${$key}Mode->where('masid='.\${$key}Data['masid'])->save(\${$key}Data);";
                $after_update .= "\r\n\t\t\telse";
                $after_update .= "\r\n\t\t\t\t\${$key}Mode->add(\${$key}Data);";
                $after_update .= "\r\n\t\t}";
                $after_insert .= "\r\n\t\t// 添加子表数据处理----" . $_SESSION['loginUserName'] . '@' . date('Y-m-d H:i:s');
                $after_insert .= "\r\n\t\t\${$key}Mode = D('" . createRealModelName($key) . "');";
                $after_insert .= "\r\n\t\t\${$key}Data = \${$key}Mode->create();";
                $after_insert .= "\r\n\t\tunset(\${$key}Data['id']);";
                $after_insert .= "\r\n\t\tif(\${$key}Data){";
                $after_insert .= "\r\n\t\t\t\t\${$key}Data['masid']=\$id;";
                $after_insert .= "\r\n\t\t\t\t\${$key}Mode->add(\${$key}Data);";
                $after_insert .= "\r\n\t\t}";
            }
        }
        // 审批流
        if ($isaudit) {
        }
        foreach ($fieldData['visibility'] as $k => $v) {
            $property = $this->getProperty($v['catalog']);
            if ($v[$property['catalog']['name']] == 'upload') {
                $after_edit .= "\r\n\t\t\$this->getAttachedRecordList(\$vo['id']);";
                $after_update .= "\r\n\t\t\$id=\$_REQUEST['id'];";
                $after_update .= "\r\n\t\t\$this->swf_upload(\$id);";
                $after_insert .= "\r\n\t\t\$this->swf_upload(\$id);";
            }
            // 			if($v[$property['catalog']['name']] == 'checkbox'){
            // 				$after_edit .="\r\n\t\tif(\$vo['".$v[$property['fields']['name']]."'])\n\t\t\t\$vo[\"".$v[$property['fields']['name']]."\"]=explode(',',\$vo[\"".$v[$property['fields']['name']]."\"]);";
            // 			}
            if ($v[$property['catalog']['name']] == 'datatable') {
                // 删除子表数据
                if (!$is_create_del_child) {
                    $delChildData .= $this->getDataTableAction();
                    $is_create_del_child = true;
                }
                //if(!$is_create_opraete_child){
                // 				$after_edit .="\r\n\t\t// 内嵌表处理".$v[$property['fields']['name']];
                // 				$after_edit .="\r\n\t\t\$innerTabelObj".$v[$property['fields']['name']]." = M('".$this->tableName.'_sub_'.$v[$property['fields']['name']]."');"; // 内嵌表名 生成规则: 主表名称_sub_组件名称
                // 				$after_edit .="\r\n\t\t\$innerTabelObj".$v[$property['fields']['name']]."Data = \$innerTabelObj".$v[$property['fields']['name']]."->where('masid='.\$vo['id'])->select();";
                // 				$after_edit .="\r\n\t\t\$this->assign(\"innerTabelObj".$v[$property['fields']['name']]."Data\",\$innerTabelObj".$v[$property['fields']['name']]."Data);";
                $after_edit .= $this->dataTableEditCode($v, $property);
                //$is_create_opraete_child = true;
                //}
                if (!$is_create_modify_child) {
                    // 					$after_update .="\r\n\t\t// 内嵌表数据添加处理";
                    //$after_update .="\r\n\t\t\$datatablefiexname =\"{$this->tableName}_sub_\";";
                    // 					$after_update .="\r\n\t\t\$insertData = array();// 数据添加缓存集合";
                    // 					$after_update .="\r\n\t\t\$updateData = array();// 数据修改缓存集合";
                    // 					$after_update .="\r\n\t\tif(\$_POST['datatable']){";
                    // 					$after_update .="\r\n\t\t	foreach(\$_POST['datatable'] as \$key=>\$val){";
                    // 					$after_update .="\r\n\t\t		foreach(\$val as \$k=>\$v){";
                    // 					$after_update .="\r\n\t\t			if(\$v['id']){";
                    // 					$after_update .="\r\n\t\t				\$updateData[\$k][]=\$v;";
                    // 					$after_update .="\r\n\t\t			}else{";
                    // 					$after_update .="\r\n\t\t				\$insertData[\$k][]=\$v;";
                    // 					$after_update .="\r\n\t\t			}";
                    // 					$after_update .="\r\n\t\t		}";
                    // 					$after_update .="\r\n\t\t	}";
                    // 					$after_update .="\r\n\t\t}";
                    // 					$after_update .="\r\n\t\t//数据处理";
                    // 					$after_update .="\r\n\t\tif(\$insertData){";
                    // 					$after_update .="\r\n\t\t	foreach(\$insertData as \$k=>\$v){";
                    // 					$after_update .="\r\n\t\t		\$model = M(\$datatablefiexname.\$k);";
                    // 					$after_update .="\r\n\t\t		foreach(\$v as \$key=>\$val){";
                    // 					$after_update .="\r\n\t\t			\$val['masid'] = \$_POST['id'];";
                    // 					$after_update .="\r\n\t\t			\$model->add(\$val);";
                    // 					$after_update .="\r\n\t\t		}";
                    // 					$after_update .="\r\n\t\t	}";
                    // 					$after_update .="\r\n\t\t}";
                    // 					$after_update .="\r\n\t\tif(\$updateData){";
                    // 					$after_update .="\r\n\t\t	foreach(\$updateData as \$k=>\$v){";
                    // 					$after_update .="\r\n\t\t		\$model = M(\$datatablefiexname.\$k);";
                    // 					$after_update .="\r\n\t\t		foreach(\$v as \$key=>\$val){";
                    // 					$after_update .="\r\n\t\t			\$model->save(\$val);";
                    // 					$after_update .="\r\n\t\t		}";
                    // 					$after_update .="\r\n\t\t	}";
                    // 					$after_update .="\r\n\t\t}";
                    $after_update .= $this->updateDatatableCode();
                    $is_create_modify_child = true;
                }
                if (!$is_create_insert_child) {
                    // 					$after_insert.="\r\n\t\t// 内嵌表数据添加处理";
                    //$after_insert.="\r\n\t\t\$datatablefiexname =\"{$this->tableName}_sub_\";";
                    // 					$after_insert.="\r\n\t\t\$insertData = array();// 数据添加缓存集合";
                    // 					$after_insert.="\r\n\t\tif(\$_POST['datatable']){";
                    // 					$after_insert.="\r\n\t\t	foreach(\$_POST['datatable'] as \$key=>\$val){";
                    // 					$after_insert.="\r\n\t\t		foreach(\$val as \$k=>\$v){";
                    // 					$after_insert.="\r\n\t\t			\$insertData[\$k][]=\$v;";
                    // 					$after_insert.="\r\n\t\t		}";
                    // 					$after_insert.="\r\n\t\t	}";
                    // 					$after_insert.="\r\n\t\t}";
                    // 					$after_insert.="\r\n\t\t//数据处理";
                    // 					$after_insert.="\r\n\t\tif(\$insertData){";
                    // 					$after_insert.="\r\n\t\t	foreach(\$insertData as \$k=>\$v){";
                    // 					$after_insert.="\r\n\t\t		\$model = M(\$datatablefiexname.\$k);";
                    // 					$after_insert.="\r\n\t\t		foreach(\$v as \$key=>\$val){";
                    // 					$after_insert.="\r\n\t\t			\$val['masid'] = \$id;";
                    // 					$after_insert.="\r\n\t\t			\$model->add(\$val);";
                    // 					$after_insert.="\r\n\t\t		}";
                    // 					$after_insert.="\r\n\t\t	}";
                    // 					$after_insert.="\r\n\t\t}";
                    $after_insert .= $this->insertDatatableCode();
                    $is_create_insert_child = true;
                }
            }
            if ($v[$property['catalog']['name']] == 'areainfo' && $isArea == false) {
                $after_edit .= $this->getAreaInfoCode();
                $isArea == true;
            }
            if ($v[$property['subimporttableobj']['name']]) {
                // 普通的绑定表
                // 				$condition = '';
                // 				if($v[$property['conditions']['name']]){
                // 					$condition = "->where('status=1 and ".html_entity_decode($v[$property['conditions']['name']])."')";
                // 				}else {
                // 					$condition = "->where('status=1')";
                // 				}
                // 				$before_add.= "\r\n\t\t\$model=M(\"".$v[$property['subimporttableobj']['name']]."\");";
                // 				$before_add.= "\r\n\t\t\$list{$v[$property['fields']['name']]} =\$model{$condition}->field(\"".$v[$property['subimporttablefieldobj']['name']].",".$v[$property['subimporttablefield2obj']['name']]."\")->select();";
                // 				$before_add.="\r\n\t\t\$this->assign(\"".$v[$property['fields']['name']]."list\"".",\$list{$v[$property['fields']['name']]});";
                // 				$after_edit .="\r\n\t\t\$model=M(\"{$v[$property['subimporttableobj']['name']]}\");";
                // 				$after_edit .="\r\n\t\t\$list{$v[$property['fields']['name']]} =\$model{$condition}->field(\"".$v[$property['subimporttablefieldobj']['name']].",".$v[$property['subimporttablefield2obj']['name']]."\")->select();";
                // 				$after_edit .="\r\n\t\t\$this->assign(\"".$v[$property['fields']['name']]."list\"".",\$list{$v[$property['fields']['name']]});";
            } elseif ($v[$property['treedtable']['name']]) {
                // 绑定的是只能选择最后一级选中效果
                // 				$before_add.= "\r\n\t\t//添加-只能选择下拉框最后一级的特殊数据获取方式 @date:".Date('y-m-d H:i:s');
                // 				$before_add.= "\r\n\t\t\$model=D(\"MisSystemRecursion\");";
                // 				$before_add.= "\r\n\t\t\$treeSelect{$v[$property['fields']['name']]}Data = \$model->modelShow('{$v[$property['treedtable']['name']]}' , array('key'=>'id','pkey'=>'{$v[$property['treeparentfield']['name']]}','fields'=>'{$v[$property['treevaluefield']['name']]},{$v[$property['treeshowfield']['name']]}') , 0 , 1);";
                // 				$before_add.= "\r\n\t\t\$this->assign(\"treeSelect{$v[$property['fields']['name']]}Data\",\$treeSelect{$v[$property['fields']['name']]}Data);";
                // 				$after_edit.= "\r\n\t\t//修改-只能选择下拉框最后一级的特殊数据获取方式 @date:".Date('y-m-d H:i:s');
                // 				$after_edit.= "\r\n\t\t\$model=D(\"MisSystemRecursion\");";
                // 				$after_edit.= "\r\n\t\t\$treeSelect{$v[$property['fields']['name']]}Data = \$model->modelShow('{$v[$property['treedtable']['name']]}' , array('key'=>'id','pkey'=>'{$v[$property['treeparentfield']['name']]}','fields'=>'{$v[$property['treevaluefield']['name']]},{$v[$property['treeshowfield']['name']]}') , 0 , 1);";
                // 				$after_edit.= "\r\n\t\t\$this->assign(\"treeSelect{$v[$property['fields']['name']]}Data\",\$treeSelect{$v[$property['fields']['name']]}Data);";
            } else {
                // 绑定的是selectlist数据源
                if ($v[$property['showoption']['name']]) {
                    // 					if(!$is_include_model){
                    // 						$model_code = "\r\n\t\t\$model=D('Selectlist');";
                    // 						$is_include_model = true;
                    // 					}
                    // 					$after_edit .=$model_code. "\r\n\t\t\$selectlis = \$model->GetRules('{$v['showoption']}');";
                    // 					$after_edit .="\r\n\t\t\$selectlist{$v[$property['fields']['name']]}=array();";
                    // 					$after_edit .="\r\n\t\tforeach(\$selectlis['{$v['showoption']}'] as \$k=>\$v){";
                    // 					$after_edit .="\r\n\t\t\t\$temp['key']=\$k;";
                    // 					$after_edit .="\r\n\t\t\t\$temp['val']=\$v;";
                    // 					$after_edit .="\r\n\t\t\t\$selectlist{$v[$property['fields']['name']]}[]=\$temp;";
                    // 					$after_edit .="\r\n\t\t}";
                    // 					$after_edit .="\r\n\t\t\$this->assign(\"selectlist{$v[$property['fields']['name']]}\",\$selectlist{$v[$property['fields']['name']]});";
                    // 					$before_add .=$model_code."\r\n\t\t\$selectlis = \$model->GetRules('{$v['showoption']}');";
                    // 					$before_add .="\r\n\t\t\$selectlist{$v[$property['fields']['name']]}=array();";
                    // 					$before_add .="\r\n\t\tforeach(\$selectlis['{$v['showoption']}'] as \$k=>\$v){";
                    // 					$before_add .="\r\n\t\t\t\$temp['key']=\$k;";
                    // 					$before_add .="\r\n\t\t\t\$temp['val']=\$v;";
                    // 					$before_add .="\r\n\t\t\t\$selectlist{$v[$property['fields']['name']]}[]=\$temp;";
                    // 					$before_add .="\r\n\t\t}";
                    // 					$before_add .="\r\n\t\t\$this->assign(\"selectlist{$v[$property['fields']['name']]}\",\$selectlist{$v[$property['fields']['name']]});";
                }
            }
        }
        $before_edit .= "\r\n\t\t\$mainTab = '{$this->tableName}';";
        $before_edit .= "\r\n\t\t//获取当前控制器名称";
        $before_edit .= "\r\n\t\t\$name=\$this->getActionName();";
        $before_edit .= "\r\n\t\t\$model = D(\"{$this->nodeName}View\");";
        $before_edit .= "\r\n\t\t//获取当前主键";
        $before_edit .= "\r\n\t\t\$map[\$mainTab.'.id']=\$_REQUEST['id'];";
        $before_edit .= "\r\n\t\t\$vo = \$model->where(\$map)->find();";
        $datetiem = date('Y-m-d H:i:s');
        $before_insert .= <<<EOF
\t\t
\t\t// 插入之前,验证编码方案是否正确符合规定 @{$datetiem}
\t\t\$name = \$this->getActionName();
\t\t\$orderno = \$_POST['orderno'];
\t\t\$MisSystemOrdernoDao = D("MisSystemOrderno");
\t\t\$data = \$MisSystemOrdernoDao->validateOrderno(\$name,\$orderno);
\t\tif(\$data['result']){
\t\t\t\$_POST['parentid'] = \$data['parentid'];
\t\t\t
\t\t}else{
\t\t\t\$this->error(\$data['altMsg']);
\t\t}
EOF;
        $before_update .= <<<EOF
\t\t
\t\t// 修改之前,验证编码方案是否正确符合规定 @{$datetiem}
\t\t\$name = \$this->getActionName();
\t\t\$orderno = \$_POST['orderno'];
\t\t\$MisSystemOrdernoDao = D("MisSystemOrderno");
\t\t\$data = \$MisSystemOrdernoDao->validateOrderno(\$name,\$orderno,\$_POST['id']);
\t\tif(\$data['result']){
\t\t\t\$_POST['parentid'] = \$data['parentid'];
\t\t}else{
\t\t\t\$this->error(\$data['altMsg']);
\t\t}
EOF;
        $before_edit .= "\r\n\t\t\$this->assign( 'vo', \$vo );";
        $before_index .= "\r\n\t\t\$this->_extend_before_index();";
        $before_index .= "\r\n\t}";
        $before_edit .= "\r\n\t\t\$this->_extend_before_edit();";
        $before_edit .= "\r\n\t}";
        $before_insert .= "\r\n\t\t\$this->_extend_before_insert();";
        $before_insert .= "\r\n\t}";
        $before_update .= "\r\n\t\t\$this->_extend_before_update();";
        $before_update .= "\r\n\t}";
        $after_edit .= "\r\n\t\t\$this->_extend_after_edit(\$vo);";
        $after_edit .= "\r\n\t}";
        $after_list .= "\r\n\t\t\$this->_extend_after_list();";
        $after_list .= "\r\n\t}";
        $after_insert .= "\r\n\t\t\$this->_extend_after_insert(\$id);";
        $after_insert .= "\r\n\t}";
        $before_add .= "\r\n\t\t\$this->_extend_before_add(\$vo);";
        $before_add .= "\r\n\t}";
        $after_update .= "\r\n\t\t\$this->_extend_after_update();";
        $after_update .= "\r\n\t}";
        $before_delete .= "\r\n\t\t\$this->_extend_before_delete();";
        $before_delete .= "\r\n\t}";
        $phpcode .= $index . $edit . $before_index . $before_edit . $before_insert . $before_update . $before_delete . $after_edit . $after_insert . $before_add . $after_update . $delChildData;
        $phpcode .= "\r\n}\r\n?>";
        $extendphpcode .= "\r\n}\r\n?>";
        if (!is_dir(dirname($actionPath))) {
            mk_dir(dirname($actionPath), 0777);
        }
        if (false === file_put_contents($actionPath, $phpcode)) {
            $this->error("Action文件生成失败!");
        }
        if ($isinitExtendAction) {
            if (false === file_put_contents($actionExtendPath, $extendphpcode)) {
                $this->error("扩展Action文件生成失败!");
            }
        } else {
            if (false == file_exists($actionExtendPath)) {
                if (false === file_put_contents($actionExtendPath, $extendphpcode)) {
                    $this->error("扩展Action文件生成失败!");
                }
            }
        }
    }