运营狗 - 自定义表单 https://blog.seo135.com/tag/%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A1%A8%E5%8D%95/ zh-CN Wed, 01 Apr 2020 09:19:00 +0800 Wed, 01 Apr 2020 09:19:00 +0800 织梦DedeCMS后台自定义表单添加全选功能 https://blog.seo135.com/654.html https://blog.seo135.com/654.html Wed, 01 Apr 2020 09:19:00 +0800 运营狗 在织梦DedeCMS后台的自定义表单中,如果想要批量审核或者删除多条记录时,只能一个一个的去操作,非常影响工作效率,我们可以在操作按钮的判断加一个【全选/全不选】功能按钮,大大方便我们的工作效率。

织梦DedeCMS后台自定义表单添加全选功能

打开/dede/templets/diy_list.htm找到,大概在58行

审核

这一行,在它上面加入

<label><input type="button" name="select" onClick="selAll()" value="全选"/></label>
<label><input type="button" name="select" onClick="noSelAll()" value="反选"/></label>
<script type="text/javascript">
function selAll(){
    var a = document.getElementsByTagName("input");
    for(var i = 0;i<a.length;i++){
        if(a[i].type == "checkbox") a[i].checked = true;
    }
}
function noSelAll(){
    var a = document.getElementsByTagName("input");
    for(var i = 0;i<a.length;i++){
        if(a[i].type == "checkbox") a[i].checked = false;
    }
}
</script>

如图
织梦DedeCMS后台自定义表单添加全选功能

]]>
0 https://blog.seo135.com/654.html#comments https://blog.seo135.com/feed/tag/%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A1%A8%E5%8D%95/
织梦DedeCMS自定义表单导出到excel https://blog.seo135.com/532.html https://blog.seo135.com/532.html Thu, 04 Apr 2019 22:04:00 +0800 运营狗 织梦DedeCMS自定义表单导出到excel

实现教程

1、/dede/templets/diy_main.htm 找到

前台预览</a>

在它的下面加入一行

| <a href="diy_list.php?action=excel&diyid={dede:field.diyid/}" target="_blank">导出表单Excel</a>

2、/dede/diy_list.php 找到

array('post', 'list', 'edit', 'check', 'delete'))

改成

array('post', 'list', 'edit', 'check', 'delete', 'excel'))

继续找到

else
{
    showmsg('未定义操作', "-1");
}

在它的上面加入

else if($action == 'excel')
{
    header("Content-type:application/vnd.ms-excel");
    header("Content-Disposition:attachment;filename={$diy->name}_".date("Y-m-d").".xls");
    $fieldlist = $diy->getFieldList();
    echo "<table><tr>";
    foreach($fieldlist as $field=>$fielddata)
    {
        echo "<th>{$fielddata[0]}</th>";
    }
    echo "<th>状态</th>";
    echo "</tr>";
    $sql = "SELECT * FROM {$diy->table} ORDER BY id DESC";
    $dsql->SetQuery($sql);
    $dsql->Execute('t');
    while($arr = $dsql->GetArray('t'))
    {
        echo "<tr>";
        foreach($fieldlist as $key => $field)
        {
            echo "<td>".$arr[$key]."</td>";
        }
        $status = $arr['ifcheck'] == 1 ? '已审核' : '未审核';
        echo "<td>".$status."</td>";
        echo "</tr>";
    }
    echo "</table>";
}

PS:导出的excel文件请用wps软件打开,office软件下好像会乱码。

]]>
0 https://blog.seo135.com/532.html#comments https://blog.seo135.com/feed/tag/%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A1%A8%E5%8D%95/