Commit 1b3527cc by wangql

提交代码

2 parents 6ae26101 c1a5b283
This diff could not be displayed because it is too large.
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"vee-validate": "^2.1.7", "vee-validate": "^2.1.7",
"vue": "^2.5.17", "vue": "^2.5.17",
"vue-amap": "^0.5.8" "wangeditor": "^3.1.1"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^3.0.1", "@vue/cli-plugin-babel": "^3.0.1",
......
...@@ -25,8 +25,12 @@ function jumpLink(url, params, _this) { ...@@ -25,8 +25,12 @@ function jumpLink(url, params, _this) {
function resetSearch(obj) { function resetSearch(obj) {
for (var item in obj) { for (var item in obj) {
if (obj[item] instanceof Array) {
obj[item] = []
} else {
obj[item] = '' obj[item] = ''
} }
}
} }
export { export {
......
...@@ -8,3 +8,12 @@ ...@@ -8,3 +8,12 @@
.p-t15 { .p-t15 {
padding-top: 15px; padding-top: 15px;
} }
.error {
color: #f56c6c;
font-size: 12px;
line-height: 1;
padding-top: 4px;
position: absolute;
top: 100%;
left: 0;
}
\ No newline at end of file \ No newline at end of file
<!-- 新增/编辑弹框 -->
<template>
<div class="add">
<gl-dialog
:title="title"
:visible.sync="isVisible"
:before-close="handleClose"
:width="diaWidth"
:close-on-click-modal="false"
>
<gl-form
label-width="120px"
:model="noticeForm"
:rules="rules"
>
<gl-form-item
label="标题:"
prop="title"
>
<gl-input
v-model="noticeForm.title"
placeholder="请输入标题"
name="title"
data-vv-as="标题"
v-validate="'required|max:30'"
clearable
></gl-input>
<span
v-show="errorBags.has('title')"
class="error"
>
{{ errorBags.first('title') }}
</span>
</gl-form-item>
<gl-form-item
label="内容详情:"
prop="context"
>
<div>
<editor
:isClear="isClear"
name="context"
data-vv-as="内容"
v-validate="'required'"
v-model="noticeForm.context"
></editor>
</div>
<span
v-show="errorBags.has('context')"
class="error"
>
{{ errorBags.first('context') }}
</span>
</gl-form-item>
<gl-form-item
label="发送对象:"
prop="sendObj"
>
<gl-checkbox-group
v-model="noticeForm.sendObj"
name="sendObj"
data-vv-as="发送对象"
v-validate="'required'"
>
<gl-checkbox
v-for="item in sendObjList"
:label="item.value"
:key="item.value"
>{{item.label}}</gl-checkbox>
</gl-checkbox-group>
<span
v-show="errorBags.has('sendObj')"
class="error"
>
{{ errorBags.first('sendObj') }}
</span>
</gl-form-item>
<gl-form-item
label="上传附件:"
prop="attachment"
>
<gl-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
name="attachment"
v-validate="'required'"
data-vv-as="附件"
:limit="2"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-error="handleError"
:on-remove="handleRemove"
:file-list="fileList"
>
<gl-button
size="small"
type="primary"
>点击上传</gl-button>
<div
slot="tip"
class="el-upload__tip"
>请上传小于20MB的文件</div>
</gl-upload>
<span
v-show="errorBags.has('attachment')"
class="error"
>
{{ errorBags.first('attachment') }}
</span>
</gl-form-item>
<gl-form-item
label="展示方式:"
prop="showType"
>
<gl-radio-group v-model="noticeForm.showType">
<gl-radio
v-for="item in showTypeList"
:label="item.value"
:key="item.value"
name="showType"
data-vv-as="展示方式"
v-validate="'required'"
>{{item.label}}</gl-radio>
</gl-radio-group>
<!-- <p>说明:没有勾选则为默认形式,即在消息中心中展示</p> -->
<span
v-show="errorBags.has('showType')"
class="error"
>
{{ errorBags.first('showType') }}
</span>
</gl-form-item>
</gl-form>
<span slot="footer">
<el-button
type="primary"
@click="handleDraft"
>保存草稿</el-button>
<el-button
type="primary"
@click="handleComfrim"
>审核并发布</el-button>
<el-button @click="handleClose">取消发布</el-button>
</span>
</gl-dialog>
</div>
</template>
<script>
import Editor from './Editor'
export default {
name: 'AddDialog',
components: {
Editor
},
data() {
return {
isClear: false,
// 通过数据watch
title: '新增',
fileList: [],
sendObjList: [
{
label: '爱车保镖分组',
value: '1'
}, {
label: '虎哥E盾分组',
value: '2'
}, {
label: '嘀加系统(TSP版)',
value: '3'
}
],
showTypeList: [{
label: '弹出框',
value: '1'
}, {
label: '置顶消息',
value: '2'
}],
rules: {
title: [{ required: true }],
context: [{ required: true }],
sendObj: [{ required: true }],
showType: [{ required: true }]
}
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
diaWidth: {
type: String,
default: '40%'
},
noticeForm: Object
},
watch: {
'noticeForm.context'(val) {
if (val == '<p><br></p>') {
this.noticeForm.context = ''
this.$validator.validate('context', this.noticeForm.context)
} else {
this.errorBags.remove('context')
}
},
isVisible(val) {
!val && (this.fileList = [])
this.$validator.errors.clear()
}
},
methods: {
// 上传附件,限制用户上传的附件格式和大小
beforeUpload(file) {
const isLT20M = file.size / 1024 / 1024 < 20
!isLT20M && this.$message.error('上传附件大小不能超过20M')
return isLT20M
},
handleSuccess(file, fileList) {
this.fileList = [{ name: fileList.name, url: fileList.url }]
this.noticeForm.attachment = fileList.url
// 移除验证
// this.errorBags.remove('attachment')
},
handleError() {
this.$message.error('上传失败,请重新上传!')
},
handleRemove(file, fileList) {
this.noticeForm.attachment = ''
// 添加验证
// this.$validator.validate('attachment', this.noticeForm.attachment)
},
handleClose() {
console.log(this.noticeForm)
this.$emit('hideDialog')
},
handleDraft() {
// this.$emit('handleAddComfirm')
// this.$validator.validateAll().then((result) => {
// if (result) {
// console.log(this.$validator)
// this.$emit('comfirmDialog', this.areaInfo)
// }
// })
},
handleComfrim() {
console.log(this.noticeForm)
this.$emit('handleAddComfirm')
this.$validator.validateAll().then((result) => {
if (result) {
console.log(this.$validator)
this.$emit('comfirmDialog', this.areaInfo)
}
})
// Promise.all([
// this.$refs['c'].$validator.validateAll(),
// this.$validator.validateAll()
// ]).then((result) => {
// if (result[0] && result[1]) {
// this.$emit('comfirmDialog', this.areaInfo)
// }
// })
}
}
}
</script>
<style>
.add .el-dialog__body {
padding: 0 20px;
}
.add .el-select {
width: 100%;
}
</style>
\ No newline at end of file \ No newline at end of file
<!-- 新增/编辑弹框 -->
<template>
<div class="detail">
<gl-dialog
:title="title"
:visible.sync="isVisible"
:before-close="handleClose"
:width="diaWidth"
:close-on-click-modal="false"
>
<gl-form
label-width="120px"
:model="noticeForm"
:rules="rules"
>
<gl-form-item
label="标题:"
prop="title"
>
<gl-input
readonly="true"
v-model="noticeForm.title"
placeholder="请输入标题"
name="title"
data-vv-as="标题"
v-validate="'required|max:30'"
clearable
></gl-input>
<span
v-show="errorBags.has('title')"
class="error"
>
{{ errorBags.first('title') }}
</span>
</gl-form-item>
<gl-form-item
label="内容详情:"
prop="context"
>
<div>
<editor
:isClear="isClear"
name="context"
data-vv-as="内容"
v-validate="'required'"
v-model="noticeForm.context"
></editor>
</div>
<span
v-show="errorBags.has('context')"
class="error"
>
{{ errorBags.first('context') }}
</span>
</gl-form-item>
<gl-form-item
label="发送对象:"
prop="sendObj"
>
<gl-checkbox-group
v-model="noticeForm.sendObj"
name="sendObj"
data-vv-as="发送对象"
v-validate="'required'"
>
<gl-checkbox
v-for="item in sendObjList"
:label="item.value"
:key="item.value"
>{{item.label}}</gl-checkbox>
</gl-checkbox-group>
<span
v-show="errorBags.has('sendObj')"
class="error"
>
{{ errorBags.first('sendObj') }}
</span>
</gl-form-item>
<gl-form-item
label="上传附件:"
prop="attachment"
>
<gl-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
name="attachment"
v-validate="'required'"
data-vv-as="附件"
:limit="2"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-error="handleError"
:on-remove="handleRemove"
:file-list="fileList"
>
<gl-button
size="small"
type="primary"
>点击上传</gl-button>
<div
slot="tip"
class="el-upload__tip"
>请上传小于20MB的文件</div>
</gl-upload>
<span
v-show="errorBags.has('attachment')"
class="error"
>
{{ errorBags.first('attachment') }}
</span>
</gl-form-item>
<gl-form-item
label="展示方式:"
prop="showType"
>
<gl-radio-group v-model="noticeForm.showType">
<gl-radio
v-for="item in showTypeList"
:label="item.value"
:key="item.value"
name="showType"
data-vv-as="展示方式"
v-validate="'required'"
>{{item.label}}</gl-radio>
</gl-radio-group>
<!-- <p>说明:没有勾选则为默认形式,即在消息中心中展示</p> -->
<span
v-show="errorBags.has('showType')"
class="error"
>
{{ errorBags.first('showType') }}
</span>
</gl-form-item>
</gl-form>
<!-- <span slot="footer">
<el-button
type="primary"
@click="handleDraft"
>保存草稿</el-button>
<el-button
type="primary"
@click="handleComfrim"
>审核并发布</el-button>
<el-button @click="handleClose">取消发布</el-button>
</span> -->
</gl-dialog>
</div>
</template>
<script>
import Editor from './Editor'
export default {
name: 'DetailDialog',
components: {
Editor
},
data() {
return {
isClear: false,
// 通过数据watch
title: '通知详情',
fileList: [],
sendObjList: [
{
label: '爱车保镖分组',
value: '1'
}, {
label: '虎哥E盾分组',
value: '2'
}, {
label: '嘀加系统(TSP版)',
value: '3'
}
],
showTypeList: [{
label: '置顶消息',
value: '2'
}, {
label: '弹出框',
value: '1'
}],
rules: {
title: [{ required: true }],
context: [{ required: true }],
sendObj: [{ required: true }],
showType: [{ required: true }]
}
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
diaWidth: {
type: String,
default: '40%'
},
noticeForm: Object
},
watch: {
'noticeForm.context'(val) {
if (val === '<p><br></p>') {
this.noticeForm.context = ''
this.$validator.validate('context', this.noticeForm.context)
} else {
this.errorBags.remove('context')
}
},
isVisible(val) {
this.$validator.errors.clear()
}
},
methods: {
// 上传附件,限制用户上传的附件格式和大小
beforeUpload(file) {
const isLT20M = file.size / 1024 / 1024 < 20
!isLT20M && this.$message.error('上传附件大小不能超过20M')
return isLT20M
},
handleSuccess(file, fileList) {
this.fileList = [{ name: fileList.name, url: fileList.url }]
this.noticeForm.attachment = fileList.url
// 移除验证
// this.errorBags.remove('attachment')
},
handleError() {
this.$message.error('上传失败,请重新上传!')
},
handleRemove(file, fileList) {
this.noticeForm.attachment = ''
// 添加验证
// this.$validator.validate('attachment', this.noticeForm.attachment)
},
handleClose() {
console.log(this.noticeForm)
this.$emit('hideDialog')
}
}
}
</script>
<style>
.detail .el-dialog__body {
padding: 0 20px;
}
.detail .el-select {
width: 100%;
}
</style>
\ No newline at end of file \ No newline at end of file
<template lang="html">
<div class="editor">
<div ref="toolbar" class="toolbar">
</div>
<div ref="editor" class="text">
</div>
</div>
</template>
<script>
// import { uploadPath } from '../../api/storage'
// 此处的uploadPath 为后端提供的上传图片的接口
import E from 'wangeditor'
export default {
name: 'Editor',
data() {
return {
// uploadPath,
editor: null,
info_: null
}
},
model: {
prop: 'value',
event: 'change'
},
props: {
value: {
type: String,
default: ''
},
isClear: {
type: Boolean,
default: false
}
},
watch: {
isClear(val) {
// 触发清除文本域内容
if (val) {
this.editor.txt.clear()
this.info_ = null
}
},
value: function(value) {
if (value !== this.editor.txt.html()) {
this.editor.txt.html(this.value)
}
}
// value为编辑框输入的内容,这里我监听了一下值,当父组件调用得时候,如果给value赋值了,子组件将会显示父组件赋给的值
},
mounted() {
this.seteditor()
this.editor.txt.html(this.value)
},
methods: {
seteditor() {
// http://192.168.2.125:8080/admin/storage/create
this.editor = new E(this.$refs.toolbar, this.$refs.editor)
this.editor.customConfig.uploadImgShowBase64 = true // base 64 存储图片
// this.editor.customConfig.uploadImgServer = uploadPath// 配置服务器端地址
this.editor.customConfig.uploadImgHeaders = { }// 自定义 header
this.editor.customConfig.uploadFileName = 'files' // 后端接受上传文件的参数名
this.editor.customConfig.uploadImgMaxSize = 2 * 1024 * 1024 // 将图片大小限制为 2M
this.editor.customConfig.uploadImgMaxLength = 6 // 限制一次最多上传 3 张图片
this.editor.customConfig.uploadImgTimeout = 3 * 60 * 1000 // 设置超时时间
// 配置菜单
this.editor.customConfig.menus = [
'head', // 标题
'bold', // 粗体
'fontSize', // 字号
'fontName', // 字体
'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
'backColor', // 背景颜色
'link', // 插入链接
'list', // 列表
'justify', // 对齐方式
'quote', // 引用
'emoticon', // 表情
'image', // 插入图片
'table', // 表格
'video', // 插入视频
'code', // 插入代码
'undo', // 撤销
'redo', // 重复
'fullscreen' // 全屏
]
this.editor.customConfig.uploadImgHooks = {
fail: (xhr, editor, result) => {
// 插入图片失败回调
},
success: (xhr, editor, result) => {
// 图片上传成功回调
},
timeout: (xhr, editor) => {
// 网络超时的回调
},
error: (xhr, editor) => {
// 图片上传错误的回调
},
customInsert: (insertImg, result, editor) => {
// 图片上传成功,插入图片的回调
// result为上传图片成功的时候返回的数据,这里我打印了一下发现后台返回的是data:[{url:"路径的形式"},...]
// console.log(result.data[0].url)
// insertImg()为插入图片的函数
// 循环插入图片
for (let i = 0; i < result.data.length; i++) {
var url = result.data[i].url
insertImg(url)
}
}
}
this.editor.customConfig.onchange = (html) => {
this.info_ = html // 绑定当前逐渐地值
this.$emit('change', this.info_) // 将内容同步到父组件中
}
// 创建富文本编辑器
this.editor.create()
}
}
}
</script>
<style lang="css">
.editor {
width: 100%;
margin: 0 auto;
position: relative;
z-index: 0;
}
.editor .text {
min-height: 200px;
height: 200px;
}
.toolbar {
border: 1px solid #ccc;
display: flex;
flex-wrap: wrap;
}
.text {
border: 1px solid #ccc;
min-height: 300px;
}
</style>
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
<gl-button <gl-button
class="newButton" class="newButton"
type="primary" type="primary"
@click="handleAdd"
>创建通知</gl-button> >创建通知</gl-button>
</gl-form-item> </gl-form-item>
</gl-col> </gl-col>
...@@ -156,16 +157,34 @@ ...@@ -156,16 +157,34 @@
:total="total_pushList" :total="total_pushList"
></gl-pagination> ></gl-pagination>
</gl-dialog> </gl-dialog>
<add-dialog
:isVisible="addVisible"
:noticeForm="noticeForm"
@hideDialog="handleAddHide"
@handleAddComfirm="handleAddComfirm"
>
</add-dialog>
<detail-dialog
:isVisible="detailVisible"
:noticeForm="noticeForm"
@hideDialog="handleDetailHide"
>
</detail-dialog>
</div> </div>
</template> </template>
<script> <script>
import { nmMethods, request } from '@/api' import { nmMethods, request } from '@/api'
import AddDialog from './AddDialog'
import DetailDialog from './DetailDialog'
// import { resetSearch } from '@/common/common'
// import { getNMList } from '@/api' // import { getNMList } from '@/api'
import notice from '@/common/notice' import notice from '@/common/notice'
export default { export default {
name: 'noticeManage', name: 'noticeManage',
components: { components: {
AddDialog,
DetailDialog
}, },
watch: { watch: {
dialogVisible_pushList(val) { dialogVisible_pushList(val) {
...@@ -207,7 +226,18 @@ export default { ...@@ -207,7 +226,18 @@ export default {
pageNum_pushList: 1, pageNum_pushList: 1,
pageSize_pushList: 10, pageSize_pushList: 10,
total_pushList: 10, total_pushList: 10,
// 编辑弹窗参数-start
addVisible: false,
noticeForm: {
title: '',
context: '',
// 发送对象
sendObj: [],
attachment: [],
showType: ''
},
// 编辑弹窗参数-end
detailVisible: false,
tableLoading: false, tableLoading: false,
addLoading: false, addLoading: false,
dialogVisible_pushList: false, dialogVisible_pushList: false,
...@@ -507,6 +537,27 @@ export default { ...@@ -507,6 +537,27 @@ export default {
notice.okTips() notice.okTips()
}) })
.catch(err => console.log(err)) .catch(err => console.log(err))
},
// 新增公告
handleAdd() {
this.noticeForm.showType = '1'
// this.noticeForm.context = '<p>fdasfdasf</p><p><img src="https://timgsa.baidu.com/timg?image&amp;quality=80&amp;size=b9999_10000&amp;sec=1555392730451&amp;di=6f2af72a691e8f7a19a436d63a40124b&amp;imgtype=0&amp;src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F20182%2F21%2F2018221142159_MZ33z.jpeg" style="max-width:100%;"><br></p><p><br></p>'
this.addVisible = !this.addVisible
},
handleAddHide() {
this.handleAdd()
// resetSearch(this.noticeForm)
},
handleAddComfirm(noticeInfo) {
this.handleAdd()
// resetSearch(this.noticeForm)
},
// 通知详情
handleDetail() {
this.detailVisible = !this.detailVisible
},
handleDetailHide() {
this.handleDetail()
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!