annual-appraisal-report.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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(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. console.error(err)
  177. })
  178. // let str = httpRequest.server + 'statisticsExport/exportAnnualAssessment?signYear='+vm.chooseYear+
  179. // '&team='+vm.teamCode+'&area='+areaCode+'&hospital='+vm.communityCode+'&range='+vm.rangeCode
  180. // window.location.href = str
  181. }
  182. },
  183. backClick:function(){
  184. history.go(-1);
  185. },
  186. bindEvent:function(){
  187. var vm=this
  188. //监听后退按钮的操作
  189. EventBus.$on("back-click", function (arg) {
  190. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  191. vm.backClick()
  192. });
  193. //监听页面刷新
  194. EventBus.$on("refresh-click", function (arg) {
  195. EventBus.$emit('update-statistics-time', {}); //更新统计时间
  196. initData(vm)
  197. });
  198. $("#main").removeClass("c-hide");
  199. },
  200. // handleCurrentChange:function(val) {
  201. // this.currentPage = val
  202. // this.getWHFInfoList()
  203. // },
  204. //获取省市区 type:区3
  205. getDistrict: function(type,code,name) {
  206. var vm=this,list = [],param=""
  207. if(type == 3){
  208. list = [{code:code,name:name}]
  209. param = "area"
  210. }else if(type == 5){
  211. list = [{code:"",name:"全部"}]
  212. param = "community"
  213. }
  214. var params={
  215. type:type,code:code
  216. }
  217. homeAPI.getDistrict(params).then(function(res) {
  218. if(res.status == 200) {
  219. vm[param+"List"]=list.concat(res.list)
  220. vm[param+"Code"]=vm[param+"List"][0].code
  221. } else {
  222. vm.$message.error(res.msg)
  223. }
  224. })
  225. },
  226. selChange:function(type){
  227. var vm=this,name=""
  228. if(type == 3){
  229. vm.initSelOption("community")
  230. vm.initSelOption("team")
  231. vm.getCommunityHospital()
  232. }else if(type == 5){
  233. vm.initSelOption("team")
  234. vm.teamListByArea()
  235. }
  236. },
  237. initSelOption:function(param){
  238. var vm=this
  239. vm[param+"List"]=[{code:"",name:"全部"}]
  240. if(param == "team"){
  241. vm[param+"List"]=[{id:"",name:"全部"}]
  242. }
  243. vm[param+"Code"]=vm[param+"List"][0].code||vm[param+"List"][0].id
  244. },
  245. getCommunityHospital:function() {
  246. var vm=this,list = [{code:"",name:"全部"}],param="community"
  247. homeAPI.getCommunityHospital({area:vm.areaCode=='350200'?"":vm.areaCode}).then(function(res) {
  248. if(res.status == 200) {
  249. vm[param+"List"]=list.concat(res.data)
  250. vm[param+"Code"]=vm[param+"List"][0].code
  251. } else {
  252. vm.$message.error(res.msg)
  253. }
  254. })
  255. },
  256. teamListByArea:function() {
  257. var vm=this,list = [{id:"",name:"全部"}],param="team"
  258. homeAPI.teamListByArea({area:vm.areaCode=='350200'?"":vm.areaCode,hospital:vm.communityCode}).then(function(res) {
  259. if(res.status == 200) {
  260. vm[param+"List"]=list.concat(res.data)
  261. vm[param+"Code"]=vm[param+"List"][0].id
  262. } else {
  263. vm.$message.error(res.msg)
  264. }
  265. })
  266. }
  267. },
  268. })
  269. function initData(vm) {
  270. //获得缓存中缓存的角色权限
  271. var userRole = window.sessionStorage.getItem("selectedRole");
  272. if (!userRole) {
  273. return false;
  274. }
  275. vm.userRole = JSON.parse(userRole);
  276. //level:2、市,3、区,4、社区,5、团队
  277. vm.initareaLevel = vm.areaLevel = vm.userRole.code == '350200' ? 2 : vm.userRole.code.length == 6 ? 3 : 4;
  278. vm.initlevel = vm.level = vm.userRole.code == '350200' ? 4 : vm.userRole.code.length == 6 ? 3 : 2;
  279. // vm.lowLevel = vm.initlowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 2 : 1;
  280. vm.initarea =vm.area = vm.userRole.code;
  281. vm.areaTitle = vm.userRole.name;
  282. vm.rangeList=[{name:"按区",code:"town"},{name:"按社区",code:"hospital"},{name:"按团队",code:"team"}]
  283. if(vm.initlevel == 4){ //市获取区
  284. vm.getDistrict(3,vm.initarea,vm.areaTitle.substr(0,3))
  285. vm.rangeCode = vm.rangeList[0].code
  286. }else if(vm.initlevel == 3){ //区获取社区
  287. vm.areaList = [{code:vm.initarea,name:vm.areaTitle}]
  288. vm.areaCode = vm.initarea
  289. vm.rangeCode = vm.rangeList[0].code
  290. }else if(vm.initlevel == 2){ //社区获取团队
  291. vm.communityList = [{code:vm.initarea,name:vm.areaTitle}]
  292. vm.communityCode = vm.initarea
  293. vm.rangeList.shift()
  294. vm.rangeCode = vm.rangeList[0].code
  295. }
  296. vm.searchJson.range = vm.rangeCode
  297. //初始化时间
  298. var now = new Date();
  299. vm.end = now.format("yyyy-MM-dd")
  300. var start = now.getTime() - 30*24*60*60*1000
  301. vm.start = new Date(start).format("yyyy-MM-dd")
  302. vm.nowyear = vm.chooseYear = now.getFullYear()
  303. vm.nowmonth = now.getMonth()+1
  304. vm.years = []
  305. for(i=vm.nowyear; i>=2016; i--){
  306. vm.years.push(i)
  307. }
  308. vm.tabledata = []
  309. vm.bindEvent()
  310. }