diff --git a/src/views/category/form.vue b/src/views/category/form.vue index db7d578..b7c7bce 100644 --- a/src/views/category/form.vue +++ b/src/views/category/form.vue @@ -78,10 +78,12 @@ export default { if (item.value !== 3) { item.typeState = true } + this.form.isType = 3 } else if (this.selectedCategory.isType === 3) { if (item.value !== 4) { item.typeState = true } + this.form.isType = 4 } }) }, diff --git a/src/views/components/category/PreviewForm.vue b/src/views/components/category/PreviewForm.vue index c7d5c86..9f0c21b 100644 --- a/src/views/components/category/PreviewForm.vue +++ b/src/views/components/category/PreviewForm.vue @@ -22,7 +22,19 @@ /> - + @@ -133,6 +145,9 @@ export default { arcId: function(newValue, oldValue) { }, parentsId: function(newValue, oldValue) { + }, + formPreviewData: function() { + this.editFormRow() } }, created() { @@ -243,6 +258,12 @@ export default { this.currentFieldName = item.fieldName this.getAllSubset(item) }, + // 预览和输入时,自动补零 + autoAddZero(isFilling, fieldName, value, fillingDigit) { + if (isFilling) { + this.addOrUpdateForm[fieldName] = value.toString().padStart(fillingDigit, '0').slice(-1 * fillingDigit) + } + }, // 动态生成表单 editFormRow() { this.rules = {} @@ -259,13 +280,13 @@ export default { this.$set(this.addOrUpdateForm, item.fieldName, null) // 防止unkonwn } } - this.rules[item.fieldName] = [ + this.$set(this.rules, item.fieldName, [ { required: !!item.isRequired, message: (item.isInputClass === 'text' ? '请输入' : '请选择') + item.fieldCnName, trigger: item.isInputClass === 'text' ? 'blur' : 'change' } - ] + ]) }) }, // 预览界面排序