annual-appraisal-report.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. Vue.use(Vuedals.default);
  2. new Vue({
  3. el: "#main",
  4. data: {
  5. height:"",
  6. isloading:false, //加载中
  7. start:"",
  8. end:"",
  9. tabledata:[], //表格数据
  10. levelList:[{level:"4",areaLevel:"2"},{level:"3",areaLevel:"3"},{level:"2",areaLevel:"4"}], //两种搜索,地区等级对比
  11. areaLevel:"", // 2、市,3、区,4、社区,5、团队
  12. initareaLevel:"",
  13. initlevel: '',
  14. initarea: '',
  15. level: '',
  16. area: '',
  17. areaTitle: '',
  18. index: '121',
  19. lowLevel: '',
  20. initlowLevel:"",
  21. years:[],
  22. chooseYear: '',
  23. userRole: '',
  24. tableHeader:[],
  25. pickerOptions:{
  26. disabledDate:function(time) {
  27. return time.getTime() > Date.now()
  28. },
  29. },
  30. radio:'1',
  31. searchJson:{},
  32. currentPage:1,
  33. currentSize:10,
  34. datatotal:0,
  35. rangeList:[],
  36. rangeCode:"",
  37. areaList:[],
  38. areaCode:"",
  39. communityList:[{code:"",name:"全部"}],
  40. communityCode:"",
  41. teamList:[{code:"",name:"全部"}],
  42. teamCode:"",
  43. fullscreenLoading:false,
  44. },
  45. components: {
  46. vuedals: Vuedals.Component
  47. },
  48. watch: {
  49. rangeCode: function (val) {
  50. var vm=this
  51. if(vm.initlevel != 2){
  52. vm.communityCode=""
  53. }
  54. vm.teamCode=""
  55. },
  56. areaCode:function(val){
  57. var vm=this
  58. vm.selChange(3)
  59. },
  60. communityCode:function(val){
  61. var vm=this
  62. vm.selChange(5)
  63. },
  64. },
  65. mounted: function () {
  66. var vm=this
  67. //初始化数据
  68. initData(vm);
  69. vm.height = document.body.offsetHeight - 125
  70. window.onresize = function () {
  71. vm.height = document.body.offsetHeight - 125
  72. console.log(vm.height)
  73. }
  74. vm.listFunction()
  75. },
  76. methods: {
  77. listFunction:function(){
  78. var vm = this
  79. vm.isloading = true
  80. statisticAPI.getAnnualAssessment({
  81. signYear:vm.chooseYear,
  82. team:vm.teamCode,
  83. area:vm.areaCode=="350200"?"":vm.areaCode,
  84. hospital:vm.communityCode,
  85. range:vm.rangeCode,
  86. }).then(function(res){
  87. console.log(res,"年度考核报表")
  88. if(res.status == 200) {
  89. vm.tabledata = res.data
  90. vm.isloading = false
  91. }
  92. })
  93. },
  94. // beforeReq:function(flag){
  95. // var vm=this,startDate="",endDate=""
  96. // if(vm.radio=="1"){
  97. // startDate = getStartDate(vm.chooseYear-1)
  98. // endDate = getEndDate(vm.chooseYear)
  99. // }else{
  100. // if(!vm.start&&!vm.end){
  101. // this.$message({
  102. // message: '请选择创建时间',
  103. // type: 'warning'
  104. // });
  105. // return false
  106. // }else{
  107. // if(vm.start>vm.end){
  108. // this.$message({
  109. // message: '开始时间应早于结束时间',
  110. // type: 'warning'
  111. // });
  112. // return false
  113. // }else{
  114. // startDate = vm.start
  115. // endDate = vm.end
  116. // }
  117. // }
  118. // }
  119. // return {start:startDate,end:endDate}
  120. // },
  121. searchHandle:function(){
  122. var vm = this
  123. vm.listFunction()
  124. // searchJson = vm.beforeReq()
  125. // if(searchJson){
  126. // vm.currentPage = 1
  127. // vm.searchJson = {
  128. // startDate:searchJson.start,
  129. // endDate:searchJson.end,
  130. // range:vm.rangeCode,
  131. // team:vm.teamCode,
  132. // hospital:vm.communityCode,
  133. // area:vm.areaCode=="350200"?"":vm.areaCode,
  134. // size:vm.currentSize,
  135. // page:vm.currentPage,
  136. // }
  137. // vm.getWHFInfoList()
  138. // }
  139. },
  140. getWHFInfoList:function(){
  141. var vm = this
  142. vm.isloading = true
  143. var params=JSON.parse(JSON.stringify(vm.searchJson))
  144. params.page = vm.currentPage
  145. statisticAPI.getWHFInfoList(params).then(function(res){
  146. if(res.status == 200) {
  147. if(res.data){
  148. vm.tabledata = res.data.consultTeams
  149. vm.datatotal = res.data.consultTeamsSize
  150. }
  151. } else {
  152. vm.$message.error(res.msg)
  153. }
  154. vm.isloading = false
  155. })
  156. },
  157. exportHandle:function(){
  158. var vm =this
  159. var vm = this
  160. var areaCode = vm.areaCode=="350200"?"":vm.areaCode
  161. vm.fullscreenLoading = true
  162. if(vm.datatotal.length!=0){
  163. statisticAPI.statisticsExportExportAnnualAssessment({
  164. signYear: vm.chooseYear,
  165. area: areaCode,
  166. hospital: vm.communityCode,
  167. range:vm.rangeCode,
  168. team: vm.teamCode,
  169. },"年度考核报表.xls").then(function(res){
  170. vm.fullscreenLoading = false
  171. // var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
  172. // FileSaver.saveAs(blob, "hello world.txt");
  173. // FileSaver()
  174. })
  175. .catch(function(err){
  176. toastr.info(err)
  177. vm.fullscreenLoading = false
  178. console.error(err)
  179. })
  180. // let str = httpRequest.server + 'statisticsExport/exportAnnualAssessment?signYear='+vm.chooseYear+
  181. // '&team='+vm.teamCode+'&area='+areaCode+'&hospital='+vm.communityCode+'&range='+vm.rangeCode
  182. // window.location.href = str
  183. }
  184. },
  185. backClick:function(){
  186. history.go(-1);
  187. },
  188. bindEvent:function(){
  189. var vm=this
  190. //监听后退按钮的操作
  191. EventBus.$on("back-click", function (arg) {
  192. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  193. vm.backClick()
  194. });
  195. //监听页面刷新
  196. EventBus.$on("refresh-click", function (arg) {
  197. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  198. initData(vm)
  199. });
  200. $("#main").removeClass("c-hide");
  201. },
  202. // handleCurrentChange:function(val) {
  203. // this.currentPage = val
  204. // this.getWHFInfoList()
  205. // },
  206. //获取省市区 type:区3
  207. getDistrict: function(type,code,name) {
  208. var vm=this,list = [],param=""
  209. if(type == 3){
  210. list = [{code:code,name:name}]
  211. param = "area"
  212. }else if(type == 5){
  213. list = [{code:"",name:"全部"}]
  214. param = "community"
  215. }
  216. var params={
  217. type:type,code:code
  218. }
  219. homeAPI.getDistrict(params).then(function(res) {
  220. if(res.status == 200) {
  221. vm[param+"List"]=list.concat(res.list)
  222. vm[param+"Code"]=vm[param+"List"][0].code
  223. } else {
  224. vm.$message.error(res.msg)
  225. }
  226. })
  227. },
  228. selChange:function(type){
  229. var vm=this,name=""
  230. if(type == 3){
  231. vm.initSelOption("community")
  232. vm.initSelOption("team")
  233. vm.getCommunityHospital()
  234. }else if(type == 5){
  235. vm.initSelOption("team")
  236. vm.teamListByArea()
  237. }
  238. },
  239. initSelOption:function(param){
  240. var vm=this
  241. vm[param+"List"]=[{code:"",name:"全部"}]
  242. if(param == "team"){
  243. vm[param+"List"]=[{id:"",name:"全部"}]
  244. }
  245. vm[param+"Code"]=vm[param+"List"][0].code||vm[param+"List"][0].id
  246. },
  247. getCommunityHospital:function() {
  248. var vm=this,list = [{code:"",name:"全部"}],param="community"
  249. homeAPI.getCommunityHospital({area:vm.areaCode=='350200'?"":vm.areaCode}).then(function(res) {
  250. if(res.status == 200) {
  251. vm[param+"List"]=list.concat(res.data)
  252. vm[param+"Code"]=vm[param+"List"][0].code
  253. } else {
  254. vm.$message.error(res.msg)
  255. }
  256. })
  257. },
  258. teamListByArea:function() {
  259. var vm=this,list = [{id:"",name:"全部"}],param="team"
  260. homeAPI.teamListByArea({area:vm.areaCode=='350200'?"":vm.areaCode,hospital:vm.communityCode}).then(function(res) {
  261. if(res.status == 200) {
  262. vm[param+"List"]=list.concat(res.data)
  263. vm[param+"Code"]=vm[param+"List"][0].id
  264. } else {
  265. vm.$message.error(res.msg)
  266. }
  267. })
  268. }
  269. },
  270. })
  271. function initData(vm) {
  272. //获得缓存中缓存的角色权限
  273. var userRole = window.sessionStorage.getItem("selectedRole");
  274. if (!userRole) {
  275. return false;
  276. }
  277. vm.userRole = JSON.parse(userRole);
  278. //level:2、市,3、区,4、社区,5、团队
  279. vm.initareaLevel = vm.areaLevel = vm.userRole.code == '350200' ? 2 : vm.userRole.code.length == 6 ? 3 : 4;
  280. vm.initlevel = vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
  281. // vm.lowLevel = vm.initlowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 2 : 1;
  282. vm.initarea =vm.area = vm.userRole.code;
  283. vm.areaTitle = vm.userRole.name;
  284. vm.rangeList=[{name:"按区",code:"town"},{name:"按社区",code:"hospital"},{name:"按团队",code:"team"}]
  285. if(vm.initlevel == 4){ //市获取区
  286. vm.getDistrict(3,vm.initarea,vm.areaTitle.substr(0,3))
  287. vm.rangeCode = vm.rangeList[0].code
  288. }else if(vm.initlevel == 3){ //区获取社区
  289. vm.areaList = [{code:vm.initarea,name:vm.areaTitle}]
  290. vm.areaCode = vm.initarea
  291. vm.rangeCode = vm.rangeList[0].code
  292. }else if(vm.initlevel == 2){ //社区获取团队
  293. vm.communityList = [{code:vm.initarea,name:vm.areaTitle}]
  294. vm.communityCode = vm.initarea
  295. vm.rangeList.shift()
  296. vm.rangeCode = vm.rangeList[0].code
  297. }
  298. vm.searchJson.range = vm.rangeCode
  299. //初始化时间
  300. var now = new Date();
  301. vm.end = now.format("yyyy-MM-dd")
  302. var start = now.getTime() - 30*24*60*60*1000
  303. vm.start = new Date(start).format("yyyy-MM-dd")
  304. vm.nowyear = vm.chooseYear = now.getFullYear()
  305. vm.nowmonth = now.getMonth()+1
  306. vm.years = []
  307. for(i=vm.nowyear; i>=2016; i--){
  308. vm.years.push(i)
  309. }
  310. vm.tabledata = []
  311. vm.bindEvent()
  312. }