|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
<template>
|
|
|
|
|
<template>
|
|
|
|
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
|
|
|
|
<el-form
|
|
|
|
|
ref="formRef"
|
|
|
|
|
@ -33,6 +33,29 @@
|
|
|
|
|
<el-form-item :label="t('TemplateManagement.PrintConfig.isEnabled')" prop="isEnabled">
|
|
|
|
|
<el-switch v-model="formData.isEnabled" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('TemplateManagement.PrintConfig.businessScenario')" prop="businessScenario">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formData.businessScenario"
|
|
|
|
|
multiple
|
|
|
|
|
clearable
|
|
|
|
|
filterable
|
|
|
|
|
:placeholder="t('TemplateManagement.PrintConfig.placeholderBusinessScenario')"
|
|
|
|
|
style="width:100%"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in businessScenarioOptions"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('TemplateManagement.PrintConfig.businessScenarioCode')" prop="businessScenarioCode">
|
|
|
|
|
<el-input v-model="formData.businessScenarioCode" :disabled="true" placeholder="选择业务场景后自动回填" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('TemplateManagement.PrintConfig.scenarioCount')" prop="scenarioCount">
|
|
|
|
|
<el-input-number v-model="formData.scenarioCount" :disabled="true" :min="0" style="width: 200px" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('TemplateManagement.PrintConfig.remark')" prop="remark">
|
|
|
|
|
<el-input v-model="formData.remark" :placeholder="t('TemplateManagement.PrintConfig.placeholderRemark')" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
@ -46,6 +69,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ConfigApi, ConfigVO } from '@/api/mes/printconfig/index'
|
|
|
|
|
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
|
|
import {
|
|
|
|
|
autoConnect,
|
|
|
|
|
defaultElementTypeProvider,
|
|
|
|
|
@ -68,10 +92,26 @@ const formData = ref({
|
|
|
|
|
systemPrinterName: undefined,
|
|
|
|
|
isDefault: false,
|
|
|
|
|
isEnabled: true,
|
|
|
|
|
businessScenario: [],
|
|
|
|
|
businessScenarioCode: undefined,
|
|
|
|
|
scenarioCount: 0,
|
|
|
|
|
remark: undefined,
|
|
|
|
|
createdAt: undefined,
|
|
|
|
|
updatedAt: undefined,
|
|
|
|
|
})
|
|
|
|
|
const businessScenarioOptions = computed(() => getStrDictOptions(DICT_TYPE.MES_BUSINESS_SCENARIO))
|
|
|
|
|
|
|
|
|
|
// watch businessScenario multi-select, auto-fill code and count
|
|
|
|
|
watch(() => formData.value.businessScenario, (val) => {
|
|
|
|
|
if (val && val.length > 0) {
|
|
|
|
|
formData.value.businessScenarioCode = val.join(',')
|
|
|
|
|
formData.value.scenarioCount = val.length
|
|
|
|
|
} else {
|
|
|
|
|
formData.value.businessScenarioCode = undefined
|
|
|
|
|
formData.value.scenarioCount = 0
|
|
|
|
|
}
|
|
|
|
|
}, { deep: true })
|
|
|
|
|
|
|
|
|
|
const formRules = reactive({
|
|
|
|
|
hostName: [{ required: false, message: '主机名(如PACKING-PC-01),不可修改不能为空', trigger: 'blur' }],
|
|
|
|
|
systemPrinterName: [{ required: true, message: '系统打印机名称,关联下拉选项不能为空', trigger: 'blur' }],
|
|
|
|
|
@ -118,7 +158,12 @@ const open = async (type: string, host: string, id?: number) => {
|
|
|
|
|
if (id) {
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
formData.value = await ConfigApi.getConfig(id)
|
|
|
|
|
const data = await ConfigApi.getConfig(id)
|
|
|
|
|
formData.value = data
|
|
|
|
|
if (data.businessScenarioCode) {
|
|
|
|
|
formData.value.businessScenario = data.businessScenarioCode.split(',')
|
|
|
|
|
formData.value.scenarioCount = formData.value.businessScenario.length
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
formLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
@ -134,6 +179,13 @@ const submitForm = async () => {
|
|
|
|
|
// 提交请求
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
// 将业务场景编码转为标签用于列表展示
|
|
|
|
|
if (formData.value.businessScenario && formData.value.businessScenario.length > 0) {
|
|
|
|
|
const dictMap = new Map(businessScenarioOptions.value.map(d => [d.value, d.label]))
|
|
|
|
|
formData.value.businessScenario = formData.value.businessScenario.map((v: string) => dictMap.get(v) || v).join(',')
|
|
|
|
|
} else {
|
|
|
|
|
formData.value.businessScenario = undefined
|
|
|
|
|
}
|
|
|
|
|
const data = formData.value as unknown as ConfigVO
|
|
|
|
|
if (formType.value === 'create') {
|
|
|
|
|
await ConfigApi.createConfig(data)
|
|
|
|
|
@ -301,6 +353,9 @@ const resetForm = () => {
|
|
|
|
|
systemPrinterName: undefined,
|
|
|
|
|
isDefault: false,
|
|
|
|
|
isEnabled: true,
|
|
|
|
|
businessScenario: [],
|
|
|
|
|
businessScenarioCode: undefined,
|
|
|
|
|
scenarioCount: 0,
|
|
|
|
|
remark: undefined,
|
|
|
|
|
createdAt: undefined,
|
|
|
|
|
updatedAt: undefined,
|
|
|
|
|
|