首页 > 其他分享 >easyUI定区关联快递员js代码

easyUI定区关联快递员js代码

时间:2024-09-06 12:57:43浏览次数:8  
标签:function easyUI title align js width 定区 true

easyUI定区关联快递员js代码:

<script type="text/javascript">
            $.fn.serializeJson=function(){  
                var serializeObj={};  
                var array=this.serializeArray();  
                var str=this.serialize();  
                $(array).each(function(){  
                    if(serializeObj[this.name]){  
                        if($.isArray(serializeObj[this.name])){  
                            serializeObj[this.name].push(this.value);  
                        }else{  
                            serializeObj[this.name]=[serializeObj[this.name],this.value];
                        }  
                    }else{  
                        serializeObj[this.name]=this.value;   
                    }  
                });  
                return serializeObj;  
            }; 
            
            function doAdd(){
                $('#addWindow').window("open");
            }
            
            function doEdit(){
                alert("修改...");
            }
            
            function doDelete(){
                alert("删除...");
            }
            
            function doSearch(){
                $('#searchWindow').window("open");
            }
            
            // 关联客户窗口弹出
            function doAssociationCustomers(){
                // 判定用户是否只选择了一个定区 
                var rows = $("#grid").datagrid('getSelections');
                // 只选择了一行 
                if(rows.length == 1){
                    // 将选中定区id,设置到form的隐藏域 
                    $("#customerFixedAreaId").val(rows[0].id);
                    
                    // 显示进度条
                    $.messager.progress({
                        interval :500 // 每0.5秒加载10%, 5秒加载完
                    });
                    
                    // 发起Ajax请求 
                    $.post("../../fixedArea_findNoAssociationCustomers.action", function(data){
                        // 查询所有 未关联定区客户列表
                        $(data).each(function(){
                            // 清空列表
                            $("#noassociationSelect").empty();
                            var option = $("<option value='"+this.id+"'>"+this.username+"("+this.address+")</option>");
                            $("#noassociationSelect").append(option);
                        });
                        
                        // 请求结束后,关闭进度条
                        $.messager.progress('close');
                        // 弹出关联窗口 
                        $('#customerWindow').window('open');
                    });
                    $.post("../../fixedArea_findHasAssociationFixedAreaCustomers.action",{"id":rows[0].id} , function(data){
                        // 查询所有 关联当前选中定区客户列表
                        $(data).each(function(){
                            // 清空列表
                            $("#associationSelect").empty();
                            var option = $("<option value='"+this.id+"'>"+this.username+"("+this.address+")</option>");
                            $("#associationSelect").append(option);
                        });
                    });
                    
                }else{
                    // 没有选 或者 选了多个定区 
                    $.messager.alert('警告','定区关联客户必须(只能)选择一个定区','warning');
                }
            }
            
            //工具栏
            var toolbar = [ {
                id : 'button-search',    
                text : '查询',
                iconCls : 'icon-search',
                handler : doSearch
            }, {
                id : 'button-add',
                text : '增加',
                iconCls : 'icon-add',
                handler : doAdd
            }, {
                id : 'button-edit',    
                text : '修改',
                iconCls : 'icon-edit',
                handler : doEdit
            },{
                id : 'button-delete',
                text : '删除',
                iconCls : 'icon-cancel',
                handler : doDelete
            },{
                id : 'button-association-customer',
                text : '关联客户',
                iconCls : 'icon-sum',
                handler : doAssociationCustomers
            },{
                id : 'button-association-courier',
                text : '关联快递员',
                iconCls : 'icon-sum',
                handler : function(){
                    // 判断是否已经选中了一个定区,弹出关联快递员窗口 
                    var rows = $("#grid").datagrid('getSelections');
                    if(rows.length==1){
                        // 只选择了一个定区
                        // 弹出定区关联快递员 窗口 
                        $("#courierWindow").window('open');
                        // 保存选中定区id 到表单隐藏域
                        $("#courierFixedAreaId").val(rows[0].id);
                    }else{
                        // 没有选中定区,或者选择 了多个定区
                        $.messager.alert("警告","关联快递员,只能(必须)选择一个定区","warning");
                    }
                }
            }];
            // 定义列
            var columns = [ [ {
                field : 'id',
                title : '编号',
                width : 80,
                align : 'center',
                checkbox:true
            },{
                field : 'fixedAreaNum',
                title : '定区编号',
                width : 120,
                align : 'center',
                formatter : function(value,row,index){
                    return row.id ;
                }
            },{
                field : 'fixedAreaName',
                title : '定区名称',
                width : 120,
                align : 'center'
            }, {
                field : 'fixedAreaLeader',
                title : '负责人',
                width : 120,
                align : 'center'
            }, {
                field : 'telephone',
                title : '联系电话',
                width : 120,
                align : 'center'
            }, {
                field : 'company',
                title : '所属公司',
                width : 120,
                align : 'center'
            } ] ];
            
            $(function(){
                // 先将body隐藏,再显示,不会出现页面刷新效果
                $("body").css({visibility:"visible"});
                
                // 定区数据表格
                $('#grid').datagrid( {
                    iconCls : 'icon-forward',
                    fit : true,
                    border : true,
                    rownumbers : true,
                    striped : true,
                    pageList: [30,50,100],
                    pagination : true,
                    toolbar : toolbar,
                    url : "../../fixedArea_pageQuery.action",
                    idField : 'id',
                    columns : columns,
                    onDblClickRow : doDblClickRow
                });
                
                // 添加、修改定区
                $('#addWindow').window({
                    title: '添加修改定区',
                    width: 600,
                    modal: true,
                    shadow: true,
                    closed: true,
                    height: 400,
                    resizable:false
                });
                
                // 查询定区
                $('#searchWindow').window({
                    title: '查询定区',
                    width: 400,
                    modal: true,
                    shadow: true,
                    closed: true,
                    height: 400,
                    resizable:false
                });
                
                // 点击查询按钮,将form数据转换为json 绑定datagrid 
                $("#btn").click(function(){
                    // 转换form对象 到 json
                    var params = $("#searchForm").serializeJson();
                    // 绑定datagrid 
                    $("#grid").datagrid('load',params);
                    // 关闭查询窗口 
                    $("#searchWindow").window('close');
                });
                
                // 点击 添加定区的保存按钮,实现添加定区
                $("#save").click(function(){
                    // 先校验表单 
                    if($("#fixedAreaForm").form('validate')){
                        $("#fixedAreaForm").submit();
                    }else{
                        // 提示用户
                        $.messager.alert("警告","表单存在非法数据项!","warning");
                    }
                });
                
                // 向右移动按钮 
                $("#toRight").click(function(){
                    $("#associationSelect").append($("#noassociationSelect option:selected"));
                });
                
                // 向左移动按钮
                $("#toLeft").click(function(){
                    $("#noassociationSelect").append($("#associationSelect option:selected"));
                });
                
                // 为关联客户按钮,添加click事件
                $("#associationBtn").click(function(){
                    // 选中所有 已关联定区客户select中选项 
                    $("#associationSelect option").attr("selected","selected");
                    // 提交表单
                    $("#customerForm").submit();
                });
                
                // 为关联快递员按钮,添加click事件
                $("#associationCourierBtn").click(function(){
                    // 判断表单是否通过校验
                    if($("#courierForm").form('validate')){
                        $("#courierForm").submit();
                    }else{
                        $.messager.alert("警告","表单中存在非法数据","warning");
                    }
                });
            });
        
            function doDblClickRow(){
                alert("双击表格数据...");
                $('#association_subarea').datagrid( {
                    fit : true,
                    border : true,
                    rownumbers : true,
                    striped : true,
                    url : "../../data/sub_area.json",
                    columns : [ [{
                        field : 'id',
                        title : '分拣编号',
                        width : 120,
                        align : 'center'
                    },{
                        field : 'province',
                        title : '省',
                        width : 120,
                        align : 'center',
                        formatter : function(data,row ,index){
                            if(row.area!=null){
                                return row.area.province;
                            }
                            return "";
                        }
                    }, {
                        field : 'city',
                        title : '市',
                        width : 120,
                        align : 'center',
                        formatter : function(data,row ,index){
                            if(row.area!=null){
                                return row.area.city;
                            }
                            return "";
                        }
                    }, {
                        field : 'district',
                        title : '区',
                        width : 120,
                        align : 'center',
                        formatter : function(data,row ,index){
                            if(row.area!=null){
                                return row.area.district;
                            }
                            return "";
                        }
                    }, {
                        field : 'addresskey',
                        title : '关键字',
                        width : 120,
                        align : 'center'
                    }, {
                        field : 'startnum',
                        title : '起始号',
                        width : 100,
                        align : 'center'
                    }, {
                        field : 'endnum',
                        title : '终止号',
                        width : 100,
                        align : 'center'
                    } , {
                        field : 'single',
                        title : '单双号',
                        width : 100,
                        align : 'center'
                    } , {
                        field : 'assistKeyWords',
                        title : '辅助关键字',
                        width : 100,
                        align : 'center'
                    } ] ]
                });
                $('#association_customer').datagrid( {
                    fit : true,
                    border : true,
                    rownumbers : true,
                    striped : true,
                    url : "../../data/association_customer.json",
                    columns : [[{
                        field : 'id',
                        title : '客户编号',
                        width : 120,
                        align : 'center'
                    },{
                        field : 'name',
                        title : '客户名称',
                        width : 120,
                        align : 'center'
                    }, {
                        field : 'company',
                        title : '所属单位',
                        width : 120,
                        align : 'center'
                    }]]
                });
                $('#association_courier').datagrid({
                    fit : true,
                    border : true,
                    rownumbers : true,
                    striped : true,
                    url : "../../data/courier.json",
                    columns : [[{
                        field : 'id',
                        title : '编号',
                        width : 120,
                        align : 'center'
                    },{
                        field : 'courierNum',
                        title : '快递员工号',
                        width : 120,
                        align : 'center'
                    },{
                        field : 'name',
                        title : '快递员姓名',
                        width : 120,
                        align : 'center'
                    }, {
                        field : 'standard.name',
                        title : '收派标准',
                        width : 120,
                        align : 'center',
                        formatter : function(value,row,index){
                            if(row.standard != null){
                                return row.standard.name;
                            }
                            return null ; 
                        }
                    }, {
                        field : 'taketime.name',
                        title : '收派时间',
                        width : 120,
                        align : 'center',
                        formatter : function(value,row,index){
                            if(row.taketime != null){
                                return row.taketime.name;
                            }
                            return null ; 
                        }
                    }, {
                        field : 'company',
                        title : '所属单位',
                        width : 120,
                        align : 'center'
                    }]]
                });
            }
        </script>

 



