Commit 18d30653 by wangql
2 parents 9da4eea1 699e5793
......@@ -5,7 +5,10 @@ const methods = {
Search: `${path}search`,
UserCountSearch: `${path_push}.push.search`,
CancelPublish: `${path_push}.publish.cancel`,
MerchantGroup: `${path_merchant}.group.dict`
MerchantGroup: `${path_merchant}.group.dict`,
Create: `${path}create`,
CreateCheck: `${path}create.check`,
Detail: `${path_push}.detail`
}
export {
methods
......
......@@ -18,11 +18,11 @@
prop="title"
>
<gl-input
v-model="noticeForm.title"
v-model="noticeForm.titile"
placeholder="请输入标题"
name="title"
data-vv-as="标题"
v-validate="'required|max:30'"
v-validate="'required|max:100'"
clearable
></gl-input>
<span
......@@ -82,9 +82,6 @@
<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"
......@@ -101,25 +98,21 @@
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-group
v-model="noticeForm.showType"
name="showType"
data-vv-as="展示方式"
v-validate="'required'">
<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> -->
......@@ -156,8 +149,7 @@ export default {
data() {
return {
isClear: false,
// 通过数据watch
title: '新增',
title: '创建通知',
fileList: [],
sendObjList: [
{
......@@ -199,7 +191,7 @@ export default {
},
watch: {
'noticeForm.context'(val) {
if (val == '<p><br></p>') {
if (val === '<p><br></p>') {
this.noticeForm.context = ''
this.$validator.validate('context', this.noticeForm.context)
} else {
......@@ -208,6 +200,8 @@ export default {
},
isVisible(val) {
!val && (this.fileList = [])
console.log(this.noticeForm.recordId)
this.noticeForm.recordId && (this.title = '编辑通知')
this.$validator.errors.clear()
}
},
......@@ -236,32 +230,20 @@ export default {
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)
// }
// })
this.$emit('handleAddComfirm')
},
// 审核并发布
handleComfrim() {
console.log(this.noticeForm)
this.$emit('handleAddComfirm')
// this.$emit('handleAddComfirm')
this.$validator.validateAll().then((result) => {
if (result) {
console.log(this.$validator)
this.$emit('comfirmDialog', this.areaInfo)
this.$emit('handleAddComfirm', true)
}
})
// Promise.all([
// this.$refs['c'].$validator.validateAll(),
// this.$validator.validateAll()
// ]).then((result) => {
// if (result[0] && result[1]) {
// this.$emit('comfirmDialog', this.areaInfo)
// }
// })
}
}
}
......
......@@ -18,20 +18,9 @@
prop="title"
>
<gl-input
readonly="true"
v-model="noticeForm.title"
placeholder="请输入标题"
name="title"
data-vv-as="标题"
v-validate="'required|max:30'"
clearable
readonly="readonly"
v-model="noticeForm.titile"
></gl-input>
<span
v-show="errorBags.has('title')"
class="error"
>
{{ errorBags.first('title') }}
</span>
</gl-form-item>
<gl-form-item
label="内容详情:"
......@@ -39,110 +28,49 @@
>
<div>
<editor
:isClear="isClear"
name="context"
data-vv-as="内容"
v-validate="'required'"
:isEditable="isEditable"
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-group v-model="noticeForm.sendObj">
<gl-checkbox
v-for="item in sendObjList"
:label="item.value"
:key="item.value"
disabled
>{{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"
class="download"
>
<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>
<!-- <a href="http://down8.5156edu.com/showzipdown4.php?f_type1=2&id=96098">下载附件</a> -->
<!-- <a href="https://cdn.shopify.com/s/files/1/1545/3617/files/SH01_User_Manaul.pdf" download="SH01_User_Manaul.pdf">下载附件</a> -->
<a href="https://down1.jyrd.com/2010/WPS.Office_ankty.rar">下载附件</a>
</gl-form-item>
<gl-form-item
label="展示方式:"
prop="showType"
>
<gl-radio-group v-model="noticeForm.showType">
<gl-radio-group
v-model="noticeForm.showType"
disabled
>
<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>
......@@ -156,10 +84,9 @@ export default {
},
data() {
return {
isClear: false,
// 通过数据watch
readonly: true,
isEditable: false,
title: '通知详情',
fileList: [],
sendObjList: [
{
label: '爱车保镖分组',
......@@ -173,11 +100,11 @@ export default {
}
],
showTypeList: [{
label: '置顶消息',
value: '2'
}, {
label: '弹出框',
value: '1'
}, {
label: '置顶消息',
value: '2'
}],
rules: {
title: [{ required: true }],
......@@ -212,26 +139,6 @@ export default {
}
},
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')
......@@ -247,4 +154,26 @@ export default {
.detail .el-select {
width: 100%;
}
.detail .download a {
color: #409eff;
text-decoration: underline;
}
.detail .el-checkbox__input.is-disabled + span.el-checkbox__label,
.detail .el-radio__input.is-disabled + span.el-radio__label {
color: #606266;
}
.detail .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,
.detail .el-radio__input.is-disabled.is-checked .el-radio__inner {
border-color: #409eff;
background: #409eff;
}
.detail .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
border-color: #fff;
}
.detail .el-radio__input.is-disabled.is-checked .el-radio__inner::after {
background-color: #fff;
}
.detail .el-radio:focus:not(.is-focus):not(:active) .el-radio__inner {
box-shadow: 0 0;
}
</style>
\ No newline at end of file
......@@ -32,6 +32,10 @@ export default {
isClear: {
type: Boolean,
default: false
},
isEditable: {
type: Boolean,
default: true
}
},
watch: {
......@@ -121,6 +125,8 @@ export default {
}
// 创建富文本编辑器
this.editor.create()
// 禁用编辑功能
!this.isEditable && this.editor.$textElem.attr('contenteditable', false)
}
}
}
......
......@@ -68,7 +68,7 @@
<gl-button
class="newButton"
type="primary"
@click="handleAdd"
@click="handleAdd(true)"
>创建通知</gl-button>
</gl-form-item>
</gl-col>
......@@ -178,7 +178,7 @@
import { nmMethods, request } from '@/api'
import AddDialog from './AddDialog'
import DetailDialog from './DetailDialog'
// import { resetSearch } from '@/common/common'
import { resetSearch } from '@/common/common'
// import { getNMList } from '@/api'
import notice from '@/common/notice'
export default {
......@@ -225,7 +225,8 @@ export default {
// 编辑弹窗参数-start
addVisible: false,
noticeForm: {
title: '',
recordId: '',
titile: '',
context: '',
// 发送对象
sendObj: [],
......@@ -336,7 +337,8 @@ export default {
label: '详情',
type: 'text',
callback: (index, row) => {
// console.log(row[index])
this.noticeDetail(row[index].recordId)
}
},
{
......@@ -363,7 +365,7 @@ export default {
return row.publishStatus === 1 ? null : '编辑'
},
callback: (index, row) => {
this.noticeDetail(row[index].recordId, 1)
}
}
]
......@@ -534,18 +536,61 @@ export default {
})
.catch(err => console.log(err))
},
// 公告详情
noticeDetail(recordId, isEdit = 0) {
const params = { 'recordId': recordId }
params.method = nmMethods.Detail
request.req(params).then(res => {
console.log(res)
for (var item in this.noticeForm) {
this.noticeForm[item] = res[item]
}
// console.log(this.noticeForm)
isEdit ? this.handleAdd() : this.handleDetail()
}).catch(err => {
notice.errorTips(err)
})
},
// 创建公告
createNotice() {
const params = this.$deep_clone(this.noticeForm)
!params.recordId && delete params.recordId
params.method = nmMethods.Create
request.req(params).then(res => {
notice.okTips('创建成功')
this.handleAdd()
resetSearch(this.noticeForm)
}).catch(err => {
notice.errorTips(err)
})
},
// 创建公告+审核发布
createCheckNotice() {
const params = this.$deep_clone(this.noticeForm)
!params.recordId && delete params.recordId
params.method = nmMethods.CreateCheck
request.req(params).then(res => {
notice.okTips('发布成功')
this.handleAdd()
resetSearch(this.noticeForm)
}).catch(err => {
notice.errorTips(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>'
handleAdd(isCreate) {
isCreate && (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%;"></p><p></p><p>gfdgdg</p><p>gfdgdg</p>'
this.addVisible = !this.addVisible
},
handleAddHide() {
this.handleAdd()
// resetSearch(this.noticeForm)
resetSearch(this.noticeForm)
},
handleAddComfirm(noticeInfo) {
this.handleAdd()
// isRelease是否审核发布,默认为仅保存
handleAddComfirm(isRelease = false) {
isRelease ? this.createCheckNotice() : this.createNotice()
// this.handleAdd()
// resetSearch(this.noticeForm)
},
// 通知详情
......@@ -553,7 +598,8 @@ export default {
this.detailVisible = !this.detailVisible
},
handleDetailHide() {
this.handleDetail()
this.detailVisible = !this.detailVisible
resetSearch(this.noticeForm)
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!