完善分类故障,属性部位的前端代码
parent
537c5ebfb7
commit
eb450b5c75
2
.env
2
.env
|
|
@ -1,5 +1,5 @@
|
|||
# 标题
|
||||
VITE_APP_TITLE=芋道管理系统
|
||||
VITE_APP_TITLE=CINO综合系统3.0
|
||||
|
||||
# 项目本地运行端口号
|
||||
VITE_PORT=80
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
name="keywords"
|
||||
content="芋道管理系统 基于 vue3 + CompositionAPI + typescript + vite3 + element plus 的后台开源免费管理系统!"
|
||||
content="CINO综合系统3.0 基于 vue3 + CompositionAPI + typescript + vite3 + element plus 的后台开源免费管理系统!"
|
||||
/>
|
||||
<meta
|
||||
name="description"
|
||||
content="芋道管理系统 基于 vue3 + CompositionAPI + typescript + vite3 + element plus 的后台开源免费管理系统!"
|
||||
content="CINO综合系统3.0 基于 vue3 + CompositionAPI + typescript + vite3 + element plus 的后台开源免费管理系统!"
|
||||
/>
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ export interface ProductCategoryVO {
|
|||
// ERP 产品分类 API
|
||||
export const ProductCategoryApi = {
|
||||
// 查询产品分类列表
|
||||
getProductCategoryList: async () => {
|
||||
return await request.get({ url: `/erp/product-category/list` })
|
||||
getProductCategoryList: async (params: any) => {
|
||||
return await request.get({ url: `/erp/product-category/list`, params })
|
||||
},
|
||||
|
||||
// 查询产品分类精简列表
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// ERP 产品分类部位 VO
|
||||
export interface ProductCategoryPartVO {
|
||||
id: number // 编号
|
||||
productCategoryId: number // 类别
|
||||
productFaultPart: string // 部位
|
||||
productFaultPartStr: string|undefined // 部位
|
||||
}
|
||||
|
||||
// ERP 产品分类部位 API
|
||||
export const ProductCategoryPartApi = {
|
||||
// 查询ERP 产品分类部位分页
|
||||
getProductCategoryPartPage: async (params: any) => {
|
||||
return await request.get({ url: `/erp/product-category-part/page`, params })
|
||||
},
|
||||
|
||||
// 查询ERP 产品分类部位详情
|
||||
getProductCategoryPart: async (id: number) => {
|
||||
return await request.get({ url: `/erp/product-category-part/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增ERP 产品分类部位
|
||||
createProductCategoryPart: async (data: ProductCategoryPartVO) => {
|
||||
return await request.post({ url: `/erp/product-category-part/create`, data })
|
||||
},
|
||||
|
||||
// 修改ERP 产品分类部位
|
||||
updateProductCategoryPart: async (data: ProductCategoryPartVO) => {
|
||||
return await request.put({ url: `/erp/product-category-part/update`, data })
|
||||
},
|
||||
|
||||
// 删除ERP 产品分类部位
|
||||
deleteProductCategoryPart: async (id: number) => {
|
||||
return await request.delete({ url: `/erp/product-category-part/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出ERP 产品分类部位 Excel
|
||||
exportProductCategoryPart: async (params) => {
|
||||
return await request.download({ url: `/erp/product-category-part/export-excel`, params })
|
||||
}
|
||||
}
|
||||
|
|
@ -216,6 +216,9 @@ export enum DICT_TYPE {
|
|||
// ========== ERP - 企业资源计划模块 ==========
|
||||
ERP_AUDIT_STATUS = 'erp_audit_status', // ERP 审批状态
|
||||
ERP_STOCK_RECORD_BIZ_TYPE = 'erp_stock_record_biz_type', // 库存明细的业务类型
|
||||
ERP_PRODUCT_FAULT_PART = 'erp_product_fault_part', // 产品的故障部位
|
||||
ERP_FILE_ORDER_TYPE = 'erp_file_order_type', // 文件单据类型
|
||||
ERP_ORDER_PRE_STATUS = 'erp_order_pre_status', // 订单预报价单状态
|
||||
|
||||
// ========== AI - 人工智能模块 ==========
|
||||
AI_PLATFORM = 'ai_platform', // AI 平台
|
||||
|
|
|
|||
|
|
@ -7,13 +7,16 @@
|
|||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="类别id" prop="productCategoryId">
|
||||
<el-input v-model="formData.productCategoryId" type="textarea" placeholder="请输入类别id" />
|
||||
<el-form-item label="类别" prop="productCategoryId">
|
||||
<!-- 普通显示 -->
|
||||
<el-select v-model="formData.productCategoryId" placeholder="请选择类别" @change="limitFaultPart" filterable clearable>
|
||||
<el-option v-for="item in productCategoryList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="故障部位" prop="productFaultPart">
|
||||
<el-select v-model="formData.productFaultPart" placeholder="请选择故障部位">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.ERP_PRODUCT_FAULT_PART)"
|
||||
v-for="dict in dictfaultPartListSelect"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
|
|
@ -25,7 +28,12 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="影响销售" prop="ifAffectSale">
|
||||
<el-radio-group v-model="formData.ifAffectSale">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
<el-radio
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="影响销售%" prop="affectSalePercentage">
|
||||
|
|
@ -36,7 +44,12 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="影响回收" prop="ifAffectRecycle">
|
||||
<el-radio-group v-model="formData.ifAffectRecycle">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
<el-radio
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="影响回收%" prop="affectRecyclePercentage">
|
||||
|
|
@ -53,8 +66,24 @@
|
|||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue';
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { ProductCategoryFaultApi, ProductCategoryFaultVO } from '@/api/erp/product/category/erpproductcategoryfault'
|
||||
import { ProductCategoryVO } from '@/api/erp/product/category'
|
||||
import { ProductCategoryPartApi, ProductCategoryPartVO} from '@/api/erp/product/category/productcategorypart'
|
||||
|
||||
/** 从父组件取productCategoryList数组*/
|
||||
defineProps<{
|
||||
productCategoryList: ProductCategoryVO[]
|
||||
}
|
||||
>();
|
||||
|
||||
/** 定义一个类型部位数组 */
|
||||
const productCategoryPartList = ref<ProductCategoryPartVO[]>([])
|
||||
|
||||
/** 定义一个字典类型的故障部位数组 */
|
||||
let dictfaultPartList = ref<{ value: string, label: string }[]>([])
|
||||
let dictfaultPartListSelect = ref<{ value: string, label: string }[]>([])
|
||||
|
||||
/** ERP 产品分类故障 表单 */
|
||||
defineOptions({ name: 'ProductCategoryFaultForm' })
|
||||
|
|
@ -79,7 +108,7 @@ const formData = ref({
|
|||
affectRecycleMoney: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
productCategoryId: [{ required: true, message: '类别id不能为空', trigger: 'blur' }],
|
||||
productCategoryId: [{ required: true, message: '类别不能为空', trigger: 'blur' }],
|
||||
productFaultPart: [{ required: true, message: '故障部位不能为空', trigger: 'change' }],
|
||||
productFault: [{ required: true, message: '具体故障不能为空', trigger: 'blur' }]
|
||||
})
|
||||
|
|
@ -94,8 +123,15 @@ const open = async (type: string, id?: number) => {
|
|||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
|
||||
try {
|
||||
formData.value = await ProductCategoryFaultApi.getProductCategoryFault(id)
|
||||
const data = await ProductCategoryFaultApi.getProductCategoryFault(id)
|
||||
formData.value = {
|
||||
...data,
|
||||
ifAffectRecycle: data.ifAffectRecycle ? 'true' : 'false' ,// 转换为字典对应的值
|
||||
ifAffectSale: data.ifAffectSale? 'true' : 'false' // 转换为字典对应的值
|
||||
|
||||
}
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
|
|
@ -143,4 +179,26 @@ const resetForm = () => {
|
|||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
/** 获取现在的类别id,通过类别id查询类别部位数组 */
|
||||
const limitFaultPart = (productCategoryId: number) => {
|
||||
if (productCategoryId) {
|
||||
// 清空故障部位
|
||||
formData.value.productFaultPart = undefined
|
||||
ProductCategoryPartApi.getProductCategoryPartPage({ productCategoryId })
|
||||
.then(res => {
|
||||
productCategoryPartList.value = res.list
|
||||
//拿到所有的故障部位,然后在表单中显示
|
||||
const faultPartList = productCategoryPartList.value.map(item => item.productFaultPart)
|
||||
// 过滤出faultPartList中没有的dictfaultPartList
|
||||
dictfaultPartListSelect.value = dictfaultPartList.value.filter(item => faultPartList.includes(item.value))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建页面 */
|
||||
onMounted(() => {
|
||||
dictfaultPartList.value = getStrDictOptions(DICT_TYPE.ERP_PRODUCT_FAULT_PART)
|
||||
dictfaultPartListSelect.value = dictfaultPartList.value
|
||||
})
|
||||
</script>
|
||||
|
|
@ -8,6 +8,21 @@
|
|||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="类别" prop="productCategoryId">
|
||||
<el-select
|
||||
v-model="queryParams.productCategoryId"
|
||||
placeholder="请选择故障部位"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in productCategoryList"
|
||||
:key="dict.id"
|
||||
:label="dict.name"
|
||||
:value="dict.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="故障部位" prop="productFaultPart">
|
||||
<el-select
|
||||
v-model="queryParams.productFaultPart"
|
||||
|
|
@ -50,7 +65,12 @@
|
|||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="影响销售%" prop="affectSalePercentage">
|
||||
|
|
@ -78,7 +98,12 @@
|
|||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="影响回收%" prop="affectRecyclePercentage">
|
||||
|
|
@ -126,8 +151,12 @@
|
|||
<!-- 列表 -->
|
||||
<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="productCategoryId" />
|
||||
<el-table-column label="编号" align="center" prop="id" />
|
||||
<el-table-column label="类别" align="center" prop="productCategoryId">
|
||||
<template #default="scope">
|
||||
{{ getCategoryName(scope.row.productCategoryId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="故障部位" align="center" prop="productFaultPart">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.ERP_PRODUCT_FAULT_PART" :value="scope.row.productFaultPart" />
|
||||
|
|
@ -141,10 +170,18 @@
|
|||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="影响销售" align="center" prop="ifAffectSale" />
|
||||
<el-table-column label="影响销售" align="center" prop="ifAffectSale" >
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifAffectSale" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="影响销售%" align="center" prop="affectSalePercentage" />
|
||||
<el-table-column label="影响销售金额" align="center" prop="affectSaleMoney" />
|
||||
<el-table-column label="影响回收" align="center" prop="ifAffectRecycle" />
|
||||
<el-table-column label="影响回收" align="center" prop="ifAffectRecycle" >
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.ifAffectRecycle" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="影响回收%" align="center" prop="affectRecyclePercentage" />
|
||||
<el-table-column label="影响回收金额" align="center" prop="affectRecycleMoney" />
|
||||
<el-table-column label="操作" align="center" min-width="120px">
|
||||
|
|
@ -178,7 +215,7 @@
|
|||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ProductCategoryFaultForm ref="formRef" @success="getList" />
|
||||
<ProductCategoryFaultForm ref="formRef" @success="getList" :product-category-list="productCategoryList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
@ -187,6 +224,10 @@ import { dateFormatter } from '@/utils/formatTime'
|
|||
import download from '@/utils/download'
|
||||
import { ProductCategoryFaultApi, ProductCategoryFaultVO } from '@/api/erp/product/category/erpproductcategoryfault'
|
||||
import ProductCategoryFaultForm from './ProductCategoryFaultForm.vue'
|
||||
import { ProductCategoryApi , ProductCategoryVO } from '@/api/erp/product/category'
|
||||
|
||||
/** ERP 产品分类的数组 */
|
||||
const productCategoryList = ref<ProductCategoryVO[]>([])
|
||||
|
||||
/** ERP 产品分类故障 列表 */
|
||||
defineOptions({ name: 'ErpProductCategoryFault' })
|
||||
|
|
@ -272,8 +313,30 @@ const handleExport = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
/** 根据用户输入搜索类别 */
|
||||
const searchProductCategory = async () => {
|
||||
//构建param对象
|
||||
const params = {
|
||||
status: 0
|
||||
}
|
||||
try {
|
||||
productCategoryList.value = await ProductCategoryApi.getProductCategoryList(params)
|
||||
} catch (error) {
|
||||
productCategoryList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据 productCategoryId 获取类别名称 */
|
||||
const getCategoryName = (id: number | undefined) => {
|
||||
if (!id) return ''
|
||||
const category = productCategoryList.value.find(item => item.id === id)
|
||||
return category ? category.name : '' // 假设类别名称字段为 name
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
searchProductCategory()
|
||||
|
||||
})
|
||||
</script>
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
<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="productCategoryId">
|
||||
<el-select v-model="formData.productCategoryId" placeholder="请选择类别" filterable clearable>
|
||||
<el-option
|
||||
v-for="item in productCategoryList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="部位" prop="productFaultPart">
|
||||
<el-select v-model="formData.productFaultPart" placeholder="请选择部位">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.ERP_PRODUCT_FAULT_PART)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</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 { defineProps } from 'vue';
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { ProductCategoryApi , ProductCategoryVO } from '@/api/erp/product/category'
|
||||
import { ProductCategoryPartApi, ProductCategoryPartVO } from '@/api/erp/product/category/productcategorypart'
|
||||
|
||||
/** 从父组件取productCategoryList数组*/
|
||||
defineProps<{
|
||||
productCategoryList: ProductCategoryVO[]
|
||||
}
|
||||
>();
|
||||
|
||||
/** ERP 产品分类部位 表单 */
|
||||
defineOptions({ name: 'ProductCategoryPartForm' })
|
||||
|
||||
|
||||
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,
|
||||
productCategoryId: undefined,
|
||||
productFaultPart: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
productCategoryId: [{ required: true, message: '类别不能为空', trigger: 'change' }],
|
||||
productFaultPart: [{ required: true, message: '部位不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await ProductCategoryPartApi.getProductCategoryPart(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 ProductCategoryPartVO
|
||||
if (formType.value === 'create') {
|
||||
await ProductCategoryPartApi.createProductCategoryPart(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await ProductCategoryPartApi.updateProductCategoryPart(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
productCategoryId: undefined,
|
||||
productFaultPart: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,243 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="类别" prop="productCategoryId">
|
||||
<el-select
|
||||
v-model="queryParams.productCategoryId"
|
||||
placeholder="请选择类别"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productCategoryList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="部位" prop="productFaultPart">
|
||||
<el-select
|
||||
v-model="queryParams.productFaultPart"
|
||||
placeholder="请选择部位"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.ERP_PRODUCT_FAULT_PART)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</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-part:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['erp:product-category-part: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="productCategoryId">
|
||||
<template #default="scope">
|
||||
{{ getCategoryName(scope.row.productCategoryId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="部位" align="center" prop="productFaultPart">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.ERP_PRODUCT_FAULT_PART" :value="scope.row.productFaultPart" />
|
||||
</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">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['erp:product-category-part:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['erp:product-category-part: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>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ProductCategoryPartForm ref="formRef" @success="getList" :product-category-list="productCategoryList"/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { ProductCategoryPartApi, ProductCategoryPartVO } from '@/api/erp/product/category/productcategorypart'
|
||||
import ProductCategoryPartForm from './ProductCategoryPartForm.vue'
|
||||
import { ProductCategoryApi , ProductCategoryVO } from '@/api/erp/product/category'
|
||||
/** ERP 产品分类的数组 */
|
||||
const productCategoryList = ref<ProductCategoryVO[]>([])
|
||||
|
||||
/** ERP 产品分类部位 列表 */
|
||||
defineOptions({ name: 'ErpProductCategoryPart' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<ProductCategoryPartVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
productCategoryId: undefined,
|
||||
productFaultPart: undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await ProductCategoryPartApi.getProductCategoryPartPage(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 ProductCategoryPartApi.deleteProductCategoryPart(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await ProductCategoryPartApi.exportProductCategoryPart(queryParams)
|
||||
download.excel(data, 'ERP 产品分类部位.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据用户输入搜索类别 */
|
||||
const searchProductCategory = async () => {
|
||||
//构建param对象
|
||||
const params = {
|
||||
status: 0
|
||||
}
|
||||
try {
|
||||
productCategoryList.value = await ProductCategoryApi.getProductCategoryList(params)
|
||||
} catch (error) {
|
||||
productCategoryList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据 productCategoryId 获取类别名称 */
|
||||
const getCategoryName = (id: number | undefined) => {
|
||||
if (!id) return ''
|
||||
const category = productCategoryList.value.find(item => item.id === id)
|
||||
return category ? category.name : '' // 假设类别名称字段为 name
|
||||
}
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
searchProductCategory()
|
||||
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue