consult-not-reply.js 8.8 KB

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