Merge remote-tracking branch 'yudao/dev' into dev
This commit is contained in:
@@ -22,6 +22,7 @@ export namespace IoTOtaTaskRecordApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @AI:这里应该拿到 IoTOtaTaskRecordApi 里
|
||||||
/** IoT OTA 升级任务记录 */
|
/** IoT OTA 升级任务记录 */
|
||||||
export interface OtaTaskRecord {
|
export interface OtaTaskRecord {
|
||||||
id?: number;
|
id?: number;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export namespace MallRewardActivityApi {
|
|||||||
export interface RewardActivity {
|
export interface RewardActivity {
|
||||||
id?: number; // 活动编号
|
id?: number; // 活动编号
|
||||||
name?: string; // 活动名称
|
name?: string; // 活动名称
|
||||||
|
status?: number; // 活动状态
|
||||||
startTime?: Date; // 开始时间
|
startTime?: Date; // 开始时间
|
||||||
endTime?: Date; // 结束时间
|
endTime?: Date; // 结束时间
|
||||||
startAndEndTime?: Date[]; // 开始和结束时间(仅前端使用)
|
startAndEndTime?: Date[]; // 开始和结束时间(仅前端使用)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import type { SystemDictTypeApi } from '#/api/system/dict/type';
|
||||||
|
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { buildUUID, cloneDeep } from '@vben/utils';
|
import { buildUUID, cloneDeep } from '@vben/utils';
|
||||||
|
|
||||||
import * as DictDataApi from '#/api/system/dict/type';
|
import { getSimpleDictTypeList } from '#/api/system/dict/type';
|
||||||
import {
|
import {
|
||||||
localeProps,
|
localeProps,
|
||||||
makeRequiredRule,
|
makeRequiredRule,
|
||||||
@@ -18,12 +20,12 @@ export function useDictSelectRule() {
|
|||||||
const rules = cloneDeep(selectRule);
|
const rules = cloneDeep(selectRule);
|
||||||
const dictOptions = ref<{ label: string; value: string }[]>([]); // 字典类型下拉数据
|
const dictOptions = ref<{ label: string; value: string }[]>([]); // 字典类型下拉数据
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const data = await DictDataApi.getSimpleDictTypeList();
|
const data = await getSimpleDictTypeList();
|
||||||
if (!data || data.length === 0) {
|
if (!data || data.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dictOptions.value =
|
dictOptions.value =
|
||||||
data?.map((item: DictDataApi.SystemDictTypeApi.DictType) => ({
|
data?.map((item: SystemDictTypeApi.DictType) => ({
|
||||||
label: item.name,
|
label: item.name,
|
||||||
value: item.type,
|
value: item.type,
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import * as FormApi from '#/api/bpm/form';
|
import { getForm } from '#/api/bpm/form';
|
||||||
import {
|
import {
|
||||||
HttpRequestSetting,
|
HttpRequestSetting,
|
||||||
parseFormFields,
|
parseFormFields,
|
||||||
@@ -229,7 +229,7 @@ watch(
|
|||||||
() => modelData.value.formId,
|
() => modelData.value.formId,
|
||||||
async (newFormId) => {
|
async (newFormId) => {
|
||||||
if (newFormId && modelData.value.formType === BpmModelFormType.NORMAL) {
|
if (newFormId && modelData.value.formType === BpmModelFormType.NORMAL) {
|
||||||
const data = await FormApi.getForm(newFormId);
|
const data = await getForm(newFormId);
|
||||||
const result: Array<{ field: string; title: string }> = [];
|
const result: Array<{ field: string; title: string }> = [];
|
||||||
if (data.fields) {
|
if (data.fields) {
|
||||||
unParsedFormFields.value = data.fields;
|
unParsedFormFields.value = data.fields;
|
||||||
|
|||||||
@@ -284,6 +284,17 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// @jason:看看能不能通过 tailwindcss 简化下
|
// @jason:看看能不能通过 tailwindcss 简化下
|
||||||
|
@keyframes bounce {
|
||||||
|
0%,
|
||||||
|
50% {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.process-definition-container {
|
.process-definition-container {
|
||||||
.definition-item-card {
|
.definition-item-card {
|
||||||
.flow-icon-img {
|
.flow-icon-img {
|
||||||
@@ -310,15 +321,4 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes bounce {
|
|
||||||
0%,
|
|
||||||
100% {
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
50% {
|
|
||||||
transform: translateY(-5px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { FormInstance } from 'ant-design-vue';
|
|||||||
import type { Rule } from 'ant-design-vue/es/form';
|
import type { Rule } from 'ant-design-vue/es/form';
|
||||||
|
|
||||||
import type { BpmProcessInstanceApi } from '#/api/bpm/processInstance';
|
import type { BpmProcessInstanceApi } from '#/api/bpm/processInstance';
|
||||||
|
import type { SystemUserApi } from '#/api/system/user';
|
||||||
|
|
||||||
import { computed, nextTick, reactive, ref, watch } from 'vue';
|
import { computed, nextTick, reactive, ref, watch } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
@@ -42,8 +43,17 @@ import {
|
|||||||
cancelProcessInstanceByStartUser,
|
cancelProcessInstanceByStartUser,
|
||||||
getNextApprovalNodes,
|
getNextApprovalNodes,
|
||||||
} from '#/api/bpm/processInstance';
|
} from '#/api/bpm/processInstance';
|
||||||
import * as TaskApi from '#/api/bpm/task';
|
import {
|
||||||
import * as UserApi from '#/api/system/user';
|
approveTask,
|
||||||
|
copyTask,
|
||||||
|
delegateTask,
|
||||||
|
getTaskListByReturn,
|
||||||
|
rejectTask,
|
||||||
|
returnTask,
|
||||||
|
signCreateTask,
|
||||||
|
signDeleteTask,
|
||||||
|
transferTask,
|
||||||
|
} from '#/api/bpm/task';
|
||||||
import { setConfAndFields2 } from '#/components/form-create';
|
import { setConfAndFields2 } from '#/components/form-create';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
@@ -57,7 +67,7 @@ const props = defineProps<{
|
|||||||
normalFormApi: any; // 流程表单 formCreate Api
|
normalFormApi: any; // 流程表单 formCreate Api
|
||||||
processDefinition: any; // 流程定义信息
|
processDefinition: any; // 流程定义信息
|
||||||
processInstance: any; // 流程实例信息
|
processInstance: any; // 流程实例信息
|
||||||
userOptions: UserApi.SystemUserApi.User[];
|
userOptions: SystemUserApi.User[];
|
||||||
writableFields: string[]; // 流程表单可以编辑的字段
|
writableFields: string[]; // 流程表单可以编辑的字段
|
||||||
}>(); // 当前登录的编号
|
}>(); // 当前登录的编号
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
@@ -249,7 +259,7 @@ async function openPopover(type: string) {
|
|||||||
}
|
}
|
||||||
if (type === 'return') {
|
if (type === 'return') {
|
||||||
// 获取退回节点
|
// 获取退回节点
|
||||||
returnList.value = await TaskApi.getTaskListByReturn(runningTask.value.id);
|
returnList.value = await getTaskListByReturn(runningTask.value.id);
|
||||||
if (returnList.value.length === 0) {
|
if (returnList.value.length === 0) {
|
||||||
message.warning('当前没有可退回的节点');
|
message.warning('当前没有可退回的节点');
|
||||||
return;
|
return;
|
||||||
@@ -375,7 +385,7 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
|
|||||||
await formCreateApi.validate();
|
await formCreateApi.validate();
|
||||||
data.variables = approveForm.value.value;
|
data.variables = approveForm.value.value;
|
||||||
}
|
}
|
||||||
await TaskApi.approveTask(data);
|
await approveTask(data);
|
||||||
popOverVisible.value.approve = false;
|
popOverVisible.value.approve = false;
|
||||||
nextAssigneesActivityNode.value = [];
|
nextAssigneesActivityNode.value = [];
|
||||||
// 清理 Timeline 组件中的自定义审批人数据
|
// 清理 Timeline 组件中的自定义审批人数据
|
||||||
@@ -389,7 +399,7 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
|
|||||||
id: runningTask.value.id,
|
id: runningTask.value.id,
|
||||||
reason: rejectReasonForm.reason,
|
reason: rejectReasonForm.reason,
|
||||||
};
|
};
|
||||||
await TaskApi.rejectTask(data);
|
await rejectTask(data);
|
||||||
popOverVisible.value.reject = false;
|
popOverVisible.value.reject = false;
|
||||||
message.success('审批不通过成功');
|
message.success('审批不通过成功');
|
||||||
}
|
}
|
||||||
@@ -415,7 +425,7 @@ async function handleCopy() {
|
|||||||
reason: copyForm.copyReason,
|
reason: copyForm.copyReason,
|
||||||
copyUserIds: copyForm.copyUserIds,
|
copyUserIds: copyForm.copyUserIds,
|
||||||
};
|
};
|
||||||
await TaskApi.copyTask(data);
|
await copyTask(data);
|
||||||
copyFormRef.value.resetFields();
|
copyFormRef.value.resetFields();
|
||||||
popOverVisible.value.copy = false;
|
popOverVisible.value.copy = false;
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -439,7 +449,7 @@ async function handleTransfer() {
|
|||||||
reason: transferForm.reason,
|
reason: transferForm.reason,
|
||||||
assigneeUserId: transferForm.assigneeUserId,
|
assigneeUserId: transferForm.assigneeUserId,
|
||||||
};
|
};
|
||||||
await TaskApi.transferTask(data);
|
await transferTask(data);
|
||||||
transferFormRef.value.resetFields();
|
transferFormRef.value.resetFields();
|
||||||
popOverVisible.value.transfer = false;
|
popOverVisible.value.transfer = false;
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -463,7 +473,7 @@ async function handleDelegate() {
|
|||||||
reason: delegateForm.reason,
|
reason: delegateForm.reason,
|
||||||
delegateUserId: delegateForm.delegateUserId,
|
delegateUserId: delegateForm.delegateUserId,
|
||||||
};
|
};
|
||||||
await TaskApi.delegateTask(data);
|
await delegateTask(data);
|
||||||
popOverVisible.value.delegate = false;
|
popOverVisible.value.delegate = false;
|
||||||
delegateFormRef.value.resetFields();
|
delegateFormRef.value.resetFields();
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -488,7 +498,7 @@ async function handlerAddSign(type: string) {
|
|||||||
reason: addSignForm.reason,
|
reason: addSignForm.reason,
|
||||||
userIds: addSignForm.addSignUserIds,
|
userIds: addSignForm.addSignUserIds,
|
||||||
};
|
};
|
||||||
await TaskApi.signCreateTask(data);
|
await signCreateTask(data);
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
addSignFormRef.value.resetFields();
|
addSignFormRef.value.resetFields();
|
||||||
popOverVisible.value.addSign = false;
|
popOverVisible.value.addSign = false;
|
||||||
@@ -512,7 +522,7 @@ async function handleReturn() {
|
|||||||
reason: returnForm.returnReason,
|
reason: returnForm.returnReason,
|
||||||
targetTaskDefinitionKey: returnForm.targetTaskDefinitionKey,
|
targetTaskDefinitionKey: returnForm.targetTaskDefinitionKey,
|
||||||
};
|
};
|
||||||
await TaskApi.returnTask(data);
|
await returnTask(data);
|
||||||
popOverVisible.value.return = false;
|
popOverVisible.value.return = false;
|
||||||
returnFormRef.value.resetFields();
|
returnFormRef.value.resetFields();
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -573,7 +583,7 @@ async function handlerDeleteSign() {
|
|||||||
id: deleteSignForm.deleteSignTaskId,
|
id: deleteSignForm.deleteSignTaskId,
|
||||||
reason: deleteSignForm.reason,
|
reason: deleteSignForm.reason,
|
||||||
};
|
};
|
||||||
await TaskApi.signDeleteTask(data);
|
await signDeleteTask(data);
|
||||||
message.success('减签成功');
|
message.success('减签成功');
|
||||||
deleteSignFormRef.value.resetFields();
|
deleteSignFormRef.value.resetFields();
|
||||||
popOverVisible.value.deleteSign = false;
|
popOverVisible.value.deleteSign = false;
|
||||||
|
|||||||
@@ -5,11 +5,18 @@ import { Page } from '@vben/common-ui';
|
|||||||
|
|
||||||
import { Badge, Card, List } from 'ant-design-vue';
|
import { Badge, Card, List } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ClueApi from '#/api/crm/clue';
|
import { getFollowClueCount } from '#/api/crm/clue';
|
||||||
import * as ContractApi from '#/api/crm/contract';
|
import {
|
||||||
import * as CustomerApi from '#/api/crm/customer';
|
getAuditContractCount,
|
||||||
import * as ReceivableApi from '#/api/crm/receivable';
|
getRemindContractCount,
|
||||||
import * as ReceivablePlanApi from '#/api/crm/receivable/plan';
|
} from '#/api/crm/contract';
|
||||||
|
import {
|
||||||
|
getFollowCustomerCount,
|
||||||
|
getPutPoolRemindCustomerCount,
|
||||||
|
getTodayContactCustomerCount,
|
||||||
|
} from '#/api/crm/customer';
|
||||||
|
import { getAuditReceivableCount } from '#/api/crm/receivable';
|
||||||
|
import { getReceivablePlanRemindCount } from '#/api/crm/receivable/plan';
|
||||||
|
|
||||||
import { useLeftSides } from './data';
|
import { useLeftSides } from './data';
|
||||||
import ClueFollowList from './modules/clue-follow-list.vue';
|
import ClueFollowList from './modules/clue-follow-list.vue';
|
||||||
@@ -64,17 +71,14 @@ function sideClick(item: { menu: string }) {
|
|||||||
|
|
||||||
/** 获取数量 */
|
/** 获取数量 */
|
||||||
async function getCount() {
|
async function getCount() {
|
||||||
customerTodayContactCount.value =
|
customerTodayContactCount.value = await getTodayContactCustomerCount();
|
||||||
await CustomerApi.getTodayContactCustomerCount();
|
customerPutPoolRemindCount.value = await getPutPoolRemindCustomerCount();
|
||||||
customerPutPoolRemindCount.value =
|
customerFollowCount.value = await getFollowCustomerCount();
|
||||||
await CustomerApi.getPutPoolRemindCustomerCount();
|
clueFollowCount.value = await getFollowClueCount();
|
||||||
customerFollowCount.value = await CustomerApi.getFollowCustomerCount();
|
contractAuditCount.value = await getAuditContractCount();
|
||||||
clueFollowCount.value = await ClueApi.getFollowClueCount();
|
contractRemindCount.value = await getRemindContractCount();
|
||||||
contractAuditCount.value = await ContractApi.getAuditContractCount();
|
receivableAuditCount.value = await getAuditReceivableCount();
|
||||||
contractRemindCount.value = await ContractApi.getRemindContractCount();
|
receivablePlanRemindCount.value = await getReceivablePlanRemindCount();
|
||||||
receivableAuditCount.value = await ReceivableApi.getAuditReceivableCount();
|
|
||||||
receivablePlanRemindCount.value =
|
|
||||||
await ReceivablePlanApi.getReceivablePlanRemindCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 激活时 */
|
/** 激活时 */
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
|
|||||||
render: (val, data) => {
|
render: (val, data) => {
|
||||||
if (val === 0) {
|
if (val === 0) {
|
||||||
return '正常';
|
return '正常';
|
||||||
} else if (val > 0 && data?.resultCode > 0) {
|
} else if (val > 0 && data?.resultMsg) {
|
||||||
return `失败 | ${val} | ${data.resultMsg}`;
|
return `失败 | ${val} | ${data.resultMsg}`;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ const formData = ref<InfraApiAccessLogApi.ApiAccessLog>();
|
|||||||
const [Descriptions] = useDescription({
|
const [Descriptions] = useDescription({
|
||||||
bordered: true,
|
bordered: true,
|
||||||
column: 1,
|
column: 1,
|
||||||
class: 'mx-4',
|
|
||||||
schema: useDetailSchema(),
|
schema: useDetailSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ const formData = ref<InfraApiErrorLogApi.ApiErrorLog>();
|
|||||||
const [Descriptions] = useDescription({
|
const [Descriptions] = useDescription({
|
||||||
bordered: true,
|
bordered: true,
|
||||||
column: 1,
|
column: 1,
|
||||||
class: 'mx-4',
|
|
||||||
schema: useDetailSchema(),
|
schema: useDetailSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const formData = ref<InfraJobLogApi.JobLog>();
|
|||||||
const [Descriptions] = useDescription({
|
const [Descriptions] = useDescription({
|
||||||
bordered: true,
|
bordered: true,
|
||||||
column: 1,
|
column: 1,
|
||||||
class: 'mx-4',
|
|
||||||
schema: useDetailSchema(),
|
schema: useDetailSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const nextTimes = ref<Date[]>([]); // 下一次执行时间
|
|||||||
const [Descriptions] = useDescription({
|
const [Descriptions] = useDescription({
|
||||||
bordered: true,
|
bordered: true,
|
||||||
column: 1,
|
column: 1,
|
||||||
class: 'mx-4',
|
|
||||||
schema: useDetailSchema(),
|
schema: useDetailSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { getSimpleDeviceGroupList } from '#/api/iot/device/group';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
/** 新增/修改设备分组的表单 */
|
/** 新增/修改设备分组的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
@@ -30,16 +31,15 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
.max(64, '分组名称长度不能超过 64 个字符'),
|
.max(64, '分组名称长度不能超过 64 个字符'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'parentId',
|
fieldName: 'status',
|
||||||
label: '父级分组',
|
label: '分组状态',
|
||||||
component: 'ApiTreeSelect',
|
component: 'RadioGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: getSimpleDeviceGroupList,
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
labelField: 'name',
|
buttonStyle: 'solid',
|
||||||
valueField: 'id',
|
optionType: 'button',
|
||||||
placeholder: '请选择父级分组',
|
|
||||||
allowClear: true,
|
|
||||||
},
|
},
|
||||||
|
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'description',
|
fieldName: 'description',
|
||||||
@@ -65,6 +65,15 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,14 +81,13 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'id',
|
||||||
title: '分组名称',
|
title: 'ID',
|
||||||
minWidth: 200,
|
minWidth: 100,
|
||||||
treeNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'description',
|
field: 'name',
|
||||||
title: '分组描述',
|
title: '分组名称',
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -92,9 +100,9 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'deviceCount',
|
field: 'description',
|
||||||
title: '设备数量',
|
title: '分组描述',
|
||||||
minWidth: 100,
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
@@ -102,6 +110,11 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
minWidth: 180,
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'deviceCount',
|
||||||
|
title: '设备数量',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 200,
|
width: 200,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|||||||
import type { IotDeviceGroupApi } from '#/api/iot/device/group';
|
import type { IotDeviceGroupApi } from '#/api/iot/device/group';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { handleTree } from '@vben/utils';
|
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
@@ -62,24 +61,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
columns: useGridColumns(),
|
columns: useGridColumns(),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
treeConfig: {
|
|
||||||
transform: true,
|
|
||||||
rowField: 'id',
|
|
||||||
parentField: 'parentId',
|
|
||||||
},
|
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async ({ page }, formValues) => {
|
query: async ({ page }, formValues) => {
|
||||||
const data = await getDeviceGroupPage({
|
return await getDeviceGroupPage({
|
||||||
pageNo: page.currentPage,
|
pageNo: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
...formValues,
|
...formValues,
|
||||||
});
|
});
|
||||||
// 转换为树形结构
|
|
||||||
return {
|
|
||||||
...data,
|
|
||||||
list: handleTree(data.list, 'id', 'parentId'),
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const [Form, formApi] = useVbenForm({
|
|||||||
},
|
},
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
showCollapseButton: false,
|
showCollapseButton: false,
|
||||||
|
showDefaultActions: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
@@ -70,9 +71,13 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
formData.value = undefined;
|
formData.value = undefined;
|
||||||
|
formApi.resetForm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置表单
|
||||||
|
await formApi.resetForm();
|
||||||
|
|
||||||
const data = modalApi.getData<IotDeviceGroupApi.DeviceGroup>();
|
const data = modalApi.getData<IotDeviceGroupApi.DeviceGroup>();
|
||||||
// 如果没有数据或没有 id,表示是新增
|
// 如果没有数据或没有 id,表示是新增
|
||||||
if (!data || !data.id) {
|
if (!data || !data.id) {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { formatDate } from '@vben/utils';
|
|||||||
|
|
||||||
import { Card, Col, Descriptions, Row } from 'ant-design-vue';
|
import { Card, Col, Descriptions, Row } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as IoTOtaFirmwareApi from '#/api/iot/ota/firmware';
|
import { getOtaFirmware } from '#/api/iot/ota/firmware';
|
||||||
import * as IoTOtaTaskRecordApi from '#/api/iot/ota/task/record';
|
import { getOtaTaskRecordStatusStatistics } from '#/api/iot/ota/task/record';
|
||||||
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
import OtaTaskList from '../task/OtaTaskList.vue';
|
import OtaTaskList from '../task/OtaTaskList.vue';
|
||||||
@@ -30,7 +30,7 @@ const firmwareStatistics = ref<Record<string, number>>({});
|
|||||||
async function getFirmwareInfo() {
|
async function getFirmwareInfo() {
|
||||||
firmwareLoading.value = true;
|
firmwareLoading.value = true;
|
||||||
try {
|
try {
|
||||||
firmware.value = await IoTOtaFirmwareApi.getOtaFirmware(firmwareId.value);
|
firmware.value = await getOtaFirmware(firmwareId.value);
|
||||||
} finally {
|
} finally {
|
||||||
firmwareLoading.value = false;
|
firmwareLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -40,10 +40,9 @@ async function getFirmwareInfo() {
|
|||||||
async function getStatistics() {
|
async function getStatistics() {
|
||||||
firmwareStatisticsLoading.value = true;
|
firmwareStatisticsLoading.value = true;
|
||||||
try {
|
try {
|
||||||
firmwareStatistics.value =
|
firmwareStatistics.value = await getOtaTaskRecordStatusStatistics(
|
||||||
await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics(
|
firmwareId.value,
|
||||||
firmwareId.value,
|
);
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
firmwareStatisticsLoading.value = false;
|
firmwareStatisticsLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { formatDate } from '@vben/utils';
|
|||||||
|
|
||||||
import { Card, Col, Descriptions, Row } from 'ant-design-vue';
|
import { Card, Col, Descriptions, Row } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as IoTOtaFirmwareApi from '#/api/iot/ota/firmware';
|
import { getOtaFirmware } from '#/api/iot/ota/firmware';
|
||||||
import * as IoTOtaTaskRecordApi from '#/api/iot/ota/task/record';
|
import { getOtaTaskRecordStatusStatistics } from '#/api/iot/ota/task/record';
|
||||||
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
import OtaTaskList from '../task/OtaTaskList.vue';
|
import OtaTaskList from '../task/OtaTaskList.vue';
|
||||||
@@ -30,7 +30,7 @@ const firmwareStatistics = ref<Record<string, number>>({});
|
|||||||
async function getFirmwareInfo() {
|
async function getFirmwareInfo() {
|
||||||
firmwareLoading.value = true;
|
firmwareLoading.value = true;
|
||||||
try {
|
try {
|
||||||
firmware.value = await IoTOtaFirmwareApi.getOtaFirmware(firmwareId.value);
|
firmware.value = await getOtaFirmware(firmwareId.value);
|
||||||
} finally {
|
} finally {
|
||||||
firmwareLoading.value = false;
|
firmwareLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -40,10 +40,9 @@ async function getFirmwareInfo() {
|
|||||||
async function getStatistics() {
|
async function getStatistics() {
|
||||||
firmwareStatisticsLoading.value = true;
|
firmwareStatisticsLoading.value = true;
|
||||||
try {
|
try {
|
||||||
firmwareStatistics.value =
|
firmwareStatistics.value = await getOtaTaskRecordStatusStatistics(
|
||||||
await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics(
|
firmwareId.value,
|
||||||
firmwareId.value,
|
);
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
firmwareStatisticsLoading.value = false;
|
firmwareStatisticsLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,12 @@ import {
|
|||||||
Tag,
|
Tag,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import * as IoTOtaTaskApi from '#/api/iot/ota/task';
|
import { getOtaTask } from '#/api/iot/ota/task';
|
||||||
import * as IoTOtaTaskRecordApi from '#/api/iot/ota/task/record';
|
import {
|
||||||
|
cancelOtaTaskRecord,
|
||||||
|
getOtaTaskRecordPage,
|
||||||
|
getOtaTaskRecordStatusStatistics,
|
||||||
|
} from '#/api/iot/ota/task/record';
|
||||||
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskRecordStatusEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
/** OTA 任务详情组件 */
|
/** OTA 任务详情组件 */
|
||||||
@@ -119,7 +123,7 @@ async function getTaskInfo() {
|
|||||||
}
|
}
|
||||||
taskLoading.value = true;
|
taskLoading.value = true;
|
||||||
try {
|
try {
|
||||||
task.value = await IoTOtaTaskApi.getOtaTask(taskId.value);
|
task.value = await getOtaTask(taskId.value);
|
||||||
} finally {
|
} finally {
|
||||||
taskLoading.value = false;
|
taskLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -132,11 +136,10 @@ async function getStatistics() {
|
|||||||
}
|
}
|
||||||
taskStatisticsLoading.value = true;
|
taskStatisticsLoading.value = true;
|
||||||
try {
|
try {
|
||||||
taskStatistics.value =
|
taskStatistics.value = await getOtaTaskRecordStatusStatistics(
|
||||||
await IoTOtaTaskRecordApi.getOtaTaskRecordStatusStatistics(
|
undefined,
|
||||||
undefined,
|
taskId.value,
|
||||||
taskId.value,
|
);
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
taskStatisticsLoading.value = false;
|
taskStatisticsLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -150,7 +153,7 @@ async function getRecordList() {
|
|||||||
recordLoading.value = true;
|
recordLoading.value = true;
|
||||||
try {
|
try {
|
||||||
queryParams.taskId = taskId.value;
|
queryParams.taskId = taskId.value;
|
||||||
const data = await IoTOtaTaskRecordApi.getOtaTaskRecordPage(queryParams);
|
const data = await getOtaTaskRecordPage(queryParams);
|
||||||
recordList.value = data.list || [];
|
recordList.value = data.list || [];
|
||||||
recordTotal.value = data.total || 0;
|
recordTotal.value = data.total || 0;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -181,7 +184,7 @@ async function handleCancelUpgrade(record: OtaTaskRecord) {
|
|||||||
content: '确认要取消该设备的升级任务吗?',
|
content: '确认要取消该设备的升级任务吗?',
|
||||||
async onOk() {
|
async onOk() {
|
||||||
try {
|
try {
|
||||||
await IoTOtaTaskRecordApi.cancelOtaTaskRecord(record.id!);
|
await cancelOtaTaskRecord(record.id!);
|
||||||
message.success('取消成功');
|
message.success('取消成功');
|
||||||
await getRecordList();
|
await getRecordList();
|
||||||
await getStatistics();
|
await getStatistics();
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { useVbenModal } from '@vben/common-ui';
|
|||||||
|
|
||||||
import { Form, Input, message, Select, Spin } from 'ant-design-vue';
|
import { Form, Input, message, Select, Spin } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as DeviceApi from '#/api/iot/device/device';
|
import { getDeviceListByProductId } from '#/api/iot/device/device';
|
||||||
import * as IoTOtaTaskApi from '#/api/iot/ota/task';
|
import { createOtaTask } from '#/api/iot/ota/task';
|
||||||
import { IoTOtaTaskDeviceScopeEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskDeviceScopeEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
/** IoT OTA 升级任务表单 */
|
/** IoT OTA 升级任务表单 */
|
||||||
@@ -82,7 +82,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
try {
|
try {
|
||||||
await formRef.value.validate();
|
await formRef.value.validate();
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
await IoTOtaTaskApi.createOtaTask(formData.value);
|
await createOtaTask(formData.value);
|
||||||
message.success('创建成功');
|
message.success('创建成功');
|
||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
@@ -98,8 +98,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
// 加载设备列表
|
// 加载设备列表
|
||||||
formLoading.value = true;
|
formLoading.value = true;
|
||||||
try {
|
try {
|
||||||
devices.value =
|
devices.value = (await getDeviceListByProductId(props.productId)) || [];
|
||||||
(await DeviceApi.getDeviceListByProductId(props.productId)) || [];
|
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false;
|
formLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
Tag,
|
Tag,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import * as IoTOtaTaskApi from '#/api/iot/ota/task';
|
import { getOtaTaskPage } from '#/api/iot/ota/task';
|
||||||
import { IoTOtaTaskStatusEnum } from '#/views/iot/utils/constants';
|
import { IoTOtaTaskStatusEnum } from '#/views/iot/utils/constants';
|
||||||
|
|
||||||
import OtaTaskDetail from './OtaTaskDetail.vue';
|
import OtaTaskDetail from './OtaTaskDetail.vue';
|
||||||
@@ -52,7 +52,7 @@ const taskDetailRef = ref(); // 任务详情引用
|
|||||||
async function getTaskList() {
|
async function getTaskList() {
|
||||||
taskLoading.value = true;
|
taskLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const data = await IoTOtaTaskApi.getOtaTaskPage(queryParams);
|
const data = await getOtaTaskPage(queryParams);
|
||||||
taskList.value = data.list;
|
taskList.value = data.list;
|
||||||
taskTotal.value = data.total;
|
taskTotal.value = data.total;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { getSimpleProductCategoryList } from '#/api/iot/product/category';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
/** 新增/修改产品分类的表单 */
|
/** 新增/修改产品分类的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
@@ -19,51 +20,37 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'name',
|
fieldName: 'name',
|
||||||
label: '分类名称',
|
label: '分类名字',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入分类名称',
|
placeholder: '请输入分类名字',
|
||||||
},
|
},
|
||||||
rules: z
|
rules: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, '分类名称不能为空')
|
.min(1, '分类名字不能为空')
|
||||||
.max(64, '分类名称长度不能超过 64 个字符'),
|
.max(64, '分类名字长度不能超过 64 个字符'),
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'parentId',
|
|
||||||
label: '父级分类',
|
|
||||||
component: 'ApiTreeSelect',
|
|
||||||
componentProps: {
|
|
||||||
api: getSimpleProductCategoryList,
|
|
||||||
labelField: 'name',
|
|
||||||
valueField: 'id',
|
|
||||||
placeholder: '请选择父级分类',
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'sort',
|
fieldName: 'sort',
|
||||||
label: '排序',
|
label: '分类排序',
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入排序',
|
placeholder: '请输入分类排序',
|
||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
min: 0,
|
min: 0,
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: z.number().min(0, '分类排序不能为空'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'status',
|
fieldName: 'status',
|
||||||
label: '状态',
|
label: '分类状态',
|
||||||
component: 'RadioGroup',
|
component: 'RadioGroup',
|
||||||
defaultValue: 1,
|
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
{ label: '开启', value: 1 },
|
buttonStyle: 'solid',
|
||||||
{ label: '关闭', value: 0 },
|
optionType: 'button',
|
||||||
],
|
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'description',
|
fieldName: 'description',
|
||||||
@@ -82,10 +69,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
fieldName: 'name',
|
fieldName: 'name',
|
||||||
label: '分类名称',
|
label: '分类名字',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入分类名称',
|
placeholder: '请输入分类名字',
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -94,9 +81,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: ['开始日期', '结束日期'],
|
...getRangePickerDefaultProps(),
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
class: 'w-full',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -114,7 +100,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
field: 'name',
|
field: 'name',
|
||||||
title: '名字',
|
title: '名字',
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
treeNode: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'sort',
|
field: 'sort',
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|||||||
import type { IotProductCategoryApi } from '#/api/iot/product/category';
|
import type { IotProductCategoryApi } from '#/api/iot/product/category';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { handleTree } from '@vben/utils';
|
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
@@ -70,16 +69,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async ({ page }, formValues) => {
|
query: async ({ page }, formValues) => {
|
||||||
const data = await getProductCategoryPage({
|
return await getProductCategoryPage({
|
||||||
pageNo: page.currentPage,
|
pageNo: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
...formValues,
|
...formValues,
|
||||||
});
|
});
|
||||||
// 转换为树形结构
|
|
||||||
return {
|
|
||||||
...data,
|
|
||||||
list: handleTree(data.list, 'id', 'parentId'),
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -91,16 +85,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
refresh: true,
|
refresh: true,
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
treeConfig: {
|
|
||||||
parentField: 'parentId',
|
|
||||||
rowField: 'id',
|
|
||||||
transform: true,
|
|
||||||
expandAll: true,
|
|
||||||
reserve: true,
|
|
||||||
trigger: 'default',
|
|
||||||
iconOpen: '',
|
|
||||||
iconClose: '',
|
|
||||||
},
|
|
||||||
} as VxeTableGridOptions<IotProductCategoryApi.ProductCategory>,
|
} as VxeTableGridOptions<IotProductCategoryApi.ProductCategory>,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -63,13 +63,17 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
formData.value = undefined;
|
formData.value = undefined;
|
||||||
|
formApi.resetForm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
|
||||||
let data = modalApi.getData<
|
// 重置表单
|
||||||
IotProductCategoryApi.ProductCategory & { parentId?: number }
|
await formApi.resetForm();
|
||||||
>();
|
|
||||||
if (!data) {
|
const data = modalApi.getData<IotProductCategoryApi.ProductCategory>();
|
||||||
|
// 如果没有数据或没有 id,表示是新增
|
||||||
|
if (!data || !data.id) {
|
||||||
|
formData.value = undefined;
|
||||||
// 新增模式:设置默认值
|
// 新增模式:设置默认值
|
||||||
await formApi.setValues({
|
await formApi.setValues({
|
||||||
sort: 0,
|
sort: 0,
|
||||||
@@ -77,23 +81,12 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 编辑模式:加载数据
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
if (data.id) {
|
formData.value = await getProductCategory(data.id);
|
||||||
// 编辑模式:加载完整数据
|
await formApi.setValues(formData.value);
|
||||||
data = await getProductCategory(data.id);
|
|
||||||
} else if (data.parentId) {
|
|
||||||
// 新增下级分类:设置父级ID
|
|
||||||
await formApi.setValues({
|
|
||||||
parentId: data.parentId,
|
|
||||||
sort: 0,
|
|
||||||
status: 1,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 设置到 values
|
|
||||||
formData.value = data;
|
|
||||||
await formApi.setValues(data);
|
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
|||||||
import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue';
|
import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
import { getMemberRegisterCountList } from '#/api/mall/statistics/member';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getMemberStatisticsChartOptions,
|
getMemberStatisticsChartOptions,
|
||||||
@@ -71,13 +71,13 @@ async function handleTimeRangeTypeChange() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 发送时间范围选中事件
|
// 发送时间范围选中事件
|
||||||
await getMemberRegisterCountList(beginTime, endTime);
|
await loadMemberRegisterCountList(beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
|
async function loadMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const list = await MemberStatisticsApi.getMemberRegisterCountList(
|
const list = await getMemberRegisterCountList(
|
||||||
beginTime.toDate(),
|
beginTime.toDate(),
|
||||||
endTime.toDate(),
|
endTime.toDate(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import { CountTo } from '@vben/common-ui';
|
|||||||
|
|
||||||
import { Card } from 'ant-design-vue';
|
import { Card } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
import { getTabsCount } from '#/api/mall/product/spu';
|
||||||
import * as PayStatisticsApi from '#/api/mall/statistics/pay';
|
import { getWalletRechargePrice } from '#/api/mall/statistics/pay';
|
||||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
import { getOrderCount } from '#/api/mall/statistics/trade';
|
||||||
|
|
||||||
/** 运营数据卡片 */
|
/** 运营数据卡片 */
|
||||||
defineOptions({ name: 'OperationDataCard' });
|
defineOptions({ name: 'OperationDataCard' });
|
||||||
@@ -51,8 +51,8 @@ const data = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 查询订单数据 */
|
/** 查询订单数据 */
|
||||||
async function getOrderData() {
|
async function loadOrderData() {
|
||||||
const orderCount = await TradeStatisticsApi.getOrderCount();
|
const orderCount = await getOrderCount();
|
||||||
if (orderCount.undelivered) {
|
if (orderCount.undelivered) {
|
||||||
data.orderUndelivered.value = orderCount.undelivered;
|
data.orderUndelivered.value = orderCount.undelivered;
|
||||||
}
|
}
|
||||||
@@ -68,16 +68,16 @@ async function getOrderData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 查询商品数据 */
|
/** 查询商品数据 */
|
||||||
async function getProductData() {
|
async function loadProductData() {
|
||||||
const productCount = await ProductSpuApi.getTabsCount();
|
const productCount = await getTabsCount();
|
||||||
data.productForSale.value = productCount['0'] || 0;
|
data.productForSale.value = productCount['0'] || 0;
|
||||||
data.productInWarehouse.value = productCount['1'] || 0;
|
data.productInWarehouse.value = productCount['1'] || 0;
|
||||||
data.productAlertStock.value = productCount['3'] || 0;
|
data.productAlertStock.value = productCount['3'] || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询钱包充值数据 */
|
/** 查询钱包充值数据 */
|
||||||
async function getWalletRechargeData() {
|
async function loadWalletRechargeData() {
|
||||||
const paySummary = await PayStatisticsApi.getWalletRechargePrice();
|
const paySummary = await getWalletRechargePrice();
|
||||||
data.rechargePrice.value = paySummary.rechargePrice;
|
data.rechargePrice.value = paySummary.rechargePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,16 +88,16 @@ function handleClick(routerName: string) {
|
|||||||
|
|
||||||
/** 激活时 */
|
/** 激活时 */
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
getOrderData();
|
loadOrderData();
|
||||||
getProductData();
|
loadProductData();
|
||||||
getWalletRechargeData();
|
loadWalletRechargeData();
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getOrderData();
|
loadOrderData();
|
||||||
getProductData();
|
loadProductData();
|
||||||
getWalletRechargeData();
|
loadWalletRechargeData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue';
|
import { Card, Radio, RadioGroup, Spin } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
import { getOrderCountTrendComparison } from '#/api/mall/statistics/trade';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getTradeTrendChartOptions,
|
getTradeTrendChartOptions,
|
||||||
@@ -76,15 +76,15 @@ async function handleTimeRangeTypeChange() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 发送时间范围选中事件
|
// 发送时间范围选中事件
|
||||||
await getOrderCountTrendComparison(beginTime, endTime);
|
await loadOrderCountTrendComparison(beginTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询订单数量趋势对照数据 */
|
/** 查询订单数量趋势对照数据 */
|
||||||
async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {
|
async function loadOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
// 1. 查询数据
|
// 1. 查询数据
|
||||||
const list = await TradeStatisticsApi.getOrderCountTrendComparison(
|
const list = await getOrderCountTrendComparison(
|
||||||
timeRangeType.value,
|
timeRangeType.value,
|
||||||
beginTime.toDate(),
|
beginTime.toDate(),
|
||||||
endTime.toDate(),
|
endTime.toDate(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { computed, onMounted, ref } from 'vue';
|
|||||||
|
|
||||||
import { handleTree } from '@vben/utils';
|
import { handleTree } from '@vben/utils';
|
||||||
|
|
||||||
import * as ProductCategoryApi from '#/api/mall/product/category';
|
import { getCategoryList } from '#/api/mall/product/category';
|
||||||
|
|
||||||
/** 商品分类选择组件 */
|
/** 商品分类选择组件 */
|
||||||
defineOptions({ name: 'ProductCategorySelect' });
|
defineOptions({ name: 'ProductCategorySelect' });
|
||||||
@@ -42,8 +42,7 @@ const selectCategoryId = computed({
|
|||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
const categoryList = ref<any[]>([]); // 分类树
|
const categoryList = ref<any[]>([]); // 分类树
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 获得分类树
|
const data = await getCategoryList({
|
||||||
const data = await ProductCategoryApi.getCategoryList({
|
|
||||||
parentId: props.parentId,
|
parentId: props.parentId,
|
||||||
});
|
});
|
||||||
categoryList.value = handleTree(data, 'id', 'parentId');
|
categoryList.value = handleTree(data, 'id', 'parentId');
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export { default as SkuTableSelect } from './sku-table-select.vue';
|
||||||
|
export { default as SpuShowcase } from './spu-showcase.vue';
|
||||||
|
export { default as SpuTableSelect } from './spu-table-select.vue';
|
||||||
@@ -8,8 +8,6 @@ import { computed, ref } from 'vue';
|
|||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { fenToYuan } from '@vben/utils';
|
import { fenToYuan } from '@vben/utils';
|
||||||
|
|
||||||
import { Input, message } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getSpu } from '#/api/mall/product/spu';
|
import { getSpu } from '#/api/mall/product/spu';
|
||||||
|
|
||||||
@@ -21,18 +19,13 @@ const emit = defineEmits<{
|
|||||||
change: [sku: MallSpuApi.Sku];
|
change: [sku: MallSpuApi.Sku];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const selectedSkuId = ref<number>();
|
|
||||||
const spuId = ref<number>();
|
const spuId = ref<number>();
|
||||||
|
|
||||||
/** 配置列 */
|
/** 表格列配置 */
|
||||||
// TODO @puhui999:貌似列太宽了?
|
|
||||||
const gridColumns = computed<VxeGridProps['columns']>(() => [
|
const gridColumns = computed<VxeGridProps['columns']>(() => [
|
||||||
{
|
{
|
||||||
field: 'id',
|
type: 'radio',
|
||||||
title: '#',
|
width: 55,
|
||||||
width: 60,
|
|
||||||
align: 'center',
|
|
||||||
slots: { default: 'radio-column' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'picUrl',
|
field: 'picUrl',
|
||||||
@@ -66,73 +59,65 @@ const gridColumns = computed<VxeGridProps['columns']>(() => [
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// TODO @芋艿:要不要直接非 pager?
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: gridColumns.value,
|
columns: gridColumns.value,
|
||||||
height: 400,
|
height: 400,
|
||||||
border: true,
|
border: true,
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
|
radioConfig: {
|
||||||
|
reserve: true,
|
||||||
|
},
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async () => {
|
query: async () => {
|
||||||
if (!spuId.value) {
|
if (!spuId.value) {
|
||||||
return { items: [], total: 0 };
|
return { items: [], total: 0 };
|
||||||
}
|
}
|
||||||
try {
|
const spu = await getSpu(spuId.value);
|
||||||
const spu = await getSpu(spuId.value);
|
return {
|
||||||
return {
|
items: spu.skus || [],
|
||||||
items: spu.skus || [],
|
total: spu.skus?.length || 0,
|
||||||
total: spu.skus?.length || 0,
|
};
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
message.error('加载 SKU 数据失败');
|
|
||||||
console.error(error);
|
|
||||||
return { items: [], total: 0 };
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
gridEvents: {
|
||||||
|
radioChange: handleRadioChange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 处理选中 */
|
/** 处理选中 */
|
||||||
function handleSelected(row: MallSpuApi.Sku) {
|
function handleRadioChange() {
|
||||||
emit('change', row);
|
const selectedRow = gridApi.grid.getRadioRecord() as MallSpuApi.Sku;
|
||||||
modalApi.close();
|
if (selectedRow) {
|
||||||
selectedSkuId.value = undefined;
|
emit('change', selectedRow);
|
||||||
|
modalApi.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
onOpenChange: async (isOpen: boolean) => {
|
onOpenChange: async (isOpen: boolean) => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
selectedSkuId.value = undefined;
|
gridApi.grid.clearRadioRow();
|
||||||
spuId.value = undefined;
|
spuId.value = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = modalApi.getData<SpuData>();
|
const data = modalApi.getData<SpuData>();
|
||||||
// TODO @puhui999:这里要不 if return,让括号的层级简单点。
|
if (!data?.spuId) {
|
||||||
if (data?.spuId) {
|
return;
|
||||||
spuId.value = data.spuId;
|
|
||||||
// 触发数据查询
|
|
||||||
await gridApi.query();
|
|
||||||
}
|
}
|
||||||
|
spuId.value = data.spuId;
|
||||||
|
await gridApi.query();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal class="w-[700px]" title="选择规格">
|
<Modal class="w-[700px]" title="选择规格">
|
||||||
<Grid>
|
<Grid />
|
||||||
<template #radio-column="{ row }">
|
|
||||||
<Input
|
|
||||||
v-model="selectedSkuId"
|
|
||||||
:value="row.id"
|
|
||||||
class="cursor-pointer"
|
|
||||||
type="radio"
|
|
||||||
@change="handleSelected(row)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Grid>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
<!-- 商品橱窗组件:用于展示和选择商品 SPU -->
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MallSpuApi } from '#/api/mall/product/spu';
|
||||||
|
|
||||||
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import { CloseCircleFilled, PlusOutlined } from '@vben/icons';
|
||||||
|
|
||||||
|
import { Image, Tooltip } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getSpuDetailList } from '#/api/mall/product/spu';
|
||||||
|
|
||||||
|
import SpuTableSelect from './spu-table-select.vue';
|
||||||
|
|
||||||
|
interface SpuShowcaseProps {
|
||||||
|
modelValue?: number | number[];
|
||||||
|
limit?: number;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<SpuShowcaseProps>(), {
|
||||||
|
modelValue: undefined,
|
||||||
|
limit: Number.MAX_VALUE,
|
||||||
|
disabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue', 'change']);
|
||||||
|
|
||||||
|
const productSpus = ref<MallSpuApi.Spu[]>([]); // 已选择的商品列表
|
||||||
|
const spuTableSelectRef = ref<InstanceType<typeof SpuTableSelect>>(); // 商品选择表格组件引用
|
||||||
|
const isMultiple = computed(() => props.limit !== 1); // 是否为多选模式
|
||||||
|
|
||||||
|
/** 计算是否可以添加 */
|
||||||
|
const canAdd = computed(() => {
|
||||||
|
if (props.disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!props.limit) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return productSpus.value.length < props.limit;
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 监听 modelValue 变化,加载商品详情 */
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
async (newValue) => {
|
||||||
|
// eslint-disable-next-line unicorn/no-nested-ternary
|
||||||
|
const ids = Array.isArray(newValue) ? newValue : newValue ? [newValue] : [];
|
||||||
|
if (ids.length === 0) {
|
||||||
|
productSpus.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 只有商品发生变化时才重新查询
|
||||||
|
if (
|
||||||
|
productSpus.value.length === 0 ||
|
||||||
|
productSpus.value.some((spu) => !ids.includes(spu.id!))
|
||||||
|
) {
|
||||||
|
productSpus.value = await getSpuDetailList(ids);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 打开商品选择对话框 */
|
||||||
|
function handleOpenSpuSelect() {
|
||||||
|
spuTableSelectRef.value?.open(productSpus.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 选择商品后触发 */
|
||||||
|
function handleSpuSelected(spus: MallSpuApi.Spu | MallSpuApi.Spu[]) {
|
||||||
|
productSpus.value = Array.isArray(spus) ? spus : [spus];
|
||||||
|
emitSpuChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除商品 */
|
||||||
|
function handleRemoveSpu(index: number) {
|
||||||
|
productSpus.value.splice(index, 1);
|
||||||
|
emitSpuChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 触发变更事件 */
|
||||||
|
function emitSpuChange() {
|
||||||
|
if (props.limit === 1) {
|
||||||
|
const spu = productSpus.value.length > 0 ? productSpus.value[0] : null;
|
||||||
|
emit('update:modelValue', spu?.id || 0);
|
||||||
|
emit('change', spu);
|
||||||
|
} else {
|
||||||
|
emit(
|
||||||
|
'update:modelValue',
|
||||||
|
productSpus.value.map((spu) => spu.id!),
|
||||||
|
);
|
||||||
|
emit('change', productSpus.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<!-- 已选商品列表 -->
|
||||||
|
<div
|
||||||
|
v-for="(spu, index) in productSpus"
|
||||||
|
:key="spu.id"
|
||||||
|
class="group relative h-[60px] w-[60px] overflow-hidden rounded-lg"
|
||||||
|
>
|
||||||
|
<Tooltip :title="spu.name">
|
||||||
|
<div class="relative h-full w-full">
|
||||||
|
<Image
|
||||||
|
:src="spu.picUrl"
|
||||||
|
class="h-full w-full rounded-lg object-cover"
|
||||||
|
/>
|
||||||
|
<!-- 删除按钮 -->
|
||||||
|
<!-- TODO @AI:还是使用 IconifyIcon:使用自己的 + 图标 -->
|
||||||
|
<CloseCircleFilled
|
||||||
|
v-if="!disabled"
|
||||||
|
class="absolute -right-2 -top-2 cursor-pointer text-xl text-red-500 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100"
|
||||||
|
@click="handleRemoveSpu(index)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加商品按钮 -->
|
||||||
|
<Tooltip v-if="canAdd" title="选择商品">
|
||||||
|
<div
|
||||||
|
class="hover:border-primary hover:bg-primary/5 flex h-[60px] w-[60px] cursor-pointer items-center justify-center rounded-lg border-2 border-dashed transition-colors"
|
||||||
|
@click="handleOpenSpuSelect"
|
||||||
|
>
|
||||||
|
<!-- TODO @AI:还是使用 IconifyIcon:使用自己的 + 图标 -->
|
||||||
|
<PlusOutlined class="text-xl text-gray-400" />
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 商品选择对话框 -->
|
||||||
|
<SpuTableSelect
|
||||||
|
ref="spuTableSelectRef"
|
||||||
|
:multiple="isMultiple"
|
||||||
|
@change="handleSpuSelected"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
<!-- SPU 商品选择弹窗组件 -->
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
import type { MallCategoryApi } from '#/api/mall/product/category';
|
||||||
|
import type { MallSpuApi } from '#/api/mall/product/spu';
|
||||||
|
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { handleTree } from '@vben/utils';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getCategoryList } from '#/api/mall/product/category';
|
||||||
|
import { getSpuPage } from '#/api/mall/product/spu';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
|
interface SpuTableSelectProps {
|
||||||
|
multiple?: boolean; // 是否单选:true - checkbox;false - radio
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<SpuTableSelectProps>(), {
|
||||||
|
multiple: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [spu: MallSpuApi.Spu | MallSpuApi.Spu[]];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const categoryList = ref<MallCategoryApi.Category[]>([]); // 分类列表
|
||||||
|
const categoryTreeList = ref<any[]>([]); // 分类树
|
||||||
|
|
||||||
|
/** 单选:处理选中变化 */
|
||||||
|
function handleRadioChange() {
|
||||||
|
const selectedRow = gridApi.grid.getRadioRecord() as MallSpuApi.Spu;
|
||||||
|
if (selectedRow) {
|
||||||
|
emit('change', selectedRow);
|
||||||
|
modalApi.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索表单 Schema */
|
||||||
|
const formSchema = computed<VbenFormSchema[]>(() => [
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '商品名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入商品名称',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'categoryId',
|
||||||
|
label: '商品分类',
|
||||||
|
component: 'TreeSelect',
|
||||||
|
// TODO @芋艿:可能要测试下;
|
||||||
|
componentProps: {
|
||||||
|
treeData: categoryTreeList,
|
||||||
|
fieldNames: {
|
||||||
|
label: 'name',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
|
treeCheckStrictly: true,
|
||||||
|
placeholder: '请选择商品分类',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
treeNodeFilterProp: 'name',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** 表格列配置 */
|
||||||
|
const gridColumns = computed<VxeGridProps['columns']>(() => {
|
||||||
|
const columns: VxeGridProps['columns'] = [];
|
||||||
|
if (props.multiple) {
|
||||||
|
columns.push({ type: 'checkbox', width: 55 });
|
||||||
|
} else {
|
||||||
|
columns.push({ type: 'radio', width: 55 });
|
||||||
|
}
|
||||||
|
columns.push(
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: '商品编号',
|
||||||
|
minWidth: 100,
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'picUrl',
|
||||||
|
title: '商品图',
|
||||||
|
width: 100,
|
||||||
|
align: 'center',
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellImage',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '商品名称',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'categoryId',
|
||||||
|
title: '商品分类',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: ({ cellValue }) => {
|
||||||
|
const category = categoryList.value?.find((c) => c.id === cellValue);
|
||||||
|
return category?.name || '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return columns;
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: formSchema.value,
|
||||||
|
layout: 'horizontal',
|
||||||
|
collapsed: false,
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: gridColumns.value,
|
||||||
|
height: 500,
|
||||||
|
border: true,
|
||||||
|
checkboxConfig: {
|
||||||
|
reserve: true,
|
||||||
|
},
|
||||||
|
radioConfig: {
|
||||||
|
reserve: true,
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
async query({ page }: any, formValues: any) {
|
||||||
|
return await getSpuPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
tabType: 0,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gridEvents: {
|
||||||
|
radioChange: handleRadioChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
destroyOnClose: true,
|
||||||
|
showConfirmButton: props.multiple, // 特殊:radio 单选情况下,走 handleRadioChange 处理。
|
||||||
|
onConfirm: () => {
|
||||||
|
const selectedRows = gridApi.grid.getCheckboxRecords() as MallSpuApi.Spu[];
|
||||||
|
emit('change', selectedRows);
|
||||||
|
modalApi.close();
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
gridApi.grid.clearCheckboxRow();
|
||||||
|
gridApi.grid.clearRadioRow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 先查询数据
|
||||||
|
await gridApi.query();
|
||||||
|
// 2. 设置已选中行
|
||||||
|
const data = modalApi.getData<MallSpuApi.Spu | MallSpuApi.Spu[]>();
|
||||||
|
if (props.multiple && Array.isArray(data) && data.length > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const tableData = gridApi.grid.getTableData().fullData;
|
||||||
|
data.forEach((spu) => {
|
||||||
|
const row = tableData.find(
|
||||||
|
(item: MallSpuApi.Spu) => item.id === spu.id,
|
||||||
|
);
|
||||||
|
if (row) {
|
||||||
|
gridApi.grid.setCheckboxRow(row, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
} else if (!props.multiple && data && !Array.isArray(data)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const tableData = gridApi.grid.getTableData().fullData;
|
||||||
|
const row = tableData.find(
|
||||||
|
(item: MallSpuApi.Spu) => item.id === data.id,
|
||||||
|
);
|
||||||
|
if (row) {
|
||||||
|
gridApi.grid.setRadioRow(row);
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 对外暴露的方法 */
|
||||||
|
defineExpose({
|
||||||
|
open: (data?: MallSpuApi.Spu | MallSpuApi.Spu[]) => {
|
||||||
|
modalApi.setData(data).open();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 初始化分类数据 */
|
||||||
|
onMounted(async () => {
|
||||||
|
categoryList.value = await getCategoryList({});
|
||||||
|
categoryTreeList.value = handleTree(categoryList.value, 'id', 'parentId');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal title="选择商品" class="w-[950px]">
|
||||||
|
<Grid />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
@@ -102,6 +102,7 @@ export function useInfoFormSchema(): VbenFormSchema[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 价格库存的表单 */
|
/** 价格库存的表单 */
|
||||||
|
// TODO @puhui999:貌似太宽了。。。屏幕小的,整个 table 展示补全哈~~
|
||||||
export function useSkuFormSchema(
|
export function useSkuFormSchema(
|
||||||
propertyList: any[] = [],
|
propertyList: any[] = [],
|
||||||
isDetail: boolean = false,
|
isDetail: boolean = false,
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ import type { MallSpuApi } from '#/api/mall/product/spu';
|
|||||||
|
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import { copyValueToTarget, formatToFraction, isEmpty } from '@vben/utils';
|
import {
|
||||||
|
copyValueToTarget,
|
||||||
|
formatToFraction,
|
||||||
|
getNestedValue,
|
||||||
|
isEmpty,
|
||||||
|
} from '@vben/utils';
|
||||||
|
|
||||||
import { Button, Image, Input, InputNumber, message } from 'ant-design-vue';
|
import { Button, Image, Input, InputNumber, message } from 'ant-design-vue';
|
||||||
|
|
||||||
@@ -43,9 +48,12 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const { isBatch, isDetail, isComponent, isActivityComponent } = props;
|
const { isBatch, isDetail, isComponent, isActivityComponent } = props;
|
||||||
|
|
||||||
const formData: Ref<MallSpuApi.Spu | undefined> = ref<MallSpuApi.Spu>(); // 表单数据
|
const formData: Ref<MallSpuApi.Spu | undefined> = ref<MallSpuApi.Spu>();
|
||||||
const skuList = ref<MallSpuApi.Sku[]>([
|
const tableHeaders = ref<{ label: string; prop: string }[]>([]);
|
||||||
{
|
|
||||||
|
/** 创建空 SKU 数据 */
|
||||||
|
function createEmptySku(): MallSpuApi.Sku {
|
||||||
|
return {
|
||||||
price: 0,
|
price: 0,
|
||||||
marketPrice: 0,
|
marketPrice: 0,
|
||||||
costPrice: 0,
|
costPrice: 0,
|
||||||
@@ -56,8 +64,10 @@ const skuList = ref<MallSpuApi.Sku[]>([
|
|||||||
volume: 0,
|
volume: 0,
|
||||||
firstBrokeragePrice: 0,
|
firstBrokeragePrice: 0,
|
||||||
secondBrokeragePrice: 0,
|
secondBrokeragePrice: 0,
|
||||||
},
|
};
|
||||||
]); // 批量添加时的临时数据
|
}
|
||||||
|
|
||||||
|
const skuList = ref<MallSpuApi.Sku[]>([createEmptySku()]);
|
||||||
|
|
||||||
/** 批量添加 */
|
/** 批量添加 */
|
||||||
function batchAdd() {
|
function batchAdd() {
|
||||||
@@ -79,34 +89,33 @@ function validateProperty() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除 sku */
|
/** 删除 SKU */
|
||||||
function deleteSku(row: MallSpuApi.Sku) {
|
function deleteSku(row: MallSpuApi.Sku) {
|
||||||
const index = formData.value!.skus!.findIndex(
|
const index = formData.value!.skus!.findIndex(
|
||||||
// 直接把列表转成字符串比较
|
|
||||||
(sku: MallSpuApi.Sku) =>
|
(sku: MallSpuApi.Sku) =>
|
||||||
JSON.stringify(sku.properties) === JSON.stringify(row.properties),
|
JSON.stringify(sku.properties) === JSON.stringify(row.properties),
|
||||||
);
|
);
|
||||||
formData.value!.skus!.splice(index, 1);
|
if (index !== -1) {
|
||||||
|
formData.value!.skus!.splice(index, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tableHeaders = ref<{ label: string; prop: string }[]>([]); // 多属性表头
|
/** 校验 SKU 数据:保存时,每个商品规格的表单要校验。例如:销售金额最低是 0.01 */
|
||||||
|
|
||||||
/** 保存时,每个商品规格的表单要校验下。例如说,销售金额最低是 0.01 这种 */
|
|
||||||
function validateSku() {
|
function validateSku() {
|
||||||
validateProperty();
|
validateProperty();
|
||||||
let warningInfo = '请检查商品各行相关属性配置,';
|
let warningInfo = '请检查商品各行相关属性配置,';
|
||||||
let validate = true; // 默认通过
|
let validate = true;
|
||||||
|
|
||||||
for (const sku of formData.value!.skus!) {
|
for (const sku of formData.value!.skus!) {
|
||||||
// 作为活动组件的校验
|
|
||||||
for (const rule of props?.ruleConfig as RuleConfig[]) {
|
for (const rule of props?.ruleConfig as RuleConfig[]) {
|
||||||
const arg = getValue(sku, rule.name);
|
const value = getNestedValue(sku, rule.name);
|
||||||
if (!rule.rule(arg)) {
|
if (!rule.rule(value)) {
|
||||||
validate = false; // 只要有一个不通过则直接不通过
|
validate = false;
|
||||||
warningInfo += rule.message;
|
warningInfo += rule.message;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 只要有一个不通过则结束后续的校验
|
|
||||||
if (!validate) {
|
if (!validate) {
|
||||||
message.warning(warningInfo);
|
message.warning(warningInfo);
|
||||||
throw new Error(warningInfo);
|
throw new Error(warningInfo);
|
||||||
@@ -114,21 +123,6 @@ function validateSku() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999:是不是可以通过 getNestedValue 简化?
|
|
||||||
function getValue(obj: any, arg: string): unknown {
|
|
||||||
const keys = arg.split('.');
|
|
||||||
let value: any = obj;
|
|
||||||
for (const key of keys) {
|
|
||||||
if (value && typeof value === 'object' && key in value) {
|
|
||||||
value = value[key];
|
|
||||||
} else {
|
|
||||||
value = undefined;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择时触发
|
* 选择时触发
|
||||||
*
|
*
|
||||||
@@ -155,7 +149,6 @@ watch(
|
|||||||
|
|
||||||
/** 生成表数据 */
|
/** 生成表数据 */
|
||||||
function generateTableData(propertyList: PropertyAndValues[]) {
|
function generateTableData(propertyList: PropertyAndValues[]) {
|
||||||
// 构建数据结构
|
|
||||||
const propertyValues = propertyList.map((item: PropertyAndValues) =>
|
const propertyValues = propertyList.map((item: PropertyAndValues) =>
|
||||||
(item.values || []).map((v: { id: number; name: string }) => ({
|
(item.values || []).map((v: { id: number; name: string }) => ({
|
||||||
propertyId: item.id,
|
propertyId: item.id,
|
||||||
@@ -164,35 +157,30 @@ function generateTableData(propertyList: PropertyAndValues[]) {
|
|||||||
valueName: v.name,
|
valueName: v.name,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
const buildSkuList = build(propertyValues);
|
const buildSkuList = build(propertyValues);
|
||||||
|
|
||||||
// 如果回显的 sku 属性和添加的属性不一致则重置 skus 列表
|
// 如果回显的 sku 属性和添加的属性不一致则重置 skus 列表
|
||||||
if (!validateData(propertyList)) {
|
if (!validateData(propertyList)) {
|
||||||
// 如果不一致则重置表数据,默认添加新的属性重新生成 sku 列表
|
|
||||||
formData.value!.skus = [];
|
formData.value!.skus = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of buildSkuList) {
|
for (const item of buildSkuList) {
|
||||||
|
const properties = Array.isArray(item) ? item : [item];
|
||||||
const row = {
|
const row = {
|
||||||
properties: Array.isArray(item) ? item : [item], // 如果只有一个属性的话返回的是一个 property 对象
|
...createEmptySku(),
|
||||||
price: 0,
|
properties,
|
||||||
marketPrice: 0,
|
|
||||||
costPrice: 0,
|
|
||||||
barCode: '',
|
|
||||||
picUrl: '',
|
|
||||||
stock: 0,
|
|
||||||
weight: 0,
|
|
||||||
volume: 0,
|
|
||||||
firstBrokeragePrice: 0,
|
|
||||||
secondBrokeragePrice: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 如果存在属性相同的 sku 则不做处理
|
// 如果存在属性相同的 sku 则不做处理
|
||||||
const index = formData.value!.skus!.findIndex(
|
const exists = formData.value!.skus!.some(
|
||||||
(sku: MallSpuApi.Sku) =>
|
(sku: MallSpuApi.Sku) =>
|
||||||
JSON.stringify(sku.properties) === JSON.stringify(row.properties),
|
JSON.stringify(sku.properties) === JSON.stringify(row.properties),
|
||||||
);
|
);
|
||||||
if (index !== -1) {
|
|
||||||
continue;
|
if (!exists) {
|
||||||
|
formData.value!.skus!.push(row);
|
||||||
}
|
}
|
||||||
formData.value!.skus!.push(row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +212,9 @@ function build(
|
|||||||
const result: MallSpuApi.Property[][] = [];
|
const result: MallSpuApi.Property[][] = [];
|
||||||
const rest = build(propertyValuesList.slice(1));
|
const rest = build(propertyValuesList.slice(1));
|
||||||
const firstList = propertyValuesList[0];
|
const firstList = propertyValuesList[0];
|
||||||
if (!firstList) return [];
|
if (!firstList) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
for (const element of firstList) {
|
for (const element of firstList) {
|
||||||
for (const element_ of rest) {
|
for (const element_ of rest) {
|
||||||
@@ -248,43 +238,33 @@ watch(
|
|||||||
if (!formData.value!.specType) {
|
if (!formData.value!.specType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果当前组件作为批量添加数据使用,则重置表数据
|
// 如果当前组件作为批量添加数据使用,则重置表数据
|
||||||
if (props.isBatch) {
|
if (props.isBatch) {
|
||||||
skuList.value = [
|
skuList.value = [createEmptySku()];
|
||||||
{
|
|
||||||
price: 0,
|
|
||||||
marketPrice: 0,
|
|
||||||
costPrice: 0,
|
|
||||||
barCode: '',
|
|
||||||
picUrl: '',
|
|
||||||
stock: 0,
|
|
||||||
weight: 0,
|
|
||||||
volume: 0,
|
|
||||||
firstBrokeragePrice: 0,
|
|
||||||
secondBrokeragePrice: 0,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断代理对象是否为空
|
// 判断代理对象是否为空
|
||||||
if (JSON.stringify(propertyList) === '[]') {
|
if (JSON.stringify(propertyList) === '[]') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 重置表头
|
|
||||||
tableHeaders.value = [];
|
// 重置并生成表头
|
||||||
// 生成表头
|
tableHeaders.value = propertyList.map((item, index) => ({
|
||||||
propertyList.forEach((item, index) => {
|
prop: `name${index}`,
|
||||||
// name加属性项index区分属性值
|
label: item.name,
|
||||||
tableHeaders.value.push({ prop: `name${index}`, label: item.name });
|
}));
|
||||||
});
|
|
||||||
// 如果回显的 sku 属性和添加的属性一致则不处理
|
// 如果回显的 sku 属性和添加的属性一致则不处理
|
||||||
if (validateData(propertyList)) {
|
if (validateData(propertyList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加新属性没有属性值也不做处理
|
// 添加新属性没有属性值也不做处理
|
||||||
if (propertyList.some((item) => !item.values || isEmpty(item.values))) {
|
if (propertyList.some((item) => !item.values || isEmpty(item.values))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成 table 数据,即 sku 列表
|
// 生成 table 数据,即 sku 列表
|
||||||
generateTableData(propertyList);
|
generateTableData(propertyList);
|
||||||
},
|
},
|
||||||
@@ -296,17 +276,21 @@ watch(
|
|||||||
|
|
||||||
const activitySkuListRef = ref();
|
const activitySkuListRef = ref();
|
||||||
|
|
||||||
|
/** 获取 SKU 表格引用 */
|
||||||
function getSkuTableRef() {
|
function getSkuTableRef() {
|
||||||
return activitySkuListRef.value;
|
return activitySkuListRef.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({ generateTableData, validateSku, getSkuTableRef });
|
defineExpose({
|
||||||
|
generateTableData,
|
||||||
|
validateSku,
|
||||||
|
getSkuTableRef,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- 情况一:添加/修改 -->
|
<!-- 情况一:添加/修改 -->
|
||||||
<!-- TODO @puhui999:有可以通过 grid 来做么?主要考虑,这样不直接使用 vxe 标签,抽象程度更高; -->
|
|
||||||
<VxeTable
|
<VxeTable
|
||||||
v-if="!isDetail && !isActivityComponent"
|
v-if="!isDetail && !isActivityComponent"
|
||||||
:data="isBatch ? skuList : formData?.skus || []"
|
:data="isBatch ? skuList : formData?.skus || []"
|
||||||
|
|||||||
@@ -1,346 +0,0 @@
|
|||||||
<!-- SPU 商品选择弹窗组件 -->
|
|
||||||
<script lang="ts" setup>
|
|
||||||
// TODO @puhui999:这个是不是可以放到 components 里?,和商品发布,关系不大
|
|
||||||
import type { CheckboxChangeEvent } from 'ant-design-vue/es/checkbox/interface';
|
|
||||||
|
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
|
||||||
import type { MallSpuApi } from '#/api/mall/product/spu';
|
|
||||||
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
|
||||||
import { handleTree } from '@vben/utils';
|
|
||||||
|
|
||||||
import { Checkbox, Radio } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import { getCategoryList } from '#/api/mall/product/category';
|
|
||||||
import { getSpuPage } from '#/api/mall/product/spu';
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
|
||||||
|
|
||||||
interface SpuTableSelectProps {
|
|
||||||
multiple?: boolean; // 是否多选模式
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<SpuTableSelectProps>(), {
|
|
||||||
multiple: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
change: [spu: MallSpuApi.Spu | MallSpuApi.Spu[]];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const selectedSpuId = ref<number>(); // 单选:选中的 SPU ID
|
|
||||||
const checkedStatus = ref<Record<number, boolean>>({}); // 多选:选中状态 map
|
|
||||||
const checkedSpus = ref<MallSpuApi.Spu[]>([]); // 多选:选中的 SPU 列表
|
|
||||||
const isCheckAll = ref(false); // 多选:全选状态
|
|
||||||
const isIndeterminate = ref(false); // 多选:半选状态
|
|
||||||
|
|
||||||
const categoryList = ref<any[]>([]); // 分类列表(扁平)
|
|
||||||
const categoryTreeList = ref<any[]>([]); // 分类树
|
|
||||||
|
|
||||||
const formSchema = computed<VbenFormSchema[]>(() => {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
fieldName: 'name',
|
|
||||||
label: '商品名称',
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入商品名称',
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'categoryId',
|
|
||||||
label: '商品分类',
|
|
||||||
component: 'TreeSelect',
|
|
||||||
componentProps: {
|
|
||||||
treeData: categoryTreeList.value,
|
|
||||||
fieldNames: {
|
|
||||||
label: 'name',
|
|
||||||
value: 'id',
|
|
||||||
},
|
|
||||||
treeCheckStrictly: true,
|
|
||||||
placeholder: '请选择商品分类',
|
|
||||||
allowClear: true,
|
|
||||||
showSearch: true,
|
|
||||||
treeNodeFilterProp: 'name',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'createTime',
|
|
||||||
label: '创建时间',
|
|
||||||
component: 'RangePicker',
|
|
||||||
componentProps: {
|
|
||||||
...getRangePickerDefaultProps(),
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
const gridColumns = computed<VxeGridProps['columns']>(() => {
|
|
||||||
const columns: VxeGridProps['columns'] = [];
|
|
||||||
|
|
||||||
// 多选模式:添加多选列
|
|
||||||
if (props.multiple) {
|
|
||||||
columns.push({
|
|
||||||
field: 'checkbox',
|
|
||||||
title: '',
|
|
||||||
width: 55,
|
|
||||||
align: 'center',
|
|
||||||
slots: { default: 'checkbox-column', header: 'checkbox-header' },
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// 单选模式:添加单选列
|
|
||||||
columns.push({
|
|
||||||
field: 'radio',
|
|
||||||
title: '#',
|
|
||||||
width: 55,
|
|
||||||
align: 'center',
|
|
||||||
slots: { default: 'radio-column' },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 其它列
|
|
||||||
columns.push(
|
|
||||||
{
|
|
||||||
field: 'id',
|
|
||||||
title: '商品编号',
|
|
||||||
minWidth: 100,
|
|
||||||
align: 'center',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'picUrl',
|
|
||||||
title: '商品图',
|
|
||||||
width: 100,
|
|
||||||
align: 'center',
|
|
||||||
cellRender: {
|
|
||||||
name: 'CellImage',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '商品名称',
|
|
||||||
minWidth: 200,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'categoryId',
|
|
||||||
title: '商品分类',
|
|
||||||
minWidth: 120,
|
|
||||||
formatter: ({ cellValue }) => {
|
|
||||||
const category = categoryList.value?.find((c) => c.id === cellValue);
|
|
||||||
return category?.name || '-';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return columns;
|
|
||||||
});
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
|
||||||
formOptions: {
|
|
||||||
schema: formSchema.value,
|
|
||||||
layout: 'horizontal',
|
|
||||||
collapsed: false,
|
|
||||||
},
|
|
||||||
gridOptions: {
|
|
||||||
columns: gridColumns.value,
|
|
||||||
height: 500,
|
|
||||||
border: true,
|
|
||||||
showOverflow: true,
|
|
||||||
proxyConfig: {
|
|
||||||
ajax: {
|
|
||||||
async query({ page }: any, formValues: any) {
|
|
||||||
// TODO @puhui999:这里是不是不 try catch?
|
|
||||||
try {
|
|
||||||
const params = {
|
|
||||||
pageNo: page.currentPage,
|
|
||||||
pageSize: page.pageSize,
|
|
||||||
tabType: 0, // 默认获取上架的商品
|
|
||||||
name: formValues.name || undefined,
|
|
||||||
categoryId: formValues.categoryId || undefined,
|
|
||||||
createTime: formValues.createTime || undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO @puhui999:一次性的,是不是不声明 params,直接放到 getSpuPage 里?
|
|
||||||
const data = await getSpuPage(params);
|
|
||||||
|
|
||||||
// 初始化多选状态
|
|
||||||
if (props.multiple && data.list) {
|
|
||||||
data.list.forEach((spu) => {
|
|
||||||
if (checkedStatus.value[spu.id!] === undefined) {
|
|
||||||
checkedStatus.value[spu.id!] = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
calculateIsCheckAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
items: data.list || [],
|
|
||||||
total: data.total || 0,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.error('加载商品数据失败:', error);
|
|
||||||
return { items: [], total: 0 };
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO @puhui999:如下的选中方法,可以因为 Grid 做简化么?
|
|
||||||
/** 单选:处理选中 */
|
|
||||||
function handleSingleSelected(row: MallSpuApi.Spu) {
|
|
||||||
selectedSpuId.value = row.id;
|
|
||||||
emit('change', row);
|
|
||||||
modalApi.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 多选:全选/全不选 */
|
|
||||||
function handleCheckAll(e: CheckboxChangeEvent) {
|
|
||||||
const checked = e.target.checked;
|
|
||||||
isCheckAll.value = checked;
|
|
||||||
isIndeterminate.value = false;
|
|
||||||
|
|
||||||
const currentList = gridApi.grid.getData();
|
|
||||||
currentList.forEach((spu: MallSpuApi.Spu) => {
|
|
||||||
handleCheckOne(checked, spu, false);
|
|
||||||
});
|
|
||||||
calculateIsCheckAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 多选:选中单个 */
|
|
||||||
function handleCheckOne(
|
|
||||||
checked: boolean,
|
|
||||||
spu: MallSpuApi.Spu,
|
|
||||||
needCalc = true,
|
|
||||||
) {
|
|
||||||
if (checked) {
|
|
||||||
// 避免重复添加
|
|
||||||
const exists = checkedSpus.value.some((item) => item.id === spu.id);
|
|
||||||
if (!exists) {
|
|
||||||
checkedSpus.value.push(spu);
|
|
||||||
}
|
|
||||||
checkedStatus.value[spu.id!] = true;
|
|
||||||
} else {
|
|
||||||
const index = checkedSpus.value.findIndex((item) => item.id === spu.id);
|
|
||||||
if (index !== -1) {
|
|
||||||
checkedSpus.value.splice(index, 1);
|
|
||||||
}
|
|
||||||
checkedStatus.value[spu.id!] = false;
|
|
||||||
isCheckAll.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needCalc) {
|
|
||||||
calculateIsCheckAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 多选:计算全选状态 */
|
|
||||||
function calculateIsCheckAll() {
|
|
||||||
const currentList = gridApi.grid.getData();
|
|
||||||
if (currentList.length === 0) {
|
|
||||||
isCheckAll.value = false;
|
|
||||||
isIndeterminate.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkedCount = currentList.filter(
|
|
||||||
(spu: MallSpuApi.Spu) => checkedStatus.value[spu.id!],
|
|
||||||
).length;
|
|
||||||
|
|
||||||
isCheckAll.value = checkedCount === currentList.length;
|
|
||||||
isIndeterminate.value = checkedCount > 0 && checkedCount < currentList.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
|
||||||
destroyOnClose: true,
|
|
||||||
// 多选模式时显示确认按钮
|
|
||||||
onConfirm: props.multiple
|
|
||||||
? () => {
|
|
||||||
emit('change', [...checkedSpus.value]);
|
|
||||||
modalApi.close();
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
async onOpenChange(isOpen: boolean) {
|
|
||||||
if (!isOpen) {
|
|
||||||
// TODO @puhui999:是不是直接清理,不要判断 selectedSpuId.value
|
|
||||||
if (!props.multiple) {
|
|
||||||
selectedSpuId.value = undefined;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 打开时处理初始数据
|
|
||||||
const data = modalApi.getData<MallSpuApi.Spu | MallSpuApi.Spu[]>();
|
|
||||||
|
|
||||||
// 重置多选状态
|
|
||||||
if (props.multiple) {
|
|
||||||
checkedSpus.value = [];
|
|
||||||
checkedStatus.value = {};
|
|
||||||
isCheckAll.value = false;
|
|
||||||
isIndeterminate.value = false;
|
|
||||||
// 恢复已选中的数据
|
|
||||||
if (Array.isArray(data) && data.length > 0) {
|
|
||||||
checkedSpus.value = [...data];
|
|
||||||
checkedStatus.value = Object.fromEntries(
|
|
||||||
data.map((spu) => [spu.id!, true]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 单选模式:恢复已选中的 ID
|
|
||||||
if (data && !Array.isArray(data)) {
|
|
||||||
selectedSpuId.value = data.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 触发查询
|
|
||||||
// TODO @puhui999:貌似不用这里再查询一次,100% 会查询的,记忆中是;
|
|
||||||
await gridApi.query();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 初始化分类数据 */
|
|
||||||
onMounted(async () => {
|
|
||||||
categoryList.value = await getCategoryList({});
|
|
||||||
categoryTreeList.value = handleTree(categoryList.value, 'id', 'parentId');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Modal :class="props.multiple ? 'w-[900px]' : 'w-[800px]'" title="选择商品">
|
|
||||||
<Grid>
|
|
||||||
<!-- 单选列 -->
|
|
||||||
<template v-if="!props.multiple" #radio-column="{ row }">
|
|
||||||
<Radio
|
|
||||||
:checked="selectedSpuId === row.id"
|
|
||||||
:value="row.id"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="handleSingleSelected(row)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 多选表头 -->
|
|
||||||
<template v-if="props.multiple" #checkbox-header>
|
|
||||||
<Checkbox
|
|
||||||
v-model:checked="isCheckAll"
|
|
||||||
:indeterminate="isIndeterminate"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@change="handleCheckAll"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 多选列 -->
|
|
||||||
<template v-if="props.multiple" #checkbox-column="{ row }">
|
|
||||||
<Checkbox
|
|
||||||
v-model:checked="checkedStatus[row.id]"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@change="(e) => handleCheckOne(e.target.checked, row)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Grid>
|
|
||||||
</Modal>
|
|
||||||
</template>
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTe
|
|||||||
|
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CouponDiscount,
|
CouponDiscount,
|
||||||
CouponDiscountDesc,
|
CouponDiscountDesc,
|
||||||
@@ -23,9 +21,7 @@ watch(
|
|||||||
() => props.property.couponIds,
|
() => props.property.couponIds,
|
||||||
async () => {
|
async () => {
|
||||||
if (props.property.couponIds?.length > 0) {
|
if (props.property.couponIds?.length > 0) {
|
||||||
couponList.value = await CouponTemplateApi.getCouponTemplateList(
|
couponList.value = await getCouponTemplateList(props.property.couponIds);
|
||||||
props.property.couponIds,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type { HotZoneProperty } from './config';
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import { Button, Form, FormItem, Typography } from 'ant-design-vue';
|
import { Button, Form, FormItem, Typography } from 'ant-design-vue';
|
||||||
|
|
||||||
import UploadImg from '#/components/upload/image-upload.vue';
|
import UploadImg from '#/components/upload/image-upload.vue';
|
||||||
@@ -30,7 +29,12 @@ const handleOpenEditDialog = () => {
|
|||||||
<template>
|
<template>
|
||||||
<ComponentContainerProperty v-model="formData.style">
|
<ComponentContainerProperty v-model="formData.style">
|
||||||
<!-- 表单 -->
|
<!-- 表单 -->
|
||||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :model="formData" class="mt-2">
|
<Form
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
:model="formData"
|
||||||
|
class="mt-2"
|
||||||
|
>
|
||||||
<FormItem label="上传图片" prop="imgUrl">
|
<FormItem label="上传图片" prop="imgUrl">
|
||||||
<UploadImg
|
<UploadImg
|
||||||
v-model="formData.imgUrl"
|
v-model="formData.imgUrl"
|
||||||
@@ -40,7 +44,9 @@ const handleOpenEditDialog = () => {
|
|||||||
:show-description="false"
|
:show-description="false"
|
||||||
>
|
>
|
||||||
<template #tip>
|
<template #tip>
|
||||||
<Typography.Text type="secondary" class="text-xs"> 推荐宽度 750</Typography.Text>
|
<Typography.Text type="secondary" class="text-xs">
|
||||||
|
推荐宽度 750
|
||||||
|
</Typography.Text>
|
||||||
</template>
|
</template>
|
||||||
</UploadImg>
|
</UploadImg>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import type { ImageBarProperty } from './config';
|
import type { ImageBarProperty } from './config';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import { Form, FormItem } from 'ant-design-vue';
|
import { Form, FormItem } from 'ant-design-vue';
|
||||||
|
|
||||||
import UploadImg from '#/components/upload/image-upload.vue';
|
import UploadImg from '#/components/upload/image-upload.vue';
|
||||||
@@ -20,7 +19,11 @@ const formData = useVModel(props, 'modelValue', emit);
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ComponentContainerProperty v-model="formData.style">
|
<ComponentContainerProperty v-model="formData.style">
|
||||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :model="formData">
|
<Form
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
:model="formData"
|
||||||
|
>
|
||||||
<FormItem label="上传图片" prop="imgUrl">
|
<FormItem label="上传图片" prop="imgUrl">
|
||||||
<UploadImg
|
<UploadImg
|
||||||
v-model="formData.imgUrl"
|
v-model="formData.imgUrl"
|
||||||
|
|||||||
@@ -1,32 +1,25 @@
|
|||||||
import { defineAsyncComponent } from 'vue';
|
/**
|
||||||
|
|
||||||
/*
|
|
||||||
* 组件注册
|
* 组件注册
|
||||||
*
|
*
|
||||||
* 组件规范:
|
* 组件规范:每个子目录就是一个独立的组件,每个目录包括以下三个文件:
|
||||||
* 1. 每个子目录就是一个独立的组件,每个目录包括以下三个文件:
|
* 1. config.ts:组件配置,必选,用于定义组件、组件默认的属性、定义属性的类型
|
||||||
* 2. config.ts:组件配置,必选,用于定义组件、组件默认的属性、定义属性的类型
|
* 2. index.vue:组件展示,用于展示组件的渲染效果。可以不提供,如 Page(页面设置),只需要属性配置表单即可
|
||||||
* 3. index.vue:组件展示,用于展示组件的渲染效果。可以不提供,如 Page(页面设置),只需要属性配置表单即可
|
* 3. property.vue:组件属性表单,用于配置组件,必选,
|
||||||
* 4. property.vue:组件属性表单,用于配置组件,必选,
|
|
||||||
*
|
*
|
||||||
* 注:
|
* 注:
|
||||||
* 组件ID以config.ts中配置的id为准,与组件目录的名称无关,但还是建议组件目录的名称与组件ID保持一致
|
* 组件 ID 以 config.ts 中配置的 id 为准,与组件目录的名称无关,但还是建议组件目录的名称与组件 ID 保持一致
|
||||||
*/
|
*/
|
||||||
|
import { defineAsyncComponent } from 'vue';
|
||||||
|
|
||||||
// 导入组件界面模块
|
const viewModules: Record<string, any> = import.meta.glob('./*/*.vue'); // 导入组件界面模块
|
||||||
const viewModules: Record<string, any> = import.meta.glob('./*/*.vue');
|
|
||||||
// 导入配置模块
|
|
||||||
const configModules: Record<string, any> = import.meta.glob('./*/config.ts', {
|
const configModules: Record<string, any> = import.meta.glob('./*/config.ts', {
|
||||||
eager: true,
|
eager: true,
|
||||||
});
|
}); // 导入配置模块
|
||||||
|
|
||||||
// 界面模块
|
const components: Record<string, any> = {}; // 界面模块
|
||||||
const components: Record<string, any> = {};
|
const componentConfigs: Record<string, any> = {}; // 组件配置模块
|
||||||
// 组件配置模块
|
|
||||||
const componentConfigs: Record<string, any> = {};
|
|
||||||
|
|
||||||
// 组件界面的类型
|
type ViewType = 'index' | 'property'; // 组件界面的类型
|
||||||
type ViewType = 'index' | 'property';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册组件的界面模块
|
* 注册组件的界面模块
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ watch(
|
|||||||
button {
|
button {
|
||||||
width: 6px;
|
width: 6px;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
border-radius: 6px;
|
|
||||||
background: #ff6000;
|
background: #ff6000;
|
||||||
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,7 @@ import type { Rect } from '#/views/mall/promotion/components/magic-cube-editor/u
|
|||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
import {
|
import { FormItem, Input, Radio, RadioGroup, Slider } from 'ant-design-vue';
|
||||||
FormItem,
|
|
||||||
Input,
|
|
||||||
Radio,
|
|
||||||
RadioGroup,
|
|
||||||
Slider,
|
|
||||||
} from 'ant-design-vue';
|
|
||||||
|
|
||||||
import appNavBarMp from '#/assets/imgs/diy/app-nav-bar-mp.png';
|
import appNavBarMp from '#/assets/imgs/diy/app-nav-bar-mp.png';
|
||||||
import UploadImg from '#/components/upload/image-upload.vue';
|
import UploadImg from '#/components/upload/image-upload.vue';
|
||||||
@@ -86,7 +80,7 @@ const handleHotAreaSelected = (
|
|||||||
</div>
|
</div>
|
||||||
<template v-for="(cell, cellIndex) in cellList" :key="cellIndex">
|
<template v-for="(cell, cellIndex) in cellList" :key="cellIndex">
|
||||||
<template v-if="selectedHotAreaIndex === Number(cellIndex)">
|
<template v-if="selectedHotAreaIndex === Number(cellIndex)">
|
||||||
<FormItem :label="`类型`">
|
<FormItem label="类型">
|
||||||
<RadioGroup v-model:value="cell.type">
|
<RadioGroup v-model:value="cell.type">
|
||||||
<Radio value="text">文字</Radio>
|
<Radio value="text">文字</Radio>
|
||||||
<Radio value="image">图片</Radio>
|
<Radio value="image">图片</Radio>
|
||||||
@@ -95,19 +89,19 @@ const handleHotAreaSelected = (
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
<!-- 1. 文字 -->
|
<!-- 1. 文字 -->
|
||||||
<template v-if="cell.type === 'text'">
|
<template v-if="cell.type === 'text'">
|
||||||
<FormItem :label="`内容`">
|
<FormItem label="内容">
|
||||||
<Input v-model:value="cell!.text" :maxlength="10" show-count />
|
<Input v-model:value="cell!.text" :maxlength="10" show-count />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem :label="`颜色`">
|
<FormItem label="颜色">
|
||||||
<ColorInput v-model="cell!.textColor" />
|
<ColorInput v-model="cell!.textColor" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem :label="`链接`">
|
<FormItem label="链接">
|
||||||
<AppLinkInput v-model="cell.url" />
|
<AppLinkInput v-model="cell.url" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<!-- 2. 图片 -->
|
<!-- 2. 图片 -->
|
||||||
<template v-else-if="cell.type === 'image'">
|
<template v-else-if="cell.type === 'image'">
|
||||||
<FormItem :label="`图片`">
|
<FormItem label="图片">
|
||||||
<UploadImg
|
<UploadImg
|
||||||
v-model="cell.imgUrl"
|
v-model="cell.imgUrl"
|
||||||
:limit="1"
|
:limit="1"
|
||||||
@@ -118,21 +112,17 @@ const handleHotAreaSelected = (
|
|||||||
<template #tip>建议尺寸 56*56</template>
|
<template #tip>建议尺寸 56*56</template>
|
||||||
</UploadImg>
|
</UploadImg>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem :label="`链接`">
|
<FormItem label="链接">
|
||||||
<AppLinkInput v-model="cell.url" />
|
<AppLinkInput v-model="cell.url" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<!-- 3. 搜索框 -->
|
<!-- 3. 搜索框 -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<FormItem :label="`提示文字`">
|
<FormItem label="提示文字">
|
||||||
<Input v-model:value="cell.placeholder" :maxlength="10" show-count />
|
<Input v-model:value="cell.placeholder" :maxlength="10" show-count />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem :label="`圆角`">
|
<FormItem label="圆角">
|
||||||
<Slider
|
<Slider v-model:value="cell.borderRadius" :max="100" :min="0" />
|
||||||
v-model:value="cell.borderRadius"
|
|
||||||
:max="100"
|
|
||||||
:min="0"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -140,8 +130,3 @@ const handleHotAreaSelected = (
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const props = defineProps<{ modelValue: NavigationBarProperty }>();
|
|||||||
const emit = defineEmits(['update:modelValue']);
|
const emit = defineEmits(['update:modelValue']);
|
||||||
|
|
||||||
// 表单校验
|
// 表单校验
|
||||||
const rules = {
|
const rules: Record<string, any> = {
|
||||||
name: [{ required: true, message: '请输入页面名称', trigger: 'blur' }],
|
name: [{ required: true, message: '请输入页面名称', trigger: 'blur' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ setInterval(() => {
|
|||||||
>
|
>
|
||||||
<Image :src="property.iconUrl" class="h-[18px]" :preview="false" />
|
<Image :src="property.iconUrl" class="h-[18px]" :preview="false" />
|
||||||
<Divider type="vertical" />
|
<Divider type="vertical" />
|
||||||
<div class="flex-1 pr-2 h-6 truncate leading-6">
|
<div class="h-6 flex-1 truncate pr-2 leading-6">
|
||||||
{{ property.contents?.[activeIndex]?.text }}
|
{{ property.contents?.[activeIndex]?.text }}
|
||||||
</div>
|
</div>
|
||||||
<IconifyIcon icon="ep:arrow-right" />
|
<IconifyIcon icon="ep:arrow-right" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import type { PageConfigProperty } from './config';
|
import type { PageConfigProperty } from './config';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import { Form, FormItem, Textarea } from 'ant-design-vue';
|
import { Form, FormItem, Textarea } from 'ant-design-vue';
|
||||||
|
|
||||||
import UploadImg from '#/components/upload/image-upload.vue';
|
import UploadImg from '#/components/upload/image-upload.vue';
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Image } from 'ant-design-vue';
|
import { Image } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
import { getSpuDetailList } from '#/api/mall/product/spu';
|
||||||
|
|
||||||
/** 商品卡片 */
|
/** 商品卡片 */
|
||||||
defineOptions({ name: 'ProductCard' });
|
defineOptions({ name: 'ProductCard' });
|
||||||
@@ -20,7 +20,7 @@ const spuList = ref<MallSpuApi.Spu[]>([]);
|
|||||||
watch(
|
watch(
|
||||||
() => props.property.spuIds,
|
() => props.property.spuIds,
|
||||||
async () => {
|
async () => {
|
||||||
spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds);
|
spuList.value = await getSpuDetailList(props.property.spuIds);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { onMounted, ref, watch } from 'vue';
|
|||||||
|
|
||||||
import { fenToYuan } from '@vben/utils';
|
import { fenToYuan } from '@vben/utils';
|
||||||
|
|
||||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
import { getSpuDetailList } from '#/api/mall/product/spu';
|
||||||
|
|
||||||
/** 商品栏 */
|
/** 商品栏 */
|
||||||
defineOptions({ name: 'ProductList' });
|
defineOptions({ name: 'ProductList' });
|
||||||
@@ -18,7 +18,7 @@ const spuList = ref<MallSpuApi.Spu[]>([]);
|
|||||||
watch(
|
watch(
|
||||||
() => props.property.spuIds,
|
() => props.property.spuIds,
|
||||||
async () => {
|
async () => {
|
||||||
spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds);
|
spuList.value = await getSpuDetailList(props.property.spuIds);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type { ProductListProperty } from './config';
|
|||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
@@ -34,7 +33,11 @@ const formData = useVModel(props, 'modelValue', emit);
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ComponentContainerProperty v-model="formData.style">
|
<ComponentContainerProperty v-model="formData.style">
|
||||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :model="formData">
|
<Form
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
:model="formData"
|
||||||
|
>
|
||||||
<Card title="商品列表" class="property-group" :bordered="false">
|
<Card title="商品列表" class="property-group" :bordered="false">
|
||||||
<!-- <SpuShowcase v-model="formData.spuIds" /> -->
|
<!-- <SpuShowcase v-model="formData.spuIds" /> -->
|
||||||
</Card>
|
</Card>
|
||||||
@@ -102,11 +105,7 @@ const formData = useVModel(props, 'modelValue', emit);
|
|||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="间隔" prop="space">
|
<FormItem label="间隔" prop="space">
|
||||||
<Slider
|
<Slider v-model:value="formData.space" :max="100" :min="0" />
|
||||||
v-model:value="formData.space"
|
|
||||||
:max="100"
|
|
||||||
:min="0"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Card>
|
</Card>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { MallArticleApi } from '#/api/mall/promotion/article';
|
|||||||
|
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
import * as ArticleApi from '#/api/mall/promotion/article/index';
|
import { getArticle } from '#/api/mall/promotion/article';
|
||||||
|
|
||||||
/** 营销文章 */
|
/** 营销文章 */
|
||||||
defineOptions({ name: 'PromotionArticle' });
|
defineOptions({ name: 'PromotionArticle' });
|
||||||
@@ -18,7 +18,7 @@ watch(
|
|||||||
() => props.property.id,
|
() => props.property.id,
|
||||||
async () => {
|
async () => {
|
||||||
if (props.property.id) {
|
if (props.property.id) {
|
||||||
article.value = await ArticleApi.getArticle(props.property.id);
|
article.value = await getArticle(props.property.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ import type { MallArticleApi } from '#/api/mall/promotion/article';
|
|||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import { Form, FormItem, Select } from 'ant-design-vue';
|
import { Form, FormItem, Select } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ArticleApi from '#/api/mall/promotion/article/index';
|
import { getArticlePage } from '#/api/mall/promotion/article';
|
||||||
|
|
||||||
import ComponentContainerProperty from '../../component-container-property.vue';
|
import ComponentContainerProperty from '../../component-container-property.vue';
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ const loading = ref(false);
|
|||||||
// 查询文章列表
|
// 查询文章列表
|
||||||
const queryArticleList = async (title?: string) => {
|
const queryArticleList = async (title?: string) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const { list } = await ArticleApi.getArticlePage({
|
const { list } = await getArticlePage({
|
||||||
title,
|
title,
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -44,7 +43,11 @@ onMounted(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ComponentContainerProperty v-model="formData.style">
|
<ComponentContainerProperty v-model="formData.style">
|
||||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :model="formData">
|
<Form
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
:model="formData"
|
||||||
|
>
|
||||||
<FormItem label="文章" prop="id">
|
<FormItem label="文章" prop="id">
|
||||||
<Select
|
<Select
|
||||||
v-model:value="formData.id"
|
v-model:value="formData.id"
|
||||||
@@ -52,7 +55,9 @@ onMounted(() => {
|
|||||||
class="w-full"
|
class="w-full"
|
||||||
filterable
|
filterable
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:options="articles.map((item) => ({ label: item.title, value: item.id }))"
|
:options="
|
||||||
|
articles.map((item) => ({ label: item.title, value: item.id }))
|
||||||
|
"
|
||||||
@search="queryArticleList"
|
@search="queryArticleList"
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Image } from 'ant-design-vue';
|
import { Image } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
import { getSpuDetailList } from '#/api/mall/product/spu';
|
||||||
import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity';
|
import { getCombinationActivityListByIds } from '#/api/mall/promotion/combination/combinationActivity';
|
||||||
|
|
||||||
/** 拼团卡片 */
|
/** 拼团卡片 */
|
||||||
defineOptions({ name: 'PromotionCombination' });
|
defineOptions({ name: 'PromotionCombination' });
|
||||||
@@ -34,9 +34,7 @@ watch(
|
|||||||
if (Array.isArray(activityIds) && activityIds.length > 0) {
|
if (Array.isArray(activityIds) && activityIds.length > 0) {
|
||||||
// 获取拼团活动详情列表
|
// 获取拼团活动详情列表
|
||||||
combinationActivityList.value =
|
combinationActivityList.value =
|
||||||
await CombinationActivityApi.getCombinationActivityListByIds(
|
await getCombinationActivityListByIds(activityIds);
|
||||||
activityIds,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取拼团活动的 SPU 详情列表
|
// 获取拼团活动的 SPU 详情列表
|
||||||
spuList.value = [];
|
spuList.value = [];
|
||||||
@@ -44,7 +42,7 @@ watch(
|
|||||||
.map((activity) => activity.spuId)
|
.map((activity) => activity.spuId)
|
||||||
.filter((spuId): spuId is number => typeof spuId === 'number');
|
.filter((spuId): spuId is number => typeof spuId === 'number');
|
||||||
if (spuIdList.value.length > 0) {
|
if (spuIdList.value.length > 0) {
|
||||||
spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value);
|
spuList.value = await getSpuDetailList(spuIdList.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 SPU 的最低价格
|
// 更新 SPU 的最低价格
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import { CommonStatusEnum } from '@vben/constants';
|
|||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Form,
|
Form,
|
||||||
FormItem,
|
FormItem,
|
||||||
Input,
|
Input,
|
||||||
Radio,
|
|
||||||
RadioButton,
|
RadioButton,
|
||||||
RadioGroup,
|
RadioGroup,
|
||||||
Slider,
|
Slider,
|
||||||
@@ -24,9 +22,9 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
import * as CombinationActivityApi from '#/api/mall/promotion/combination/combinationActivity';
|
import { getCombinationActivityPage } from '#/api/mall/promotion/combination/combinationActivity';
|
||||||
import UploadImg from '#/components/upload/image-upload.vue';
|
import UploadImg from '#/components/upload/image-upload.vue';
|
||||||
import CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue';
|
// import CombinationShowcase from '#/views/mall/promotion/combination/components/combination-showcase.vue';
|
||||||
import { ColorInput } from '#/views/mall/promotion/components';
|
import { ColorInput } from '#/views/mall/promotion/components';
|
||||||
|
|
||||||
// 拼团属性面板
|
// 拼团属性面板
|
||||||
@@ -38,7 +36,7 @@ const formData = useVModel(props, 'modelValue', emit);
|
|||||||
// 活动列表
|
// 活动列表
|
||||||
const activityList = ref<MallCombinationActivityApi.CombinationActivity[]>([]);
|
const activityList = ref<MallCombinationActivityApi.CombinationActivity[]>([]);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const { list } = await CombinationActivityApi.getCombinationActivityPage({
|
const { list } = await getCombinationActivityPage({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
status: CommonStatusEnum.ENABLE,
|
status: CommonStatusEnum.ENABLE,
|
||||||
@@ -49,7 +47,11 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ComponentContainerProperty v-model="formData.style">
|
<ComponentContainerProperty v-model="formData.style">
|
||||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :model="formData">
|
<Form
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
:model="formData"
|
||||||
|
>
|
||||||
<Card title="拼团活动" class="property-group" :bordered="false">
|
<Card title="拼团活动" class="property-group" :bordered="false">
|
||||||
<CombinationShowcase v-model="formData.activityIds" />
|
<CombinationShowcase v-model="formData.activityIds" />
|
||||||
</Card>
|
</Card>
|
||||||
@@ -167,11 +169,7 @@ onMounted(async () => {
|
|||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="间隔" prop="space">
|
<FormItem label="间隔" prop="space">
|
||||||
<Slider
|
<Slider v-model:value="formData.space" :max="100" :min="0" />
|
||||||
v-model:value="formData.space"
|
|
||||||
:max="100"
|
|
||||||
:min="0"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Card>
|
</Card>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Image } from 'ant-design-vue';
|
import { Image } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
import { getSpuDetailList } from '#/api/mall/product/spu';
|
||||||
import * as PointActivityApi from '#/api/mall/promotion/point';
|
import { getPointActivityListByIds } from '#/api/mall/promotion/point';
|
||||||
|
|
||||||
/** 积分商城卡片 */
|
/** 积分商城卡片 */
|
||||||
defineOptions({ name: 'PromotionPoint' });
|
defineOptions({ name: 'PromotionPoint' });
|
||||||
@@ -30,8 +30,7 @@ watch(
|
|||||||
// 检查活动ID的有效性
|
// 检查活动ID的有效性
|
||||||
if (Array.isArray(activityIds) && activityIds.length > 0) {
|
if (Array.isArray(activityIds) && activityIds.length > 0) {
|
||||||
// 获取积分商城活动详情列表
|
// 获取积分商城活动详情列表
|
||||||
pointActivityList.value =
|
pointActivityList.value = await getPointActivityListByIds(activityIds);
|
||||||
await PointActivityApi.getPointActivityListByIds(activityIds);
|
|
||||||
|
|
||||||
// 获取积分商城活动的 SPU 详情列表
|
// 获取积分商城活动的 SPU 详情列表
|
||||||
spuList.value = [];
|
spuList.value = [];
|
||||||
@@ -39,7 +38,7 @@ watch(
|
|||||||
(activity) => activity.spuId,
|
(activity) => activity.spuId,
|
||||||
);
|
);
|
||||||
if (spuIdList.value.length > 0) {
|
if (spuIdList.value.length > 0) {
|
||||||
spuList.value = (await ProductSpuApi.getSpuDetailList(
|
spuList.value = (await getSpuDetailList(
|
||||||
spuIdList.value,
|
spuIdList.value,
|
||||||
)) as MallPointActivityApi.SpuExtensionWithPoint[];
|
)) as MallPointActivityApi.SpuExtensionWithPoint[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts" setup>
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Image } from 'ant-design-vue';
|
import { Image } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as ProductSpuApi from '#/api/mall/product/spu';
|
import { getSpuDetailList } from '#/api/mall/product/spu';
|
||||||
import * as SeckillActivityApi from '#/api/mall/promotion/seckill/seckillActivity';
|
import { getSeckillActivityListByIds } from '#/api/mall/promotion/seckill/seckillActivity';
|
||||||
|
|
||||||
/** 秒杀卡片 */
|
/** 秒杀卡片 */
|
||||||
defineOptions({ name: 'PromotionSeckill' });
|
defineOptions({ name: 'PromotionSeckill' });
|
||||||
@@ -32,7 +32,7 @@ watch(
|
|||||||
if (Array.isArray(activityIds) && activityIds.length > 0) {
|
if (Array.isArray(activityIds) && activityIds.length > 0) {
|
||||||
// 获取秒杀活动详情列表
|
// 获取秒杀活动详情列表
|
||||||
seckillActivityList.value =
|
seckillActivityList.value =
|
||||||
await SeckillActivityApi.getSeckillActivityListByIds(activityIds);
|
await getSeckillActivityListByIds(activityIds);
|
||||||
|
|
||||||
// 获取秒杀活动的 SPU 详情列表
|
// 获取秒杀活动的 SPU 详情列表
|
||||||
spuList.value = [];
|
spuList.value = [];
|
||||||
@@ -40,7 +40,7 @@ watch(
|
|||||||
.map((activity) => activity.spuId)
|
.map((activity) => activity.spuId)
|
||||||
.filter((spuId): spuId is number => typeof spuId === 'number');
|
.filter((spuId): spuId is number => typeof spuId === 'number');
|
||||||
if (spuIdList.value.length > 0) {
|
if (spuIdList.value.length > 0) {
|
||||||
spuList.value = await ProductSpuApi.getSpuDetailList(spuIdList.value);
|
spuList.value = await getSpuDetailList(spuIdList.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 SPU 的最低价格
|
// 更新 SPU 的最低价格
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type { TabBarProperty } from './config';
|
|||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormItem,
|
FormItem,
|
||||||
@@ -45,7 +44,11 @@ const handleThemeChange = () => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="tab-bar">
|
<div class="tab-bar">
|
||||||
<!-- 表单 -->
|
<!-- 表单 -->
|
||||||
<Form :model="formData" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
<Form
|
||||||
|
:model="formData"
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
>
|
||||||
<FormItem label="主题" name="theme">
|
<FormItem label="主题" name="theme">
|
||||||
<Select v-model:value="formData!.theme" @change="handleThemeChange">
|
<Select v-model:value="formData!.theme" @change="handleThemeChange">
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
</script>
|
||||||
|
<template><Page>待完成</Page></template>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import type { VideoPlayerProperty } from './config';
|
import type { VideoPlayerProperty } from './config';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
|
|
||||||
import { Form, FormItem, Slider, Switch } from 'ant-design-vue';
|
import { Form, FormItem, Slider, Switch } from 'ant-design-vue';
|
||||||
|
|
||||||
import UploadFile from '#/components/upload/file-upload.vue';
|
import UploadFile from '#/components/upload/file-upload.vue';
|
||||||
@@ -25,7 +24,11 @@ const formData = useVModel(props, 'modelValue', emit);
|
|||||||
<Slider v-model:value="formData.style.height" :max="500" :min="100" />
|
<Slider v-model:value="formData.style.height" :max="500" :min="100" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<Form :model="formData" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
<Form
|
||||||
|
:model="formData"
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
>
|
||||||
<FormItem label="上传视频" name="videoUrl">
|
<FormItem label="上传视频" name="videoUrl">
|
||||||
<UploadFile
|
<UploadFile
|
||||||
v-model="formData.videoUrl"
|
v-model="formData.videoUrl"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { DiyComponent, DiyComponentLibrary, PageConfig } from './util';
|
import type { DiyComponent, DiyComponentLibrary, PageConfig } from './util';
|
||||||
|
|
||||||
import { inject, onMounted, ref, unref, watch } from 'vue';
|
import { onMounted, ref, unref, watch } from 'vue';
|
||||||
|
|
||||||
import { IFrame } from '@vben/common-ui';
|
import { IFrame } from '@vben/common-ui';
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
@@ -19,57 +19,48 @@ import { componentConfigs, components } from './components/mobile';
|
|||||||
import { component as NAVIGATION_BAR_COMPONENT } from './components/mobile/navigation-bar/config';
|
import { component as NAVIGATION_BAR_COMPONENT } from './components/mobile/navigation-bar/config';
|
||||||
import { component as PAGE_CONFIG_COMPONENT } from './components/mobile/page-config/config';
|
import { component as PAGE_CONFIG_COMPONENT } from './components/mobile/page-config/config';
|
||||||
import { component as TAB_BAR_COMPONENT } from './components/mobile/tab-bar/config';
|
import { component as TAB_BAR_COMPONENT } from './components/mobile/tab-bar/config';
|
||||||
|
|
||||||
/** 页面装修详情页 */
|
/** 页面装修详情页 */
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'DiyPageDetail',
|
name: 'DiyPageDetail',
|
||||||
components,
|
components,
|
||||||
});
|
});
|
||||||
// 定义属性
|
|
||||||
|
/** 定义属性 */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// 页面配置,支持Json字符串
|
modelValue: { type: [String, Object], required: true }, // 页面配置,支持 Json 字符串
|
||||||
modelValue: { type: [String, Object], required: true },
|
title: { type: String, default: '' }, // 标题
|
||||||
// 标题
|
libs: { type: Array<DiyComponentLibrary>, default: () => [] }, // 组件库
|
||||||
title: { type: String, default: '' },
|
showNavigationBar: { type: Boolean, default: true }, // 是否显示顶部导航栏
|
||||||
// 组件库
|
showTabBar: { type: Boolean, default: false }, // 是否显示底部导航菜单
|
||||||
libs: { type: Array<DiyComponentLibrary>, default: () => [] },
|
showPageConfig: { type: Boolean, default: true }, // 是否显示页面配置
|
||||||
// 是否显示顶部导航栏
|
previewUrl: { type: String, default: '' }, // 预览地址:提供了预览地址,才会显示预览按钮
|
||||||
showNavigationBar: { type: Boolean, default: true },
|
|
||||||
// 是否显示底部导航菜单
|
|
||||||
showTabBar: { type: Boolean, default: false },
|
|
||||||
// 是否显示页面配置
|
|
||||||
showPageConfig: { type: Boolean, default: true },
|
|
||||||
// 预览地址:提供了预览地址,才会显示预览按钮
|
|
||||||
previewUrl: { type: String, default: '' },
|
|
||||||
});
|
});
|
||||||
// 工具栏操作
|
|
||||||
const emits = defineEmits(['reset', 'preview', 'save', 'update:modelValue']);
|
const emits = defineEmits(['reset', 'preview', 'save', 'update:modelValue']); // 工具栏操作
|
||||||
|
|
||||||
const qrcode = useQRCode(props.previewUrl, {
|
const qrcode = useQRCode(props.previewUrl, {
|
||||||
errorCorrectionLevel: 'H',
|
errorCorrectionLevel: 'H',
|
||||||
margin: 4,
|
margin: 4,
|
||||||
});
|
}); // 预览二维码
|
||||||
|
|
||||||
// 左侧组件库
|
const componentLibrary = ref(); // 左侧组件库
|
||||||
const componentLibrary = ref();
|
|
||||||
// 页面设置组件
|
|
||||||
const pageConfigComponent = ref<DiyComponent<any>>(
|
const pageConfigComponent = ref<DiyComponent<any>>(
|
||||||
cloneDeep(PAGE_CONFIG_COMPONENT),
|
cloneDeep(PAGE_CONFIG_COMPONENT),
|
||||||
);
|
); // 页面设置组件
|
||||||
// 顶部导航栏
|
|
||||||
const navigationBarComponent = ref<DiyComponent<any>>(
|
const navigationBarComponent = ref<DiyComponent<any>>(
|
||||||
cloneDeep(NAVIGATION_BAR_COMPONENT),
|
cloneDeep(NAVIGATION_BAR_COMPONENT),
|
||||||
);
|
); // 顶部导航栏
|
||||||
// 底部导航菜单
|
const tabBarComponent = ref<DiyComponent<any>>(cloneDeep(TAB_BAR_COMPONENT)); // 底部导航菜单
|
||||||
const tabBarComponent = ref<DiyComponent<any>>(cloneDeep(TAB_BAR_COMPONENT));
|
|
||||||
|
|
||||||
// 选中的组件,默认选中顶部导航栏
|
const selectedComponent = ref<DiyComponent<any>>(); // 选中的组件,默认选中顶部导航栏
|
||||||
const selectedComponent = ref<DiyComponent<any>>();
|
const selectedComponentIndex = ref<number>(-1); // 选中的组件索引
|
||||||
// 选中的组件索引
|
const pageComponents = ref<DiyComponent<any>[]>([]); // 组件列表
|
||||||
const selectedComponentIndex = ref<number>(-1);
|
|
||||||
// 组件列表
|
/**
|
||||||
const pageComponents = ref<DiyComponent<any>[]>([]);
|
* 监听传入的页面配置
|
||||||
// 监听传入的页面配置
|
* 解析出 pageConfigComponent 页面整体的配置,navigationBarComponent、pageComponents、tabBarComponent 页面上、中、下的配置
|
||||||
// 解析出 pageConfigComponent 页面整体的配置,navigationBarComponent、pageComponents、tabBarComponent 页面上、中、下的配置
|
*/
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
() => {
|
() => {
|
||||||
@@ -77,6 +68,7 @@ watch(
|
|||||||
isString(props.modelValue) && !isEmpty(props.modelValue)
|
isString(props.modelValue) && !isEmpty(props.modelValue)
|
||||||
? (JSON.parse(props.modelValue) as PageConfig)
|
? (JSON.parse(props.modelValue) as PageConfig)
|
||||||
: props.modelValue;
|
: props.modelValue;
|
||||||
|
// TODO @AI:这里可以简化么?idea 提示 Invalid 'typeof' check: 'modelValue' cannot have type 'string'
|
||||||
pageConfigComponent.value.property =
|
pageConfigComponent.value.property =
|
||||||
(typeof modelValue !== 'string' && modelValue?.page) ||
|
(typeof modelValue !== 'string' && modelValue?.page) ||
|
||||||
PAGE_CONFIG_COMPONENT.property;
|
PAGE_CONFIG_COMPONENT.property;
|
||||||
@@ -113,19 +105,20 @@ watch(
|
|||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
// 保存
|
/** 保存 */
|
||||||
const handleSave = () => {
|
function handleSave() {
|
||||||
// 发送保存通知
|
// 发送保存通知,由外部保存
|
||||||
emits('save');
|
emits('save');
|
||||||
};
|
}
|
||||||
// 监听配置修改
|
|
||||||
const pageConfigChange = () => {
|
/** 监听配置修改 */
|
||||||
|
function pageConfigChange() {
|
||||||
const pageConfig = {
|
const pageConfig = {
|
||||||
page: pageConfigComponent.value.property,
|
page: pageConfigComponent.value.property,
|
||||||
navigationBar: navigationBarComponent.value.property,
|
navigationBar: navigationBarComponent.value.property,
|
||||||
tabBar: tabBarComponent.value.property,
|
tabBar: tabBarComponent.value.property,
|
||||||
components: pageComponents.value.map((component) => {
|
components: pageComponents.value.map((component) => {
|
||||||
// 只保留APP有用的字段
|
// 只保留 APP 有用的字段
|
||||||
return { id: component.id, property: component.property };
|
return { id: component.id, property: component.property };
|
||||||
}),
|
}),
|
||||||
} as PageConfig;
|
} as PageConfig;
|
||||||
@@ -137,7 +130,8 @@ const pageConfigChange = () => {
|
|||||||
? JSON.stringify(pageConfig)
|
? JSON.stringify(pageConfig)
|
||||||
: pageConfig;
|
: pageConfig;
|
||||||
emits('update:modelValue', modelValue);
|
emits('update:modelValue', modelValue);
|
||||||
};
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [
|
() => [
|
||||||
pageConfigComponent.value.property,
|
pageConfigComponent.value.property,
|
||||||
@@ -150,15 +144,17 @@ watch(
|
|||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
// 处理页面选中:显示属性表单
|
|
||||||
const handlePageSelected = (event: any) => {
|
|
||||||
if (!props.showPageConfig) return;
|
|
||||||
|
|
||||||
|
/** 处理页面选中:显示属性表单 */
|
||||||
|
function handlePageSelected(event: any) {
|
||||||
|
if (!props.showPageConfig) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 配置了样式 page-prop-area 的元素,才显示页面设置
|
// 配置了样式 page-prop-area 的元素,才显示页面设置
|
||||||
if (event?.target?.classList?.contains('page-prop-area')) {
|
if (event?.target?.classList?.contains('page-prop-area')) {
|
||||||
handleComponentSelected(unref(pageConfigComponent));
|
handleComponentSelected(unref(pageConfigComponent));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选中组件
|
* 选中组件
|
||||||
@@ -166,26 +162,26 @@ const handlePageSelected = (event: any) => {
|
|||||||
* @param component 组件
|
* @param component 组件
|
||||||
* @param index 组件的索引
|
* @param index 组件的索引
|
||||||
*/
|
*/
|
||||||
const handleComponentSelected = (
|
function handleComponentSelected(
|
||||||
component: DiyComponent<any>,
|
component: DiyComponent<any>,
|
||||||
index: number = -1,
|
index: number = -1,
|
||||||
) => {
|
) {
|
||||||
selectedComponent.value = component;
|
selectedComponent.value = component;
|
||||||
selectedComponentIndex.value = index;
|
selectedComponentIndex.value = index;
|
||||||
};
|
}
|
||||||
|
|
||||||
// 选中顶部导航栏
|
/** 选中顶部导航栏 */
|
||||||
const handleNavigationBarSelected = () => {
|
function handleNavigationBarSelected() {
|
||||||
handleComponentSelected(unref(navigationBarComponent));
|
handleComponentSelected(unref(navigationBarComponent));
|
||||||
};
|
}
|
||||||
|
|
||||||
// 选中底部导航菜单
|
/** 选中底部导航菜单 */
|
||||||
const handleTabBarSelected = () => {
|
function handleTabBarSelected() {
|
||||||
handleComponentSelected(unref(tabBarComponent));
|
handleComponentSelected(unref(tabBarComponent));
|
||||||
};
|
}
|
||||||
|
|
||||||
// 组件变动(拖拽)
|
/** 组件变动(拖拽) */
|
||||||
const handleComponentChange = (dragEvent: any) => {
|
function handleComponentChange(dragEvent: any) {
|
||||||
// 新增,即从组件库拖拽添加组件
|
// 新增,即从组件库拖拽添加组件
|
||||||
if (dragEvent.added) {
|
if (dragEvent.added) {
|
||||||
const { element, newIndex } = dragEvent.added;
|
const { element, newIndex } = dragEvent.added;
|
||||||
@@ -196,40 +192,38 @@ const handleComponentChange = (dragEvent: any) => {
|
|||||||
// 保持选中
|
// 保持选中
|
||||||
selectedComponentIndex.value = newIndex;
|
selectedComponentIndex.value = newIndex;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// 交换组件
|
/** 交换组件 */
|
||||||
const swapComponent = (oldIndex: number, newIndex: number) => {
|
function swapComponent(oldIndex: number, newIndex: number) {
|
||||||
const temp = pageComponents.value[oldIndex]!;
|
const temp = pageComponents.value[oldIndex]!;
|
||||||
pageComponents.value[oldIndex] = pageComponents.value[newIndex]!;
|
pageComponents.value[oldIndex] = pageComponents.value[newIndex]!;
|
||||||
pageComponents.value[newIndex] = temp;
|
pageComponents.value[newIndex] = temp;
|
||||||
// 保持选中
|
// 保持选中
|
||||||
selectedComponentIndex.value = newIndex;
|
selectedComponentIndex.value = newIndex;
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 移动组件(上移、下移) */
|
/** 移动组件(上移、下移) */
|
||||||
const handleMoveComponent = (index: number, direction: number) => {
|
function handleMoveComponent(index: number, direction: number) {
|
||||||
const newIndex = index + direction;
|
const newIndex = index + direction;
|
||||||
if (newIndex < 0 || newIndex >= pageComponents.value.length) return;
|
if (newIndex < 0 || newIndex >= pageComponents.value.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
swapComponent(index, newIndex);
|
swapComponent(index, newIndex);
|
||||||
};
|
}
|
||||||
|
|
||||||
/** 复制组件 */
|
/** 复制组件 */
|
||||||
const handleCopyComponent = (index: number) => {
|
function handleCopyComponent(index: number) {
|
||||||
const component = pageComponents.value[index];
|
const component = pageComponents.value[index];
|
||||||
if (component) {
|
if (component) {
|
||||||
const clonedComponent = cloneDeep(component);
|
const clonedComponent = cloneDeep(component);
|
||||||
clonedComponent.uid = Date.now();
|
clonedComponent.uid = Date.now();
|
||||||
pageComponents.value.splice(index + 1, 0, clonedComponent);
|
pageComponents.value.splice(index + 1, 0, clonedComponent);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/** 删除组件 */
|
||||||
* 删除组件
|
function handleDeleteComponent(index: number) {
|
||||||
* @param index 当前组件index
|
|
||||||
*/
|
|
||||||
const handleDeleteComponent = (index: number) => {
|
|
||||||
// 删除组件
|
// 删除组件
|
||||||
pageComponents.value.splice(index, 1);
|
pageComponents.value.splice(index, 1);
|
||||||
if (index < pageComponents.value.length) {
|
if (index < pageComponents.value.length) {
|
||||||
@@ -250,25 +244,23 @@ const handleDeleteComponent = (index: number) => {
|
|||||||
// 3. 组件全部删除之后,显示页面设置
|
// 3. 组件全部删除之后,显示页面设置
|
||||||
handleComponentSelected(unref(pageConfigComponent));
|
handleComponentSelected(unref(pageConfigComponent));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// // 注入无感刷新页面函数
|
/** 重置 */
|
||||||
// const reload = inject<() => void>('reload'); // TODO @芋艿:是 vue3 + element-plus 独有的,可以清理掉。
|
function handleReset() {
|
||||||
// // 重置
|
emits('reset');
|
||||||
// const handleReset = () => {
|
}
|
||||||
// if (reload) reload();
|
|
||||||
// emits('reset');
|
|
||||||
// };
|
|
||||||
|
|
||||||
// 预览
|
// TODO @AI:搞成 modal 来?
|
||||||
|
/** 预览 */
|
||||||
const previewDialogVisible = ref(false);
|
const previewDialogVisible = ref(false);
|
||||||
const handlePreview = () => {
|
function handlePreview() {
|
||||||
previewDialogVisible.value = true;
|
previewDialogVisible.value = true;
|
||||||
emits('preview');
|
emits('preview');
|
||||||
};
|
}
|
||||||
|
|
||||||
// 设置默认选中的组件
|
/** 设置默认选中的组件 */
|
||||||
const setDefaultSelectedComponent = () => {
|
function setDefaultSelectedComponent() {
|
||||||
if (props.showPageConfig) {
|
if (props.showPageConfig) {
|
||||||
selectedComponent.value = unref(pageConfigComponent);
|
selectedComponent.value = unref(pageConfigComponent);
|
||||||
} else if (props.showNavigationBar) {
|
} else if (props.showNavigationBar) {
|
||||||
@@ -276,12 +268,14 @@ const setDefaultSelectedComponent = () => {
|
|||||||
} else if (props.showTabBar) {
|
} else if (props.showTabBar) {
|
||||||
selectedComponent.value = unref(tabBarComponent);
|
selectedComponent.value = unref(tabBarComponent);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.showPageConfig, props.showNavigationBar, props.showTabBar],
|
() => [props.showPageConfig, props.showNavigationBar, props.showTabBar],
|
||||||
() => setDefaultSelectedComponent(),
|
() => setDefaultSelectedComponent(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setDefaultSelectedComponent();
|
setDefaultSelectedComponent();
|
||||||
});
|
});
|
||||||
@@ -614,12 +608,12 @@ $phone-width: 375px;
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
:deep(.ant-tag) {
|
:deep(.ant-tag) {
|
||||||
border: none;
|
|
||||||
box-shadow: 0 2px 8px 0 rgb(0 0 0 / 10%);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 2px 8px 0 rgb(0 0 0 / 10%);
|
||||||
|
|
||||||
.anticon {
|
.anticon {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
|
|||||||
@@ -2,37 +2,29 @@ import type { NavigationBarProperty } from './components/mobile/navigation-bar/c
|
|||||||
import type { PageConfigProperty } from './components/mobile/page-config/config';
|
import type { PageConfigProperty } from './components/mobile/page-config/config';
|
||||||
import type { TabBarProperty } from './components/mobile/tab-bar/config';
|
import type { TabBarProperty } from './components/mobile/tab-bar/config';
|
||||||
|
|
||||||
// 页面装修组件
|
/** 页面装修组件 */
|
||||||
export interface DiyComponent<T> {
|
export interface DiyComponent<T> {
|
||||||
// 用于区分同一种组件的不同实例
|
uid?: number; // 用于区分同一种组件的不同实例
|
||||||
uid?: number;
|
id: string; // 组件唯一标识
|
||||||
// 组件唯一标识
|
name: string; // 组件名称
|
||||||
id: string;
|
icon: string; // 组件图标
|
||||||
// 组件名称
|
|
||||||
name: string;
|
|
||||||
// 组件图标
|
|
||||||
icon: string;
|
|
||||||
/*
|
/*
|
||||||
组件位置:
|
组件位置:
|
||||||
top: 固定于手机顶部,例如 顶部的导航栏
|
top: 固定于手机顶部,例如 顶部的导航栏
|
||||||
bottom: 固定于手机底部,例如 底部的菜单导航栏
|
bottom: 固定于手机底部,例如 底部的菜单导航栏
|
||||||
center: 位于手机中心,每个组件占一行,顺序向下排列
|
center: 位于手机中心,每个组件占一行,顺序向下排列
|
||||||
空:同center
|
空:同 center
|
||||||
fixed: 由组件自己决定位置,如弹窗位于手机中心、浮动按钮一般位于手机右下角
|
fixed: 由组件自己决定位置,如弹窗位于手机中心、浮动按钮一般位于手机右下角
|
||||||
*/
|
*/
|
||||||
position?: '' | 'bottom' | 'center' | 'fixed' | 'top';
|
position?: '' | 'bottom' | 'center' | 'fixed' | 'top';
|
||||||
// 组件属性
|
property: T; // 组件属性
|
||||||
property: T;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面装修组件库
|
/** 页面装修组件库 */
|
||||||
export interface DiyComponentLibrary {
|
export interface DiyComponentLibrary {
|
||||||
// 组件库名称
|
name: string; // 组件库名称
|
||||||
name: string;
|
extended: boolean; // 是否展开
|
||||||
// 是否展开
|
components: string[]; // 组件列表
|
||||||
extended: boolean;
|
|
||||||
// 组件列表
|
|
||||||
components: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组件样式
|
// 组件样式
|
||||||
@@ -63,21 +55,18 @@ export interface ComponentStyle {
|
|||||||
borderBottomLeftRadius: number;
|
borderBottomLeftRadius: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面配置
|
/** 页面配置 */
|
||||||
export interface PageConfig {
|
export interface PageConfig {
|
||||||
// 页面属性
|
page: PageConfigProperty; // 页面属性
|
||||||
page: PageConfigProperty;
|
navigationBar: NavigationBarProperty; // 顶部导航栏属性
|
||||||
// 顶部导航栏属性
|
tabBar?: TabBarProperty; // 底部导航菜单属性
|
||||||
navigationBar: NavigationBarProperty;
|
|
||||||
// 底部导航菜单属性
|
|
||||||
tabBar?: TabBarProperty;
|
|
||||||
// 页面组件列表
|
|
||||||
components: PageComponent[];
|
|
||||||
}
|
|
||||||
// 页面组件,只保留组件ID,组件属性
|
|
||||||
export type PageComponent = Pick<DiyComponent<any>, 'id' | 'property'>;
|
|
||||||
|
|
||||||
// 页面组件库
|
components: PageComponent[]; // 页面组件列表
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PageComponent = Pick<DiyComponent<any>, 'id' | 'property'>; // 页面组件,只保留组件 ID,组件属性
|
||||||
|
|
||||||
|
/** 页面组件库 */
|
||||||
export const PAGE_LIBS = [
|
export const PAGE_LIBS = [
|
||||||
{
|
{
|
||||||
name: '基础组件',
|
name: '基础组件',
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getCouponTemplatePage } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
|
||||||
|
import { discountFormat } from '../formatter';
|
||||||
|
import { useCouponSelectFormSchema, useCouponSelectGridColumns } from './data';
|
||||||
|
|
||||||
|
defineOptions({ name: 'CouponSelect' });
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
takeType?: number; // 领取方式
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [value: MallCouponTemplateApi.CouponTemplate[]];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const selectedCoupons = ref<MallCouponTemplateApi.CouponTemplate[]>([]);
|
||||||
|
|
||||||
|
/** Grid 配置 */
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useCouponSelectFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useCouponSelectGridColumns(),
|
||||||
|
height: '500px',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
// TODO @芋艿:要不要 ele 和 antd 统一下;
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
const params: any = {
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 如果有 takeType 参数,添加到查询条件
|
||||||
|
if (props.takeType !== undefined) {
|
||||||
|
params.canTakeTypes = [props.takeType];
|
||||||
|
}
|
||||||
|
|
||||||
|
return await getCouponTemplatePage(params);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MallCouponTemplateApi.CouponTemplate>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 复选框变化处理 */
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: MallCouponTemplateApi.CouponTemplate[];
|
||||||
|
}) {
|
||||||
|
selectedCoupons.value = records;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Modal 配置 */
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
onConfirm() {
|
||||||
|
emit('change', selectedCoupons.value);
|
||||||
|
modalApi.close();
|
||||||
|
},
|
||||||
|
onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
selectedCoupons.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gridApi.query();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
function open() {
|
||||||
|
modalApi.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal title="选择优惠券" class="w-2/3">
|
||||||
|
<Grid table-title="优惠券列表">
|
||||||
|
<!-- 优惠列自定义渲染 -->
|
||||||
|
<template #discount="{ row }">
|
||||||
|
<DictTag
|
||||||
|
:type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE"
|
||||||
|
:value="row.discountType"
|
||||||
|
/>
|
||||||
|
<span class="ml-1">{{ discountFormat(row) }}</span>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
@@ -1,13 +1,42 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
discountFormat,
|
discountFormat,
|
||||||
remainedCountFormat,
|
remainedCountFormat,
|
||||||
|
takeLimitCountFormat,
|
||||||
usePriceFormat,
|
usePriceFormat,
|
||||||
validityTypeFormat,
|
validityTypeFormat,
|
||||||
} from '../formatter';
|
} from '../formatter';
|
||||||
|
|
||||||
|
/** 优惠券选择弹窗的搜索表单 schema */
|
||||||
|
export function useCouponSelectFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '优惠券名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入优惠券名称',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
fieldName: 'discountType',
|
||||||
|
label: '优惠类型',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE, 'number'),
|
||||||
|
placeholder: '请选择优惠类型',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/** 搜索表单的 schema */
|
/** 搜索表单的 schema */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
@@ -23,6 +52,78 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 优惠券选择弹窗的表格列配置 */
|
||||||
|
export function useCouponSelectGridColumns(): VxeGridProps['columns'] {
|
||||||
|
return [
|
||||||
|
{ type: 'checkbox', width: 55 },
|
||||||
|
{
|
||||||
|
title: '优惠券名称',
|
||||||
|
field: 'name',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类型',
|
||||||
|
field: 'productScope',
|
||||||
|
minWidth: 80,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.PROMOTION_PRODUCT_SCOPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '优惠',
|
||||||
|
field: 'discount',
|
||||||
|
minWidth: 100,
|
||||||
|
slots: { default: 'discount' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '领取方式',
|
||||||
|
field: 'takeType',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.PROMOTION_COUPON_TAKE_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '使用时间',
|
||||||
|
field: 'validityType',
|
||||||
|
minWidth: 185,
|
||||||
|
align: 'center',
|
||||||
|
formatter: ({ row }) => validityTypeFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '发放数量',
|
||||||
|
field: 'totalCount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '剩余数量',
|
||||||
|
minWidth: 100,
|
||||||
|
align: 'center',
|
||||||
|
formatter: ({ row }) => remainedCountFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '领取上限',
|
||||||
|
field: 'takeLimitCount',
|
||||||
|
minWidth: 100,
|
||||||
|
align: 'center',
|
||||||
|
formatter: ({ row }) => takeLimitCountFormat(row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
field: 'status',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 80,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/** 表格列配置 */
|
/** 表格列配置 */
|
||||||
export function useGridColumns(): VxeGridProps['columns'] {
|
export function useGridColumns(): VxeGridProps['columns'] {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
export { default as CouponSelect } from './coupon-select.vue';
|
||||||
export * from './data';
|
export * from './data';
|
||||||
export { default as CouponSendForm } from './send-form.vue';
|
export { default as CouponSendForm } from './send-form.vue';
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import { useRoute } from 'vue-router';
|
|||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as DiyPageApi from '#/api/mall/promotion/diy/page';
|
import {
|
||||||
|
getDiyPageProperty,
|
||||||
|
updateDiyPageProperty,
|
||||||
|
} from '#/api/mall/promotion/diy/page';
|
||||||
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
|
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
|
||||||
|
|
||||||
/** 装修页面表单 */
|
/** 装修页面表单 */
|
||||||
@@ -23,7 +26,7 @@ async function getPageDetail(id: any) {
|
|||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
formData.value = await DiyPageApi.getDiyPageProperty(id);
|
formData.value = await getDiyPageProperty(id);
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@@ -36,7 +39,7 @@ async function submitForm() {
|
|||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await DiyPageApi.updateDiyPageProperty(unref(formData)!);
|
await updateDiyPageProperty(unref(formData)!);
|
||||||
message.success('保存成功');
|
message.success('保存成功');
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ import { isEmpty } from '@vben/utils';
|
|||||||
|
|
||||||
import { message, Radio, RadioGroup, Tooltip } from 'ant-design-vue';
|
import { message, Radio, RadioGroup, Tooltip } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as DiyPageApi from '#/api/mall/promotion/diy/page';
|
import { updateDiyPageProperty } from '#/api/mall/promotion/diy/page';
|
||||||
import * as DiyTemplateApi from '#/api/mall/promotion/diy/template';
|
import {
|
||||||
|
getDiyTemplateProperty,
|
||||||
|
updateDiyTemplateProperty,
|
||||||
|
} from '#/api/mall/promotion/diy/template';
|
||||||
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
|
import { DiyEditor, PAGE_LIBS } from '#/views/mall/promotion/components';
|
||||||
|
|
||||||
/** 装修模板表单 */
|
/** 装修模板表单 */
|
||||||
@@ -54,7 +57,7 @@ async function getPageDetail(id: any) {
|
|||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
formData.value = await DiyTemplateApi.getDiyTemplateProperty(id);
|
formData.value = await getDiyTemplateProperty(id);
|
||||||
|
|
||||||
// 拼接手机预览链接
|
// 拼接手机预览链接
|
||||||
const domain = import.meta.env.VITE_MALL_H5_DOMAIN;
|
const domain = import.meta.env.VITE_MALL_H5_DOMAIN;
|
||||||
@@ -112,20 +115,18 @@ async function submitForm() {
|
|||||||
// 情况一:基础设置
|
// 情况一:基础设置
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
// 提交模板属性
|
// 提交模板属性
|
||||||
await DiyTemplateApi.updateDiyTemplateProperty(
|
await updateDiyTemplateProperty(isEmpty(data) ? formData.value! : data);
|
||||||
isEmpty(data) ? formData.value! : data,
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 提交页面属性
|
// 提交页面属性
|
||||||
// 情况二:提交当前正在编辑的页面
|
// 情况二:提交当前正在编辑的页面
|
||||||
if (currentFormData.value?.name.includes(templateItem.name)) {
|
if (currentFormData.value?.name.includes(templateItem.name)) {
|
||||||
await DiyPageApi.updateDiyPageProperty(currentFormData.value!);
|
await updateDiyPageProperty(currentFormData.value!);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 情况三:提交页面编辑缓存
|
// 情况三:提交页面编辑缓存
|
||||||
if (!isEmpty(data)) {
|
if (!isEmpty(data)) {
|
||||||
await DiyPageApi.updateDiyPageProperty(data!);
|
await updateDiyPageProperty(data!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.success('保存成功');
|
message.success('保存成功');
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import {
|
|||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { getPropertyList } from '#/views/mall/product/spu/form';
|
import { getPropertyList } from '#/views/mall/product/spu/form';
|
||||||
|
|
||||||
import { SpuAndSkuList, SpuSkuSelect } from '../../../components';
|
// TODO @puhui999:有问题
|
||||||
|
// import { SpuAndSkuList, SpuSkuSelect } from '../../../components';
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- eslint-disable unicorn/no-nested-ternary -->
|
||||||
<!-- 积分活动橱窗组件 - 用于装修时展示和选择积分活动 -->
|
<!-- 积分活动橱窗组件 - 用于装修时展示和选择积分活动 -->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// TODO @puhui999:看看是不是整体优化下代码风格,参考别的模块
|
// TODO @puhui999:看看是不是整体优化下代码风格,参考别的模块
|
||||||
@@ -95,9 +96,9 @@ watch(
|
|||||||
async () => {
|
async () => {
|
||||||
const ids = Array.isArray(props.modelValue)
|
const ids = Array.isArray(props.modelValue)
|
||||||
? props.modelValue
|
? props.modelValue
|
||||||
: (props.modelValue
|
: props.modelValue
|
||||||
? [props.modelValue]
|
? [props.modelValue]
|
||||||
: []);
|
: [];
|
||||||
|
|
||||||
// 不需要返显
|
// 不需要返显
|
||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
@@ -158,7 +159,7 @@ watch(
|
|||||||
<!-- 积分活动选择对话框 -->
|
<!-- 积分活动选择对话框 -->
|
||||||
<PointTableSelect
|
<PointTableSelect
|
||||||
ref="pointActivityTableSelectRef"
|
ref="pointActivityTableSelectRef"
|
||||||
:multiple="limit != 1"
|
:multiple="limit !== 1"
|
||||||
@change="handleActivitySelected"
|
@change="handleActivitySelected"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
export { default as RewardRuleCouponSelect } from './reward-rule-coupon-select.vue';
|
|
||||||
export { default as RewardRule } from './reward-rule.vue';
|
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import {
|
||||||
|
DICT_TYPE,
|
||||||
|
PromotionConditionTypeEnum,
|
||||||
|
PromotionProductScopeEnum,
|
||||||
|
} from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
@@ -98,8 +103,8 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
component: 'Input',
|
|
||||||
fieldName: 'id',
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
triggerFields: [''],
|
triggerFields: [''],
|
||||||
show: () => false,
|
show: () => false,
|
||||||
@@ -109,23 +114,24 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
fieldName: 'name',
|
fieldName: 'name',
|
||||||
label: '活动名称',
|
label: '活动名称',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
rules: 'required',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入活动名称',
|
placeholder: '请输入活动名称',
|
||||||
|
allowClear: true,
|
||||||
},
|
},
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'startAndEndTime',
|
fieldName: 'startAndEndTime',
|
||||||
label: '活动时间',
|
label: '活动时间',
|
||||||
component: 'RangePicker',
|
component: 'RangePicker',
|
||||||
|
rules: 'required',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
showTime: true,
|
showTime: true,
|
||||||
format: 'YYYY-MM-DD HH:mm:ss',
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
placeholder: [$t('common.startTimeText'), $t('common.endTimeText')],
|
placeholder: [$t('common.startTimeText'), $t('common.endTimeText')],
|
||||||
|
allowClear: true,
|
||||||
},
|
},
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
// TODO @puhui999:增加一个 defaultValue
|
|
||||||
{
|
{
|
||||||
fieldName: 'conditionType',
|
fieldName: 'conditionType',
|
||||||
label: '条件类型',
|
label: '条件类型',
|
||||||
@@ -135,8 +141,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
buttonStyle: 'solid',
|
buttonStyle: 'solid',
|
||||||
optionType: 'button',
|
optionType: 'button',
|
||||||
},
|
},
|
||||||
defaultValue: PromotionConditionTypeEnum.PRICE.type,
|
rules: z.number().default(PromotionConditionTypeEnum.PRICE.type),
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'productScope',
|
fieldName: 'productScope',
|
||||||
@@ -147,7 +152,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
buttonStyle: 'solid',
|
buttonStyle: 'solid',
|
||||||
optionType: 'button',
|
optionType: 'button',
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: z.number().default(PromotionProductScopeEnum.ALL.scope),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldName: 'remark',
|
fieldName: 'remark',
|
||||||
@@ -156,6 +161,24 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
placeholder: '请输入备注',
|
placeholder: '请输入备注',
|
||||||
rows: 4,
|
rows: 4,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'rules',
|
||||||
|
label: '优惠设置',
|
||||||
|
component: 'Input',
|
||||||
|
formItemClass: 'items-start',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productSpuIds',
|
||||||
|
label: '选择商品',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['productScope'],
|
||||||
|
show: (values) => {
|
||||||
|
return values.productScope === PromotionProductScopeEnum.SPU.scope;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|||||||
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { CommonStatusEnum } from '@vben/constants';
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
@@ -41,13 +42,14 @@ function handleEdit(row: MallRewardActivityApi.RewardActivity) {
|
|||||||
|
|
||||||
/** 关闭满减送活动 */
|
/** 关闭满减送活动 */
|
||||||
async function handleClose(row: MallRewardActivityApi.RewardActivity) {
|
async function handleClose(row: MallRewardActivityApi.RewardActivity) {
|
||||||
|
// TODO @puhui999:这个国际化,需要加下哈;closing、closeSuccess;
|
||||||
const hideLoading = message.loading({
|
const hideLoading = message.loading({
|
||||||
content: '正在关闭中...',
|
content: $t('ui.actionMessage.closing', [row.name]),
|
||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await closeRewardActivity(row.id!);
|
await closeRewardActivity(row.id!);
|
||||||
message.success('关闭成功');
|
message.success($t('ui.actionMessage.closeSuccess', [row.name]));
|
||||||
handleRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
@@ -96,7 +98,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
refresh: true,
|
refresh: true,
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions,
|
} as VxeTableGridOptions<MallRewardActivityApi.RewardActivity>,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -111,19 +113,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
label: $t('ui.actionTitle.create', ['活动']),
|
label: $t('ui.actionTitle.create', ['活动']),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: ACTION_ICON.ADD,
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['promotion:reward-activity:create'],
|
||||||
onClick: handleCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #actions="{ row }">
|
<template #actions="{ row }">
|
||||||
<!-- TODO @AI:table action 的权限标识;参考 /Users/yunai/Java/yudao-ui-admin-vue3/src/views/mall/promotion/rewardActivity/index.vue -->
|
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
{
|
{
|
||||||
label: $t('common.edit'),
|
label: $t('common.edit'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
icon: ACTION_ICON.EDIT,
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['promotion:reward-activity:update'],
|
||||||
onClick: handleEdit.bind(null, row),
|
onClick: handleEdit.bind(null, row),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -131,9 +134,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.CLOSE,
|
icon: ACTION_ICON.CLOSE,
|
||||||
ifShow: row.status === 0,
|
auth: ['promotion:reward-activity:close'],
|
||||||
|
ifShow: row.status === CommonStatusEnum.ENABLE,
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: '确认关闭该满减活动吗?',
|
title: '确认关闭该满减送活动吗?',
|
||||||
confirm: handleClose.bind(null, row),
|
confirm: handleClose.bind(null, row),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -142,6 +146,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['promotion:reward-activity:delete'],
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
confirm: handleDelete.bind(null, row),
|
confirm: handleDelete.bind(null, row),
|
||||||
@@ -153,4 +158,3 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VbenFormProps } from '#/adapter/form';
|
|
||||||
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
||||||
|
|
||||||
import { computed, nextTick, ref } from 'vue';
|
import { computed, nextTick, ref } from 'vue';
|
||||||
@@ -11,7 +10,7 @@ import {
|
|||||||
} from '@vben/constants';
|
} from '@vben/constants';
|
||||||
import { convertToInteger, formatToFraction } from '@vben/utils';
|
import { convertToInteger, formatToFraction } from '@vben/utils';
|
||||||
|
|
||||||
import { Alert, FormItem, message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import {
|
import {
|
||||||
@@ -20,18 +19,19 @@ import {
|
|||||||
updateRewardActivity,
|
updateRewardActivity,
|
||||||
} from '#/api/mall/promotion/reward/rewardActivity';
|
} from '#/api/mall/promotion/reward/rewardActivity';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { SpuAndSkuList } from '#/views/mall/promotion/components';
|
import { SpuShowcase } from '#/views/mall/product/spu/components';
|
||||||
|
|
||||||
import RewardRule from '../components/reward-rule.vue';
|
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
|
import RewardRule from './reward-rule.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
// TODO @puhui999:代码风格,和别的 form 保持一致;
|
|
||||||
const formData = ref<MallRewardActivityApi.RewardActivity>({
|
const formData = ref<MallRewardActivityApi.RewardActivity>({
|
||||||
conditionType: PromotionConditionTypeEnum.PRICE.type,
|
conditionType: PromotionConditionTypeEnum.PRICE.type,
|
||||||
productScope: PromotionProductScopeEnum.ALL.scope,
|
productScope: PromotionProductScopeEnum.ALL.scope,
|
||||||
rules: [],
|
rules: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return formData.value?.id
|
return formData.value?.id
|
||||||
? $t('ui.actionTitle.edit', ['满减送'])
|
? $t('ui.actionTitle.edit', ['满减送'])
|
||||||
@@ -43,13 +43,16 @@ const [Form, formApi] = useVbenForm({
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
},
|
},
|
||||||
} as VbenFormProps['commonConfig'],
|
labelWidth: 100,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const rewardRuleRef = ref<InstanceType<typeof RewardRule>>();
|
const rewardRuleRef = ref<InstanceType<typeof RewardRule>>();
|
||||||
|
|
||||||
|
// TODO @芋艿:这里需要在简化下;
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
async onConfirm() {
|
async onConfirm() {
|
||||||
const { valid } = await formApi.validate();
|
const { valid } = await formApi.validate();
|
||||||
@@ -59,29 +62,28 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
const data = await formApi.getValues();
|
const data = await formApi.getValues();
|
||||||
// 设置活动规则优惠券
|
|
||||||
rewardRuleRef.value?.setRuleCoupon();
|
rewardRuleRef.value?.setRuleCoupon();
|
||||||
// 时间段转换
|
|
||||||
if (data.startAndEndTime && Array.isArray(data.startAndEndTime)) {
|
if (data.startAndEndTime && Array.isArray(data.startAndEndTime)) {
|
||||||
data.startTime = data.startAndEndTime[0];
|
data.startTime = data.startAndEndTime[0];
|
||||||
data.endTime = data.startAndEndTime[1];
|
data.endTime = data.startAndEndTime[1];
|
||||||
delete data.startAndEndTime;
|
delete data.startAndEndTime;
|
||||||
}
|
}
|
||||||
// 规则元转分
|
|
||||||
data.rules?.forEach((item: any) => {
|
data.rules?.forEach((item: any) => {
|
||||||
item.discountPrice = convertToInteger(item.discountPrice || 0);
|
item.discountPrice = convertToInteger(item.discountPrice || 0);
|
||||||
if (data.conditionType === PromotionConditionTypeEnum.PRICE.type) {
|
if (data.conditionType === PromotionConditionTypeEnum.PRICE.type) {
|
||||||
item.limit = convertToInteger(item.limit || 0);
|
item.limit = convertToInteger(item.limit || 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 设置商品范围
|
|
||||||
setProductScopeValues(data);
|
setProductScopeValues(data);
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
await (formData.value?.id
|
await (formData.value?.id
|
||||||
? updateRewardActivity(<MallRewardActivityApi.RewardActivity>data)
|
? updateRewardActivity(data as MallRewardActivityApi.RewardActivity)
|
||||||
: createRewardActivity(<MallRewardActivityApi.RewardActivity>data));
|
: createRewardActivity(data as MallRewardActivityApi.RewardActivity));
|
||||||
// 关闭并提示
|
|
||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -98,17 +100,18 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
|
||||||
const data = modalApi.getData<MallRewardActivityApi.RewardActivity>();
|
const data = modalApi.getData<MallRewardActivityApi.RewardActivity>();
|
||||||
if (!data || !data.id) {
|
if (!data || !data.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
const result = await getReward(data.id);
|
const result = await getReward(data.id);
|
||||||
// 转区段时间
|
|
||||||
result.startAndEndTime = [result.startTime, result.endTime];
|
result.startAndEndTime = [result.startTime, result.endTime] as any[];
|
||||||
// 规则分转元
|
|
||||||
result.rules?.forEach((item: any) => {
|
result.rules?.forEach((item: any) => {
|
||||||
item.discountPrice = formatToFraction(item.discountPrice || 0);
|
item.discountPrice = formatToFraction(item.discountPrice || 0);
|
||||||
if (result.conditionType === PromotionConditionTypeEnum.PRICE.type) {
|
if (result.conditionType === PromotionConditionTypeEnum.PRICE.type) {
|
||||||
@@ -117,10 +120,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
formData.value = result;
|
formData.value = result;
|
||||||
// 设置到 values
|
|
||||||
await formApi.setValues(result);
|
await formApi.setValues(result);
|
||||||
|
|
||||||
// 获得商品范围
|
|
||||||
await getProductScope();
|
await getProductScope();
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
@@ -128,8 +129,6 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 获得商品范围 */
|
|
||||||
// TODO @puhui999:可以参考下优惠劵模版的做法;可见 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mall/promotion/coupon/template/data.ts 的 295 行;
|
|
||||||
async function getProductScope() {
|
async function getProductScope() {
|
||||||
switch (formData.value.productScope) {
|
switch (formData.value.productScope) {
|
||||||
case PromotionProductScopeEnum.CATEGORY.scope: {
|
case PromotionProductScopeEnum.CATEGORY.scope: {
|
||||||
@@ -139,15 +138,12 @@ async function getProductScope() {
|
|||||||
Array.isArray(productCategoryIds) &&
|
Array.isArray(productCategoryIds) &&
|
||||||
productCategoryIds.length === 1
|
productCategoryIds.length === 1
|
||||||
) {
|
) {
|
||||||
// 单选时使用数组不能反显
|
|
||||||
productCategoryIds = productCategoryIds[0];
|
productCategoryIds = productCategoryIds[0];
|
||||||
}
|
}
|
||||||
// 设置品类编号
|
|
||||||
formData.value.productCategoryIds = productCategoryIds;
|
formData.value.productCategoryIds = productCategoryIds;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PromotionProductScopeEnum.SPU.scope: {
|
case PromotionProductScopeEnum.SPU.scope: {
|
||||||
// 设置商品编号
|
|
||||||
formData.value.productSpuIds = formData.value.productScopeValues;
|
formData.value.productSpuIds = formData.value.productScopeValues;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -157,7 +153,6 @@ async function getProductScope() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置商品范围 */
|
|
||||||
function setProductScopeValues(data: any) {
|
function setProductScopeValues(data: any) {
|
||||||
switch (formData.value.productScope) {
|
switch (formData.value.productScope) {
|
||||||
case PromotionProductScopeEnum.CATEGORY.scope: {
|
case PromotionProductScopeEnum.CATEGORY.scope: {
|
||||||
@@ -178,32 +173,17 @@ function setProductScopeValues(data: any) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle" class="!w-[65%]">
|
<Modal :title="getTitle" class="w-2/3">
|
||||||
<!-- TODO @puhui999:貌似可以不要? -->
|
<Form class="mx-6">
|
||||||
<Alert
|
<!-- 自定义插槽:优惠规则 -->
|
||||||
description="【营销】满减送"
|
<template #rules>
|
||||||
message="提示"
|
<RewardRule ref="rewardRuleRef" v-model="formData" />
|
||||||
show-icon
|
</template>
|
||||||
type="info"
|
|
||||||
class="mb-4"
|
|
||||||
/>
|
|
||||||
<Form class="mx-4" />
|
|
||||||
|
|
||||||
<!-- 优惠设置 -->
|
<!-- 自定义插槽:商品选择 -->
|
||||||
<FormItem label="优惠设置">
|
<template #productSpuIds>
|
||||||
<RewardRule ref="rewardRuleRef" v-model="formData" />
|
<SpuShowcase v-model="formData.productSpuIds" />
|
||||||
</FormItem>
|
</template>
|
||||||
<!-- 商品范围选择 -->
|
</Form>
|
||||||
<FormItem
|
|
||||||
v-if="formData.productScope === PromotionProductScopeEnum.SPU.scope"
|
|
||||||
label="选择商品"
|
|
||||||
>
|
|
||||||
<SpuAndSkuList
|
|
||||||
v-model:spu-ids="formData.productSpuIds"
|
|
||||||
:rule-config="[]"
|
|
||||||
:spu-property-list="[]"
|
|
||||||
:deletable="true"
|
|
||||||
:spu-list="[]"/>
|
|
||||||
</FormItem>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
||||||
|
|
||||||
import { nextTick, onMounted, ref } from 'vue';
|
import { nextTick, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
import { Button, Input } from 'ant-design-vue';
|
import { Button, Input } from 'ant-design-vue';
|
||||||
|
|
||||||
// import { CouponSelect } from '@/views/mall/promotion/coupon/components'; // TODO: 根据实际路径调整
|
import { getCouponTemplateList } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||||
// import * as CouponTemplateApi from '#/api/mall/promotion/coupon/couponTemplate'; // TODO: API
|
import { DictTag } from '#/components/dict-tag';
|
||||||
// import { discountFormat } from '@/views/mall/promotion/coupon/formatter'; // TODO: 根据实际路径调整
|
import { CouponSelect } from '#/views/mall/promotion/coupon/components';
|
||||||
|
import { discountFormat } from '#/views/mall/promotion/coupon/formatter';
|
||||||
|
|
||||||
// TODO @puhui999:这里报错了。
|
|
||||||
defineOptions({ name: 'RewardRuleCouponSelect' });
|
defineOptions({ name: 'RewardRuleCouponSelect' });
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -21,17 +24,22 @@ const emits = defineEmits<{
|
|||||||
(e: 'update:modelValue', v: any): void;
|
(e: 'update:modelValue', v: any): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
/** 选择赠送的优惠类型拓展 */
|
||||||
|
interface GiveCoupon extends MallCouponTemplateApi.CouponTemplate {
|
||||||
|
giveCount?: number;
|
||||||
|
}
|
||||||
|
|
||||||
const rewardRule = useVModel(props, 'modelValue', emits);
|
const rewardRule = useVModel(props, 'modelValue', emits);
|
||||||
const list = ref<any[]>([]); // TODO: 改为 GiveCouponVO[] 类型
|
const list = ref<GiveCoupon[]>([]);
|
||||||
|
|
||||||
const CouponTemplateTakeTypeEnum = {
|
const CouponTemplateTakeTypeEnum = {
|
||||||
ADMIN: { type: 2 },
|
ADMIN: { type: 2 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 选择优惠券 */
|
/** 选择优惠券 */
|
||||||
// const couponSelectRef = ref<InstanceType<typeof CouponSelect>>();
|
const couponSelectRef = ref<InstanceType<typeof CouponSelect>>();
|
||||||
function selectCoupon() {
|
function selectCoupon() {
|
||||||
// couponSelectRef.value?.open();
|
couponSelectRef.value?.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 选择优惠券后的回调 */
|
/** 选择优惠券后的回调 */
|
||||||
@@ -51,20 +59,22 @@ function deleteCoupon(index: number) {
|
|||||||
|
|
||||||
/** 初始化赠送的优惠券列表 */
|
/** 初始化赠送的优惠券列表 */
|
||||||
async function initGiveCouponList() {
|
async function initGiveCouponList() {
|
||||||
// if (!rewardRule.value || !rewardRule.value.giveCouponTemplateCounts) {
|
if (!rewardRule.value || !rewardRule.value.giveCouponTemplateCounts) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// const tempLateIds = Object.keys(rewardRule.value.giveCouponTemplateCounts);
|
const tempLateIds = Object.keys(
|
||||||
// const data = await CouponTemplateApi.getCouponTemplateList(tempLateIds);
|
rewardRule.value.giveCouponTemplateCounts,
|
||||||
// if (!data) {
|
) as unknown as number[];
|
||||||
// return;
|
const data = await getCouponTemplateList(tempLateIds);
|
||||||
// }
|
if (!data) {
|
||||||
// data.forEach((coupon) => {
|
return;
|
||||||
// list.value.push({
|
}
|
||||||
// ...coupon,
|
data.forEach((coupon) => {
|
||||||
// giveCount: rewardRule.value.giveCouponTemplateCounts![coupon.id],
|
list.value.push({
|
||||||
// });
|
...coupon,
|
||||||
// });
|
giveCount: rewardRule.value.giveCouponTemplateCounts![coupon.id],
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置赠送的优惠券 */
|
/** 设置赠送的优惠券 */
|
||||||
@@ -99,14 +109,18 @@ onMounted(async () => {
|
|||||||
<div>优惠券名称:{{ item.name }}</div>
|
<div>优惠券名称:{{ item.name }}</div>
|
||||||
<div>
|
<div>
|
||||||
范围:
|
范围:
|
||||||
<!-- <DictTag :type="DICT_TYPE.PROMOTION_PRODUCT_SCOPE" :value="item.productScope" /> -->
|
<DictTag
|
||||||
{{ item.productScope }}
|
:type="DICT_TYPE.PROMOTION_PRODUCT_SCOPE"
|
||||||
|
:value="item.productScope"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
优惠:
|
优惠:
|
||||||
<!-- <DictTag :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :value="item.discountType" /> -->
|
<DictTag
|
||||||
<!-- {{ discountFormat(item) }} -->
|
:type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE"
|
||||||
{{ item.discountType }}
|
:value="item.discountType"
|
||||||
|
/>
|
||||||
|
{{ discountFormat(item) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="coupon-list-item-right flex items-center gap-2">
|
<div class="coupon-list-item-right flex items-center gap-2">
|
||||||
@@ -123,10 +137,10 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 优惠券选择 -->
|
<!-- 优惠券选择 -->
|
||||||
<!-- <CouponSelect
|
<CouponSelect
|
||||||
ref="couponSelectRef"
|
ref="couponSelectRef"
|
||||||
:take-type="CouponTemplateTakeTypeEnum.ADMIN.type"
|
:take-type="CouponTemplateTakeTypeEnum.ADMIN.type"
|
||||||
@change="handleCouponChange"
|
@change="handleCouponChange"
|
||||||
/> -->
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// TODO @puhui999:在优化下代码;
|
|
||||||
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
import type { MallRewardActivityApi } from '#/api/mall/promotion/reward/rewardActivity';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { PromotionConditionTypeEnum } from '@vben/constants';
|
||||||
|
|
||||||
import { useVModel } from '@vueuse/core';
|
import { useVModel } from '@vueuse/core';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -33,23 +34,12 @@ const formData = useVModel(props, 'modelValue', emits);
|
|||||||
const rewardRuleCouponSelectRef =
|
const rewardRuleCouponSelectRef =
|
||||||
ref<InstanceType<typeof RewardRuleCouponSelect>[]>();
|
ref<InstanceType<typeof RewardRuleCouponSelect>[]>();
|
||||||
|
|
||||||
const PromotionConditionTypeEnum = {
|
|
||||||
PRICE: { type: 10 },
|
|
||||||
COUNT: { type: 20 },
|
|
||||||
};
|
|
||||||
|
|
||||||
const isPriceCondition = computed(() => {
|
const isPriceCondition = computed(() => {
|
||||||
return (
|
return (
|
||||||
formData.value?.conditionType === PromotionConditionTypeEnum.PRICE.type
|
formData.value?.conditionType === PromotionConditionTypeEnum.PRICE.type
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 删除优惠规则 */
|
|
||||||
function deleteRule(ruleIndex: number) {
|
|
||||||
formData.value.rules.splice(ruleIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 添加优惠规则 */
|
|
||||||
function addRule() {
|
function addRule() {
|
||||||
if (!formData.value.rules) {
|
if (!formData.value.rules) {
|
||||||
formData.value.rules = [];
|
formData.value.rules = [];
|
||||||
@@ -62,7 +52,10 @@ function addRule() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置规则优惠券-提交时 */
|
function deleteRule(ruleIndex: number) {
|
||||||
|
formData.value.rules.splice(ruleIndex, 1);
|
||||||
|
}
|
||||||
|
|
||||||
function setRuleCoupon() {
|
function setRuleCoupon() {
|
||||||
if (!rewardRuleCouponSelectRef.value) {
|
if (!rewardRuleCouponSelectRef.value) {
|
||||||
return;
|
return;
|
||||||
@@ -76,11 +69,12 @@ defineExpose({ setRuleCoupon });
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Row>
|
<Row :gutter="[16, 16]">
|
||||||
<template v-if="formData.rules">
|
<template v-if="formData.rules">
|
||||||
<Col v-for="(rule, index) in formData.rules" :key="index" :span="24">
|
<Col v-for="(rule, index) in formData.rules" :key="index" :span="24">
|
||||||
<div class="mb-4">
|
<!-- 规则标题 -->
|
||||||
<span class="font-bold">活动层级{{ index + 1 }}</span>
|
<div class="mb-4 flex items-center">
|
||||||
|
<span class="text-base font-bold">活动层级 {{ index + 1 }}</span>
|
||||||
<Button
|
<Button
|
||||||
v-if="index !== 0"
|
v-if="index !== 0"
|
||||||
type="link"
|
type="link"
|
||||||
@@ -92,8 +86,9 @@ defineExpose({ setRuleCoupon });
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form :model="rule">
|
<Form :model="rule" layout="horizontal">
|
||||||
<FormItem label="优惠门槛:" label-col="{ span: 4 }">
|
<!-- 优惠门槛 -->
|
||||||
|
<FormItem label="优惠门槛" :label-col="{ span: 4 }">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span>满</span>
|
<span>满</span>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
@@ -102,44 +97,46 @@ defineExpose({ setRuleCoupon });
|
|||||||
:min="0"
|
:min="0"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
:step="0.1"
|
:step="0.1"
|
||||||
class="!w-150px"
|
:controls="false"
|
||||||
placeholder=""
|
class="!w-40"
|
||||||
controls-position="right"
|
placeholder="请输入金额"
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
v-else
|
v-else
|
||||||
v-model:value="rule.limit"
|
v-model:value="rule.limit"
|
||||||
:min="0"
|
:min="0"
|
||||||
class="!w-150px"
|
class="!w-40"
|
||||||
placeholder=""
|
placeholder="请输入数量"
|
||||||
type="number"
|
type="number"
|
||||||
/>
|
/>
|
||||||
<span>{{ isPriceCondition ? '元' : '件' }}</span>
|
<span>{{ isPriceCondition ? '元' : '件' }}</span>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
<FormItem label="优惠内容:" label-col="{ span: 4 }">
|
<!-- 优惠内容 -->
|
||||||
|
<FormItem label="优惠内容" :label-col="{ span: 4 }">
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<!-- 订单金额优惠 -->
|
<!-- 订单金额优惠 -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<span>订单金额优惠</span>
|
<div class="font-medium">订单金额优惠</div>
|
||||||
</div>
|
<div class="ml-4 flex items-center gap-2">
|
||||||
<div class="ml-4 flex items-center gap-2">
|
<span>减</span>
|
||||||
<span>减</span>
|
<InputNumber
|
||||||
<InputNumber
|
v-model:value="rule.discountPrice"
|
||||||
v-model:value="rule.discountPrice"
|
:min="0"
|
||||||
:min="0"
|
:precision="2"
|
||||||
:precision="2"
|
:step="0.1"
|
||||||
:step="0.1"
|
:controls="false"
|
||||||
class="!w-150px"
|
class="!w-40"
|
||||||
controls-position="right"
|
placeholder="请输入金额"
|
||||||
/>
|
/>
|
||||||
<span>元</span>
|
<span>元</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 包邮 -->
|
<!-- 包邮 -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span>包邮:</span>
|
<span class="font-medium">包邮:</span>
|
||||||
<Switch
|
<Switch
|
||||||
v-model:checked="rule.freeDelivery"
|
v-model:checked="rule.freeDelivery"
|
||||||
checked-children="是"
|
checked-children="是"
|
||||||
@@ -149,23 +146,24 @@ defineExpose({ setRuleCoupon });
|
|||||||
|
|
||||||
<!-- 送积分 -->
|
<!-- 送积分 -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span>送积分:</span>
|
<span class="font-medium">送积分:</span>
|
||||||
<span>送</span>
|
<span>送</span>
|
||||||
<Input
|
<InputNumber
|
||||||
v-model:value="rule.point"
|
v-model:value="rule.point"
|
||||||
class="!w-150px"
|
:min="0"
|
||||||
placeholder=""
|
:controls="false"
|
||||||
type="number"
|
class="!w-40"
|
||||||
|
placeholder="请输入积分"
|
||||||
/>
|
/>
|
||||||
<span>积分</span>
|
<span>积分</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 送优惠券 -->
|
<!-- 送优惠券 -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-start gap-2">
|
||||||
<span>送优惠券:</span>
|
<span class="font-medium">送优惠券:</span>
|
||||||
<RewardRuleCouponSelect
|
<RewardRuleCouponSelect
|
||||||
ref="rewardRuleCouponSelectRef"
|
ref="rewardRuleCouponSelectRef"
|
||||||
v-model="rule"
|
:model-value="rule"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -174,12 +172,16 @@ defineExpose({ setRuleCoupon });
|
|||||||
</Col>
|
</Col>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<Col :span="24" class="mt-4">
|
<!-- 添加规则按钮 -->
|
||||||
<Button type="primary" @click="addRule">添加优惠规则</Button>
|
<Col :span="24" class="mt-2">
|
||||||
|
<Button type="primary" @click="addRule">+ 添加优惠规则</Button>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col :span="24" class="mt-4">
|
<!-- 提示信息 -->
|
||||||
<Tag color="warning">赠送积分为 0 时不赠送。未选优惠券时不赠送。</Tag>
|
<Col :span="24" class="mt-2">
|
||||||
|
<Tag color="warning">
|
||||||
|
提示:赠送积分为 0 时不赠送;未选择优惠券时不赠送。
|
||||||
|
</Tag>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</template>
|
</template>
|
||||||
@@ -4,6 +4,9 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { getSimpleSeckillConfigList } from '#/api/mall/promotion/seckill/seckillConfig';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
@@ -29,6 +32,114 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 新增/编辑的表单 */
|
||||||
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'id',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '秒杀活动名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入活动名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'startTime',
|
||||||
|
label: '活动开始时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择活动开始时间',
|
||||||
|
showTime: false,
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
|
valueFormat: 'x',
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'endTime',
|
||||||
|
label: '活动结束时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择活动结束时间',
|
||||||
|
showTime: false,
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
|
valueFormat: 'x',
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'configIds',
|
||||||
|
label: '秒杀时段',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择秒杀时段',
|
||||||
|
mode: 'multiple',
|
||||||
|
api: getSimpleSeckillConfigList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'totalLimitCount',
|
||||||
|
label: '总限购数量',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入总限购数量',
|
||||||
|
min: 0,
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
rules: z.number().min(0).default(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'singleLimitCount',
|
||||||
|
label: '单次限购数量',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入单次限购数量',
|
||||||
|
min: 0,
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
rules: z.number().min(0).default(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sort',
|
||||||
|
label: '排序',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入排序',
|
||||||
|
min: 0,
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
rules: z.number().min(0).default(0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 4,
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import type { MallSeckillActivityApi } from '#/api/mall/promotion/seckill/seckil
|
|||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
|
||||||
|
|
||||||
import { message, Tag } from 'ant-design-vue';
|
import { message, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
@@ -16,6 +15,7 @@ import {
|
|||||||
getSeckillActivityPage,
|
getSeckillActivityPage,
|
||||||
} from '#/api/mall/promotion/seckill/seckillActivity';
|
} from '#/api/mall/promotion/seckill/seckillActivity';
|
||||||
import { getSimpleSeckillConfigList } from '#/api/mall/promotion/seckill/seckillConfig';
|
import { getSimpleSeckillConfigList } from '#/api/mall/promotion/seckill/seckillConfig';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import { formatConfigNames, formatTimeRange, setConfigList } from './formatter';
|
import { formatConfigNames, formatTimeRange, setConfigList } from './formatter';
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { MallSeckillActivityApi } from '#/api/mall/promotion/seckill/seckillActivity';
|
import type { MallSeckillActivityApi } from '#/api/mall/promotion/seckill/seckillActivity';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, nextTick, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import {
|
import {
|
||||||
@@ -15,59 +15,53 @@ import {
|
|||||||
} from '#/api/mall/promotion/seckill/seckillActivity';
|
} from '#/api/mall/promotion/seckill/seckillActivity';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
const formData = ref<MallSeckillActivityApi.SeckillActivity>();
|
const formData = ref<MallSeckillActivityApi.SeckillActivity>();
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return formData.value?.id
|
return formData.value?.id
|
||||||
? $t('ui.actionTitle.edit', ['秒杀活动'])
|
? $t('ui.actionTitle.edit', ['秒杀活动'])
|
||||||
: $t('ui.actionTitle.create', ['秒杀活动']);
|
: $t('ui.actionTitle.create', ['秒杀活动']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 简化的表单配置,实际项目中应该有完整的字段配置
|
// ================= 商品选择相关 =================
|
||||||
const formSchema = [
|
const spuId = ref<number>();
|
||||||
{
|
const spuName = ref<string>('');
|
||||||
fieldName: 'id',
|
const skuTableData = ref<any[]>([]);
|
||||||
component: 'Input',
|
|
||||||
dependencies: {
|
// 选择商品(占位函数,实际需要对接商品选择组件)
|
||||||
triggerFields: [''],
|
const handleSelectProduct = () => {
|
||||||
show: () => false,
|
message.info('商品选择功能需要对接商品选择组件');
|
||||||
},
|
// TODO: 打开商品选择弹窗
|
||||||
},
|
// 实际使用时需要:
|
||||||
{
|
// 1. 打开商品选择弹窗
|
||||||
fieldName: 'name',
|
// 2. 选择商品后调用以下逻辑设置数据:
|
||||||
label: '活动名称',
|
// spuId.value = selectedSpu.id;
|
||||||
component: 'Input',
|
// spuName.value = selectedSpu.name;
|
||||||
componentProps: {
|
// skuTableData.value = selectedSkus.map(sku => ({
|
||||||
placeholder: '请输入活动名称',
|
// skuId: sku.id,
|
||||||
},
|
// skuName: sku.name || '',
|
||||||
rules: 'required',
|
// picUrl: sku.picUrl || selectedSpu.picUrl || '',
|
||||||
},
|
// price: sku.price || 0,
|
||||||
{
|
// stock: 0,
|
||||||
fieldName: 'status',
|
// seckillPrice: 0,
|
||||||
label: '活动状态',
|
// }));
|
||||||
component: 'Select',
|
};
|
||||||
componentProps: {
|
|
||||||
placeholder: '请选择活动状态',
|
// ================= end =================
|
||||||
options: [
|
|
||||||
{ label: '开启', value: 0 },
|
|
||||||
{ label: '关闭', value: 1 },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
rules: 'required',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
componentProps: {
|
componentProps: {
|
||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
},
|
},
|
||||||
formItemClass: 'col-span-2',
|
|
||||||
labelWidth: 80,
|
|
||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: formSchema,
|
schema: useFormSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
|
wrapperClass: 'grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
@@ -76,15 +70,46 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 验证商品和 SKU 配置
|
||||||
|
if (!spuId.value) {
|
||||||
|
message.error('请选择秒杀商品');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skuTableData.value.length === 0) {
|
||||||
|
message.error('请至少配置一个 SKU');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证 SKU 配置
|
||||||
|
const hasInvalidSku = skuTableData.value.some(
|
||||||
|
(sku) => sku.stock < 1 || sku.seckillPrice < 0.01,
|
||||||
|
);
|
||||||
|
if (hasInvalidSku) {
|
||||||
|
message.error('请正确配置 SKU 的秒杀库存(≥1)和秒杀价格(≥0.01)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
// 提交表单
|
|
||||||
const data =
|
|
||||||
(await formApi.getValues()) as MallSeckillActivityApi.SeckillActivity;
|
|
||||||
try {
|
try {
|
||||||
|
const values = await formApi.getValues();
|
||||||
|
|
||||||
|
// 构建提交数据
|
||||||
|
const data: any = {
|
||||||
|
...values,
|
||||||
|
spuId: spuId.value,
|
||||||
|
products: skuTableData.value.map((sku) => ({
|
||||||
|
skuId: sku.skuId,
|
||||||
|
stock: sku.stock,
|
||||||
|
seckillPrice: Math.round(sku.seckillPrice * 100), // 转换为分
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
|
||||||
await (formData.value?.id
|
await (formData.value?.id
|
||||||
? updateSeckillActivity(data)
|
? updateSeckillActivity(data)
|
||||||
: createSeckillActivity(data));
|
: createSeckillActivity(data));
|
||||||
// 关闭并提示
|
|
||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -95,18 +120,27 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
formData.value = undefined;
|
formData.value = undefined;
|
||||||
|
spuId.value = undefined;
|
||||||
|
spuName.value = '';
|
||||||
|
skuTableData.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
|
||||||
const data = modalApi.getData<MallSeckillActivityApi.SeckillActivity>();
|
const data = modalApi.getData<MallSeckillActivityApi.SeckillActivity>();
|
||||||
if (!data || !data.id) {
|
if (!data || !data.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
formData.value = await getSeckillActivity(data.id);
|
formData.value = await getSeckillActivity(data.id);
|
||||||
// 设置到 values
|
await nextTick();
|
||||||
await formApi.setValues(formData.value);
|
await formApi.setValues(formData.value);
|
||||||
|
|
||||||
|
// TODO: 加载商品和 SKU 信息
|
||||||
|
// 需要调用商品 API 获取 SPU 详情
|
||||||
|
// spuId.value = formData.value.spuId;
|
||||||
|
// await loadProductDetails(formData.value.spuId, formData.value.products);
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
@@ -115,7 +149,72 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal class="w-2/5" :title="getTitle">
|
<Modal class="w-4/5" :title="getTitle">
|
||||||
<Form class="mx-4" />
|
<div class="mx-4">
|
||||||
|
<Form />
|
||||||
|
|
||||||
|
<!-- 商品选择区域 -->
|
||||||
|
<div class="mt-4">
|
||||||
|
<div class="mb-2 flex items-center">
|
||||||
|
<span class="text-sm font-medium">秒杀活动商品:</span>
|
||||||
|
<Button class="ml-2" type="primary" @click="handleSelectProduct">
|
||||||
|
选择商品
|
||||||
|
</Button>
|
||||||
|
<span v-if="spuName" class="ml-4 text-sm text-gray-600">
|
||||||
|
已选择: {{ spuName }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- SKU 配置表格 -->
|
||||||
|
<div v-if="skuTableData.length > 0" class="mt-4">
|
||||||
|
<table class="w-full border-collapse border border-gray-300">
|
||||||
|
<thead>
|
||||||
|
<tr class="bg-gray-100">
|
||||||
|
<th class="border border-gray-300 px-4 py-2">商品图片</th>
|
||||||
|
<th class="border border-gray-300 px-4 py-2">SKU 名称</th>
|
||||||
|
<th class="border border-gray-300 px-4 py-2">原价(元)</th>
|
||||||
|
<th class="border border-gray-300 px-4 py-2">秒杀库存</th>
|
||||||
|
<th class="border border-gray-300 px-4 py-2">秒杀价格(元)</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(sku, index) in skuTableData" :key="index">
|
||||||
|
<td class="border border-gray-300 px-4 py-2 text-center">
|
||||||
|
<img
|
||||||
|
v-if="sku.picUrl"
|
||||||
|
:src="sku.picUrl"
|
||||||
|
alt="商品图片"
|
||||||
|
class="h-16 w-16 object-cover"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td class="border border-gray-300 px-4 py-2">
|
||||||
|
{{ sku.skuName }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-gray-300 px-4 py-2 text-center">
|
||||||
|
¥{{ (sku.price / 100).toFixed(2) }}
|
||||||
|
</td>
|
||||||
|
<td class="border border-gray-300 px-4 py-2">
|
||||||
|
<input
|
||||||
|
v-model.number="sku.stock"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
class="w-full rounded border border-gray-300 px-2 py-1"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td class="border border-gray-300 px-4 py-2">
|
||||||
|
<input
|
||||||
|
v-model.number="sku.seckillPrice"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
step="0.01"
|
||||||
|
class="w-full rounded border border-gray-300 px-2 py-1"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Col, Row } from 'ant-design-vue';
|
import { Col, Row } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
import { getMemberSummary } from '#/api/mall/statistics/member';
|
||||||
|
|
||||||
import MemberAreaCard from './modules/area-card.vue';
|
import MemberAreaCard from './modules/area-card.vue';
|
||||||
import MemberFunnelCard from './modules/funnel-card.vue';
|
import MemberFunnelCard from './modules/funnel-card.vue';
|
||||||
@@ -22,15 +22,15 @@ const loading = ref(true); // 加载中
|
|||||||
const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据
|
const summary = ref<MallMemberStatisticsApi.Summary>(); // 会员统计数据
|
||||||
|
|
||||||
/** 查询会员统计 */
|
/** 查询会员统计 */
|
||||||
async function getMemberSummary() {
|
async function loadMemberSummary() {
|
||||||
summary.value = await MemberStatisticsApi.getMemberSummary();
|
summary.value = await getMemberSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
await getMemberSummary();
|
await loadMemberSummary();
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
|||||||
import { Card, Spin } from 'ant-design-vue';
|
import { Card, Spin } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
import { getMemberAreaStatisticsList } from '#/api/mall/statistics/member';
|
||||||
|
|
||||||
import { getAreaChartOptions, getAreaTableColumns } from './area-chart-options';
|
import { getAreaChartOptions, getAreaTableColumns } from './area-chart-options';
|
||||||
|
|
||||||
@@ -44,10 +44,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 按照省份,查询会员统计列表 */
|
/** 按照省份,查询会员统计列表 */
|
||||||
async function getMemberAreaStatisticsList() {
|
async function loadMemberAreaStatisticsList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const list = await MemberStatisticsApi.getMemberAreaStatisticsList();
|
const list = await getMemberAreaStatisticsList();
|
||||||
areaStatisticsList.value = list.map(
|
areaStatisticsList.value = list.map(
|
||||||
(item: MallMemberStatisticsApi.AreaStatistics) => ({
|
(item: MallMemberStatisticsApi.AreaStatistics) => ({
|
||||||
...item,
|
...item,
|
||||||
@@ -80,7 +80,7 @@ function areaReplace(areaName: string): string {
|
|||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getMemberAreaStatisticsList();
|
loadMemberAreaStatisticsList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Card } from 'ant-design-vue';
|
import { Card } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
import { getMemberAnalyse } from '#/api/mall/statistics/member';
|
||||||
import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker';
|
import { ShortcutDateRangePicker } from '#/components/shortcut-date-range-picker';
|
||||||
|
|
||||||
/** 会员概览卡片 */
|
/** 会员概览卡片 */
|
||||||
@@ -23,7 +23,7 @@ async function loadData(times: [Dayjs, Dayjs]) {
|
|||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
analyseData.value = await MemberStatisticsApi.getMemberAnalyse({
|
analyseData.value = await getMemberAnalyse({
|
||||||
times,
|
times,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
|||||||
|
|
||||||
import { Card, Spin } from 'ant-design-vue';
|
import { Card, Spin } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
import { getMemberSexStatisticsList } from '#/api/mall/statistics/member';
|
||||||
|
|
||||||
import { getSexChartOptions } from './sex-chart-options';
|
import { getSexChartOptions } from './sex-chart-options';
|
||||||
|
|
||||||
@@ -23,10 +23,10 @@ const chartRef = ref<EchartsUIType>();
|
|||||||
const { renderEcharts } = useEcharts(chartRef);
|
const { renderEcharts } = useEcharts(chartRef);
|
||||||
|
|
||||||
/** 按照性别,查询会员统计列表 */
|
/** 按照性别,查询会员统计列表 */
|
||||||
async function getMemberSexStatisticsList() {
|
async function loadMemberSexStatisticsList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const list = await MemberStatisticsApi.getMemberSexStatisticsList();
|
const list = await getMemberSexStatisticsList();
|
||||||
const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number');
|
const dictDataList = getDictOptions(DICT_TYPE.SYSTEM_USER_SEX, 'number');
|
||||||
dictDataList.push({ label: '未知', value: null } as any);
|
dictDataList.push({ label: '未知', value: null } as any);
|
||||||
const chartData = dictDataList.map((dictData: any) => {
|
const chartData = dictDataList.map((dictData: any) => {
|
||||||
@@ -49,7 +49,7 @@ async function getMemberSexStatisticsList() {
|
|||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getMemberSexStatisticsList();
|
loadMemberSexStatisticsList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
|||||||
|
|
||||||
import { Card, Spin } from 'ant-design-vue';
|
import { Card, Spin } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
|
import { getMemberTerminalStatisticsList } from '#/api/mall/statistics/member';
|
||||||
|
|
||||||
import { getTerminalChartOptions } from './terminal-chart-options';
|
import { getTerminalChartOptions } from './terminal-chart-options';
|
||||||
|
|
||||||
@@ -20,10 +20,10 @@ const chartRef = ref<EchartsUIType>();
|
|||||||
const { renderEcharts } = useEcharts(chartRef);
|
const { renderEcharts } = useEcharts(chartRef);
|
||||||
|
|
||||||
/** 按照终端,查询会员统计列表 */
|
/** 按照终端,查询会员统计列表 */
|
||||||
const getMemberTerminalStatisticsList = async () => {
|
const loadMemberTerminalStatisticsList = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const list = await MemberStatisticsApi.getMemberTerminalStatisticsList();
|
const list = await getMemberTerminalStatisticsList();
|
||||||
const dictDataList = getDictOptions('terminal', 'number');
|
const dictDataList = getDictOptions('terminal', 'number');
|
||||||
const chartData = dictDataList.map((dictData: any) => {
|
const chartData = dictDataList.map((dictData: any) => {
|
||||||
const userCount = list.find(
|
const userCount = list.find(
|
||||||
@@ -43,7 +43,7 @@ const getMemberTerminalStatisticsList = async () => {
|
|||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getMemberTerminalStatisticsList();
|
loadMemberTerminalStatisticsList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { formatDateTime } from '@vben/utils';
|
|||||||
import { Card } from 'ant-design-vue';
|
import { Card } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import * as ProductStatisticsApi from '#/api/mall/statistics/product';
|
import { getProductStatisticsRankPage } from '#/api/mall/statistics/product';
|
||||||
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
||||||
|
|
||||||
/** 商品排行 */
|
/** 商品排行 */
|
||||||
@@ -104,7 +104,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async ({ page, sorts }) => {
|
query: async ({ page, sorts }) => {
|
||||||
return await ProductStatisticsApi.getProductStatisticsRankPage({
|
return await getProductStatisticsRankPage({
|
||||||
pageNo: page.currentPage,
|
pageNo: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
|
|||||||
@@ -21,8 +21,13 @@ import {
|
|||||||
import { Button, Card, Col, Row, Spin } from 'ant-design-vue';
|
import { Button, Card, Col, Row, Spin } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import * as ProductStatisticsApi from '#/api/mall/statistics/product';
|
import {
|
||||||
|
exportProductStatisticsExcel,
|
||||||
|
getProductStatisticsAnalyse,
|
||||||
|
getProductStatisticsList,
|
||||||
|
} from '#/api/mall/statistics/product';
|
||||||
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getProductSummaryChartOptions } from './summary-chart-options';
|
import { getProductSummaryChartOptions } from './summary-chart-options';
|
||||||
|
|
||||||
@@ -51,7 +56,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
|
|||||||
/** 处理日期范围变化 */
|
/** 处理日期范围变化 */
|
||||||
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
||||||
if (times?.length !== 2) {
|
if (times?.length !== 2) {
|
||||||
getProductTrendData();
|
loadProductTrendData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
|
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
|
||||||
@@ -65,29 +70,29 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 查询数据
|
// 查询数据
|
||||||
getProductTrendData();
|
loadProductTrendData();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 处理商品状况查询 */
|
/** 处理商品状况查询 */
|
||||||
const getProductTrendData = async () => {
|
const loadProductTrendData = async () => {
|
||||||
trendLoading.value = true;
|
trendLoading.value = true;
|
||||||
try {
|
try {
|
||||||
await Promise.all([getProductTrendSummary(), getProductStatisticsList()]);
|
await Promise.all([loadProductTrendSummary(), loadProductStatisticsList()]);
|
||||||
} finally {
|
} finally {
|
||||||
trendLoading.value = false;
|
trendLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 查询商品状况数据统计 */
|
/** 查询商品状况数据统计 */
|
||||||
async function getProductTrendSummary() {
|
async function loadProductTrendSummary() {
|
||||||
trendSummary.value = await ProductStatisticsApi.getProductStatisticsAnalyse({
|
trendSummary.value = await getProductStatisticsAnalyse({
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询商品状况数据列表 */
|
/** 查询商品状况数据列表 */
|
||||||
async function getProductStatisticsList() {
|
async function loadProductStatisticsList() {
|
||||||
const list = await ProductStatisticsApi.getProductStatisticsList({
|
const list = await getProductStatisticsList({
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,7 +109,7 @@ async function handleExport() {
|
|||||||
});
|
});
|
||||||
// 发起导出
|
// 发起导出
|
||||||
exportLoading.value = true;
|
exportLoading.value = true;
|
||||||
const data = await ProductStatisticsApi.exportProductStatisticsExcel({
|
const data = await exportProductStatisticsExcel({
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
});
|
});
|
||||||
// 处理下载
|
// 处理下载
|
||||||
@@ -125,7 +130,7 @@ async function handleExport() {
|
|||||||
<template #icon>
|
<template #icon>
|
||||||
<IconifyIcon icon="lucide:download" />
|
<IconifyIcon icon="lucide:download" />
|
||||||
</template>
|
</template>
|
||||||
导出
|
{{ $t('page.action.export') }}
|
||||||
</Button>
|
</Button>
|
||||||
</ShortcutDateRangePicker>
|
</ShortcutDateRangePicker>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
|
|||||||
|
|
||||||
import { Col, Row } from 'ant-design-vue';
|
import { Col, Row } from 'ant-design-vue';
|
||||||
|
|
||||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
import { getTradeStatisticsSummary } from '#/api/mall/statistics/trade';
|
||||||
|
|
||||||
import TradeTrendCard from './modules/trend-card.vue';
|
import TradeTrendCard from './modules/trend-card.vue';
|
||||||
|
|
||||||
@@ -31,14 +31,14 @@ function calculateRelativeRate(value?: number, reference?: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 查询交易统计 */
|
/** 查询交易统计 */
|
||||||
async function getTradeStatisticsSummary() {
|
async function loadTradeStatisticsSummary() {
|
||||||
summary.value = await TradeStatisticsApi.getTradeStatisticsSummary();
|
summary.value = await getTradeStatisticsSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 初始化 */
|
/** 初始化 */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await getTradeStatisticsSummary();
|
await loadTradeStatisticsSummary();
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -21,8 +21,13 @@ import {
|
|||||||
import { Button, Card, Col, Row, Spin } from 'ant-design-vue';
|
import { Button, Card, Col, Row, Spin } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
|
import {
|
||||||
|
exportTradeStatisticsExcel,
|
||||||
|
getTradeStatisticsAnalyse,
|
||||||
|
getTradeStatisticsList,
|
||||||
|
} from '#/api/mall/statistics/trade';
|
||||||
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
import ShortcutDateRangePicker from '#/components/shortcut-date-range-picker/shortcut-date-range-picker.vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { getTradeTrendChartOptions } from './trend-chart-options';
|
import { getTradeTrendChartOptions } from './trend-chart-options';
|
||||||
|
|
||||||
@@ -51,7 +56,7 @@ const calculateRelativeRate = (value?: number, reference?: number): string => {
|
|||||||
/** 处理日期范围变化 */
|
/** 处理日期范围变化 */
|
||||||
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
||||||
if (times?.length !== 2) {
|
if (times?.length !== 2) {
|
||||||
getTradeTrendData();
|
loadTradeTrendData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
|
// 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
|
||||||
@@ -65,29 +70,32 @@ const handleDateRangeChange = (times?: [Dayjs, Dayjs]) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 查询数据
|
// 查询数据
|
||||||
getTradeTrendData();
|
loadTradeTrendData();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 处理交易状况查询 */
|
/** 处理交易状况查询 */
|
||||||
async function getTradeTrendData() {
|
async function loadTradeTrendData() {
|
||||||
trendLoading.value = true;
|
trendLoading.value = true;
|
||||||
try {
|
try {
|
||||||
await Promise.all([getTradeStatisticsAnalyse(), getTradeStatisticsList()]);
|
await Promise.all([
|
||||||
|
loadTradeStatisticsAnalyse(),
|
||||||
|
loadTradeStatisticsList(),
|
||||||
|
]);
|
||||||
} finally {
|
} finally {
|
||||||
trendLoading.value = false;
|
trendLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询交易状况数据统计 */
|
/** 查询交易状况数据统计 */
|
||||||
async function getTradeStatisticsAnalyse() {
|
async function loadTradeStatisticsAnalyse() {
|
||||||
trendSummary.value = await TradeStatisticsApi.getTradeStatisticsAnalyse({
|
trendSummary.value = await getTradeStatisticsAnalyse({
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询交易状况数据列表 */
|
/** 查询交易状况数据列表 */
|
||||||
async function getTradeStatisticsList() {
|
async function loadTradeStatisticsList() {
|
||||||
const list = await TradeStatisticsApi.getTradeStatisticsList({
|
const list = await getTradeStatisticsList({
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,7 +112,7 @@ async function handleExport() {
|
|||||||
});
|
});
|
||||||
// 发起导出
|
// 发起导出
|
||||||
exportLoading.value = true;
|
exportLoading.value = true;
|
||||||
const data = await TradeStatisticsApi.exportTradeStatisticsExcel({
|
const data = await exportTradeStatisticsExcel({
|
||||||
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
times: searchTimes.value.length > 0 ? searchTimes.value : undefined,
|
||||||
});
|
});
|
||||||
// 处理下载
|
// 处理下载
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ const afterSale = ref<MallAfterSaleApi.AfterSale>({
|
|||||||
logs: [],
|
logs: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO @xingyu:貌似 antd 相比 antd 来说,多了一个框?有啥办法只有 1 个么?
|
||||||
const [OrderDescriptions] = useDescription({
|
const [OrderDescriptions] = useDescription({
|
||||||
title: '订单信息',
|
title: '订单信息',
|
||||||
bordered: false,
|
bordered: false,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { $t } from '@vben/locales';
|
|||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import * as AfterSaleApi from '#/api/mall/trade/afterSale/index';
|
import { disagreeAfterSale } from '#/api/mall/trade/afterSale';
|
||||||
|
|
||||||
import { useDisagreeFormSchema } from '../data';
|
import { useDisagreeFormSchema } from '../data';
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
try {
|
try {
|
||||||
const data =
|
const data =
|
||||||
(await formApi.getValues()) as MallAfterSaleApi.DisagreeRequest;
|
(await formApi.getValues()) as MallAfterSaleApi.DisagreeRequest;
|
||||||
await AfterSaleApi.disagreeAfterSale(data);
|
await disagreeAfterSale(data);
|
||||||
// 关闭并提示
|
// 关闭并提示
|
||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ import { useTabs } from '@vben/hooks';
|
|||||||
import { Card, message, Tag } from 'ant-design-vue';
|
import { Card, message, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import * as DeliveryExpressApi from '#/api/mall/trade/delivery/express';
|
import { getSimpleDeliveryExpressList } from '#/api/mall/trade/delivery/express';
|
||||||
import * as DeliveryPickUpStoreApi from '#/api/mall/trade/delivery/pickUpStore';
|
import { getDeliveryPickUpStore } from '#/api/mall/trade/delivery/pickUpStore';
|
||||||
import * as TradeOrderApi from '#/api/mall/trade/order';
|
import {
|
||||||
|
getExpressTrackList,
|
||||||
|
getOrder,
|
||||||
|
pickUpOrder,
|
||||||
|
} from '#/api/mall/trade/order';
|
||||||
import { useDescription } from '#/components/description';
|
import { useDescription } from '#/components/description';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { TableAction } from '#/components/table-action';
|
import { TableAction } from '#/components/table-action';
|
||||||
@@ -56,6 +60,7 @@ const deliveryExpressList = ref<MallDeliveryExpressApi.SimpleDeliveryExpress[]>(
|
|||||||
const expressTrackList = ref<any[]>([]);
|
const expressTrackList = ref<any[]>([]);
|
||||||
const pickUpStore = ref<MallDeliveryPickUpStoreApi.PickUpStore | undefined>();
|
const pickUpStore = ref<MallDeliveryPickUpStoreApi.PickUpStore | undefined>();
|
||||||
|
|
||||||
|
// TODO @xingyu:貌似 antd 相比 antd 来说,多了一个框?有啥办法只有 1 个么?
|
||||||
const [OrderInfoDescriptions] = useDescription({
|
const [OrderInfoDescriptions] = useDescription({
|
||||||
title: '订单信息',
|
title: '订单信息',
|
||||||
bordered: false,
|
bordered: false,
|
||||||
@@ -157,7 +162,7 @@ const [PriceFormModal, priceFormModalApi] = useVbenModal({
|
|||||||
async function getDetail() {
|
async function getDetail() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await TradeOrderApi.getOrder(orderId.value);
|
const res = await getOrder(orderId.value);
|
||||||
if (res === null) {
|
if (res === null) {
|
||||||
message.error('交易订单不存在');
|
message.error('交易订单不存在');
|
||||||
handleBack();
|
handleBack();
|
||||||
@@ -169,12 +174,9 @@ async function getDetail() {
|
|||||||
|
|
||||||
// 如果配送方式为快递,则查询物流公司
|
// 如果配送方式为快递,则查询物流公司
|
||||||
if (res.deliveryType === DeliveryTypeEnum.EXPRESS.type) {
|
if (res.deliveryType === DeliveryTypeEnum.EXPRESS.type) {
|
||||||
deliveryExpressList.value =
|
deliveryExpressList.value = await getSimpleDeliveryExpressList();
|
||||||
await DeliveryExpressApi.getSimpleDeliveryExpressList();
|
|
||||||
if (res.logisticsId) {
|
if (res.logisticsId) {
|
||||||
expressTrackList.value = await TradeOrderApi.getExpressTrackList(
|
expressTrackList.value = await getExpressTrackList(res.id!);
|
||||||
res.id!,
|
|
||||||
);
|
|
||||||
expressTrackGridApi.setGridOptions({
|
expressTrackGridApi.setGridOptions({
|
||||||
data: expressTrackList.value || [],
|
data: expressTrackList.value || [],
|
||||||
});
|
});
|
||||||
@@ -183,9 +185,7 @@ async function getDetail() {
|
|||||||
res.deliveryType === DeliveryTypeEnum.PICK_UP.type &&
|
res.deliveryType === DeliveryTypeEnum.PICK_UP.type &&
|
||||||
res.pickUpStoreId
|
res.pickUpStoreId
|
||||||
) {
|
) {
|
||||||
pickUpStore.value = await DeliveryPickUpStoreApi.getDeliveryPickUpStore(
|
pickUpStore.value = await getDeliveryPickUpStore(res.pickUpStoreId);
|
||||||
res.pickUpStoreId,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@@ -217,7 +217,7 @@ const handlePickUp = async () => {
|
|||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await TradeOrderApi.pickUpOrder(order.value.id!);
|
await pickUpOrder(order.value.id!);
|
||||||
message.success('核销成功');
|
message.success('核销成功');
|
||||||
await getDetail();
|
await getDetail();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -338,7 +338,7 @@ onMounted(async () => {
|
|||||||
<OperateLogGrid table-title="操作日志">
|
<OperateLogGrid table-title="操作日志">
|
||||||
<template #userType="{ row }">
|
<template #userType="{ row }">
|
||||||
<Tag v-if="row.userType === 0" color="default"> 系统 </Tag>
|
<Tag v-if="row.userType === 0" color="default"> 系统 </Tag>
|
||||||
<DictTag :type="DICT_TYPE.USER_TYPE" :value="row.userType" />
|
<DictTag v-else :type="DICT_TYPE.USER_TYPE" :value="row.userType" />
|
||||||
</template>
|
</template>
|
||||||
</OperateLogGrid>
|
</OperateLogGrid>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,11 +17,8 @@ import { useDetailLogColumns, useDetailSchema } from '../data';
|
|||||||
const formData = ref<PayNotifyApi.NotifyTask>();
|
const formData = ref<PayNotifyApi.NotifyTask>();
|
||||||
|
|
||||||
const [Description] = useDescription({
|
const [Description] = useDescription({
|
||||||
componentProps: {
|
bordered: true,
|
||||||
bordered: true,
|
column: 2,
|
||||||
column: 2,
|
|
||||||
class: 'mx-4',
|
|
||||||
},
|
|
||||||
schema: useDetailSchema(),
|
schema: useDetailSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,8 @@ import { useDetailSchema } from '../data';
|
|||||||
const formData = ref<PayOrderApi.Order>();
|
const formData = ref<PayOrderApi.Order>();
|
||||||
|
|
||||||
const [Descriptions] = useDescription({
|
const [Descriptions] = useDescription({
|
||||||
componentProps: {
|
bordered: true,
|
||||||
bordered: true,
|
column: 2,
|
||||||
column: 2,
|
|
||||||
class: 'mx-4',
|
|
||||||
},
|
|
||||||
schema: useDetailSchema(),
|
schema: useDetailSchema(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user