# Conflicts:
#	.env.local
This commit is contained in:
dzc committed 2025-08-12 18:17:00 +08:00
commit 9d53fffe8a
4 files changed
+588 -1

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ NODE_ENV=production
VITE_DEV=true
# 请求路径
VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn'
VITE_BASE_URL='https://xrhomeapi.asset-cloud.com.cn'
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务
VITE_UPLOAD_TYPE=server
+79
View File
@@ -0,0 +1,79 @@
import request from "@/config/axios";
// 商品汇总分页查询参数
export interface SummaryPageReqVO {
pageNo: number; // 页码,从 1 开始
pageSize: number; // 每页条数,最大值为 100
name?: string; // 商品名称
deviceId?: string; // 设备IMEI
barCode?: string; // SKU 的条形码
keyword?: string; // 关键字
introduction?: string; // 商品简介
description?: string; // 商品详情
categoryId?: string; // 商品分类编号
brandId?: string; // 商品品牌编号
picUrl?: string; // 商品封面图
sliderPicUrls?: string; // 商品轮播图地址数组,以逗号分隔 最多上传15张
sort?: string; // 排序字段
price?: string; // 商品价格,单位使用:分
marketPrice?: string; // 市场价,单位使用:分
costPrice?: string; // 成本价,单位: 分
createTime?: string[]; // 创建时间
}
// 商品汇总 VO
export interface SummaryVO {
id: number; // 商品编号,自增
deviceId: string; // 设备IMEI
barCode: string; // SKU 的条形码
name: string; // 商品名称
keyword: string; // 关键字
introduction: string; // 商品简介
description: string; // 商品详情
categoryId: number; // 商品分类编号
brandId: number; // 商品品牌编号
picUrl: string; // 商品封面图
sliderPicUrls: string; // 商品轮播图地址
// 数组,以逗号分隔
// 最多上传15张
sort: number; // 排序字段
price: number; // 商品价格,单位使用:分
marketPrice: number; // 市场价,单位使用:分
costPrice: number; // 成本价,单位: 分
}
// 商品汇总 API
export const SummaryApi = {
// 查询商品汇总分页
getSummaryPage: async (params: SummaryPageReqVO) => {
return await request.get({ url: `/product/summary/sumPage`, params });
},
// 查询商品汇总详情
getSummary: async (id: number) => {
return await request.get({ url: `/product/summary/get?id=` + id });
},
// 新增商品汇总
createSummary: async (data: SummaryVO) => {
return await request.post({ url: `/product/summary/create`, data });
},
// 修改商品汇总
updateSummary: async (data: SummaryVO) => {
return await request.put({ url: `/product/summary/update`, data });
},
// 删除商品汇总
deleteSummary: async (id: number) => {
return await request.delete({ url: `/product/summary/delete?id=` + id });
},
// 导出商品汇总 Excel
exportSummary: async (params) => {
return await request.download({
url: `/product/summary/export-excel`,
params,
});
},
};
@@ -0,0 +1,174 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="设备IMEI" prop="deviceId">
<el-input v-model="formData.deviceId" placeholder="请输入设备IMEI" />
</el-form-item>
<el-form-item label="SKU 的条形码" prop="barCode">
<el-input v-model="formData.barCode" placeholder="请输入SKU 的条形码" />
</el-form-item>
<el-form-item label="商品名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入商品名称" />
</el-form-item>
<el-form-item label="关键字" prop="keyword">
<el-input v-model="formData.keyword" placeholder="请输入关键字" />
</el-form-item>
<el-form-item label="商品简介" prop="introduction">
<el-input v-model="formData.introduction" placeholder="请输入商品简介" />
</el-form-item>
<el-form-item label="商品详情" prop="description">
<Editor v-model="formData.description" height="150px" />
</el-form-item>
<el-form-item label="商品分类编号" prop="categoryId">
<el-input v-model="formData.categoryId" placeholder="请输入商品分类编号" />
</el-form-item>
<el-form-item label="商品品牌编号" prop="brandId">
<el-input v-model="formData.brandId" placeholder="请输入商品品牌编号" />
</el-form-item>
<el-form-item label="商品封面图" prop="picUrl">
<el-input v-model="formData.picUrl" placeholder="请输入商品封面图" />
</el-form-item>
<el-form-item
label="商品轮播图地址
数组,以逗号分隔
最多上传15张"
prop="sliderPicUrls"
>
<el-input
v-model="formData.sliderPicUrls"
placeholder="请输入商品轮播图地址
数组,以逗号分隔
最多上传15张"
/>
</el-form-item>
<el-form-item label="排序字段" prop="sort">
<el-input v-model="formData.sort" placeholder="请输入排序字段" />
</el-form-item>
<el-form-item label="商品价格,单位使用:分" prop="price">
<el-input v-model="formData.price" placeholder="请输入商品价格,单位使用:分" />
</el-form-item>
<el-form-item label="市场价,单位使用:分" prop="marketPrice">
<el-input v-model="formData.marketPrice" placeholder="请输入市场价,单位使用:分" />
</el-form-item>
<el-form-item label="成本价,单位: 分" prop="costPrice">
<el-input v-model="formData.costPrice" placeholder="请输入成本价,单位: 分" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { SummaryApi, SummaryVO } from '@/api/product/summary'
/** 商品汇总 表单 */
defineOptions({ name: 'SummaryForm' })
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const formType = ref('') // 表单的类型:create - 新增;update - 修改
const formData = ref({
id: undefined,
deviceId: undefined,
barCode: undefined,
name: undefined,
keyword: undefined,
introduction: undefined,
description: undefined,
categoryId: undefined,
brandId: undefined,
picUrl: undefined,
sliderPicUrls: undefined,
sort: undefined,
price: undefined,
marketPrice: undefined,
costPrice: undefined
})
const formRules = reactive({
deviceId: [{ required: true, message: '设备IMEI不能为空', trigger: 'blur' }],
barCode: [{ required: true, message: 'SKU 的条形码不能为空', trigger: 'blur' }],
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }],
categoryId: [{ required: true, message: '商品分类编号不能为空', trigger: 'blur' }],
picUrl: [{ required: true, message: '商品封面图不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '排序字段不能为空', trigger: 'blur' }],
price: [{ required: true, message: '商品价格,单位使用:分不能为空', trigger: 'blur' }],
costPrice: [{ required: true, message: '成本价,单位: 分不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
// 修改时,设置数据
if (id) {
formLoading.value = true
try {
formData.value = await SummaryApi.getSummary(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 校验表单
await formRef.value.validate()
// 提交请求
formLoading.value = true
try {
const data = formData.value as unknown as SummaryVO
if (formType.value === 'create') {
await SummaryApi.createSummary(data)
message.success(t('common.createSuccess'))
} else {
await SummaryApi.updateSummary(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
deviceId: undefined,
barCode: undefined,
name: undefined,
keyword: undefined,
introduction: undefined,
description: undefined,
categoryId: undefined,
brandId: undefined,
picUrl: undefined,
sliderPicUrls: undefined,
sort: undefined,
price: undefined,
marketPrice: undefined,
costPrice: undefined
}
formRef.value?.resetFields()
}
</script>
+334
View File
@@ -0,0 +1,334 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="设备IMEI" prop="deviceId">
<el-input
v-model="queryParams.deviceId"
placeholder="请输入设备IMEI"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<!-- <el-form-item label="SKU 的条形码" prop="barCode">
<el-input
v-model="queryParams.barCode"
placeholder="请输入SKU 的条形码"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<el-form-item label="商品名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入商品名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="关键字" prop="keyword">
<el-input
v-model="queryParams.keyword"
placeholder="请输入关键字"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<!-- <el-form-item label="商品简介" prop="introduction">
<el-input
v-model="queryParams.introduction"
placeholder="请输入商品简介"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="商品分类编号" prop="categoryId">
<el-input
v-model="queryParams.categoryId"
placeholder="请输入商品分类编号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="商品品牌编号" prop="brandId">
<el-input
v-model="queryParams.brandId"
placeholder="请输入商品品牌编号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="商品封面图" prop="picUrl">
<el-input
v-model="queryParams.picUrl"
placeholder="请输入商品封面图"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item
label="商品轮播图地址
数组,以逗号分隔
最多上传15张"
prop="sliderPicUrls"
>
<el-input
v-model="queryParams.sliderPicUrls"
placeholder="请输入商品轮播图地址
数组,以逗号分隔
最多上传15张"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="排序字段" prop="sort">
<el-input
v-model="queryParams.sort"
placeholder="请输入排序字段"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="商品价格,单位使用:分" prop="price">
<el-input
v-model="queryParams.price"
placeholder="请输入商品价格,单位使用:分"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="市场价,单位使用:分" prop="marketPrice">
<el-input
v-model="queryParams.marketPrice"
placeholder="请输入市场价,单位使用:分"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<!-- <el-form-item label="成本价,单位: 分" prop="costPrice">
<el-input
v-model="queryParams.costPrice"
placeholder="请输入成本价,单位: 分"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item> -->
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-220px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['product:summary:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['product:summary:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="商品编号,自增" align="center" prop="id" />
<el-table-column label="设备IMEI" align="center" prop="deviceId" />
<!-- <el-table-column label="SKU 的条形码" align="center" prop="barCode" /> -->
<el-table-column label="商品名称" align="center" prop="name" />
<el-table-column label="关键字" align="center" prop="keyword" />
<!-- <el-table-column label="商品简介" align="center" prop="introduction" /> -->
<el-table-column label="商品详情" align="center" prop="description" />
<el-table-column label="商品分类编号" align="center" prop="categoryId" />
<!-- <el-table-column label="商品品牌编号" align="center" prop="brandId" /> -->
<!-- <el-table-column label="商品封面图" align="center" prop="picUrl" /> -->
<!-- <el-table-column
label="商品轮播图地址
数组,以逗号分隔
最多上传15张"
align="center"
prop="sliderPicUrls"
/> -->
<!-- <el-table-column label="排序字段" align="center" prop="sort" /> -->
<el-table-column label="商品价格,单位使用:分" align="center" prop="price" />
<el-table-column label="市场价,单位使用:分" align="center" prop="marketPrice" />
<el-table-column label="成本价,单位: 分" align="center" prop="costPrice" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" min-width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['product:summary:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['product:summary:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<SummaryForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { SummaryApi, SummaryVO } from '@/api/product/summary'
import SummaryForm from './SummaryForm.vue'
/** 商品汇总 列表 */
defineOptions({ name: 'Summary' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const list = ref<SummaryVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
deviceId: undefined,
barCode: undefined,
name: undefined,
keyword: undefined,
introduction: undefined,
description: undefined,
categoryId: undefined,
brandId: undefined,
picUrl: undefined,
sliderPicUrls: undefined,
sort: undefined,
price: undefined,
marketPrice: undefined,
costPrice: undefined,
createTime: []
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await SummaryApi.getSummaryPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
await SummaryApi.deleteSummary(id)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await SummaryApi.exportSummary(queryParams)
download.excel(data, '商品汇总.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>