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;
}
}

View File

@@ -5,6 +5,17 @@
:model="dataForm"
@keyup.enter.native="getDataList()"
>
<el-form-item label="分类">
<el-select v-model="query.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-item label="文章标题">
<el-input
v-model="query.title"
@@ -65,6 +76,14 @@
</template>
</el-table-column>
<el-table-column
prop="type"
header-align="center"
align="center"
label="分类"
:formatter="typeFormatter"
>
</el-table-column>
<el-table-column
width="200"
prop="createTime"
@@ -132,8 +151,10 @@ export default {
key: ""
},
query: {
title:""
title:"",
type: ""
},
typeList: [],
dataList: [],
delFlag: false,
pageIndex: 1,
@@ -155,9 +176,28 @@ export default {
this.pageIndex = this.$route.query.upPageIndex;
console.log(this.pageIndex);
}
this.getTypeList();
this.getDataList();
},
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 = [];
}
});
},
typeFormatter(row) {
const current = this.typeList.find(
item => item.dictType === row.type || String(item.dictType) === String(row.type)
);
return current ? current.dictValue : row.type;
},
// 获取数据列表
getDataList() {
console.log("this.selectQueryApp at line 195:", this.selectQueryApp);