123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- layui.use(['laypage', 'layer', 'table', 'element', 'form', 'upload'], function () {
- var layer = layui.layer
- , table = layui.table
- , element = layui.element
- , form = layui.form
- , upload = layui.upload;
-
- var indexTtable = table.render({
- elem: '#housefacilitieslist'
- , url: '/dictionary/facilitiesform'
- , where: {token: csrfToken}
- , method: 'post'
- , page: true
- , text: '数据加载中'
- , id: 'tablerReload'
- , cols: [[
-
- {type: 'numbers'},
- {field: 'name', title: '户型', align: 'center'}
- , {
- field: 'sort',
- title: '排序',
- width: 200,
- event: 'sortData',
- edit: 'text',
- align: 'center',
- sort: true,
- templet: "#sortBox"
- }
- , {
- field: 'is_show', title: '审核', align: 'center', width: 200, templet: function (d) {
- if (d.is_show == 2) {
- return '<input type="checkbox" value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
- } else {
- return '<input type="checkbox" checked value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
- }
- }
- }
- , {field: 'create_at', title: '添加时间', width: 120, align: 'center'}
- , {fixed: 'right', title: '操作', width: 165, align: 'center', toolbar: '#operate'}
- ]]
- });
- indexTtable.reload('tablerReload');
-
- form.on('switch(switchTest)', function (data) {
- layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
- $.post('/dictionary/facilitiesstate', {id: data.value, type: 'is_show'}, function (data) {
- layer.msg(data.msg);
- table.reload('tablerReload');
- })
- }, function (aa) {
- indexTtable.reload('tablerReload');
- })
- });
-
- table.on('tool(housefacilitieslist)', 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: ['/dictionary/facilitiessave?id=' + data.id, 'yes'],
- });
- } else if (layEvent === 'del') {
- layer.confirm('您确定要删除吗?', {btn: ['确定', '取消']}, function () {
- $.post('/dictionary/facilitiesdel', {'id': data.id}, function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- table.reload('tablerReload');
- } else if (data.code == 300) {
- layer.msg(data.msg);
- }
- })
- })
- } else if (layEvent === 'sortData') {
- table.on('edit(housefacilitieslist)', function (obj) {
- var data = obj.data;
- $.post('/dictionary/facilitiessort', {
- id: data.id,
- type: 'sort',
- sort: data.sort
- }, function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- } else if (data.code == 300) {
- layer.msg(data.msg);
- }
- })
- })
- }
- });
- var $ = layui.$, active = {
- addData: function () {
- layer.open({
- type: 2,
- title: '添加配套信息',
- closeBtn: 1,
- shade: [0],
- area: ['600px', '500px'],
- anim: 2,
- content: ['/dictionary/facilitiesadd', 'yes'],
- });
-
-
-
- }
- };
- $('.demoTable .layui-btn').on('click', function () {
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
-
- upload.render({
- elem: '#test1'
- , url: '/house/createimg'
- , data: {token: csrfToken}
- , field: 'img'
- , size: 1000
- , exts: 'png|jpg|jpeg'
- , auto: false
- , bindAction: '#addcity'
- , choose: function (obj) {
- obj.preview(function (index, file, result) {
- $('#demo1').attr('src', result);
- });
- }
- });
-
- upload.render({
- elem: '#test2'
- , url: '/house/createimg'
- , data: {token: csrfToken}
- , field: 'mobile_img'
- , size: 1000
- , exts: 'png|jpg|jpeg'
- , auto: false
- , bindAction: '#addcity'
- , choose: function (obj) {
- obj.preview(function (index, file, result) {
- $('#demo2').attr('src', result);
- });
- }
- });
-
- upload.render({
- elem: '#test3'
- , url: '/house/createimg'
- , data: {token: csrfToken}
- , field: 'map_img'
- , size: 1000
- , exts: 'png|jpg|jpeg'
- , auto: false
- , bindAction: '#addcity'
- , choose: function (obj) {
- obj.preview(function (index, file, result) {
- $('#demo3').attr('src', result);
- });
- }
- });
-
- form.on('submit(save_form)', function (data) {
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8});
- var formData = new FormData($('#facilities_form')[0]);
- $.ajax({
- cache: true,
- type: "post",
- url: '/dictionary/facilitiessaveform',
- data: formData,
-
- contentType: false,
- processData: false,
- error: function (request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success: function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- parent.layui.table.reload('housefacilitieslist');
- TableClose();
- } else if (data.code == 300) {
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data));
- }
- }
- });
- return false;
- });
-
- $('.layui_magnify').on('click', function () {
- var _src = $(this).attr('src');
- layui.layer.open({
- type: 1,
- title: false,
- area: ['60%', '80%'],
- shade: 0.6,
- closeBtn: 1,
- shadeClose: true,
- content: '<img style="width:100%;height:100%" src="' + _src + '">',
- });
- });
-
- form.on('submit(add_form)', function (data) {
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8});
- var formData = new FormData($('#facilities_form')[0]);
- $.ajax({
- cache: true,
- type: "post",
- url: '/dictionary/facilitiesaddform',
- data: formData,
-
- contentType: false,
- processData: false,
- error: function (request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success: function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- parent.layui.table.reload('tablerReload');
-
- } else if (data.code == 300) {
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data), {icon: 5});
- }
- }
- });
- return false;
- });
- });
|