zoukankan      html  css  js  c++  java
  • Ecshop里添加多个h1标题


    功能:

    点击页面右边的两个按钮,切换下面的<div class="form-div">和表格里的内容

    思路:

    1. 控制器里把$action_link 和 $action_link2赋值到模板里(变量里带连接和标题名字)
    2. 控制器里把$filter.sn_type的值(1或者2) 赋值到模板里
    3. 模板里判断$filter.sn_type eq 1还是$filter.sn_type eq 2 来切换显示的内容

    效果:

    image

    pageheader_list.htm里

    D:phpStudyWWWworkwdm runkwww.wdmcake.cnwwwadmin emplatespageheader_list.htm

    {/if}
    <h1>
    {if $action_link}
    <span class="action-span"><a href="{$action_link.href}">{$action_link.text}</a></span>
    {/if}
    {if $action_link2}
    <span class="action-span"><a href="{$action_link2.href}">{$action_link2.text}</a>&nbsp;&nbsp;</span>
    {/if}
    <span class="action-span1"><a href="index.php?act=main">{$lang.cp_home}</a> </span><span id="search_id" class="action-span1">{if $ur_here} - {$ur_here} {/if}</span>
    <div style="clear:both"></div>
    </h1>
    

    product_sn_list.htm模板里

    D:phpStudyWWWworkwdm runkwww.wdmcake.cnwwwadmin emplatesproduct_sn_list.htm

    {include file="pageheader_list.htm"} <!--  引入头模板 -->
    
    {if $filter.sn_type eq 1}
        <div class="form-div">
            <form action="javascript:searchproduct();" name="addForm"  id="addForm">
            <!-- 分类 -->
            选择城市
            <select name="city" id="city" onchange="get_city();">
                    <option value="-1">所在城市</option>
                    {html_options options=$goods_city}
            </select>
            <select name="sn_gid" id="sn_gid" onchange="get_products();" style="135px;">
            <option value="0">请选择商品</option>
            {foreach from=$goods_list item=goods}
            <option value="{$goods.goods_id}">{$goods.goods_sn}  {$goods.goods_name}</option>
            {/foreach}
            </select>
            <!-- 商品:<input type="text" name="sn_name" value="" size="12" /> -->
    
            <select name="sn_pid" id="sn_pid">
            <option value="0">请选择规格</option>
            {foreach from=$products item=product}
            <option value="{$product.product_id}">{$product.product_name}</option>
            {/foreach}
            </select>
    
            <select name="sn_pizi" id="sn_pizi">
            <option value="0">请选择坯子</option>
            {foreach from=$pizi_list item=pizi}
            <option value="{$pizi.title}">{$pizi.title}</option>
            {/foreach}
            </select>
            
            <!-- sn_type --><input type="hidden" name="sn_type" id="sn_type" value="1" size="15" />
            <!-- 半成品品号 --><input type="hidden" name="semi_sn" value="" size="5" />
            <!-- 半成品品名 --><input type="hidden" name="sn_name" value="" size="5" />
            成品品号<input type="text" name="sn_sn" value="" size="15" />
            <!-- 新货品 --><input type="hidden" name="sn_newsn" value="" size="5" />
            货品价格<input type="text" name="sn_price" value="" size="5" />
            <input type="button" value="添加成品" class="button" onclick="add_sn();" />
            <input type="submit" value="搜索" class="button"/>
            </form>
            <!-- 批量导入对应关系 -->
            <!--  <form action="product_sn.php?act=batchAddGoods_relate" method="post" enctype="multipart/form-data" name="excel" target="_blank">
                <input type="file" name="file" value="">
                <input type="submit" value="Excel导入批量导入对应关系" class="button" />
             </form> -->
             <!-- 批量导入对应关系 -->
        </div>
        <!-- 添加货品 -->
    {/if}
    {if $filter.sn_type eq 2}
        <div class="form-div">
            <form action="javascript:searchproduct();" name="addForm"  id="addForm">
            <!-- 分类 -->
            选择城市<select name="city" id="city" onchange="get_city();">
              <option value="-1">所在城市</option>
            {html_options options=$goods_city}
            </select>
            <select name="sn_gid" id="sn_gid" onchange="get_products();" style="135px;">
            <option value="0">请选择商品</option>
            {foreach from=$goods_list item=goods}
            <option value="{$goods.goods_id}">{$goods.goods_sn}  {$goods.goods_name}</option>
            {/foreach}
            </select>
    
            <select name="sn_pid" id="sn_pid">
            <option value="0">请选择规格</option>
            {foreach from=$products item=product}
            <option value="{$product.product_id}">{$product.product_name}</option>
            {/foreach}
            </select>
    
            <select name="sn_pizi" id="sn_pizi">
            <option value="0">请选择坯子</option>
            {foreach from=$pizi_list item=pizi}
            <option value="{$pizi.title}">{$pizi.title}</option>
            {/foreach}
            </select>
            <!-- sn_type --><input type="hidden" name="sn_type" id="sn_type" value="2" size="15" />     
            <!-- 半成品品号 --><input type="hidden" name="semi_sn" id="semi_sn" value="" size="15" />
            半成品品名<input type="text" name="sn_name" id="sn_name" value="" size="15" />
            半成品品号<input type="text" name="sn_sn" id="sn_sn" value="" size="15" />
            <!-- 新货品 --><input type="hidden" name="sn_newsn" value="" size="5" />
            <!-- 货品价格 --><input type="hidden" name="sn_price" value="" size="5" />
            <input type="button" value="添加半成品" class="button" id="add_semi_sn" />
            <input type="submit" value="搜索" class="button"/>    
            </form>
             <form action="product_sn.php?act=batchAddGoodsSemi_sn" method="post" enctype="multipart/form-data" name="excel" target="_blank">
                <input type="file" name="file" value="">
                <input type="submit" value="Excel导入批量新建半成品" class="button" />
                 <span>
                    <a href="http://www.wdmcake.cn/data/demo_batchAddGoodsSemi_sn.xlsx" alt="" target="">导入模板下载</a>
                </span>
             </form>
            
        </div>
        <!-- 添加货品 -->
    {/if}
    
    {/if}
      <div class="list-div" style="margin-bottom: 5px; margin-top: 10px;" id="listDiv">
          <form method="post" action="goods.php" name="listForm" id="listForm" >
    
        {if $filter.sn_type eq 1}
          <table width="100%" cellpadding="3" cellspacing="1" id="table_list">
            <tr>
             <td class="label_2"  style=" 5%">ID</td> 
             <td class="label_2" style=" 20%">产品名</td>
             <td class="label_2" style=" 10%">规格</td>
             <td class="label_2" style=" 10%">坯子</td>
              <td class="label_2" style=" 8%">品号</td>
              <td class="label_2" style=" 150px;" id="newgoodsn">关联半成品</td>
              <td class="label_2" style=" 5%">品号价格</td>
              <td class="label_2" style=" 5%">{$lang.handler}</td>
            </tr>
    
            {foreach from=$product_list item=sn}
            <tr>
               <td class="td_1">{$sn.id}</td>
               <td class="td_1">{$sn.goods_name} {$sn.goods_sn}</td>
               <td class="td_1">{$sn.product_name} </td>
              <td class="td_1">{$sn.pizi}</td>      
              <td class="td_1"><span onclick="listTable.edit(this, 'edit_sn', {$sn.id})">{$sn.sn}</span></td>
          <!--     <td class="td_1"><span onclick="listTable.edit(this, 'edit_newsn', {$sn.id})">{$sn.newsn|default:点击修改}</span></td> -->
             
    
              <td class="td_1 add_semi_sn">  
              <div class="select2div"></div>
                <select  class="js-example-basic-multiple add_semi_sn_relate" name="sn_type[]" sn_id="{$sn.id}" multiple="multiple"> 
                  {foreach from=$semi_sninfo item=v}
                    <option value="{$v.sn}" {if in_array($v.sn,$sn['semi_sn_arr'])}selected="selected"{/if} >{$v.sn_name}</option> 
                  {/foreach}            
                   <!--  <option value="111" >111</option> 
                    <option value="222" >2222</option> 
                    <option value="333" >333</option>  -->
                       
                </select>       
              </td>
    
    
    
    
              <td class="td_1"><span onclick="listTable.edit(this, 'edit_sn_price', {$sn.id})">{$sn.sn_price}</span></td>
              <td align="center">
              <span>
              
             <a href="javascript:;" onclick="listTable.remove({$sn.id}, '删除品号?', 'remove')" title="{$lang.remove}"><img src="images/icon_drop.gif" border="0" height="16" width="16"></a>
             </span>
             </td>
            </tr>
            {/foreach}
            <tr>&nbsp;
            <td align="right" nowrap="true" colspan="8">{include file="page.htm"}</td>
          </tr>    
          </table>
        {/if}
        {if $filter.sn_type eq 2}
          <table width="100%" cellpadding="3" cellspacing="1" id="table_list">
            <tr>
             <td class="label_2">ID</td>      
             <td class="label_2">半成品品名</td>  
             <td class="label_2">半成品品号sn</td>
             <td class="label_2">商品号goods_sn</td> 
             <td class="label_2">{$lang.handler}</td>
            </tr>
    
            {foreach from=$product_list item=sn}
            <tr>
               <td class="td_1">{$sn.id}</td>       
               <td class="td_1">{$sn.goods_name}</td>               
              <td class="td_1"><span onclick="listTable.edit(this, 'edit_sn', {$sn.id})">{$sn.sn}</span></td>
              <td class="td_1">{$sn.goods_sn}</td>
          <!--     <td class="td_1"><span onclick="listTable.edit(this, 'edit_newsn', {$sn.id})">{$sn.newsn|default:点击修改}</span></td> -->
          
             <!--  <td class="td_1"><span onclick="listTable.edit(this, 'edit_sn_price', {$sn.id})">{$sn.sn_price}</span></td> -->
              <td align="center">
              <span>
              
             <a href="javascript:;" onclick="listTable.remove({$sn.id}, '删除品号?', 'remove')" title="{$lang.remove}"><img src="images/icon_drop.gif" border="0" height="16" width="16"></a>
             </span>
             </td>
            </tr>
            {/foreach}
            <tr>&nbsp;
            <td align="right" nowrap="true" colspan="8">{include file="page.htm"}</td>
          </tr>    
          </table>
        {/if} 
    
       
        </form>
      {if $full_page}
        {include file="pagefooter.htm"}
      {/if}
    </div>
    <!-- end 添加货品 -->
    
    
    

    控制器里

    D:phpStudyWWWworkwdm runkwww.wdmcake.cnwwwadminproduct_sn.php

    /* 取商品的货品 */
    $product = product_sn_list();
    
    $smarty->assign('ur_here',      $product['filter']['sn_type']==1?'成品品号列表':'半成品品号列表');
    $smarty->assign('action_link2',  array('href' => 'product_sn.php?act=list&sn_type=1', 'text' =>'成品品号列表'));
    $smarty->assign('action_link',  array('href' => 'product_sn.php?act=list&sn_type=2', 'text' => '半成品品号列表'));
    
    $smarty->assign('product_list', $product['list']);
    $smarty->assign('goods_id',     $goods_id);
    $smarty->assign('filter',       $product['filter']);
    $smarty->assign('full_page',    1);
    $smarty->assign('record_count', $product['record_count']);
    $smarty->assign('page_count', $product['page_count']);
    
    /**
     *  获取货号列表信息
     *
     * @access  public
     * @param
     *
     * @return void
     */
    function product_sn_list()
    {
        $result = get_filter();
        wdmlog('第'.__LINE__.'行','product_sn','product_sn_list');
        wdmlog($result,'product_sn','product_sn_list');
        if ($result === false)
        {
            /* 过滤信息 */
            $filter['gid'] = isset($_REQUEST['gid']) ? intval($_REQUEST['gid']) : 0;
    		$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'id' : trim($_REQUEST['sort_by']);
            $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
            $filter['pizi'] = isset($_REQUEST['pizi']) ? intval($_REQUEST['pizi']) : 0;
            $filter['sn'] = empty($_REQUEST['sn']) ? '' : trim($_REQUEST['sn']);
            $filter['newsn'] = empty($_REQUEST['newsn']) ? '' : trim($_REQUEST['newsn']);
            $filter['sn_price'] = empty($_REQUEST['sn_price']) ? '0' : trim($_REQUEST['sn_price']);
            $filter['sn_name'] = empty($_REQUEST['sn_name']) ? '' : trim($_REQUEST['sn_name']);
            $filter['goods_city'] = isset($_REQUEST['goods_city']) ? intval($_REQUEST['goods_city']) : -1;
    
            $filter['sn_type'] = isset($_REQUEST['sn_type']) ? intval($_REQUEST['sn_type']) : 1;
    
            $where = '';
            
            if ($filter['gid'])
            {
                $where .= " AND s.goods_id ='" . $filter['gid'] . "'";
            }
            if ($filter['pizi'])
            {
            	$where .= " AND s.pizi ='" . $filter['pizi'] . "'";
            }
            if ($filter['sn'])
            {
            	$where .= " AND s.sn ='" . $filter['sn'] . "'";
            }
            if ($filter['newsn'])
            {
            	$where .= " AND s.newsn ='" . $filter['newsn'] . "'";
            }
            if ($filter['sn_price'])
            {
            	$where .= " AND s.sn_price ='" . $filter['sn_price'] . "'";
            }
            if ($filter['sn_name'])
            {
            	$where .= " AND g.goods_name like '%" . $filter['sn_name'] . "%'";
            }   
    		if ($filter['goods_city'] != -1)
    		{
    			$where .= " AND g.goods_city ='" . $filter['goods_city'] . "'";
    		}
    		
    		if(isset($_SESSION['city_id']) && $_SESSION['city_id'] >0 )
    		{
    		   $where .= " AND g.goods_city='$_SESSION[city_id]'";	
    		}
    
            if ($filter['sn_type'])
            {
                $where .= " AND s.sn_type ='" . $filter['sn_type'] . "'";
            }
    		
            /* 分页大小 */
            $filter['page'] = empty($_REQUEST['page']) || (intval($_REQUEST['page']) <= 0) ? 1 : intval($_REQUEST['page']);
    
            if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0)
            {
                $filter['page_size'] = intval($_REQUEST['page_size']);
            }
            elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0)
            {
                $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']);
            }
            else
            {
                $filter['page_size'] = 15;
            }
    
            /* 记录总数 */
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('product_sn') . " AS s left join  " . $GLOBALS['ecs']->table('goods') . " as g on g.goods_id =s.goods_id left join  " . $GLOBALS['ecs']->table('products') . " as p on p.product_id =s.product_id where 1  $where ";
            $filter['record_count']   = $GLOBALS['db']->getOne($sql);
            $filter['page_count']     = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;
    
            /* 查询 */
            $sql = "SELECT s.*, g.goods_name, g.goods_sn, p.product_sn, p.product_name FROM " . $GLOBALS['ecs']->table('product_sn') . " AS s left join  " . $GLOBALS['ecs']->table('goods') . " as g on g.goods_id =s.goods_id left join  " . $GLOBALS['ecs']->table('products') . " as p on p.product_id =s.product_id where 1  $where ORDER BY $filter[sort_by] $filter[sort_order]  LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",$filter[page_size]";
    
            set_filter($filter, $sql);
        }
        else
        {
            $sql    = $result['sql'];
            $filter = $result['filter'];
        }
        $rows = $GLOBALS['db']->getAll($sql);
    
    
        foreach($rows as $k=>$v){
            $rows[$k]['semi_sn_arr'] = array();
            if(!empty($v['semi_sn'])){
                $rows[$k]['semi_sn_arr'] = explode(',',$v['semi_sn']);
            }
    
        }
        wdmlog('第'.__LINE__.'行','product_sn','rows');
        wdmlog($rows,'product_sn','rows');
    	
        $list = array('list' => $rows, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
        return $list;
    }
    
    
  • 相关阅读:
    java 内部类
    webservice restful rpc
    linux 修改文件权限chmod
    java ThreadLocal的理解
    转:Eclipse常用开发插件
    Eclipse安装插件支持jQuery智能提示
    转:VS2008 vs2010中JQUERY智能提醒
    jquery ui和jquery easy ui的区别
    线程池
    java连接数据库URL
  • 原文地址:https://www.cnblogs.com/haima/p/9700802.html
Copyright © 2011-2022 走看看