123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
- var laypage = layui.laypage //分页
- ,$ = layui.jquery
- ,layer = layui.layer //弹层
- ,table = layui.table //表格
- ,element = layui.element //元素操作
- ,form = layui.form;
- var port_id = $('input[name="port"]').val();
- //第一个实例
- table.render({
- elem: '#menulist'
- ,url: '/othersiteset/fixedinfoform' //数据接口
- ,where:{token:csrfToken,port:port_id}
- ,method:'post'
- ,page: true //开启分页
- ,height:600
- ,text:'数据加载中'
- ,id:'linkId'
- ,cols: [[ //表头
- {type:'numbers'}
- ,{field: 'keys', title: 'keys名称', align:'center'}
- ,{field: 'values', title: '简体内容', align:'center'}
- ,{field: 'values_ft', title: '繁体内容', align:'center'}
- ,{field: 'type', title: '位置', align:'center'}
- ,{fixed: 'right',title:'操作', width: 200, align:'center', toolbar: '#operate'}
- ]]
- });
- //列表操作
- table.on('tool(menulist)', function(obj){
- var layEvent = obj.event,
- data = obj.data;
- if(layEvent === 'edit'){
- layer.open({
- type: 2,
- title: '修改',
- closeBtn: 1, //不显示关闭按钮
- shade: [0],
- area: ['600px', '500px'],
- anim: 2,
- content:'/othersiteset/fixedinfosave?port='+port_id+'&id='+data.id, //iframe的url,no代表不显示滚动条
- end:function () {
- table.reload('linkId');
- }
- });
- } else if(layEvent === 'del') {
- layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
- $.post('/othersiteset/fixedinfodelform',{'id':data.id},function (data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- table.reload('linkId');
- })
- })
- }
- });
- var $ = layui.$, active = {
- addData: function(){ //获取选中数据
- layer.open({
- type: 2,
- title: '添加',
- closeBtn: 1, //不显示关闭按钮
- shade: [0],
- area: ['600px', '500px'],
- anim: 2,
- content: '/othersiteset/fixedinfoadd?port='+port_id, //iframe的url,no代表不显示滚动条
- end: function(){ //此处用于演示
- table.reload('linkId');
- }
- });
- },
- reload:function () {
- var form = pfgs_serialize($('form'));
- console.log(form);
- var keys = '';
- var values = '';
- // console.log($('form').serializeArray());
- if(form.input_house == 'name'){
- keys = form.input_house_text;
- } else if(form.input_house == 'id'){
- values = form.input_house_text;
- }
- table.reload('linkId',{
- where:{
- values:values,
- keys:keys,
- type:form.typearray,
- port:port_id,
- },
- page:{
- curr:1
- }
- })
- }
- };
- // 转换拼音
- $('.layui_w_name').on('keyup ',function(){
- var _txt = $(this).val();
- $.post('/othersiteset/cnvert',{'data':_txt},function (data) {
- if(data.code == '200'){
- $('input[name="values_ft"]').val(data.data.content);
- }
- })
- })
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- form.on('submit(save_link)', function(data){
- $.post('/othersiteset/fixedinfosaveform',data.field,function (data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- })
- return false;
- });
- form.on('submit(tijiao)', function(data){
- $.post('/othersiteset/fixedinfoaddform',data.field,function (data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- })
- return false;
- });
- });
|