黄伟杰 2 months ago
commit d448a29dac

@ -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) // 12 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>

@ -1,7 +1,8 @@
<!-- ERP 产品列表 --> <!-- ERP 产品列表 -->
<template> <template>
<div class="dv-repair-page">
<template v-if="!formVisible">
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 -->
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="auto" @submit.prevent> <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="auto" @submit.prevent>
<el-form-item :label="t('FactoryModeling.ProductInformation.searchCodeLabel')" prop="barCode"> <el-form-item :label="t('FactoryModeling.ProductInformation.searchCodeLabel')" prop="barCode">
<el-input v-model="queryParams.barCode" <el-input v-model="queryParams.barCode"
@ -31,18 +32,9 @@
</el-form> </el-form>
</ContentWrap> </ContentWrap>
<!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-tabs v-model="activeName" @tab-click="handleTabClick"> <el-tabs v-model="activeName" @tab-click="handleTabClick">
<!-- 使用 v-for 动态生成 el-tab-pane -->
<el-tab-pane v-for="item in parentList" :key="item.id" :label="item.name" :name="item.id.toString()" /> <el-tab-pane v-for="item in parentList" :key="item.id" :label="item.name" :name="item.id.toString()" />
<!-- <el-tab-pane label="产品" name="2" />
<el-tab-pane label="原料" name="1" />
<el-tab-pane label="备件" name="5" />
<el-tab-pane label="工具" name="3" />
<el-tab-pane label="耗材" name="4" />
<el-tab-pane label="办公室用品" name="6" />
<el-tab-pane label="其他" name="0" /> -->
</el-tabs> </el-tabs>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column :label="t('FactoryModeling.ProductInformation.tableBarCodeColumn')" align="center" prop="barCode" <el-table-column :label="t('FactoryModeling.ProductInformation.tableBarCodeColumn')" align="center" prop="barCode"
@ -65,14 +57,6 @@
prop="createTime" :formatter="dateFormatter" width="180px" sortable /> prop="createTime" :formatter="dateFormatter" width="180px" sortable />
<el-table-column :label="t('FactoryModeling.ProductInformation.tableOperateColumn')" align="center" width="150px"> <el-table-column :label="t('FactoryModeling.ProductInformation.tableOperateColumn')" align="center" width="150px">
<template #default="scope"> <template #default="scope">
<!-- <el-button-->
<!-- v-if="scope.row.categoryId ===2"-->
<!-- link-->
<!-- type="primary"-->
<!-- @click="openBomForm('detail', scope.row.id)"-->
<!-- >-->
<!-- BOM-->
<!-- </el-button>-->
<el-button link type="primary" @click="openForm('update', scope.row.id)" v-hasPermi="['erp:product:update']"> <el-button link type="primary" @click="openForm('update', scope.row.id)" v-hasPermi="['erp:product:update']">
{{ t('FactoryModeling.ProductInformation.tableEditAction') }} {{ t('FactoryModeling.ProductInformation.tableEditAction') }}
</el-button> </el-button>
@ -82,16 +66,14 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页 -->
<Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize" <Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
@pagination="getList" /> @pagination="getList" />
</ContentWrap> </ContentWrap>
</template>
<!-- 表单弹窗添加/修改 --> <ProductForm v-else-if="formType === 'product'" ref="formRef" @success="getList" @closed="handleFormClosed" />
<ProductForm ref="formRef" @success="getList" /> <BomForm v-else-if="formType === 'bom'" ref="bomFormRef" @success="getList" @closed="handleFormClosed" />
<!-- 表单弹窗添加/修改 --> </div>
<BomForm ref="bomFormRef" @success="getList" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -107,12 +89,12 @@ import BomForm from "@/views/mes/bom/BomForm.vue";
/** ERP 产品列表 */ /** ERP 产品列表 */
defineOptions({ name: 'ErpProduct' }) defineOptions({ name: 'ErpProduct' })
const message = useMessage() // const message = useMessage()
const { t } = useI18n() // const { t } = useI18n()
const loading = ref(true) // const loading = ref(true)
const list = ref<ProductVO[]>([]) // const list = ref<ProductVO[]>([])
const total = ref(0) // const total = ref(0)
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
@ -120,12 +102,13 @@ const queryParams = reactive({
barCode: undefined, barCode: undefined,
categoryId: undefined categoryId: undefined
}) })
const queryFormRef = ref() // const queryFormRef = ref()
const exportLoading = ref(false) // const exportLoading = ref(false)
const categoryList = ref<ProductCategoryVO[]>([]) // const categoryList = ref<ProductCategoryVO[]>([])
const parentList = ref<ProductCategoryVO[]>([]) const parentList = ref<ProductCategoryVO[]>([])
const formVisible = ref(false)
const formType = ref('')
/** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
@ -137,43 +120,37 @@ const getList = async () => {
} }
} }
/** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.pageNo = 1 queryParams.pageNo = 1
getList() getList()
} }
/** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
handleQuery() handleQuery()
} }
/** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
formVisible.value = true
formType.value = 'product'
nextTick(() => {
formRef.value.open(type, id) formRef.value.open(type, id)
})
} }
/** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
//
await message.delConfirm() await message.delConfirm()
//
await ProductApi.deleteProduct(id) await ProductApi.deleteProduct(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
//
await getList() await getList()
} catch { } } catch { }
} }
/** 导出按钮操作 */
const handleExport = async () => { const handleExport = async () => {
try { try {
//
await message.exportConfirm() await message.exportConfirm()
//
exportLoading.value = true exportLoading.value = true
const data = await ProductApi.exportProduct(queryParams) const data = await ProductApi.exportProduct(queryParams)
download.excel(data, '产品.xls') download.excel(data, '产品.xls')
@ -183,33 +160,36 @@ const handleExport = async () => {
} }
} }
/** 初始化 **/
onMounted(async () => { onMounted(async () => {
queryParams.categoryId = 2 queryParams.categoryId = 2
await getList() await getList()
//
const categoryData = await ProductCategoryApi.getProductCategorySimpleList() const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
categoryList.value = handleTree(categoryData, 'id', 'parentId') categoryList.value = handleTree(categoryData, 'id', 'parentId')
//
for (let i = 0; i < categoryData.length; i++) { for (let i = 0; i < categoryData.length; i++) {
if (categoryData[i].parentId === 0) { if (categoryData[i].parentId === 0) {
parentList.value.push(categoryData[i]); parentList.value.push(categoryData[i]);
} }
} }
//
parentList.value.sort((a, b) => a.sort - b.sort); parentList.value.sort((a, b) => a.sort - b.sort);
}) })
/** tab 切换 */
let activeName = '2' let activeName = '2'
const handleTabClick = (tab: TabsPaneContext) => { const handleTabClick = (tab: TabsPaneContext) => {
queryParams.categoryId = tab.paneName queryParams.categoryId = tab.paneName
handleQuery() handleQuery()
} }
/** 添加/修改操作 */
const bomFormRef = ref() const bomFormRef = ref()
const openBomForm = (type: string, id?: number) => { const openBomForm = (type: string, id?: number) => {
formVisible.value = true
formType.value = 'bom'
nextTick(() => {
bomFormRef.value.open(type, id) bomFormRef.value.open(type, id)
})
}
const handleFormClosed = () => {
formVisible.value = false
formType.value = ''
} }
</script> </script>

@ -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) // 12 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>

