salary
qsh 6 months ago
parent 1e0ba3b619
commit de522af86f
  1. 25
      src/api/mall/product/index.js
  2. 34
      src/views/MiniMall/Product/add.vue
  3. 159
      src/views/MiniMall/Product/index.vue

@ -0,0 +1,25 @@
import request from '@/config/axios'
// 查询列表
export const getProductPage = async (params) => {
return await request.get({ url: '/admin-api/crm/erp-product//page', params })
}
// 查询详情
export const getProduct = async (id) => {
return await request.get({ url: '/admin-api/crm/erp-product//get?id=' + id })
}
// 新增
export const createProduct = async (data) => {
return await request.post({ url: '/admin-api/crm/erp-product//create', data: data })
}
// 修改
export const updateProduct = async (params) => {
return await request.put({ url: '/admin-api/crm/erp-product//update', data: params })
}
// 删除
export const deleteProduct = async (id) => {
return await request.delete({ url: '/admin-api/crm/erp-product//delete?id=' + id })
}

@ -4,26 +4,39 @@
<el-form :model="form" ref="spuForm" :rules="rules" label-width="90px"> <el-form :model="form" ref="spuForm" :rules="rules" label-width="90px">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8" :offset="0"> <el-col :span="8" :offset="0">
<el-form-item label="产品名称" prop="name"> <el-form-item label="产品名称" prop="productName">
<el-input v-model="form.name" placeholder="请输入产品名称" /> <el-input v-model="form.productName" placeholder="请输入产品名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8" :offset="0"> <el-col :span="8" :offset="0">
<el-form-item label="分类" prop="category"> <el-form-item label="分类" prop="productCategory">
<el-input v-model="form.category" placeholder="请输入分类" /> <el-cascader
:options="opts.productCategory"
v-model="form.productCategory"
placeholder="请选择分类"
filterable
show-all-levels
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8" :offset="0"> <el-col :span="8" :offset="0">
<el-form-item label="品牌" prop="brand"> <el-form-item label="品牌" prop="productBrand">
<el-input v-model="form.brand" placeholder="请输入品牌" /> <el-select v-model="form.productBrand" placeholder="请选择品牌" filterable>
<el-option
v-for="item in opts.brand"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12" :offset="0"> <el-col :span="12" :offset="0">
<el-form-item label="产品简介" prop="intro"> <el-form-item label="产品简介" prop="productIntro">
<el-input <el-input
v-model="form.intro" v-model="form.productIntro"
type="textarea" type="textarea"
:autosize="{ minRows: 4 }" :autosize="{ minRows: 4 }"
placeholder="请输入产品简介" placeholder="请输入产品简介"
@ -148,6 +161,11 @@ const form = ref({
const rules = ref({}) const rules = ref({})
const attributesAddFormRef = ref() // const attributesAddFormRef = ref() //
const opts = {
brand: [],
productCategory: []
}
/** 删除属性*/ /** 删除属性*/
function handleCloseProperty(index) { function handleCloseProperty(index) {
form.value.specsList?.splice(index, 1) form.value.specsList?.splice(index, 1)

@ -1,31 +1,40 @@
<template> <template>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form <el-form inline :model="queryParams" class="-mb-15px" label-width="0">
ref="queryFormRef" <el-form-item>
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<!-- TODO @puhui999品牌应该是数据下拉哈 -->
<el-form-item label="品牌名称" prop="productBrandName">
<el-input <el-input
v-model="queryParams.productBrandName" v-model="queryParams.productName"
class="!w-240px" class="!w-200px"
clearable clearable
placeholder="请输入品名称" placeholder="请输入产品名称"
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="创建时间" prop="createTime"> <el-form-item>
<el-date-picker <el-select
v-model="queryParams.createTime" v-model="queryParams.productBrand"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" placeholder="请选择品牌"
class="!w-240px" clearable
end-placeholder="结束日期" filterable
start-placeholder="开始日期" @change="handleQuery"
type="daterange" >
value-format="YYYY-MM-DD HH:mm:ss" <el-option
v-for="item in opts.brand"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-cascader
:options="opts.productCategory"
v-model="queryParams.productCategory"
placeholder="请选择分类"
clearable
filterable
show-all-levels
@change="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -36,36 +45,34 @@
</el-form> </el-form>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" class="mt-20px" :data="list" border> <el-table v-loading="loading" class="mt-20px" :data="tableList" border>
<el-table-column type="expand" width="30"> <el-table-column type="expand" width="30">
<template #default="scope"> <template #default="{ row }">
<div class="pl-100px pr-100px"> <div class="pl-100px pr-100px">
<el-table :data="scope.row.specsList"> <el-table :data="row.productSpecList">
<el-table-column label="规格名称" prop="" /> <el-table-column label="规格名称" prop="specsName" />
<el-table-column label="颜色" prop="color" />
<el-table-column label="售价" prop="price" /> <el-table-column label="售价" prop="price" />
<el-table-column label="成本价" prop="" />
<el-table-column label="简介" prop="intro" /> <el-table-column label="简介" prop="intro" />
</el-table> </el-table>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column key="id" label="产品编码" prop="id" /> <el-table-column key="productId" label="产品编码" prop="productId" />
<el-table-column show-overflow-tooltip label="产品名称" min-width="200" prop="name" /> <el-table-column show-overflow-tooltip label="产品名称" min-width="200" prop="productName" />
<el-table-column label="分类" min-width="90" prop="salesCount" /> <el-table-column label="分类" min-width="90" prop="productCategoryName" />
<el-table-column label="品牌" min-width="90" prop="stock" /> <el-table-column label="品牌" min-width="90" prop="productBrandName" />
<el-table-column label="商品图" min-width="80"> <el-table-column label="商品图" min-width="80">
<template #default="{ row }"> <template #default="{ row }">
<el-image :src="row.picUrl" @click="imagePreview(row.picUrl)" class="w-30px h-30px" /> <el-image :src="row.mainImage" @click="imagePreview(row.mainImage)" class="w-30px h-30px" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="简介" min-width="70" prop="sort" /> <el-table-column label="简介" min-width="70" prop="productIntro" />
<el-table-column :formatter="dateFormatter" label="创建时间" prop="createTime" width="180" /> <el-table-column :formatter="dateFormatter" label="创建时间" prop="createTime" width="180" />
<el-table-column fixed="right" label="操作" min-width="80"> <el-table-column fixed="right" label="操作" min-width="80">
<template #default="{ row }"> <template #default="{ row }">
<!-- TODO @puhui999详情可以后面点做哈 --> <!-- TODO详情可以后面点做哈 -->
<el-button link type="primary" @click="openForm(row.id)"> 修改 </el-button> <el-button link type="primary" @click="openForm(row.productId)"> 修改 </el-button>
<el-button link type="danger" @click="handleDelete(row.id)"> 删除 </el-button> <el-button link type="danger" @click="handleDelete(row.productId)"> 删除 </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -81,58 +88,51 @@
<script setup name="Product"> <script setup name="Product">
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
import * as ProductApi from '@/api/mall/product'
const { currentRoute, push } = useRouter() const { currentRoute, push } = useRouter()
const message = useMessage() //
const { t } = useI18n() //
const queryParams = ref({ const queryParams = ref({
productName: undefined,
productBrand: undefined,
productCategory: undefined,
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10
}) // }) //
const opts = ref({
brand: [],
productCategory: []
})
const loading = ref(false) // const loading = ref(false) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const tableList = ref([]) //
/** 删除按钮操作 */ /** 删除按钮操作 */
function handleDelete() { async function handleDelete(id) {
console.log('123') try {
// try { //
// // await message.delConfirm()
// await message.delConfirm() //
// // await ProductApi.deleteProduct(id)
// // await ProductSpuApi.deleteSpu(id) message.success(t('common.delSuccess'))
// message.success(t('common.delSuccess')) //
// // await getList()
// await getList() } catch {}
// } catch { }
} }
function getList() { async function getList() {
list.value = [ loading.value = true
{ try {
id: '1234', const data = await ProductApi.getProductPage(queryParams.value)
name: '爱玩熊攀岩墙', tableList.value = data.list
specsList: [ total.value = data.total
{ } finally {
color: '黑色', loading.value = false
price: 1234
},
{
color: '灰色',
price: 4231
}
]
},
{
id: '12345',
name: '熊攀尼攀岩墙',
specsList: [
{
color: '黑色',
price: 12345
} }
]
}
]
} }
/** 商品图预览 */ /** 商品图预览 */
function imagePreview(imgUrl) { function imagePreview(imgUrl) {
@ -143,19 +143,26 @@ function imagePreview(imgUrl) {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
function handleQuery() { function handleQuery() {
queryParams.value.pageNo = 1
getList() getList()
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
function resetQuery() { function resetQuery() {
queryFormRef.value.resetFields() queryParams.value = {
productName: undefined,
productBrand: undefined,
productCategory: undefined,
pageNo: 1,
pageSize: 10
}
handleQuery() handleQuery()
} }
/** /**
* 新增或修改 * 新增或修改
* *
* @param id 商品 SPU 编号 * @param id 商品 编号
*/ */
function openForm(id) { function openForm(id) {
// //

Loading…
Cancel
Save