mzfRzmx.js 5.7 KB

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