@ -1,4 +1,6 @@
<template> <template>
<div class="dv-repair-page">
<template v-if="!formVisible">
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form <el-form
@ -147,9 +149,10 @@
@pagination="getList" @pagination="getList"
/> />
</ContentWrap> </ContentWrap>
</template>
<!-- 表单弹窗添加/修改 --> <BomForm v-else ref="formRef" @success="getList" @closed="formVisible = false" />
<BomForm ref="formRef" @success="getList" /> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -161,16 +164,16 @@ import BomForm from './BomForm.vue'
import BomDetailList from './components/BomDetailList.vue' import BomDetailList from './components/BomDetailList.vue'
import { ProductApi, ProductVO } from '@/api/erp/product/product' import { ProductApi, ProductVO } from '@/api/erp/product/product'
const productList = ref<ProductVO[]>([]) // const productList = ref<ProductVO[]>([])
/** 产品BOM 列表 */ /** 产品BOM 列表 */
defineOptions({ name: 'Bom' }) defineOptions({ name: 'Bom' })
const message = useMessage() // const message = useMessage()
const { t } = useI18n() // const { t } = useI18n()
const loading = ref(true) // const loading = ref(true)
const list = ref<BomVO[]>([]) // const list = ref<BomVO[]>([])
const total = ref(0) // const total = ref(0)
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
@ -183,10 +186,11 @@ const queryParams = reactive({
isEnable: undefined, isEnable: undefined,
createTime: [] createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref()
const exportLoading = ref(false) // const exportLoading = ref(false)
const showAllFilters = ref(false) // const showAllFilters = ref(false)
const filterCount = 4 // codeproductIdremarkisEnable const filterCount = 4
const formVisible = ref(false)
/** 切换筛选框展开/折叠 */ /** 切换筛选框展开/折叠 */
const toggleFilters = () => { const toggleFilters = () => {
@ -220,18 +224,18 @@ const resetQuery = () => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
formVisible.value = true
nextTick(() => {
formRef.value.open(type, id) formRef.value.open(type, id)
})
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
//
await message.delConfirm() await message.delConfirm()
//
await BomApi.deleteBom(id) await BomApi.deleteBom(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
//
await getList() await getList()
} catch {} } catch {}
} }
@ -239,9 +243,7 @@ const handleDelete = async (id: number) => {
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = async () => { const handleExport = async () => {
try { try {
//
await message.exportConfirm() await message.exportConfirm()
//
exportLoading.value = true exportLoading.value = true
const data = await BomApi.exportBom(queryParams) const data = await BomApi.exportBom(queryParams)
download.excel(data, '产品BOM.xls') download.excel(data, '产品BOM.xls')
@ -254,7 +256,6 @@ const handleExport = async () => {
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
await getList() await getList()
//
productList.value = await ProductApi.getMesProductSimpleList() productList.value = await ProductApi.getMesProductSimpleList()
}) })
</script> </script>

Loading…
Cancel
Save