123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- layui.use([ 'laypage', 'layer', 'table', 'element','form','upload','laydate'], function(){
- var laypage = layui.laypage
- ,$ = layui.jquery
- ,layer = layui.layer
- ,table = layui.table
- ,form = layui.form
- ,laydate = layui.laydate;
- var tableId = 'citylist';
-
- table.render({
- elem: '#'+tableId
- ,url: '/pricetrend/homeform'
- ,where:{token:csrfToken}
- ,method:'post'
- ,page: true
- ,text:'数据加载中'
- ,id:'tablerReload'
- ,height : 600
- ,limit:15
- ,cols: [[
- {type:'numbers'}
- ,{field: 'city_name', title: '区域名称',align:'center'}
- ,{field: 'count', title: '价格数量',align:'center'}
- ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
- ]]
- });
-
- table.on('tool('+tableId+')', function(obj){
- var layEvent = obj.event,
- data = obj.data;
- if(layEvent === 'edit'){
- indexOpen = layui.layer.open({
- type: 2,
- title: '[<span style="color:red">'+data.city_name+'</span>]区域历史价格',
- area: ['','100%'],
- content: '/pricetrend/recordprice?cid='+data.city_id,
- success:function (layero, index) {
- }
- });
- layui.layer.full(indexOpen);
-
- $(window).on("resize",function(){
- layui.layer.full(indexOpen);
- })
- } else if(layEvent === 'del') {
- layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
- $.post('/categorycity/delform',{'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 === 'add') {
- layer.open({
- type: 2,
- title: '添加价格',
- closeBtn: 1,
- shade: [0],
- area: ['780px', '550px'],
- anim: 2,
- content: '/pricetrend/lineadd?cid='+data.city_id+'&city_name='+data.city_name,
- });
- }
- });
- var $ = layui.$, active = {
- addData: function(){
- layer.open({
- type: 2,
- title: '添加价格',
- closeBtn: 1,
- shade: [0],
- area: ['780px', '550px'],
- anim: 2,
- content: '/pricetrend/priceadd.html',
- });
- },
- reload:function () {
- var formdara = pfgs_serialize($('form'));
- table.reload('tablerReload',{
- where:{
- city_id:formdara.input_city
- }
- })
-
- }
- };
-
- laydate.render({
- elem: '#date1'
- });
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- $('.The_house').focus(function(){
- indexOpen = parent.layui.layer.open({
- type: 2,
- title: '选择需要添加的区域',
- area: ['','100%'],
- content: '/publicuse/city?type=1',
- success:function (layero, index) {
- },
- end:function(){
- }
- });
- parent.layui.layer.full(indexOpen);
-
- $(window).on("resize",function(){
- parent.layui.layer.full(indexOpen);
- })
- })
- form.on('submit(editcity)', function(data){
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- var formData = new FormData($('form')[0]);
- $.ajax({
- cache : true,
- type : "post",
- url : '/categorycity/edithomeform',
- data : formData,
- contentType: false,
- processData: false,
- error : function(request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success : function(data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- parent.layui.table.reload('tablerReload');
- }
- });
- return false;
- });
-
- form.on('submit(addcity)', function(data){
- layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- var formData = new FormData($('form')[0]);
- $.ajax({
- cache : true,
- type : "post",
- url : '/pricetrend/priceaddform',
- data : formData,
- contentType: false,
- processData: false,
- error : function(request) {
- layer.alert("网络超时");
- },
- success : function(data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- parent.layui.table.reload('tablerReload');
- }
- });
- return false;
- });
- });
|