| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>联系方式</title>
- <script src="../../js/min-loader-next.js"></script>
- </head>
-
- <body class="body-content">
- <div class="order-body">
- <div class="order-tiaojian back-gray">
- <div class="tiaojian-part1" id="conditions">
- <div class="fl f12-gray4-op mt4">所选条件:</div>
- </div>
- <div class="tiaojian-part2 fr demoTable">
- <button class="order-bnt1" onclick="loadAA();">查询</button>
- <button class="order-bnt2" onclick="cancle();">重置</button>
- <a href="#" id="toggle" class="top">收起<i class="iconfont up iconSelect_drop-down"></i></a>
- </div>
- </div>
- <form class="layui-form" id = "formName" >
- <div class="order-select back-border" id="content" style="display: block;">
- <div class="layui-inline">
- <label class="f12-gray4">姓名:</label>
- <input type="tel" name="accName" id ="accName" autocomplete="off" placeholder="请输入姓名" class="search-select">
- </div>
- </div>
- </form>
- </div>
- <div class="shadow-content" >
- <div class="gray-title demoTable" >
- <button class="layui-btn left-bnt1 in-b" data-type="addContact" id="addContact">
- <i class="layui-icon"></i>添加
- </button>
- </div>
- <table id="tabletest" lay-filter="tableFilter"></table>
- </div>
- <!--操作功能-->
- <script type="text/html" id="barDemo1">
- <a class="f12-blue ml0-4" lay-event="edit">编辑</a>
- <a class="f12-red2 ml0-4" lay-event="delete">删除</a>
- </script>
-
- <script>
- $("#toggle").click(function() {
- $(this).html($("#content").is(":hidden") ? "收起" + "<i class='iconfont up iconSelect_drop-down'/></i>" : "展开" +
- "<i class='iconfont up iconSelect_drop-down'/></i>");
- $("#content").slideToggle();
- });
- var rowData = layui.sessionData("ROW_DATA").NOW_ROW;
- layui.use('element', function(){
- var element = layui.element;
-
- });
-
- var table;
- layui.use('table', function(){
- var aciId = rowData.aciId;
- table = layui.table;
- table.render({
- id : 'tabletest'
- ,elem: '#tabletest'
- ,limit:10
- ,url: 'ContactManageAction/queryContact' //数据接口
- ,method: 'post'
- ,where:{MINView:"JSON", aciId:aciId}
- ,page: true //开启分页
- ,cols: [[ //表头
- {type:'numbers',title: '序号',width:"5%"}
- ,{field: 'aciName', title: '客户名称', width:"25%"}
- ,{field: 'accName', title: '姓名', width:"10%"}
- ,{field: 'phone', title: '电话号', width:"15%"}
- ,{field: 'remarks', title: '备注', width:"25%"}
- ,{field: 'operate', title: '操作',width:"20%", toolbar: '#barDemo1'}
- ]]
- ,done: function(res, curr, count){
- //如果是异步请求数据方式,res即为你接口返回的信息。
- console.log(res);
- //得到当前页码
- console.log(curr);
- //得到数据总量
- console.log(count);
- }
- ,even: true //开启隔行背景
- });
-
- // 监听工具条(操作)
- table.on('tool(tableFilter)', function(obj){ //注:tool是工具条事件名,tableFilter是table原始容器的属性 lay-filter="对应的值"
- var data = obj.data; //获得当前行数据
- var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
- var tr = obj.tr; //获得当前行 tr 的DOM对象
- var accId = data.accId;
- if(layEvent === 'delete'){ //删除
- layer.confirm('确认删除当前联系人吗?', function(index){
- layer.close(index);
- //向服务端发送删除指令roleDelete
- $.request({
- action : "ContactManageAction/deleteContact",
- data : {
- accId : accId,
- State : 01
- },
- success : function(resData) {
- if (resData.MINStatus == 0) {
- layer.alert('操作成功!', {icon: 1});
- obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
- window.location.reload();
- } else {
- layer.alert(resData.MINErrorMessage, {
- icon: 5,
- title: "提示"
- });
- }
- },
- error : function(data2){
- layer.alert(data2.MINErrorMessage, {
- icon: 5,
- title: "提示"
- });
- }
- });
- });
- }
- else if(layEvent === 'edit'){ //编辑
- editDetail(data);
- }
- });
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
-
- });
-
-
- //新增
- $(document).on('click','#addContact',function(data){
- // 寄存当前数据
- layer.open({
- type: 2,
- title: '新增',
- shadeClose: true,
- // shade: true ,
- shade: 0.8,
- //maxmin: true, //开启最大化最小化按钮
- area: ['55%', '65%'],
- content: '../contactManage/addContact.html'
- });
- });
- //编辑
- function editDetail(data) {
- var params = {};
- params.columnNumber = 2; //每行显示两个字段
- // 寄存当前数据
- layui.sessionData("ROW_DATA", {key:"NOW_ROW", value:data});
- layer.open({
- type: 2,
- title: '编辑',
- shadeClose: true,
- // shade: true ,
- shade: 0.8,
- //maxmin: true, //开启最大化最小化按钮
- area: ['55%', '65%'],
- content: '../contactManage/editContact.html'
- });
- }
-
- function loadAA() {
- var accName = $('#accName').val();
- //执行重载
- table.reload('tabletest', {
- page: {
- curr: 1 //重新从第 1 页开始
- }
- ,where: {
- accName : accName
- }
- });
- }
-
- //重置
- function cancle(){
- $('#formName')[0].reset();
- }
- </script>
- </body>
- </html>
|