|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <el-dialog :title="dialogTitle" :visible.sync="editCategoryVsible" width="30%">
|
|
|
+ <el-dialog :close-on-click-modal="false" :title="dialogTitle" :visible.sync="editCategoryVsible" width="30%">
|
|
|
<el-form ref="editCategoryFormRef" :model="form" :rules="rules">
|
|
|
<el-form-item label="分类名称" prop="categoryName">
|
|
|
<el-input v-model="form.categoryName" placeholder="请填写分类名称"></el-input>
|
|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
<el-form-item label="排序值" prop="categorySort">
|
|
|
<el-input v-model="form.categorySort" placeholder="请填写排序值"></el-input>
|
|
|
+ <div style="font-size: 14px; color: #ccc;">值越大,排序越靠前</div>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
@@ -38,10 +39,28 @@ export default {
|
|
|
},
|
|
|
rules: {
|
|
|
categoryName: [{ required: true, message: '请输入分类名称', trigger: 'blur' }],
|
|
|
- categoryImage: [{ required: true, message: '请上传分类图片', trigger: 'blur' }]
|
|
|
+ categoryImage: [{ required: true, message: '请上传分类图片', trigger: 'blur' }],
|
|
|
+ categorySort: [
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value) {
|
|
|
+ const sortValue = Number(value)
|
|
|
+ // 检查转换后的值是否为有效数字
|
|
|
+ if (Number.isNaN(sortValue)) {
|
|
|
+ callback(new Error('排序值必须是一个有效的数字'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: ['change', 'blur']
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
isLoading: false,
|
|
|
- categoryList: []
|
|
|
+ categoryList: [],
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -72,8 +91,6 @@ export default {
|
|
|
this.editCategoryVsible = true
|
|
|
},
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// 关闭弹窗
|
|
|
handleClose() {
|
|
|
this.editCategoryVsible = false
|