|
@@ -147,7 +147,6 @@ function findLabel(nodes: any[], id: string | number): string {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 收集整棵树的所有节点 key,用于一次性展开整个下拉树
|
|
|
|
|
function collectAllKeys(nodes: any[]): string[] {
|
|
function collectAllKeys(nodes: any[]): string[] {
|
|
|
const keys: string[] = [];
|
|
const keys: string[] = [];
|
|
|
const stack = [...nodes];
|
|
const stack = [...nodes];
|
|
@@ -249,10 +248,8 @@ const handleTimeRangeChange = (day: string, timeRange: [Dayjs, Dayjs] | null) =>
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 为每个日期创建响应式的时间范围值
|
|
|
|
|
const timeRangeValues = ref<Record<string, [Dayjs, Dayjs] | null>>({});
|
|
const timeRangeValues = ref<Record<string, [Dayjs, Dayjs] | null>>({});
|
|
|
|
|
|
|
|
-// 初始化所有日期的时间范围值
|
|
|
|
|
function initTimeRangeValues() {
|
|
function initTimeRangeValues() {
|
|
|
days.forEach(day => {
|
|
days.forEach(day => {
|
|
|
if (!(day in timeRangeValues.value)) {
|
|
if (!(day in timeRangeValues.value)) {
|
|
@@ -261,13 +258,11 @@ function initTimeRangeValues() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 初始化时间范围值
|
|
|
|
|
watch(() => model.value.businessHours, (newVal) => {
|
|
watch(() => model.value.businessHours, (newVal) => {
|
|
|
if (newVal) {
|
|
if (newVal) {
|
|
|
days.forEach(day => {
|
|
days.forEach(day => {
|
|
|
const dayData = newVal[day];
|
|
const dayData = newVal[day];
|
|
|
if (dayData?.enabled) {
|
|
if (dayData?.enabled) {
|
|
|
- // 如果日期已启用,设置时间范围值
|
|
|
|
|
if (dayData?.start && dayData?.end) {
|
|
if (dayData?.start && dayData?.end) {
|
|
|
try {
|
|
try {
|
|
|
timeRangeValues.value[day] = [dayjs(dayData.start, 'HH:mm'), dayjs(dayData.end, 'HH:mm')];
|
|
timeRangeValues.value[day] = [dayjs(dayData.start, 'HH:mm'), dayjs(dayData.end, 'HH:mm')];
|
|
@@ -275,11 +270,9 @@ watch(() => model.value.businessHours, (newVal) => {
|
|
|
timeRangeValues.value[day] = [dayjs('08:00', 'HH:mm'), dayjs('20:00', 'HH:mm')];
|
|
timeRangeValues.value[day] = [dayjs('08:00', 'HH:mm'), dayjs('20:00', 'HH:mm')];
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- // 如果已启用但没有时间,使用默认值
|
|
|
|
|
timeRangeValues.value[day] = [dayjs('08:00', 'HH:mm'), dayjs('20:00', 'HH:mm')];
|
|
timeRangeValues.value[day] = [dayjs('08:00', 'HH:mm'), dayjs('20:00', 'HH:mm')];
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- // 如果未启用,也初始化默认值,以便组件能正常显示
|
|
|
|
|
if (!timeRangeValues.value[day]) {
|
|
if (!timeRangeValues.value[day]) {
|
|
|
timeRangeValues.value[day] = [dayjs('08:00', 'HH:mm'), dayjs('20:00', 'HH:mm')];
|
|
timeRangeValues.value[day] = [dayjs('08:00', 'HH:mm'), dayjs('20:00', 'HH:mm')];
|
|
|
}
|
|
}
|
|
@@ -296,23 +289,6 @@ initTimeRangeValues();
|
|
|
|
|
|
|
|
const formRef = ref<any>(null);
|
|
const formRef = ref<any>(null);
|
|
|
|
|
|
|
|
-// 验证至少选择一个项目类型(实体商品、线下服务、线上权益)
|
|
|
|
|
-// function validateAtLeastOneProjectType() {
|
|
|
|
|
-// const onlineCPTypes = formProps.data?.onlineCPTypes;
|
|
|
|
|
-// const offlineCPTypes = formProps.data?.offlineCPTypes;
|
|
|
|
|
-// const outlineCPTypes = formProps.data?.outlineCPTypes;
|
|
|
|
|
-// const hasOnline = onlineCPTypes && Array.isArray(onlineCPTypes) && onlineCPTypes.length > 0;
|
|
|
|
|
-// const hasOffline = offlineCPTypes && Array.isArray(offlineCPTypes) && offlineCPTypes.length > 0;
|
|
|
|
|
-// const hasOutline = outlineCPTypes && Array.isArray(outlineCPTypes) && outlineCPTypes.length > 0;
|
|
|
|
|
-
|
|
|
|
|
-// if (!hasOnline && !hasOffline && !hasOutline) {
|
|
|
|
|
-// // throw new Error('实体商品、线下服务、线上权益至少选择一项');
|
|
|
|
|
-// notification.warning({
|
|
|
|
|
-// message: '实体商品、线下服务、线上权益至少选择一项',
|
|
|
|
|
-// });
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
// 基础表单项(不包含营业时间)
|
|
// 基础表单项(不包含营业时间)
|
|
|
const baseFormItems = [
|
|
const baseFormItems = [
|
|
|
{
|
|
{
|
|
@@ -436,15 +412,6 @@ const baseFormItems = [
|
|
|
span: 24,
|
|
span: 24,
|
|
|
itemRender: { name: 'VxeInput', props: { placeholder: '请输入', type: 'number', min: 0, max: 100 } },
|
|
itemRender: { name: 'VxeInput', props: { placeholder: '请输入', type: 'number', min: 0, max: 100 } },
|
|
|
},
|
|
},
|
|
|
- // 营业时间
|
|
|
|
|
- // {
|
|
|
|
|
- // field: 'businessTime',
|
|
|
|
|
- // title: '营业时间',
|
|
|
|
|
- // span: 24,
|
|
|
|
|
- // slots: {
|
|
|
|
|
- // default: 'businessHours',
|
|
|
|
|
- // },
|
|
|
|
|
- // },
|
|
|
|
|
// 营业状态 单选,营业、休息、停业
|
|
// 营业状态 单选,营业、休息、停业
|
|
|
{
|
|
{
|
|
|
field: 'businessStatus',
|
|
field: 'businessStatus',
|
|
@@ -459,9 +426,10 @@ const baseFormItems = [
|
|
|
// 营业时间字段
|
|
// 营业时间字段
|
|
|
const businessHoursField = {
|
|
const businessHoursField = {
|
|
|
field: 'businessTime',
|
|
field: 'businessTime',
|
|
|
- title: '*营业时间',
|
|
|
|
|
|
|
+ title: '营业时间',
|
|
|
span: 24,
|
|
span: 24,
|
|
|
slots: {
|
|
slots: {
|
|
|
|
|
+ title: 'businessTimeTitle',
|
|
|
default: 'businessHours',
|
|
default: 'businessHours',
|
|
|
},
|
|
},
|
|
|
} as const;
|
|
} as const;
|
|
@@ -585,12 +553,12 @@ watch(() => formProps.data?.offlineCPTypes, (newVal) => {
|
|
|
const newHasValue = !!(newVal && Array.isArray(newVal) && newVal.length > 0);
|
|
const newHasValue = !!(newVal && Array.isArray(newVal) && newVal.length > 0);
|
|
|
const oldHasValue = !!(prevOfflineCPTypes.value && Array.isArray(prevOfflineCPTypes.value) && prevOfflineCPTypes.value.length > 0);
|
|
const oldHasValue = !!(prevOfflineCPTypes.value && Array.isArray(prevOfflineCPTypes.value) && prevOfflineCPTypes.value.length > 0);
|
|
|
|
|
|
|
|
- // 检测从有值变为空
|
|
|
|
|
|
|
+
|
|
|
if (oldHasValue && !newHasValue) {
|
|
if (oldHasValue && !newHasValue) {
|
|
|
wasCleared = true;
|
|
wasCleared = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 检测从空变为有值(清除后再次选择)
|
|
|
|
|
|
|
+
|
|
|
if (wasCleared && !oldHasValue && newHasValue) {
|
|
if (wasCleared && !oldHasValue && newHasValue) {
|
|
|
resetBusinessHours();
|
|
resetBusinessHours();
|
|
|
wasCleared = false;
|
|
wasCleared = false;
|
|
@@ -600,19 +568,6 @@ watch(() => formProps.data?.offlineCPTypes, (newVal) => {
|
|
|
updateFormItems();
|
|
updateFormItems();
|
|
|
}, { deep: true });
|
|
}, { deep: true });
|
|
|
|
|
|
|
|
-function handleSelect(value: string, node: any, extra: any) {
|
|
|
|
|
- const get = (children?: any[]) => {
|
|
|
|
|
- if (!Array.isArray(children)) return;
|
|
|
|
|
- children.forEach(child => {
|
|
|
|
|
- if (!model.value.collaborateDepts.find((item: any) => item.value === child.value)) {
|
|
|
|
|
- model.value.collaborateDepts.push(child)
|
|
|
|
|
- }
|
|
|
|
|
- get(child.children)
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- get(node.children)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const formEmits: VxeFormListeners<FormModel> = {
|
|
const formEmits: VxeFormListeners<FormModel> = {
|
|
|
submit({ data }) {
|
|
submit({ data }) {
|
|
|
// 验证至少选择一个项目类型
|
|
// 验证至少选择一个项目类型
|
|
@@ -725,7 +680,7 @@ onBeforeMount(async () => {
|
|
|
await getOfflineCPList();
|
|
await getOfflineCPList();
|
|
|
// 初始化线下服务的前一个值
|
|
// 初始化线下服务的前一个值
|
|
|
prevOfflineCPTypes.value = formProps.data?.offlineCPTypes ? [...formProps.data.offlineCPTypes] : undefined;
|
|
prevOfflineCPTypes.value = formProps.data?.offlineCPTypes ? [...formProps.data.offlineCPTypes] : undefined;
|
|
|
- // 初始化表单项
|
|
|
|
|
|
|
+ // 初始化表单
|
|
|
updateFormItems();
|
|
updateFormItems();
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
@@ -740,6 +695,9 @@ onBeforeMount(async () => {
|
|
|
:dropdownMatchSelectWidth="false" :dropdownStyle="{ zIndex: 4000 }" placeholder="请选择" @change="onDeptChange"
|
|
:dropdownMatchSelectWidth="false" :dropdownStyle="{ zIndex: 4000 }" placeholder="请选择" @change="onDeptChange"
|
|
|
@dropdownVisibleChange="onVisibleChange" />
|
|
@dropdownVisibleChange="onVisibleChange" />
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template #businessTimeTitle>
|
|
|
|
|
+ <span style="color: #ff4d4f">*</span>营业时间
|
|
|
|
|
+ </template>
|
|
|
<template #businessHours>
|
|
<template #businessHours>
|
|
|
<div class="business-hours-container">
|
|
<div class="business-hours-container">
|
|
|
<div class="business-hours-header">
|
|
<div class="business-hours-header">
|