完善部分产品分类属性绑定的功能

pull/744/head
没钱 2025-03-10 13:09:15 +08:00
parent 835055b4b2
commit cbbd372216
7 changed files with 433 additions and 4 deletions

View File

@ -7,8 +7,8 @@ export interface ProductCategoryPropertiesVO {
ifSingleProperty: boolean // 是否单数属性 ifSingleProperty: boolean // 是否单数属性
productPropertiesEn: string // 设备属性英文 productPropertiesEn: string // 设备属性英文
productPropertiesCn: string // 设备属性中文 productPropertiesCn: string // 设备属性中文
productPropertiesCategory: string // 设备属性分类
ifRequired: boolean // 是否必填 ifRequired: boolean // 是否必填
ifAttachment: boolean // 是否配件
ifSn: boolean // 是否允许记录sn ifSn: boolean // 是否允许记录sn
} }

View File

@ -0,0 +1,42 @@
import request from '@/config/axios'
// ERP 产品分类属性绑定 VO
export interface ProductCategoryPropertiesCategoryMapVO {
id: number // 编号
productCategoryPropertiesId: number // 类别属性
productCategoryId: number // 产品分类
productCategoryPropertiesValue: string // 类别属性值
}
// ERP 产品分类属性绑定 API
export const ProductCategoryPropertiesCategoryMapApi = {
// 查询ERP 产品分类属性绑定分页
getProductCategoryPropertiesCategoryMapPage: async (params: any) => {
return await request.get({ url: `/erp/product-category-properties-category-map/page`, params })
},
// 查询ERP 产品分类属性绑定详情
getProductCategoryPropertiesCategoryMap: async (id: number) => {
return await request.get({ url: `/erp/product-category-properties-category-map/get?id=` + id })
},
// 新增ERP 产品分类属性绑定
createProductCategoryPropertiesCategoryMap: async (data: ProductCategoryPropertiesCategoryMapVO) => {
return await request.post({ url: `/erp/product-category-properties-category-map/create`, data })
},
// 修改ERP 产品分类属性绑定
updateProductCategoryPropertiesCategoryMap: async (data: ProductCategoryPropertiesCategoryMapVO) => {
return await request.put({ url: `/erp/product-category-properties-category-map/update`, data })
},
// 删除ERP 产品分类属性绑定
deleteProductCategoryPropertiesCategoryMap: async (id: number) => {
return await request.delete({ url: `/erp/product-category-properties-category-map/delete?id=` + id })
},
// 导出ERP 产品分类属性绑定 Excel
exportProductCategoryPropertiesCategoryMap: async (params) => {
return await request.download({ url: `/erp/product-category-properties-category-map/export-excel`, params })
}
}

View File

@ -242,7 +242,7 @@ const total = ref(0) // 列表的总页数
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
productCategoryId: null as number | null, productCategoryId: null as any,
productFaultPart: undefined, productFaultPart: undefined,
productFault: undefined, productFault: undefined,
createTime: [], createTime: [],

View File

@ -155,7 +155,7 @@ const total = ref(0) // 列表的总页数
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
productCategoryId: null as number | null, productCategoryId: null as any,
productFaultPart: undefined, productFaultPart: undefined,
createTime: [] createTime: []
}) })

View File

@ -180,6 +180,12 @@
/> />
<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"
v-hasPermi="['erp:product-category-properties-category-map:query']"
>
<el-button link type="primary"
>绑定</el-button>
</router-link>
<el-button <el-button
link link
type="primary" type="primary"
@ -239,7 +245,7 @@ const total = ref(0) // 列表的总页数
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
productCategoryId: null as number | null, productCategoryId: null as any,
ifSingleProperty: undefined, ifSingleProperty: undefined,
productPropertiesEn: undefined, productPropertiesEn: undefined,
productPropertiesCn: undefined, productPropertiesCn: undefined,

View File

