|
|
|
|
@ -71,6 +71,25 @@
|
|
|
|
|
:label="unit.name"
|
|
|
|
|
:value="unit.id"
|
|
|
|
|
/>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div v-if="!isAddingUnit" class="px-10px py-6px">
|
|
|
|
|
<el-button text bg size="small" @click.stop="onAddUnit('unit')">
|
|
|
|
|
+ 新增单位
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="px-10px py-6px">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="unitInputName"
|
|
|
|
|
size="small"
|
|
|
|
|
placeholder="请输入单位名称"
|
|
|
|
|
class="mb-6px"
|
|
|
|
|
/>
|
|
|
|
|
<div class="flex gap-6px">
|
|
|
|
|
<el-button type="primary" size="small" @click.stop="onConfirmAddUnit('unit')">确定</el-button>
|
|
|
|
|
<el-button size="small" @click.stop="clearAddUnit()">取消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
@ -83,6 +102,25 @@
|
|
|
|
|
:label="unit.name"
|
|
|
|
|
:value="unit.id"
|
|
|
|
|
/>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div v-if="!isAddingPurchaseUnit" class="px-10px py-6px">
|
|
|
|
|
<el-button text bg size="small" @click.stop="onAddUnit('purchaseUnit')">
|
|
|
|
|
+ 新增单位
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="px-10px py-6px">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="unitInputName"
|
|
|
|
|
size="small"
|
|
|
|
|
placeholder="请输入单位名称"
|
|
|
|
|
class="mb-6px"
|
|
|
|
|
/>
|
|
|
|
|
<div class="flex gap-6px">
|
|
|
|
|
<el-button type="primary" size="small" @click.stop="onConfirmAddUnit('purchaseUnit')">确定</el-button>
|
|
|
|
|
<el-button size="small" @click.stop="clearAddUnit()">取消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
@ -298,6 +336,7 @@
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" @click="handlePackagingSchemeSearch">{{ t('FactoryModeling.ProductInformation.searchButtonText') }}</el-button>
|
|
|
|
|
<el-button @click="resetPackagingSchemeSearch">{{ t('FactoryModeling.ProductInformation.resetButtonText') }}</el-button>
|
|
|
|
|
<el-button type="primary" plain @click="openPackagingSchemeAdd">{{ t('action.create') }}</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<el-table
|
|
|
|
|
@ -392,6 +431,7 @@
|
|
|
|
|
<el-button @click="supplierDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
<PackagingSolutionForm ref="packagingSolutionFormRef" @success="handlePackagingSchemeSuccess" />
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
|
|
|
|
@ -402,6 +442,7 @@ import TableSelectDialog from '@/components/TableSelectDialog/TableSelectDialog.
|
|
|
|
|
import { DeviceLedgerApi } from '@/api/mes/deviceledger'
|
|
|
|
|
import { MoldBrandApi } from '@/api/erp/mold'
|
|
|
|
|
import { PackagingSchemeApi } from '@/api/erp/stock/packagingScheme'
|
|
|
|
|
import PackagingSolutionForm from '@/views/erp/stock/packagingSolution/PackagingSolutionForm.vue'
|
|
|
|
|
import { SupplierApi } from '@/api/erp/purchase/supplier'
|
|
|
|
|
import { CommonStatusEnum } from '@/utils/constants'
|
|
|
|
|
import { defaultProps, handleTree } from '@/utils/tree'
|
|
|
|
|
@ -805,6 +846,19 @@ const resetPackagingSchemeSearch = () => {
|
|
|
|
|
searchPackagingSchemeFormRef.value?.resetFields()
|
|
|
|
|
handlePackagingSchemeSearch()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const packagingSolutionFormRef = ref()
|
|
|
|
|
const openPackagingSchemeAdd = () => {
|
|
|
|
|
packagingSolutionFormRef.value?.open('create')
|
|
|
|
|
}
|
|
|
|
|
const handlePackagingSchemeSuccess = () => {
|
|
|
|
|
// 新增成功后刷新包装方案弹框列表和缓存
|
|
|
|
|
getPackagingSchemeDialogList()
|
|
|
|
|
PackagingSchemeApi.getPackagingSchemePage({ pageNo: 1, pageSize: 100, status: 0 }).then((data) => {
|
|
|
|
|
packagingSchemeList.value = data.list || []
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 供应商弹框相关
|
|
|
|
|
const supplierDialogVisible = ref(false)
|
|
|
|
|
const supplierDialogLoading = ref(false)
|
|
|
|
|
@ -1045,6 +1099,56 @@ const handlePurchaseUnitChange = (val: any) => {
|
|
|
|
|
formData.value.purchaseUnitName = unit?.name ?? undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isAddingUnit = ref(false)
|
|
|
|
|
const isAddingPurchaseUnit = ref(false)
|
|
|
|
|
const unitInputName = ref('')
|
|
|
|
|
|
|
|
|
|
const onAddUnit = (type: 'unit' | 'purchaseUnit') => {
|
|
|
|
|
if (type === 'unit') {
|
|
|
|
|
isAddingUnit.value = true
|
|
|
|
|
} else {
|
|
|
|
|
isAddingPurchaseUnit.value = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onConfirmAddUnit = async (type: 'unit' | 'purchaseUnit') => {
|
|
|
|
|
if (!unitInputName.value.trim()) {
|
|
|
|
|
message.warning('请输入单位名称')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
await ProductUnitApi.createProductUnit({
|
|
|
|
|
name: unitInputName.value.trim(),
|
|
|
|
|
status: CommonStatusEnum.ENABLE,
|
|
|
|
|
primaryFlag: 'Y'
|
|
|
|
|
} as ProductUnitVO)
|
|
|
|
|
// 刷新单位列表
|
|
|
|
|
const newList = await ProductUnitApi.getProductUnitSimpleList()
|
|
|
|
|
unitList.value = newList
|
|
|
|
|
// 找到新创建的单位并选中
|
|
|
|
|
const newUnit = newList.find((u: any) => u.name === unitInputName.value.trim())
|
|
|
|
|
if (newUnit) {
|
|
|
|
|
if (type === 'unit') {
|
|
|
|
|
formData.value.unitId = newUnit.id
|
|
|
|
|
} else {
|
|
|
|
|
formData.value.purchaseUnitId = newUnit.id
|
|
|
|
|
handlePurchaseUnitChange(newUnit.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
clearAddUnit()
|
|
|
|
|
message.success('新增单位成功')
|
|
|
|
|
} finally {
|
|
|
|
|
formLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const clearAddUnit = () => {
|
|
|
|
|
unitInputName.value = ''
|
|
|
|
|
isAddingUnit.value = false
|
|
|
|
|
isAddingPurchaseUnit.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getQrcodeRefreshUrl = () => {
|
|
|
|
|
if (!formData.value.id || !formData.value.barCode) return ''
|
|
|
|
|
return `/erp/product/regenerate-code?id=${formData.value.id}&code=${encodeURIComponent(String(formData.value.barCode))}`
|
|
|
|
|
|