政策解读的完成。资讯快报页面初始化

This commit is contained in:
熊丽君
2021-07-16 16:45:57 +08:00
parent 0d9c268cdf
commit cc4d1dbaa3
7 changed files with 432 additions and 207 deletions

View File

@ -0,0 +1,34 @@
import request from '@/utils/request';
// 获取政策解读列表
export function getPolicyRead(params) {
return request({
url: '/policy/getPolicyRead',
method: 'get',
params
});
}
// 删除政策解读
export function delRead(params) {
return request({
url: '/policy/delRead',
method: 'get',
params
});
}
// 添加/更新政策解读
export function read(data) {
return request({
url: '/policy/read',
method: 'post',
data
});
}
// 编辑政策解读的数据回显
export function getPolicyReadInfo(params) {
return request({
url: '/policy/getPolicyReadInfo',
method: 'get',
params
});
}

View File

@ -15,12 +15,26 @@ const nestedRouter = {
name: 'unscramble',
meta: { title: '政策解读' }
},
{
path: 'addUnscramble',
component: resolve => require(['@/views/front/unscramble/add'], resolve),
name: 'addUnscramble',
meta: { title: '解读' },
hidden: true
},
{
path: 'expressNews',
component: resolve =>
require(['@/views/front/expressNews/index'], resolve),
name: 'expressNews',
meta: { title: '资讯快报' }
},
{
path: 'addExpressNews',
component: resolve => require(['@/views/front/expressNews/add'], resolve),
name: 'addExpressNews',
meta: { title: '资讯' },
hidden: true
}
]
};

View File

@ -0,0 +1,83 @@
<template>
<div class="app-container">
<div>添加资讯</div>
<el-form
style="width:50%;margin:15px 0 0 15px"
label-position="left"
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="80px"
>
<el-form-item label="资讯标题" prop="title">
<el-input placeholder="请输入" v-model="ruleForm.title"></el-input>
</el-form-item>
<el-form-item label="正文" prop="text">
<editor v-model="ruleForm.text" :min-height="192" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')"
>确定</el-button
>
<!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
</el-form-item>
</el-form>
</div>
</template>
<script>
import Editor from '@/components/Editor';
import { read, getPolicyReadInfo } from '@/api/front/unscramble';
export default {
components: {
Editor
},
data() {
return {
editPage: false,
ruleForm: {
title: '',
text: ''
},
rules: {
title: [{ required: true, message: '请输入资讯标题', trigger: 'blur' }],
text: [{ required: true, message: '请填写富文本内容', trigger: 'blur' }]
}
};
},
methods: {
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
if (this.editPage) {
// 修改
read(this.ruleForm).then(({ message }) => {
this.msgSuccess(message);
});
} else {
// 添加
read(this.ruleForm).then(({ message }) => {
this.msgSuccess(message);
});
}
this.$router.go(-1);
} else {
console.log('error submit!!');
return false;
}
});
}
// resetForm(formName) {
// this.$refs[formName].resetFields();
// }
},
created() {
let { id } = this.$route.query;
if (id) {
this.editPage = true;
getPolicyReadInfo({ readId: id }).then(({ data }) => {
this.ruleForm = data;
});
}
}
};
</script>

View File

