123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- layui.use(['form', 'layer', 'laydate', 'table', 'laytpl', 'layedit', 'upload'], function () {
- var form = layui.form,
- layer = parent.layer === undefined ? layui.layer : top.layer,
- $ = layui.jquery,
- laydate = layui.laydate,
- laytpl = layui.laytpl,
- table = layui.table,
- layedit = layui.layedit
- , upload = layui.upload;
- var houid = $('input[name=hid]').val();
- var houname = $('input[name=name]').val();
- //调用编辑器
- var tableIds = 'housespriceList';
- //楼盘列表
- var tableIns = table.render({
- elem: '#' + tableIds,
- url: '/house/priceviewform',
- cellMinWidth: 95,
- where: {hid: houid},
- method: 'post',
- page: true,
- height: 600,
- limit: 20,
- id: 'pricetablerReload',
- cols: [[
- {type: 'numbers', fixed: "left"},
- // {type: "checkbox", fixed: "left", width: 50},
- {field: 'create_time', title: '记录时间', align: "center", sort: true},
- {field: 'min_price', title: '最低价', width: 120, align: "center", sort: true},
- {field: 'price', title: '均价', width: 120, align: "center", sort: true},
- {field: 'price_unit', title: '单位', width: 120, align: "center", sort: true},
- {field: 'explain', title: '价格说明', width: 500, align: "center", sort: true},
- // {title: '操作', width: 150, templet: '#housesListBar', fixed: "right", align: "center"}
- ]]
- });
- tableIns.reload('pricetablerReload'); //重新加载
- var $ = layui.$, active = {
- addData: function () { //获取选中数据
- var index = parent.layui.layer.open({
- title: "添加新价格",
- type: 2,
- area: ['', '100%'],
- maxmin: true,
- content: "/house/priceadd?hid=" + houid + '&name=' + houname,
- end: function () {
- layui.table.reload('pricetablerReload');
- }
- })
- parent.layui.layer.full(index);
- // // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize", function () {
- parent.layui.layer.full(index);
- })
- },
- reload: function () {
- var form = pfgs_serialize($('form'));
- var name = '';
- var id = '';
- // console.log($('form').serializeArray());
- if (form.input_house == 'name') {
- name = form.input_house_text;
- } else if (form.input_house == 'id') {
- id = form.input_house_text;
- }
- table.reload('tablerReload', {
- where: {
- sort: form.input_sort,
- id: id,
- name: name,
- city: form.input_city
- }
- })
- }
- };
- $('.demoTable .layui-btn').on('click', function () {
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- //日期
- laydate.render({
- elem: '#date1'
- });
- //列表操作
- table.on('tool(' + tableIds + ')', function (obj) {
- var data = obj.data;
- if (obj.event === 'edit') {
- var index = parent.layui.layer.open({
- title: "修改价格信息",
- type: 2,
- area: ['', '100%'],
- maxmin: true,
- content: "/house/priceedit?id=" + data.id + '&name=' + houname,
- end: function () {
- layui.table.reload('pricetablerReload');
- }
- })
- parent.layui.layer.full(index);
- // // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize", function () {
- parent.layui.layer.full(index);
- })
- } else if (obj.event === 'del') {
- layer.confirm('您确认要删除吗?', {btn: ['确认', '取消']}, function () {
- $.post('/house/housedel', {id: data.id}, function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- // parent.layui.
- table.reload('tablerReload');
- // TableClose();
- } else {
- layer.msg(data.msg);
- }
- })
- })
- }
- });
- form.on('submit(pricetijiao)', function (data) {
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
- var formData = new FormData($('#price_form')[0]);
- console.log(formData)
- $.ajax({
- cache: true,
- type: "post",
- url: "/house/priceaddform",
- data: formData, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步,
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- error: function (request) {
- layer.close(index); //关闭数据提交信息
- layer.alert("网络超时");
- },
- success: function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- TableClose();
- } else if (data.code == 300) {
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data), {icon: 5});
- }
- }
- });
- return false;
- })
- form.on('submit(priceSave)', function (data) {
- //aaaaa
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
- var formData = new FormData($('#price_form')[0]);
- $.ajax({
- cache: true,
- type: "post",
- url: "/house/priceeditform",
- data: formData, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步,
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- error: function (request) {
- layer.close(index); //关闭数据提交信息
- layer.alert("网络超时");
- },
- success: function (data) {
- layer.close(index); //关闭数据提交信息
- if (data.code == 200) {
- layer.msg(data.msg);
- // parent.layui.table.reload('pricetablerReload');
- TableClose();
- } else if (data.code == 300) {
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data), {icon: 5});
- }
- }
- });
- return false;
- })
- form.on('submit(del_price)', function (data) {
- //aaaaa
- var index = layer.msg('数据提交中,请稍候', {icon: 16, time: false, shade: 0.8}); //数据提交提示
- var checkStatus = table.checkStatus('pricetablerReload');
- if (typeof checkStatus.data[0] == 'object') {
- // var Hid = $('#houseId').val();
- var formdat = new FormData();
- $.each(checkStatus.data, function (key, val) {
- formdat.append('id[]', val.id);
- })
- $.ajax({
- cache: true,
- type: "post",
- url: "/house/pricedel",
- data: formdat, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步,
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- error: function (request) {
- layer.close(index); //关闭数据提交信息
- layer.alert("网络超时");
- },
- success: function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- layui.table.reload('pricetablerReload');
- } else if (data.code == 300) {
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data), {icon: 5});
- }
- }
- });
- return false;
- }
- layer.msg('请选择需要删除的行');
- return false;
- // $.ajax({
- // cache : true,
- // type : "post",
- // url : "/house/priceeditform",
- // data : formData, // 你的formid
- // // async : false, //async 默认为true异步,修改为false为同步,
- // contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- // processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- // error : function(request) {
- // layer.close(index); //关闭数据提交信息
- // layer.alert("网络超时");
- // },
- // success : function(data) {
- // if (data.code == 200) {
- // layer.msg(data.msg);
- // // parent.layui.table.reload('pricetablerReload');
- // TableClose();
- // } else if(data.code == 300){
- // layer.msg(data.msg);
- // layer.msg(ReturnInfo(data.data),{icon:5});
- //
- // }
- // }
- // });
- // return false;
- })
- })
- // $(function () {
- // // 动态添加批量删除按钮
- // var _btn = '<div class="layui-inline " style="float:left;position:relative;left:10px;bottom:35px">'
- // + '<a class="layui-btn layui-btn-danger search_btn layui_w_btn" style="height:30px;line-height:30px;font-size:14px;" lay-submit="" lay-filter="del_price">删除</a>'
- // + '</div>'
- // $('.layui-form').append(_btn)
- // })
|