新增:产品详情页面
This commit is contained in:
56
src/views/crm/product/detail/ProductDetailsHeader.vue
Normal file
56
src/views/crm/product/detail/ProductDetailsHeader.vue
Normal file
@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex items-start justify-between">
|
||||
<div>
|
||||
<el-col>
|
||||
<el-row>
|
||||
<span class="text-xl font-bold">{{ product.name }}</span>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</div>
|
||||
<div>
|
||||
<!-- 右上:按钮 -->
|
||||
<el-button @click="openForm('update', product.id)" v-hasPermi="['crm:product:update']">
|
||||
编辑
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ContentWrap class="mt-10px">
|
||||
<el-descriptions :column="5" direction="vertical">
|
||||
<el-descriptions-item label="产品类别">
|
||||
{{ productCategoryList?.find((c) => c.id === product.categoryId)?.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="产品单位">
|
||||
<dict-tag :type="DICT_TYPE.PRODUCT_UNIT" :value="product.unit"/>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="产品价格">{{ fenToYuan(product.price) }}元</el-descriptions-item>
|
||||
<el-descriptions-item label="产品编码">{{ product.no }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</ContentWrap>
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ProductForm ref="formRef" @success="emit('refresh')"/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import ProductForm from '@/views/crm/product/ProductForm.vue'
|
||||
import {DICT_TYPE} from "@/utils/dict";
|
||||
import {fenToYuan} from "@/utils";
|
||||
import * as ProductApi from "@/api/crm/product";
|
||||
import * as ProductCategoryApi from '@/api/crm/product/productCategory'
|
||||
|
||||
|
||||
//操作修改
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
const {product} = defineProps<{ product: ProductApi.ProductVO }>()
|
||||
const emit = defineEmits(['refresh']) // 定义 success 事件,用于操作成功后的回调
|
||||
|
||||
/** 初始化 */
|
||||
const productCategoryList = ref([]) // 产品分类树
|
||||
|
||||
onMounted(async () => {
|
||||
productCategoryList.value = await ProductCategoryApi.getProductCategoryList({})
|
||||
})
|
||||
</script>
|
||||
45
src/views/crm/product/detail/ProductDetailsInfo.vue
Normal file
45
src/views/crm/product/detail/ProductDetailsInfo.vue
Normal file
@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<el-collapse v-model="activeNames">
|
||||
<el-collapse-item name="basicInfo">
|
||||
<template #title>
|
||||
<span class="text-base font-bold">基本信息</span>
|
||||
</template>
|
||||
<el-descriptions :column="4">
|
||||
<el-descriptions-item label="产品名称">{{ product.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="产品编码">{{ product.no }}</el-descriptions-item>
|
||||
<el-descriptions-item label="价格">{{ fenToYuan(product.price) }}元</el-descriptions-item>
|
||||
<el-descriptions-item label="产品描述">{{ product.description }}</el-descriptions-item>
|
||||
<el-descriptions-item label="产品类型">
|
||||
{{ productCategoryList?.find((c) => c.id === product.categoryId)?.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="是否上下架">
|
||||
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_STATUS" :value="product.status"/>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="单位">
|
||||
<dict-tag :type="DICT_TYPE.PRODUCT_UNIT" :value="product.unit"/>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {DICT_TYPE} from '@/utils/dict'
|
||||
import * as ProductApi from '@/api/crm/product'
|
||||
import {fenToYuan} from '@/utils'
|
||||
import * as ProductCategoryApi from '@/api/crm/product/productCategory'
|
||||
|
||||
const {product} = defineProps<{
|
||||
product: ProductApi.ProductVO
|
||||
}>()
|
||||
|
||||
// 展示的折叠面板
|
||||
const activeNames = ref(['basicInfo'])
|
||||
|
||||
/** 初始化 */
|
||||
const productCategoryList = ref([]) // 产品分类树
|
||||
onMounted(async () => {
|
||||
productCategoryList.value = await ProductCategoryApi.getProductCategoryList({})
|
||||
})
|
||||
</script>
|
||||
64
src/views/crm/product/detail/index.vue
Normal file
64
src/views/crm/product/detail/index.vue
Normal file
@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<ProductDetailsHeader :product="product" :loading="loading" @refresh="getProductData(id)"/>
|
||||
<el-col>
|
||||
<el-tabs>
|
||||
<el-tab-pane label="详细资料">
|
||||
<ProductDetailsInfo :product="product"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="操作日志">
|
||||
<OperateLogV2 :log-list="logList"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-col>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {useTagsViewStore} from '@/store/modules/tagsView'
|
||||
import {OperateLogV2VO} from '@/api/system/operatelog'
|
||||
import * as ProductApi from '@/api/crm/product'
|
||||
import ProductDetailsHeader from '@/views/crm/product/detail/ProductDetailsHeader.vue'
|
||||
import ProductDetailsInfo from '@/views/crm/product/detail/ProductDetailsInfo.vue'
|
||||
|
||||
defineOptions({name: 'CrmProductDetail'})
|
||||
|
||||
const route = useRoute()
|
||||
const id = Number(route.params.id) // 编号
|
||||
const loading = ref(true) // 加载中
|
||||
const product = ref<ProductApi.ProductVO>({} as ProductApi.ProductVO) // 详情
|
||||
|
||||
/** 获取详情 */
|
||||
const getProductData = async (id: number) => {
|
||||
loading.value = true
|
||||
try {
|
||||
product.value = await ProductApi.getProduct(id)
|
||||
await getOperateLog(id)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取操作日志
|
||||
*/
|
||||
const logList = ref<OperateLogV2VO[]>([]) // 操作日志列表
|
||||
const getOperateLog = async (productId: number) => {
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
const data = await ProductApi.getOperateLogPage({
|
||||
bizId: productId
|
||||
})
|
||||
logList.value = data.list
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
const {delView} = useTagsViewStore() // 视图操作
|
||||
const {currentRoute} = useRouter() // 路由
|
||||
onMounted(async () => {
|
||||
if (!id) {
|
||||
ElMessage.warning('参数错误,产品不能为空!')
|
||||
delView(unref(currentRoute))
|
||||
return
|
||||
}
|
||||
await getProductData(id)
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user