@ -1,5 +1,98 @@
<template>
<div>
快报
<div class="app-container">
<el-card shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<el-button style="float: right" @click="handlePage(null)" size="mini">
添加资讯
</el-button>
</el-card>
<el-table style="width: 100%" class="table-container" :data="categoryList">
<el-table-column
label="序号"
align="center"
type="index"
></el-table-column>
<el-table-column label="资讯标题" prop="name" align="center">
<template slot-scope="scope">
<el-link type="primary" :underline="false">{{
scope.row.name
}}</el-link>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button @click="handlePage(scope.row.id)" type="text" size="small"
>编辑</el-button
>
<el-button
@click="handleDelete(scope.row.id)"
type="text"
size="small"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import {
getCategory,
addCategory,
addLabel,
getLabel,
update,
del
} from '@/api/policy/tag';
export default {
data() {
return {
queryParams: {
pageNum: 1,
pageSize: 100
},
categoryList: []
};
},
methods: {
handleSearchList() {
this.queryParams.pageNum = 1;
this.getList();
},
getList() {
getCategory(this.queryParams).then(({ data }) => {
this.categoryList = data.list;
// this.total = data.total
});
},
// 跳转页面
handlePage(id) {
this.$router.push({ path: '/front/addExpressNews', query: { id } });
},
/** 删除按钮操作 */
handleDelete(id) {
this.$confirm('确认删除该分类?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(function() {
return del({ id });
})
.then(() => {
this.getList();
this.msgSuccess('删除成功');
});
}
},
created() {
this.getList();
}
};
</script>
<style lang="scss" scoped>
// .el-tag + .el-tag {
// margin-left: 10px;
// }
</style>

View File

@ -0,0 +1,141 @@
<template>
<div class="app-container">
<div>添加解读</div>
<el-form
style="width:50%;margin:15px 0 0 15px"
label-position="left"
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="80px"
>
<el-form-item label="解读标题" prop="title">
<el-input placeholder="请输入" v-model="ruleForm.title"></el-input>
</el-form-item>
<el-form-item label="归口" prop="attribute">
<el-select v-model="ruleForm.attribute" placeholder="请选择">
<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="发布日期" required>
<el-form-item prop="listDate">
<el-date-picker
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
v-model="ruleForm.listDate"
style="width: 30%;"
></el-date-picker>
</el-form-item>
</el-form-item>
<el-form-item label="来源" prop="source">
<el-input placeholder="请输入" v-model="ruleForm.source"></el-input>
</el-form-item>
<el-form-item label="正文" prop="text">
<editor v-model="ruleForm.text" :min-height="192" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')"
>确定</el-button
>
<!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
</el-form-item>
</el-form>
</div>
</template>
<script>
import Editor from '@/components/Editor';
import { read, getPolicyReadInfo } from '@/api/front/unscramble';
export default {
components: {
Editor
},
data() {
return {
editPage: false,
ruleForm: {
title: '',
attribute: '',
listDate: '',
source: '',
text: ''
},
// 归口选项
attributeOptions: [
{
value: 'KJJ',
label: '科技'
},
{
value: 'JXJ',
label: '经信'
},
{
value: 'FGW',
label: '发改'
},
{
value: 'qita',
label: '其他'
}
],
rules: {
title: [{ required: true, message: '请输入解读标题', trigger: 'blur' }],
attribute: [
{ required: true, message: '请选择归口', trigger: 'change' }
],
listDate: [
{
// type: 'date',
required: true,
message: '请选择日期',
trigger: 'change'
}
],
source: [{ required: true, message: '请填写来源', trigger: 'blur' }],
text: [{ required: true, message: '请填写富文本内容', trigger: 'blur' }]
}
};
},
methods: {
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
if (this.editPage) {
// 修改
read(this.ruleForm).then(({ message }) => {
this.msgSuccess(message);
});
} else {
// 添加
read(this.ruleForm).then(({ message }) => {
this.msgSuccess(message);
});
}
this.$router.go(-1);
} else {
console.log('error submit!!');
return false;
}
});
}
// resetForm(formName) {
// this.$refs[formName].resetFields();
// }
},
created() {
let { id } = this.$route.query;
if (id) {
this.editPage = true;
getPolicyReadInfo({ readId: id }).then(({ data }) => {
this.ruleForm = data;
});
}
}
};
</script>

View File

@ -18,7 +18,7 @@
:inline="true"
@submit.native.prevent
>
<el-form-item label="政策标题">
<el-form-item label="解读标题">
<el-input v-model="queryParams.title" placeholder="请输入" />
</el-form-item>
</el-form>
@ -27,47 +27,53 @@
<el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<el-button class="btn-add" @click="handleAdd" size="mini">
添加分类
<el-button class="btn-add" @click="handlePage(null)" size="mini">
添加解读
</el-button>
</el-card>
<el-table style="width: 100%" class="table-container" :data="categoryList">
<el-table
style="width: 100%"
class="table-container"
:data="unscrambleList"
>
<el-table-column
label="序号"
align="center"
type="index"
></el-table-column>
<el-table-column
label="标签分类"
prop="name"
align="center"
></el-table-column>
<el-table-column label="标签" align="center">
<el-table-column label="解读标题" prop="name" align="center">
<template slot-scope="scope">
<el-button
plain
:disabled="scope.row.name == '类型' ? true : false"
size="mini"
@click="handleAddTag(scope.row.id)"
>添加标签</el-button
>
<el-button plain size="mini" @click="handleLook(scope.row.id)"
>查看标签</el-button
>
<el-link type="primary" :underline="false">{{
scope.row.title
}}</el-link>
</template>
</el-table-column>
<el-table-column label="归口" align="center" prop="attribute">
<template slot-scope="scope">
{{
attributeOptions.filter(
item => item.value == scope.row.attribute
)[0].label
}}
</template>
</el-table-column>
<el-table-column
label="发布日期"
align="center"
prop="listDate"
></el-table-column>
<el-table-column
label="来源"
align="center"
prop="source"
></el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button
@click="editDialog(scope.row)"
type="text"
size="small"
:disabled="scope.row.name == '类型' ? true : false"
<el-button @click="handlePage(scope.row.id)" type="text" size="small"
>编辑</el-button
>
<el-button
@click="handleDelete(scope.row.id)"
:disabled="scope.row.name == '类型' ? true : false"
type="text"
size="small"
>删除</el-button
@ -75,69 +81,10 @@
</template>
</el-table-column>
</el-table>
<!-- 添加修改 -->
<el-dialog :title="str" :visible.sync="addDialog" width="500px">
<el-form :model="form" ref="form" :rules="rules" @submit.native.prevent>
<el-form-item label="名称" prop="name" label-width="80px">
<el-input v-model="form.name"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="addDialog = false"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</el-dialog>
<!-- 查看可删除 -->
<el-dialog title="查看标签" :visible.sync="lookDialog" width="300px">
<div v-for="(tag, index) in tagList" :key="tag.id">
<el-input
style="margin-top:10px;"
v-if="editable[index]"
v-model="tag.name"
:ref="'editableInput' + index"
size="small"
placeholder="请输入标签信息"
@keyup.enter.native="handleEditableInputConfirm(tag, index)"
@change="handleEditableInputConfirm(tag, index)"
@blur="handleEditableInputBlur(tag, index)"
show-word-limit
></el-input>
<div v-else>
<span style="margin-right:10px">{{ index + 1 }}</span>
<el-tag
style="margin-top:10px;"
@click="showEditTagInput(index)"
closable
@close="handleClose(tag.id, index)"
>{{ tag.name }}</el-tag
>
</div>
</div>
<!-- <el-tag
v-for="(tag,index) in tagList"
:key="tag.id"
closable
@click="showEditTagInput(index)"
@close="closeTag(tag, index)"
>
{{tag.name}}
</el-tag> -->
<!-- <div slot="footer" class="dialog-footer">
<el-button @click="lookDialog = false"> </el-button>
<el-button type="primary" @click="handleTag"> </el-button>
</div> -->
</el-dialog>
</div>
</template>
<script>
import {
getCategory,
addCategory,
addLabel,
getLabel,
update,
del
} from '@/api/policy/tag';
import { getPolicyRead, delRead } from '@/api/front/unscramble';
export default {
data() {
return {
@ -145,133 +92,51 @@ export default {
pageNum: 1,
pageSize: 100
},
// total:0,
categoryList: [],
form: {
name: ''
},
addDialog: false,
lookDialog: false,
tagList: [],
// 当前行
rowId: null,
// 弹出层标题
str: '',
// 表单校验
rules: {
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
},
editable: []
unscrambleList: [],
// 归口选项
attributeOptions: [
{
value: 'KJJ',
label: '科技'
},
{
value: 'JXJ',
label: '经信'
},
{
value: 'FGW',
label: '发改'
},
{
value: 'qita',
label: '其他'
}
]
};
},
methods: {
handleSearchList() {
this.queryParams.pageNum = 1;
this.getList();
},
getList() {
getCategory(this.queryParams).then(({ data }) => {
this.categoryList = data.list;
// this.total = data.total
getPolicyRead(this.queryParams).then(({ data }) => {
this.unscrambleList = data.list;
});
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.addDialog = true;
this.str = '添加标签分类';
},
handleAddTag(id) {
this.handleAdd();
this.str = '添加标签';
this.rowId = id;
},
/** 表单重置 */
reset() {
this.form = {
name: ''
};
this.resetForm('form');
},
/** 提交表单 */
submitForm() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.str === '添加标签分类') {
addCategory(this.form).then(({ message }) => {
this.msgSuccess(message);
this.addDialog = false;
this.getList();
});
} else if (this.str === '添加标签') {
addLabel(Object.assign({}, { id: this.rowId }, this.form)).then(
({ message }) => {
this.msgSuccess(message);
this.addDialog = false;
this.getList();
}
);
} else {
update(this.form).then(({ message }) => {
this.msgSuccess(message);
this.addDialog = false;
this.getList();
});
// addLabel(Object.assign({},{id:this.rowId},this.form)).then(({message}) => {
// this.msgSuccess(message);
// this.addDialog = false;
// this.getList();
// });
}
}
});
},
/** 查看标签 */
handleLook(id) {
this.lookDialog = true;
getLabel(Object.assign({}, { id }, this.queryParams)).then(({ data }) => {
this.tagList = data.list;
});
},
// 编辑 input发生改变
handleEditableInputConfirm(item, index) {
if (item.name) {
// 把当前修改的发送
update(item).then(res => {
this.$set(this.editable, index, false);
});
} else {
this.$message({ message: '请输入标签信息', type: 'info' });
}
},
//编辑 input失去焦点
handleEditableInputBlur(item, index) {
this.handleEditableInputConfirm(item, index);
},
// 编辑 input显示
showEditTagInput(index) {
this.$set(this.editable, index, true);
this.$nextTick(_ => {
let editableInput = 'editableInput' + index;
this.$refs[editableInput][0].$refs.input.focus();
});
},
handleClose(id, i) {
del({ id }).then(res => {
this.tagList.splice(i, 1);
});
// this.tagList.splice(this.tagList.indexOf(id), 1);
},
editDialog(row) {
this.form = Object.assign({}, row);
this.addDialog = true;
this.str = '修改标签分类';
// 跳转页面
handlePage(id) {
this.$router.push({ path: '/front/addUnscramble', query: { id } });
},
/** 删除按钮操作 */
handleDelete(id) {
this.$confirm('确认删除该分类?', '提示', {
this.$confirm('确认删除该数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(function() {
return del({ id });
return delRead({ id });
})
.then(() => {
this.getList();
@ -284,8 +149,3 @@ export default {
}
};
</script>
<style lang="scss" scoped>
// .el-tag + .el-tag {
// margin-left: 10px;
// }
</style>

View File

@ -3,7 +3,7 @@
<el-card shadow="never">
<i class="el-icon-tickets"></i>
<span>数据列表</span>
<el-button class="btn-add" @click="handleAdd" size="mini">
<el-button style="float: right" @click="handleAdd" size="mini">
添加分类
</el-button>
</el-card>