mzfSfjd.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. var template = ''
  2. $.ajax('../html/mzfSfjd.html',{
  3. data: {},
  4. dataType: 'html',
  5. cache: false,
  6. timeout: 60000,
  7. async: false,
  8. error: function(res) {
  9. },
  10. success: function(res) {
  11. template = res
  12. }
  13. })
  14. Vue.component('mzf-sfjd', {
  15. props: [],
  16. template: template,
  17. data: function() {
  18. return {
  19. mzfSfjdData:[],
  20. list:[],
  21. startTime:new Date('2023','05','26'),
  22. endTime:new Date(),
  23. regionList:[],
  24. regionData:[
  25. {label:'全市',id:'1',type:'1'}
  26. ],
  27. regionListList:[],
  28. tertiaryHospitalsData:[
  29. {label:'全部',id:'1',type:'2'}
  30. ],
  31. communityHospitalsList:[],
  32. communityHospitalsData:[
  33. {label:'全部',id:'1',type:'3'}
  34. ],
  35. groupingList:[],
  36. groupingData:[
  37. {label:'全部',id:'1',type:'4'}
  38. ],
  39. administrationStatusList:[],
  40. administrationStatusData:[
  41. {label:'全部',id:'1',type:'5'}
  42. ],
  43. show:false,
  44. showTwo:false,
  45. showThree:false,
  46. currentPage:1,
  47. currentSize:10,
  48. datatotal:0, //总数
  49. loadingTwo:false,
  50. setDisabled:{
  51. disabledDate:function(time) {
  52. return time.getTime() < new Date('2023','05','26') || time.getTime() > Date.now();
  53. }
  54. },
  55. s:'',
  56. e:'',
  57. mergeObj: {},
  58. mergeArr: ['areaName', 'gradeHospitalName', 'groupName',],
  59. }
  60. },
  61. created: function(){
  62. this.s = this.startTime.format('yyyy-MM-dd')
  63. this.e = this.endTime.format('yyyy-MM-dd')
  64. this.list.unshift({type:'0',id:'time',label:this.s +"~"+ this.e})
  65. this.getCopdFollowData()
  66. },
  67. watch:{
  68. 'startTime':{
  69. handler:function(o) {
  70. if(!o) {
  71. this.list.splice(0,1)
  72. }
  73. },
  74. deep: true,
  75. immediate: true
  76. },
  77. 'endTime':{
  78. handler:function(o) {
  79. if(!o) {
  80. this.list.splice(0,1)
  81. }
  82. },
  83. deep: true,
  84. immediate: true
  85. },
  86. },
  87. methods: {
  88. getCopdFollowData:function() {
  89. var vm = this
  90. vm.loadingTwo = true
  91. var data = {
  92. startTime:this.startTime.format('yyyy-MM-dd'),
  93. endTime:this.endTime.format('yyyy-MM-dd')
  94. }
  95. statisticAPI.getCopdFollowData({
  96. jsonStr:JSON.stringify(data)
  97. }).then(function(res){
  98. if(res.status == 200) {
  99. vm.loadingTwo = false
  100. console.log(res, 'sfjd');
  101. vm.mzfSfjdData = res.data
  102. vm.getSpanArr(vm.mzfSfjdData)
  103. }
  104. }).catch(function(err){
  105. vm.loadingTwo = false
  106. })
  107. },
  108. startTimeChange:function(o) {
  109. if(!this.list[0] || this.list[0].type!=0) {
  110. this.list.unshift({type:'0',id:'time',label:o.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')})
  111. }else{
  112. this.list[0].label = o.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')
  113. }
  114. },
  115. endTimeChange:function(o) {
  116. if(!this.list[0] || this.list[0].type!=0) {
  117. this.list.unshift({type:'0',id:'time',label:this.startTime.format('yyyy-MM-dd') +"~"+ o.format('yyyy-MM-dd')})
  118. }else{
  119. this.list[0].label = this.startTime.format('yyyy-MM-dd') +"~"+ o.format('yyyy-MM-dd')
  120. }
  121. },
  122. deleteClick:function(item) {
  123. if(item.id == "time") {
  124. this.startTime = ''
  125. this.endTime = ''
  126. this.list.splice(0,1)
  127. }
  128. var index = this.list.findIndex(function(v){
  129. return item.id == v.id
  130. })
  131. this.list.splice(index,1)
  132. },
  133. // 下一页 上一页
  134. handleCurrentChange:function(val) {
  135. var vm = this
  136. vm.currentPage = val
  137. },
  138. change:function(val) {
  139. this.list = this.list.concat(val)
  140. },
  141. // 确定
  142. confirm:function() {
  143. this.getCopdFollowData()
  144. },
  145. // 取消
  146. cancel:function() {
  147. this.startTime = new Date('2023','05','26')
  148. this.endTime = new Date()
  149. if(!this.list[0] || this.list[0].type!=0) {
  150. this.list.unshift({type:'0',id:'time',label:this.startTime.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')})
  151. }else{
  152. this.list[0].label = this.startTime.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')
  153. }
  154. },
  155. // 导出 慢阻肺随访进度
  156. exportHandle:function() {
  157. var vm = this
  158. vm.loadingTwo = true
  159. var data = {
  160. startTime:this.startTime.format('yyyy-MM-dd'),
  161. endTime:this.endTime.format('yyyy-MM-dd')
  162. }
  163. var jsonStr = JSON.stringify(data)
  164. statisticAPI.exportCopdFollowData({
  165. jsonStr: encodeURIComponent(jsonStr)
  166. },'慢阻肺随访进度.xls').then(function(res){
  167. vm.loadingTwo = false
  168. })
  169. },
  170. getSpanArr(data) {
  171. this.mergeArr.forEach((key, index1) => {
  172. var count = 0; // 用来记录需要合并行的起始位置
  173. this.mergeObj[key] = []; // 记录每一列的合并信息
  174. data.forEach((item, index) => {
  175. // index == 0表示数据为第一行,直接 push 一个 1
  176. if(index === 0) {
  177. this.mergeObj[key].push(1);
  178. } else {
  179. // 判断当前行是否与上一行其值相等 如果相等 在 count 记录的位置其值 +1 表示当前行需要合并 并push 一个 0 作为占位
  180. if(item[key] === data[index - 1][key]) {
  181. this.mergeObj[key][count] += 1;
  182. this.mergeObj[key].push(0);
  183. } else {
  184. // 如果当前行和上一行其值不相等
  185. count = index; // 记录当前位置
  186. this.mergeObj[key].push(1); // 重新push 一个 1
  187. }
  188. }
  189. })
  190. })
  191. },
  192. //得到行、列的合并值
  193. objectSpanMethod: function({row, column, rowIndex, columnIndex}) {
  194. if(this.mergeArr.indexOf(column.property) !== -1) {
  195. // 判断其值是不是为0
  196. if(this.mergeObj[column.property][rowIndex]) {
  197. return [this.mergeObj[column.property][rowIndex], 1]
  198. } else {
  199. // 如果为0则为需要合并的行
  200. return [0, 0];
  201. }
  202. }
  203. },
  204. }
  205. })