报价系统工作总结

关于报价系统的分页实现

1.分页实现的效果:


2,首先,在共享文件中定义了属性参数
    private int pageindex; //begin:0
    private int pagestart;
    private int pagesize;
     然后利用工具生成查询文件.xml
 <select id="selectClientordersList" parameterType="Clientorders" resultType="Clientorders">
        <![CDATA[select * from clientorders]]>
        <where>
            fast = 0
            <if test="clientorderid != null">and clientorderid = #{clientorderid}</if>
            <if test="clientid != null">and clientid = #{clientid}</if>
            <if test="ordercode != null">and ordercode = #{ordercode}</if>
            <if test="clientname != null">and clientname = #{clientname}</if>
            <if test="clientcontacts != null">and clientcontacts = #{clientcontacts}</if>
            <if test="seller != null">and seller = #{seller}</if>
            <if test="projectname != null">and projectname = #{projectname}</if>
            <if test="accuracytype != null">and accuracytype = #{accuracytype}</if>
            <if test="assembly != null">and assembly = #{assembly}</if>
            <if test="paint != null">and paint = #{paint}</if>
            <if test="polish != null">and polish = #{polish}</if>
            <if test="packaged != null">and packaged = #{packaged}</if>
            <if test="price != null">and price = #{price}</if>
            <if test="invoicetitle != null">and invoicetitle = #{invoicetitle}</if>
            <if test="address != null">and address = #{address}</if>
            <if test="invoice != null">and invoice = #{invoice}</if>
            <if test="createtime != null">and createtime = #{createtime}</if>
            <if test="begintime != null">and begintime = #{begintime}</if>
            <if test="finshtime != null">and finshtime = #{finshtime}</if>
            <if test="orderstatus != null">and orderstatus = #{orderstatus}</if>
            <if test="material != null">and material = #{material}</if>
            <if test="counts != null">and counts = #{counts}</if>
            <if test="request != null">and request = #{request}</if>
            <if test="ordermem != null">and ordermem = #{ordermem}</if>
        </where>
        <if test="pagesize > 0">
            limit ${pagestart} ,${pagesize}
        </if>
    </select>
注意:
	<if test="pagesize > 0">
            limit ${pagestart} ,${pagesize}
        </if>
是做分页的重要查询语句。

3,在查询方法getClientordersByWorkerid中编辑为:
 @Override
    public List<ClientordersBean> getClientordersByWorkerid(ClientordersBean workerid) {
        ClientordersBean param = new ClientordersBean();
        param.setWorkerid(workerid.getWorkerid());
        param.setSearchkey(workerid.getSearchkey());
	//分页判断
        if (workerid.getPagesize()>0){
            param.setPagesize(workerid.getPagesize());
            param.setPageindex(workerid.getPageindex());
        }
        List<ClientordersBean> list;
        try{
            list = clientordersDao.selectClientordersListByWorkid(param);
        }catch (Exception e){
            e.printStackTrace();
            list = new ArrayList<>();
        }
        return list;
    }

4,然后在controller中对分页进行参数定义:
@RequestMapping(value = "/listOrders.act")
    public String listOrders(
	 //定义参数P为分页页面
	 @RequestParam(value = "p",required = false,defaultValue = "0") int pageindex,
	@RequestParam(value = "s",required = false,defaultValue = "") String searchkey,
	@RequestParam(value = "i",required = false,defaultValue ="-1") int orderstatus){
        getRequest().setAttribute("searchkey",searchkey);
        if(getSessionUserinfo().getType() == 1){
            ClientordersBean  pageparam=new ClientordersBean();
            pageparam.setClientorderid(getSessionUserinfo().getWid());
	    //设置每一页为25条数据
            pageparam.setPagesize(25);
            pageparam.setPageindex(pageindex);
            if(orderstatus>-1) {
                pageparam.setOrderstatus(orderstatus);
            }
            if(!searchkey.equals("")){
                pageparam.setSearchkey(searchkey);
            }
            getRequest().setAttribute("list",ordersManager.getClientordersByWorkerid(pageparam));
        }else if(getSessionUserinfo().getType() == 2){
            ClientordersBean  pageparam=new ClientordersBean();
            pageparam.setPagesize(25);
            pageparam.setPageindex(pageindex);
            if(orderstatus>-1) {
                pageparam.setOrderstatus(orderstatus);
            }
            if(!searchkey.equals("")){
                pageparam.setSearchkey(searchkey);
            }
            getRequest().setAttribute("list",ordersManager.getAllClientorders(pageparam));
        }else{
            List<ClientordersBean> list = new ArrayList<>();
            getRequest().setAttribute("list",list);
        }
        getRequest().setAttribute("orderStatus",orderstatus);
        return "crm/orders/orderlist";
    }
5,在jsp页面中先写一个获取分页数据的<script>,获取来自listOrders()方法中定义的参数P,并进行参数计算。
<script>
<c:choose>
                    <c:when test="${paramValues['p'][0] == null}">var p = 0;</c:when>
                    <c:otherwise>var p = ${paramValues['p'][0]};</c:otherwise>
            </c:choose>
            <c:choose>
                    <c:when test="${paramValues['s'][0] != null}">var s = "&s=${paramValues['s'][0]}";</c:when>
                    <c:otherwise>var s = '';</c:otherwise>
            </c:choose>
            <c:choose>
                    <c:when test="${paramValues['i'][0] == null}">var i = 0;</c:when>
                    <c:otherwise>var i = ${paramValues['i'][0]};</c:otherwise>
            </c:choose>
            function last() {
                if(p>0){
                    i = $("#orderStatus").val();
                    self.location.href = "/crm/listOrders.act?p="+(p-1)+s;
                }
            }
            function next() {
                i = $("#orderStatus").val();
                self.location.href = "/crm/listOrders.act?p="+(p+1)+s;
            }
</script>
6,在jsp中定义一个两个Button:
		<div class="div-line">
                    <button type="button" <c:if test="${paramValues['p'][0] == null || paramValues['p'][0] > 0}">οnclick="last()"</c:if>>上一页</button>
                    <button type="button" <c:if test="${fn:length(list) == 25}">οnclick="next()"</c:if>>下一页</button>
                </div>

这样就实现了分页的查询,这里的方法比较难看懂,主要是在前期数据库处理那里用到了工具方法,生成的
<if test="pagesize > 0">
            limit ${pagestart} ,${pagesize}
        </if>
语句,这里主要是用于自己的工作总结,和公司的代码匹配,如果看不懂也是正常情况。这样就可以实现简单代码的分页效果啦:



数据库里面的订单按状态查询:

实现效果:

    private Integer orderstatus; // 0:用户询价无下文 1:报价后客户不接受 2:无法满足客户需求无法 3:下单成功



步骤:
1,在controller的方法中定义获取状态的参数: @RequestParam(value = "i",required = false,defaultValue ="-1") int orderstatus
@RequestMapping(value = "/listOrders.act")
    public String listOrders(
	@RequestParam(value = "p",required = false,defaultValue = "0") int pageindex,
	@RequestParam(value = "s",required = false,defaultValue = "") String searchkey,
	@RequestParam(value = "i",required = false,defaultValue ="-1") int orderstatus){
        getRequest().setAttribute("searchkey",searchkey);
        if(getSessionUserinfo().getType() == 1){
            ClientordersBean  pageparam=new ClientordersBean();
            pageparam.setClientorderid(getSessionUserinfo().getWid());
            pageparam.setPagesize(25);
            pageparam.setPageindex(pageindex);
            if(orderstatus>-1) {
                pageparam.setOrderstatus(orderstatus);
            }
            if(!searchkey.equals("")){
                pageparam.setSearchkey(searchkey);
            }
            getRequest().setAttribute("list",ordersManager.getClientordersByWorkerid(pageparam));
        }else if(getSessionUserinfo().getType() == 2){
            ClientordersBean  pageparam=new ClientordersBean();
            pageparam.setPagesize(25);
            pageparam.setPageindex(pageindex);
	    //-1为查询全部的订单信息
            if(orderstatus>-1) {
                pageparam.setOrderstatus(orderstatus);
            }
            if(!searchkey.equals("")){
                pageparam.setSearchkey(searchkey);
            }
            getRequest().setAttribute("list",ordersManager.getAllClientorders(pageparam));
        }else{
            List<ClientordersBean> list = new ArrayList<>();
            getRequest().setAttribute("list",list);
        }
	//设置键值对,记住分页查询的状态
        getRequest().setAttribute("orderStatus",orderstatus);
        return "crm/orders/orderlist";
    }

2,在jsp页面中写<jscrip>获取参数状态和实现按状态查询的分页,以及设置<select>选择后的跳转路径:
<script>
            <c:choose>
                    <c:when test="${paramValues['p'][0] == null}">var p = 0;</c:when>
                    <c:otherwise>var p = ${paramValues['p'][0]};</c:otherwise>
            </c:choose>
            <c:choose>
                    <c:when test="${paramValues['s'][0] != null}">var s = "&s=${paramValues['s'][0]}";</c:when>
                    <c:otherwise>var s = '';</c:otherwise>
            </c:choose>
            <c:choose>
                    <c:when test="${paramValues['i'][0] == null}">var i = 0;</c:when>
                    <c:otherwise>var i = ${paramValues['i'][0]};</c:otherwise>
            </c:choose>
            function last() {
                if(p>0){
                    i = $("#orderStatus").val();
                    self.location.href = "/crm/listOrders.act?p="+(p-1)+s+"&i="+i;
                }
            }
            function next() {
                i = $("#orderStatus").val();
                self.location.href = "/crm/listOrders.act?p="+(p+1)+s+"&i="+i;
            }
            function Orderstatuschaxun(sobj) {
                var status =sobj.options[sobj.selectedIndex].value;
                if (status != "") {
                    self.location.href = "/crm/listOrders.act?p=0"+s+"&i="+status;
                    sobj.selectedIndex=0;
                    sobj.blur();
                }
            }
        </script>
3,在jsp增加一个下拉列表,并传值给can参数i,i根据传入的参数做状态查询:  pageparam.setOrderstatus(orderstatus);
<select οnchange=Orderstatuschaxun(this) name="select" id="orderStatus" >
                        <option value=""   >请选择订单状态查询</option>
                        <option value="-1" <c:if test="${orderStatus == -1}">selected</c:if>>全部</option>
                        <option value="0"  <c:if test="${orderStatus == 0}">selected</c:if>>客户询价</option>
                        <option value="1"  <c:if test="${orderStatus == 1}">selected</c:if>>交涉中</option>
                        <option value="2"  <c:if test="${orderStatus == 2}">selected</c:if>>询价无下文</option>
                        <option value="3"  <c:if test="${orderStatus == 3}">selected</c:if>>报价后客户不接受</option>
                        <option value="4"  <c:if test="${orderStatus == 4}">selected</c:if>>无法满足客户需求</option>
                        <option value="5"  <c:if test="${orderStatus == 5}">selected</c:if>>打印中</option>
                        <option value="6"  <c:if test="${orderStatus == 6}">selected</c:if>>打印失败重打</option>
                        <option value="7"  <c:if test="${orderStatus == 7}">selected</c:if>>后期处理</option>
                        <option value="8"  <c:if test="${orderStatus == 8}">selected</c:if>>发货中</option>
                        <option value="9"  <c:if test="${orderStatus == 9}">selected</c:if>>交易完成</option>
                    </select>

这样就实现了按状态进行查询的效果:

关键点在于要在controller中得到状态信息,再根据jsp中传入的参数进行状态分配,然后实现不同的状态查询。












IT报价系统v1.3正式版 【安装说明】 安装链接:install.php、管理后台链接:admina.php 安装过程需要生成8000左右节点,中间有稍许停顿,请耐心等待。 强烈建议不要使用创始人帐号进行内容管理,请使用以下管理组的帐号进行常规管理: 系统管理组:内置帐号与密码有admin08cms,用于进行系统设置与模板管理等。 常规管理组:内置帐号与密码有08cms,用于日常的内容管理。 强烈建议不用创始人帐号进行日常管理,而使用管理帐号08cms或相应权限的帐号。 【普通版功能】 # 启用v3.5新内核,更高效,更安全。在节点生成环节,效率提高10倍以上,在前台页面生成上,有不等的效率的提升。 # 新增经销商频道节点,支持自定义节点,可以多角度索引商家,促销信息,及商家排行。 # 全站页面url自定义部署,首页允许分页,域名绑定将更加灵活多变。 # 新增WAP功能 # 会员推广与论证 # 新增类目字段,设置商家、广告,不同子站栏目之间内容的关联。 # 增加类目的选择方式,增加类目分级联动选择(普通加载、ajax加载可选)。 # 精简系统程序文件,让系统变得更简洁。 # 改进产品报价的操作流程。 # 重新规划前台后台菜单,有更好的用户体验。 # 新增栏目、品牌、价格,可以继续设置三者之间的关联性,并自动生成节点。 # 在原有的资讯频道(手机、数码相机、摄像机、MP3/MP4、GPS、笔记本、DIY硬件、台式机)的基础上。新增新闻、导购、评测、行情等资讯类前台展示页面。 # 增加会员自行发布促销功能,并在会员频道中加入促销模块。 # 改进会员注册流程,商家会员注册成功后直接成为普通经销商。 # 增加促销信息的置顶,推到首页,商家置顶及推到首页,报价置顶等营销方式。 # 在资讯类信息与产品之间,进行有效关联,并在前台的资讯与产品页面体现。 # 产品库前台增加一个品牌与价格通道页面,进入产品检索。 # 广告与栏目更好地关联,并全面使用混合广告位(一个广告位同时支持图片、FLASH、或代码)。 # 更加灵活的文档内容页面,url完全自定义,增加文档附加页页数(共支持4个文档页面),所有页面允许分页与生成静态。 # 更加灵活的类目节点页面,url完全自定义,支持3个节点页面,所有节点页允许分页与生成静态。 # 在模板标识(单个文档、单个会员)中,增加浏览权限功能,不同权限的会员浏览时将更到不同的效果。 # 标识js调用将不再限制用封装标识。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值