CRM客户关系管理系统<5>营销管理页面显示

版权声明:有一种生活不去经历不知其中艰辛,有一种艰辛不去体会,不会知道其中快乐,有一种快乐,没有拥有不知其中纯粹 https://blog.csdn.net/wwwzydcom/article/details/83241900

营销机会管理页面跳转

  <a href="javascript:openTab('营销机会管理','saleChance/index/1','icon-yxjhgl')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-yxjhgl'" style="width: 150px">营销机会管理</a>

点击发送请求saleChance/index/1到后台
这里的1采用了restful风格
Controller层

  @RequestMapping("index/{state}")
    public String index(@PathVariable Integer state){
        if (state == 1){
            return "sale_chance";
        }else if (state == 2){
            return "cus_dev_plan";
        }
        return "error";
    }

重点:index/{state},在形参上加上了注解:@PathVariable integer state
通过判断state的值,转入不同的页面 ,这里转入的是营销机会管理

页面的数据显示

打开页面触发

	 url="${ctx}/saleChance/querySaleChancesByParams"

发送请求,进入Controller层

  	@RequestMapping("querySaleChancesByParams")
    @ResponseBody
    public Map<String,Object>querySaleChancesByParams(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer rows, SaleChanceQuery query){
        query.setPageNum(page);
        query.setPageSize(rows);
        return saleChanceService.queryForPage(query);
    }

通过map的方式,按照键值对的形式进行存取,
注解@RequestParam(defaultValue = ) 设置参数的默认值

根据前台需要的参数类型,创建一个SaleChanceQuery
其中由于很多页面都需要有 pageNum 和pageSize 进行封装了BaseQuery

BaseQuery

	 private Integer pageNum=1;
    private Integer pageSize=10;

SaleChanceQuery

    private String customerName;  //客户名
    private Integer state;		//开发状态
    private Integer devResult;	//开发结果
    private String createDate;	//创建时间

其中将时间改为String类型,由于前台的参数传递的是String类型,使用Date会发生类型转换错误

封装BaseService分页操作

  public Map<String,Object> queryForPage(BaseQuery baseQuery) throws  DataAccessException{
        PageHelper.startPage(baseQuery.getPageNum(),baseQuery.getPageSize());
        List<T> entities=baseDao.queryByParams(baseQuery);
        PageInfo<T> pageInfo=new PageInfo<T>(entities);
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("total",pageInfo.getTotal());
        map.put("rows",pageInfo.getList());
        return map;
    }
  1. 使用了SpringMVC分页的PageHelper,传递num和size参数,

  2. 通过BaseDao查询接口的BaseDao

     public  List<T> queryByParams(BaseQuery baseQuery) throws  DataAccessException;
    

    同时BaseService,多条件查询

       public PageInfo<T> queryByParams(BaseQuery baseQuery) throws  DataAccessException{
             PageHelper.startPage(baseQuery.getPageNum(),baseQuery.getPageSize());
             List<T> entities=baseDao.queryByParams(baseQuery);
             return new PageInfo<T>(entities);
         }
    
  3. 数据查询
    SaleChanceMapper.xml

     	 <select id="queryByParams" parameterType="saleChanceQuery" resultMap="BaseResultMap">
     	    SELECT <include refid="Base_Column_List" />
     	    FROM t_sale_chance
     	    <where>
     	      is_valid=1
     	    <if test="null != customerName and ''!=customerName">
     	      AND customer_name LIKE concat('%',#{customerName},'%')
     	    </if>
     	    <if test="null != state">
     	        AND state=#{state}
     	    </if>
     	      <if test="null != devResult ">
     	        and dev_result=#{devResult}
     	      </if>
     	    <if test="null != createDate and ''!=createDate">
     	      AND create_date &lt;=#{createDate}
     	    </if>
     	    </where>
     	  </select>
    

	<include refid="Base_Column_List" /> 类似于jsp中的include,指向其id即可
	
	 <sql id="Base_Column_List" >
	    id, chance_source, customer_name, cgjl, overview, link_man, link_phone, description, 
	    create_man, assign_man, assign_time, state, dev_result, is_valid, create_date, update_date
	  </sql>
	查询到结果

同时搜索也做好了,js文件

		function querySaleChancesByParams() {
		    $('#dg').datagrid('load',{
		        customerName:$('#customerName').val(),
		        state:$('#state').combobox('getValue'),
		        devResult:$('#devResult').combobox('getValue'),
		        createDate:$('#time').datebox('getValue')
		    });
		}

猜你喜欢

转载自blog.csdn.net/wwwzydcom/article/details/83241900