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" :rows="3"
></el-input> ></el-input>
</el-form-item> </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> </el-form>
</div> </div>
@@ -42,14 +53,19 @@ export default {
visible: false, visible: false,
dialogImageUrl: "", dialogImageUrl: "",
dialogVisible: false, dialogVisible: false,
typeList: [],
dataForm: { dataForm: {
id: null, id: null,
title: '', title: '',
url: '' url: '',
type: ''
}, },
dataRule: { dataRule: {
type: [
{ required: true, message: "分类不能为空", trigger: "change" }
],
url: [ url: [
{ required: true, message: "链接地址不能为空", trigger: "blur" } { required: true, message: "链接地址不能为空", trigger: "change" }
] ]
}, },
urlList: { urlList: {
@@ -60,12 +76,31 @@ export default {
}; };
}, },
methods: { 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) { init(row) {
this.getTypeList();
this.dataForm = { this.dataForm = {
id: row && row.id || null, 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.visible = true;
this.$nextTick(() => {
if (this.$refs["dataForm"]) {
this.$refs["dataForm"].clearValidate();
}
});
}, },
// 表单提交 // 表单提交
dataFormSubmit() { dataFormSubmit() {
@@ -101,6 +136,9 @@ export default {
}); });
}, },
handlereset() { handlereset() {
if (this.$refs["dataForm"]) {
this.$refs["dataForm"].clearValidate();
}
this.visible = false; this.visible = false;
} }
} }

View File

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