文章管理部分接口对接

This commit is contained in:
Double-_-Z 2025-07-14 23:55:04 +08:00
parent d27a44d446
commit 8a48837db7
5 changed files with 109 additions and 36 deletions

View File

@ -2,7 +2,7 @@ import request from '@/utils/request'
export function add(data) { export function add(data) {
return request({ return request({
url: 'api/article', url: 'aerocraftAdminApi/cpArticle',
method: 'post', method: 'post',
data data
}) })

33
src/api/platform/label.js Normal file
View File

@ -0,0 +1,33 @@
import request from '@/utils/request'
export function tree(moduleId) {
return request({
url: `aerocraftAdminApi/cpLabel/tree/${moduleId}`,
method: 'get',
})
}
export function add(data) {
return request({
url: 'aerocraftAdminApi/cpLabel',
method: 'post',
data
})
}
export function del(id) {
return request({
url: `aerocraftAdminApi/cpLabel/${id}`,
method: 'delete',
})
}
export function edit(data) {
return request({
url: 'aerocraftAdminApi/cpLabel',
method: 'put',
data
})
}
export default { tree, add, edit, del }

View File

@ -0,0 +1,33 @@
import request from '@/utils/request'
export function all() {
return request({
url: 'aerocraftAdminApi/cpModule/all',
method: 'get',
})
}
export function add(data) {
return request({
url: 'aerocraftAdminApi/cpModule',
method: 'post',
data
})
}
export function del(id) {
return request({
url: `aerocraftAdminApi/cpModule/${id}`,
method: 'delete',
})
}
export function edit(data) {
return request({
url: 'aerocraftAdminApi/cpModule',
method: 'put',
data
})
}
export default { all, add, edit, del }

View File

@ -4,13 +4,13 @@
<div class="head-container"> <div class="head-container">
<div> <div>
<!-- 搜索 --> <!-- 搜索 -->
<el-select v-model="query.moduleName" placeholder="请选择模块" clearable size="small" class="filter-item" <el-select v-model="query.moduleId" placeholder="请选择模块" clearable size="small" class="filter-item"
style="width: 200px"> style="width: 200px" @change="getLabels">
<el-option v-for="(item,index) in modules" :key="index" :label="item.label" :value="item.value" /> <el-option v-for="(item,index) in modules" :key="index" :label="item.moduleName" :value="item.id" />
</el-select> </el-select>
<el-select v-model="query.labelName" placeholder="请选择标签" clearable size="small" class="filter-item" <el-select v-model="query.cplabelId" placeholder="请选择标签" clearable size="small" class="filter-item"
style="width: 200px"> style="width: 200px">
<el-option v-for="(item,index) in labels" :key="index" :label="item.label" :value="item.value" /> <el-option v-for="(item,index) in labels" :key="index" :label="item.name" :value="item.id" />
</el-select> </el-select>
<el-input v-model="query.title" clearable size="small" placeholder="请输入标题" style="width: 200px;" <el-input v-model="query.title" clearable size="small" placeholder="请输入标题" style="width: 200px;"
class="filter-item" @keyup.enter.native="crud.toQuery"/> class="filter-item" @keyup.enter.native="crud.toQuery"/>
@ -50,7 +50,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!--分页组件--> <!--分页组件-->
<pagination /> <pagination pageProp="pages" />
</div> </div>
</template> </template>
<script> <script>
@ -58,15 +58,15 @@ import crudArticle from '@/api/platform/article'
import CRUD, { presenter, header, form, crud } from '@crud/crud' import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation' import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination' import pagination from '@crud/Pagination'
import { all } from '@/api/platform/module'
import { tree } from '@/api/platform/label'
export default { export default {
name: 'Article', name: 'Article',
components: { rrOperation, pagination }, components: { rrOperation, pagination },
// cruds() {
dicts: ['material_type'], return CRUD({ title: '文章', url: '/aerocraftAdminApi/cpArticle', crudMethod: { ...crudArticle }, optShow: { reset: true }})
cruds() { },
return CRUD({ title: '文章', url: 'api/article', crudMethod: { ...crudArticle }, optShow: { reset: true }}) mixins: [presenter(), header(), crud()],
},
mixins: [presenter(), header(), crud()],
data() { data() {
return { return {
permission: { permission: {
@ -74,25 +74,12 @@ export default {
edit: ['admin', 'article:edit'], edit: ['admin', 'article:edit'],
del: ['admin', 'article:del'] del: ['admin', 'article:del']
}, },
modules:[ modules:[],
{ label: '景区', value: '景区' }, labels:[]
{ label: '新闻', value: '新闻' },
{ label: '活动', value: '活动' },
{ label: '其他', value: '其他' }
],
labels:[
{ label: '图片', value: '图片' },
{ label: '视频', value: '视频' },
{ label: '音频', value: '音频' },
{ label: '文件', value: '文件' }
]
} }
}, },
created() { created() {
this.crud.data = [{ id: 1, title: '景区', articletype: '图文', top: 1, moduleName: '工作台', labelName: '使用教程', createTime: '2020-01-01' }, this.getModules();
{ id: 2, title: '景区', articletype: '图文', top: 0, moduleName: '工作台', labelName: '使用教程', createTime: '2020-01-01' },
]
this.crud.resetDataStatus()
}, },
methods: { methods: {
// //
@ -107,6 +94,23 @@ export default {
this.$message.success('复制成功'); this.$message.success('复制成功');
aux.remove(); aux.remove();
}, },
//
getModules(){
all().then(res => {
this.modules = res;
})
},
// id
getLabels(){
if(this.query.moduleId){
tree(this.query.moduleId).then(res => {
this.labels = res;
});
}else{
this.labels = [];
this.query.cplabelId = '';
}
},
// //
toShowDetail(row) { toShowDetail(row) {
this.$router.push({ path: '/platform/article/detail' , query: { id:row.id, moduleName: row.moduleName, labelName: row.labelName } }); this.$router.push({ path: '/platform/article/detail' , query: { id:row.id, moduleName: row.moduleName, labelName: row.labelName } });
@ -144,6 +148,9 @@ export default {
// state.tableData.loading = false; // state.tableData.loading = false;
} }
}) })
},
[CRUD.HOOK.beforeRefresh](crud, form) {
crud.query.current = crud.page.page;
} }
} }
} }

View File

@ -29,13 +29,13 @@ module.exports = {
}, },
// lintOnSave: false, // lintOnSave: false,
proxy: { proxy: {
// '/aerocraftAdminApi': { '/aerocraftAdminApi': {
// target: process.env.VUE_APP_BASE_API, target: process.env.VUE_APP_BASE_API,
// changeOrigin: true, changeOrigin: true,
// // pathRewrite: { pathRewrite: {
// // '^/api': 'api' '^/aerocraftAdminApi': ''
// // } }
// }, },
'/api': { '/api': {
target: process.env.VUE_APP_BASE_API, target: process.env.VUE_APP_BASE_API,
changeOrigin: true, changeOrigin: true,