|
|
@@ -44,11 +44,23 @@
|
|
|
@change="handleScheduleTimeChange">
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
+<!-- <el-form-item label="创建时间" prop="createTime">-->
|
|
|
+<!-- <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"-->
|
|
|
+<!-- type="daterange"-->
|
|
|
+<!-- :required="true"-->
|
|
|
+<!-- range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="createChange"></el-date-picker>-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
<el-form-item label="创建时间" prop="createTime">
|
|
|
- <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"
|
|
|
- type="daterange"
|
|
|
- :required="true"
|
|
|
- range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="createChange"></el-date-picker>
|
|
|
+ <el-date-picker
|
|
|
+ v-model="createTime"
|
|
|
+ type="datetimerange"
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ @change="createChange"
|
|
|
+ :default-time="['00:00:00', '23:59:59']"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="最新更新时间" prop="updateTime">
|
|
|
<el-date-picker v-model="updateTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
|
|
|
@@ -262,16 +274,38 @@ export default {
|
|
|
|
|
|
setToday(){
|
|
|
const today = new Date();
|
|
|
- const todayStr = this.formatDate(today);
|
|
|
- this.createTime = [todayStr, todayStr];
|
|
|
- this.queryParams.sTime = todayStr;
|
|
|
- this.queryParams.eTime = todayStr;
|
|
|
+ const todayStart = new Date(today);
|
|
|
+ todayStart.setHours(0, 0, 0, 0);
|
|
|
+ const todayEnd = new Date(today);
|
|
|
+ todayEnd.setHours(23, 59, 59, 999);
|
|
|
+
|
|
|
+ this.createTime = [this.formatDate(todayStart), this.formatDate(todayEnd)];
|
|
|
+ this.queryParams.sTime = this.formatDate(todayStart);
|
|
|
+ this.queryParams.eTime = this.formatDate(todayEnd);
|
|
|
},
|
|
|
formatDate(date) {
|
|
|
- const year = date.getFullYear();
|
|
|
- const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
- const day = String(date.getDate()).padStart(2, '0');
|
|
|
- return `${year}-${month}-${day}`;
|
|
|
+ if (!date) return ''
|
|
|
+
|
|
|
+ // 确保 date 是 Date 对象
|
|
|
+ let dateObj = date
|
|
|
+ if (typeof date === 'string') {
|
|
|
+ dateObj = new Date(date)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果转换失败,返回空字符串
|
|
|
+ if (!(dateObj instanceof Date) || isNaN(dateObj.getTime())) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用更安全的格式化方法
|
|
|
+ const year = dateObj.getFullYear()
|
|
|
+ const month = String(dateObj.getMonth() + 1).padStart(2, '0')
|
|
|
+ const day = String(dateObj.getDate()).padStart(2, '0')
|
|
|
+ const hours = String(dateObj.getHours()).padStart(2, '0')
|
|
|
+ const minutes = String(dateObj.getMinutes()).padStart(2, '0')
|
|
|
+ const seconds = String(dateObj.getSeconds()).padStart(2, '0')
|
|
|
+
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
},
|
|
|
handleClear(){
|
|
|
this.queryUserLoading = false;
|
|
|
@@ -311,35 +345,58 @@ export default {
|
|
|
this.videoList=response.list
|
|
|
});
|
|
|
},
|
|
|
- createChange() {
|
|
|
- if (this.createTime != null) {
|
|
|
- const startDate = new Date(this.createTime[0]);
|
|
|
- const endDate = new Date(this.createTime[1]);
|
|
|
- const timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
|
|
|
- const diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
|
|
-
|
|
|
- // 限制时间区间为一个月
|
|
|
- if (diffDays >= 31) {
|
|
|
- this.$message.warning('创建时间区间不能超过一个月');
|
|
|
+ checkDateRangeLimit(dateRange) {
|
|
|
+ if (dateRange && dateRange.length >= 2) {
|
|
|
+ const startDate = new Date(dateRange[0]);
|
|
|
+ const endDate = new Date(dateRange[1]);
|
|
|
+
|
|
|
+ // 设置时间为当天开始,避免时间部分影响计算
|
|
|
+ startDate.setHours(0, 0, 0, 0);
|
|
|
+ endDate.setHours(0, 0, 0, 0);
|
|
|
+
|
|
|
+ const timeDiff = Math.abs(endDate - startDate);
|
|
|
+ const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
|
|
|
+
|
|
|
+ if (diffDays > 31) { // maxDays-1 因为包含起始日
|
|
|
+ this.$message.warning('时间区间不能超过一个月');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ createChange(createTime) {
|
|
|
+ if (createTime && createTime.length >= 2) {
|
|
|
+ if(!this.checkDateRangeLimit(createTime)){
|
|
|
this.createTime = null;
|
|
|
- this.queryParams.sTime = null;
|
|
|
- this.queryParams.eTime = null;
|
|
|
+ this.queryParams.sTime=null;
|
|
|
+ this.queryParams.eTime=null;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- this.queryParams.sTime = this.createTime[0];
|
|
|
- this.queryParams.eTime = this.createTime[1];
|
|
|
+ // this.createTimeText = this.formatDateRange(createTime);
|
|
|
+ this.queryParams.sTime = this.formatDate(createTime[0]) || null;
|
|
|
+ this.queryParams.eTime = this.formatDate(createTime[1]) || null;
|
|
|
} else {
|
|
|
+ this.createTimeText = '';
|
|
|
this.queryParams.sTime = null;
|
|
|
this.queryParams.eTime = null;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- updateChange(){
|
|
|
- if (this.updateTime != null) {
|
|
|
- this.queryParams.upSTime = this.updateTime[0];
|
|
|
- this.queryParams.upETime = this.updateTime[1];
|
|
|
+ updateChange(updateTime){
|
|
|
+ if (updateTime && updateTime.length >= 2) {
|
|
|
+ if(!this.checkDateRangeLimit(updateTime)){
|
|
|
+ this.updateTime = null;
|
|
|
+ this.queryParams.upSTime=null;
|
|
|
+ this.queryParams.upETime=null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // this.updateTime = this.formatDateRange(updateTime);
|
|
|
+ this.queryParams.upSTime = updateTime[0] || null;
|
|
|
+ this.queryParams.upETime = updateTime[1] || null;
|
|
|
} else {
|
|
|
+ this.updateTime = [];
|
|
|
this.queryParams.upSTime = null;
|
|
|
this.queryParams.upETime = null;
|
|
|
}
|
|
|
@@ -356,9 +413,11 @@ export default {
|
|
|
/** 查询短链课程看课记录列表 */
|
|
|
getList() {
|
|
|
|
|
|
- // xgb 看课数据量太大必须限制时间
|
|
|
- if (!this.createTime) {
|
|
|
- this.$message.warning('请选择创建时间');
|
|
|
+ // xgb 看课数据量太大必须限制时间if (this.isEmptyArray(this.createTime) &&
|
|
|
+ if (this.isEmptyArray(this.createTime) &&
|
|
|
+ this.isEmptyArray(this.updateTime) &&
|
|
|
+ this.isEmptyArray(this.scheduleTime)) {
|
|
|
+ this.$message.warning('请选择创建时间或营期时间或最新更新时间');
|
|
|
return;
|
|
|
}
|
|
|
this.loading = true;
|
|
|
@@ -370,7 +429,10 @@ export default {
|
|
|
this.courseWatchLogList = response.rows;
|
|
|
this.total = response.total;
|
|
|
this.loading = false;
|
|
|
- });
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
},
|
|
|
// 取消按钮
|
|
|
cancel() {
|
|
|
@@ -479,10 +541,17 @@ export default {
|
|
|
this.msgSuccess("删除成功");
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
+ // 添加辅助方法
|
|
|
+ isEmptyArray(arr) {
|
|
|
+ return !arr || arr.length === 0;
|
|
|
+ },
|
|
|
/** 导出按钮操作 */
|
|
|
handleExport() {
|
|
|
- if (!this.createTime) {
|
|
|
- this.$message.warning('请选择创建时间');
|
|
|
+ // xgb 看课数据量太大必须限制时间
|
|
|
+ if (this.isEmptyArray(this.createTime) &&
|
|
|
+ this.isEmptyArray(this.updateTime) &&
|
|
|
+ this.isEmptyArray(this.scheduleTime)) {
|
|
|
+ this.$message.warning('请选择创建时间或营期时间或最新更新时间');
|
|
|
return;
|
|
|
}
|
|
|
const queryParams = this.queryParams;
|
|
|
@@ -498,11 +567,20 @@ export default {
|
|
|
this.exportLoading = false;
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
- handleScheduleTimeChange(val) {
|
|
|
- if (val) {
|
|
|
- this.queryParams.scheduleStartTime = val[0];
|
|
|
- this.queryParams.scheduleEndTime = val[1];
|
|
|
+ handleScheduleTimeChange(scheduleTime) {
|
|
|
+ if (scheduleTime && scheduleTime.length >= 2) {
|
|
|
+ if(!this.checkDateRangeLimit(scheduleTime)){
|
|
|
+ this.scheduleTime = null;
|
|
|
+ this.queryParams.scheduleStartTime=null;
|
|
|
+ this.queryParams.scheduleStartTime=null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // this.scheduleTime = this.formatDateRange(scheduleTime);
|
|
|
+ this.queryParams.scheduleStartTime = scheduleTime[0] || null;
|
|
|
+ this.queryParams.scheduleEndTime = scheduleTime[1] || null;
|
|
|
} else {
|
|
|
+ this.scheduleTime = [];
|
|
|
this.queryParams.scheduleStartTime = null;
|
|
|
this.queryParams.scheduleEndTime = null;
|
|
|
}
|