master
parent
ef9489b540
commit
f47f37e5ca
@ -0,0 +1,244 @@
|
||||
<template>
|
||||
<div>
|
||||
<lx-header
|
||||
icon="md-apps"
|
||||
style="margin-bottom: 10px; border: 0px; margin-top: 15px"
|
||||
text="项目栏目管理"
|
||||
>
|
||||
<div slot="content"></div>
|
||||
<slot>
|
||||
<div class="selects">
|
||||
<div>
|
||||
<span style="padding: 0 6px; word-break: keep-all"> 关键字 </span>
|
||||
<Input
|
||||
v-model="select.keyword"
|
||||
placeholder="请输入关键字"
|
||||
style="width: 180px"
|
||||
></Input>
|
||||
</div>
|
||||
<div>
|
||||
<span style="padding: 0 6px; word-break: keep-all"> 项目 </span>
|
||||
<Select @on-change="changeActive" v-model="select.activity_list_id" style="width:200px">
|
||||
<Option v-for="item in listActivity" :value="item.id" :key="item.id">{{ item.name }}</Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
style="margin-left: 10px"
|
||||
type="primary"
|
||||
@click="select = { page: 1, keyword: '',activity_list_id:'' }"
|
||||
>重置
|
||||
</Button>
|
||||
<Button style="margin-left: 10px" type="primary" @click="doSearch"
|
||||
>查询</Button
|
||||
>
|
||||
<Button
|
||||
style="margin-left: 10px"
|
||||
type="primary"
|
||||
@click="
|
||||
$refs['create'].setForm(['activity_list_id','pid'],[select.activity_list_id||'',0]),
|
||||
$refs['create'].setType('add'),
|
||||
$refs['create'].setOption(listActivity),
|
||||
$refs['create'].setTree(list),
|
||||
$refs['create'].show()
|
||||
"
|
||||
>新增</Button
|
||||
>
|
||||
</div>
|
||||
</slot>
|
||||
</lx-header>
|
||||
|
||||
<xy-table
|
||||
:list="list"
|
||||
:total="total"
|
||||
:table-item="table"
|
||||
:isPage="false"
|
||||
@pageSizeChange="pageSizeChange"
|
||||
@pageIndexChange="pageChange"
|
||||
>
|
||||
<template v-slot:btns>
|
||||
<template>
|
||||
<el-table-column label="操作" width="260" fixed="right">
|
||||
<template #default="{ row }">
|
||||
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
style="margin-right: 4px"
|
||||
@click="
|
||||
$refs['create'].setForm(['activity_list_id','pid'],[row.activity_list_id,row.id]);
|
||||
$refs['create'].setId(row.id);
|
||||
$refs['create'].setType('editor');
|
||||
$refs['create'].setOption(listActivity),
|
||||
$refs['create'].setTree(list),
|
||||
$refs['create'].show();
|
||||
"
|
||||
>编辑</Button
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
style="margin-right: 4px"
|
||||
@click="
|
||||
$refs['create'].setForm(['activity_list_id','pid'],[select.activity_list_id||'',row.id||0]),
|
||||
$refs['create'].setType('add'),
|
||||
$refs['create'].setOption(listActivity),
|
||||
$refs['create'].setTree(list),
|
||||
$refs['create'].show()
|
||||
"
|
||||
>子栏目</Button
|
||||
>
|
||||
<Poptip confirm transfer title="确认删除?" @on-ok="deleteitem(row)">
|
||||
<Button size="small" type="error">删除</Button>
|
||||
</Poptip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
</template>
|
||||
</xy-table>
|
||||
<create ref="create" @refresh="load"></create>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { index, destroy, show } from "@/api/index";
|
||||
import { index as activityIndex } from "@/api/activity/index"
|
||||
import create from "./components/create"
|
||||
export default {
|
||||
components: {
|
||||
create
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
select: {
|
||||
page: 1,
|
||||
page_size: 9999,
|
||||
with_relations: ['cover'],
|
||||
table_name: "study_columns",
|
||||
activity_list_id: '',
|
||||
filter: [],
|
||||
},
|
||||
listActivity: [],
|
||||
total: 0,
|
||||
list: [],
|
||||
table: [
|
||||
// {
|
||||
// prop: "activity_list_id",
|
||||
// label: "所属项目",
|
||||
// minWidth: 220,
|
||||
// align: "left",
|
||||
// },
|
||||
{
|
||||
prop: "title",
|
||||
label: "栏目名称",
|
||||
minWidth: 220,
|
||||
align:'left'
|
||||
},
|
||||
|
||||
{
|
||||
prop: "created_at",
|
||||
label: "创建信息",
|
||||
width: 190,
|
||||
formatter: (v1, v2, value) => {
|
||||
return this.$moment(value).format("YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: "updated_at",
|
||||
label: "更新时间",
|
||||
align: "left",
|
||||
width: 190,
|
||||
formatter: (v1, v2, value) => {
|
||||
return this.$moment(value).format("YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async loadActivity() {
|
||||
const res = await activityIndex({
|
||||
page: 1,
|
||||
page_size: 999,
|
||||
});
|
||||
this.listActivity = res.data;
|
||||
},
|
||||
doSearch() {
|
||||
this.select.page = 1;
|
||||
this.load();
|
||||
},
|
||||
|
||||
pageSizeChange(e) {
|
||||
this.select.page_size = e;
|
||||
this.select.page = 1;
|
||||
this.load();
|
||||
},
|
||||
changeActive(e){
|
||||
if(e){
|
||||
this.select.activity_list_id = e
|
||||
this.load()
|
||||
}
|
||||
},
|
||||
async load() {
|
||||
if(!this.select.activity_list_id){
|
||||
this.$message({
|
||||
type:'warning',
|
||||
message:'请先选择项目'
|
||||
})
|
||||
return
|
||||
}
|
||||
const res = await index(this.select);
|
||||
|
||||
this.total = res.total;
|
||||
this.list = this.arrayToTree(res.data);
|
||||
console.log("list",this.list)
|
||||
},
|
||||
arrayToTree(arr, pid = 0) {
|
||||
const result = [];
|
||||
|
||||
arr.forEach(item => {
|
||||
if (item.pid === pid) {
|
||||
const children = this.arrayToTree(arr, item.id);
|
||||
if (children.length) {
|
||||
item.children = children;
|
||||
}
|
||||
result.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
deleteitem(row) {
|
||||
destroy({
|
||||
id: row.id,
|
||||
activity_list_id: row.activity_list_id,
|
||||
table_name: 'study_columns'
|
||||
}).then((res) => {
|
||||
this.load();
|
||||
this.$Message.success("操作成功");
|
||||
});
|
||||
},
|
||||
pageChange(e) {
|
||||
this.select.page = e;
|
||||
this.load();
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.load();
|
||||
},
|
||||
created() {
|
||||
this.loadActivity()
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.selects {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
& > div {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue