|
|
|
@ -168,6 +168,20 @@ ref="detailRef" :visible="detailVisible"
|
|
|
|
<el-option v-for="item in recipeTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
<el-option v-for="item in recipeTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
</el-select>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item :label="t('RecipeManagement.RecipeConfig.dialogProductCategoryLabel')" prop="productCategoryId">
|
|
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
|
|
v-model="dialogForm.productCategoryId"
|
|
|
|
|
|
|
|
:placeholder="t('RecipeManagement.RecipeConfig.dialogProductCategoryPlaceholder')"
|
|
|
|
|
|
|
|
clearable
|
|
|
|
|
|
|
|
filterable
|
|
|
|
|
|
|
|
class="!w-full"
|
|
|
|
|
|
|
|
:loading="categoryLoading"
|
|
|
|
|
|
|
|
@change="handleCategoryChange"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<el-option v-for="item in categoryOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('RecipeManagement.RecipeConfig.dialogProductNameLabel')" prop="productId">
|
|
|
|
<el-form-item :label="t('RecipeManagement.RecipeConfig.dialogProductNameLabel')" prop="productId">
|
|
|
|
<el-select
|
|
|
|
<el-select
|
|
|
|
v-model="dialogForm.productId"
|
|
|
|
v-model="dialogForm.productId"
|
|
|
|
@ -176,6 +190,7 @@ ref="detailRef" :visible="detailVisible"
|
|
|
|
filterable
|
|
|
|
filterable
|
|
|
|
class="!w-full"
|
|
|
|
class="!w-full"
|
|
|
|
:loading="productLoading"
|
|
|
|
:loading="productLoading"
|
|
|
|
|
|
|
|
:disabled="!dialogForm.productCategoryId"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-option v-for="item in productOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
<el-option v-for="item in productOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
</el-select>
|
|
|
|
</el-select>
|
|
|
|
@ -290,6 +305,7 @@ ref="detailRef" :visible="detailVisible"
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import download from '@/utils/download'
|
|
|
|
import download from '@/utils/download'
|
|
|
|
import { ProductApi } from '@/api/erp/product/product'
|
|
|
|
import { ProductApi } from '@/api/erp/product/product'
|
|
|
|
|
|
|
|
import { ProductCategoryApi } from '@/api/erp/product/category'
|
|
|
|
import { DeviceApi } from '@/api/iot/device'
|
|
|
|
import { DeviceApi } from '@/api/iot/device'
|
|
|
|
import { RecipeApi } from '@/api/iot/recipe'
|
|
|
|
import { RecipeApi } from '@/api/iot/recipe'
|
|
|
|
import { RecipeConfigApi, RecipeConfigVO } from '@/api/iot/recipeConfig'
|
|
|
|
import { RecipeConfigApi, RecipeConfigVO } from '@/api/iot/recipeConfig'
|
|
|
|
@ -386,6 +402,8 @@ const handleDelete = async (row: RecipeConfigVO) => {
|
|
|
|
|
|
|
|
|
|
|
|
const productLoading = ref(false)
|
|
|
|
const productLoading = ref(false)
|
|
|
|
const productOptions = ref<SelectOption<string>[]>([])
|
|
|
|
const productOptions = ref<SelectOption<string>[]>([])
|
|
|
|
|
|
|
|
const categoryLoading = ref(false)
|
|
|
|
|
|
|
|
const categoryOptions = ref<SelectOption<string>[]>([])
|
|
|
|
const deviceLoading = ref(false)
|
|
|
|
const deviceLoading = ref(false)
|
|
|
|
const deviceOptions = ref<SelectOption<string>[]>([])
|
|
|
|
const deviceOptions = ref<SelectOption<string>[]>([])
|
|
|
|
const recipeTypeLoading = ref(false)
|
|
|
|
const recipeTypeLoading = ref(false)
|
|
|
|
@ -399,10 +417,24 @@ const getRecipeTypeLabel = (value: unknown) => {
|
|
|
|
return matched?.label ?? String(value)
|
|
|
|
return matched?.label ?? String(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getProductOptions = async () => {
|
|
|
|
const getCategoryOptions = async () => {
|
|
|
|
|
|
|
|
categoryLoading.value = true
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const data = await ProductCategoryApi.getProductCategorySimpleList()
|
|
|
|
|
|
|
|
categoryOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.id }))
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
categoryLoading.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getProductOptions = async (categoryId: string | number | undefined) => {
|
|
|
|
|
|
|
|
if (categoryId === undefined || categoryId === null || categoryId === '') {
|
|
|
|
|
|
|
|
productOptions.value = []
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
productLoading.value = true
|
|
|
|
productLoading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const data = await ProductApi.getProductSimpleList()
|
|
|
|
const data = await ProductApi.getProductSimpleList({ categoryId })
|
|
|
|
productOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.id }))
|
|
|
|
productOptions.value = (data ?? []).map((item: any) => ({ label: item.name, value: item.id }))
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
productLoading.value = false
|
|
|
|
productLoading.value = false
|
|
|
|
@ -430,7 +462,7 @@ const getRecipeTypeOptions = async () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ensureOptionsLoaded = async () => {
|
|
|
|
const ensureOptionsLoaded = async () => {
|
|
|
|
if (!productOptions.value.length) await getProductOptions()
|
|
|
|
if (!categoryOptions.value.length) await getCategoryOptions()
|
|
|
|
if (!deviceOptions.value.length) await getDeviceOptions()
|
|
|
|
if (!deviceOptions.value.length) await getDeviceOptions()
|
|
|
|
if (!recipeTypeOptions.value.length) await getRecipeTypeOptions()
|
|
|
|
if (!recipeTypeOptions.value.length) await getRecipeTypeOptions()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -450,6 +482,7 @@ const dialogForm = reactive({
|
|
|
|
recipeCode: '',
|
|
|
|
recipeCode: '',
|
|
|
|
name: '',
|
|
|
|
name: '',
|
|
|
|
recipeTypeId: '' as string | number | undefined,
|
|
|
|
recipeTypeId: '' as string | number | undefined,
|
|
|
|
|
|
|
|
productCategoryId: '' as string | number | undefined,
|
|
|
|
productId: '' as string | number | undefined,
|
|
|
|
productId: '' as string | number | undefined,
|
|
|
|
machineId: '' as string | number | undefined,
|
|
|
|
machineId: '' as string | number | undefined,
|
|
|
|
recipeDesc: ''
|
|
|
|
recipeDesc: ''
|
|
|
|
@ -485,9 +518,11 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
|
|
|
|
dialogForm.recipeCode = ''
|
|
|
|
dialogForm.recipeCode = ''
|
|
|
|
dialogForm.name = ''
|
|
|
|
dialogForm.name = ''
|
|
|
|
dialogForm.recipeTypeId = ''
|
|
|
|
dialogForm.recipeTypeId = ''
|
|
|
|
|
|
|
|
dialogForm.productCategoryId = ''
|
|
|
|
dialogForm.productId = ''
|
|
|
|
dialogForm.productId = ''
|
|
|
|
dialogForm.machineId = ''
|
|
|
|
dialogForm.machineId = ''
|
|
|
|
dialogForm.recipeDesc = ''
|
|
|
|
dialogForm.recipeDesc = ''
|
|
|
|
|
|
|
|
productOptions.value = []
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -497,6 +532,7 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
|
|
|
|
dialogForm.recipeTypeId =
|
|
|
|
dialogForm.recipeTypeId =
|
|
|
|
(row as any)?.recipeTypeId ??
|
|
|
|
(row as any)?.recipeTypeId ??
|
|
|
|
(row?.recipeType === undefined || row?.recipeType === null ? '' : (row as any).recipeType)
|
|
|
|
(row?.recipeType === undefined || row?.recipeType === null ? '' : (row as any).recipeType)
|
|
|
|
|
|
|
|
dialogForm.productCategoryId = (row as any)?.productCategoryId ?? (row as any)?.categoryId ?? ''
|
|
|
|
|
|
|
|
|
|
|
|
const findProductValueByName = (name: string | undefined) => {
|
|
|
|
const findProductValueByName = (name: string | undefined) => {
|
|
|
|
if (!name) return ''
|
|
|
|
if (!name) return ''
|
|
|
|
@ -509,11 +545,17 @@ const openDialog = async (mode: DialogMode, row?: RecipeConfigVO) => {
|
|
|
|
return matched?.value ?? ''
|
|
|
|
return matched?.value ?? ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await getProductOptions(dialogForm.productCategoryId)
|
|
|
|
dialogForm.productId = (row as any)?.productId ?? findProductValueByName(row?.productName)
|
|
|
|
dialogForm.productId = (row as any)?.productId ?? findProductValueByName(row?.productName)
|
|
|
|
dialogForm.machineId = (row as any)?.machineId ?? (row as any)?.deviceId ?? findDeviceValueByName(row?.machineName ?? row?.deviceName)
|
|
|
|
dialogForm.machineId = (row as any)?.machineId ?? (row as any)?.deviceId ?? findDeviceValueByName(row?.machineName ?? row?.deviceName)
|
|
|
|
dialogForm.recipeDesc = row?.recipeDesc ?? row?.remark ?? ''
|
|
|
|
dialogForm.recipeDesc = row?.recipeDesc ?? row?.remark ?? ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleCategoryChange = async (value: string | number | undefined) => {
|
|
|
|
|
|
|
|
dialogForm.productId = ''
|
|
|
|
|
|
|
|
await getProductOptions(value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const submitDialog = async () => {
|
|
|
|
const submitDialog = async () => {
|
|
|
|
if (!dialogFormRef.value) return
|
|
|
|
if (!dialogFormRef.value) return
|
|
|
|
await dialogFormRef.value.validate()
|
|
|
|
await dialogFormRef.value.validate()
|
|
|
|
@ -524,6 +566,7 @@ const submitDialog = async () => {
|
|
|
|
recipeCode: dialogForm.recipeCode,
|
|
|
|
recipeCode: dialogForm.recipeCode,
|
|
|
|
name: dialogForm.name,
|
|
|
|
name: dialogForm.name,
|
|
|
|
recipeTypeId: dialogForm.recipeTypeId,
|
|
|
|
recipeTypeId: dialogForm.recipeTypeId,
|
|
|
|
|
|
|
|
productCategoryId: dialogForm.productCategoryId,
|
|
|
|
productId: dialogForm.productId,
|
|
|
|
productId: dialogForm.productId,
|
|
|
|
machineId: dialogForm.machineId,
|
|
|
|
machineId: dialogForm.machineId,
|
|
|
|
recipeDesc: dialogForm.recipeDesc
|
|
|
|
recipeDesc: dialogForm.recipeDesc
|
|
|
|
|