syncOperate.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. layui.use(['layer','element','form','table'], function(){
  2. var laypage = layui.laypage //分页
  3. ,layer = layui.layer //弹层
  4. ,table = layui.table //表格
  5. ,element = layui.element //元素操作
  6. ,form = layui.form;
  7. layer.photos({
  8. photos: '#demo2',
  9. closeBtn: 1
  10. ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  11. });
  12. //选项卡切换
  13. $('.layui-tab-title .site-demo-active').on('click', function(){
  14. $(this).addClass('layui-this').siblings().removeClass('layui-this');
  15. var lay_id = $(this).attr('lay-id');
  16. $('.layui-tab-item').removeClass('layui-show');
  17. $('.layui-tab-content #'+lay_id).addClass('layui-show');
  18. });
  19. var verdict = $('#editor').html();
  20. if(typeof verdict == "string"){
  21. var ue = UE.getEditor('editor'); //编辑器
  22. }
  23. form.on('submit(sync_edit)', function(data){
  24. layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  25. var formData = new FormData($('#house_edit_form')[0]);
  26. $.ajax({
  27. cache : true,
  28. type : "post",
  29. url : "/othersync/houseadd",
  30. data : formData, // 你的formid
  31. async : false,
  32. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  33. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  34. error : function(request) {
  35. layer.alert("请联系管理员");
  36. },
  37. success : function(data) {
  38. if(data.data != null)
  39. {
  40. layer.msg(ReturnInfo(data.data),{icon:5});
  41. return false;
  42. }
  43. layer.msg(data.msg);
  44. TableClose();
  45. }
  46. });
  47. return false;
  48. });
  49. var data = {};
  50. form.on('checkbox(editlist)', function(obj){
  51. var paren = $(this).parent().parent().parent();
  52. var name = paren.attr('name');
  53. if(obj.elem.checked == true){
  54. var arr = [];
  55. data[name] = paren.find("input[name="+name+"]").val();
  56. $.each(paren.find('input:checkbox:checked'),function(){
  57. if($(this).val() != 'on'){
  58. arr.push($(this).val());
  59. }
  60. });
  61. if(arr.length>0){
  62. data[name] = arr;
  63. }
  64. }else if(obj.elem.checked == false){
  65. delete data[name];
  66. }
  67. // console.log( console.log(data));
  68. });
  69. // 添加页面提交
  70. form.on('submit(sync_infoedit)',function (arr) {
  71. layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  72. var formData = new FormData($('#house_edit_form')[0]);
  73. $.post("/othersync/houseadd",{data:data,unid:formData.get('uniqid'),hid:formData.get('hid'),sync:formData.get('sync')},function(datas){
  74. if(datas.data != null)
  75. {
  76. layer.msg(ReturnInfo(datas.data),{icon:5});
  77. return false;
  78. }
  79. layer.msg(datas.msg);
  80. // TableClose();
  81. })
  82. return false;
  83. })
  84. // 添加页面提交
  85. form.on('submit(edit_Album)',function (data) {
  86. layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  87. $.post("/othersync/houseallbumform",{data:data.field,},function(datas){
  88. if(datas.data != null)
  89. {
  90. layer.msg(ReturnInfo(datas.data),{icon:5});
  91. return false;
  92. }
  93. layer.msg(datas.msg);
  94. // TableClose();
  95. })
  96. return false;
  97. })
  98. });