123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- var id="";
- layui.define(['layer', 'form','element'], function (exports) {
- var $ = layui.jquery,layer = layui.layer,form = layui.form,element = layui.element;
- getFollow();
- function getFollow(){
- web.ajaxPost(base+"/wxReply/getFollow",{},function(data){
- id=data.id;
- $("#rm_content").val(data.rm_content);
- });
- }
- var table = $('#dateTable').DataTable({
- ajax: {
- url: base+"/wxReply/query",
- data : function(data) {
- data.keyword = $.trim($("#keyword").val());
- }
- },
- "columns": [ // 自定义数据列
- {data:function(obj){
- return '<input type="checkbox" lay-skin="primary" lay-filter="oneChoose" data-id="'+obj.id+'" />';
- }},
- {data: 'reply_keyword'},
- {data: function(obj){
- return web.getDictVal('reply_type',obj.rm_type)
- }},
- {data: 'rm_content'},
- {data:function(obj){
- return '<a title="编辑" class="ml-5 btn-edit"><i class="layui-icon"></i></a>'+
- '<a title="删除" class="ml-5 btn-delete"><i class="layui-icon"></i></a>';
- },sClass:'text-c'}
- ],
- "stateSaveParams": function () { // 初始化完成调用事件
- // 重新渲染form checkbox
- form.render('checkbox');
- web.hideTableBtns("#dateTable");
- }
- }).on('click', '.btn-delete', function (e) {
- e.stopPropagation();
- var row = table.row($(this).parents('tr')).data();
- layer.confirm('确认要删除吗?', function (index) {
- del(row.id);
- });
- }).on('click', '.btn-edit', function (e) {
- e.stopPropagation();
- var row = table.row($(this).parents('tr')).data();
- add("编辑", row.id);
- }).on("dblclick","tr",function () {
- //获取值的对象数据
- var row = table.row(this).data();
- add("编辑",row.id);
- });
-
- form.on('checkbox(allChoose)', function(data){
- var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
- child.each(function(index, item){
- item.checked = data.elem.checked;
- });
- form.render('checkbox');
- });
-
- //查询
- $("#btn-query").on('click',function(){
- table.ajax.reload();
- });
-
- //新增
- $('#btn-add').on('click',function(){
- add("新增","");
- });
-
- //删除
- $('#btn-delete').on('click', function(){
- var ids = web.getIds($('#dateTable'),'data-id');
- if (ids.length == 0) {
- layer.msg("请至少选中一条数据");
- } else {
- layer.confirm('确认要删除吗?', function (index) {
- del(ids.join(","));
- });
- }
- });
-
- //删除
- function del(id){
- web.ajaxPost(base + "/wxReply/delete", {id: id}, function (data) {
- if (data.success) {
- table.ajax.reload();
- layer.msg('删除成功');
- } else {
- layer.msg('删除失败');
- }
- });
- }
-
- $('#btn-save').on('click',function(){
- var rm_content = $.trim($("#rm_content").val());
- if(rm_content==""){
- layer.msg("请输入回复内容");
- return;
- }
- web.ajaxPost(base+"/wxReply/followSave",{id:id,rm_content:rm_content},function(data){
- layer.msg(data.msg);
- if(data.res){
- id=data.res.id;
- }
- });
- return false;
- });
- //弹出
- function add(title,id){
- var url="wxReplyForm.jsp";
- if(id){
- url +="?id="+id;
- }
- layer_show(title,url,"100%","100%");
- }
-
- exports('wxReplyList', {});
- });
|