consult-not-reply.js 9.1 KB

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