feat(心理论坛模块): 添加分类选择功能及数据加载

- 在新增/修改心理论坛表单中添加分类选择项,支持用户选择分类
- 更新表单验证规则,确保分类为必填项
- 实现分类数据的动态加载,优化用户体验
- 在心理论坛列表中添加分类列,支持分类信息的展示
This commit is contained in:
2026-03-30 09:10:42 +08:00
parent 0506cbccc1
commit 4d4c644b81
2 changed files with 82 additions and 4 deletions

View File

@@ -23,6 +23,17 @@
:rows="3"
></el-input>
</el-form-item>
<el-form-item label="分类" prop="type">
<el-select v-model="dataForm.type" placeholder="请选择分类" clearable>
<el-option
v-for="item in typeList"
:key="item.dictType"
:label="item.dictValue"
:value="item.dictType"
>
</el-option>
</el-select>
</el-form-item>
</el-form>
</div>
@@ -42,14 +53,19 @@ export default {
visible: false,
dialogImageUrl: "",
dialogVisible: false,
typeList: [],
dataForm: {
id: null,
title: '',
url: ''
url: '',
type: ''
},
dataRule: {
type: [
{ required: true, message: "分类不能为空", trigger: "change" }
],
url: [
{ required: true, message: "链接地址不能为空", trigger: "blur" }
{ required: true, message: "链接地址不能为空", trigger: "change" }
]
},
urlList: {
@@ -60,12 +76,31 @@ export default {
};
},
methods: {
getTypeList() {
this.$http({
url: this.$http.adornUrl("/book/sysdictdata/selectByType/psycheForumLabel"),
method: "get"
}).then(({ data }) => {
if (data && data.code === 0) {
this.typeList = data.dataList || [];
} else {
this.typeList = [];
}
});
},
init(row) {
this.getTypeList();
this.dataForm = {
id: row && row.id || null,
url: row && row.url || ''
url: row && row.url || '',
type: row && row.type != null ? String(row.type) : ''
};
this.visible = true;
this.$nextTick(() => {
if (this.$refs["dataForm"]) {
this.$refs["dataForm"].clearValidate();
}
});
},
// 表单提交
dataFormSubmit() {
@@ -101,6 +136,9 @@ export default {
});
},
handlereset() {
if (this.$refs["dataForm"]) {
this.$refs["dataForm"].clearValidate();
}
this.visible = false;
}
}