政策库添加筛选

This commit is contained in:
熊丽君
2021-08-06 17:58:21 +08:00
parent 55b9550924
commit f419218bca
4 changed files with 159 additions and 75 deletions

View File

@ -76,3 +76,10 @@ export function getPolicyInfo(params) {
params params
}); });
} }
// 根据level查询城市 1->省 2->市 3->合肥
export function getCityByLevel(params) {
return request({
url: '/dict/getCityByLevel',
params
});
}

View File

@ -9,25 +9,25 @@
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" /> <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
<!-- <div class="right-menu"> <div class="right-menu">
<template v-if="device!=='mobile'"> <!-- <template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" /> --> <search id="header-search" class="right-menu-item" />
<!-- <el-tooltip content="源码地址" effect="dark" placement="bottom"> <el-tooltip content="源码地址" effect="dark" placement="bottom">
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" /> <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
</el-tooltip> </el-tooltip>
<el-tooltip content="文档地址" effect="dark" placement="bottom"> <el-tooltip content="文档地址" effect="dark" placement="bottom">
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" /> <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
</el-tooltip> --> </el-tooltip>
<!-- <screenfull id="screenfull" class="right-menu-item hover-effect" /> <screenfull id="screenfull" class="right-menu-item hover-effect" />
<el-tooltip content="布局大小" effect="dark" placement="bottom"> <el-tooltip content="布局大小" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" /> <size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip> </el-tooltip>
</template> </template>-->
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click"> <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
<div class="avatar-wrapper"> <div class="avatar-wrapper">
@ -35,18 +35,21 @@
<i class="el-icon-caret-bottom" /> <i class="el-icon-caret-bottom" />
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<router-link to="/user/profile"> <!-- <router-link to="/user/profile">
<el-dropdown-item>个人中心</el-dropdown-item> <el-dropdown-item>个人中心</el-dropdown-item>
</router-link> </router-link>
<el-dropdown-item @click.native="setting = true"> <el-dropdown-item @click.native="setting = true">
<span>布局设置</span> <span>布局设置</span>
</el-dropdown-item> </el-dropdown-item> -->
<router-link to="/">
<el-dropdown-item>首页</el-dropdown-item>
</router-link>
<el-dropdown-item divided @click.native="logout"> <el-dropdown-item divided @click.native="logout">
<span>退出登录</span> <span>退出登录</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> --> </div>
</div> </div>
</template> </template>

View File

