123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- layui.use(['layer', 'table', 'form','upload'], function () {
-
- var $ = layui.jquery
- , layer = layui.layer
- , table = layui.table
- , form = layui.form
- ,upload = layui.upload
-
- var list_id = $('#type_id').val();
- var tableIds = 'vrlist';
-
- var url = '/vr/vrindexform';
- var where = {token: csrfToken, 'type': list_id};
-
- table.render({
- elem: '#' + tableIds
- , url: url
- , where: where
- , method: 'post'
- , page: true
- , text: '数据加载中'
- , height: 580
- , id: 'tablerReload'
- , cols: [[
- {type: 'checkbox', width: 50}
- ,{type: 'numbers', title: '序号', width: 50}
- , {field: 'name', title: 'VR标题', align: 'center'}
- , {field: 'abstarct', title: '厅卫厨', align: 'center'}
- , {field: 'covered_area', title: '建筑面积', align: 'center'}
- , {field: 'path', title: 'VR地址', align: 'center'}
- , {field: 'huxing_name', title: '户型类别', align: 'center'}
- , {field: 'img', title: '图片', width: 150, align: 'center',templet: function (d) {
- return '<img src="'+d.img+'" style="width: 100px;50px;">'
- }}
- , {field: 'house_name', title: '楼盘名称', align: 'center'}
- , {field: 'city_name', title: '地区名称', align: 'center', width: 100}
- , {
- field: 'sort',
- title: '排序',
- width: 100,
- event: 'sortData',
- edit: 'text',
- align: 'center',
- sort: true,
- templet: "#sortBox"
- }
- , {field: 'state', title: '审核', align: 'center', width: 100,templet: function (d) {
- if (d.state == 2) {
- return '<input type="checkbox" value="' + d.id + '" res_state="1" lay-skin="switch" lay-filter="switchTest3" lay-text="|">'
- } else {
- return '<input type="checkbox" checked value="' + d.id + '" res_state="2" lay-skin="switch" lay-filter="switchTest3" lay-text="|">'
- }
- }}
- , {field: 'create_at', title: '添加时间', width: 150, align: 'center'}
-
- ]]
- });
-
- table.on('tool(' + tableIds + ')', function (obj) {
- var layEvent = obj.event,
- data = obj.data;
- if (layEvent === 'edit') {
- var index = layer.open({
- type: 2,
- title: '修改直播信息',
- area: ['80%', '80%'],
- content: '/vr/vredit?id=' + data.id,
- end: function () {
- table.reload('tablerReload');
- }
- });
- } else if (layEvent === 'del') {
- var index = layer.confirm('您确定要删除吗?', {btn: ['确定', '取消']}, function () {
- setListHouse('del',data.id);
- layer.close(index);
- })
- } else if (layEvent === 'sortData') {
- table.on('edit(' + tableIds + ')', function (obj) {
- var data = obj.data;
- setListHouse('sort',data.id,data.sort);
- })
- } else if (layEvent === 'syncvr') {
- var index = layer.confirm('您确定要同步吗?', {btn: ['确定', '取消']}, function () {
- $.post('/vr/vrsync',{vid:data.id},function(res){
- if(res.code == 200){
- layer.msg('提交同步成功,请前往审核');
- }
- },'json')
- layer.close(index);
- })
- }
- });
-
-
- var $ = layui.$, active = {
- addData: function () {
- var index = layui.layer.open({
- type: 2,
- title: '添加VR数据信息',
- closeBtn: 1,
- area: ['80%', '80%'],
- content: '/vr/vradd?type=' + list_id
- , success: function (layero, index) {
- },
- end: function () {
- table.reload('tablerReload');
- }
- });
- },
- reload: function () {
- var form = pfgs_serialize($('form'));
- table.reload('tablerReload', {
- where: {
- name: form.input_vrname,
- house: form.input_house
- },
- page: {
- curr: 1
- }
- })
- },
- };
- $('.demoTable .layui-btn').on('click', function () {
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
-
-
- form.on('submit(adds)', function (data) {
- var formData = new FormData($('form')[0]);
- if (formData.getAll('img')[0].size == 0) {
- layer.msg('请选择图片');
- return false;
- }
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8});
- $.ajax({
- cache: false,
- type: "post",
- url: "/vr/vraddform",
- data: formData,
- contentType: false,
- processData: false,
- error: function (request) {
- layer.close(index);
- layer.msg("请联系管理员");
- },
- success: function (data) {
- layer.msg(data.msg);
- }
- });
- return false;
- });
- form.on('submit(edits)', function (data) {
- var formData = new FormData($('form')[0]);
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8});
- $.ajax({
- cache: false,
- type: "post",
- url: "/vr/vreditform",
- data: formData,
- contentType: false,
- processData: false,
- error: function (request) {
- layer.close(index);
- layer.msg("请联系管理员");
- },
- success: function (data) {
- if (data.data != null) {
- layer.msg(ReturnInfo(data.data), {icon: 5});
- return;
- }
- layer.msg(data.msg);
- }
- });
- return false;
- });
-
-
-
- upload.render({
- elem: '#test1'
- , field: 'img'
- , size: 1000
- , exts: 'png|jpg|jpeg'
- , auto: false
- , choose: function (obj) {
- obj.preview(function (index, file, result) {
- $('#breviary_img').attr('src', result);
- });
- }
- });
-
- $('.The_house').focus(function () {
- var type_id = $('input[name=type]').val();
- var houseUrl = '';
- if (type_id == 1) {
- houseUrl = '/publicuse/housename';
- } else {
- houseUrl = '/publicuse/housenamecn';
- }
- indexOpen = parent.layui.layer.open({
- type: 2,
- title: '选择需要添加的楼盘',
- area: ['', '100%'],
- content: houseUrl,
- success: function (layero, index) {
- },
- end: function () {
- }
- });
- parent.layui.layer.full(indexOpen);
-
- $(window).on("resize", function () {
- parent.layui.layer.full(indexOpen);
- })
- })
-
- form.on('switch(switchTest3)', function (data) {
- let id = data.value;
- let val = $(this).attr('res_state');
- var index = layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
- setListHouse('state',id,val)
- layer.close(index)
- }, function (aa) {
- renderTable();
- })
- });
- function setListHouse(code, id, val = null) {
- $.post('/vr/vrset',{code:code,id:id,val:val},function(res){
- layer.msg(res.msg)
- table.reload('tablerReload');
- },'json')
- }
-
- })
|