smfw-comprehensive-analysis.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. var reqList = [{}]; //记录请求的参数和url,用于后退时使用
  2. var colors={"0":"#5b9db5","1":"#ed7d31","2":"#a5a5a5",
  3. "3":"#ffc000","4":"#44c274","5":"#70ad47",
  4. "6":"#255e91","7":"#9e480e","8":"#7e7e7e","9":"#997300","10":"#264478","11":"#43682b","12":"#5b9db5"}
  5. Vue.use(Vuedals.default);
  6. new Vue({
  7. el: "#main",
  8. data: {
  9. isloading:false, //加载中
  10. start:"",
  11. end:"",
  12. dateValue: "",
  13. initDate:"",
  14. pickerOptions: {
  15. disabledDate: function(d) {
  16. return d > new Date();
  17. }
  18. },
  19. pieData:[], //饼图数据
  20. tabnumber:0,
  21. diagnosisList:[], //疾病分析列表
  22. itemList:[], //服务项目列表
  23. drugList:[], //药品分析列表
  24. tabledata0:[], //表格数据
  25. topData:{},
  26. //请求页面所需参数
  27. levelList:[{level:"4",areaLevel:"2"},{level:"3",areaLevel:"3"},{level:"2",areaLevel:"4"}], //两种搜索,地区等级对比
  28. areaLevel:"", // 2、市,3、区,4、社区,5、团队
  29. initareaLevel:"",
  30. initlevel: '',
  31. initarea: '',
  32. level: '',
  33. area: '',
  34. areaTitle: '',
  35. index: '121',
  36. lowLevel: '',
  37. initlowLevel:"",
  38. lowCode: '',
  39. chooseYear: '',
  40. userRole: '',
  41. ptab:"1",
  42. tableParams:[{isloading:false,noMore:false,page:1}, //疾病分析
  43. {isloading:false,noMore:false,page:1},//药品分析
  44. {isloading:false,noMore:false,page:1}], //服务项分析
  45. pieShow:true,
  46. pageSize:100,
  47. reqListLength:1,
  48. },
  49. components: {
  50. vuedals: Vuedals.Component
  51. },
  52. mounted: function () {
  53. var vm=this
  54. //初始化数据
  55. initData(vm);
  56. vm.getData()
  57. vm.bindEvent()
  58. },
  59. methods: {
  60. getData:function(isNext,type){ //是否下转
  61. var vm = this
  62. var params={
  63. areaLevel: vm.areaLevel,
  64. level: vm.level,
  65. area: vm.area,
  66. endDate: vm.start,
  67. startDate: vm.end,
  68. lowLevel: vm.lowLevel
  69. }
  70. _.each(vm.tableParams,function(item,index){
  71. vm.tableParams[index].page=1 //重新搜索时,上边三个表格重新加载
  72. })
  73. loadData([0,1,2,3,4], vm); //刷新数据
  74. if(isNext){
  75. //存储请求所带的参数
  76. reqList.push(params);
  77. vm.reqListLength=reqList.length
  78. }else{
  79. reqList[reqList.length-1]=params
  80. vm.reqListLength=reqList.length
  81. }
  82. },
  83. //加载上边三个表格
  84. loadTableData:function(index){
  85. var vm = this
  86. vm.tableParams[index].isloading=true
  87. vm.tableParams[index].page++
  88. loadData([index], vm); //刷新数据
  89. },
  90. //表格tab切换/下转
  91. getnewdata:function(arg){
  92. var vm = this
  93. vm.lowLevel=arg.lowLevel||""
  94. if(arg.level){
  95. vm.level = arg.level
  96. vm.areaLevel = _.find(vm.levelList,{level:vm.level}).areaLevel
  97. }
  98. if(arg.area){
  99. vm.area = arg.area
  100. }
  101. if(arg.areaTitle){
  102. vm.areaTitle = arg.areaTitle
  103. }
  104. vm.getData(arg.level) //有传level,说明是下转
  105. },
  106. //时间选择
  107. changeDate: function () {
  108. var vm=this
  109. if(vm.dateValue){
  110. if(vm.initDate==vm.dateValue){
  111. vm.end = new Date().format("yyyy-MM-dd");
  112. var start= new Date();
  113. start.setDate(1)
  114. vm.start = start.format("yyyy-MM-dd")
  115. }else{
  116. var year=vm.dateValue.split("-")[0]
  117. var month=vm.dateValue.split("-")[1]
  118. vm.start=new Date(vm.dateValue).format("yyyy-MM-dd")
  119. vm.end=new Date(year,month,0).format("yyyy-MM-dd")
  120. }
  121. //搜索时,取消下转记录
  122. vm.area=vm.initarea
  123. vm.areaLevel=vm.initareaLevel
  124. vm.level=vm.initlevel
  125. vm.lowLevel = vm.initlowLevel
  126. reqList=[{}]; //搜索时清空历史记录,重新搜索
  127. vm.getData()
  128. vm.initTable()
  129. }
  130. },
  131. showTab:function(){
  132. },
  133. backClick:function(){
  134. var vm=this
  135. if (reqList.length == 1) {
  136. history.go(-1);
  137. } else {
  138. var preInfo = reqList.pop();
  139. var info = reqList[reqList.length - 1];
  140. vm.areaLevel = info.areaLevel;
  141. vm.level = info.level;
  142. vm.area = info.area;
  143. vm.lowLevel = info.lowLevel;
  144. vm.getData()
  145. vm.$refs.tableRef0.changeTab({level:vm.level,lowlevel:vm.lowLevel}) //表格tab
  146. }
  147. },
  148. bindEvent:function(){
  149. var vm=this
  150. //监听后退按钮的操作
  151. EventBus.$on("back-click", function (arg) {
  152. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  153. vm.backClick()
  154. });
  155. //监听页面刷新
  156. EventBus.$on("refresh-click", function (arg) {
  157. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  158. loadData([0, 1,2,3,4], vm);
  159. });
  160. $("#main").removeClass("c-hide");
  161. },
  162. initTable:function(){
  163. var vm=this
  164. vm.$refs.tableRef1.initTable({
  165. //表格表头
  166. headers:[{thead:"疾病名称",param:"name",canclick:true,style:{width:'260px'}},{thead:"工单量(个)",param:"orderCount"}],
  167. })
  168. vm.$refs.tableRef2.initTable({
  169. //表格表头
  170. headers:[{thead:"服务项目",param:"name",canclick:true,style:{width:'260px'}},{thead:"使用人数(人)",param:"patientCount"},{thead:"工单量(个)",param:"orderCount"}],
  171. })
  172. vm.$refs.tableRef3.initTable({
  173. //表格表头
  174. headers:[{thead:"药品",param:"name",canclick:true,style:{width:'260px'}},{thead:"使用人数(人)",param:"patientCount"},{thead:"工单量(个)",param:"orderCount"}],
  175. })
  176. vm.$refs.tableRef0.initTable({
  177. tabList:[{name:"各区",level:"4",lowlevel:"3",isShow:true},{name:"社区",level:"3",lowlevel:"2",isShow:true},{name:"团队",level:"2",lowlevel:"1",isShow:true}],
  178. //表格表头
  179. headers:[{thead:"名称",param:"name",canclick:true},{thead:"合计(个)",param:"all"},{thead:"待派单(个)",param:"waitinglist"},{thead:"待接单(个)",param:"waitingorder"},
  180. // {thead:"已接单(个)",param:"waitingservice"},
  181. {thead:"待服务(个)",param:"waitingpay"},{thead:"待评价(个)",param:"waitingcomment"},{thead:"已完成(个)",param:"completed"},{thead:"评价均分(分)",param:"evaluateSplit"}],
  182. tabnumber:vm.tabnumber
  183. })
  184. },
  185. },
  186. })
  187. function initData(vm) {
  188. //获得缓存中缓存的角色权限
  189. var userRole = window.sessionStorage.getItem("selectedRole");
  190. if (!userRole) {
  191. return false;
  192. }
  193. vm.userRole = JSON.parse(userRole);
  194. //level:2、市,3、区,4、社区,5、团队
  195. vm.initareaLevel = vm.areaLevel = vm.userRole.code == '350200' ? 2 : vm.userRole.code.length == 6 ? 3 : 4;
  196. vm.initlevel = vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
  197. // vm.lowLevel = vm.initlowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 2 : 1;
  198. vm.initarea =vm.area = vm.userRole.code;
  199. vm.areaTitle = vm.userRole.name;
  200. vm.tabnumber=vm.areaLevel==4?1:vm.areaLevel==3?2:3 //表格显示的tab数
  201. //初始化时间
  202. var now = new Date();
  203. vm.end = new Date().format("yyyy-MM-dd");
  204. var start= new Date();
  205. start.setDate(1)
  206. vm.start = start.format("yyyy-MM-dd")
  207. vm.initDate=vm.dateValue=now.format("yyyy-MM")
  208. vm.initTable()
  209. }
  210. function initReqParams(vm) {
  211. var reqParam = [{
  212. url: "doctor/statisticAnalyze/getDoorDiagnosisAnalysis", //疾病列表
  213. reqType: 'get',
  214. data:{
  215. area: vm.area,
  216. level: vm.areaLevel, //等级,2市 3区 4社区 5团队
  217. page: vm.tableParams[0].page,
  218. pageSize: vm.pageSize,
  219. startDate:vm.start,
  220. endDate: vm.end
  221. },
  222. },{
  223. url: "doctor/statisticAnalyze/getDoorDrugCodeAnalysis", //药品分析列表
  224. reqType: 'get',
  225. data:{
  226. area: vm.area,
  227. level: vm.areaLevel, //等级,2市 3区 4社区 5团队
  228. page: vm.tableParams[1].page,
  229. pageSize: vm.pageSize,
  230. subjectClass: "010",
  231. startDate:vm.start,
  232. endDate:vm.end,
  233. },
  234. },{
  235. url: "doctor/statisticAnalyze/getDoorDrugCodeAnalysis", //服务项列表
  236. reqType: 'get',
  237. data:{
  238. area: vm.area,
  239. level: vm.areaLevel, //等级,2市 3区 4社区 5团队
  240. page: vm.tableParams[2].page,
  241. pageSize: vm.pageSize,
  242. subjectClass: "020",
  243. startDate:vm.start,
  244. endDate:vm.end,
  245. },
  246. },{
  247. url: "doctor/statisticAnalyze/doorAggregateAnalysis", //头中部数据
  248. reqType: 'get',
  249. data:{
  250. startDate: vm.start,
  251. endDate: vm.end,
  252. area: vm.area,
  253. level: vm.areaLevel, //2、市,3、区,4、社区,5、团队
  254. },
  255. },{
  256. url: "doctor/statisticAnalyze/order_lowlevel_all", //工单列表--表格
  257. reqType: 'get',
  258. data:{
  259. startDate: vm.start,
  260. endDate: vm.end,
  261. area: vm.area,
  262. level: vm.level, //2、市,3、区,4、社区,5、团队
  263. sort: 1,
  264. lowLevel:vm.lowLevel||"", //等级 1:团队 2社区机构 3区级 4市级
  265. },
  266. },]
  267. return reqParam;
  268. }
  269. function loadData(loadArr, vm) {
  270. //获取其他请求的参数
  271. var reqParams = initReqParams(vm),
  272. reqPromise = [],
  273. newArr = []; //记录非顶部请求的请求数组
  274. for (i = 0; i < loadArr.length; i++) {
  275. var j = loadArr[i];
  276. var param = reqParams[j];
  277. reqPromise.push(httpRequest.get(param.url, {
  278. data: param.data
  279. }));
  280. newArr.push(loadArr[i]);
  281. }
  282. vm.isloading=true
  283. if (reqPromise.length > 0) {
  284. Promise.all(reqPromise).then(function (ress) {
  285. var res1, res2, res3, res4, res5;
  286. for (var i = 0; i < loadArr.length; i++) {
  287. var j = loadArr[i] + 1;
  288. if (j == 1) { res1 = ress[i]; }
  289. if (j == 2) { res2 = ress[i]; }
  290. if (j == 3) { res3 = ress[i]; }
  291. if (j == 4) { res4 = ress[i]; }
  292. if (j == 5) { res5 = ress[i]; }
  293. }
  294. if (res4 && res4.status == 200) {
  295. vm.topData=res4.data
  296. // vm.topData.evaluateSplit=parseFloat(vm.topData.evaluateSplit).toFixed(2)
  297. var voucherList=_.map(vm.topData.voucherList,function(item,index){
  298. return {
  299. code:item.slaveKey1,
  300. amount:item.result1,
  301. name:item.slaveKey1Name,
  302. }
  303. })
  304. if(voucherList.length==0||(voucherList.length==1&&!voucherList.name)){
  305. vm.pieShow=false
  306. }else{
  307. vm.pieShow=true
  308. }
  309. setTimeout(function(){
  310. //服务人群分析-饼图
  311. handlePieData({elId:"pieChart",arry: voucherList, title:{},colors: colors,param:"total",position:['30%', '51%']})
  312. },10)
  313. }
  314. if (res5 && res5.status == 200) {
  315. vm.tabledata0=listHandle(res5.data["index_121"],"all", vm);
  316. }
  317. if (res1 && res1.status == 200) {
  318. if(vm.tableParams[0].page==1){
  319. vm.diagnosisList=[]
  320. }
  321. vm.diagnosisList=listHandle(vm.diagnosisList.concat(res1.data),"orderCount",vm)
  322. vm.tableParams[0].isloading=false
  323. if(res1.data.length<vm.pageSize){
  324. vm.tableParams[0].noMore=true
  325. }else{
  326. vm.tableParams[0].noMore=false
  327. }
  328. vm.tableParams[0].isloading=false
  329. }
  330. if (res2 && res2.status == 200) {
  331. if(vm.tableParams[1].page==1){
  332. vm.drugList=[]
  333. }
  334. vm.drugList=listHandle(vm.drugList.concat(res2.data),"orderCount",vm)
  335. vm.tableParams[1].isloading=false
  336. if(res2.data.length< vm.pageSize){
  337. vm.tableParams[1].noMore=true
  338. }else{
  339. vm.tableParams[1].noMore=false
  340. }
  341. vm.tableParams[1].isloading=false
  342. }
  343. if (res3 && res3.status == 200) {
  344. if(vm.tableParams[2].page==1){
  345. vm.itemList=[]
  346. }
  347. vm.itemList=listHandle(vm.itemList.concat(res3.data),"orderCount",vm)
  348. vm.tableParams[2].isloading=false
  349. if(res3.data.length< vm.pageSize){
  350. vm.tableParams[2].noMore=true
  351. }else{
  352. vm.tableParams[2].noMore=false
  353. }
  354. vm.tableParams[0].isloading=false
  355. }
  356. vm.isloading=false
  357. })
  358. }
  359. }
  360. function listHandle(list,param, vm){
  361. var topArr = [];
  362. if(list.length==1&&!list[0].name){
  363. list=[]
  364. }
  365. topArr = soreRank(getKeyValueArr(list, param||"amount"));
  366. var newlist = _.map(list, function(o, index){
  367. o.rank=topArr[index]
  368. return o
  369. });
  370. EventBus.$emit("render-area-data",{
  371. });
  372. return newlist
  373. }