@ -2,7 +2,7 @@
<div class="app-container"> <div class="app-container">
<div>{{ editPage ? '修改' : '添加' }}政策</div> <div>{{ editPage ? '修改' : '添加' }}政策</div>
<el-form <el-form
style="width:50%;margin:15px 0 0 15px" style="width: 50%; margin: 15px 0 0 15px"
label-position="left" label-position="left"
:model="ruleForm" :model="ruleForm"
:rules="rules" :rules="rules"
@ -16,8 +16,8 @@
:disabled="editPage" :disabled="editPage"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="级别" prop="level"> <el-form-item label="城市" prop="ids">
<el-select <!-- <el-select
v-model="ruleForm.level" v-model="ruleForm.level"
placeholder="请选择" placeholder="请选择"
:disabled="editPage" :disabled="editPage"
@ -28,7 +28,15 @@
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
/> />
</el-select> </el-select> -->
<el-cascader
v-model="ruleForm.ids"
:options="levelOptions"
:props="{ expandTrigger: 'hover' }"
:show-all-levels="false"
:disabled="editPage"
>
</el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="归口" prop="attribute"> <el-form-item label="归口" prop="attribute">
<el-select <el-select
@ -51,7 +59,7 @@
placeholder="选择日期" placeholder="选择日期"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
v-model="ruleForm.listDate" v-model="ruleForm.listDate"
style="width: 30%;" style="width: 30%"
:disabled="editPage" :disabled="editPage"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
@ -80,77 +88,81 @@
<script> <script>
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
import { addPolicy, updatePolicy, getPolicyInfo } from '@/api/policy/library'; import { addPolicy, updatePolicy, getPolicyInfo } from '@/api/policy/library';
import { getCityByLevel } from '@/api/policy/library';
export default { export default {
components: { components: {
Editor Editor,
}, },
data() { data() {
return { return {
editPage: false, editPage: false,
ruleForm: { ruleForm: {
title: '', title: '',
level: '', ids: '',
attribute: '', attribute: '',
listDate: '', listDate: '',
source: '', source: '',
text: '' text: '',
}, },
// 归口选项 // 归口选项
attributeOptions: [ attributeOptions: [
{ {
value: 'KJJ', value: 'KJJ',
label: '科技' label: '科技',
}, },
{ {
value: 'JXJ', value: 'JXJ',
label: '经信' label: '经信',
}, },
{ {
value: 'FGW', value: 'FGW',
label: '发改' label: '发改',
}, },
{ {
value: 'OTHER', value: 'OTHER',
label: '其他' label: '其他',
} },
], ],
// 级别选项 // 级别选项
levelOptions: [ levelOptions: [
{ {
value: 1, value: '1',
label: '省级' label: '安徽省',
}, },
{ {
value: 2, value: '2',
label: '市级' label: '地级市',
children: [],
}, },
{ {
value: 3, value: '3',
label: '区级' label: '合肥区县',
} children: [],
},
], ],
rules: { rules: {
title: [{ required: true, message: '请输入政策标题', trigger: 'blur' }], title: [{ required: true, message: '请输入政策标题', trigger: 'blur' }],
level: [{ required: true, message: '请选择级别', trigger: 'change' }], ids: [{ required: true, message: '请选择级别', trigger: 'change' }],
attribute: [ attribute: [
{ required: true, message: '请选择归口', trigger: 'change' } { required: true, message: '请选择归口', trigger: 'change' },
], ],
listDate: [ listDate: [
{ {
// type: 'date',
required: true, required: true,
message: '请选择日期', message: '请选择日期',
trigger: 'change' trigger: 'change',
} },
], ],
source: [{ required: true, message: '请填写来源', trigger: 'blur' }], source: [{ required: true, message: '请填写来源', trigger: 'blur' }],
text: [{ required: true, message: '请填写富文本内容', trigger: 'blur' }] text: [
} { required: true, message: '请填写富文本内容', trigger: 'blur' },
],
},
}; };
}, },
methods: { methods: {
submitForm(formName) { submitForm(formName) {
this.$refs[formName].validate(valid => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
if (this.editPage) { if (this.editPage) {
// 修改 // 修改
@ -169,20 +181,20 @@ export default {
return false; return false;
} }
}); });
} },
// resetForm(formName) { // resetForm(formName) {
// this.$refs[formName].resetFields(); // this.$refs[formName].resetFields();
// } // }
}, },
watch: { watch: {
ruleForm: { ruleForm: {
handler: function() { handler: function () {
this.$nextTick(() => { this.$nextTick(() => {
this.formatRichText(this.ruleForm.downloadUrl); this.formatRichText(this.ruleForm.downloadUrl);
}); });
} },
}, },
deep: true deep: true,
}, },
created() { created() {
let { id } = this.$route.query; let { id } = this.$route.query;
@ -192,7 +204,13 @@ export default {
this.ruleForm = data; this.ruleForm = data;
}); });
} }
} getCityByLevel({ level: 2 }).then(({ data }) => {
this.levelOptions[1].children = data;
});
getCityByLevel({ level: 3 }).then(({ data }) => {
this.levelOptions[2].children = data;
});
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -4,7 +4,7 @@
<div> <div>
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<span>筛选搜索</span> <span>筛选搜索</span>
<div style="float:right"> <div style="float: right">
<el-button type="primary" @click="handleSearchList" size="small"> <el-button type="primary" @click="handleSearchList" size="small">
查询 查询
</el-button> </el-button>
@ -66,6 +66,26 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="城市选择">
<el-cascader
v-model="queryParams.city"
:options="leveOptions"
:props="{ expandTrigger: 'hover', emitPath: false }"
:show-all-levels="false"
>
</el-cascader>
</el-form-item>
<el-form-item label="发布日期">
<el-date-picker
v-model="value1"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
</el-form-item>
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
@ -96,30 +116,30 @@
<el-table-column label="产生" align="center" prop="method" width="150"> <el-table-column label="产生" align="center" prop="method" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
{{ {{
methodOptions.filter(item => item.value == scope.row.method)[0] methodOptions.filter((item) => item.value == scope.row.method)[0]
.label .label
}} }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="政策标题" align="center" prop="title"> <el-table-column label="政策标题" align="center" prop="title">
<template slot-scope="scope"> <!-- <template slot-scope="scope">
<el-link type="primary" :underline="false">{{ <el-link type="primary" :underline="false">{{
scope.row.title scope.row.title
}}</el-link> }}</el-link>
</template> </template> -->
</el-table-column> </el-table-column>
<el-table-column label="级别" align="center" prop="level" width="150"> <el-table-column label="级别" align="center" prop="level" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.level == 1"></span> <span v-if="scope.row.level == 1">安徽</span>
<span v-if="scope.row.level == 2"></span> <span v-if="scope.row.level == 2">地级</span>
<span v-if="scope.row.level == 3">区级</span> <span v-if="scope.row.level == 3">合肥区县</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="归口" align="center" prop="attribute" width="100"> <el-table-column label="归口" align="center" prop="attribute" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
{{ {{
attributeOptions.filter( attributeOptions.filter(
item => item.value == scope.row.attribute (item) => item.value == scope.row.attribute
)[0].label )[0].label
}} }}
</template> </template>
@ -238,7 +258,8 @@ import {
setPolicyLabel, setPolicyLabel,
updatePolicy, updatePolicy,
pushPolicy, pushPolicy,
noPushPolicy noPushPolicy,
getCityByLevel,
} from '@/api/policy/library'; } from '@/api/policy/library';
export default { export default {
name: 'Role', name: 'Role',
@ -248,47 +269,64 @@ export default {
methodOptions: [ methodOptions: [
{ {
value: 1, value: 1,
label: '爬虫' label: '爬虫',
}, },
{ {
value: 2, value: 2,
label: '手动添加' label: '手动添加',
} },
], ],
// 归口选项 // 归口选项
attributeOptions: [ attributeOptions: [
{ {
value: 'KJJ', value: 'KJJ',
label: '科技' label: '科技',
}, },
{ {
value: 'JXJ', value: 'JXJ',
label: '经信' label: '经信',
}, },
{ {
value: 'FGW', value: 'FGW',
label: '发改' label: '发改',
}, },
{ {
value: 'OTHER', value: 'OTHER',
label: '其他' label: '其他',
} },
], ],
// 推送状态选项 // 推送状态选项
statusOptions: [ statusOptions: [
{ {
value: 0, value: 0,
label: '未推送' label: '未推送',
}, },
{ {
value: 1, value: 1,
label: '已推送' label: '已推送',
} },
],
// 城市选择
leveOptions: [
{
value: 'AH',
label: '安徽省',
},
{
value: '2',
label: '地级市',
children: [],
},
{
value: '3',
label: '合肥区县',
children: [],
},
], ],
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10,
}, },
// 遮罩层 // 遮罩层
loading: true, loading: true,
@ -303,9 +341,21 @@ export default {
form: {}, form: {},
arr: [], arr: [],
labelList: [], labelList: [],
policyId: null policyId: null,
value1: '',
}; };
}, },
watch: {
value1(a, b) {
if (a) {
this.queryParams.startTime = a[0];
this.queryParams.endTime = a[1];
} else {
delete this.queryParams.startTime;
delete this.queryParams.endTime;
}
},
},
methods: { methods: {
handleSearchList() { handleSearchList() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
@ -334,7 +384,7 @@ export default {
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id); this.ids = selection.map((item) => item.id);
}, },
// 批量推送 // 批量推送
batchPush() { batchPush() {
@ -349,10 +399,10 @@ export default {
getLabelSetting({ policyId: row.id, pageNum: 1, pageSize: 100 }).then( getLabelSetting({ policyId: row.id, pageNum: 1, pageSize: 100 }).then(
({ data }) => { ({ data }) => {
this.labelList = data.list; this.labelList = data.list;
this.arr = data.list.map(item => this.arr = data.list.map((item) =>
item.labelList item.labelList
? item.labelList.filter(v => v.isHas)[0] ? item.labelList.filter((v) => v.isHas)[0]
? item.labelList.filter(v => v.isHas)[0].id ? item.labelList.filter((v) => v.isHas)[0].id
: '' : ''
: undefined : undefined
); );
@ -374,7 +424,7 @@ export default {
}, },
submitForm() { submitForm() {
if (this.str === '标签设置') { if (this.str === '标签设置') {
let ids = this.arr.filter(item => item); let ids = this.arr.filter((item) => item);
setPolicyLabel({ id: this.policyId, ids }).then(({ message }) => { setPolicyLabel({ id: this.policyId, ids }).then(({ message }) => {
this.msgSuccess(message); this.msgSuccess(message);
this.dialogVisible = false; this.dialogVisible = false;
@ -391,9 +441,9 @@ export default {
this.$confirm('确认删除该数据?', '提示', { this.$confirm('确认删除该数据?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
}) })
.then(function() { .then(function () {
return delPolicy({ ids: [id] }); return delPolicy({ ids: [id] });
}) })
.then(() => { .then(() => {
@ -406,7 +456,7 @@ export default {
pushPolicy({ ids, status: 1 }).then(({ data }) => { pushPolicy({ ids, status: 1 }).then(({ data }) => {
this.$message({ this.$message({
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
message: data message: data,
}); });
this.getList(); this.getList();
}); });
@ -417,10 +467,16 @@ export default {
this.msgSuccess(message); this.msgSuccess(message);
this.getList(); this.getList();
}); });
} },
}, },
created() { created() {
this.getList(); this.getList();
} getCityByLevel({ level: 2 }).then(({ data }) => {
this.leveOptions[1].children = data;
});
getCityByLevel({ level: 3 }).then(({ data }) => {
this.leveOptions[2].children = data;
});
},
}; };
</script> </script>