Commit 12eedc4b authored by Zhang Xiaojie's avatar Zhang Xiaojie

Merge branch 'dev' of gitlab.33.cn:CassiniatSaturn/fns_backend into dev

parents 409a5640 b66567b0
......@@ -45,6 +45,7 @@
import Vue, { PropType } from 'vue'
import vue2Dropzone from 'vue2-dropzone'
import 'vue2-dropzone/dist/vue2Dropzone.min.css'
import FileService from '@/service/FileService/index'
import { Editor } from '@tiptap/vue-2'
export default Vue.extend({
......@@ -60,10 +61,11 @@ export default Vue.extend({
confirmLoading: false,
imageSrc: '',
dropzoneOptions: {
url: '/api/upload',
url: '/proxyApi/api/v1/image/upload',
thumbnailWidth: 200,
maxFilesize: 200,
dictDefaultMessage: '拖动/选择文件上传图片(200M以内)',
paramName: 'uploadFile'
},
tab: 1,
}
......@@ -79,7 +81,8 @@ export default Vue.extend({
showModal() {
this.visible = true
},
vfileUploaded(file: File | Blob) {
vfileUploaded(file: File | Blob, res: { data: string }) {
this.imageSrc = new FileService().getImageSrc(res.data)
/** Here is where you get your URL/Base64 string or what ever.*/
},
cursorToEnd(){
......
......@@ -105,4 +105,4 @@ export default Vue.extend({
margin-top: 8px;
color: #666;
}
</style>
\ No newline at end of file
</style>
......@@ -73,4 +73,4 @@ export default Vue.extend({
height: 0;
font-style: italic;
}
</style>
\ No newline at end of file
</style>
......@@ -39,7 +39,7 @@ export default Vue.extend({
startTime = firstM._d.getTime()
endTime = secondM._d.getTime()
}
console.log(startTime)
this.$emit('getNewTime',startTime,endTime)
},
}
......
......@@ -4,7 +4,8 @@ const columns:Array<column>=
{
title:'发布时间',
align:'center',
dataIndex:'time'
dataIndex:'time',
scopedSlots: { customRender: 'time' },
},
{
title:'消息标题',
......@@ -20,12 +21,14 @@ const columns:Array<column>=
{
title:'显示类型',
align:'center',
dataIndex:'type'
dataIndex:'type',
scopedSlots: { customRender: 'type' },
},
{
title:'状态',
align:'center',
dataIndex:'state'
dataIndex:'state',
scopedSlots: { customRender: 'status' },
},
{
title:'操作',
......
......@@ -3,7 +3,8 @@ const columns:Array<column>=[
{
title: '发布时间',
align:'center',
dataIndex: 'time',
dataIndex: 'created_at',
scopedSlots: { customRender: 'created_at' },
},
{
title: '资讯标题',
......@@ -13,12 +14,13 @@ const columns:Array<column>=[
{
title: '咨询分类',
align:'center',
dataIndex: 'type',
dataIndex: 'article_type',
scopedSlots: { customRender: 'type' },
},
{
title: '作者名称',
align:'center',
dataIndex: 'author',
dataIndex: 'writer',
},
{
title: '新闻内容',
......@@ -29,7 +31,8 @@ const columns:Array<column>=[
{
title: '状态',
align:'center',
dataIndex: 'state',
dataIndex: 'article_status',
scopedSlots: { customRender: 'status' },
},
{
title: '操作',
......
export default [
{
title: '创建日期',
align: 'center',
dataIndex: 'time',
},
{
title: '所属一级分行',
align: 'center',
dataIndex: 'title',
dataIndex: 'first_branch',
},
{
title: '所属二级分行',
align: 'center',
dataIndex: 'content',
scopedSlots: { customRender: 'content' },
dataIndex: 'second_branch',
},
{
title: '所属一级支行',
align: 'center',
dataIndex: 'state',
dataIndex: 'first_sub_branch',
},
{
title: '所属二级支行',
align: 'center',
dataIndex: 'action',
dataIndex: 'second_sub_branch',
},
{
title: '详细地址',
align: 'center',
dataIndex: 'action',
dataIndex: 'location',
},
{
title: '经度',
align: 'center',
dataIndex: 'longitude',
},
{
title: '纬度',
align: 'center',
dataIndex: 'latitude',
},
{
title: '是否营业',
align: 'center',
dataIndex: 'action',
dataIndex: 'is_normal_work',
scopedSlots: { customRender: 'is_normal_work' },
},
{
title: '营业时间',
align: 'center',
dataIndex: 'action',
dataIndex: 'opening_hours',
scopedSlots: { customRender: 'opening_hours' },
},
{
title: '备注',
title: '不营业原因',
align: 'center',
dataIndex: 'action',
dataIndex: 'note',
scopedSlots: { customRender: 'note' },
},
{
title: '操作',
......
......@@ -95,6 +95,18 @@ export default {
return '已发布'
}
},
filterWorkDay(weekend_status: number){
const silly = '周一至周五'
if(weekend_status === 0){
return silly;
}else if(weekend_status === 1){
return silly + ', 周六'
} else if(weekend_status === 2){
return silly + ', 周日'
} else if(weekend_status === 3){
return '周一至周日'
}
}
} as {
[key: string]: (...args: any) => any
}
......@@ -6,6 +6,7 @@ import 'ant-design-vue/dist/antd.css'
import 'tailwindcss/tailwind.css'
import 'element-ui/lib/theme-chalk/index.css'
import filter from './filter'
import moment from 'moment'
Vue.config.productionTip = false
......
import baseAxios from '../index'
import { iOutLetDetail } from './types'
export default class AddressService {
prefix: string
private prefix: string
static instance: AddressService
max_len_gps: number
private max_len_gps: number
static getInstance() {
if (!AddressService.instance) {
AddressService.instance = new AddressService()
......@@ -55,4 +56,38 @@ export default class AddressService {
})
}
}
getOutlet(data: { outlet_name: string }) {
return baseAxios<iOutLetDetail>({
url: '/address/getOutlet',
method: 'post',
data,
})
}
note(id: number) {
return baseAxios({
url: '/address/note',
method: 'post',
data: {
id,
},
})
}
update(data: {
id: number
is_normal_work: boolean
lat_lon: string
location: string
note: string
opening_hours: string
weekend_status: number
}) {
return baseAxios({
url: '/address/update',
method: 'post',
data,
})
}
}
export interface iOutLetDetail {
id: number
city_name: string
is_normal_work: boolean
latitude: string
location: string
longitude: string
opening_hours: string
outlet_name: string
region_name: string
}
import baseAxios from '../index'
export default class NewsService {
static instance: NewsService
static getInstance() {
if (!NewsService.instance) {
NewsService.instance = new NewsService()
}
return NewsService.instance
}
/**
* 新增资讯
* @param data
* @returns
*/
addArticle(data: {
article_type: number,
content: string,
desc: string,
file_name: string,
title: string,
writer: string
}) {
return baseAxios({
url: '/article/admin/add',
method: 'post',
data,
})
}
/**
* 删除新闻文章
* @param data
* @returns
*/
delArticle(params: { uuid: string }) {
return baseAxios({
url: '/article/admin/delete/news',
method: 'delete',
params,
})
}
/**
* 删除政策文章
* @param data
* @returns
*/
delPolicyArticle(params: { uuid: string }) {
return baseAxios({
url: '/article/admin/delete/policy',
method: 'delete',
params,
})
}
/**
* 查询列表
* @param data
* @returns
*/
articleList(data: {
article_status: number|string,
article_type: number|undefined,
end_time: number|undefined,
limit: number,
offset: number,
start_time: number|undefined
}) {
return baseAxios({
url: '/article/admin/list',
method: 'post',
data,
})
}
/**
* 修改资讯
* @param data
* @returns
*/
editArticle(data: {
article_type: number,
content: string,
desc: string,
file_name: string,
title: string,
writer: string,
uuid: string
}) {
return baseAxios({
url: '/article/admin/modify',
method: 'post',
data,
})
}
/**
* 修改资讯状态
* @param data
* @returns
*/
modifyStatus(data: {
uuid: string,
article_status: number,
article_type: number|undefined
}) {
return baseAxios({
url: '/article/admin/modify/status',
method: 'post',
data,
})
}
/**
* 模糊查询新闻标题
* @param data
* @returns
*/
searchByTitle(data: {
title: string
}) {
return baseAxios({
url: '/article/query/fuzzy/news',
method: 'get',
params: data,
})
}
/**
* 模糊查询政策文章
* @param data
* @returns
*/
searchByPolicy(data: {
title: string
}) {
return baseAxios({
url: '/article/query/fuzzy/policy',
method: 'get',
params: data,
})
}
/**
* 查询新闻
* @param data
* @returns
*/
searchNews(uuid: string) {
return baseAxios({
url: '/article/query/news',
method: 'get',
params: {
uuid
},
})
}
/**
* 查询新闻列表
* @param data
* @returns
*/
searchList(data: {
limit: number,
offset: number
}) {
return baseAxios({
url: '/article/query/news/list',
method: 'post',
data,
})
}
/**
* 查询政策文章
* @param data
* @returns
*/
searchPolicy(uuid: string) {
return baseAxios({
url: '/article/query/policy',
method: 'get',
params: {
uuid
},
})
}
/**
* 查询政策列表
* @param data
* @returns
*/
searchPolicyList(data: {
limit: number,
offset: number
}) {
return baseAxios({
url: '/article/query/policy/list',
method: 'post',
data,
})
}
}
import baseAxios from '../index'
export default class NotifyService {
static instance: NotifyService
static getInstance() {
if (!NotifyService.instance) {
NotifyService.instance = new NotifyService()
}
return NotifyService.instance
}
/**
* 新增消息
* @param data
* @returns
*/
addNotify(data: {
content: string,
notify_type: number,
title: string
}) {
return baseAxios({
url: '/notify/admin/add',
method: 'post',
data,
})
}
/**
* 删除消息
* @param uuid
* @returns
*/
removeNotify(uuid: string) {
return baseAxios({
url: '/notify/admin/delete',
method: 'delete',
params: {
uuid
},
})
}
/**
* 消息列表
* @param data
* @returns
*/
notifyList(data: {
end_time?: number,
limit: number,
notify_status: number,
notify_type: number,
offset: number,
start_time?: number
}) {
return baseAxios({
url: '/notify/admin/list',
method: 'post',
data,
})
}
/**
* 修改消息
* @param data
* @returns
*/
modifyNotify(data: {
content: string,
notify_type: number,
title: string,
uuid: string
}) {
return baseAxios({
url: '/notify/admin/modify',
method: 'post',
data,
})
}
/**
* 修改消息状态
* @param data
* @returns
*/
modifyNotifyStatus(data: {
notify_status: number,
uuid: string
}) {
return baseAxios({
url: '/notify/admin/modify/status',
method: 'post',
data,
})
}
}
......@@ -157,33 +157,38 @@ function parseJSYHSheet(Sheet: any) {
/* 只能解析xlsx文件 accpet设置 .xlsx */
export const handle建设银行excelFileChange = (e: Event) => {
const files = (e.target as HTMLInputElement).files
if (files && files.length !== 0) {
const f = files[0]
var reader = new FileReader()
reader.onload = function (e) {
var data = new Uint8Array(
((e.target as any).result as unknown) as ArrayBufferLike,
)
var workbook = xlsx.read(data, { type: 'array' })
/* DO SOMETHING WITH workbook HERE */
return new Promise((resolve) => {
const files = (e.target as HTMLInputElement).files
if (files && files.length !== 0) {
const f = files[0]
var reader = new FileReader()
reader.onload = function (e) {
var data = new Uint8Array(
((e.target as any).result as unknown) as ArrayBufferLike,
)
var workbook = xlsx.read(data, { type: 'array' })
/* DO SOMETHING WITH workbook HERE */
const Sheets = workbook.Sheets
const SheetsKeys = Object.keys(Sheets)
if (SheetsKeys.length !== 0) {
const list = (parseJSYHSheet(Sheets[SheetsKeys[0]]) as unknown) as any[]
const locationList = getAddressList((list as unknown) as any)
console.log(JSON.stringify(locationList))
getAddressLalonObj(locationList).then((addressLalonObj) => {
list.forEach((data) => {
data.la_lon = addressLalonObj[data.location]
const Sheets = workbook.Sheets
const SheetsKeys = Object.keys(Sheets)
if (SheetsKeys.length !== 0) {
const list = (parseJSYHSheet(
Sheets[SheetsKeys[0]],
) as unknown) as any[]
const locationList = getAddressList((list as unknown) as any)
console.log(JSON.stringify(locationList))
getAddressLalonObj(locationList).then((addressLalonObj) => {
list.forEach((data) => {
data.la_lon = addressLalonObj[data.location]
})
console.log(list, 'show list')
resolve(list)
})
console.log(list, 'show list')
})
} else {
throw new Error('excel文件无Sheet')
} else {
throw new Error('excel文件无Sheet')
}
}
reader.readAsArrayBuffer(f)
}
reader.readAsArrayBuffer(f)
}
})
}
function getDate(day: Date,isSmaller:Boolean) {
export function getDate(day: Date,isSmaller:Boolean) {
let mm:Number,dd:Number
if(isSmaller){
mm = day.getMonth() + 1 < 10 ? + (day.getMonth()+1): day.getMonth()+1 ;
......
import moment from 'moment'
import moment, { Moment } from 'moment'
export default function transferTimeStampToMoment(
startTime: number,
......@@ -7,3 +7,36 @@ export default function transferTimeStampToMoment(
if (startTime && endTime) return [moment(startTime), moment(endTime)]
else return []
}
// 早上9:00 下午17:00
export function transfterStrToDate(str: string) {
const arr = str.split(' ')
if (arr.length === 2) {
let [start, end] = arr
start = start.replace(':', ':').replace('早上', '').replace('下午', '')
end = end.replace(':', ':').replace('早上', '').replace('下午', '')
const d = new Date()
start = `${d.getFullYear()} ${d.getMonth() + 1} ${d.getDate()} ${start}`
end = `${d.getFullYear()} ${d.getMonth() + 1} ${d.getDate()} ${end}`
const startDate = new Date(start)
const endDate = new Date(end)
return [startDate, endDate]
} else {
return undefined
}
}
export function getOpeningHoursFromMoment(start: Moment, end: Moment) {
const h1 = start.hour()
const h2 = end.hour()
const c1 = h1 <= 12 ? '早上' : '下午'
const c2 = h2 <= 12 ? '早上' : '下午'
return `${c1}${start.format('HH:mm')} ${c2}${end.format('HH:mm')}`
}
export function getWeekendStatusFromArr(arr: string[]) {
let count = 0
arr.indexOf('6') !== -1 && (count += 1)
arr.indexOf('7') !== -1 && (count += 2)
return count
}
......@@ -219,6 +219,7 @@ export default Vue.extend({
const ret = await UserService.getInstance().login({
is_admin: isAdminAccount,
use_pwd: true,
phone: isAdminAccount ? undefined : name,
pwd,
});
console.log(ret);
......
......@@ -3,8 +3,8 @@
<p class=" text-2xl font-bold mb-5">消息管理</p>
<!-- 消息分类 -->
<span class=" mr-3">消息分类</span>
<a-select :default-value="msgType[0]" style="width: 120px; margin-right:10px;">
<a-select-option v-for="(type,i) in msgType" :key="i">{{type}}</a-select-option>
<a-select :default-value="1" style="width: 120px; margin-right:10px;" v-model="types">
<a-select-option v-for="type in msgType" :key="type.value">{{ type.label }}</a-select-option>
</a-select>
<!-- 操作 -->
<a-button type="primary" style=" margin-right:10px;" @click="query">查询</a-button>
......@@ -12,12 +12,12 @@
<!-- 发布弹窗 -->
<a-modal v-model="show" title="发布消息" :centered="true" footer="">
<a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" ref="ruleForm" :rules="rules">
<a-form-model-item label="模板名称" :required="true" prop="module">
<!-- <a-form-model-item label="模板名称" :required="true" prop="module">
<a-input v-model="form.module" placeholder="请输入模板名称" style="width: 200px"/>
</a-form-model-item>
</a-form-model-item> -->
<a-form-model-item label="消息分类" :required="true" prop="type">
<a-select :default-value="msgType[0]" style="width: 200px" v-model="form.type">
<a-select-option v-for="(type,i) in msgType" :key="i">{{type}}</a-select-option>
<a-select style="width: 200px" v-model="form.type" placeholder="请选择分类" >
<a-select-option v-for="type in msgType" :key="type.value">{{type.label}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="消息标题" :required="true" prop="title" >
......@@ -38,23 +38,46 @@
<p class=" text-base">{{current.content}}</p>
</a-modal>
<!-- 消息列表 -->
<a-table :columns="columns" :data-source="list" style=" text-align: center; margin-top:40px;" bordered >
<a-table
:columns="columns"
:data-source="list"
style=" text-align: center; margin-top:40px;"
bordered
:pagination="pagination"
@change="tableChange">
<!-- 发布时间 -->
<span slot="time" slot-scope="text,record">
{{ record.created_at | format }}
</span>
<!-- 新闻内容 -->
<span slot="content" slot-scope="text,record">
<a href="javascript:;" @click="showModal(record)">查看</a>
</span>
<!-- 显示类型 -->
<span slot="type" slot-scope="text,record">
{{ record.notify_type === 1 ? '滚动通知' : '系统消息' }}
</span>
<!-- 状态 -->
<span slot="status" slot-scope="text,record">
{{ record.notify_status === 1 ? '待发布' : '已发布' }}
</span>
<!-- 操作 -->
<span slot="action" slot-scope="text,record">
<a v-if="record.state=='已下架'"
@click="add(record.key)">
<a v-if="record.notify_status==1"
@click="add(record)">
上架
</a>
<a v-else
@click="remove(record.key)">
@click="remove(record)">
下架
</a>
<a-divider type="vertical" />
<a @click="onDelete(record.key)">
<a v-show="record.notify_status === 1"
@click="onEdit(record)">
编辑
</a>
<a-divider v-show="record.notify_status === 1" type="vertical" />
<a @click="onDelete(record)">
删除
</a>
</span>
......@@ -76,14 +99,22 @@
<script lang="ts">
import Vue from 'vue';
import { columns } from '@/const/columns/msgColumns'
import { FormModel } from 'ant-design-vue'
import { FormModel, message } from 'ant-design-vue'
import { msg } from '@/types/msg'
import { msgList } from '@/mock/index'
import { modal } from './const'
import timerange from '@/components/TimePicker/index.vue'
import Notify from '@/service/Notify/index'
import Filter from '@/filter/index'
const notify = new Notify()
export default Vue.extend({
components:{ timerange },
filters: {
format(value: string) {
return Filter.formatDate(value)
}
},
computed:{
columns(){
return columns
......@@ -93,46 +124,108 @@ export default Vue.extend({
msgType:{
type:Array,
default(){
return ['滚动通知','系统消息']
return [
{
label: '滚动通知',
value: 1
},
{
label: '系统消息',
value: 2
}
]
}
}
},
created() {
this.getList()
},
methods:{
getList() {
console.log(this.form.type)
notify.notifyList({
limit: this.pagination.defaultPageSize,
offset: (this.pagination.current - 1) * this.pagination.defaultPageSize,
notify_status: 0,
notify_type: this.types
}).then(res => {
this.list = res.data.items
this.pagination.total = res.data.total
})
},
tableChange(e: {current: number}) {
this.pagination.current = e.current
this.getList()
},
add(record:any){
this.type = modal.on
this.showActionModal = true
this.uuid = record.uuid
this.title = '上架消息'
this.text = '确定上架该消息吗?'
},
remove(record:any){
this.type = modal.off
this.showActionModal = true
this.uuid = record.uuid
this.title = '下架消息'
this.text = '确定下架该消息吗?'
},
onEdit(record: any) {
this.form = {
title: record.title,
content: record.content,
type: record.notify_type
}
this.btnType = 'edit'
this.uuid = record.uuid
this.show = true
},
onDelete(record:any){
this.type = modal.delete
this.showActionModal = true
this.uuid = record.uuid
this.title = '删除消息'
this.text = '确定删除该消息吗?'
},
setStatus(status: number, msg: string) {
notify.modifyNotifyStatus({
notify_status: status,
uuid: this.uuid
}).then(res => {
if (res.code === 200) {
message.success(msg)
this.getList()
}
})
},
removeNotify() {
notify.removeNotify(this.uuid).then(res => {
if (res.code === 200) {
message.success('删除成功')
this.getList()
}
})
},
onOk(record:any){
if( this.type == modal.on){
this.setStatus(2, '发布成功')
} else if( this.type == modal.off){
this.setStatus(1, '下架成功')
} else if( this.type == modal.delete){
this.removeNotify()
this.pagination.current = 1
}
this.showActionModal = false
},
query(){
this.getList()
},
publish(){
this.resetForm()
this.show = true
this.btnType = 'add'
},
showModal(current:object){
this.visible = true
......@@ -141,12 +234,43 @@ export default Vue.extend({
handleOk(){
this.visible = false
},
addNotice() {
notify.addNotify({
content: this.form.content,
notify_type: this.form.type,
title: this.form.title
}).then(res => {
if (res.code === 200) {
message.success('新增成功')
this.show = false
this.getList()
}
})
},
editNotice() {
notify.modifyNotify({
content: this.form.content,
notify_type: this.form.type,
title: this.form.title,
uuid: this.uuid
}).then(res => {
if (res.code === 200) {
message.success('编辑成功')
this.show = false
this.getList()
}
})
},
onSubmit() {
(this.$refs.ruleForm as FormModel).validate(valid => {
if (valid) {
this.show = false
if (this.btnType === 'add') {
this.addNotice()
} else {
this.editNotice()
}
} else {
console.log('error submit!!');
message.error('请先填写表单内容')
return false;
}
});
......@@ -157,23 +281,14 @@ export default Vue.extend({
Object.keys(this.form).forEach(m=>{
this.form[m as formtype] = ''
})
},
edit(record:msg){
let form = this.form
type msgtype = keyof msg
type formtype = keyof typeof form
Object.keys(this.form).map(m=>{
this.form[m as formtype] = record[m as msgtype ]
})
this.show = true
this.form['type'] = 1
},
},
data(){
const list = msgList
const rules={
module: [
{ required: true, message: '请输入模板名称', trigger: 'blur' },
],
// module: [
// { required: true, message: '请输入模板名称', trigger: 'blur' },
// ],
type: [
{ required: true, message: '请选择消息分类', trigger: 'blur' },
],
......@@ -195,14 +310,22 @@ export default Vue.extend({
labelCol: { span: 4 },
wrapperCol: { span: 14 },
form: {
name: '',
// name: '',
title:'',
type:'',
type: 1,
content:'',
module:''
// module:''
},
rules,
list
uuid: "",
types: 1,
list: [],
pagination: {
current: 1,
defaultPageSize: 10,
total: 0
},
btnType: 'add'
}
}
})
......
<template>
<div>
<p class=" text-2xl font-bold mb-5 ">{{title}}</p>
<p class=" text-gray-400">发布时间:{{time}} <span class=" ml-2">作者:{{name}}</span></p>
<p class="text-left p-5">{{content}}</p>
<p class=" text-2xl font-bold mb-5 ">{{ title }}</p>
<p class=" text-gray-400">发布时间:{{ time | format }} <span class=" ml-2">作者:{{ name }}</span></p>
<div class="text-left p-5" v-html="content"></div>
<!-- <p class="text-left p-5">{{content}}</p> -->
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import News from '@/service/News/index'
import Filter from '@/filter/index'
const news = new News()
export default Vue.extend({
data(){
return{
title:'银保监会、人民银行联合出台现金管理类理财产品监管规则',
time:'2021-07-01',
name:'丁洁',
content:'“中国冰雪大篷车”是国家体育总局深入推进冰雪运动“南展西扩东进”战略,落实“带动三亿人参与冰雪运动”目标的重要群众性活动之一。“中国冰雪大篷车”将在为期半年的时间里,深入全国30余个城市,举办100场线下活动,同时结合持续的线上互动,以创新的体验模式、丰富的活动内容和众多的展示渠道,普及冰雪运动常识,推广冰雪运动理念,让普通大众在家门口就能感受冰雪运动的乐趣。'
title:'',
time:'',
name:'',
content:''
}
},
filters: {
format(value: string) {
return Filter.formatDate(value)
}
},
methods: {
getDetails() {
const type = this.$route.query.type
const uuid = this.$route.query.key as string
const request = +type === 1 ? 'searchPolicy' : 'searchNews'
news[request](uuid).then(res => {
console.log(res)
const { data } = res
this.time = data.created_at
this.name = data.writer
this.content = data.content
this.title = data.title
})
}
},
created() {
this.getDetails()
}
})
......
......@@ -5,37 +5,61 @@
<a-input placeholder="标题模糊搜索" v-model="searchPageReqParams.title" style="width: 150px; margin-right:10px;"/>
<!-- timepicker -->
<span class=" font-semibold">注册时间:</span>
<timerange class=" mr-3"
<timerange class=" mr-3" :startTime="searchPageReqParams.start_time" :endTime="searchPageReqParams.end_time"
@getNewTime="getNewTime"/>
<!-- 咨询分类 -->
<span class=" mr-3">资讯分类</span>
<a-select :default-value="newsType[0]" style="width: 120px; margin-right:10px;" v-model="searchPageReqParams.type">
<a-select-option v-for="(type,i) in newsType" :key="i">
{{type}}
<a-select :default-value="newsType[0]" style="width: 120px; margin-right:10px;" v-model="searchPageReqParams.article_type">
<a-select-option v-for="type in newsType" :key="type.value">
{{type.label}}
</a-select-option>
</a-select>
<!-- 操作 -->
<a-button type="primary" style=" margin-right:10px;" @click="query">查询</a-button>
<a-button type="primary" style=" margin-right:10px;" @click="reset">重置</a-button>
<a-button type="primary" @click="release">发布</a-button>
<a-button type="primary" @click="release(null, null)">发布</a-button>
<!-- 资讯列表 -->
<a-table :columns="columns" :data-source="list" style=" text-align: center; margin-top:40px;" bordered >
<a-table
:columns="columns"
:data-source="list"
rowKey="columns"
style=" text-align: center; margin-top:40px;"
bordered
:pagination="pagination"
@change="tableChange">
<!-- 发布时间 -->
<span slot="created_at" slot-scope="text,record">
{{ record.created_at | format }}
</span>
<!-- 新闻内容 -->
<span slot="content" slot-scope="text,record">
<a @click="toDetail(record.key)">查看</a>
<a @click="toDetail(record.uuid, searchPageReqParams.article_type)">查看</a>
</span>
<!-- 新闻状态 -->
<span slot="status" slot-scope="text,record">
{{ record.article_status === 2 ? '已发布' : '未发布' }}
</span>
<!-- 新闻分类 -->
<span slot="type">
{{ searchPageReqParams.article_type === 2 ? '新闻' : '政策' }}
</span>
<!-- 操作 -->
<span slot="action" slot-scope="text,record">
<a v-if="record.state=='已下架'"
@click="add(record.key)">
<a v-if="record.article_status==1"
@click="add(record)">
上架
</a>
<a v-else
@click="remove(record.key)">
<a v-else-if="record.article_status === 2"
@click="remove(record)">
下架
</a>
<a-divider type="vertical" />
<a @click="onDelete(record.key)">
<a-divider type="vertical" />
<a v-show="record.article_status==1"
@click="release(record.uuid, searchPageReqParams.article_type)">
编辑
</a>
<a-divider v-show="record.article_status==1" type="vertical" />
<a @click="onDelete(record)">
删除
</a>
</span>
......@@ -56,26 +80,39 @@
<script lang="ts">
import Vue from 'vue'
import { newsList } from '@/mock/index'
import { columns } from '@/const/columns/newsColunms'
import { modal } from './const'
import { getDate } from '@/utils/days/index'
import timerange from '@/components//TimePicker/index.vue'
import News from '@/service/News/index'
import { message } from 'ant-design-vue'
import Filter from '@/filter/index'
const news = new News()
export default Vue.extend({
components:{ timerange },
filters: {
format(value: string) {
return Filter.formatDate(value)
}
},
computed:{
columns(){
return columns
},
list(){
return newsList
}
},
props:{
newsType:{
type:Array,
default(){
return ['全部','政策','新闻']
return [{
label: '新闻',
value: 2
}, {
label: '政策',
value: 1
}]
}
}
},
......@@ -83,32 +120,81 @@ export default Vue.extend({
return{
show:false,
title:'',
list: [],
type:modal.on,
text:'',
searchPageReqParams: {
title: '',
type: '',
startTime: undefined as undefined | number,
endTime: undefined as undefined | number,
article_status: 0,
article_type: 1 as undefined | number,
start_time: undefined as undefined | number,
end_time: undefined as undefined | number,
},
pagination: {
current: 1,
defaultPageSize: 10,
total: 0
},
uuid: ''
}
},
created() {
this.getList()
},
methods:{
tableChange(e: any) {
this.pagination.current = e.current
this.getList()
},
getList() {
const params = {
...this.searchPageReqParams,
limit: this.pagination.defaultPageSize,
// offset: 10
offset: (this.pagination.current - 1) * this.pagination.defaultPageSize
}
news.articleList(params).then(res => {
console.log(res)
this.list = res.data.items
this.pagination.total = res.data.total
// if (this.searchPageReqParams.title) {
// this.findTitle()
// }
})
},
findTitle() {
const searchParams = this.searchPageReqParams.article_type === 1 ? "searchByPolicy" : "searchByTitle"
news[searchParams]({title: this.searchPageReqParams.title}).then(res => {
console.log(res)
this.list = res.data.items
this.pagination.total = res.data.total
})
},
query(){
console.log(this.searchPageReqParams);
if (this.searchPageReqParams.title) {
this.findTitle()
} else {
this.getList()
}
},
getNewTime(startTime:number,endTime:number){
this.searchPageReqParams.startTime = startTime
this.searchPageReqParams.endTime = endTime
this.searchPageReqParams.start_time = startTime
this.searchPageReqParams.end_time = endTime
},
reset(){
this.searchPageReqParams.title =''
this.searchPageReqParams.type = ''
this.searchPageReqParams.startTime = undefined
this.searchPageReqParams.endTime = undefined
this.searchPageReqParams.title = ''
this.searchPageReqParams.article_status = 0
this.searchPageReqParams.article_type = 1
this.searchPageReqParams.start_time = undefined
this.searchPageReqParams.end_time = undefined
},
release(){
this.$router.push({name:'publishNews'})
release(key?:string, type?:string){
if (key && type) {
this.$router.push({name:'publishNews', query: {key, type}})
} else {
this.$router.push({name:'publishNews'})
}
},
edit(key:string){
this.$router.push({name:'publishNews',query:{key:key}})
......@@ -116,34 +202,59 @@ export default Vue.extend({
add(record:any){
this.type = modal.on
this.show = true
this.uuid = record.uuid
this.title = '上架资讯'
this.text = '确定上架该资讯吗?'
},
remove(record:any){
this.type = modal.off
this.show = true
this.uuid = record.uuid
this.title = '下架资讯'
this.text = '确定下架该资讯吗?'
},
onDelete(record:any){
this.type = modal.delete
this.show = true
this.uuid = record.uuid
this.title = '删除资讯'
this.text = '确定删除该资讯吗?'
},
setStatus(status: number, msg: string) {
news.modifyStatus({
article_status: status,
article_type: this.searchPageReqParams.article_type,
uuid: this.uuid
}).then(res => {
if (res.code === 200) {
message.success(msg)
this.getList()
}
})
},
removeArticle() {
const props = this.searchPageReqParams.article_type === 1 ? 'delPolicyArticle' : 'delArticle'
news[props]({uuid: this.uuid}).then(res => {
if (res.code === 200) {
message.success('删除成功')
this.getList()
}
})
},
handleOk(record:any){
console.log(record)
if( this.type == modal.on){
this.setStatus(2, '上架成功')
} else if( this.type == modal.off){
this.setStatus(1, '下架成功')
} else if( this.type == modal.delete){
this.removeArticle()
this.pagination.current = 1
}
this.show = false
},
toDetail(key:string){
this.$router.push({name:'newsDetail',query:{key:key}})
toDetail(key:string, type:string){
this.$router.push({name:'newsDetail',query:{key:key,type:type}})
}
}
})
......
......@@ -7,16 +7,16 @@
<!-- 作者 -->
<a-input v-model="author" placeholder="请输入作者名称" style="width: 35%" />
<!-- 文章分类 -->
<a-select style="width: 20%" v-model="type">
<a-select-option v-for="type in articalType" :key="type">{{type}}</a-select-option>
<a-select style="width: 20%" v-model="type" placeholder="请选择资讯分类">
<a-select-option v-for="item in articalType" :key="item.value">{{item.label}}</a-select-option>
</a-select>
</div>
<!-- 上传概要图片 -->
<editor-upload class=" mt-5"/>
<editor-upload class=" mt-5" :path="imageUrl" @getFileHash="getImage" />
<!-- 文章概要 -->
<a-textarea v-model="summary" :maxLength="50" placeholder="请输入文章概要,字数限制50字以内" auto-size />
<!-- 编辑器 -->
<editor class="edit-news text-left mt-5"
<editor class="edit-news text-left mt-5" :text="editableContent" :editorContent.sync="content"
@getContent="getContent"/>
<!-- 发布操作 -->
<a-button type="primary" @click="onSubmit" class=" mt-5">确定发布</a-button>
......@@ -27,6 +27,11 @@
import Vue from 'vue';
import Editor from '@/components/Editor/index.vue'
import EditorUpload from '@/components/Editor/editorUpload.vue'
import News from '@/service/News/index'
import FileService from "@/service/FileService/index";
import { message } from 'ant-design-vue';
const news = new News()
export default Vue.extend({
components:{ Editor,EditorUpload },
......@@ -34,7 +39,13 @@ export default Vue.extend({
articalType:{
type:Array,
default(){
return ['新闻','政策']
return [{
label: '新闻',
value: 2
}, {
label: '政策',
value: 1
}]
}
}
},
......@@ -42,17 +53,91 @@ export default Vue.extend({
return{
title:'',
author:'',
type:'新闻',
type: undefined as number|any,
imgUrl: '',
imageUrl: '',
summary:'',
content:''
content:'',
editableContent: '',
}
},
created() {
this.getDetails()
},
methods:{
getDetails() {
if (Object.keys(this.$route.query).length === 0) {
this.type = undefined
return
}
const type = this.$route.query.type
const id = this.$route.query.key as string
this.type = +type
if (+type === 1) {
news.searchPolicy(id).then(res => {
this.initData(res.data)
})
} else {
news.searchNews(id).then(res => {
this.initData(res.data)
})
}
},
initData(res: any) {
this.title = res.title
this.author = res.writer
this.imgUrl = res.file_name
this.imageUrl = new FileService().getImageSrc(res.file_name)
this.summary = res.desc
this.editableContent = res.content
},
getContent(value:string){
this.content = value
console.log(value)
},
getImage(val: string) {
this.imgUrl = val
},
addForm() {
const params = {
article_type: this.type,
content: this.content,
desc: this.summary,
file_name: this.imgUrl,
title: this.title,
writer: this.author
}
news.addArticle(params).then(res => {
if (res.code === 200) {
message.success('新增成功')
this.$router.push({ name: 'newsManage' })
}
})
},
editForm() {
const params = {
article_type: this.type,
content: this.content,
desc: this.summary,
file_name: this.imgUrl,
title: this.title,
writer: this.author,
uuid: this.$route.query.key as string
}
news.editArticle(params).then(res => {
if (res.code === 200) {
message.success('编辑成功')
this.$router.push({ name: 'newsManage' })
}
})
},
onSubmit() {
// console.log(this.content);
console.log(this.content)
if (this.$route.query.key) {
this.editForm()
} else {
this.addForm()
}
},
}
})
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment