Commit 7a7d4b5b by qinjianhui

fix:添加排版类型校验

parent 2e5ae693
...@@ -172,7 +172,11 @@ ...@@ -172,7 +172,11 @@
" "
/> />
<div style="color: #606266; margin-left: 155px; margin-right: 10px">状态:</div> <div
style="color: #606266; margin-left: 155px; margin-right: 10px"
>
状态:
</div>
<el-switch <el-switch
v-model="editForm.status" v-model="editForm.status"
active-value="ACTIVE" active-value="ACTIVE"
...@@ -195,11 +199,27 @@ ...@@ -195,11 +199,27 @@
label="排版类型:" label="排版类型:"
prop="type" prop="type"
label-width="100" label-width="100"
:rules="editForm.isAuto ? [ :rules="
{ required: true, message: '请选择排版类型', trigger: 'change' } editForm.isAuto
] : []" ? [
{
required: true,
message: '请选择排版类型',
trigger: 'change',
},
]
: []
"
>
<el-radio-group
v-model="editForm.type"
:required="editForm.isAuto"
@change="() => {
if (editForm.thArrangeMax) {
editFormRef?.validateField('thArrangeMax')
}
}"
> >
<el-radio-group v-model="editForm.type" :required="editForm.isAuto">
<el-radio label="tiff">tiff排版</el-radio> <el-radio label="tiff">tiff排版</el-radio>
<el-radio label="png">png排版</el-radio> <el-radio label="png">png排版</el-radio>
</el-radio-group> </el-radio-group>
...@@ -211,11 +231,22 @@ ...@@ -211,11 +231,22 @@
label="排版宽度:" label="排版宽度:"
prop="templateWidth" prop="templateWidth"
label-width="100" label-width="100"
:rules="editForm.isAuto ? [ :rules="
{ required: true, message: '请选择排版宽度', trigger: 'change' } editForm.isAuto
] : []" ? [
{
required: true,
message: '请选择排版宽度',
trigger: 'change',
},
]
: []
"
>
<el-radio-group
v-model="editForm.templateWidth"
:required="editForm.isAuto"
> >
<el-radio-group v-model="editForm.templateWidth" :required="editForm.isAuto">
<el-radio :value="42">40+2cm</el-radio> <el-radio :value="42">40+2cm</el-radio>
<el-radio :value="60">60cm</el-radio> <el-radio :value="60">60cm</el-radio>
</el-radio-group> </el-radio-group>
...@@ -232,18 +263,7 @@ ...@@ -232,18 +263,7 @@
label="烫画类工艺自动排单一个批次里生产单件数的最大值为:" label="烫画类工艺自动排单一个批次里生产单件数的最大值为:"
prop="thArrangeMax" prop="thArrangeMax"
label-width="380" label-width="380"
:rules="[ :rules="thArrangeMaxRules"
{
required: true,
message: '请输入数量',
trigger: ['blur'],
},
{
pattern: /^\d+$/,
message: '请输入整数',
trigger: ['blur', 'change'],
},
]"
> >
<el-input <el-input
v-model="editForm.thArrangeMax" v-model="editForm.thArrangeMax"
...@@ -300,9 +320,11 @@ import { ...@@ -300,9 +320,11 @@ import {
import { Plus, Minus } from '@element-plus/icons-vue' import { Plus, Minus } from '@element-plus/icons-vue'
import LogDialog from '.././components/dialog.tsx' import LogDialog from '.././components/dialog.tsx'
import CustomizeForm from '@/components/CustomizeForm.tsx'
import { Edit } from '@element-plus/icons-vue' import { Edit } from '@element-plus/icons-vue'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import type { FormInstance } from 'element-plus'
import { computed } from 'vue'
import type { FormItemRule } from 'element-plus'
const editForm = ref<BaseForm>({ isAuto: false, status: 'ACTIVE' }) const editForm = ref<BaseForm>({ isAuto: false, status: 'ACTIVE' })
const tableData = ref([]) const tableData = ref([])
...@@ -333,7 +355,7 @@ onMounted(() => { ...@@ -333,7 +355,7 @@ onMounted(() => {
const dialogVisible = ref(false) const dialogVisible = ref(false)
const editFormRef = ref<InstanceType<typeof CustomizeForm> | null>(null) const editFormRef = ref<FormInstance | null>(null)
const paramsList = ref(['craft_type']) const paramsList = ref(['craft_type'])
...@@ -345,6 +367,57 @@ const rulesList = ref([ ...@@ -345,6 +367,57 @@ const rulesList = ref([
]) ])
/** /**
* @description: 烫画类工艺自动排单最大值的校验规则
*/
const thArrangeMaxRules = computed(() => {
return [
{
required: true,
message: '请输入数量',
trigger: ['blur'],
},
{
pattern: /^\d+$/,
message: '请输入整数',
trigger: ['blur', 'change'],
},
{
validator: (
_rule: FormItemRule,
value: string | number | undefined,
callback: (error?: Error) => void
) => {
if (!value) {
callback()
return
}
const numValue = Number(value)
if (isNaN(numValue)) {
callback()
return
}
if (editForm.value.type === 'tiff') {
if (numValue > 40) {
callback(new Error('排版类型为TIFF时,最大值不能超过40'))
} else {
callback()
}
} else if (editForm.value.type === 'png') {
if (numValue > 100) {
callback(new Error('排版类型为PNG时,最大值不能超过100'))
} else {
callback()
}
} else {
callback()
}
},
trigger: ['blur', 'change'],
},
]
})
/**
* @description: 取消按钮 * @description: 取消按钮
*/ */
function cancelFn() { function cancelFn() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment