<?php

function code_pc_html($post) {
    $tabname = $post->get('table', '', 'all');
    $subpath = $post->get('subpath', '', 'all');
    $saasfield = $post->get('saasfield', '', 'all');
    $saasusr = $post->get('saasusr', '', 'all');
    $titname = $post->get('_bcod_titname', '', 'all');
    $liiddict = str_replace('，',',', $post->get('_bcod_liiddict', '', 'all'));
    $uptabcard = str_replace('，',',', $post->get('_bcod_uptabcard', '', 'all'));
    $uptabcards = array();
    if (!empty($uptabcard))
        $uptabcards = explode(',', $uptabcard);
    $btntop_newline = $post->get('_bcod_btntop_newline', '', 'all');
    $btnlist_line = $post->get('_bcod_btnlist_line', '', 'all');
    $btntop_multibtn = $post->get('_bcod_btntop_multibtn', '', 'all');
    $savepc = $post->get('_bcod_savepc', '', 'all');
    $pcparam = $post->get('_bcod_pcparam');

    $hasview = strpos($btnlist_line, '查看') !== false;

    $flds = calfld($post);
    $chk_audit = false;
    $chk_matter = false;
    $chk_getupdate = false;
    $chk_deltimes = false;
    $ciycmp2 = false;
    $ciydict = [];
    $cchar = 'char2';
    $maxnamelen = 0;
    foreach ($flds as $fld) {
        $len = gb_strlen($fld['name']);
        if ($len > $maxnamelen)
            $maxnamelen = $len;
        if ($fld['col'] == 'auditstatus')
            $chk_audit = true; //auditstatus/audituser/audittimes/auditmsg: 加审核按钮
        if ($fld['col'] == 'matterstatus')
            $chk_matter = true; //matterstatus/matternextuser/mattertimes: 加流程功能，是否可编辑/删除
        if ($fld['col'] == 'deltimes')
            $chk_deltimes = true;
        if ($fld['set']['listload'] == 'rel'){
            if(!$fld['set']['noup'])
                $chk_getupdate = true;
        }
        if ($fld['set']['nocmn'] == 'no')
            $chk_getupdate = true;
        $cate = $fld['cate'];
        if (
            $cate == 'CATM' || $cate == 'CATS' || $cate == 'MD' || $cate == 'FILEMD' || $cate == 'CYC' || $cate == 'LOC' || $cate == 'UNIT'
            || $cate == 'TIME' || $cate == 'SEC' || $cate == 'IMG1' || $cate == 'IMG' || $cate == 'DOWN' || $cate == 'AV'
        )
            $ciycmp2 = true;
        list($dicttype, $dictname) = splitdict($fld['data']);
        if ($dicttype == 'dictciy')
            $ciydict[] = $dictname;
    }
    if ($maxnamelen > 16)
        $cchar = 'char9';
    else if ($maxnamelen > 14)
        $cchar = 'char8';
    else if ($maxnamelen > 12)
        $cchar = 'char7';
    else if ($maxnamelen > 10)
        $cchar = 'char6';
    else if ($maxnamelen > 8)
        $cchar = 'char5';
    else if ($maxnamelen > 6)
        $cchar = 'char4';
    else if ($maxnamelen > 4)
        $cchar = 'char3';
    $hasadd = false;
    $hasreview = false;
    $hasedit = strpos($btnlist_line,'修改') !== false;
    $hasaudit = false;
    $hasexcelin = false;
    $hasexcelout = false;
    $hashelp = false;
    $topbtns = [];
    $strs = explode(',', $btntop_newline); //添加,导入,导出,其他,操作|成果|方法|-修改|删除
    foreach ($strs as $str) {
        if(empty($str))
            continue;
        $ind = strpos($str, '|');
        if ($ind === false) {
            if ($str == '添加') {
                $hasadd = true;
                $hasedit = true;
                $topbtns[] = '<a class="lang btn" onclick="edit(0)">添加</a>';
            } else if ($str == '导入') {
                $hasexcelin = true;
                $topbtns[] = '<a class="lang btn" onclick="multiin()">导入</a>';
            } else if ($str == '导出') {
                $hasexcelout = true;
                $topbtns[] = '<a class="lang btn" onclick="exportxls()">导出</a>';
            } else if ($str == '帮助') {
                $hashelp = true;
                $topbtns[] = '<a class="lang btn def" onclick="pagehelp()">帮助</a>';
            } else
                $topbtns[] = '<a class="lang btn" onclick="">' . $str . '</a>';
        } else {
            $subs = explode('|', $str); //操作|成果|方法|-|修改|删除
            $btnhtml = "<a class=\"btn btn-menu\" direction=\"lr\"><span class=\"lang\">{$subs[0]}</span>\n";
            $btnhtml .= "                        <span class=\"caret\"></span>\n";
            $btnhtml .= "                        <ul class=\"ciy-popmenu\">\n";
            for ($j = 1; $j < count($subs); $j++) {
                $name = $subs[$j];
                if ($name == '-') {
                    $btnhtml .= "                            <li class=\"line\"></li>\n";
                } else {
                    $btnhtml .= "                            <li onclick=\"\">{$name}</li>\n";
                }
            }
            $btnhtml .= "                        </ul>\n";
            $btnhtml .= "                    </a>";
            $topbtns[] = $btnhtml;
        }
    }
    $codex = <<<data
<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <link href="/jscss/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" charset="utf-8" src="/jscss/theme.js"></script>
</head>

<body>
    <div class="container">
        <form class="search" onsubmit="table.search(this,'btn');return false;">
            <ul></ul>
            <div>
                <div class="sinps"></div>
                <div class="sbtns">
                    <button class="lang btn" type="submit">查询</button>

data;

    if (strpos($pcparam, ',topbtnnewline,') === false) {
        foreach ($topbtns as $topbtn) {
            $codex .= '                    ' . $topbtn . "\n";
        }
    }
    $codex .= <<<data
                </div>
            </div>
        </form>

data;

    if (strpos($pcparam, ',topbtnnewline,') !== false) {
        $codex .= "        <div class=\"topbtn\">\n";
        foreach ($topbtns as $topbtn) {
            $codex .= '            ' . $topbtn . "\n";
        }
        $codex .= "        </div>\n";
    }
    $chk_multis = [];
    $multibtn = '';
    if ($btntop_multibtn) {
        $btns = explode(',', $btntop_multibtn);
        foreach ($btns as $btn) {
            if ($btn == '批量删除') {
                $multibtn .= "\n                    <a class=\"lang btn dag\" onclick=\"ciyfn.select_callfunc(table, this, 'del','已选{n}条，是否{$btn}?', {},function(json){table.delline(json)})\">{$btn}</a>";
            } else if ($btn == '审核通过') {
                $hasaudit = true;
                $multibtn .= "\n                    <a class=\"lang btn imp\" onclick=\"ciyfn.select_callfunc(table, this, 'audit','已选{n}条，是否批量审核通过?', {auditstatus:100},function(json){table.updateline(json)})\">{$btn}</a>";
            } else if ($btn == '驳回') {
                $hasaudit = true;
                $auditmsg = '';
                foreach ($flds as $fld) {
                    if($fld['col'] == 'auditmsg'){
                        $auditmsg = "<br/>原因 <input name=auditmsg type=text />";
                    }
                }
                $multibtn .= "\n                    <a class=\"lang btn warn\" onclick=\"ciyfn.select_callfunc(table, this, 'audit','已选{n}条，是否批量驳回?{$auditmsg}', {auditstatus:90},function(json){table.updateline(json)})\">{$btn}</a>";
            } else {
                $btnstrs = explode('.', $btn);
                $str = $btnstrs[0];
                $extkey = '';
                if(count($btnstrs) > 1)
                    $extkey = $btnstrs[1];
                if($str[0] == '&'){
                    $str = substr($str, 1);
                    if(empty($extkey))
                        $extkey = $str;
                    $chk_multis[$extkey] = $str;
                    $multibtn .= "\n                    <a class=\"lang btn\" onclick=\"multi_{$extkey}()\">{$str}</a>";
                }else{
                    $multibtn .= "\n                    <a class=\"lang btn\" onclick=\"ciyfn.select_callfunc(table, this, '{$extkey}','已选{n}条，是否{$btn}?', {xxx:1},function(json){table.updateline(json)})\">{$str}</a>";
                }
            }
        }
    }

    $codex .= <<<data
        <div class="table">
            <div class="loading col-24">Loading...</div>
            <div class="list"></div>
            <div>
                <div class="btmbtn">
                    <a class="lang btn def" onclick="ciyfn.select_all(table)">全选</a>
                    <a class="lang btn def" onclick="ciyfn.select_diff(table)">反选</a>
                    |{$multibtn}
                </div>
                <div class="page"></div>
            </div>
        </div>
    </div>

data;

    if ($hashelp)
        $codex .= <<<data
    <div id="alert_pagehelp" style="display:none;">
        <b>标题</b>
        <div style="margin:0 0 1em 1em">
            第一行
            <br />第二行
        </div>
        <b>标题</b>
        <ol style="margin:0 0 1em -1em">
            <li>第一行</li>
            <li>第二行</li>
            <li>第三行</li>
        </ol>
    </div>

data;
    if ($hasexcelin)
        $codex .= <<<data
    <div id="alert_multiin" style="display:none;">
        <div style="display:flex;">
            <div>
                <ciy-upload com="file" />
            </div>
            <div style="margin-left:0.3em;">
                <a class="lang btn btn-sm def" href="/ud/inpl/{$tabname}.xlsx" target="_blank">下载导入模板</a><br />
                <div class="lang">每次导入建议不超过1000条</div>
                <div class="lang">导入更新，首列为导出的行码</div>
                <div class="lang">请按模版列填写</div>
            </div>
        </div>
    </div>

data;
$pspec = '';
if($hasedit){
    $codex .= "\n    <div id=\"alert_edit\" style=\"display:none;\">";
    if(count($uptabcards) > 0){
        $codex .= "\n        <div class=\"ciy-tabcard simple full {$cchar}\">";
        $codex .= "\n            <ul>";
        foreach ($uptabcards as $uptabcard)
            $codex .= "\n                <li class=\"lang\">{$uptabcard}</li>";
        $codex .= "\n            </ul>";
        $codex .= "\n            <div>";
        $codex .= "\n                <div class=\"tabcontent row\">";
        $pspec = '        ';
    }else{
        $codex .= "\n        <div class=\"{$cchar} row\">";
    }
    foreach ($flds as $fld) {
        $col = $fld['col'];
        // if ($col == 'id' || $col == 'ip' || $col == 'uptimes' || $col == 'lat' || $col == 'addtimes' || $col == $saasfield)
        //     continue;
        // if ($col == 'auditstatus' || $col == 'audittimes' || $col == 'audituser' || $col == 'auditmsg')
        //     continue;
        // if ($col == 'matterstatus' || $col == 'matternextuser' || $col == 'mattertimes')
        //     continue;
        if ($fld['set']['noup'] && $fld['set']['noup'] != 'view')
            continue;
        $sgcol = (isset($fld['set']['coledit']) ? $fld['set']['coledit'] : '24');
        //$style = (isset($fld['set']['style']) ? $fld['set']['style'] : '');

        $cate = $fld['cate'];
        $labclass = 'lang';
        if ($fld['bimp'] && $fld['set']['noup'] != 'view')
            $labclass .= ' imp';
        $clstop = '';
        if($cate == 'MD' || $cate == 'FILEMD' || $cate == 'BR' || $cate == 'AV' || $cate == 'IMG' || $cate == 'IMG1')
            $clstop = ' top';
        $codex .= "\n{$pspec}            <div class=\"ciy-form col-24 col-sm-{$sgcol}{$clstop}\">";
        if ($cate != 'MD' && $cate != 'FILEMD') //富文本编辑器，不加label
            $codex .= "\n{$pspec}                <label class=\"{$labclass}\">{$fld['name']}</label>";
        $codex .= "\n{$pspec}                <div>";
        $ext = '';
        if ($fld['set']['noup'] == 'view') {
            $codex .= "\n{$pspec}                    <div wit=\"{$col}\"></div>";
        } else if ($cate == 'FSIZE') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"KB\" bet=\"1024\" width=\"7em\" />";
        } else if ($cate == 'METRE') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"米\" bet=\"1000\" />";
        } else if ($cate == 'DATE') {
            if (strpos($fld['data'], 'H') !== false)
                $ext = ' type="datetime"';
            $codex .= "\n{$pspec}                    <ciy-datetime com=\"{$col}\"{$ext} />";
        } else if ($cate == 'TIME') {
            if (strpos($fld['data'], ':s') !== false)
                $ext = ' type="second"';
            $codex .= "\n{$pspec}                    <ciy-timepoint com=\"{$col}\"{$ext} />";
        } else if ($cate == 'MCNY') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"元\" bet=\"10000\" />";
        } else if ($cate == 'WCNY') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"万元\" bet=\"1000000\" />";
        } else if ($cate == 'MD' || $cate == 'FILEMD' || $cate == 'DOWN' || $cate == 'AV' || $cate == 'IMG' || $cate == 'IMG1') {
            if ($cate != 'MD' && $cate != 'FILEMD') {
                if ($cate == 'IMG1')
                    $num = 1;
                else
                    $num = isset($fld['set']['num']) ? $fld['set']['num'] : 3;
                $ext .= ' num="' . $num . '"';
                if (isset($fld['set']['fwh']))
                    $ext .= ' showwh="' . $fld['set']['fwh'] . '"';
                if (isset($fld['set']['ftype']))
                    $ext .= ' type="' . $fld['set']['ftype'] . '"';
            }
            if (isset($fld['set']['flimit']))
                $ext .= ' maxsize="' . $fld['set']['flimit'] . '"';
            if (isset($fld['set']['fwater']))
                $ext .= ' waterfont="28px Arial" watertext="' . $fld['set']['fwater'] . '"';
            if (isset($fld['set']['fimgw']))
                $ext .= ' imgwidth="' . $fld['set']['fimgw'] . '"';
            if (isset($fld['set']['fimgh']))
                $ext .= ' imgheight="' . $fld['set']['fimgh'] . '"';
            if (isset($fld['set']['fzip']))
                $ext .= ' zipjpg="' . $fld['set']['fzip'] . '"';
            if (isset($fld['set']['fzext']))
                $ext .= ' zipext="' . $fld['set']['fzext'] . '"';
            // if(isset($fld['set']['savepath']))
            //     $ext .= ' path="' . $fld['set']['savepath'] . '"';
            if ($cate == 'MD' || $cate == 'FILEMD')
                $codex .= "\n{$pspec}                    <ciy-markdown com=\"{$col}\"{$ext} />";
            else
                $codex .= "\n{$pspec}                    <ciy-upload com=\"{$col}\"{$ext} />";
        } else if ($cate == 'BOOL') {
            $datas = explode('.', $fld['data']);
            if (empty($datas[0]))
                $datas[0] = '✔';
            if (!isset($datas[1]) || empty($datas[1]))
                $datas[1] = '✘';
            $ext .= ' y="' . $datas[0] . '"';
            $ext .= ' n="' . $datas[1] . '"';
            $codex .= "\n{$pspec}                    <ciy-switch com=\"{$col}\"{$ext} />";
        } else if ($cate == 'UNIT') {
            $codex .= "\n{$pspec}                    <ciy-inputunitedit com=\"{$col}\" />";
        } else if ($cate == 'CATA' || $cate == 'TINT') {
            if (isset($fld['set']['catacmp']) && $fld['set']['catacmp'] == 'radio')
                $codex .= "\n{$pspec}                    <ciy-radio com=\"{$col}\" />";
            else {
                if (!$fld['bimp'])
                    $ext .= ' all="无"';
                $codex .= "\n{$pspec}                    <ciy-select com=\"{$col}\"{$ext} />";
            }
        } else if ($cate == 'DB' || $cate == 'CATU') {
            if (isset($fld['set']['dbedit']) && $fld['set']['dbedit'] == 'window') //暂无实现窗选/组织
                $codex .= "\n{$pspec}                    <ciy-select com=\"{$col}\"{$ext} />";
            else if (isset($fld['set']['dbedit']) && $fld['set']['dbedit'] == 'text') {
                $codex .= "\n{$pspec}                    <input type=\"text\" name=\"{$col}\" style=\"width:10em;\" />";
            } else {
                if (!$fld['bimp'])
                    $ext .= ' all="无"';
                $codex .= "\n{$pspec}                    <ciy-select com=\"{$col}\"{$ext} />";
            }
        } else if ($cate == 'CATS' || $cate == 'TBIN') {
            if (isset($fld['set']['catstype']) && $fld['set']['catstype'] == 'selmulti')
                $codex .= "\n{$pspec}                    <ciy-selmulti com=\"{$col}\" />";
            else
                $codex .= "\n{$pspec}                    <ciy-checkbox com=\"{$col}\" />";
        } else if ($cate == 'CATM') {
            if (isset($fld['set']['cas']))
                $ext = ' rootupid="' . $fld['set']['cas'] . '"';
            $codex .= "\n{$pspec}                    <ciy-selcas com=\"{$col}\"{$ext} />";
        } else if ($cate == 'CYC') {
            $codex .= "\n{$pspec}                    <ciy-inputcyc com=\"{$col}\" />";
        } else if ($cate == 'SEC') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"秒\" bet=\"1\" />";
        } else if ($cate == 'INT') {
            $strstart = '';
            $strend = $fld['data'];
            $ind = strpos($fld['data'], '?');
            $align = 'right';
            if ($ind > 0) {
                $strstart = substr($fld['data'], 0, $ind);
                $strend = substr($fld['data'], $ind + 1);
                if (empty($strend))
                    $align = 'left';
                else
                    $align = 'center';
            }
            $codex .= "\n{$pspec}                    {$strstart}<input type=\"text\" name=\"{$col}\" style=\"width:6em;text-align:{$align};\" /> {$strend}";
        } else if ($cate == 'TON') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"吨\" bet=\"1000000\" />";
        } else if ($cate == 'BET') {
            $unit = flddata($fld['data'], 0, '');
            $bet = flddata($fld['data'], 1, 100);
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"{$unit}\" bet=\"{$bet}\" />";
        } else if ($cate == 'LNY') {
            $unit = flddata($fld['data'], 0, '元.万元.亿元');
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"{$unit}\" bet=\"100.1000000.10000000000\" />";
        } else if ($cate == 'SNY') {
            $unit = flddata($fld['data'], 0, '¤.K¤.M¤.B¤.T¤.Q¤');
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"{$unit}\" bet=\"100.100000.100000000.100000000000.100000000000000\" />";
        } else if ($cate == 'WGT') {
            $unit = flddata($fld['data'], 0, '克.*千克.吨');
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"{$unit}\" bet=\"1.1000.1000000\" />";
        } else if ($cate == 'LGH') {
            $unit = flddata($fld['data'], 0, '厘米.*米.公里');
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"{$unit}\" bet=\"10.1000.1000000\" />";
        } else if ($cate == 'PCT') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"%\" bet=\"100\" />";
        } else if ($cate == 'CNY') {
            $strend = $fld['data'];
            if(empty($strend))
                $strend = '元';
            else{
                $ind = strpos($strend, ',');
                $strend = substr($strend, $ind + 1);
            }
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"{$strend}\" bet=\"100\" />";
        } else if ($cate == 'LOC') {
            $codex .= "\n{$pspec}                    <ciy-map com=\"loc\" />";
        } else if ($cate == 'NUM') {
            $codex .= "\n{$pspec}                    <input type=\"text\" name=\"{$col}\" style=\"width:9em;text-align:right;\" />";
        } else if ($cate == 'URL' || $cate == 'MSK') {
            $codex .= "\n{$pspec}                    <input type=\"text\" name=\"{$col}\" style=\"width:100%;\" />";
        } else if ($cate == 'KG') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"KG\" bet=\"1000\" />";
        } else if ($cate == 'TC') {
            $codex .= "\n{$pspec}                    <ciy-inputbet com=\"{$col}\" unit=\"℃\" bet=\"1000\" />";
        } else if ($cate == 'BR') {
            $ext = ' total="{line}行，{word}字"';
            if (!empty($fld['set']['height']))
                $ext = ' minheight="' . $fld['set']['height'] . '"';
            $codex .= "\n{$pspec}                    <ciy-textarea com=\"{$col}\"{$ext} />";
        } else {
            if (@$fld['set']['txtedit'] == 'txtarea'){
                if (!empty($fld['set']['height']))
                    $ext = ' minheight="' . $fld['set']['height'] . '"';
                    $codex .= "\n{$pspec}                    <ciy-textarea com=\"{$col}\"{$ext} />";
            }else{
                $codex .= "\n{$pspec}                    <input type=\"text\" name=\"{$col}\" style=\"width:100%;\" />";
            }
        }
        $codex .= "\n{$pspec}                </div>";
        $codex .= "\n{$pspec}            </div>";
    }
    if(count($uptabcards) > 0){
        for ($i=0;$i<count($uptabcards)-1;$i++){
            $codex .= "\n                </div>";
            $codex .= "\n                <div class=\"tabcontent row\">";
        }
        $codex .= "\n                </div>";
        $codex .= "\n            </div>";
        $codex .= "\n        </div>";
    }else{
        $codex .= "\n        </div>";
    }
    $codex .= "\n    </div>";
}

    foreach($chk_multis as $key=>$name){
        $codex .= "\n    <div id=\"alert_multi_{$key}\" style=\"display:none;\">";
        $codex .= "\n        <div class=\"char4 row\">";
        $codex .= "\n            <div class=\"ciy-form col-24 col-sm-24\">";
        $codex .= "\n                <label class=\"lang\">录入</label>";
        $codex .= "\n                <div>";
        $codex .= "\n                    <input name=\"inptext\" type=\"text\" style=\"width:100%;\"></input>";
        $codex .= "\n                </div>";
        $codex .= "\n            </div>";
        $codex .= "\n            <div class=\"ciy-form col-24 col-sm-24\">";
        $codex .= "\n                <label class=\"lang\">组件</label>";
        $codex .= "\n                <div>";
        $codex .= "\n                    <ciy-datetime com=\"comxxx\"></ciy-datetime>";
        $codex .= "\n                </div>";
        $codex .= "\n            </div>";
        $codex .= "\n        </div>";
        $codex .= "\n    </div>";
    }

    $codex .= "\n    <script type=\"text/javascript\" src=\"/jscss/ciy.js\"></script>";
    $codex .= "\n    <script type=\"text/javascript\" src=\"/jscss/ciycmp.js\"></script>";
    if ($ciycmp2)
        $codex .= "\n    <script type=\"text/javascript\" src=\"/jscss/ciycmp2.js\"></script>";
    $codex .= "\n    <script type=\"text/javascript\" src=\"/jscss/ciytable.js\"></script>";
    foreach ($ciydict as $dictjs) {
        $codex .= "\n    <script type=\"text/javascript\" src=\"/ud/dict/{$dictjs}.js\"></script>";
    }
    $savepc = str_replace('\\', '/', $savepc);
    $savepc = substr($savepc, strpos($savepc, 'web/') + 4);
    $count = substr_count($savepc, '/');
    $subpathn = './';
    if($count > 0)
        $subpathn = str_repeat('../', $count - 1);
    $codex .= "\n    <script type=\"text/javascript\" src=\"{$subpathn}common.js\"></script>";

    $liid = '';
    if (!empty($liiddict)) {
        if (strpos($liiddict, ',') !== false) {
            $liiddicts = explode(',', $liiddict);
            $liids = [];
            $liidnum = 0;
            foreach ($liiddicts as $liidname) {
                if (empty($liidname))
                    continue;
                $liids[] = "{ id: '" . ($liidnum == 0 ? '' : $liidnum) . "', name: '{$liidname}' }";
                $liidnum++;
            }
            $liid .= "\n                        , lidata: [" . implode(', ', $liids) . "]";
            $liid .= "\n                        , liclick: function (dom) {";
            $liid .= "\n                            table.search(dom, 'li');";
            $liid .= "\n                        }";
        } else {
            $liid .= "\n                        , liall: '全部'";
            $liid .= "\n                        , lidata: '{$liiddict}'";
            $liid .= "\n                        , liclick: function (dom) {";
            $liid .= "\n                            table.search(dom, 'li');";
            $liid .= "\n                        }";
        }
    }

    $editbtn = '';
    $menubtn = '';
    $bmenubtn = false;
    $subpathn = '';
    $ind = strpos($subpath, '\\');
    if($ind > 0)
        $subpathn = str_replace('\\','/', substr($subpath, $ind+1)) . '/';
    $strs = explode(',', $btnlist_line); //添加,导入,导出,其他,操作|成果|方法|-修改|删除,&填报,$跳转选项卡
    $subgomenus = array();
    foreach ($strs as $str) {
        $ind = strpos($str, '|');
        if ($ind === false) {
            $extcls = '';
            $extkey = '';
            if ($str == '查看') {
                $extcls = ' def';
                $extkey = 'view';
                $menubtn .= "\n            if (btn == 'view') {";
                $menubtn .= "\n                view(id);";
                $menubtn .= "\n            }";
            }
            else if ($str == '修改') {
                $extkey = 'edit';
                $menubtn .= "\n            if (btn == 'edit') {";
                $menubtn .= "\n                edit(id);";
                $menubtn .= "\n            }";
            }
            else if ($str == '删除') {
                $extcls = ' dag';
                $extkey = 'del';
                $menubtn .= "\n            if (btn == 'del') {";
                $menubtn .= "\n                ciyfn.callfastfunc(dom, '是否删除?', 'del', { ids: id }, function (json){ table.delline(json) });";
                $menubtn .= "\n            }";
            }
            else if ($str == '审核') {
                $hasreview = true;
                $extcls = '';
                $extkey = 'review';
                $menubtn .= "\n            if (btn == 'review') {";
                $menubtn .= "\n                review(id);";
                $menubtn .= "\n            }";
            }
            else {
                $btnstrs = explode('.', $str);
                $str = $btnstrs[0];
                $extkey = '';
                if(count($btnstrs) > 1)
                    $extkey = $btnstrs[1];
                if($str[0] == '&'){
                    $str = substr($str, 1);
                    if(empty($extkey))
                        $extkey = $str;
                    $menubtn .= "\n            if (btn == '{$extkey}') {";
                    $menubtn .= "\n                edit_{$extkey}(id);";
                    $menubtn .= "\n            }";
                }else if($str[0] == '$'){
                    $str = substr($str, 1);
                    if(empty($extkey))
                        $extkey = $str;
                    $xid = 'xxxid';
                    if(isset($btnstrs[2]))
                        $xid = $btnstrs[2];
                    $menubtn .= "\n            if (btn == '{$extkey}') {";
                    $menubtn .= "\n                ciyfn.sendsignal(window.top, 'manage_ifropen', {";
                    $menubtn .= "\n                    url: '{$subpathn}{$extkey}.html?_{$xid}=' + id";
                    $menubtn .= "\n                    , name: '{$str}<code>' + table.data[id].name + '</code>'";
                    $menubtn .= "\n                });";
                    $menubtn .= "\n            }";
                }else{
                    if(empty($extkey))
                        $extkey = $str;
                    $menubtn .= "\n            if (btn == '{$extkey}') {";
                    $menubtn .= "\n                ciyfn.callfastfunc(dom, '是否{$str}?', '{$extkey}', { ids: id }, function (json) { table.updateline(json) });";
                    $menubtn .= "\n            }";
                }
                $extcls = '';
            }
            $editbtn .= "\n                        html += `<a class=\"lang btn{$extcls}\" onclick=\"menubtn(this, '{$extkey}')\" onmousedown=\"event.stopPropagation()\">{$str}</a>`;";
        } else {
            $bmenubtn = true;
            $subs = explode('|', $str); //操作|成果|方法|-|修改|删除
            $editbtn .= "\n                        html += `<a class=\"btn btn-menu\" direction=\"lr\"><span class=\"lang\">{$subs[0]}</span>";
            $editbtn .= "\n                                <span class=\"caret\"></span>";
            $editbtn .= "\n                                <ul class=\"ciy-popmenu\">";
            for ($j = 1; $j < count($subs); $j++) {
                $str = $subs[$j];
                if ($str == '-') {
                    $editbtn .= "\n                                    <li class=\"line\"></li>";
                } else {
                    $btnstrs = explode('.', $str);
                    $str = $btnstrs[0];
                    $extkey = '';
                    if(count($btnstrs) > 1)
                        $extkey = $btnstrs[1];
                    if($str[0] == '&'){
                        $str = substr($str, 1);
                        if(empty($extkey))
                            $extkey = $str;
                        $menubtn .= "\n            if (btn == '{$extkey}') {";
                        $menubtn .= "\n                {$extkey}(id);";
                        $menubtn .= "\n            }";
                    }else if($str[0] == '$'){
                        $str = substr($str, 1);
                        if(empty($extkey))
                            $extkey = $str;
                        $xid = 'xxxid';
                        if(isset($btnstrs[2]))
                            $xid = $btnstrs[2];
                        $menubtn .= "\n            if (btn == '{$extkey}') {";
                        $menubtn .= "\n                ciyfn.sendsignal(window.top, 'manage_ifropen', {";
                        $menubtn .= "\n                    url: '{$subpathn}{$extkey}.html?_{$xid}=' + id";
                        $menubtn .= "\n                    , name: '{$str}<code>' + table.data[id].name + '</code>'";
                        $menubtn .= "\n                });";
                        $menubtn .= "\n            }";
                    }else if ($str == '查看') {
                        $extcls = ' def';
                        $extkey = 'view';
                        $menubtn .= "\n            if (btn == 'view') {";
                        $menubtn .= "\n                view(id);";
                        $menubtn .= "\n            }";
                    }
                    else if ($str == '修改') {
                        $extkey = 'edit';
                        $menubtn .= "\n            if (btn == 'edit') {";
                        $menubtn .= "\n                edit(id);";
                        $menubtn .= "\n            }";
                    }
                    else if ($str == '删除') {
                        $extcls = ' dag';
                        $extkey = 'del';
                        $menubtn .= "\n            if (btn == 'del') {";
                        $menubtn .= "\n                ciyfn.callfastfunc(dom, '是否删除?', 'del', { ids: id }, function (json){ table.delline(json) });";
                        $menubtn .= "\n            }";
                    }
                    else if ($str == '审核') {
                        $hasreview = true;
                        $extcls = '';
                        $extkey = 'review';
                        $menubtn .= "\n            if (btn == 'review') {";
                        $menubtn .= "\n                review(id);";
                        $menubtn .= "\n            }";
                    }
                    else {
                        if(empty($extkey))
                            $extkey = $str;
                        $menubtn .= "\n            if (btn == '{$extkey}') {";
                        $menubtn .= "\n                ciyfn.callfastfunc(dom, '是否{$str}?', '{$extkey}', { ids: id }, function (json) { table.updateline(json) });";
                        $menubtn .= "\n            }";
                    }
                    $editbtn .= "\n                                    <li{$ext} onclick=\"menubtn(this, '{$extkey}')\" onmousedown=\"event.stopPropagation()\">{$str}</li>";
                }
            }
            $editbtn .= "\n                                </ul></a>`;";
        }
    }
    $pcaddtit = '';
    if ($hasadd)
        $pcaddtit = "id == 0 ? '新建' : ";
    $codex .= "\n    <script type=\"text/javascript\">";
    $codex .= "\n        'use strict';";
    $codex .= "\n        var table;";
    $codex .= "\n        var Glob = {};";
    $codex .= "\n        ciyfn.pageload(function () {";
    $codex .= "\n            //Glob.urlp = ciyfn.urlparam();";
    $codex .= "\n            table = new ciyclass.table({";
    $codex .= "\n                dom: '.table'";
    $codex .= "\n                , url: 'list'";
    $codex .= "\n                , pagecount: 10";
    if (strpos($pcparam, ',listchk,') !== false)
        $codex .= "\n                , chkbox: true";
    $codex .= "\n                , fn_beforedata: function (json) {";
    $codex .= "\n                    ciyfn.fillsearch({";
    $codex .= "\n                        searchdom: '.search'";
    $codex .= "\n                        , data: json{$liid}";
    $codex .= "\n                    });";
    $codex .= "\n                    return json;";
    $codex .= "\n                }";
    $codex .= "\n                , fn_tdcontent: function (key, datashow, field, data) {";
    $codex .= "\n                    if (key == '_btn') {";
    $codex .= "\n                        var html = '';{$editbtn}";
    $codex .= "\n                        return html;";
    $codex .= "\n                    }";
    $codex .= "\n                }";
    $codex .= "\n                , fn_done: function (json) {";
    $codex .= "\n                    // table.mergecol('auditstatus');";
    $codex .= "\n                    // table.mergefix('总计', 'center', 6, 0, 8, 1);";
    $codex .= "\n                    // table.footertotal();";
    if($bmenubtn)
        $codex .= "\n                    ciyfn.dropmenu('.btn-menu');";
    $codex .= "\n                }";
    $codex .= "\n            });";
    $codex .= "\n            table.callpage(1);";
    $codex .= "\n        });";
    $codex .= "\n        function menubtn(dom, btn) {";
    $codex .= "\n            var id = $5(dom).parent('tr').attr('data-id');{$menubtn}";
    $codex .= "\n        }";
    $codex .= "\n";
    if ($hasedit || $hasview || $hasreview) {
        $codex .= "\n        function getdata(id, act, cb) {";
        if ($chk_getupdate) {
            $codex .= "\n            ciyfn.callfunc('getdata', { id: id, act: act }, function (json) {";
            $codex .= "\n                cb(json);";
            $codex .= "\n            });";
            $codex .= "\n            // cb({ data: id == 0 ? {} : table.data[id] });";
        }else{
            $codex .= "\n            cb({ data: id == 0 ? {} : table.data[id] });";
        }
        $codex .= "\n        }";
        $codex .= "\n";
    }
    if ($hasedit) {
        $codex .= "\n        function edit(id) {";
        $codex .= "\n            getdata(id, 'edit', function (jsndat) {";
        $codex .= "\n                ciyfn.alert({";
        $codex .= "\n                    title: {$pcaddtit}'修改'";
        $codex .= "\n                    , width: 'pc'";
        if(count($uptabcards) > 0)
            $codex .= "\n                    , height: 'pc'";
        $codex .= "\n                    , content: document.getElementById(\"alert_edit\").innerHTML";
        $codex .= "\n                    //, noparent:true";
        $codex .= "\n                    , fn_showed: function (doc, dom) {";
        if (count($uptabcards) > 0) {
            $codex .= "\n                        var tab = new ciyclass.tabcard({";
            $codex .= "\n                            dom: $5('.ciy-tabcard', dom),";
            $codex .= "\n                            onchange: function (e) {}";
            $codex .= "\n                        });";
        }
        $codex .= "\n                        var dat = jsndat.data;";
        foreach ($flds as $fld) {
            $cate = $fld['cate'];
            $col = $fld['col'];
            if ($fld['set']['noup'] && $fld['set']['noup'] != 'view')
                continue;

            if ($fld['set']['noup'] == 'view') {
                $codex .= "\n                        $5('[wit={$col}]', dom).html(ciyfn.tdshow('{$col}', dat.{$col}, table.field.{$col}.ext, dat, table.json, true));";
            } else if (
                $cate == 'FSIZE' || $cate == 'METRE' || $cate == 'DATE' || $cate == 'TIME' || $cate == 'BOOL'
                || $cate == 'WCNY' || $cate == 'UNIT' || $cate == 'CYC' || $cate == 'SEC' || $cate == 'TON'
                || $cate == 'PCT' || $cate == 'MCNY' || $cate == 'CNY' || $cate == 'KG' || $cate == 'TC'
                || $cate == 'BET' || $cate == 'LNY' || $cate == 'SNY' || $cate == 'WGT' || $cate == 'LGH'
            ) {
                $codex .= "\n                        ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col} });";
            } else if ($cate == 'BR') {
                $codex .= "\n                        ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, autoheight: true });";
            } else if ($cate == 'CATA' || $cate == 'CATU' || $cate == 'CATM' || $cate == 'CATS' || $cate == 'TINT' || $cate == 'DB') {
                list($dicttype, $dictname) = splitdict($fld['data']);
                if ($dicttype == 'dictciy')
                    $range = $dictname;
                else if ($dicttype == 'dictdb') {
                    if (isset($fld['set']['listload']) && $fld['set']['listload'] == 'rel')
                        $range = 'jsndat.' . $dictname;
                    else
                        $range = 'table.json.' . $dictname;
                } else
                    $range = "'{$dictname}'";
                if (isset($fld['set']['dbedit']) && $fld['set']['dbedit'] == 'text')
                    $codex .= "\n                        $5('[name={$col}]', dom).val(dat.{$col});";
                else
                    $codex .= "\n                        ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, range: {$range} });";
            } else if ($cate == 'MD' || $cate == 'DOWN' || $cate == 'AV' || $cate == 'IMG' || $cate == 'IMG1') {
                $codex .= "\n                        ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col}, path: ciyfn.makeuploadpath('{$fld['set']['savepath']}', ciyfn.getstorage(ciy_vars.tokenfield)) });";
            } else if ($cate == 'FILEMD') {
                $codex .= "\n                        var path = ciyfn.makeuploadpath('{$fld['set']['savepath']}', ciyfn.getstorage(ciy_vars.tokenfield));";
                $codex .= "\n                        ciyfn.ajax({";
                $codex .= "\n                            url: ciyfn.file_stor('/md/{$fld['set']['savepath']}/' + dat.id + '_' + dat.{$col} + '.txt')";
                $codex .= "\n                            , method: 'GET'";
                $codex .= "\n                            , success: function (res) {";
                $codex .= "\n                                ciycmp({ dom: $5('[com={$col}]', dom), value: res, path: path });";
                $codex .= "\n                            }";
                $codex .= "\n                        , fail: function (res) {";
                $codex .= "\n                                ciycmp({ dom: $5('[com={$col}]', dom), value: '[MD]', path: path });";
                $codex .= "\n                            }";
                $codex .= "\n                        });";
            } else if ($cate == 'TBIN') {
                $codex .= "\n                        var values = [];";
                $codex .= "\n                        var ibin = parseInt(dat.{$col});";
                $codex .= "\n                        for (var tt = 0; tt < 64; tt++) {";
                $codex .= "\n                            if (ibin & Math.pow(2, tt))";
                $codex .= "\n                            values.push(tt + 1);";
                $codex .= "\n                        }";
                $dats = explode('|', $fld['data']);
                $codex .= "\n                        ciycmp({ dom: $5('[com={$col}]', dom), value: values.join(','), range: '{$dats[0]}' });";
            } else if ($cate == 'LOC') {
                $codex .= "\n                        ciycmp({ dom: $5('[com=loc]', dom), value: { lat: dat.lat, lng: dat.lng } });";
            } else { //INT NUM URL MSK
                if(@$fld['set']['txtedit'] == 'txtarea')
                    $codex .= "\n                        ciycmp({ dom: $5('[com={$col}]', dom), value: dat.{$col} });";
                else
                    $codex .= "\n                        $5('[name={$col}]', dom).val(dat.{$col});";
            }
        }

        $codex .= "\n                    }";
        $codex .= "\n                    , cb: function (opn) {";
        $codex .= "\n                        if (opn.btn == \"关闭\")";
        $codex .= "\n                            return opn.close();";
        $codex .= "\n                        opn.inputs.id = id;";
        $codex .= "\n                        if (ciyfn.throttle(opn.dombtn)) return;";
        foreach ($flds as $fld) {
            $col = $fld['col'];
            if ($fld['cate'] == 'TBIN') {
                $codex .= "\n                        var bins = opn.inputs.{$col}.split(',');";
                $codex .= "\n                        opn.inputs.{$col} = 0;";
                $codex .= "\n                        for (var bi in bins) {";
                $codex .= "\n                            if (!bins[bi])";
                $codex .= "\n                                continue;";
                $codex .= "\n                            var bc = toint(bins[bi]);";
                $codex .= "\n                            if (bc < 1 || bc > 63)";
                $codex .= "\n                                continue;";
                $codex .= "\n                            opn.inputs.renzheng += Math.pow(2, (bc - 1));";
                $codex .= "\n                        }";
            }
        }
        $codex .= "\n                        ciyfn.callfunc('update', opn.inputs, function (json) {";
        if (strpos($pcparam, ',editsave,') !== false) {
            $codex .= "\n                            if (opn.btn == '保存(Ctrl+S)')";
            $codex .= "\n                                return;";
        }
        $codex .= "\n                            table.updateline(json);";
        $codex .= "\n                            opn.close();";
        $codex .= "\n                            ciyfn.toast('提交成功');";
        $codex .= "\n                        });";
        $codex .= "\n                    },";
        if (strpos($pcparam, ',editsave,') !== false)
            $codex .= "\n                    btns: id == 0 ? [\"新建\", \"*关闭\"] : [\"#保存(Ctrl+S)\", \"提交\", \"*关闭\"],";
        else
            $codex .= "\n                    btns: id == 0 ? [\"新建\", \"*关闭\"] : [\"提交\", \"*关闭\"],";
        $codex .= "\n                });";
        $codex .= "\n            });";
        $codex .= "\n        }";
    }
    if ($hasview) {
        $codex .= "\n        function view(id) {";
        $codex .= "\n            getdata(id, 'view', function (jsndat) {";
        $codex .= "\n                var dat = jsndat.data;";
        $codex .= "\n                var html = '<div class=\"{$cchar} row gridline\">';";
        foreach ($flds as $fld) {
            $col = $fld['col'];
            $cate = $fld['cate'];
            if (empty($fld['name']))
                continue;
            // if (empty($fld['name']) || $col == 'id' || $col == 'lat' || $col == $saasfield)
            //     continue;
            if (!$fld['bviw'])
                continue;
            $sgcol = (isset($fld['set']['colview']) ? $fld['set']['colview'] : '24');
            $clstop = '';
            if($cate == 'MD' || $cate == 'FILEMD' || $cate == 'BR' || $cate == 'AV' || $cate == 'IMG' || $cate == 'IMG1')
                $clstop = ' top';
            $codex .= "\n                html += '<div class=\"ciy-form col-24 col-sm-{$sgcol}{$clstop}\">';";
            $codex .= "\n                html += '<label class=\"lang\">{$fld['name']}</label><div>';";
            $codex .= "\n                html += ciyfn.tdshow('{$col}', dat.{$col}, table.field.{$col}.ext, dat, table.json, true);";
            $codex .= "\n                html += '&nbsp;</div></div>';";
            $codex .= "\n";
        }
        $codex .= "\n                html += '</div>';";
        $codex .= "\n                ciyfn.alert({";
        $codex .= "\n                    title: '查看'";
        $codex .= "\n                    , width: 'pc'";
        $codex .= "\n                    , autoheight: true";
        foreach ($flds as $fld) {
            if($fld['cate'] == 'FILEMD'){
                $codex .= "\n                    , fn_showed: function (doc, dom) {";
                $codex .= "\n                        var path = ciyfn.makeuploadpath('{$fld['set']['savepath']}', ciyfn.getstorage(ciy_vars.tokenfield));";
                $codex .= "\n                        path = path.replace(/{Y}/g, new Date().getFullYear()).replace(/{m}/g, ciyfn.topad0(new Date().getMonth() + 1, 2)).replace(/{d}/g, ciyfn.topad0(new Date().getDate(), 2));";
                $codex .= "\n                        ciyfn.ajax({";
                $codex .= "\n                            url: ciyfn.file_stor('/' + path + '/' + dat.id + '_' + dat.{$fld['col']} + '.txt')";
                $codex .= "\n                            , method: 'GET'";
                $codex .= "\n                            , success: function (res) {";
                $codex .= "\n                                $5('[data-mdver]', dom).html(ciyfn.markdown(res));";
                $codex .= "\n                            }";
                $codex .= "\n                        , fail: function (res) {";
                $codex .= "\n                                $5('[data-mdver]', dom).html('未加载');";
                $codex .= "\n                            }";
                $codex .= "\n                        });";
                $codex .= "\n                    }";
            }
        }
        $codex .= "\n                    , content: html";
        $codex .= "\n                });";
        $codex .= "\n            });";
        $codex .= "\n        }";
    }

    if ($hasreview) {
        $codex .= "\n        function review(id) {";
        $codex .= "\n            getdata(id, 'review', function (jsndat) {";
        $codex .= "\n                var dat = jsndat.data;";
        $codex .= "\n                var html = '<div class=\"{$cchar} row gridline\">';";
        foreach ($flds as $fld) {
            $col = $fld['col'];
            if (empty($fld['name']))
                continue;
            if (!$fld['bviw'])
                continue;
            if ($col == 'auditstatus' || $col == 'auditmsg')
                continue;
            if ($saasfield == $fld['col'])
                continue;
            $sgcol = (isset($fld['set']['colview']) ? $fld['set']['colview'] : '24');
            $codex .= "\n                html += '<div class=\"ciy-form col-24 col-sm-{$sgcol}\">';";
            $codex .= "\n                html += '<label class=\"lang\">{$fld['name']}</label><div>';";
            $codex .= "\n                html += ciyfn.tdshow('{$col}', dat.{$col}, table.field.{$col}.ext, dat, table.json, true);";
            $codex .= "\n                html += '</div></div>';";
            $codex .= "\n";
        }
        foreach ($flds as $fld) {
            if($fld['col'] == 'auditmsg'){
                $codex .= "\n                html += '<div class=\"ciy-form col-24 col-sm-24\">';";
                $codex .= "\n                html += '<label class=\"lang\">拒绝理由</label><div>';";
                $codex .= "\n                html += '<input type=\"text\" name=\"auditmsg\" style=\"width:100%;\" />';";
                $codex .= "\n                html += '</div></div>';";
            }
        }
        $codex .= "\n                html += '</div>';";
        $codex .= "\n                ciyfn.alert({";
        $codex .= "\n                    title: '审核'";
        $codex .= "\n                    , width: 'pc'";
        $codex .= "\n                    , autoheight: true";
        $codex .= "\n                    , content: html";
        $codex .= "\n                    , cb: function (opn) {";
        $codex .= "\n                        if (opn.btn == \"关闭\")";
        $codex .= "\n                            return opn.close();";
        $codex .= "\n                        opn.inputs.ids = id;";
        $codex .= "\n                        opn.inputs.auditstatus = opn.btn == \"审核通过\" ? 100 : 90;";
        $codex .= "\n                        if (ciyfn.throttle(opn.dombtn)) return;";
        $codex .= "\n                        ciyfn.callfunc('audit', opn.inputs, function (json) {";
        $codex .= "\n                            table.updateline(json);";
        $codex .= "\n                            opn.close();";
        $codex .= "\n                            ciyfn.toast('提交成功');";
        $codex .= "\n                        });";
        $codex .= "\n                    }";
        $codex .= "\n                    , btns: [\"审核通过\", \"!驳回\", \"*关闭\"]";
        $codex .= "\n                });";
        $codex .= "\n            });";
        $codex .= "\n        }";
    }

    if ($hasexcelin) {
        $codex .= <<<data

        function multiin() {
            ciyfn.table_multiin('importxls', document.getElementById("alert_multiin").innerHTML, function (json) {
                ciyfn.toast('导入成功');
                table.cachecount = -1;
                table.callpage();
            });
        }

data;
    }
    if ($hasexcelout) {
        $codex .= <<<data

        function exportxls() {
            ciyfn.table_exportxls('exportxls', table, function (json) {
                ciyfn.alert({
                    content: '<div style="text-align:center;"><span class="lang">导出数据已生成</span><br/><br/><a class="lang btn lg" href="' + json.url + '" target="_blank">下载数据</a></div>'
                    , btns: null
                });
            });
        }

data;
    }
    if ($hashelp) {
        $codex .= <<<data

        function pagehelp() {
            ciyfn.alert({
                title: '页面帮助'
                , width: 'pc'
                , content: document.getElementById("alert_pagehelp").innerHTML
            });
        }

data;
    }



    foreach($chk_multis as $key=>$name){
        $codex .= <<<data

        function multi_{$key}() {
            var ids = [];
            $5('[data-id]', '.table').each(function (dom) {
                if ($5(dom).hasClass("selected"))
                ids.push($5(dom).attr("data-id"));
            });
            if (ids.length == 0)
                return ciyfn.toast("请至少选择一条信息");
            
            ciyfn.alert({
                title: '批量{$name}'
                , width: 'pc'
                , content: document.getElementById("alert_multi_{$key}").innerHTML
                , nomaskclose: true
                //, noparent:true
                , fn_showed: function (doc, dom) {
                    ciycmp({ dom: $5('[com=comxxx]', dom), value: tostamp() });
                }
                , cb: function (opn) {
                    if (opn.btn == "关闭")
                        return opn.close();
                    opn.inputs.ids = ids.join(",");
                    if (ciyfn.throttle(opn.dombtn)) return;
                    ciyfn.callfunc('multi_{$key}', opn.inputs, function (json) {
                        table.updateline(json);
                        opn.close();
                        ciyfn.toast('提交成功');
                    });
                },
                btns: ["提交", "*关闭"]
            });
        }

data;
    }
    $codex .= <<<data

    </script>
</body>

</html>
data;
    return $codex;
}
