|
@@ -470,16 +470,10 @@
|
|
|
<el-date-picker
|
|
<el-date-picker
|
|
|
size="small"
|
|
size="small"
|
|
|
v-model="form.startTime"
|
|
v-model="form.startTime"
|
|
|
- @change="timeChange"
|
|
|
|
|
|
|
+ @change="onStartTimeChange"
|
|
|
type="datetime"
|
|
type="datetime"
|
|
|
format="yyyy-MM-dd HH:mm:ss"
|
|
format="yyyy-MM-dd HH:mm:ss"
|
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
- :picker-options="{
|
|
|
|
|
- timePickerOptions: {
|
|
|
|
|
- selectableRange: '00:00:00 - 23:59:59',
|
|
|
|
|
- format: 'HH:mm:ss',
|
|
|
|
|
- },
|
|
|
|
|
- }"
|
|
|
|
|
placeholder="选择开始时间"
|
|
placeholder="选择开始时间"
|
|
|
>
|
|
>
|
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
@@ -495,13 +489,8 @@
|
|
|
type="datetime"
|
|
type="datetime"
|
|
|
format="yyyy-MM-dd HH:mm:ss"
|
|
format="yyyy-MM-dd HH:mm:ss"
|
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
- :picker-options="{
|
|
|
|
|
- timePickerOptions: {
|
|
|
|
|
- selectableRange: '00:00:00 - 23:59:59',
|
|
|
|
|
- format: 'HH:mm:ss',
|
|
|
|
|
- },
|
|
|
|
|
- }"
|
|
|
|
|
- placeholder="视屏播放结束"
|
|
|
|
|
|
|
+ :disabled="form.liveType == 2"
|
|
|
|
|
+ :placeholder="form.liveType == 2 ? '根据视频时长自动计算' : '选择结束时间'"
|
|
|
>
|
|
>
|
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -830,30 +819,31 @@ export default {
|
|
|
watch: {
|
|
watch: {
|
|
|
"form.startTime": {
|
|
"form.startTime": {
|
|
|
handler(newVal) {
|
|
handler(newVal) {
|
|
|
- // 1. 若 startTime 为空,直接返回(避免无效处理)
|
|
|
|
|
- if (!newVal) return;
|
|
|
|
|
|
|
+ if (!newVal || typeof newVal !== "string") return;
|
|
|
|
|
+ // 已是 :01 结尾则不再回写,避免干扰日期选择器导致无法改时间
|
|
|
|
|
+ if (/:\d{2}$/.test(newVal) && newVal.slice(-2) === "01") return;
|
|
|
|
|
|
|
|
- // 2. 将字符串时间转为 Date 对象(处理 "yyyy-MM-dd HH:mm:ss" 格式)
|
|
|
|
|
- const timeObj = new Date(newVal);
|
|
|
|
|
- // 兼容时间解析失败的情况(如格式错误)
|
|
|
|
|
|
|
+ const normalized = newVal.replace("T", " ").substring(0, 19);
|
|
|
|
|
+ const timeObj = new Date(normalized.replace(/-/g, "/"));
|
|
|
if (isNaN(timeObj.getTime())) return;
|
|
if (isNaN(timeObj.getTime())) return;
|
|
|
|
|
|
|
|
- // 3. 强制将秒数设为 1 并补零(即 01 秒)
|
|
|
|
|
- timeObj.setSeconds(1); // 固定秒数为 1
|
|
|
|
|
- const formattedSeconds = this.pad(timeObj.getSeconds()); // 补零为 "01"
|
|
|
|
|
-
|
|
|
|
|
- // 4. 重新拼接完整的时间字符串(保持原格式:yyyy-MM-dd HH:mm:ss)
|
|
|
|
|
- const year = timeObj.getFullYear();
|
|
|
|
|
- const month = this.pad(timeObj.getMonth() + 1); // 月份从 0 开始,需 +1
|
|
|
|
|
- const day = this.pad(timeObj.getDate());
|
|
|
|
|
- const hours = this.pad(timeObj.getHours());
|
|
|
|
|
- const minutes = this.pad(timeObj.getMinutes());
|
|
|
|
|
-
|
|
|
|
|
- // 5. 更新 form.startTime,完成格式强制修正
|
|
|
|
|
- this.form.startTime = `${year}-${month}-${day} ${hours}:${minutes}:${formattedSeconds}`;
|
|
|
|
|
|
|
+ timeObj.setSeconds(1);
|
|
|
|
|
+ const formatted = `${timeObj.getFullYear()}-${this.pad(
|
|
|
|
|
+ timeObj.getMonth() + 1
|
|
|
|
|
+ )}-${this.pad(timeObj.getDate())} ${this.pad(
|
|
|
|
|
+ timeObj.getHours()
|
|
|
|
|
+ )}:${this.pad(timeObj.getMinutes())}:${this.pad(timeObj.getSeconds())}`;
|
|
|
|
|
+ if (formatted !== newVal) {
|
|
|
|
|
+ this.form.startTime = formatted;
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
- immediate: true, // 初始化时立即执行一次(确保初始值也符合格式)
|
|
|
|
|
- deep: false, // startTime 是字符串,无需深度监听
|
|
|
|
|
|
|
+ immediate: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ "form.liveType"(val) {
|
|
|
|
|
+ // 切到录播时,若已有开始时间与时长则重算结束时间
|
|
|
|
|
+ if (val == 2) {
|
|
|
|
|
+ this.timeChange();
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -943,11 +933,16 @@ export default {
|
|
|
},
|
|
},
|
|
|
handleVideoDuration(duration) {
|
|
handleVideoDuration(duration) {
|
|
|
this.form.duration = duration;
|
|
this.form.duration = duration;
|
|
|
|
|
+ this.timeChange();
|
|
|
},
|
|
},
|
|
|
handleVideoChange(videoUrl, lineOne) {
|
|
handleVideoChange(videoUrl, lineOne) {
|
|
|
this.videoUrl = videoUrl;
|
|
this.videoUrl = videoUrl;
|
|
|
this.form.videoUrl = videoUrl;
|
|
this.form.videoUrl = videoUrl;
|
|
|
},
|
|
},
|
|
|
|
|
+ /** 开始时间变更:录播时按视频时长重算结束时间 */
|
|
|
|
|
+ onStartTimeChange() {
|
|
|
|
|
+ this.timeChange();
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
showLivingUrl(row) {
|
|
showLivingUrl(row) {
|
|
|
this.serverName = "";
|
|
this.serverName = "";
|
|
@@ -1071,16 +1066,18 @@ export default {
|
|
|
this.timeChange();
|
|
this.timeChange();
|
|
|
},
|
|
},
|
|
|
timeChange() {
|
|
timeChange() {
|
|
|
- if (!this.form.startTime) return;
|
|
|
|
|
- if (!this.form.duration) return;
|
|
|
|
|
- const startDateTime = new Date(this.form.startTime);
|
|
|
|
|
- // 将视频时长(秒)加到开始时间
|
|
|
|
|
|
|
+ // 仅录播根据视频时长自动计算结束时间
|
|
|
|
|
+ if (this.form.liveType != 2) return;
|
|
|
|
|
+ if (!this.form.startTime || !this.form.duration) return;
|
|
|
|
|
+ const normalized = String(this.form.startTime)
|
|
|
|
|
+ .replace("T", " ")
|
|
|
|
|
+ .substring(0, 19);
|
|
|
|
|
+ const startDateTime = new Date(normalized.replace(/-/g, "/"));
|
|
|
|
|
+ if (isNaN(startDateTime.getTime())) return;
|
|
|
const endDateTime = new Date(
|
|
const endDateTime = new Date(
|
|
|
- startDateTime.getTime() + this.form.duration * 1000
|
|
|
|
|
- ); // 毫秒为单位
|
|
|
|
|
- // 格式化为年月日 时分秒
|
|
|
|
|
|
|
+ startDateTime.getTime() + Number(this.form.duration) * 1000
|
|
|
|
|
+ );
|
|
|
this.form.finishTime = this.formatDate(endDateTime);
|
|
this.form.finishTime = this.formatDate(endDateTime);
|
|
|
- this.$forceUpdate();
|
|
|
|
|
},
|
|
},
|
|
|
// 将秒数转换为时分秒
|
|
// 将秒数转换为时分秒
|
|
|
secondsToTime(seconds) {
|
|
secondsToTime(seconds) {
|