📖 CRM:产品模块的 review

This commit is contained in:
shizhong 2024-03-08 21:24:00 +08:00
parent f2fcaf0eb3
commit 231ba51650
4 changed files with 43 additions and 50 deletions

View File

@ -14,35 +14,35 @@ export interface ProductVO {
// 查询产品列表 // 查询产品列表
export const getProductPage = async (params) => { export const getProductPage = async (params) => {
return await request.get({url: `/crm/product/page`, params}) return await request.get({ url: `/crm/product/page`, params })
} }
// 查询产品详情 // 查询产品详情
export const getProduct = async (id: number) => { export const getProduct = async (id: number) => {
return await request.get({url: `/crm/product/get?id=` + id}) return await request.get({ url: `/crm/product/get?id=` + id })
} }
// 新增产品 // 新增产品
export const createProduct = async (data: ProductVO) => { export const createProduct = async (data: ProductVO) => {
return await request.post({url: `/crm/product/create`, data}) return await request.post({ url: `/crm/product/create`, data })
} }
// 修改产品 // 修改产品
export const updateProduct = async (data: ProductVO) => { export const updateProduct = async (data: ProductVO) => {
return await request.put({url: `/crm/product/update`, data}) return await request.put({ url: `/crm/product/update`, data })
} }
// 删除产品 // 删除产品
export const deleteProduct = async (id: number) => { export const deleteProduct = async (id: number) => {
return await request.delete({url: `/crm/product/delete?id=` + id}) return await request.delete({ url: `/crm/product/delete?id=` + id })
} }
// 导出产品 Excel // 导出产品 Excel
export const exportProduct = async (params) => { export const exportProduct = async (params) => {
return await request.download({url: `/crm/product/export-excel`, params}) return await request.download({ url: `/crm/product/export-excel`, params })
} }
// 查询产品操作日志 // 查询产品操作日志
export const getOperateLogPage = async (params: any) => { export const getOperateLogPage = async (params: any) => {
return await request.get({url: '/crm/product/operate-log-page', params}) return await request.get({ url: '/crm/product/operate-log-page', params })
} }

View File

@ -502,7 +502,8 @@ const remainingRouter: AppRouteRecordRaw[] = [
meta: { meta: {
title: '客户详情', title: '客户详情',
noCache: true, noCache: true,
hidden: true hidden: true,
activeMenu: '/crm/customer'
}, },
component: () => import('@/views/crm/customer/detail/index.vue') component: () => import('@/views/crm/customer/detail/index.vue')
}, },
@ -512,7 +513,8 @@ const remainingRouter: AppRouteRecordRaw[] = [
meta: { meta: {
title: '联系人详情', title: '联系人详情',
noCache: true, noCache: true,
hidden: true hidden: true,
activeMenu: '/crm/contact'
}, },
component: () => import('@/views/crm/contact/detail/index.vue') component: () => import('@/views/crm/contact/detail/index.vue')
}, },
@ -522,7 +524,8 @@ const remainingRouter: AppRouteRecordRaw[] = [
meta: { meta: {
title: '产品详情', title: '产品详情',
noCache: true, noCache: true,
hidden: true hidden: true,
activeMenu: '/crm/product'
}, },
component: () => import('@/views/crm/product/detail/index.vue') component: () => import('@/views/crm/product/detail/index.vue')
} }

View File

@ -62,13 +62,13 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="价格" prop="price"> <el-form-item label="价格" prop="price">
<el-input <el-input-number
type="number"
v-model="formData.price" v-model="formData.price"
placeholder="请输入价格" placeholder="请输入价格"
:min="0" :min="0"
:precision="2" :precision="2"
:step="0.1" :step="0.1"
class="w-full!"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>

View File

