special.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,element = layui.element //元素操作
  7. ,form = layui.form
  8. ,upload = layui.upload;
  9. var tableIds = 'videolist'; //表格ID
  10. //第一个实例
  11. table.render({
  12. elem: '#'+tableIds
  13. ,url: '/routinevideo/homeform' //数据接口
  14. ,where:{token:csrfToken}
  15. ,method:'post'
  16. ,page: true //开启分页
  17. ,text:'数据加载中'
  18. ,limit:20
  19. ,id:'tablerReload'
  20. ,cols: [[ //表头
  21. // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'},
  22. {type:'numbers'},
  23. {field: 'type_name', title: '分类名称', align:'center'},
  24. {field: 'title', title: '视频标题', align:'center'},
  25. {field: 'house_name', title: '楼盘名称', align:'center'},
  26. {field: 'city_name', title: '所属区域', align:'center'},
  27. {field: 'source', title: '来源', align:'center'}
  28. ,{field: 'create_at', title: '添加时间',width:130, align:'center'}
  29. ,{field: 'state', title: '审核',width:100, templet:function (d) {
  30. if(d.state == 2){
  31. return '<input type="checkbox" value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  32. } else {
  33. return '<input type="checkbox" checked value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  34. }
  35. }}
  36. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  37. ]]
  38. });
  39. table.reload('tablerReload'); //重新加载
  40. //监听指定开关
  41. form.on('switch(switchTest)', function(data){
  42. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  43. $.post('/routinevideo/videostate',{id:data.value},function (data) {
  44. if(data.data != null){
  45. layer.msg(ReturnInfo(data.data),{icon:5});
  46. return ;
  47. }
  48. layer.msg(data.msg);
  49. table.reload('tablerReload');
  50. })
  51. },function (aa) {
  52. table.reload('tablerReload'); //重新加载
  53. })
  54. });
  55. //列表操作
  56. table.on('tool('+tableIds+')', function(obj){
  57. var layEvent = obj.event,
  58. data = obj.data;
  59. if(layEvent === 'edit'){
  60. var index = layer.open({
  61. type: 2,
  62. title: '修改视频',
  63. area:['','100%'],
  64. content: '/routinevideo/videoedit?id='+data.id+'&house_name='+data.house_name,
  65. end:function () {
  66. table.reload('tablerReload'); //重新加载
  67. }
  68. });
  69. layui.layer.full(index);
  70. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  71. $(window).on("resize",function(){
  72. layui.layer.full(index);
  73. })
  74. } else if(layEvent === 'del') {
  75. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  76. $.post('/routinevideo/videodel',{'id':data.id},function (data) {
  77. if(data.data != null){
  78. layer.msg(ReturnInfo(data.data),{icon:5});
  79. return ;
  80. }
  81. layer.msg(data.msg);
  82. table.reload('tablerReload');
  83. })
  84. })
  85. }
  86. });
  87. $('.layui_magnify').click(function(){
  88. var _src = $(this).attr('src');
  89. layui.layer.open({
  90. type: 1,
  91. title: false, //是否显示标题
  92. area: ['60%', '80%'],
  93. shade: 0.6, //透明度
  94. closeBtn: 1, //按钮 1有,0无
  95. shadeClose: true,
  96. content: '<img style="width:100%;height:100%" src="'+_src+'">',
  97. });
  98. })
  99. //添加图片上传
  100. upload.render({
  101. elem: '#test1'
  102. ,url: '/house/createimg'
  103. ,data:{token:csrfToken}
  104. ,field:'img'
  105. ,size:1000 //限制上传图片的大小,单位为KB
  106. ,exts:'png|jpg|jpeg' //只允许上传压缩文件
  107. ,auto:false
  108. ,bindAction:'#addcity'
  109. ,choose: function(obj){
  110. obj.preview(function(index, file, result){
  111. $('#breviary_img').attr('src', result); //图片链接(base64)
  112. });
  113. }
  114. });
  115. var $ = layui.$, active = {
  116. addData: function(){ //获取选中数据
  117. var index = layui.layer.open({
  118. type: 2,
  119. title: '添加专题',
  120. area: ['','100%'],
  121. content: '/routinespecial/create' //iframe的url,no代表不显示滚动条
  122. ,success:function (layero, index) {
  123. // indexOpen = layer.getChildFrame('body', index) ;
  124. // console.log(indexOpen);
  125. },
  126. end:function () {
  127. table.reload('tablerReload');
  128. }
  129. });
  130. layui.layer.full(index);
  131. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  132. $(window).on("resize",function(){
  133. layui.layer.full(index);
  134. })
  135. },
  136. reload:function(){
  137. var form = pfgs_serialize($('form'));
  138. var name = '';
  139. var house_name = '';
  140. if(form.input_house == 'name'){
  141. name = form.input_house_text;
  142. } else if(form.input_house == 'house_name'){
  143. house_name = form.input_house_text;
  144. }
  145. table.reload('tablerReload',{
  146. where:{
  147. title:name,
  148. house_name:house_name,
  149. city:form.input_city,
  150. type_name:form.type_name
  151. }
  152. })
  153. },
  154. house_reload:function(){
  155. var form = pfgs_serialize($('form'));
  156. console.log(form);
  157. table.reload('houseReload',{
  158. where:{
  159. name:11111
  160. }
  161. })
  162. }
  163. };
  164. $('.demoTable .layui-btn').on('click', function(){
  165. var type = $(this).data('type');
  166. active[type] ? active[type].call(this) : '';
  167. });
  168. //修改
  169. form.on('submit(edit_video_type_name)', function(data){
  170. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  171. var formData = new FormData($('form')[0]);
  172. $.ajax({
  173. cache : false,
  174. type : "post",
  175. url : "/routinevideo/videoeditform",
  176. data : formData,
  177. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  178. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  179. error : function(request) {
  180. layer.close(index);
  181. layer.msg("请联系管理员");
  182. },
  183. success : function(data) {
  184. if(data.data != null){
  185. layer.msg(ReturnInfo(data.data),{icon:5});
  186. return ;
  187. }
  188. layer.msg(data.msg);
  189. }
  190. });
  191. return false;
  192. });
  193. //添加
  194. form.on('submit(add_video_type_name)', function(data){
  195. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  196. var formData = new FormData($('form')[0]);
  197. $.ajax({
  198. cache : false,
  199. type : "post",
  200. url : "/routinevideo/videoaddform",
  201. data : formData, // 你的formid
  202. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  203. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  204. error : function(request) {
  205. layer.close(index);
  206. layer.msg("请联系管理员");
  207. },
  208. success : function(data) {
  209. if(data.data != null){
  210. layer.msg(ReturnInfo(data.data),{icon:5});
  211. return ;
  212. }
  213. layer.msg(data.msg);
  214. }
  215. });
  216. return false;
  217. });
  218. $('.The_house').focus(function(){
  219. indexOpen = parent.layui.layer.open({
  220. type: 2,
  221. title: '选择需要添加的楼盘',
  222. area: ['','100%'],
  223. content: '/publicuse/housename',
  224. success:function (layero, index) {
  225. },
  226. end:function(){
  227. }
  228. });
  229. parent.layui.layer.full(indexOpen);
  230. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  231. $(window).on("resize",function(){
  232. parent.layui.layer.full(indexOpen);
  233. })
  234. })
  235. // var indexO = table.render({
  236. // elem: '#houselist'
  237. // ,url: '/routinevideo/allhouseform' //数据接口
  238. // ,where:{token:csrfToken}
  239. // ,method:'post'
  240. // ,page: true //开启分页
  241. // ,text:'数据加载中'
  242. // ,id:'houseReload'
  243. // ,cols: [[ //表头
  244. // {title:'选择',event:'check',width:60,align:'center',templet:"#checkBox",templet:function(d){
  245. // return '<div class="layui-inline"><input type="radio" name="sex" ></div>'
  246. // }},
  247. // {type:'numbers',title:'序号'},
  248. // {field: 'name', title: '楼盘名称', align:'center'},
  249. // ]]
  250. // });
  251. //选择所属楼盘添加
  252. // var _data;
  253. // table.on('tool(houselist)', function(obj){
  254. // var layEvent = obj.event,
  255. // data = obj.data;
  256. // if(layEvent === 'check'){
  257. // _data = data;
  258. // }
  259. // });
  260. // // 提交按钮
  261. // $('.xuanzhouse').click(function () {
  262. // var a = parent.layer.getChildFrame('body', indexOpen);
  263. // var _length = a.find('input#hiddenBox[type="hidden"]');
  264. // if(_length.length > 0){
  265. // _length.remove();
  266. // }
  267. // if(typeof _data == 'object'){
  268. // a.find('#house_name').val(_data.name)
  269. // a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
  270. // TableClose();
  271. // }
  272. // })
  273. var ue = UE.getEditor('editor'); //编辑器
  274. });