fixedinfo.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form'], 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. var port_id = $('input[name="port"]').val();
  9. //第一个实例
  10. table.render({
  11. elem: '#menulist'
  12. ,url: '/othersiteset/fixedinfoform' //数据接口
  13. ,where:{token:csrfToken,port:port_id}
  14. ,method:'post'
  15. ,page: true //开启分页
  16. ,height:600
  17. ,text:'数据加载中'
  18. ,id:'linkId'
  19. ,cols: [[ //表头
  20. {type:'numbers'}
  21. ,{field: 'keys', title: 'keys名称', align:'center'}
  22. ,{field: 'values', title: '简体内容', align:'center'}
  23. ,{field: 'values_ft', title: '繁体内容', align:'center'}
  24. ,{field: 'type', title: '位置', align:'center'}
  25. ,{fixed: 'right',title:'操作', width: 200, align:'center', toolbar: '#operate'}
  26. ]]
  27. });
  28. //列表操作
  29. table.on('tool(menulist)', function(obj){
  30. var layEvent = obj.event,
  31. data = obj.data;
  32. if(layEvent === 'edit'){
  33. layer.open({
  34. type: 2,
  35. title: '修改',
  36. closeBtn: 1, //不显示关闭按钮
  37. shade: [0],
  38. area: ['600px', '500px'],
  39. anim: 2,
  40. content:'/othersiteset/fixedinfosave?port='+port_id+'&id='+data.id, //iframe的url,no代表不显示滚动条
  41. end:function () {
  42. table.reload('linkId');
  43. }
  44. });
  45. } else if(layEvent === 'del') {
  46. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  47. $.post('/othersiteset/fixedinfodelform',{'id':data.id},function (data) {
  48. if(data.data != null){
  49. layer.msg(ReturnInfo(data.data),{icon:5});
  50. return ;
  51. }
  52. layer.msg(data.msg);
  53. table.reload('linkId');
  54. })
  55. })
  56. }
  57. });
  58. var $ = layui.$, active = {
  59. addData: function(){ //获取选中数据
  60. layer.open({
  61. type: 2,
  62. title: '添加',
  63. closeBtn: 1, //不显示关闭按钮
  64. shade: [0],
  65. area: ['600px', '500px'],
  66. anim: 2,
  67. content: '/othersiteset/fixedinfoadd?port='+port_id, //iframe的url,no代表不显示滚动条
  68. end: function(){ //此处用于演示
  69. table.reload('linkId');
  70. }
  71. });
  72. },
  73. reload:function () {
  74. var form = pfgs_serialize($('form'));
  75. console.log(form);
  76. var keys = '';
  77. var values = '';
  78. // console.log($('form').serializeArray());
  79. if(form.input_house == 'name'){
  80. keys = form.input_house_text;
  81. } else if(form.input_house == 'id'){
  82. values = form.input_house_text;
  83. }
  84. table.reload('linkId',{
  85. where:{
  86. values:values,
  87. keys:keys,
  88. type:form.typearray,
  89. port:port_id,
  90. },
  91. page:{
  92. curr:1
  93. }
  94. })
  95. }
  96. };
  97. // 转换拼音
  98. $('.layui_w_name').on('keyup ',function(){
  99. var _txt = $(this).val();
  100. $.post('/othersiteset/cnvert',{'data':_txt},function (data) {
  101. if(data.code == '200'){
  102. $('input[name="values_ft"]').val(data.data.content);
  103. }
  104. })
  105. })
  106. $('.demoTable .layui-btn').on('click', function(){
  107. var type = $(this).data('type');
  108. active[type] ? active[type].call(this) : '';
  109. });
  110. form.on('submit(save_link)', function(data){
  111. $.post('/othersiteset/fixedinfosaveform',data.field,function (data) {
  112. if(data.data != null){
  113. layer.msg(ReturnInfo(data.data),{icon:5});
  114. return ;
  115. }
  116. layer.msg(data.msg);
  117. })
  118. return false;
  119. });
  120. form.on('submit(tijiao)', function(data){
  121. $.post('/othersiteset/fixedinfoaddform',data.field,function (data) {
  122. if(data.data != null){
  123. layer.msg(ReturnInfo(data.data),{icon:5});
  124. return ;
  125. }
  126. layer.msg(data.msg);
  127. })
  128. return false;
  129. });
  130. });