@ -28,17 +28,10 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"> <el-button @click="handleQuery"> <Icon icon="ep:search" class="mr-5px" /> 搜索 </el-button>
<Icon icon="ep:search" class="mr-5px"/> <el-button @click="resetQuery"> <Icon icon="ep:refresh" class="mr-5px" /> 重置 </el-button>
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px"/>
重置
</el-button>
<el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:product:create']"> <el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:product:create']">
<Icon icon="ep:plus" class="mr-5px"/> <Icon icon="ep:plus" class="mr-5px" /> 新增
新增
</el-button> </el-button>
<el-button <el-button
type="success" type="success"
@ -47,7 +40,7 @@
:loading="exportLoading" :loading="exportLoading"
v-hasPermi="['crm:product:export']" v-hasPermi="['crm:product:export']"
> >
<Icon icon="ep:download" class="mr-5px"/> <Icon icon="ep:download" class="mr-5px" />
导出 导出
</el-button> </el-button>
</el-form-item> </el-form-item>
@ -64,26 +57,27 @@
</el-link> </el-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="产品类型" align="center" prop="categoryName" width="160"/> <el-table-column label="产品类型" align="center" prop="categoryName" width="160" />
<el-table-column label="产品单位" align="center" prop="unit"> <el-table-column label="产品单位" align="center" prop="unit">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.PRODUCT_UNIT" :value="scope.row.unit"/> <dict-tag :type="DICT_TYPE.PRODUCT_UNIT" :value="scope.row.unit" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="产品编码" align="center" prop="no"/> <el-table-column label="产品编码" align="center" prop="no" />
<el-table-column <el-table-column
label="价格(元)" label="价格(元)"
align="center" align="center"
prop="price" prop="price"
:formatter="fenToYuanFormat" :formatter="fenToYuanFormat"
width="100"
/> />
<el-table-column label="产品描述" align="center" prop="description"/> <el-table-column label="产品描述" align="center" prop="description" width="150" />
<el-table-column label="是否架" align="center" prop="status"> <el-table-column label="上架状态" align="center" prop="status" width="120">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_STATUS" :value="scope.row.status"/> <dict-tag :type="DICT_TYPE.CRM_PRODUCT_STATUS" :value="scope.row.status" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="负责人" align="center" prop="ownerUserName"/> <el-table-column label="负责人" align="center" prop="ownerUserName" width="120" />
<el-table-column <el-table-column
label="更新时间" label="更新时间"
align="center" align="center"
@ -91,7 +85,7 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180px" width="180px"
/> />
<el-table-column label="创建" align="center" prop="creatorName"/> <el-table-column label="创建" align="center" prop="creatorName" width="120" />
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
@ -130,21 +124,21 @@
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<ProductForm ref="formRef" @success="getList"/> <ProductForm ref="formRef" @success="getList" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {DICT_TYPE, getIntDictOptions} from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import {dateFormatter} from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import * as ProductApi from '@/api/crm/product' import * as ProductApi from '@/api/crm/product'
import ProductForm from './ProductForm.vue' import ProductForm from './ProductForm.vue'
import {fenToYuanFormat} from '@/utils/formatter' import { fenToYuanFormat } from '@/utils/formatter'
defineOptions({name: 'CrmProduct'}) defineOptions({ name: 'CrmProduct' })
const message = useMessage() // const message = useMessage() //
const {t} = useI18n() // const { t } = useI18n() //
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
@ -189,9 +183,9 @@ const openForm = (type: string, id?: number) => {
} }
/** 打开详情 */ /** 打开详情 */
const {currentRoute, push} = useRouter() const { currentRoute, push } = useRouter()
const openDetail = (id: number) => { const openDetail = (id: number) => {
push({name: 'CrmProductDetail', params: {id}}) push({ name: 'CrmProductDetail', params: { id } })
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
@ -204,8 +198,7 @@ const handleDelete = async (id: number) => {
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch { } catch {}
}
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
@ -223,16 +216,13 @@ const handleExport = async () => {
} }
} }
/** 监听路由变化更新列表 */ /** 激活时 */
watch( onActivated(() => {
() => currentRoute.value, getList()
() => { })
getList()
}
)
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(() => {
await getList() getList()
}) })
</script> </script>