|
@@ -1,6 +1,16 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
+ <el-form-item label="分类" prop="types">
|
|
|
+ <el-cascader
|
|
|
+ :options="treeOptions"
|
|
|
+ placeholder="请选择分类"
|
|
|
+ v-model="queryParams.catalog"
|
|
|
+ :props="{ label: 'typeName', value: 'typeId', emitPath: false }"
|
|
|
+ clearable
|
|
|
+ size="small">
|
|
|
+ </el-cascader>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="标题" prop="title">
|
|
|
<el-input v-model="queryParams.title" placeholder="请输入标题" clearable size="small"
|
|
|
@keyup.enter.native="handleQuery" />
|
|
@@ -124,10 +134,18 @@
|
|
|
<el-row>
|
|
|
<el-col :span="7">
|
|
|
<el-form-item label="分类">
|
|
|
- <el-select v-model="form.typeIds" multiple placeholder="请选择" filterable clearable>
|
|
|
+ <!-- <el-select v-model="form.typeIds" multiple placeholder="请选择" filterable clearable>
|
|
|
<el-option v-for="item in typeOptions" :key="item.typeId" :label="item.typeName" :value="item.typeId">
|
|
|
</el-option>
|
|
|
- </el-select>
|
|
|
+ </el-select> -->
|
|
|
+ <el-cascader
|
|
|
+ :options="treeOptions"
|
|
|
+ placeholder="请选择分类"
|
|
|
+ v-model="form.typeIds"
|
|
|
+ :props="{ label: 'typeName', value: 'typeId', emitPath: false, multiple: true }"
|
|
|
+ clearable
|
|
|
+ size="small">
|
|
|
+ </el-cascader>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="17">
|
|
@@ -263,6 +281,12 @@
|
|
|
created() {
|
|
|
this.getList();
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ getBlog().then(res => {
|
|
|
+ this.typeOptions = res.types;
|
|
|
+ this.tagOptions = res.tags;
|
|
|
+ })
|
|
|
+ },
|
|
|
methods: {
|
|
|
/** 查询文章管理列表 */
|
|
|
getList() {
|
|
@@ -339,13 +363,9 @@
|
|
|
},
|
|
|
/** 新增按钮操作 */
|
|
|
handleAdd() {
|
|
|
- getBlog().then(response => {
|
|
|
- this.typeOptions = response.types;
|
|
|
- this.tagOptions = response.tags;
|
|
|
- this.reset();
|
|
|
- this.open = true;
|
|
|
- this.title = "添加文章";
|
|
|
- });
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ this.title = "添加文章";
|
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
@@ -520,6 +540,18 @@
|
|
|
}
|
|
|
return '';
|
|
|
},
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ treeOptions() {
|
|
|
+ console.log('typeOptions:', this.typeOptions);
|
|
|
+ this.typeOptions?.forEach((p, _, a) => {
|
|
|
+ p.children = a?.filter(c => c.parentId == p.typeId);
|
|
|
+ if (p.children?.length == 0) p.children = null;
|
|
|
+ })
|
|
|
+ const ret = this.typeOptions?.filter(p => p.parentId == 0);
|
|
|
+ console.log(ret);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|