consult-not-reply.js 8.2 KB

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