mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
34 lines
728 B
JavaScript
34 lines
728 B
JavaScript
import _ from 'lodash-es'
|
|
|
|
function handleInputs (inputs) {
|
|
if (inputs == null) {
|
|
return
|
|
}
|
|
_.forEach(inputs, (item, key) => {
|
|
if (item.component?.required === true) {
|
|
if (item.component.rules == null) {
|
|
item.component.rules = []
|
|
}
|
|
if (item.component.rules.length > 0) {
|
|
const hasRequired = item.rules.filter(rule => {
|
|
return rule.required === true
|
|
})
|
|
if (hasRequired.length > 0) {
|
|
return
|
|
}
|
|
}
|
|
item.component.rules.push({ required: true, message: '该项必填' })
|
|
delete item.component.required
|
|
}
|
|
})
|
|
}
|
|
export default {
|
|
|
|
handle (list) {
|
|
_.forEach(list, item => {
|
|
handleInputs(item.input)
|
|
})
|
|
}
|
|
|
|
}
|