annual-appraisal-report.js 9.2 KB

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