123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- var reqList = [{}]; //记录请求的参数和url,用于后退时使用
- var colors={"0":"#5b9db5","1":"#ed7d31","2":"#a5a5a5",
- "3":"#ffc000","4":"#44c274","5":"#70ad47",
- "6":"#255e91","7":"#9e480e","8":"#7e7e7e","9":"#997300","10":"#264478","11":"#43682b","12":"#5b9db5"}
- Vue.use(Vuedals.default);
- new Vue({
- el: "#main",
- data: {
- isloading:false, //加载中
- valueName: "",
- optionsName: [{code:"",title:"全部"}],
- valueType:'',
- optionsType:[{name:'全部',code:''},{name:'等级医院',code:'1'},{name:'社区医院',code:'2'}],//预约类型
- dateValue: [],
- pickerOptions: {
- disabledDate: function(d) {
- return d > new Date();
- }
- },
- ptab:"132", //高危/预警人群分析 131性别、132服务类型
- pieData132:[], //饼图数据
- pieData131:[], //饼图数据
- pieShow131:true,
- pieShow132:true,
- tabnumber:0,
- headerList:[],
- tableData:[], //表格数据
- topData:{},
- //请求页面所需参数
- levelList:[{level:"4",areaLevel:"2"},{level:"3",areaLevel:"3"},{level:"2",areaLevel:"4"}], //两种搜索,地区等级对比
- areaLevel:"", // 2、市,3、区,4、社区,5、团队\
- initareaLevel:"",
- initlevel: '',
- initarea: '',
- level: '',
- area: '',
- areaTitle: '',
- index: '3',
- selectedDateType: 1, //折线图坐标值1-日,2-周,3-月
- lowLevel: '',
- lowCode: '',
- chooseYear: '',
- userRole: '',
- reqListLength:1,
- },
- components: {
- vuedals: Vuedals.Component
- },
- mounted: function () {
- var vm=this
- //初始化数据
- initData(vm);
- vm.getOptionsName() //获取搜索疾病列表
- vm.getData()
- vm.bindEvent()
- },
- methods: {
- getData:function(isNext,type){ //是否下转
- var vm = this
- var params={
- areaLevel: vm.areaLevel,
- level: vm.level,
- area: vm.area,
- endDate: vm.dateValue[1],
- startDate: vm.dateValue[0],
- lowLevel: vm.lowLevel
- }
- if(type=="type"){ //改变预约类型,不会更改转诊率和预警率
- loadData([1,2,3,4], vm); //刷新数据
- }else{
- loadData([0,1,2,3,4], vm); //刷新数据
- }
- if(isNext){
- //存储请求所带的参数
- reqList.push(params);
- vm.reqListLength=reqList.length
- }else{
- reqList[reqList.length-1]=params
- vm.reqListLength=reqList.length
- }
- },
- //表格tab切换/下转
- getnewdata:function(arg){
- var vm = this
- vm.lowLevel=arg.lowLevel||""
- if(arg.level){
- vm.level = arg.level
- vm.areaLevel = _.find(vm.levelList,{level:vm.level}).areaLevel
- }
- if(arg.area){
- vm.area = arg.area
- }
- if(arg.areaTitle){
- vm.areaTitle = arg.areaTitle
- }
- vm.getData(arg.level) //有传level,说明是下转
- },
- //时间选择
- changeDate: function (type) {
- var vm=this
- if(vm.dateValue[0]&&vm.dateValue[1]&&vm.dateValue[0]<=vm.dateValue[1]){
- //搜索时,取消下转记录
- vm.area=vm.initarea
- vm.areaLevel=vm.initareaLevel
- vm.level=vm.initlevel
- vm.lowLevel = ""
- reqList=[{}]; //搜索时清空历史记录,重新搜索
- vm.getData(false,type)
- vm.initTable()
- }else{
- vm.$message({
- message: '请完善时间选择',
- type: 'warning'
- });
- }
- },
- //获取疾病筛查表
- getOptionsName:function(){
- var vm=this
- vm.optionsName = [{code:"",title:"全部"}]
- var params={}
- jbscAPI.surveyTemplates(params).then(function(res) {
- if(res.status == 200) {
- vm.optionsName=vm.optionsName.concat(res.data)
- } else {
- vm.$message.error(res.msg)
- }
- })
- },
- //筛查表切换
- seleName:function(){
- var vm=this
- vm.changeDate()
- },
- //预约类型切换
- seleType:function(){
- var vm=this
- vm.changeDate("type")
- },
- //切换饼图
- changePie:function(){
- var vm=this
- if(vm['pieData'+vm.ptab].length==0||(vm['pieData'+vm.ptab].length==1&&!vm['pieData'+vm.ptab].name)){
- vm["pieShow"+vm.ptab]=false
- }else{
- vm["pieShow"+vm.ptab]=true
- }
- setTimeout(function(){
- handlePieData({elId:"pieChart"+vm.ptab,arry: vm['pieData'+vm.ptab], title:{},colors: colors,param:"total"})
- },50)
- },
- backClick:function(){
- var vm=this
- if (reqList.length == 1) {
- history.go(-1);
- } else {
- var preInfo = reqList.pop();
- var info = reqList[reqList.length - 1];
- vm.areaLevel = info.areaLevel;
- vm.level = info.level;
- vm.area = info.area;
- vm.lowLevel = info.lowLevel;
- vm.getData()
-
- vm.$refs.tableRef.changeTab({level:vm.level,lowlevel:vm.lowLevel}) //表格tab
- }
- },
- bindEvent:function(){
- var vm=this
- //监听后退按钮的操作
- EventBus.$on("back-click", function (arg) {
- EventBus.$emit('update-statistics-time', {}); //更新统计时间
- vm.backClick()
- });
- //监听页面刷新
- EventBus.$on("refresh-click", function (arg) {
- EventBus.$emit('update-statistics-time', {}); //更新统计时间
- loadData([0, 1,2,3,4], vm);
- });
- $("#main").removeClass("c-hide");
- },
- initTable:function(){
- var vm=this
- vm.$refs.tableRef.initTable({
- //表格表头 lowlevel等级 1:团队 2社区机构 3区级 4市级
- headers:[{thead:"名称",param:"name",canclick:true},{thead:"居民预约量",param:"reservationTotal1Amount0"},
- {thead:"代预约量",param:"reservationTota2Amount0"},{thead:"预约总量",param:"reservationTotalAmount0"}],
- tabnumber:vm.tabnumber
- })
- },
- },
- })
- function initData(vm) {
- //获得缓存中缓存的角色权限
- var userRole = window.sessionStorage.getItem("selectedRole");
- if (!userRole) {
- return false;
- }
- vm.userRole = JSON.parse(userRole);
- //level:2、市,3、区,4、社区,5、团队
- vm.initareaLevel = vm.areaLevel = vm.userRole.code == '350200' ? 2 : vm.userRole.code.length == 6 ? 3 : 4;
- vm.initlevel = vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
- vm.initarea =vm.area = vm.userRole.code;
- vm.areaTitle = vm.userRole.name;
-
- vm.tabnumber=vm.areaLevel==4?1:vm.areaLevel==3?2:3 //表格显示的tab数
-
- //初始化时间
- var now = new Date();
- vm.dateValue[1] = new Date().format("yyyy-MM-dd");
- var start= new Date();
- start.setDate(1)
- vm.dateValue[0] = start.format("yyyy-MM-dd")
-
- vm.initTable()
- }
- function initReqParams(vm) {
- var param={
- startDate: vm.dateValue[0],
- endDate: vm.dateValue[1],
- area: vm.area,
- level: vm.areaLevel, //2、市,3、区,4、社区,5、团队
- slaveKey1 : vm.valueName, // 问卷标题
- slaveKey2 : vm.valueType, //代预约类型 1、医院2、社区
- }
- var reqParam = [{
- url: "third/surveyStatis/total", //转诊率和预警率
- reqType: 'get',
- data:{},
- },{
- url: "third/surveyStatis/surveyArea", //高危/预警人群分析--饼图
- reqType: 'get',
- data:{},
- }, {
- url: "third/surveyStatis/surveyArea", //高危/预警人群分析--饼图
- reqType: 'get',
- data:{},
- }, {
- url: "third/surveyStatis/line", //预约趋势分析--折线图
- reqType: 'get',
- data:{},
- },{
- url: "third/surveyStatis/lowlevel_all", //预约量分析--表格
- reqType: 'get',
- data:{},
- }];
- _.each(reqParam,function(item,index){
- item.data=JSON.parse(JSON.stringify(param))
- if(index==0){
- reqParam[index].data.index="128" //注释:128预约总量
- }else if(index==1){
- reqParam[index].data.index="131" //131性别、132服务类型
- }else if(index==2){
- reqParam[index].data.index="132" //131性别、132服务类型
- }else if(index==3){
- reqParam[index].data.index="128,129,130" //128预约总量、129居民预约量130,代预约量
- }else if(index==4){
- reqParam[index].data.index="128,129,130" //128预约总量、129居民预约量130,代预约量
- reqParam[index].data.sort= 1
- reqParam[index].data.level= vm.level
- if(vm.lowLevel){
- reqParam[index].data.lowLevel = vm.lowLevel
- }
- }
- })
- return reqParam;
- }
- 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) {
- var res1, res2, res3, res4, res5;
- 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 (j == 4) { res4 = ress[i]; }
- if (j == 5) { res5 = ress[i]; }
- }
- if (res1 && res1.status == 200) {
- vm.topData=res1.data
- }
- if (res2 && res2.status == 200) {
- // res2={"msg":"查询成功!","data":[{"total":100,"code":"1","name":"女"},{"total":200,"code":"2","name":"男"},{"total":30,"code":"3","name":"未知"}],"status":200}
- vm.pieData131=res2.data
- }
- if (res3 && res3.status == 200) {
- // res3={"msg":"查询成功!","data":[{"total":11,"code":"1","name":"普通人群"},{"total":11,"code":"10","name":"重性精神疾病"},{"total":11,"code":"11","name":"残疾人"},{"total":0,"code":"12","name":"结核病"},{"total":0,"code":"3","name":"老年人"},{"total":0,"code":"4","name":"高血压"},{"total":0,"code":"5","name":"糖尿病"},{"total":11,"code":"6","name":"孕产妇"},{"total":0,"code":"7","name":"0-6岁儿童"},{"total":0,"code":"8","name":"贫困人口"},{"total":0,"code":"9","name":"计生特殊人群"}],"status":200}
- vm.pieData132=res3.data
- }
- if (res4 && res4.status == 200) {
- handleSecondPanelData(res4.data, vm);
- }
- if (res5 && res5.status == 200) {
- listHandle(res5.data, vm);;
- }
- vm.changePie()
- vm.isloading=false
- })
- }
- }
- function handleSecondPanelData(data, vm) {
- var xDatas = [],
- yDatas = [],
- names = [],
- colors = ['#12b7f5', '#cd67fd','#FF9526'],
- labels = {'128': '预约总量', '129': '居民预约量', '130': '代预约量'}
- index_names = {'index_128': '预约总量', 'index_129': '居民预约量', 'index_130': '代预约量'};
- for(var p in data){
- names.push(index_names[p]);
- xData = _.map(data[p], function(o){
- return o.range;
- });
- 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,
- selectedDateType: vm.selectedDateType,
- nowlineid : "lineChart",
- noDateType: true,
- chartheight:"322",
- unit:"人次",
- noshowDate:true,
- });
- }
- function listHandle(list, vm){
- var topArr = [];
- if(list.length==1&&!list[0].name){
- list=[]
- }
- topArr = soreRank(getKeyValueArr(list, 'reservationTotalAmount0'));
- vm.tableData = _.map(list, function(o, index){
- o.rank=topArr[index]
- return o
- });
- EventBus.$emit("render-area-data",{
- });
- }
- //获取结束时间
- function getEndDate(chooseYear) {
- chooseYear = parseInt(chooseYear);
- var endDate = new Date((chooseYear + 1) + '-06-29'),
- now = new Date();
- var yesterday = new Date(now.setDate(now.getDate() - 1))
- if (yesterday <= endDate) {
- return yesterday.format("yyyy-MM-dd");
- } else {
- return (chooseYear + 1) + '-06-29';
- }
- }
|