|
|
|
@ -1,6 +1,13 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1200px" :close-on-click-modal="false">
|
|
|
|
<div class="dv-repair-panel">
|
|
|
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" v-loading="formLoading">
|
|
|
|
<div class="dv-repair-panel__header">
|
|
|
|
|
|
|
|
<div class="dv-repair-panel__title">{{ dialogTitle }}</div>
|
|
|
|
|
|
|
|
<el-button text @click="closeForm">
|
|
|
|
|
|
|
|
<Icon icon="ep:close" />
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="dv-repair-dialog" v-loading="formLoading">
|
|
|
|
|
|
|
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductBOM.dialogCodeLabel')" prop="code">
|
|
|
|
<el-form-item :label="t('FactoryModeling.ProductBOM.dialogCodeLabel')" prop="code">
|
|
|
|
<el-input v-model="formData.code" :placeholder="t('FactoryModeling.ProductBOM.dialogCodePlaceholder')"
|
|
|
|
<el-input v-model="formData.code" :placeholder="t('FactoryModeling.ProductBOM.dialogCodePlaceholder')"
|
|
|
|
:disabled="formType === 'update'" />
|
|
|
|
:disabled="formType === 'update'" />
|
|
|
|
@ -43,11 +50,13 @@
|
|
|
|
<BomDetailForm ref="bomDetailFormRef" :bom-id="formData.id" />
|
|
|
|
<BomDetailForm ref="bomDetailFormRef" :bom-id="formData.id" />
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
</el-tabs>
|
|
|
|
<template #footer>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="dv-repair-footer">
|
|
|
|
|
|
|
|
<el-button @click="closeForm">{{ t('common.cancel') }}</el-button>
|
|
|
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button>
|
|
|
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button>
|
|
|
|
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
|
import { getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
|
@ -56,19 +65,18 @@ import BomDetailForm from './components/BomDetailForm.vue'
|
|
|
|
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
|
|
|
|
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
|
|
|
|
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
|
|
|
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
|
|
|
|
|
|
|
|
|
|
|
const productList = ref<ProductVO[]>([]) // 产品列表
|
|
|
|
const productList = ref<ProductVO[]>([])
|
|
|
|
const unitList = ref<ProductUnitVO[]>([]) // 产品单位列表
|
|
|
|
const unitList = ref<ProductUnitVO[]>([])
|
|
|
|
|
|
|
|
|
|
|
|
/** 产品BOM 表单 */
|
|
|
|
/** 产品BOM 表单 */
|
|
|
|
defineOptions({ name: 'BomForm' })
|
|
|
|
defineOptions({ name: 'BomForm' })
|
|
|
|
|
|
|
|
|
|
|
|
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 formData = ref({
|
|
|
|
const formData = ref({
|
|
|
|
id: undefined,
|
|
|
|
id: undefined,
|
|
|
|
code: undefined,
|
|
|
|
code: undefined,
|
|
|
|
@ -86,19 +94,20 @@ const formRules = reactive({
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductBOM.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
unitId: [{ required: true, message: t('FactoryModeling.ProductBOM.validatorUnitRequired'), trigger: 'blur' }],
|
|
|
|
isEnable: [{ required: true, message: t('FactoryModeling.ProductBOM.validatorEnableRequired'), trigger: 'blur' }]
|
|
|
|
isEnable: [{ required: true, message: t('FactoryModeling.ProductBOM.validatorEnableRequired'), trigger: 'blur' }]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
|
const formRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
/** 子表的表单 */
|
|
|
|
/** 子表的表单 */
|
|
|
|
const subTabsName = ref('bomDetail')
|
|
|
|
const subTabsName = ref('bomDetail')
|
|
|
|
const bomDetailFormRef = ref()
|
|
|
|
const bomDetailFormRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
// 修改时,设置数据
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
if (id) {
|
|
|
|
formLoading.value = true
|
|
|
|
formLoading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -107,33 +116,35 @@ const open = async (type: string, id?: number) => {
|
|
|
|
formLoading.value = false
|
|
|
|
formLoading.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (type === 'detail') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 产品单位
|
|
|
|
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
// 加载产品、
|
|
|
|
|
|
|
|
productList.value = await ProductApi.getMesProductSimpleList()
|
|
|
|
productList.value = await ProductApi.getMesProductSimpleList()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['success', 'closed'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const closeForm = () => {
|
|
|
|
|
|
|
|
openRequestId++
|
|
|
|
|
|
|
|
emit('closed')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
|
|
openRequestId++
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
/** 提交表单 */
|
|
|
|
/** 提交表单 */
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
const submitForm = async () => {
|
|
|
|
// 校验表单
|
|
|
|
|
|
|
|
await formRef.value.validate()
|
|
|
|
await formRef.value.validate()
|
|
|
|
// 校验子表单
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await bomDetailFormRef.value.validate()
|
|
|
|
await bomDetailFormRef.value.validate()
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
subTabsName.value = 'bomDetail'
|
|
|
|
subTabsName.value = 'bomDetail'
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 提交请求
|
|
|
|
|
|
|
|
formLoading.value = true
|
|
|
|
formLoading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const data = formData.value as unknown as BomVO
|
|
|
|
const data = formData.value as unknown as BomVO
|
|
|
|
// 拼接子表的数据
|
|
|
|
|
|
|
|
data.bomDetails = bomDetailFormRef.value.getData()
|
|
|
|
data.bomDetails = bomDetailFormRef.value.getData()
|
|
|
|
if (formType.value === 'create') {
|
|
|
|
if (formType.value === 'create') {
|
|
|
|
await BomApi.createBom(data)
|
|
|
|
await BomApi.createBom(data)
|
|
|
|
@ -143,9 +154,8 @@ const submitForm = async () => {
|
|
|
|
await BomApi.updateBom(data)
|
|
|
|
await BomApi.updateBom(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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -166,3 +176,58 @@ const resetForm = () => {
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|