@ -0,0 +1,162 @@
<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="类别属性" prop="productCategoryPropertiesId"
v-show="false"
>
<el-input
v-model="formData.productCategoryPropertiesId"
placeholder="请输入类别属性"
clearable
/>
</el-form-item>
<el-form-item label="类别属性" prop="productPropertiesCn">
<el-input
v-model="formData.productPropertiesCn"
placeholder="请输入类别属性"
clearable
disabled
/>
</el-form-item>
<el-form-item label="产品分类" prop="productCategoryId" v-if="productPropertiesCategory===1">
<el-tree-select
v-model="formData.productCategoryId"
:data="productCategoryTree"
:props="defaultProps"
check-strictly
default-expand-all
placeholder="请选择上级编号"
/>
</el-form-item>
<el-form-item label="类别属性值" prop="productCategoryPropertiesValue" v-if="productPropertiesCategory===0">
<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 { ProductCategoryPropertiesCategoryMapApi, ProductCategoryPropertiesCategoryMapVO } from '@/api/erp/product/category/productcategoryproperties/propertiescategorymap'
import { ProductCategoryApi,ProductCategoryVO} from '@/api/erp/product/category'
import { defaultProps, handleTree } from '@/utils/tree'
import { ProductCategoryPropertiesApi,ProductCategoryPropertiesVO } from '@/api/erp/product/category/productcategoryproperties'
/** 产品属性类别 */
let productPropertiesCategory = ref()
/** 产品分类的list */
const productCategoryTree = ref() //
/** 从父组件取数据*/
const props = defineProps<{
productPropertiesCn: string,
productCategoryPropertiesId: number,
}>();
/** ERP 产品分类属性绑定 表单 */
defineOptions({ name: 'ProductCategoryPropertiesCategoryMapForm' })
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,
productPropertiesCn: null as any,
productCategoryId: undefined,
productCategoryPropertiesValue: undefined,
productCategoryPropertiesId: null as any
})
const formRules = reactive({
})
const formRef = ref() // Ref
/** 判断使用下拉还是使用自定义属性 */
const getProductPropertiesCategory = async () => {
ProductCategoryPropertiesApi.getProductCategoryProperties(props.productCategoryPropertiesId).then((res) => {
productPropertiesCategory.value = res.productPropertiesCategory
})
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
formData.value.productCategoryPropertiesId = props.productCategoryPropertiesId
formData.value.productPropertiesCn = props.productPropertiesCn
await getProductPropertiesCategory()
getAllProductCategory()
//
if (id) {
formLoading.value = true
try {
formData.value = await ProductCategoryPropertiesCategoryMapApi.getProductCategoryPropertiesCategoryMap(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
console.log(formData.value)
//
formLoading.value = true
try {
const data = formData.value as unknown as ProductCategoryPropertiesCategoryMapVO
if (formType.value === 'create') {
await ProductCategoryPropertiesCategoryMapApi.createProductCategoryPropertiesCategoryMap(data)
message.success(t('common.createSuccess'))
} else {
await ProductCategoryPropertiesCategoryMapApi.updateProductCategoryPropertiesCategoryMap(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
productPropertiesCn: null as any,
productCategoryId: undefined,
productCategoryPropertiesValue: undefined,
productCategoryPropertiesId: null as any
}
formRef.value?.resetFields()
}
/** 获取所有产品分类 */
const getAllProductCategory = async () => {
productCategoryTree.value = []
const data = await ProductCategoryApi.getProductCategoryList({})
const root: Tree = { id: 0, name: '顶级产品分类', children: [] }
root.children = handleTree(data, 'id', 'parentId')
productCategoryTree.value.push(root)
}
/** 通过分类属性查询分类属性的详情 */
</script>

View File

@ -0,0 +1,219 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="类别属性">
<el-input
v-model="productPropertiesCn"
placeholder="请输入类别属性"
clearable
disabled
@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-category-properties-category-map:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['erp:product-category-properties-category-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="产品分类" align="center" prop="productCategoryValue" />
<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-category-properties-category-map:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['erp:product-category-properties-category-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>
<!-- 表单弹窗添加/修改 -->
<ProductCategoryPropertiesCategoryMapForm ref="formRef" @success="getList" :product-properties-cn="productPropertiesCn" :product-category-properties-id="Number(route.query.searchId)"/>
</template>
<script setup lang="ts">
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'
const route = useRoute() //
let searchCount = 0
/** ERP 产品分类属性绑定 列表 */
defineOptions({ name: 'ErpProductCategoryPropertiesCategoryMap' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<ProductCategoryPropertiesCategoryMapVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
productCategoryPropertiesId: null as any,
productCategoryId: undefined,
productCategoryPropertiesValue: undefined,
createTime: []
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 类别属性中文 */
let productPropertiesCn = ref('')
/** 查询列表 */
const getList = async () => {
loading.value = true
if(route.query.searchId && searchCount == 0){
searchCount++
queryParams.productCategoryPropertiesId = Number(route.query.searchId)
}
try {
const data = await ProductCategoryPropertiesCategoryMapApi.getProductCategoryPropertiesCategoryMapPage(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 ProductCategoryPropertiesCategoryMapApi.deleteProductCategoryPropertiesCategoryMap(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ProductCategoryPropertiesCategoryMapApi.exportProductCategoryPropertiesCategoryMap(queryParams)
download.excel(data, 'ERP 产品分类属性绑定.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 根据用户输入搜索类别 */
const searchProductCategoryProperties = async () => {
//id
if (!route.query.searchId) {
return
}
try {
ProductCategoryPropertiesApi.getProductCategoryProperties(Number(route.query.searchId)).then(res => {
productPropertiesCn.value = res.productPropertiesCn
})
}catch (error) {
message.error('查询类别属性失败')
}
}
/** 初始化 **/
onMounted(() => {
getList()
searchProductCategoryProperties()
})
</script>