var reqList = []; var util = {}; util.treeTableXcode = function(data, xcode) { xcode = xcode || ""; for(var i = 0; i < data.length; i++) { var item = data[i]; item.xcode = xcode + i; if(item.children && item.children.length > 0) { util.treeTableXcode(item.children, item.xcode + "-"); } } }; Vue.use(Vuedals.default); new Vue({ el: "#main", data: { tableData: [], valueArea: "350203", optionsArea: [{code:"350203",name:"思明区"}], dateValue: [], pickerOptions: { disabledDate: function(d) { return d > new Date(); } }, isloading:false, //加载中 }, components: { vuedals: Vuedals.Component }, mounted: function() { var vm = this //初始化时间 var end = new Date(); var start = new Date(); start.setDate(1) vm.dateValue = [start.format("yyyy-MM-dd"), end.format("yyyy-MM-dd")] //初始化数据 vm.initData() // vm.getDistrict() $("#main").removeClass("c-hide"); //监听后退按钮的操作 EventBus.$on("back-click", function(arg) { history.go(-1); }); //监听页面刷新 EventBus.$on("refresh-click", function(arg) { vm.initData() }); window.onresize = function() { } }, methods: { initData: function() { var vm=this var startDate,endDate if(vm.dateValue[0]>vm.dateValue[1]){ vm.$message.warning("开始时间应小于结束时间") return false } vm.isloading=true startDate=vm.dateValue[0] endDate=vm.dateValue[1] var params={ userAgent:localStorage.getItem('wlyyAgentForDoc'), area:vm.valueArea,startDate:startDate,endDate:endDate, } statisticAPI.subsidyExpense(params).then(function(res) { vm.isloading=false if(res.status == 200) { vm.tableData=res.data util.treeTableXcode(vm.tableData); } else { vm.$message.error(res.msg) } }) }, changeDateValue: function() { alert(JSON.stringify(this.dateValue)) }, getDistrict: function() { var vm=this var params={ type:3,code:"350200" } homeAPI.getDistrict(params).then(function(res) { if(res.status == 200) { vm.optionsArea=res.list vm.valueArea=vm.optionsArea[0].code vm.initData() } else { vm.$message.error(res.msg) } }) }, exportData: function() { var vm=this var startDate,endDate if(typeof(vm.dateValue[0])!="string"){ startDate=vm.dateValue[0].format("yyyy-MM-dd") endDate=vm.dateValue[1].format("yyyy-MM-dd") }else{ startDate=vm.dateValue[0] endDate=vm.dateValue[1] } var params={ userAgent:localStorage.getItem('wlyyAgentForDoc'), area:vm.valueArea,startDate:startDate,endDate:endDate, } var str = statisticAPI.subsidyExpenseExport+"?area="+vm.valueArea+"&startDate="+startDate+"&endDate="+endDate; window.open(str, "接收包数据导出")//导出数据 }, treeClick: function(item, index) { if(item.open) { this.collapse(item, index); } else { this.expand(item, index); } }, expand: function(item, index) { if(!item.children) { return index; } //展开 for(var i = 0; item.children && i < item.children.length; i++) { var child = item.children[i]; this.tableData.splice(++index, 0, child); if(child.children && child.children.length > 0 && child.open) { index = this.expand(child, index); } } item.open = true; return index; }, collapse: function(item, index) { if(!item.children) { return index; } //收缩 item.open = false; var len = this.tableData[index].children.length; this.tableData.splice(index + 1, len); } } });