完善部分产品分类属性绑定的功能
parent
835055b4b2
commit
cbbd372216
|
|
@ -7,8 +7,8 @@ export interface ProductCategoryPropertiesVO {
|
|||
ifSingleProperty: boolean // 是否单数属性
|
||||
productPropertiesEn: string // 设备属性英文
|
||||
productPropertiesCn: string // 设备属性中文
|
||||
productPropertiesCategory: string // 设备属性分类
|
||||
ifRequired: boolean // 是否必填
|
||||
ifAttachment: boolean // 是否配件
|
||||
ifSn: boolean // 是否允许记录sn
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ const total = ref(0) // 列表的总页数
|
|||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
productCategoryId: null as number | null,
|
||||
productCategoryId: null as any,
|
||||
productFaultPart: undefined,
|
||||
productFault: undefined,
|
||||
createTime: [],
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ const total = ref(0) // 列表的总页数
|
|||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
productCategoryId: null as number | null,
|
||||
productCategoryId: null as any,
|
||||
productFaultPart: undefined,
|
||||
createTime: []
|
||||
})
|
||||
|
|
|
|||
|
|
@ -180,6 +180,12 @@
|
|||
/>
|
||||
<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"
|
||||
v-hasPermi="['erp:product-category-properties-category-map:query']"
|
||||
>
|
||||
<el-button link type="primary"
|
||||
>绑定</el-button>
|
||||
</router-link>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
|
|
@ -239,7 +245,7 @@ const total = ref(0) // 列表的总页数
|
|||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
productCategoryId: null as number | null,
|
||||
productCategoryId: null as any,
|
||||
ifSingleProperty: undefined,
|
||||
productPropertiesEn: undefined,
|
||||
productPropertiesCn: undefined,
|
||||
|
|
|
|||
|
|
@ -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) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
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>
|
||||
|
|
@ -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>
|
||||
Loading…
Reference in New Issue