标签:function,easyUI,title,align,js,width,定区,true
From: https://blog.51cto.com/zhangxueliang/11937106

相关文章

  • AngularJS进阶(十五)Cookie ‘data‘ possibly not set or overflowed because it was
    Cookie ‘data’ possibly not set or overflowedbecause it was too large (5287 > 4096 bytes)!注:请点击此处进行充电!故事起源项目开发过程中遇到以上问题,刚开始以为只是个警告,没太在意。后来发现直接影响到了程序的执行效果。果断寻找解决方法。问题......
  • AngularJS基于模块化的MVC实现
    AngularJS基于模块化的MVC实现1<!DOCTYPEhtml>2<html>3<head>4<metacharset="UTF-8">5<title>AngularJS基于模块化的MVC实现</title>6<scripttype="text/javascript"src=".......
  • JSP就业系统的设计与实现kd92s(程序+源码+数据库+调试部署+开发环境)
    本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表系统功能:用户,企业,招聘信息,投掷简历,课程信息,简历库,邀请信息,校园宣传会,报名信息,沟通信息开题报告内容一、选题背景与意义随着信息技术的快速发展和互联......
  • Node.js视频活体识别接口集成示例
    在数字时代的浪潮中,信息安全成为了一个不可忽视的议题。随着网络服务的日益普及,从银行金融到社交媒体,各种在线平台都需要确保其用户的身份真实可靠。在需求的推动下,视频活体识别技术应运而生,并迅速发展成为保护网络安全的重要手段。视频活体识别技术是一种通过分析用户的......
  • 基于ECharts+JS+Flask 交互可视化呈现NBA近期比赛信息及球队排名及数据 | 源码分享
    目录文章|内容结语|源代码文章|内容和大家分享一个我在闲暇之余写的一个小项目。为了能够更加直观的了解近期的NBA比赛信息、球队排名以及数据,本项目采用了ECharts、JS、Flask等技术进行可视化呈现。通过这种方式,我们可以更直观的了解NBA比赛,为球迷提供更好的观赛体验......
  • JavaScript 中 structuredClone 和 JSON.parse(JSON.stringify()) 克隆对象的区别
    JavaScript中structuredClone和JSON.parse(JSON.stringify())克隆对象的异同点一、什么是structuredClone?1.structuredClone的发展structuredClone是在ECMAScript2021(ES12)标准中引入的,ECMAScript2021规范正式发布于2021年6月自2022年3月起,该功能适用于最......
  • vue+ThreeJS:从0 到1 搭建开发环境
    文章目录一、下载安装(懒人版)二、顺序安装1,下载安装nodejs2,安装vue-cli3,创建vue-three项目。4,安装threeJS5,安装elementUI(选装)最终package.json文件如下:本系列教程是在vue2.X的基础上加载threeJS程序,来开发各种示例程序。一、下载安装(懒人版)下载vue-three系统包,n......
  • HTML/CSS/JS学习笔记 Day2(HTML)
    跟着该视频学习,记录笔记:【黑马程序员pink老师前端入门教程,零基础必看的h5(html5)+css3+移动端前端视频教程】https://www.bilibili.com/video/BV14J4114768?p=12&vd_source=04ee94ad3f2168d7d5252c857a2bf358Day2 内容梳理:目录HTML2.0网页开发的标签2.1基础标签的含义......
  • 吉林长春产权交易中心JS逆向:魔改AES请求加密与解密
    吉林长春产权交易中心JS逆向:魔改AES请求加密与解密......
  • SpringMVC-05-Json
    1、什么是JSON?JSON:JavaScriptObjectNotation(JS对象描述法)。JSON是一种存储和交换数据的语法。JSON是通过JS对象描述法书写的文本,用字面文本的形式来表示一个JS对象2、为什么要使用JSON?JSON是一种轻量级的数据交换格式,伴随着JavaScript语言的火爆,目前使用特别广泛。......