123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- var reqList = []; //记录请求的参数和url,用于后退时使用
- Vue.use(Vuedals.default);
- new Vue({
- el: "#main",
- data: {
- appname: "祝福分析",
- years: [],
- isback: true,
- isrefresh: true,
- isopen: false,
- //请求页面所需参数
- level: '',
- area: '',
- areaTitle: '',
- index: '3',
- selectedDateType: 3, //折线图坐标值1-日,2-周,3-月
- endDate: '',
- startDate: '',
- lowLevel: '',
- lowCode: '',
- chooseYear: '',
- userRole: '',
- analysisType: "1", // 筛选维度的id, 1-按任务,2-按人口,3-高血压,4-糖尿病,5-65岁以上人群
- analysisName: "按任务",
- signRateData: {
- signRateText: "",
- signRate: "",
- signAmount: "",
- signRateAll: "",
- completeRateText: "",
- completeRate: "",
- completeAmount: "",
- completeRateAll: ""
- },
- sendRate:null,
- noSendRate:null,
- sendCount:null,
- noSendCount:null,
- total:null,
- yearHtml: "",
- contentHtml: "",
- isloading:false,
- },
- components: {
- vuedals: Vuedals.Component
- },
- methods: {
- getNewLineData: function (arg) {
- this.selectedDateType = arg.dateType;
- loadData([1], this);
- },
- selectChange: function () {
- var vm=this
- vm.startDate = getStartDate(vm.chooseYear);
- vm.endDate = getEndDate(vm.chooseYear);
- //请求参数重置,页面类型重新开始
- vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
- vm.area = vm.userRole.code;
- vm.areaTitle = vm.userRole.name;
- EventBus.$emit('update-area-name', {
- areaName: vm.areaTitle
- });
- //然后清空请求列表数组
- reqList.splice(0, reqList.length);
- loadData([0, 1, 2], vm); //刷新数据
- //存储请求所带的参数
- reqList.push({
- level: vm.level,
- area: vm.area,
- areaTitle: vm.areaTitle,
- index: vm.index,
- endDate: vm.endDate,
- startDate: vm.startDate,
- lowLevel: vm.lowLevel,
- lowCode: vm.lowCode,
- analysisType: vm.analysisType
- });
- EventBus.$emit('update-statistics-year', {
- selectDate: vm.chooseYear + "年"
- }); //更新年份
- EventBus.$emit('update-statistics-time', {}); //更新统计时间
- },
- getAreaData: function (arg) {
- //如果level改变,则需要重新加载整个页面的数据,否则只需加载底部区域数据
- if (arg.level == this.level) {
- this.lowLevel = arg.lowLevel;
- loadData([2], this);
- } else {
- this.level = arg.level;
- this.lowLevel = arg.lowLevel;
- this.area = arg.area;
- this.areaTitle = arg.areaTitle;
- loadData([0, 1, 2], this);
- }
- EventBus.$emit('update-area-name', {
- areaName: this.areaTitle
- });
- //存储请求所带的参数
- reqList.push({
- level: this.level,
- area: this.area,
- areaTitle: this.areaTitle,
- index: this.index,
- endDate: this.endDate,
- startDate: this.startDate,
- lowLevel: this.lowLevel,
- lowCode: this.lowCode,
- analysisType: this.analysisType,
- })
- },
- jumpTip: function (tab) {
- $('#shadow' + tab).css("visibility", "visible")
- },
- leaveTip: function (tab) {
- $('#shadow' + tab).css("visibility", "hidden")
- },
- },
- mounted: function () {
- //初始化数据
- initData(this);
- // 初始化年份
- initYear(this)
- //获得顶部各tab的值
- loadData([0, 1, 2], this); //参数组数表示请求的区域为上中下
- //存储请求所带的参数
- reqList.push({
- level: this.level,
- area: this.area,
- areaTitle: this.areaTitle,
- index: this.index,
- endDate: this.endDate,
- startDate: this.startDate,
- lowLevel: this.lowLevel,
- lowCode: this.lowCode,
- analysisType: this.analysisType
- });
- //设置监听器, 监听折线图日期变化
- var vm = this;
- //监听后退按钮的操作
- EventBus.$on("back-click", function (arg) {
- EventBus.$emit('update-statistics-time', {}); //更新统计时间
- if (reqList.length == 1) {
- history.go(-1);
- } else {
- var preInfo = reqList.pop();
- var info = reqList[reqList.length - 1];
- vm.level = info.level;
- vm.area = info.area;
- vm.areaTitle = info.areaTitle;
- vm.lowLevel = info.lowLevel;
- vm.index = info.index;
- vm.lowCode = info.lowCode;
- loadData([0, 1, 2], vm);
- EventBus.$emit('update-area-name', { areaName: vm.areaTitle });
- }
- });
- //监听页面刷新
- EventBus.$on("refresh-click", function (arg) {
- EventBus.$emit('update-statistics-time', {}); //更新统计时间
- loadData([0, 1, 2], vm);
- });
- $("#main").removeClass("c-hide");
- }
- })
- function initData(vm) {
- //获得缓存中缓存的角色权限
- var userRole = window.sessionStorage.getItem("selectedRole");
- if (!userRole) {
- return false;
- }
- vm.userRole = JSON.parse(userRole);
- vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
- vm.area = vm.userRole.code;
- vm.areaTitle = vm.userRole.name;
- var now = new Date();
- if (now.getMonth() >= 6 || now.getFullYear()>=2023) {
- vm.chooseYear = now.getFullYear();
- } else {
- vm.chooseYear = now.getFullYear() - 1;
- }
- vm.startDate = getStartDate(vm.chooseYear);
- vm.endDate = getEndDate(vm.chooseYear);
- //更新头部信息
- EventBus.$emit('update-all-prompt-info', {
- areaName: vm.areaTitle,
- selectDate: vm.chooseYear + "年",
- dimensionVal: vm.analysisName
- });
- }
- function initReqParams(vm) {
- vm.index = 13;
- if (vm.lowCode) {
- vm.index = 17;
- }
- reqParam = [{
- url: "/statistics/article_total",
- reqType: 'get',
- data: {
- index:'98,99',
- level: vm.level,
- area: vm.area,
- year: vm.chooseYear,
- endDate: vm.endDate,
- startDate: vm.startDate,
- }
- }, {
- url: "/statistics/interval",
- reqType: 'get',
- data: {
- index: '99',
- level: vm.level,
- area: vm.area,
- startDate: vm.startDate,
- endDate: vm.endDate,
- interval: vm.selectedDateType,
- }
- }, {
- url: "/statistics/birthday_lowlevel_total",
- reqType: 'get',
- data: {
- sort: 1,
- endDate: vm.endDate,
- level: vm.level,
- area: vm.area,
- }
- }];
- if (vm.lowLevel) {
- reqParam[2].data.lowLevel = vm.lowLevel;
- }
- return reqParam;
- }
- function initYear(vm) {
- var now = new Date(),
- year = now.getFullYear();
- // if (now.getMonth() < 6) {
- // year--;
- // }
- for (i = year; i > 2018; i--) {
- vm.years.push(i);
- }
- }
- function getTopTagDatas(data, vm) {
- // 指标98已发送,99未发送
- vm.total=parseFloat(data.index_98+data.index_99)
- vm.sendCount=data.index_98
- vm.noSendCount=data.index_99
- vm.sendRate=vm.total!=0?(data.index_98 / vm.total *100).toFixed(2) +'%':'0%'
- vm.noSendRate=vm.total!=0?(data.index_99 / vm.total *100).toFixed(2) +'%':'0%'
- window.onresize = function () {
- window.lineCharts.resize(); //日周月折线图
- }
- }
- function loadData(loadArr, vm) {
- //获取其他请求的参数
- var reqParams = initReqParams(vm),
- reqPromise = [],
- newArr = []; //记录非顶部请求的请求数组
- for (i = 0; i < loadArr.length; i++) {
- var j = loadArr[i];
- var param = reqParams[j];
- reqPromise.push(httpRequest.get(param.url, {
- data: param.data
- }));
- newArr.push(loadArr[i]);
- }
- vm.isloading=true
- if (reqPromise.length > 0) {
- Promise.all(reqPromise).then(function (ress) {
- vm.isloading=false
- var res1, res2, res3;
- for (var i = 0; i < loadArr.length; i++) {
- var j = loadArr[i] + 1;
- if (j == 1) {
- res1 = ress[i];
- }
- if (j == 2) {
- res2 = ress[i];
- }
- if (j == 3) {
- res3 = ress[i];
- }
- }
- if (res1 && res1.status == 200) {
- getTopTagDatas(res1.data, vm);
- }
- if (res2 && res2.status == 200) {
- handleSecondPanelData(res2.data, vm);
- }
- if (res3) {
- if (res3.status == 200) {
- listHandle(res3.data, vm);
- } else {
- console.log(res3.msg);
- }
- }
- })
- }
- }
- function handleSecondPanelData(data, vm) {
- var xDatas = [],
- yDatas = [],
- names = [],
- colors = ['#12b7f5'],
- index_names = {
- 'index_99': '未发送量'
- };
- for (var p in data) {
- names.push(index_names[p]);
- var xData = _.map(data[p], function (o) {
- return o.range;
- });
- var yData = _.map(data[p], function (o) {
- return o.amount;
- });
- xDatas.push(xData);
- yDatas.push(yData);
- }
- EventBus.$emit("draw-line-chart", {
- panelName: "未发送量趋势分析",
- quotaNames: names,
- xData: xDatas[0],
- yDatas: yDatas,
- colors: colors,
- markLineValue: null,
- markLineName: "目标量",
- endDate:vm.endDate,
- startDate:vm.startDate
- });
- }
- function listHandle(data, vm) {
- for (i in data) {
- var list = data[i];
- var topArr = [];
- topArr = soreRank(getKeyValueArr(list, 'notPushNum'));
- var arr = _.map(list, function (o, index) {
- var cols = [];
- cols.push(topArr[index])
- cols.push(o.name)
- cols.push(o.notPushNum)
- cols.push(o.amount)
- cols.push(o.notPushRate)
- return {
- rank: topArr[index],
- code: o.code,
- name: o.name,
- cols: cols
- }
- });
- var headers = ["排名", "各区", "未发送量", "生日居民", "未发送率"]; //analysisType=2 为按人口
- if (vm.lowLevel == 2 || vm.level == 3) { //社区
- headers = ["排名", "社区", "未发送量", "生日居民", "未发送率"];
- }
- if (vm.lowLevel == 1 || vm.level == 2) { //团队
- headers = ["排名", "团队", "未发送量", "生日居民", "未发送率"];
- }
- EventBus.$emit("render-area-data", {
- level: vm.level,
- area: vm.area,
- lowLevel: vm.lowLevel,
- headers: headers,
- rows: arr,
- reqList:reqList
- });
- }
- }
- //获取结束时间
- function getEndDate(chooseYear) {
-
- var nowdate = new Date();
- var year = nowdate.getFullYear();
- var month = nowdate.getMonth() + 1;
- var day = nowdate.getDate();
- var endDate = ''
- if(chooseYear < '2022') {
- endDate = new Date((parseInt(chooseYear)+1) + '-06-30');
- }else{
- endDate = new Date((parseInt(chooseYear)) + '-12-31');
- }
- var now = new Date();
-
- if(now <= endDate){
- return now.format("yyyy-MM-dd");
- }else{
- if(chooseYear < '2022') {
- return (parseInt(chooseYear)+1) + '-06-30';
- }else{
- return (parseInt(chooseYear)) + '-12-31';
- }
- }
-
-
- }
|