@@ -211,6 +219,7 @@
import { smartSentry } from '/@/lib/smart-sentry';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons-vue';
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
+ import dayjs from 'dayjs';
// ------------------------ 事件 ------------------------
@@ -325,7 +334,7 @@
videoNo: undefined, //视频编号
videoStatus: 1, //状态,默认正常
deleteStatus: 0, //删除状态,默认未删除
- pushDate: undefined, //发表时间
+ pushDate: new Date().toISOString().slice(0, 19).replace('T', ' '), //发表时间,默认为当天
isLink: 0, //是否外部链接,0:否 1:是
isLinkUrl: undefined, //外部链接地址
labelList: [], //标签列表
@@ -335,12 +344,82 @@
let form = reactive({ ...formDefault });
- const rules = {
+ // ------------------------ 外部链接相关 ------------------------
+ const isLinkChecked = computed({
+ get: () => form.isLink === 1,
+ set: (value) => {
+ form.isLink = value ? 1 : 0;
+ if (value) {
+ // 选择外部链接时,清空视频编号
+ form.videoNo = undefined;
+ } else {
+ // 不选择外部链接时,清空外部链接地址
+ form.isLinkUrl = undefined;
+ }
+ }
+ });
+
+ const rules = computed(() => ({
videoTitle: [{ required: true, message: '标题 必填' }],
- videoNo: [{ required: true, message: '视频编号 必填' }],
+ videoNo: [{
+ required: !isLinkChecked.value,
+ message: '视频编号 必填',
+ validator: (rule, value) => {
+ if (isLinkChecked.value) {
+ return Promise.resolve();
+ }
+ if (!value || value.trim() === '') {
+ return Promise.reject('视频编号 必填');
+ }
+ return Promise.resolve();
+ }
+ }],
videoStatus: [{ required: true, message: '状态 必填' }],
- pushDate: [{ required: true, message: '发表时间 必填' }],
- };
+ pushDate: [
+ { required: true, message: '发表时间 必填' },
+ {
+ validator: (rule, value) => {
+ if (!value) {
+ return Promise.resolve();
+ }
+ const selectedDate = new Date(value);
+ const currentDate = new Date();
+ // 设置当前时间为当天的23:59:59,允许选择当天
+ currentDate.setHours(23, 59, 59, 999);
+
+ if (selectedDate > currentDate) {
+ return Promise.reject('发表时间不能大于当前时间');
+ }
+ return Promise.resolve();
+ }
+ }
+ ],
+ isLinkUrl: [{
+ required: isLinkChecked.value,
+ message: '外部链接地址 必填',
+ validator: (rule, value) => {
+ if (!isLinkChecked.value) {
+ return Promise.resolve();
+ }
+ if (!value || value.trim() === '') {
+ return Promise.reject('外部链接地址 必填');
+ }
+ return Promise.resolve();
+ }
+ }],
+ authorList: [
+ {
+ required: true,
+ message: '作者 必填',
+ validator: (rule, value) => {
+ if (!value || !Array.isArray(value) || value.length === 0) {
+ return Promise.reject('请至少选择一个作者');
+ }
+ return Promise.resolve();
+ }
+ }
+ ],
+ }));
// 点击确定,验证表单
async function onSubmit() {
@@ -371,17 +450,6 @@
}
}
- // ------------------------ 外部链接相关 ------------------------
- const isLinkChecked = computed({
- get: () => form.isLink === 1,
- set: (value) => {
- form.isLink = value ? 1 : 0;
- if (!value) {
- form.isLinkUrl = undefined;
- }
- }
- });
-
// ------------------------ 标签相关 ------------------------
const selectedLabels = ref([null, null, null]);
const labelOptions = ref([[], [], []]);
@@ -612,6 +680,54 @@
});
}
+ // 禁用未来日期
+ function disabledFutureDate(current) {
+ // 禁用今天之后的日期
+ return current && current > dayjs().endOf('day');
+ }
+
+ // 禁用未来时间
+ function disabledFutureTime(date) {
+ if (date) {
+ const today = dayjs();
+ const selectedDate = dayjs(date);
+
+ // 如果是今天,禁用未来时间
+ if (selectedDate.isSame(today, 'day')) {
+ return {
+ disabledHours: () => {
+ const hours = [];
+ for (let i = today.hour() + 1; i < 24; i++) {
+ hours.push(i);
+ }
+ return hours;
+ },
+ disabledMinutes: (hour) => {
+ if (hour === today.hour()) {
+ const minutes = [];
+ for (let i = today.minute() + 1; i < 60; i++) {
+ minutes.push(i);
+ }
+ return minutes;
+ }
+ return [];
+ },
+ disabledSeconds: (hour, minute) => {
+ if (hour === today.hour() && minute === today.minute()) {
+ const seconds = [];
+ for (let i = today.second() + 1; i < 60; i++) {
+ seconds.push(i);
+ }
+ return seconds;
+ }
+ return [];
+ }
+ };
+ }
+ }
+ return {};
+ }
+
// 暴露方法
defineExpose({
diff --git a/src/views/business/case-clinical-video/case-clinical-video-list.vue b/src/views/business/case-clinical-video/case-clinical-video-list.vue
index cf5cbf5..1565408 100644
--- a/src/views/business/case-clinical-video/case-clinical-video-list.vue
+++ b/src/views/business/case-clinical-video/case-clinical-video-list.vue
@@ -10,14 +10,11 @@
-
+
-
-
-
@@ -107,10 +104,6 @@
/>
-
- {{ text === 1 ? '是' : '否' }}
-
-
{{ text }}
@@ -196,11 +189,6 @@
},
width: 150,
},
- {
- title: '删除状态',
- dataIndex: 'deleteStatus',
- ellipsis: true,
- },
{
title: '阅读量',
dataIndex: 'readNum',
@@ -239,7 +227,6 @@
const queryFormState = {
keywords: undefined, //关键字
videoStatus: undefined, //状态
- deleteStatus: undefined, //删除状态
pageNum: 1,
pageSize: 10,
};
diff --git a/src/views/business/case-exchange/case-exchange-form.vue b/src/views/business/case-exchange/case-exchange-form.vue
index 6ac1147..4d25a64 100644
--- a/src/views/business/case-exchange/case-exchange-form.vue
+++ b/src/views/business/case-exchange/case-exchange-form.vue
@@ -44,7 +44,9 @@
valueFormat="YYYY-MM-DD HH:mm:ss"
v-model:value="form.pushDate"
style="width: 100%"
- placeholder="发表时间"
+ placeholder="发表时间"
+ :disabled-date="disabledFutureDate"
+ :disabled-time="disabledFutureTime"
/>
@@ -222,13 +224,15 @@