var template = ''
$.ajax('../html/mzfRzjd.html',{
data: {},
dataType: 'html',
cache: false,
timeout: 60000,
async: false,
error: function(res) {
},
success: function(res) {
template = res
}
})
Vue.component('mzf-rzjd', {
props: [],
template: template,
data: function() {
return {
mzfRzjdData:[],
testArr1: [],
testArr2: [],
testPosition1: 0,
testPosition2: 0,
list:[],
startTime:new Date('2023','05','26'),
endTime:new Date(),
regionList:[],
regionData:[
{label:'全市',id:'1',type:'1'}
],
regionListList:[],
tertiaryHospitalsData:[
{label:'全部',id:'1',type:'2'}
],
communityHospitalsList:[],
communityHospitalsData:[
{label:'全部',id:'1',type:'3'}
],
groupingList:[],
groupingData:[
{label:'全部',id:'1',type:'4'}
],
administrationStatusList:[],
administrationStatusData:[
{label:'全部',id:'1',type:'5'}
],
show:false,
showTwo:false,
showThree:false,
currentPage:1,
currentSize:10,
datatotal:0, //总数
loadingTwo:false,
setDisabled:{
disabledDate:function(time) {
return time.getTime() < new Date('2023','05','26') || time.getTime() > Date.now();
}
},
s:'',
e:'',
}
},
created: function(){
this.s = this.startTime.format('yyyy-MM-dd')
this.e = this.endTime.format('yyyy-MM-dd')
this.list.unshift({type:'0',id:'time',label:this.s +"~"+ this.e})
this.getCopdEntryData()
},
watch:{
'startTime':{
handler:function(o) {
if(!o) {
this.list.splice(0,1)
}
},
deep: true,
immediate: true
},
'endTime':{
handler:function(o) {
if(!o) {
this.list.splice(0,1)
}
},
deep: true,
immediate: true
},
},
methods: {
getCopdEntryData:function() {
var vm = this
vm.loadingTwo = true
var data = {
startTime:this.startTime.format('yyyy-MM-dd'),
endTime:this.endTime.format('yyyy-MM-dd')
}
statisticAPI.getCopdEntryData({
jsonStr:JSON.stringify(data)
}).then(function(res){
if(res.status == 200) {
console.log(res,'入组随访计划');
vm.loadingTwo = false
vm.mzfRzjdData = res.data
vm.getSpanArr(vm.mzfRzjdData)
}
}).catch(function(err){
vm.loadingTwo = false
})
},
startTimeChange:function(o) {
if(!this.list[0] || this.list[0].type!=0) {
this.list.unshift({type:'0',id:'time',label:o.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')})
}else{
this.list[0].label = o.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')
}
},
endTimeChange:function(o) {
if(!this.list[0] || this.list[0].type!=0) {
this.list.unshift({type:'0',id:'time',label:this.startTime.format('yyyy-MM-dd') +"~"+ o.format('yyyy-MM-dd')})
}else{
this.list[0].label = this.startTime.format('yyyy-MM-dd') +"~"+ o.format('yyyy-MM-dd')
}
},
deleteClick:function(item) {
if(item.id == "time") {
this.startTime = ''
this.endTime = ''
this.list.splice(0,1)
}
var index = this.list.findIndex(function(v){
return item.id == v.id
})
this.list.splice(index,1)
},
// 下一页 上一页
handleCurrentChange:function(val) {
var vm = this
vm.currentPage = val
},
change:function(val) {
this.list = this.list.concat(val)
},
// 确定
confirm:function() {
this.getCopdEntryData()
},
// 取消
// cancel:function() {
// this.startTime = new Date('2023','05','26')
// this.endTime = new Date()
// if(!this.list[0] || this.list[0].type!=0) {
// this.list.unshift({type:'0',id:'time',label:this.startTime.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')})
// }else{
// this.list[0].label = this.startTime.format('yyyy-MM-dd') +"~"+ this.endTime.format('yyyy-MM-dd')
// }
// },
// 导出
exportHandle:function() {
var vm = this
vm.loadingTwo = true
var data = {
startTime:this.startTime.format('yyyy-MM-dd'),
endTime:this.endTime.format('yyyy-MM-dd')
}
var jsonStr = JSON.stringify(data)
statisticAPI.exportCopdEntryData({
jsonStr: encodeURIComponent(jsonStr)
},'慢阻肺入组进度.xls').then(function(res){
vm.loadingTwo = false
})
},
//表格合并单元格跨行,实现首列根据不同类型进行跨行
getSpanArr: function(data) {
this.spanArr = []
for (var i = 0; i < data.length; i++) {
if (i === 0) {
this.spanArr.push(1);
this.podds = 0
} else {
/*判断当前元素与上一个元素type值是否相同
*相同就+1,代表需要合并的行+1
*/
if (data[i].areaName === data[i - 1].areaName) {
this.spanArr[this.podds] += 1;
this.spanArr.push(0);
} else {
this.spanArr.push(1);
this.podds = i;
}
}
}
},
//得到行、列的合并值
objectSpanMethod: function({row, column, rowIndex, columnIndex}) {
if (columnIndex === 0) {
const _rows = this.spanArr[rowIndex];
const _cols = _rows > 0 ? 1 : 0;
return {
rowspan: _rows, //跨的行合并数
colspan: _cols //跨的列合并数
}
}
},
}
})