优化用户体验
parent
42c2b69124
commit
96e09786f1
|
|
@ -53,5 +53,11 @@ export const ProductApi = {
|
||||||
// 导出产品 Excel
|
// 导出产品 Excel
|
||||||
exportProduct: async (params) => {
|
exportProduct: async (params) => {
|
||||||
return await request.download({ url: `/erp/product/export-excel`, params })
|
return await request.download({ url: `/erp/product/export-excel`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
//通过产品分类id查询产品list
|
||||||
|
getProductListByCategoryIds: async (productCategoryIds: number[]) => {
|
||||||
|
return await request.get({ url: `/erp/product/simple-list-by-category-ids`, params: { productCategoryIds } })
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
// ERP 产品属性映射 VO
|
||||||
|
export interface ProductPropertiesMapVO {
|
||||||
|
id: number // 编号
|
||||||
|
productId: number // 产品id
|
||||||
|
productCategoryPropertiesId: number // 产品类别属性id
|
||||||
|
productPropertiesProductId: number // 产品属性产品id
|
||||||
|
productCategoryPropertiesValue: string // 产品类别属性值
|
||||||
|
}
|
||||||
|
|
||||||
|
// ERP 产品属性映射 API
|
||||||
|
export const ProductPropertiesMapApi = {
|
||||||
|
// 查询ERP 产品属性映射分页
|
||||||
|
getProductPropertiesMapPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/erp/product-properties-map/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询ERP 产品属性映射详情
|
||||||
|
getProductPropertiesMap: async (id: number) => {
|
||||||
|
return await request.get({ url: `/erp/product-properties-map/get?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增ERP 产品属性映射
|
||||||
|
createProductPropertiesMap: async (data: ProductPropertiesMapVO) => {
|
||||||
|
return await request.post({ url: `/erp/product-properties-map/create`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改ERP 产品属性映射
|
||||||
|
updateProductPropertiesMap: async (data: ProductPropertiesMapVO) => {
|
||||||
|
return await request.put({ url: `/erp/product-properties-map/update`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除ERP 产品属性映射
|
||||||
|
deleteProductPropertiesMap: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/erp/product-properties-map/delete?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出ERP 产品属性映射 Excel
|
||||||
|
exportProductPropertiesMap: async (params) => {
|
||||||
|
return await request.download({ url: `/erp/product-properties-map/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -136,7 +136,7 @@ const formData = ref({
|
||||||
productPropertiesCn: undefined,
|
productPropertiesCn: undefined,
|
||||||
ifRequired: undefined,
|
ifRequired: undefined,
|
||||||
productPropertiesCategory: undefined,
|
productPropertiesCategory: undefined,
|
||||||
ifSn: undefined
|
ifSn: false
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
productCategoryId: [{ required: true, message: '类别属性不能为空', trigger: 'change' }],
|
productCategoryId: [{ required: true, message: '类别属性不能为空', trigger: 'change' }],
|
||||||
|
|
@ -204,7 +204,7 @@ const resetForm = () => {
|
||||||
productPropertiesCn: undefined,
|
productPropertiesCn: undefined,
|
||||||
ifRequired: undefined,
|
ifRequired: undefined,
|
||||||
productPropertiesCategory: undefined,
|
productPropertiesCategory: undefined,
|
||||||
ifSn: undefined
|
ifSn: false
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="记录sn" align="center" prop="ifSn">
|
<el-table-column label="记录sn" align="center" prop="ifSn">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifRequired" />
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifSn" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
|
|
@ -180,7 +180,9 @@
|
||||||
/>
|
/>
|
||||||
<el-table-column label="操作" align="center" min-width="120px">
|
<el-table-column label="操作" align="center" min-width="120px">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<router-link :to="'/erp/product/product-category-properties-category-map?searchId=' + scope.row.id"
|
<router-link :to="'/erp/product/product-category-properties-category-map?productCategoryPropertiesId=' + scope.row.id+'&productPropertiesCategory='+scope.row.productPropertiesCategory"
|
||||||
|
|
||||||
|
v-show="scope.row.productPropertiesCategory !== 2"
|
||||||
v-hasPermi="['erp:product-category-properties-category-map:query']"
|
v-hasPermi="['erp:product-category-properties-category-map:query']"
|
||||||
>
|
>
|
||||||
<el-button link type="primary"
|
<el-button link type="primary"
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@
|
||||||
<el-tree-select v-model="formData.productCategoryId" :data="productCategoryTree" :props="defaultProps"
|
<el-tree-select v-model="formData.productCategoryId" :data="productCategoryTree" :props="defaultProps"
|
||||||
check-strictly default-expand-all placeholder="请选择上级编号" />
|
check-strictly default-expand-all placeholder="请选择上级编号" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-row>
|
<el-row v-if="productPropertiesCategory === 0">
|
||||||
<el-col :span="21">
|
<el-col :span="21">
|
||||||
<el-form-item label="分类属性值" prop="productCategoryPropertiesValue" v-if="productPropertiesCategory === 0">
|
<el-form-item label="分类属性值" prop="productCategoryPropertiesValue">
|
||||||
<el-select v-model="formData.productCategoryPropertiesValue" placeholder="请选择产品分类属性值" clearable>
|
<el-select v-model="formData.productCategoryPropertiesValue" placeholder="请选择产品分类属性值" clearable>
|
||||||
<el-option v-for="dict in productCategoryPropertiesValueList" :key="dict.id"
|
<el-option v-for="dict in productCategoryPropertiesValueList" :key="dict.id"
|
||||||
:label="dict.productCategoryPropertiesValue" :value="dict.productCategoryPropertiesValue" />
|
:label="dict.productCategoryPropertiesValue" :value="dict.productCategoryPropertiesValue" />
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<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="编号" align="center" prop="id" />
|
||||||
<el-table-column label="产品分类" align="center" prop="productCategoryValue" />
|
<el-table-column label="产品分类" align="center" prop="productCategoryValue" v-if="productPropertiesCategory===1"/>
|
||||||
<el-table-column label="分类属性值" align="center" prop="productCategoryPropertiesValue" />
|
<el-table-column label="分类属性值" align="center" prop="productCategoryPropertiesValue" v-if="productPropertiesCategory===0"/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="创建时间"
|
label="创建时间"
|
||||||
align="center"
|
align="center"
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<ProductCategoryPropertiesCategoryMapForm ref="formRef" @success="getList" :product-properties-cn="productPropertiesCn" :product-category-properties-id="Number(route.query.searchId)"/>
|
<ProductCategoryPropertiesCategoryMapForm ref="formRef" @success="getList" :product-properties-cn="productPropertiesCn" :product-category-properties-id="Number(route.query.productCategoryPropertiesId)"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -107,7 +107,7 @@ import { dateFormatter } from '@/utils/formatTime'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import { ProductCategoryPropertiesCategoryMapApi, ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap'
|
import { ProductCategoryPropertiesCategoryMapApi, ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap'
|
||||||
import ProductCategoryPropertiesCategoryMapForm from './ProductCategoryPropertiesCategoryMapForm.vue'
|
import ProductCategoryPropertiesCategoryMapForm from './ProductCategoryPropertiesCategoryMapForm.vue'
|
||||||
import { ProductCategoryPropertiesApi,ProductCategoryPropertiesVO } from '@/api/erp/product/category/productcategoryproperties'
|
import { ProductCategoryPropertiesApi } from '@/api/erp/product/category/productcategoryproperties'
|
||||||
|
|
||||||
const route = useRoute() // 路由
|
const route = useRoute() // 路由
|
||||||
let searchCount = 0
|
let searchCount = 0
|
||||||
|
|
@ -132,13 +132,18 @@ const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
/** 分类属性中文 */
|
/** 分类属性中文 */
|
||||||
let productPropertiesCn = ref('')
|
let productPropertiesCn = ref('')
|
||||||
|
/** 产品属性分类 */
|
||||||
|
let productPropertiesCategory = ref()
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
if(route.query.searchId && searchCount == 0){
|
if(route.query.productCategoryPropertiesId && searchCount == 0){
|
||||||
searchCount++
|
searchCount++
|
||||||
queryParams.productCategoryPropertiesId = Number(route.query.searchId)
|
queryParams.productCategoryPropertiesId = Number(route.query.productCategoryPropertiesId)
|
||||||
|
}
|
||||||
|
if(route.query.productPropertiesCategory){
|
||||||
|
productPropertiesCategory.value = Number(route.query.productPropertiesCategory)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const data = await ProductCategoryPropertiesCategoryMapApi.getProductCategoryPropertiesCategoryMapPage(queryParams)
|
const data = await ProductCategoryPropertiesCategoryMapApi.getProductCategoryPropertiesCategoryMapPage(queryParams)
|
||||||
|
|
@ -199,11 +204,11 @@ const handleExport = async () => {
|
||||||
/** 根据用户输入搜索类别 */
|
/** 根据用户输入搜索类别 */
|
||||||
const searchProductCategoryProperties = async () => {
|
const searchProductCategoryProperties = async () => {
|
||||||
//通过分类属性id查询详情
|
//通过分类属性id查询详情
|
||||||
if (!route.query.searchId) {
|
if (!route.query.productCategoryPropertiesId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ProductCategoryPropertiesApi.getProductCategoryProperties(Number(route.query.searchId)).then(res => {
|
ProductCategoryPropertiesApi.getProductCategoryProperties(Number(route.query.productCategoryPropertiesId)).then(res => {
|
||||||
productPropertiesCn.value = res.productPropertiesCn
|
productPropertiesCn.value = res.productPropertiesCn
|
||||||
})
|
})
|
||||||
}catch (error) {
|
}catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
<template>
|
||||||
|
<!-- 列表 -->
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="70%">
|
||||||
|
<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="单数属性" align="center" prop="ifSingleProperty">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifSingleProperty" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="属性英文" align="center" prop="productPropertiesEn" />
|
||||||
|
<el-table-column label="属性中文" align="center" prop="productPropertiesCn" />
|
||||||
|
<el-table-column label="必填" align="center" prop="ifRequired">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifRequired" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="属性分类" align="center" prop="productPropertiesCategory">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.ERP_PRODUCT_PROPERTIES_CATEGORY" :value="scope.row.productPropertiesCategory" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="记录sn" align="center" prop="ifSn">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifRequired" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" width="180px" />
|
||||||
|
<el-table-column label="操作" align="center" min-width="120px">
|
||||||
|
<template #default="scope">
|
||||||
|
<!-- 普通属性 -->
|
||||||
|
<router-link
|
||||||
|
v-show="scope.row.productPropertiesCategory === 0"
|
||||||
|
:to="'/erp/product/product-category-properties-category-map?productCategoryPropertiesId=' + scope.row.id+'&productId='+fProductId+'&productPropertiesCategory='+scope.row.productPropertiesCategory+'&productCategoryId='+scope.row.productCategoryId+''"
|
||||||
|
v-hasPermi="['erp:product-properties-map:query']">
|
||||||
|
<el-button link type="primary">绑定</el-button>
|
||||||
|
</router-link>
|
||||||
|
<router-link
|
||||||
|
v-show="scope.row.productPropertiesCategory === 1"
|
||||||
|
:to="'/erp/product/product-properties-map?productCategoryPropertiesId=' + scope.row.id+'&productId='+fProductId+'&productPropertiesCategory='+scope.row.productPropertiesCategory+'&productCategoryId='+scope.row.productCategoryId+''"
|
||||||
|
v-hasPermi="['erp:product-properties-map:query']">
|
||||||
|
<el-button link type="primary">绑定</el-button>
|
||||||
|
</router-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
</ContentWrap>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import { ProductCategoryPropertiesApi, ProductCategoryPropertiesVO } from '@/api/erp/product/category/productcategoryproperties'
|
||||||
|
|
||||||
|
/** 展示表格 */
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('')
|
||||||
|
/** ERP 产品分类属性 列表 */
|
||||||
|
defineOptions({ name: 'ProductProperties' })
|
||||||
|
|
||||||
|
/** 传递过来的产品id */
|
||||||
|
let fProductId = ref()
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<ProductCategoryPropertiesVO[]>([]) // 列表的数据
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
productCategoryId: null as any,
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProductCategoryPropertiesApi.getProductCategoryPropertiesPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (productId: any,productCategoryId?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = "产品属性"
|
||||||
|
queryParams.productCategoryId = productCategoryId
|
||||||
|
fProductId = productId
|
||||||
|
await getList()
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -98,8 +98,16 @@
|
||||||
:formatter="dateFormatter"
|
:formatter="dateFormatter"
|
||||||
width="180px"
|
width="180px"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="操作" align="center" width="110">
|
<el-table-column label="操作" align="center" width="160">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openPropertiesForm(scope.row.id,scope.row.categoryId)"
|
||||||
|
v-hasPermi="['erp:product-properties-map:query']"
|
||||||
|
>
|
||||||
|
属性
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|
@ -130,6 +138,10 @@
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<ProductForm ref="formRef" @success="getList" />
|
<ProductForm ref="formRef" @success="getList" />
|
||||||
|
<!-- 产品属性弹窗 -->
|
||||||
|
<ProductPropertiesForm ref="formPropertiesRef" @success="getList" />
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -141,6 +153,7 @@ import ProductForm from './ProductForm.vue'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
import { erpPriceTableColumnFormatter } from '@/utils'
|
import { erpPriceTableColumnFormatter } from '@/utils'
|
||||||
|
import ProductPropertiesForm from './ProductPropertiesForm.vue'
|
||||||
|
|
||||||
/** ERP 产品列表 */
|
/** ERP 产品列表 */
|
||||||
defineOptions({ name: 'ErpProduct' })
|
defineOptions({ name: 'ErpProduct' })
|
||||||
|
|
@ -191,6 +204,12 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 产品属性 */
|
||||||
|
const formPropertiesRef = ref()
|
||||||
|
const openPropertiesForm = (id: number,productCategoryId: number) => {
|
||||||
|
formPropertiesRef.value.open(id,productCategoryId)
|
||||||
|
}
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
<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="产品id" prop="productId">
|
||||||
|
<el-input v-model="formData.productId" disabled placeholder="请输入产品id" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="分类属性" prop="productCategoryPropertiesId">
|
||||||
|
<el-input v-model="formData.productCategoryPropertiesId" disabled placeholder="请输入产品分类属性id" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="属性" prop="productPropertiesProductId">
|
||||||
|
<el-select v-model="formData.productPropertiesProductId" placeholder="请选择产品属性产品">
|
||||||
|
<el-option
|
||||||
|
v-for="item in products"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="分类属性值" prop="productCategoryPropertiesValue">
|
||||||
|
<el-input v-model="formData.productCategoryPropertiesValue" 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 { ProductPropertiesMapApi, ProductPropertiesMapVO } from '@/api/erp/product/product/productpropertiesmap'
|
||||||
|
import { ProductCategoryPropertiesCategoryMapApi,ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap'
|
||||||
|
import { ProductCategoryApi,ProductCategoryVO } from '@/api/erp/product/category'
|
||||||
|
import { ProductApi,ProductVO } from '@/api/erp/product/product'
|
||||||
|
|
||||||
|
/** 从父组件取值 */
|
||||||
|
const props = defineProps({
|
||||||
|
productCategoryPropertiesId: {
|
||||||
|
type: Number,
|
||||||
|
default: undefined
|
||||||
|
},
|
||||||
|
productPropertiesCategory:{
|
||||||
|
type: Number,
|
||||||
|
default: () => {}
|
||||||
|
},
|
||||||
|
productId:{
|
||||||
|
type: Number,
|
||||||
|
default: () => {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/** ERP 产品属性映射 表单 */
|
||||||
|
defineOptions({ name: 'ProductPropertiesMapForm' })
|
||||||
|
|
||||||
|
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,
|
||||||
|
productId: null as any,
|
||||||
|
productCategoryPropertiesId: null as any,
|
||||||
|
productPropertiesProductId: undefined,
|
||||||
|
productCategoryPropertiesValue: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
productCategoryPropertiesId: [{ required: true, message: '产品分类属性id不能为空', trigger: 'blur' }],
|
||||||
|
productId: [{ required: true, message: '产品id不能为空', trigger: 'blur' }],
|
||||||
|
})
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
// 产品列表
|
||||||
|
const products = ref<ProductVO[]>([])
|
||||||
|
|
||||||
|
/** 通过 productCategoryPropertiesId查询所有的分类id */
|
||||||
|
const getProductPropertiesCategoryList = async () => {
|
||||||
|
if (props.productCategoryPropertiesId) {
|
||||||
|
//构建查询条件
|
||||||
|
const params = {
|
||||||
|
productCategoryPropertiesId: props.productCategoryPropertiesId
|
||||||
|
}
|
||||||
|
ProductCategoryPropertiesCategoryMapApi.getProductCategoryPropertiesCategoryMapPage(params).then((res) => {
|
||||||
|
const data = res.list as ProductCategoryPropertiesCategoryMapVO[]
|
||||||
|
//将所有的productCategoryId 汇总成数组
|
||||||
|
const productCategoryIds = data.map((item) => item.productCategoryId)
|
||||||
|
getProductList(productCategoryIds)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 通过productCategoryIds查询所有相关的product */
|
||||||
|
const getProductList = async (productCategoryIds: number[]) => {
|
||||||
|
if (productCategoryIds.length > 0) {
|
||||||
|
//构建查询条件
|
||||||
|
ProductApi.getProductListByCategoryIds(productCategoryIds).then((res) => {
|
||||||
|
|
||||||
|
products.value = res as ProductVO[]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
//赋值
|
||||||
|
formData.value.productId = props.productId
|
||||||
|
formData.value.productCategoryPropertiesId = props.productCategoryPropertiesId
|
||||||
|
await getProductPropertiesCategoryList()
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await ProductPropertiesMapApi.getProductPropertiesMap(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 ProductPropertiesMapVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await ProductPropertiesMapApi.createProductPropertiesMap(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await ProductPropertiesMapApi.updateProductPropertiesMap(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
productId: null as any,
|
||||||
|
productCategoryPropertiesId: null as any,
|
||||||
|
productPropertiesProductId: undefined,
|
||||||
|
productCategoryPropertiesValue: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,218 @@
|
||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="产品id" prop="productId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.productId"
|
||||||
|
placeholder="请输入产品id"
|
||||||
|
disabled
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="分类属性" prop="productCategoryPropertiesId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.productCategoryPropertiesId"
|
||||||
|
placeholder="请输入产品分类属性"
|
||||||
|
disabled
|
||||||
|
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="['erp:product-properties-map:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['erp:product-properties-map: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="产品id" align="center" prop="productId" />
|
||||||
|
<el-table-column label="分类属性" align="center" prop="productCategoryPropertiesId" />
|
||||||
|
<el-table-column label="属性id" align="center" prop="productPropertiesProductId" />
|
||||||
|
<el-table-column label="分类属性值" align="center" prop="productCategoryPropertiesValue" />
|
||||||
|
<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="['erp:product-properties-map:update']"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['erp:product-properties-map: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>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<ProductPropertiesMapForm ref="formRef" @success="getList" :product-id="route.query.productId" :product-category-properties-id="queryParams.productCategoryPropertiesId" :product-properties-category="productPropertiesCategory"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { ProductPropertiesMapApi, ProductPropertiesMapVO } from '@/api/erp/product/product/productpropertiesmap'
|
||||||
|
import ProductPropertiesMapForm from './ProductPropertiesMapForm.vue'
|
||||||
|
|
||||||
|
const route = useRoute() // 路由
|
||||||
|
let searchCount = 0
|
||||||
|
/** ERP 产品属性映射 列表 */
|
||||||
|
defineOptions({ name: 'ErpProductPropertiesMap' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<ProductPropertiesMapVO[]>([]) // 列表的数据
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
productId: null as any,
|
||||||
|
productCategoryPropertiesId: null as any,
|
||||||
|
productPropertiesProductId: undefined,
|
||||||
|
productCategoryPropertiesValue: undefined,
|
||||||
|
createTime: []
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
const productPropertiesCategory = ref()
|
||||||
|
/** 通过路由获取次产品属性关联的所有的值 */
|
||||||
|
const getProductPropertiesProductList = async () => {
|
||||||
|
if(route.query.productCategoryPropertiesId){
|
||||||
|
queryParams.productCategoryPropertiesId = Number(route.query.productCategoryPropertiesId)
|
||||||
|
}
|
||||||
|
if(route.query.productId){
|
||||||
|
queryParams.productId = Number(route.query.productId)
|
||||||
|
}
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProductPropertiesMapApi.getProductPropertiesMapPage(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 ProductPropertiesMapApi.deleteProductPropertiesMap(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
// 导出的二次确认
|
||||||
|
await message.exportConfirm()
|
||||||
|
// 发起导出
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await ProductPropertiesMapApi.exportProductPropertiesMap(queryParams)
|
||||||
|
download.excel(data, 'ERP 产品属性映射.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getProductPropertiesProductList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue