|
|
|
@ -1,13 +1,13 @@
|
|
|
|
<!-- ERP 产品的新增/修改 -->
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
|
|
|
<div class="dv-repair-panel">
|
|
|
|
<el-form
|
|
|
|
<div class="dv-repair-panel__header">
|
|
|
|
ref="formRef"
|
|
|
|
<div class="dv-repair-panel__title">{{ dialogTitle }}</div>
|
|
|
|
:model="formData"
|
|
|
|
<el-button text @click="closeForm">
|
|
|
|
:rules="formRules"
|
|
|
|
<Icon icon="ep:close" />
|
|
|
|
label-width="120px"
|
|
|
|
</el-button>
|
|
|
|
v-loading="formLoading"
|
|
|
|
</div>
|
|
|
|
>
|
|
|
|
<div class="dv-repair-dialog" v-loading="formLoading">
|
|
|
|
|
|
|
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px">
|
|
|
|
<el-row :gutter="20">
|
|
|
|
<el-row :gutter="20">
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogBarCodeLabel')" prop="barCode">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogBarCodeLabel')" prop="barCode">
|
|
|
|
@ -77,49 +77,6 @@
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
<!-- <el-col :span="12">
|
|
|
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogWeightLabel')" prop="weight">
|
|
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
|
|
v-model="formData.weight"
|
|
|
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogWeightPlaceholder')"
|
|
|
|
|
|
|
|
:min="0"
|
|
|
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col> -->
|
|
|
|
|
|
|
|
<!-- <el-col :span="12">
|
|
|
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogPurchasePriceLabel')" prop="purchasePrice">
|
|
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
|
|
v-model="formData.purchasePrice"
|
|
|
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogPurchasePricePlaceholder')"
|
|
|
|
|
|
|
|
:min="0"
|
|
|
|
|
|
|
|
:precision="2"
|
|
|
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogSalePriceLabel')" prop="salePrice">
|
|
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
|
|
v-model="formData.salePrice"
|
|
|
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogSalePricePlaceholder')"
|
|
|
|
|
|
|
|
:min="0"
|
|
|
|
|
|
|
|
:precision="2"
|
|
|
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductInformation.dialogMinPriceLabel')" prop="minPrice">
|
|
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
|
|
v-model="formData.minPrice"
|
|
|
|
|
|
|
|
:placeholder="t('FactoryModeling.ProductInformation.dialogMinPricePlaceholder')"
|
|
|
|
|
|
|
|
:min="0"
|
|
|
|
|
|
|
|
:precision="2"
|
|
|
|
|
|
|
|
class="!w-1/1"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-col> -->
|
|
|
|
|
|
|
|
<el-col v-if="isProductCategory" :span="12">
|
|
|
|
<el-col v-if="isProductCategory" :span="12">
|
|
|
|
<el-form-item label="关联设备" prop="devices">
|
|
|
|
<el-form-item label="关联设备" prop="devices">
|
|
|
|
<el-input
|
|
|
|
<el-input
|
|
|
|
@ -177,11 +134,15 @@
|
|
|
|
</el-col>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</el-row>
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
<template #footer>
|
|
|
|
</div>
|
|
|
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button>
|
|
|
|
|
|
|
|
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
<div class="dv-repair-footer">
|
|
|
|
</template>
|
|
|
|
<el-button @click="closeForm">{{ t('common.cancel') }}</el-button>
|
|
|
|
</Dialog>
|
|
|
|
<el-button v-if="formType !== 'detail'" @click="submitForm" type="primary" :disabled="formLoading">
|
|
|
|
|
|
|
|
{{ t('common.ok') }}
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<TableSelectDialog
|
|
|
|
<TableSelectDialog
|
|
|
|
ref="deviceSelectDialogRef"
|
|
|
|
ref="deviceSelectDialogRef"
|
|
|
|
title="选择设备"
|
|
|
|
title="选择设备"
|
|
|
|
@ -191,7 +152,6 @@
|
|
|
|
@confirm="handleDeviceSelectConfirm"
|
|
|
|
@confirm="handleDeviceSelectConfirm"
|
|
|
|
:query-params="mergedQueryParams"
|
|
|
|
:query-params="mergedQueryParams"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<!-- 使用 header 插槽插入查询表单 -->
|
|
|
|
|
|
|
|
<template #header>
|
|
|
|
<template #header>
|
|
|
|
<el-form ref="searchFormRef" :model="searchParams" :inline="true">
|
|
|
|
<el-form ref="searchFormRef" :model="searchParams" :inline="true">
|
|
|
|
<el-form-item label="设备编号" prop="deviceCode">
|
|
|
|
<el-form-item label="设备编号" prop="deviceCode">
|
|
|
|
@ -216,7 +176,6 @@
|
|
|
|
@confirm="handleMoldSelectConfirm"
|
|
|
|
@confirm="handleMoldSelectConfirm"
|
|
|
|
:query-params="mergedMoldQueryParams"
|
|
|
|
:query-params="mergedMoldQueryParams"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<!-- 使用 header 插槽插入查询表单 -->
|
|
|
|
|
|
|
|
<template #header>
|
|
|
|
<template #header>
|
|
|
|
<el-form ref="searchMoldFormRef" :model="searchMoldParams" :inline="true">
|
|
|
|
<el-form ref="searchMoldFormRef" :model="searchMoldParams" :inline="true">
|
|
|
|
<el-form-item label="模具编号" prop="code">
|
|
|
|
<el-form-item label="模具编号" prop="code">
|
|
|
|
@ -248,24 +207,21 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
|
/** ERP 产品 表单 */
|
|
|
|
/** ERP 产品 表单 */
|
|
|
|
defineOptions({ name: 'ProductForm' })
|
|
|
|
defineOptions({ name: 'ProductForm' })
|
|
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const { t } = useI18n()
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
const message = useMessage()
|
|
|
|
|
|
|
|
|
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
|
const dialogTitle = ref('')
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
const formLoading = ref(false)
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
const formType = ref('')
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
|
|
|
|
const deviceSelectDialogRef = ref()
|
|
|
|
const deviceSelectDialogRef = ref()
|
|
|
|
const moldSelectDialogRef = ref()
|
|
|
|
const moldSelectDialogRef = ref()
|
|
|
|
const searchFormRef = ref()
|
|
|
|
const searchFormRef = ref()
|
|
|
|
// 1. 自定义表单的查询参数
|
|
|
|
|
|
|
|
const searchParams = reactive({
|
|
|
|
const searchParams = reactive({
|
|
|
|
deviceCode: undefined,
|
|
|
|
deviceCode: undefined,
|
|
|
|
deviceName: undefined,
|
|
|
|
deviceName: undefined,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
const handleSearch = () => {
|
|
|
|
// 触发弹窗内部重新加载数据
|
|
|
|
|
|
|
|
deviceSelectDialogRef.value?.reload?.()
|
|
|
|
deviceSelectDialogRef.value?.reload?.()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -274,23 +230,20 @@ const resetSearch = () => {
|
|
|
|
handleSearch()
|
|
|
|
handleSearch()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 自定义表单的查询参数
|
|
|
|
|
|
|
|
const searchMoldParams = reactive({
|
|
|
|
const searchMoldParams = reactive({
|
|
|
|
code: undefined,
|
|
|
|
code: undefined,
|
|
|
|
name: undefined,
|
|
|
|
name: undefined,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const searchMoldFormRef = ref()
|
|
|
|
const searchMoldFormRef = ref()
|
|
|
|
const handleMoldSearch = () => {
|
|
|
|
const handleMoldSearch = () => {
|
|
|
|
// 触发弹窗内部重新加载数据
|
|
|
|
|
|
|
|
moldSelectDialogRef.value?.reload?.()
|
|
|
|
moldSelectDialogRef.value?.reload?.()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const resetMoldSearch = () => {
|
|
|
|
const resetMoldSearch = () => {
|
|
|
|
searchMoldFormRef.value?.resetFields()
|
|
|
|
searchMoldFormRef.value?.resetFields()
|
|
|
|
handleSearch()
|
|
|
|
handleMoldSearch()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 合并参数:将表单参数与组件内部的分页参数合并
|
|
|
|
|
|
|
|
const mergedQueryParams = computed(() => ({ ...searchParams }))
|
|
|
|
const mergedQueryParams = computed(() => ({ ...searchParams }))
|
|
|
|
const mergedMoldQueryParams = computed(() => ({ ...searchMoldParams }))
|
|
|
|
const mergedMoldQueryParams = computed(() => ({ ...searchMoldParams }))
|
|
|
|
const formData = ref({
|
|
|
|
const formData = ref({
|
|
|
|
@ -485,20 +438,20 @@ const formRules = reactive({
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
status: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorStatusRequired'), trigger: 'blur' }]
|
|
|
|
status: [{ required: true, message: t('FactoryModeling.ProductInformation.validatorStatusRequired'), trigger: 'blur' }]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
|
const formRef = ref()
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([]) // 产品分类列表
|
|
|
|
const categoryList = ref<ProductCategoryVO[]>([])
|
|
|
|
const unitList = ref<ProductUnitVO[]>([]) // 产品单位列表
|
|
|
|
const unitList = ref<ProductUnitVO[]>([])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let openRequestId = 0
|
|
|
|
|
|
|
|
|
|
|
|
/** 打开弹窗 */
|
|
|
|
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
dialogVisible.value = true
|
|
|
|
const currentOpenId = ++openRequestId
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
formType.value = type
|
|
|
|
formType.value = type
|
|
|
|
resetForm()
|
|
|
|
resetForm()
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
|
|
|
|
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
categoryList.value = handleTree(categoryData, 'id', 'parentId')
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
// 修改时,设置数据
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
if (id) {
|
|
|
|
formLoading.value = true
|
|
|
|
formLoading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -533,7 +486,19 @@ const open = async (type: string, id?: number) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['success', 'closed'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const closeForm = () => {
|
|
|
|
|
|
|
|
openRequestId++
|
|
|
|
|
|
|
|
emit('closed')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
|
|
openRequestId++
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const handleCodeAutoChange = (value: boolean) => {
|
|
|
|
const handleCodeAutoChange = (value: boolean) => {
|
|
|
|
if (value) {
|
|
|
|
if (value) {
|
|
|
|
@ -573,12 +538,8 @@ const buildRelationIdListString = (list: { id: number; name: string }[]) => {
|
|
|
|
return list.map((item) => Number(item.id)).filter((id) => Number.isFinite(id))
|
|
|
|
return list.map((item) => Number(item.id)).filter((id) => Number.isFinite(id))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 提交表单 */
|
|
|
|
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
const submitForm = async () => {
|
|
|
|
// 校验表单
|
|
|
|
|
|
|
|
await formRef.value.validate()
|
|
|
|
await formRef.value.validate()
|
|
|
|
// 提交请求
|
|
|
|
|
|
|
|
formLoading.value = true
|
|
|
|
formLoading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const relationDevices = isProductCategory.value ? formData.value.devices : []
|
|
|
|
const relationDevices = isProductCategory.value ? formData.value.devices : []
|
|
|
|
@ -597,15 +558,13 @@ const submitForm = async () => {
|
|
|
|
await ProductApi.updateProduct(data)
|
|
|
|
await ProductApi.updateProduct(data)
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
|
|
// 发送操作成功的事件
|
|
|
|
|
|
|
|
emit('success')
|
|
|
|
emit('success')
|
|
|
|
|
|
|
|
closeForm()
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
formLoading.value = false
|
|
|
|
formLoading.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 重置表单 */
|
|
|
|
|
|
|
|
const resetForm = () => {
|
|
|
|
const resetForm = () => {
|
|
|
|
formData.value = {
|
|
|
|
formData.value = {
|
|
|
|
id: undefined,
|
|
|
|
id: undefined,
|
|
|
|
@ -643,4 +602,58 @@ watch(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
<style scoped lang="scss"></style>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
.dv-repair-panel {
|
|
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
|
|
box-shadow: var(--el-box-shadow-light);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dv-repair-panel__header {
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dv-repair-panel__title {
|
|
|
|
|
|
|
|
color: #1f2937;
|
|
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dv-repair-dialog {
|
|
|
|
|
|
|
|
max-height: calc(100vh - 220px);
|
|
|
|
|
|
|
|
padding: 20px 20px 0;
|
|
|
|
|
|
|
|
padding-right: 16px;
|
|
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dv-repair-footer {
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
padding: 16px 20px 20px;
|
|
|
|
|
|
|
|
border-top: 1px solid #ebeef5;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
|
|
|
.dv-repair-panel__header {
|
|
|
|
|
|
|
|
padding: 14px 16px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dv-repair-dialog {
|
|
|
|
|
|
|
|
max-height: none;
|
|
|
|
|
|
|
|
padding: 16px 16px 0;
|
|
|
|
|
|
|
|
overflow-y: visible;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dv-repair-footer {
|
|
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|