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