BOS08——Web工程中的CXF客户端,加载select框中的内容,select框移动,提交时将select全部选中,CRM中更新的方法,别名的用于不用

1、Web工程中的CXF客户端

第一步:在BOS项目的pom.xml中引入CXF的依赖

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>3.0.1</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.0.1</version>
</dependency>

第二步:使用wsimport命令解析wsdl文件生成本地代码,只需要接口文件和实体类

第三步:在spring配置文件中注册crm客户端代理对象

<!-- 注册crm客户端代理对象 -->
<jaxws:client id="crmClient"
              serviceClass="cn.x5456.crmClient.ICustomerService"
              address="http://127.0.0.1:8889/crm/service/customer"/>

第四步:通过注解方式将代理对象注入给Action

@RunWith(SpringJUnit4ClassRunner.class)     // 创建容器
@ContextConfiguration("classpath:applicationContext.xml")    // 通过类加载形式,读取配置文件,创建对象
public class testAction {

    @Autowired
    private ICustomerService proxy;

    @Test
    public void func() throws Exception {

        List<Customer> customerList = proxy.findListNotAssociation();

        System.out.println(customerList);

    }
}

2、加载select框中的内容,select框移动,提交时将select全部选中,CRM中更新的方法

1)

 1 function doAssociations() {
 2 
 3     // 1.获取当前数据表格所有选中的行,返回数组
 4     var row = $("#grid").datagrid("getSelections");
 5     // 2.判断是否选中一行
 6     if (row.length != 1){
 7         // 弹出提示框
 8         $.messager.alert("提示信息","请选择一个定区操作!","warning")
 9     } else {
10         // 弹出修改框
11         $('#customerWindow').window('open');
12         // 3.清理下拉框中的内容
13         $("#noassociationSelect").empty();
14         $("#associationSelect").empty();
15         // 4.发送ajax请求加载下拉框中的内容
16         var url_1 = "decidedzoneAction_findListNotAssociation.action";
17         $.post(url_1,{},function (dat) {
18             for(var i=0;i<dat.length;i++){
19                 var id = dat[i].id;
20                 var name = dat[i].name;
21                 var telephone = dat[i].telephone;
22 
23                 name = name+"("+telephone+")";
24 
25                 $("#noassociationSelect").append("<option value='"+id+"'>"+name+"</option>");
26             }
27 
28         },"json");
29 
30         var url_2 = "decidedzoneAction_findListHasAssociation.action";
31         $.post(url_2,{"decidedzoneId":row[0].id},function (dat) {
32             for(var i=0;i<dat.length;i++){
33                 var id = dat[i].id;
34                 var name = dat[i].name;
35                 var telephone = dat[i].telephone;
36 
37                 name = name+"("+telephone+")";
38 
39                 $("#associationSelect").append("<option value='"+id+"'>"+name+"</option>");
40             }
41 
42         },"json")
43     }
44 }
加载select框中的数据
 1 // 接收定区id
 2 private String decidedzoneId;
 3 
 4 
 5 public void setDecidedzoneId(String decidedzoneId) {
 6     this.decidedzoneId = decidedzoneId;
 7 }
 8 
 9 /**
10  * 调用WebService获取当前定区的所有客户
11  * @return
12  * @throws Exception
13  */
14 public String findListHasAssociation() throws Exception {
15     
16     List<Customer> listNotAssociation = proxy.findListHasAssociation(decidedzoneId);
17 
18     super.writeJson(listNotAssociation,new String[]{});
19 
20     return "none";
21 }
Action调用WebService
 1 /**
 2  * 查询所有绑定指定定区的客户
 3  * @return
 4  */
 5 @Override
 6 public List<Customer> findListHasAssociation(String decidedzone_id) {
 7     String sql = "select * from t_customer where decidedzone_id = ?";
 8 
 9     List<Customer> customerList = super.getJdbcTemplate().query(sql, new RowMapper<Customer>() {
10         @Override
11         public Customer mapRow(ResultSet resultSet, int i) throws SQLException {
12             Customer customer = new Customer();
13 
14             customer.setId(resultSet.getInt("id"));
15             customer.setName(resultSet.getString("name"));
16             customer.setStation(resultSet.getString("station"));
17             customer.setTelephone(resultSet.getString("telephone"));
18             customer.setAddress(resultSet.getString("address"));
19             return customer;
20         }
21     },decidedzone_id);
22     return customerList;
23 }
CRM_获取绑定指定定区的客户

2)

 1 <script type="text/javascript">
 2     $(function () {
 3         $("#toRight").click(function () {
 4             // 将选中的option移动(append)到另一边
 5             $("#associationSelect").append($("#noassociationSelect option:selected"))
 6         });
 7 
 8         $("#toLeft").click(function () {
 9             // 将选中的option移动(append)到另一边
10             $("#noassociationSelect").append($("#associationSelect option:selected"))
11         });
12 
13         $("#associationBtn").click(function () {
14             var row = $("#grid").datagrid("getSelections");
15             var id = row[0].id;
16             // 为隐藏域赋(定区)值
17             $("input[name='decidedzoneId']").val(id);
18             // 在表单提交钱,将右侧下拉框全部选中;因为只会提交选中的
19             $("#associationSelect option").attr("selected","selected");
20             // 提交表单
21             $("#customerForm").submit()
22         })
23     })
24 </script>
option移动+提交按钮的事件
 1 /**
 2  * 更新用户绑定的定区
 3  * update t_customer set decidedzone_id = null where decidedzone_id = xxx;
 4  * update t_customer set decidedzone_id = decidedzone_id where customer_id = customer_id;
 5  */
 6 @Override
 7 public void updateAssociation(String decidedzoneId,List<Integer> customerIds) {
 8     String sql = "update t_customer set decidedzone_id = null where decidedzone_id = ?";
 9 
10     // 清除customer表中定区id == decidedzoneId
11     super.getJdbcTemplate().update(sql,decidedzoneId);
12 
13     sql = "update t_customer set decidedzone_id = ? where id = ?";
14 
15     // 重新为传来的用户们修改定区/home/x5456/cn/x5456/service/ICustomerService.java
16     for (Integer customer_id : customerIds) {
17         super.getJdbcTemplate().update(sql,decidedzoneId,customer_id);
18     }
19 
20 }
CRM_修改客户

3、别名的用于不用

原文地址:https://www.cnblogs.com/x54256/p/8595541.html