Files

427 lines
12 KiB
Vue
Raw Normal View History

2021-07-15 11:56:51 +08:00
<template>
<div class="app-container">
<el-card shadow="never">
<div>
<i class="el-icon-search"></i>
<span>筛选搜索</span>
<div style="float:right">
<el-button type="primary" @click="handleSearchList" size="small">
查询
</el-button>
</div>
</div>
<div style="margin-top: 15px">
<el-form
size="small"
:model="queryParams"
ref="queryForm"
:inline="true"
2021-07-15 11:56:51 +08:00
>
<el-form-item label="政策标题">
<el-input
v-model="queryParams.title"
placeholder="请输入"
clearable
/>
</el-form-item>
<el-form-item label="产出">
<el-select
v-model="queryParams.method"
placeholder="请选择"
clearable
>
<el-option
v-for="item in methodOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="归口">
<el-select
v-model="queryParams.attribute"
placeholder="请选择"
clearable
>
<el-option
v-for="item in attributeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="推送状态">
<el-select
v-model="queryParams.status"
placeholder="请选择"
clearable
>
<el-option
v-for="item in statusOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-form>
</div>
</el-card>
2021-07-15 11:56:51 +08:00
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<div class="btn-add">
<el-button @click="batchPush" size="small">批量推送</el-button>
<el-button @click="handlePage(null)" size="small">添加政策</el-button>
</div>
</el-card>
2021-07-15 11:56:51 +08:00
<!-- v-loading="loading" -->
2021-07-15 11:56:51 +08:00
<el-table
class="table-container"
:data="libraryList"
2021-07-15 11:56:51 +08:00
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" prop="id" width="120" />
<!-- <el-table-column
label="序号"
width="120"
type="index"
:index="indexMethods"
/> -->
<el-table-column label="产生" align="center" prop="method" width="150">
<template slot-scope="scope">
{{
methodOptions.filter(item => item.value == scope.row.method)[0]
.label
}}
</template>
</el-table-column>
<el-table-column label="政策标题" align="center" prop="title">
<template slot-scope="scope">
<el-link type="primary" :underline="false">{{
scope.row.title
}}</el-link>
</template>
</el-table-column>
<el-table-column label="级别" align="center" prop="level" width="150">
2021-07-15 11:56:51 +08:00
<template slot-scope="scope">
<span v-if="scope.row.level == 1">省级</span>
<span v-if="scope.row.level == 2">市级</span>
<span v-if="scope.row.level == 3">区级</span>
</template>
</el-table-column>
<el-table-column label="归口" align="center" prop="attribute" width="100">
<template slot-scope="scope">
{{
attributeOptions.filter(
item => item.value == scope.row.attribute
)[0].label
}}
2021-07-15 11:56:51 +08:00
</template>
</el-table-column>
<el-table-column
label="发布日期"
2021-07-15 11:56:51 +08:00
align="center"
prop="listDate"
2021-07-15 11:56:51 +08:00
width="180"
>
<!-- <template slot-scope="scope">
2021-07-15 11:56:51 +08:00
<span>{{ parseTime(scope.row.createTime) }}</span>
</template> -->
2021-07-15 11:56:51 +08:00
</el-table-column>
<el-table-column label="来源" align="center" prop="source" width="100" />
2021-07-15 11:56:51 +08:00
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<p>
<el-button size="small" type="text" @click="open(scope.row)"
>标签管理</el-button
>
<el-button size="small" type="text" @click="openTime(scope.row)"
>截止时间</el-button
>
</p>
<p>
<el-button
size="small"
type="text"
@click="handlePage(scope.row.id)"
>编辑</el-button
>
<el-button
size="small"
type="text"
@click="handleDelete(scope.row.id)"
>删除</el-button
>
</p>
</template>
</el-table-column>
<el-table-column label="推送" align="center" prop="roleName" width="150">
2021-07-15 11:56:51 +08:00
<template slot-scope="scope">
<el-button
size="small"
:disabled="scope.row.status === 1"
2021-07-15 11:56:51 +08:00
type="text"
@click="push([scope.row.id])"
>推送</el-button
2021-07-15 11:56:51 +08:00
>
<el-button
size="small"
:disabled="scope.row.status === 0"
2021-07-15 11:56:51 +08:00
type="text"
@click="revoke(scope.row.id)"
>撤销</el-button
2021-07-15 11:56:51 +08:00
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog :title="str" :visible.sync="dialogVisible" width="20%">
<el-form ref="form" :model="form" label-width="80px">
<section v-show="str === '标签设置'">
<el-form-item
:label="item.name"
v-for="(item, index) in labelList"
:key="item.id"
2021-07-15 11:56:51 +08:00
>
<!-- v-if="item.labelList" -->
<el-select v-model="arr[index]" placeholder="请选择" clearable>
<el-option
v-for="i in item.labelList"
:key="i.id"
:label="i.name"
:value="i.id"
/>
</el-select>
</el-form-item>
</section>
<section v-show="str === '截止时间设置'">
<el-form-item label="截止时间">
<el-date-picker
type="datetime"
placeholder="选择日期"
value-format="yyyy-MM-dd HH:mm:ss"
v-model="form.cutOffTime"
></el-date-picker>
</el-form-item>
</section>
2021-07-15 11:56:51 +08:00
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
2021-07-15 11:56:51 +08:00
<el-button type="primary" @click="submitForm"> </el-button>
</span>
2021-07-15 11:56:51 +08:00
</el-dialog>
</div>
</template>
<script>
import {
getPolicy,
delPolicy,
getLabelSetting,
setPolicyLabel,
updatePolicy,
pushPolicy,
noPushPolicy
} from '@/api/policy/library';
2021-07-15 11:56:51 +08:00
export default {
name: 'Role',
data() {
return {
// 产出选项
methodOptions: [
2021-07-15 11:56:51 +08:00
{
value: 1,
label: '爬虫'
2021-07-15 11:56:51 +08:00
},
{
value: 2,
label: '手动添加'
}
],
// 归口选项
attributeOptions: [
{
value: 'KJJ',
label: '科技'
2021-07-15 11:56:51 +08:00
},
{
value: 'JXJ',
label: '经信'
2021-07-15 11:56:51 +08:00
},
{
value: 'FGW',
label: '发改'
},
{
value: 'qita',
label: '其他'
}
],
// 推送状态选项
statusOptions: [
{
value: 0,
label: '未推送'
2021-07-15 11:56:51 +08:00
},
{
value: 1,
label: '已推送'
2021-07-15 11:56:51 +08:00
}
],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10
2021-07-15 11:56:51 +08:00
},
// 遮罩层
loading: true,
libraryList: [],
// 总条数
total: 0,
// 选中数组
ids: [],
// 标签管理弹窗状态
dialogVisible: false,
str: '',
2021-07-15 11:56:51 +08:00
form: {},
arr: [],
labelList: [],
policyId: null
2021-07-15 11:56:51 +08:00
};
},
methods: {
handleSearchList() {
2021-07-15 11:56:51 +08:00
this.queryParams.pageNum = 1;
this.getList();
},
getList() {
getPolicy(this.queryParams).then(({ data }) => {
this.libraryList = data.list;
this.total = data.total;
});
},
// 处理序号=》倒序
// indexMethods(index) {
// console.log(index);
// if (this.libraryList.length < 10) {
// return this.libraryList.length - index;
// } else {
// return (
// this.libraryList.length - (this.queryParams.pageNum - 1) * 10 - index
// );
// }
// },
// 跳转页面
handlePage(id) {
this.$router.push({ path: '/policy/add', query: { id } });
2021-07-15 11:56:51 +08:00
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id);
2021-07-15 11:56:51 +08:00
},
// 批量推送
batchPush() {
if (this.ids == null || this.ids.length < 1)
return this.msgInfo('请选择要操作的数据');
this.push(this.ids);
2021-07-15 11:56:51 +08:00
},
open(row) {
this.str = '标签设置';
this.dialogVisible = true;
this.policyId = row.id;
getLabelSetting({ policyId: row.id, pageNum: 1, pageSize: 100 }).then(
({ data }) => {
this.labelList = data.list;
this.arr = data.list.map(item =>
item.labelList
? item.labelList.filter(v => v.isHas)[0]
? item.labelList.filter(v => v.isHas)[0].id
: ''
: undefined
);
// this.arr = data.list.map(item => {
// // return item.labelList ? item.labelList.map(v => v.id) : undefined;
// return item.labelList
// ? item.labelList.filter(v => v.isHas)[0]
// ? item.labelList.filter(v => v.isHas)[0].id
// : ''
// : undefined;
// });
}
);
2021-07-15 11:56:51 +08:00
},
openTime(row) {
this.str = '截止时间设置';
this.dialogVisible = true;
this.form = row;
2021-07-15 11:56:51 +08:00
},
submitForm() {
if (this.str === '标签设置') {
let ids = this.arr.filter(item => item);
setPolicyLabel({ id: this.policyId, ids }).then(({ message }) => {
this.msgSuccess(message);
this.dialogVisible = false;
2021-07-15 11:56:51 +08:00
});
} else {
updatePolicy(this.form).then(({ message }) => {
this.msgSuccess(message);
this.dialogVisible = false;
2021-07-15 11:56:51 +08:00
});
}
},
// 删除
handleDelete(id) {
this.$confirm('确认删除该数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
2021-07-15 11:56:51 +08:00
.then(function() {
return delPolicy({ ids: [id] });
2021-07-15 11:56:51 +08:00
})
.then(() => {
this.getList();
this.msgSuccess('删除成功');
});
},
// 推送
push(ids) {
pushPolicy({ ids, status: 1 }).then(({ data }) => {
this.$message({
dangerouslyUseHTMLString: true,
message: data
2021-07-15 11:56:51 +08:00
});
this.getList();
});
},
// 撤销
revoke(id) {
noPushPolicy({ id, status: 0 }).then(({ message }) => {
this.msgSuccess(message);
this.getList();
});
2021-07-15 11:56:51 +08:00
}
},
created() {
this.getList();
2021-07-15 11:56:51 +08:00
}
};
</script>