优化用户体验

pull/744/head
没钱 2025-03-11 17:00:33 +08:00
parent 42c2b69124
commit 96e09786f1
10 changed files with 582 additions and 15 deletions

View File

@ -53,5 +53,11 @@ export const ProductApi = {
// 导出产品 Excel
exportProduct: async (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 } })
}
}

View File

@ -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 })
}
}

View File

@ -136,7 +136,7 @@ const formData = ref({
productPropertiesCn: undefined,
ifRequired: undefined,
productPropertiesCategory: undefined,
ifSn: undefined
ifSn: false
})
const formRules = reactive({
productCategoryId: [{ required: true, message: '类别属性不能为空', trigger: 'change' }],
@ -204,7 +204,7 @@ const resetForm = () => {
productPropertiesCn: undefined,
ifRequired: undefined,
productPropertiesCategory: undefined,
ifSn: undefined
ifSn: false
}
formRef.value?.resetFields()
}

View File

@ -168,7 +168,7 @@
</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" />
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifSn" />
</template>
</el-table-column>
<el-table-column
@ -180,7 +180,9 @@
/>
<el-table-column label="操作" align="center" min-width="120px">
<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']"
>
<el-button link type="primary"

View File

@ -24,9 +24,9 @@
<el-tree-select v-model="formData.productCategoryId" :data="productCategoryTree" :props="defaultProps"
check-strictly default-expand-all placeholder="请选择上级编号" />
</el-form-item>
<el-row>
<el-row v-if="productPropertiesCategory === 0">
<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-option v-for="dict in productCategoryPropertiesValueList" :key="dict.id"
:label="dict.productCategoryPropertiesValue" :value="dict.productCategoryPropertiesValue" />

View File

@ -58,8 +58,8 @@
<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="productCategoryValue" />
<el-table-column label="分类属性值" align="center" prop="productCategoryPropertiesValue" />
<el-table-column label="产品分类" align="center" prop="productCategoryValue" v-if="productPropertiesCategory===1"/>
<el-table-column label="分类属性值" align="center" prop="productCategoryPropertiesValue" v-if="productPropertiesCategory===0"/>
<el-table-column
label="创建时间"
align="center"
@ -99,7 +99,7 @@
</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>
<script setup lang="ts">
@ -107,7 +107,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { ProductCategoryPropertiesCategoryMapApi, ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap'
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() //
let searchCount = 0
@ -132,13 +132,18 @@ const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) //
/** 分类属性中文 */
let productPropertiesCn = ref('')
/** 产品属性分类 */
let productPropertiesCategory = ref()
/** 查询列表 */
const getList = async () => {
loading.value = true
if(route.query.searchId && searchCount == 0){
if(route.query.productCategoryPropertiesId && searchCount == 0){
searchCount++
queryParams.productCategoryPropertiesId = Number(route.query.searchId)
queryParams.productCategoryPropertiesId = Number(route.query.productCategoryPropertiesId)
}
if(route.query.productPropertiesCategory){
productPropertiesCategory.value = Number(route.query.productPropertiesCategory)
}
try {
const data = await ProductCategoryPropertiesCategoryMapApi.getProductCategoryPropertiesCategoryMapPage(queryParams)
@ -199,11 +204,11 @@ const handleExport = async () => {
/** 根据用户输入搜索类别 */
const searchProductCategoryProperties = async () => {
//id
if (!route.query.searchId) {
if (!route.query.productCategoryPropertiesId) {
return
}
try {
ProductCategoryPropertiesApi.getProductCategoryProperties(Number(route.query.searchId)).then(res => {
ProductCategoryPropertiesApi.getProductCategoryProperties(Number(route.query.productCategoryPropertiesId)).then(res => {
productPropertiesCn.value = res.productPropertiesCn
})
}catch (error) {

View File

@ -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>

View File

@ -98,8 +98,16 @@
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" width="110">
<el-table-column label="操作" align="center" width="160">
<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
link
type="primary"
@ -130,6 +138,10 @@
<!-- 表单弹窗添加/修改 -->
<ProductForm ref="formRef" @success="getList" />
<!-- 产品属性弹窗 -->
<ProductPropertiesForm ref="formPropertiesRef" @success="getList" />
</template>
<script setup lang="ts">
@ -141,6 +153,7 @@ import ProductForm from './ProductForm.vue'
import { DICT_TYPE } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import { erpPriceTableColumnFormatter } from '@/utils'
import ProductPropertiesForm from './ProductPropertiesForm.vue'
/** ERP 产品列表 */
defineOptions({ name: 'ErpProduct' })
@ -191,6 +204,12 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 产品属性 */
const formPropertiesRef = ref()
const openPropertiesForm = (id: number,productCategoryId: number) => {
formPropertiesRef.value.open(id,productCategoryId)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {

View File

@ -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) // 12
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>

View File

@ -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>