crm营销管理之营销机会管理更新

分析思路

1.更新与添加共同一个对话框

2.点击更新弹出来窗口,会反显后台的数据

3.添加与更新功能实现就在于添加会返回主键,更新不会返回主键

功能实现

1.service实现类直接加入判断(SaleChanceServiceImpl.java)

package com.shsxt.crm.sales.service.impl;

import com.shsxt.crm.base.constants.CrmConstants;
import com.shsxt.crm.base.util.AssertUtil;
import com.shsxt.crm.sales.dao.SaleChanceMapper;
import com.shsxt.crm.sales.pojo.SaleChance;
import com.shsxt.crm.sales.service.SaleChanceService;
import com.shsxt.crm.system.pojo.User;
import com.shsxt.crm.system.service.UserServiceI;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 营销机会管理service实现
 * Created by Administrator on 2019/8/29.
 */
@Service
public class SaleChanceServiceImpl extends SaleChanceService {

    @Autowired
    private SaleChanceMapper saleChanceMapper;

    @Autowired
    private UserServiceI userServiceI;
    /**
     * 添加或修改营销机会管理
     *
     * @param saleChance
     * @param userId
     */
    @Override
    public void saveOrUpdateSaleChance(SaleChance saleChance, Integer userId) {
        //校验参数
        AssertUtil.isTrue(StringUtils.isBlank(saleChance.getCustomerName()), "客户名称为空");
        AssertUtil.isTrue(StringUtils.isBlank(saleChance.getLinkMan()), "联系人不能为空");
        AssertUtil.isTrue(StringUtils.isBlank(saleChance.getLinkPhone()), "联系电话为空");

        //先判断是否有分配人
        String assignMan = saleChance.getAssignMan();
        if (StringUtils.isNotBlank(assignMan)){
            saleChance.setState(1);//1代表以分配
            saleChance.setAssignTime(new Date());//分配时间
        }else{
            saleChance.setState(0);//0代表未分配
        }
        //判断是否是添加还是修改(看是否有主键返回)
        Integer id= saleChance.getId();
        if(null==id){
            //添加
            User user=userServiceI.selectUserById(userId);
            AssertUtil.isNotLogin(null==user);
            saleChance.setCreateMan(user.getUserName());//创建人
            saleChance.setCreateDate(new Date());
            saleChance.setUpdateDate(new Date());
            //调用dao层添加功能+判断
            AssertUtil.isTrue(saleChanceMapper.save(saleChance)<1,
                    CrmConstants.OPS_FAILED_MESSAGE);
        }else{
            //调用dao层修改功能+判断
            saleChance.setUpdateDate(new Date());
            AssertUtil.isTrue(saleChanceMapper.update(saleChance<1,
                    CrmConstants.OPS_FAILED_MESSAGE);
        }
    }
}

2.找到主页更新按钮(sale_chance.ftl)

<html>
<head>
<#include "common.ftl" >
    <script type="text/javascript" src="${ctx}/js/sale.chance2.js"></script>
</head>
<body style="margin: 1px">
<table id="dg" class="easyui-datagrid"
       pagination="true" rownumbers="true"
       url="${ctx}/saleChance/selectSaleChanceByParams" fit="true" toolbar="#tb">
    <thead>
    <tr>
        <th field="cb" checkbox="true" align="center"></th>
        <th field="id" width="50" align="center">编号</th>
        <th field="chanceSource" width="200" align="center">机会来源</th>
        <th field="customerName" width="50" align="center">客户名称</th>
        <th field="cgjl" width="50" align="center">成功几率</th>
        <th field="overview" width="200" align="center">概要</th>
        <th field="linkMan" width="100" align="center">联系人</th>
        <th field="linkPhone" width="100" align="center">联系电话</th>
        <th field="description" width="200" align="center">机会描述</th>
        <th field="createMan" width="100" align="center">创建人</th>
        <th field="createDate" width="100" align="center">创建时间</th>
        <th field="trueName" width="200" align="center">指派人</th>
        <th field="assignTime" width="200" align="center">指派时间</th>
        <th field="state" width="100" align="center" formatter="formatterState">分配状态</th>
        <th field="devResult" width="200" align="center" formatter="formatterDevResult">客户开发状态</th>
    </tr>
    </thead>
</table>
<div id="tb">
    <a href="javascript:openAddSaleChacneDialog()" class="easyui-linkbutton" iconCls="icon-save" plain="true">添加</a>
    <a href="javascript:openModifySaleChanceDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">更新</a>
    <a href="javascript:deleteSaleChance()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
    <br/>
    客户名称:<input type="text" id="customerName"/>
    状态:
    <select class="easyui-combobox" name="state" id="state" panelHeight="auto">
        <option value="">全部</option>
        <option value="0">未分配</option>
        <option value="1">已分配</option>
    </select>
    开发结果:
    <select class="easyui-combobox" id="devResult" panelHeight="auto">
        <option value="">全部</option>
        <option value="0">未开发</option>
        <option value="1">开发中</option>
        <option value="2">开发成功</option>
        <option value="3">开发失败</option>
    </select>
    创建时间:<input id="time" type="text" class="easyui-datebox"></input>
    <a href="javascript:querySaleChancesByParams()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
</div>

<div id="dlg" class="easyui-dialog" title="添加营销记录" closed="true"
     style="width: 500px;height:300px" buttons="#bt">
    <form id="fm" method="post">
        <table style="font-size: 12px;">
            <tr>
                <td>机会来源:</td>
                <td><input type="text" id="chanceSource" name="chanceSource"/></td>
            </tr>
            <tr>
                <td>客户名称:</td>
                <td><input type="text" id="customerName02" class="easyui-validatebox" name="customerName" required="required"/></td>
            </tr>
            <tr>
                <td>成功几率:</td>
                <td><input type="text" id="cgjl" name="cgjl"/></td>
            </tr>
            <tr>
                <td>联系人:</td>
                <td><input type="text" name="linkMan" id="linkMan" class="easyui-validatebox" required="required"/></td>
            </tr>
            <tr>
                <td>联系电话:</td>
                <td><input type="text" name="linkPhone" id="linkPhone" class="easyui-validatebox" required="required"/></td>
            </tr>
            <tr>
                <td>描述信息:</td>
                <td><input type="text" id="description" name="description"/></td>
            </tr>
            <tr>
                <td>分配人:</td>
                <td>
                   <#--<input type="text" id="assignMan" name="assignMan"/>-->

                    <input class="easyui-combobox" id="assignMan" name="assignMan"
                           valueField="id" textField="trueName" editable="false"
                           url="${ctx}/user/selectCustomerLists" panelHeight="auto"/>

                </td>
            </tr>
        </table>
        <input name="id" id="id" type="hidden"/>
    </form>
</div>
<div id="bt">
    <a href="javascript:saveOrUpdateSaleChance()" class="easyui-linkbutton" plain="true" iconCls="icon-save">保存</a>
    <a href="javascript:closeDlg()" class="easyui-linkbutton" plain="true" iconCls="icon-cancel">取消</a>
</div>


</body>
</html>

在这里插入图片描述

3.sale_chance.js

//打开修改对话框
function openModifySaleChanceDialog() {
    //获取选中行数据
    var rows = $("#dg").datagrid("getSelections");
    // 业务判断
    if (rows.length > 1) {
        $.messager.alert("系统提示", "只可以选中一行", "warning");
        return;
    }
    if (rows.length < 1) {
        $.messager.alert("系统提示", "请选择一行记录", "warning");
        return;
    }
    $("#dlg").dialog("open");
    // 返显数据
    $("#fm").form("load", rows[0]);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值