Commit 6b83832f by 胡悦

提交群发助手

1 parent fe0eee8d
...@@ -163,6 +163,24 @@ const remindUserGroup = params => { ...@@ -163,6 +163,24 @@ const remindUserGroup = params => {
sign: true sign: true
}) })
} }
const getMerchant = params => {
params.method = 'scrm.api.coupon.list.merchant'
return http({
url: 'rop-scrm-coupon/router',
method: 'POST',
data: params,
sign: true
})
}
const getCard = params => {
params.method = 'scrm.api.equity.card.class.list.with.page'
return http({
url: 'rop-scrm-equity/router',
method: 'POST',
data: params,
sign: true
})
}
export default { export default {
customerList, customerList,
customerGroupList, customerGroupList,
...@@ -179,5 +197,7 @@ export default { ...@@ -179,5 +197,7 @@ export default {
groupDetailStatistic, groupDetailStatistic,
staffList, staffList,
customerDetailList, customerDetailList,
groupDetailList groupDetailList,
getMerchant,
getCard
} }
export function debounce(func, wait= 200){
let timeout;
return function(event){
clearTimeout(timeout)
timeout = setTimeout(()=>{
func.call(this, event)
},wait)
}
}
export function dateFormat (dateTime, format = 'YYYY-MM-DD HH:mm') { export function dateFormat (dateTime, format = 'YYYY-MM-DD HH:mm') {
const date = new Date(dateTime) const date = new Date(dateTime)
const config = { const config = {
......
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
@confirmDialog="handleConfirm" @confirmDialog="handleConfirm"
@closeDialog="membersVisible = !membersVisible" @closeDialog="membersVisible = !membersVisible"
> >
<SelectMembers :selectData="selectData" ref="membersForm"></SelectMembers> <SelectMembers islord="false" :selectData="selectData" ref="membersForm"></SelectMembers>
</glsx-dialog> </glsx-dialog>
</div> </div>
<div <div
...@@ -219,6 +219,7 @@ export default { ...@@ -219,6 +219,7 @@ export default {
} }
} }
const validatorAttachment = (rule, value, callback) => { const validatorAttachment = (rule, value, callback) => {
console.log(this.$refs.welcome.previewList)
const previewList = this.$refs.welcome.previewList const previewList = this.$refs.welcome.previewList
if (previewList.length != 0) { if (previewList.length != 0) {
this.basicForm.attachmentList = previewList this.basicForm.attachmentList = previewList
...@@ -332,13 +333,13 @@ export default { ...@@ -332,13 +333,13 @@ export default {
this.$refs.selectLabel.init() this.$refs.selectLabel.init()
}, },
handleSubmit() { handleSubmit() {
console.log(this.basicForm) console.log(this.basicForm, this.$refs.welcome.previewList)
this.$refs.basicForm.validate(valid => { this.$refs.basicForm.validate(valid => {
if (valid) { if (valid) {
console.log(valid) console.log(valid)
this.$refs.groupForm.validate(v => { this.$refs.groupForm.validate(v => {
if (v) { if (v) {
if (this.groupNumber == 0) { if (this.basicForm.selectType == 2 && this.groupNumber == 0) {
this.$message({ this.$message({
type: 'error', type: 'error',
message: '选择客户数量为0,不可创建' message: '选择客户数量为0,不可创建'
...@@ -347,8 +348,15 @@ export default { ...@@ -347,8 +348,15 @@ export default {
} }
const params = this.getSiftMembers() const params = this.getSiftMembers()
params.type = 1 params.type = 1
params.attachmentList = this.basicForm.attachmentList // params.attachmentList = this.basicForm.attachmentList
params.sendType = this.basicForm.sendType params.sendType = this.basicForm.sendType
const attachmentList = this.$common.utils.deepClone(this.$refs.welcome.previewList).map(item => {
if (item.attType == 1) {
item.attContent = item.attContent.replace('@昵称', '[@昵称]')
}
return item
})
params.attachmentList = attachmentList
// const params = { // const params = {
// type: 1, // type: 1,
// attachmentList: this.basicForm.attachmentList, // attachmentList: this.basicForm.attachmentList,
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
@confirmDialog="handleConfirm" @confirmDialog="handleConfirm"
@closeDialog="membersVisible = !membersVisible" @closeDialog="membersVisible = !membersVisible"
> >
<SelectMembers ref="membersForm"></SelectMembers> <SelectMembers ref="membersForm" islord="true"></SelectMembers>
</glsx-dialog> </glsx-dialog>
</div> </div>
</template> </template>
......
<template>
<div class="square-main">
<el-dialog title="选择活动" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
<div class="model-panel">
<div class="model-panel-tab">
<label>活动类型:</label>
<el-tabs v-model="activeName" @tab-click="handleClick" type="card">
<el-tab-pane label="券营销" name="1"></el-tab-pane>
<el-tab-pane label="权益卡" name="2"></el-tab-pane>
</el-tabs>
</div>
<div class="model-item-panel" v-if="modelList.length > 0" v-loading="loading">
<div
class="model-item"
:class="{ checked: selectItem == item }"
v-for="(item, index) in modelList"
:key="index"
@click="handleSelectItem(item)"
>
<div class="model-item-title" v-show="activeName == 2">{{ item.cardClassName }}</div>
<div class="model-item-title" v-show="activeName == 1">{{ item.couponName }}</div>
<div class="model-item-content" v-show="activeName == 1">数量:{{ item.residueAmount }}</div>
<div class="model-item-content" v-show="activeName == 2">价格:{{ item.price }}</div>
<div
class="model-item-content"
v-show="activeName == 2 && item.effectiveType == 2"
>有效期:{{ item.effectiveNum }}天</div>
<div
class="model-item-content"
v-show="activeName == 2 && item.effectiveType == 1"
>有效期:无限制</div>
<div
class="model-item-content"
v-show="activeName == 1 && item.effectiveType == 2"
>有效期:{{ item.effectiveStartTime }}~{{ item.effectiveEndTime }}</div>
<div
class="model-item-content"
v-show="activeName == 1 && item.effectiveType == 1"
>有效期:{{ item.effectiveDays }}天</div>
<div
class="model-item-content"
v-show="activeName == 1 && item.effectiveType == 3"
>有效期:无限制</div>
<div
class="model-item-content"
v-show="activeName == 1"
>类型:{{ item.discountType == 1 ? '满减劵' : item.discountType == 2 ? '折扣券' : item.discountType == 3 ? '代金券' : item.discountType == 4 ? '实物券' : item.discountType == 5 ? '购车代金券' : item.discountType == 6 ? '商品折扣券' : item.discountType == 7 ? '会员服务' : '' }}</div>
<div class="model-item-content" v-show="activeName == 2">类型:权益卡</div>
</div>
</div>
<div class="model-item-empty" v-else v-loading="loading">
<img src="@/assets/empty.png" />
<div class="empty-item">暂无数据</div>
</div>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[10, 20, 30, 40]"
:page-size="pageSize"
:total="tableTotal"
layout="total, sizes, prev, pager, next, jumper"
></el-pagination>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogVisible = false">取 消</el-button>
<el-button size="small" type="primary" @click="handleSelect">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'ActivityModel',
data() {
return {
dialogVisible: false,
loading: false,
activeName: '1',
modelList: [],
pageNum: 1,
pageSize: 10,
tableTotal: 0,
selectItem: {}
}
},
methods: {
handleSelectItem(item) {
this.selectItem = item
},
handleSelect() {
if (!this.selectItem.id) {
this.$message({
type: 'error',
message: '请选择活动'
})
return
}
this.dialogVisible = false
this.$emit('selectActivity', { marketingId: this.selectItem.id, marketingType: this.activeName == 1 ? 2 : 3, marketingName: this.activeName == 2 ? this.selectItem.cardClassName : this.selectItem.couponName })
},
handleSizeChange(val) {
this.pageSize = val
this.getModelList()
},
handleCurrentChange(val) {
this.pageNum = val
this.getModelList()
},
getModelList() {
this.modelList = []
this.loading = true
let market = ''
switch (this.activeName) {
case '1':
market = 'getMerchant'
break
case '2':
market = 'getCard'
break
}
let params = {
pageSize: this.pageSize,
pageNum: this.pageNum
}
this.$apis.customerTransform[market](params).then(res => {
this.modelList = res.list ? res.list : res.data
this.tableTotal = res.total
this.loading = false
})
},
init() {
this.dialogVisible = true
this.getModelList()
this.selectItem = {}
},
handleClick() {
this.getModelList()
}
}
}
</script>
<style lang="scss" scoped>
.model-panel {
.model-panel-tab {
display: flex;
align-items: center;
margin-bottom: 18px;
label {
font-size: 16px;
font-weight: 400;
color: #000000;
line-height: 24px;
}
/deep/ {
.el-checkbox:last-of-type {
margin-right: 8px;
}
.el-tabs__nav {
border: 0;
}
.el-tabs__header {
border: 0;
background-color: #f4f6fc;
margin: 0px;
}
.el-tabs__item {
border: none;
width: 180px;
height: 32px;
line-height: 32px;
margin: 2px;
text-align: center;
}
.el-tabs__item.is-active {
background-color: #fff;
border-radius: 4px;
}
}
}
.model-item-empty {
> img {
display: block;
margin: 50px auto 0px;
width: 60px;
height: auto;
}
.empty-item {
text-align: center;
font-size: 14px;
font-weight: 400;
color: #000000;
line-height: 22px;
margin-bottom: 30px;
}
}
.model-item-panel {
display: grid;
grid-template-columns: repeat(4, 25%);
grid-row-gap: 10px;
height: 40vh;
overflow: auto;
.model-item {
position: relative;
height: 128px;
background: #ffffff;
border-radius: 4px;
border: 2px solid #e6e6e6;
padding: 14px 24px;
box-sizing: border-box;
margin-right: 10px;
&:nth-child(4n) {
margin-right: 0px;
}
&.checked {
border: 2px solid #5850ff;
}
&-qrcode {
position: absolute;
right: 10px;
bottom: 10px;
width: 60px;
height: 60px;
border: 1px solid #979797;
}
&-title {
font-size: 18px;
font-weight: 600;
color: #333333;
line-height: 25px;
margin-bottom: 5px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
&-content {
font-size: 12px;
font-weight: 400;
color: #666666;
line-height: 17px;
margin-top: 6px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -7,11 +7,19 @@ ...@@ -7,11 +7,19 @@
<template v-if="item.attType == 1"> <template v-if="item.attType == 1">
<div class="preview-text text">{{ item.attContent }}</div> <div class="preview-text text">{{ item.attContent }}</div>
</template> </template>
<template v-else-if="item.attType == 4"> <template v-else-if="item.attType == 7">
<div class="preview-text preview-link"> <div class="preview-activity">
<img class="applet-logo" src="@/assets/guestCustom/applet-logo.png" alt />
<div class="activity-name">{{item.attContent.marketingName}}</div>
<img class="activity-logo" src="@/assets/guestCustom/activity-logo.png" alt />
<div class="activity-footer">
<img src="@/assets/guestCustom/applet-footer.png" alt />
</div>
</div>
<!-- <div class="preview-text preview-link">
{{ item.attContent.url }} {{ item.attContent.url }}
<img src="@/assets/guestCustom/preview-link.png" alt /> <img src="@/assets/guestCustom/preview-link.png" alt />
</div> </div>-->
</template> </template>
<template v-else-if="item.attType == 2"> <template v-else-if="item.attType == 2">
<el-image style="width: 100px" :src="item.attContent" fit="contain"></el-image> <el-image style="width: 100px" :src="item.attContent" fit="contain"></el-image>
...@@ -139,6 +147,31 @@ export default { ...@@ -139,6 +147,31 @@ export default {
margin-bottom: 5px; margin-bottom: 5px;
} }
} }
.preview-activity {
width: 160px;
// height: 184px;
background-color: #fff;
border-radius: 4px;
border: 1px solid #dce1e5;
padding: 7px 7px 0;
.activity-name {
font-size: 12px;
color: #333;
margin: 7px 0 4px;
width: 160px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.applet-logo {
width: 95px;
height: 24px;
}
.activity-footer {
margin-top: 4px;
border-top: 1px solid #edeff3;
}
}
} }
} }
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<script> <script>
export default { export default {
name: 'selectEmp', name: 'selectEmp',
props: ['selectData'], props: ['selectData', 'islord'],
data() { data() {
return { return {
treeHeight: 0, treeHeight: 0,
...@@ -69,7 +69,6 @@ export default { ...@@ -69,7 +69,6 @@ export default {
] ]
}, },
tableEmpData: [], tableEmpData: [],
group: {},
currentArr: [], currentArr: [],
loading: true loading: true
} }
...@@ -79,10 +78,14 @@ export default { ...@@ -79,10 +78,14 @@ export default {
this.$emit('selectTable', val) this.$emit('selectTable', val)
}, },
listDepartmentTree() { listDepartmentTree() {
this.$apis.customerTransform.listDepartmentTree({ merchantId: 10001001, addChildrensFlag: true }).then(res => { const params = { merchantId: 10001001, addChildrensFlag: true }
if (this.islord) {
params.islord = this.islord
}
this.$apis.customerTransform.listDepartmentTree(params).then(res => {
this.listTree = res this.listTree = res
this.loading = false this.loading = false
this.listTree[0].entmicroStaffResponses = this.getEmployee(this.listTree) // this.listTree[0].entmicroStaffResponses = this.getEmployee(this.listTree)
console.log(this.listTree) console.log(this.listTree)
this.currentArr = this.$common.utils.deepClone(this.listTree[0].entmicroStaffResponses) this.currentArr = this.$common.utils.deepClone(this.listTree[0].entmicroStaffResponses)
this.selectData.forEach(i => { this.selectData.forEach(i => {
...@@ -145,6 +148,7 @@ export default { ...@@ -145,6 +148,7 @@ export default {
// } // }
}, },
mounted() { mounted() {
console.log('islord', this.islord)
let clientHeight = document.documentElement.clientHeight let clientHeight = document.documentElement.clientHeight
this.treeHeight = clientHeight - 650 this.treeHeight = clientHeight - 650
this.listDepartmentTree() this.listDepartmentTree()
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<div class="select-sale-panel"> <div class="select-sale-panel">
<select-emp <select-emp
:selectData="selectData" :selectData="selectData"
@group="handlGroup" :islord="islord"
@selectTable="selectTable" @selectTable="selectTable"
ref="selectEmpTabel" ref="selectEmpTabel"
></select-emp> ></select-emp>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
import selectEmp from './selectEmp.vue' import selectEmp from './selectEmp.vue'
export default { export default {
name: 'SelectMembers', name: 'SelectMembers',
props: ['selectData'], props: ['selectData', 'islord'],
components: { components: {
selectEmp selectEmp
}, },
......
...@@ -3,15 +3,30 @@ ...@@ -3,15 +3,30 @@
<!-- <div class="required">入群欢迎语</div> --> <!-- <div class="required">入群欢迎语</div> -->
<div class="content"> <div class="content">
<div class="content-bg"> <div class="content-bg">
<el-input <!-- <div id="nick" contenteditable="false" class="nickname">
@昵称
<i class="el-icon-error"></i>
</div>-->
<!-- <div id="toolbar-container" style="display: none;"></div>
<div id="text-container" class="editor-container"></div>-->
<div
id="editor"
ref="editor"
@input="changeInput"
class="text-editor"
contenteditable="true"
autofocus
></div>
<!-- <el-input
type="textarea" type="textarea"
:rows="9" :rows="9"
maxlength="600" maxlength="600"
show-word-limit show-word-limit
v-model="guestForm.name" v-model="guestForm.name"
@input="textInput" @input="textInput"
style="-webkit-user-modify: read-write-plaintext-only !important;"
placeholder="请输入内容" placeholder="请输入内容"
></el-input> ></el-input>-->
<div v-for="itm in previewList" :key="itm.id"> <div v-for="itm in previewList" :key="itm.id">
<div class="welcome-file" v-if="itm.attType != 1"> <div class="welcome-file" v-if="itm.attType != 1">
<template v-if="itm.attType == 2"> <template v-if="itm.attType == 2">
...@@ -22,9 +37,9 @@ ...@@ -22,9 +37,9 @@
<img src="@/assets/guestCustom/icon-img.png" alt /> <img src="@/assets/guestCustom/icon-img.png" alt />
<span>{{ itm.attContent }}</span> <span>{{ itm.attContent }}</span>
</template> </template>
<template v-else-if="itm.attType == 4"> <template v-else-if="itm.attType == 7">
<img src="@/assets/guestCustom/icon-link.png" alt /> <img src="@/assets/guestCustom/icon-applet.png" alt />
<span>{{ itm.attContent.url }}</span> <span>{{ itm.attContent.marketingName }}</span>
</template> </template>
<template v-else-if="itm.attType == 5"> <template v-else-if="itm.attType == 5">
<img src="@/assets/guestCustom/icon-applet.png" alt /> <img src="@/assets/guestCustom/icon-applet.png" alt />
...@@ -35,9 +50,9 @@ ...@@ -35,9 +50,9 @@
</div> </div>
<div class="btn-group"> <div class="btn-group">
<div class="add-btn" v-for="item in btnList" :key="item.id"> <div class="add-btn" v-for="item in btnList" :key="item.id">
<i class="el-icon-circle-plus-outline"></i> <!-- <i class="el-icon-circle-plus-outline"></i> -->
<img :src="require(`@/assets/guestCustom/add-${item.type}.png`)" alt />
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
<!-- <div id="video"></div> -->
<input <input
v-if="item.type == 'img'" v-if="item.type == 'img'"
type="file" type="file"
...@@ -49,7 +64,7 @@ ...@@ -49,7 +64,7 @@
@change="e => handleImgChange(e, item)" @change="e => handleImgChange(e, item)"
/> />
<input <input
v-if="item.type == 'video'" v-else-if="item.type == 'video'"
type="file" type="file"
style="opacity: 0" style="opacity: 0"
:id="item.name + 'file'" :id="item.name + 'file'"
...@@ -58,11 +73,7 @@ ...@@ -58,11 +73,7 @@
:accept="item.accept || 'video/*'" :accept="item.accept || 'video/*'"
@change="e => handleVideoChange(e, item)" @change="e => handleVideoChange(e, item)"
/> />
<el-link <el-link v-else style="opacity: 0" @click="handleFun(item.funName)">{{ item.name }}</el-link>
v-if="item.type == 'popup'"
style="opacity: 0"
@click="switchDailog(item.funName)"
>{{ item.name }}</el-link>
</div> </div>
</div> </div>
</div> </div>
...@@ -71,85 +82,7 @@ ...@@ -71,85 +82,7 @@
<span>客户每个月最多接收来自同一企业的管理员的 4 条群发消息,4条消息可在同一天发送,达到上限后,无法再接收管理员的群发消息。</span> <span>客户每个月最多接收来自同一企业的管理员的 4 条群发消息,4条消息可在同一天发送,达到上限后,无法再接收管理员的群发消息。</span>
</div> </div>
</div> </div>
<!-- <div class="required">发送时间</div> <ActivityModel ref="activity" @selectActivity="selectActivity"></ActivityModel>
<div class="content">
<el-radio-group v-model="sendType">
<el-radio :label="1">立即发送</el-radio>
<el-radio :label="2">定时发送</el-radio>
</el-radio-group>
<div v-show="sendType == 2" class="date-picker">
<el-date-picker v-model="sendTime" size="small" type="date" placeholder="选择日期"></el-date-picker>
-
<el-time-picker v-model="sendDate" size="small" placeholder="选择时间"></el-time-picker>
</div>
</div>-->
<glsx-dialog
:title="dialogTitle"
:width="'712px'"
:isVisible="dialogVisible"
@confirmDialog="handleConfirm"
@closeDialog="dialogVisible = !dialogVisible"
>
<slot>
<el-form
v-if="dialogTitle == '添加网页消息'"
:model="linkForm"
:rules="linkRules"
ref="linkForm"
label-width="120px"
>
<el-form-item label="网页标题" prop="title">
<el-input v-model="linkForm.title" placeholder="请输入网页标题"></el-input>
</el-form-item>
<el-form-item label="添加网页链接" prop="url">
<el-input v-model="linkForm.url" placeholder="以http或https开头"></el-input>
</el-form-item>
</el-form>
<el-form
v-else-if="dialogTitle == '添加小程序'"
:model="appletForm"
:rules="appletRules"
ref="appletForm"
label-width="120px"
>
<el-form-item label="小程序标题" prop="title">
<el-input v-model="appletForm.title" placeholder="请输入小程序标题"></el-input>
</el-form-item>
<el-form-item label="小程序appID" prop="appid">
<el-input v-model="appletForm.appid" placeholder="请输入小程序appID"></el-input>
</el-form-item>
<el-form-item label="小程序路径" prop="page">
<el-input v-model="appletForm.page" placeholder="请输入小程序路径"></el-input>
<div class="form-tips">注意:小程序路径以html作为后缀</div>
</el-form-item>
<el-form-item label="小程序封面" prop="page">
<div class="upload">
<div v-show="!appletForm.picUrl" class="upload-bg">
<i class="el-icon-circle-plus"></i>
<div class="upload-text">上传封面</div>
</div>
<input
type="file"
style="opacity: 0"
ref="file"
class="form-upload img-w-h"
accept="image/png, image/jpeg, image/gif, image/jpg"
@change="handleImg"
/>
<el-image
v-show="appletForm.picUrl"
style="width: 140px"
:src="appletForm.picUrl"
fit="contain"
></el-image>
</div>
<div class="form-tips">建议图片大小在2M以内,建议尺寸:352*282px</div>
</el-form-item>
</el-form>
</slot>
</glsx-dialog>
</div> </div>
</template> </template>
<script> <script>
...@@ -159,66 +92,75 @@ const ATT_TYPE = { ...@@ -159,66 +92,75 @@ const ATT_TYPE = {
VEDIO: 3, VEDIO: 3,
URL: 4, URL: 4,
MINIPROGRAM: 5, MINIPROGRAM: 5,
FILE: 6 FILE: 6,
ACTIVITY: 7
} }
// import E from 'wangeditor'
import ActivityModel from './activityModel'
import { debounce } from '@/utils/index'
export default { export default {
name: 'WelcomeWords', name: 'WelcomeWords',
components: {
ActivityModel
},
props: { eventBus: Object }, props: { eventBus: Object },
data() { data() {
return { return {
btnList: [ btnList: [
// {
// id: 1,
// name: '表情',
// funcName: '',
// type: 'expression',
// limitSize: 10
// },
{ {
id: 1, id: 2,
name: '图片', name: '图片',
funcName: '', funcName: '',
type: 'img', type: 'img',
limitSize: 10 limitSize: 10
}, },
{ // {
id: 2, // id: 3,
name: '视频', // name: '昵称',
funcName: '', // type: 'nickname',
type: 'video', // funName: 'nickname'
limitSize: 10 // },
},
{
id: 3,
name: '链接',
type: 'popup',
funName: 'link'
},
{ {
id: 4, id: 4,
name: '小程序', name: '活动',
type: 'popup', type: 'acivity',
funName: 'applet' funName: 'activity'
} }
], ],
guestForm: {}, guestForm: {},
dialogTitle: '',
dialogVisible: false,
linkForm: {},
linkRules: {
title: [{ required: true, message: '请输入网页标题', trigger: 'blur' }],
url: [{ required: true, message: '请输入网页链接', trigger: 'blur' }]
},
appletForm: {},
appletRules: {
title: [{ required: true, message: '请输入网页标题', trigger: 'blur' }],
appid: [{ required: true, message: '请输入网页链接', trigger: 'blur' }],
page: [{ required: true, message: '请输入小程序路径', trigger: 'blur' }]
},
previewList: [], previewList: [],
sendType: '', sendType: '',
sendTime: '', sendTime: '',
sendDate: '' sendDate: '',
editor: {}
} }
}, },
mounted() { mounted() {
// const _this = this
// this.editor = new E('#toolbar-container', '#text-container')
// this.editor.config.zIndex = 100
// this.editor.config.height = 165
// this.editor.config.colors = ['#000000', '#f7f7f7']
// this.editor.config.focus = false
// this.editor.config.onchange = function(newHtml) {
// console.log('change 之后最新的 html', newHtml)
// console.log(_this.editor.txt.text())
// const val = _this.editor.txt.text()
// _this.textInput(val)
// }
// this.editor.config.onchangeTimeout = 500
// this.editor.create()
this.eventBus.$emit('update', this.previewList) this.eventBus.$emit('update', this.previewList)
// obj.init('video')
}, },
methods: { methods: {
// 上传图片
handleImgChange(e, targetItem) { handleImgChange(e, targetItem) {
var reader = new FileReader() var reader = new FileReader()
var file = e.srcElement.files[0] var file = e.srcElement.files[0]
...@@ -250,6 +192,7 @@ export default { ...@@ -250,6 +192,7 @@ export default {
} }
} }
}, },
// 上传视频
handleVideoChange(e, targetItem) { handleVideoChange(e, targetItem) {
var file = e.srcElement.files[0] var file = e.srcElement.files[0]
var reader = new FileReader() var reader = new FileReader()
...@@ -275,77 +218,29 @@ export default { ...@@ -275,77 +218,29 @@ export default {
}) })
} }
}, },
handleImg(e) { // 添加昵称
var reader = new FileReader() handleFun(name) {
var file = e.srcElement.files[0] if (name == 'nickname') {
console.log(file) this.$refs.editor.focus()
// 默认1MB this.insertHtmlAtCaret('@昵称')
const limitSize = 10 this.changeInput()
const isLt = file.size / 1024 / 1024 < limitSize // var range = window.getSelection().getRangeAt(0)
if (!isLt) { // console.log(range)
this.$message.error('上传图片大小不能超过' + limitSize + 'MB!') // range.selectNodeContents(range.endContainer.childNodes[range.startOffset - 2])
return true // var el = document.createElement('span')
} // el.setAttribute('contenteditable', false)
reader.readAsDataURL(file) // el.setAttribute('class', 'nickname')
reader.onload = e => { // el.innerHTML = '@昵称<i class="el-icon-error"></i>'
var image = new Image() // el.innerHTML = '<span id="nick" contenteditable="false" class="nickname">@昵称<i class="el-icon-error"></i></span>'
image.src = e.target.result // var node = document.getElementById('nick')
image.onload = () => { // var targetNode = document.getElementById('editor')
const imgFile = e.target.result // targetNode.appendChild(el)
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1] // var EL = document.createElement('div')
this.$apis.common.pictureUpload({ file: base64 }).then(res => { // EL.setAttribute('contenteditable', true)
if (res) { // targetNode.appendChild(EL)
console.log(res) // this.editor.txt.append('<span class="nickname">@昵称<i class="el-icon-error"></i><span>')
this.$set(this.appletForm, 'picUrl', res) } else if (name == 'activity') {
// this.appletForm.picUrl = res this.$refs.activity.init()
}
})
}
}
},
switchDailog(funName) {
if (funName == 'link') {
this.dialogTitle = '添加网页消息'
} else if (funName == 'applet') {
this.dialogTitle = '添加小程序'
}
this.dialogVisible = !this.dialogVisible
},
handleConfirm() {
const { dialogTitle } = this
switch (dialogTitle) {
case '添加网页消息':
this.$refs.linkForm.validate(valid => {
if (valid) {
console.log(this.linkForm)
this.previewList.push({
attType: ATT_TYPE.URL,
attContent: this.linkForm
})
this.dialogVisible = !this.dialogVisible
} else {
console.log('error submit!!')
return false
}
})
break
case '添加小程序':
this.$refs.appletForm.validate(valid => {
if (valid) {
console.log(this.appletForm)
this.previewList.push({
attType: ATT_TYPE.MINIPROGRAM,
attContent: this.appletForm
})
this.dialogVisible = !this.dialogVisible
} else {
console.log('error submit!!')
return false
}
})
break
default:
console.log(dialogTitle)
} }
}, },
close(index) { close(index) {
...@@ -365,7 +260,58 @@ export default { ...@@ -365,7 +260,58 @@ export default {
attType: ATT_TYPE.TEXT attType: ATT_TYPE.TEXT
}) })
} }
} },
selectActivity(val) {
console.log(val)
if (val) {
this.previewList.push({
attContent: val,
attType: ATT_TYPE.ACTIVITY
})
}
},
insertHtmlAtCaret(html) {
var sel, range, frag
if (window.getSelection) {
sel = window.getSelection()
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0)
range.deleteContents()
var el = document.createElement('span')
el.innerHTML = '<span contenteditable="false" class="nickname">@昵称<i class="el-icon-error"></i></span>'
// var el = document.createElement('div')
// el.innerHTML = html
frag = document.createDocumentFragment()
var node
var lastNode
while ((node = el.firstChild)) {
lastNode = frag.appendChild(node)
}
range.insertNode(frag)
if (lastNode) {
range = range.cloneRange()
range.setEndAfter(lastNode)
range.collapse(true)
sel.removeAllRanges()
sel.addRange(range)
}
}
}
},
changeInput: debounce(function() {
console.log(document.getElementById('editor').childNodes)
var allNodes = document.getElementById('editor').childNodes
var str = ''
allNodes.forEach(item => {
if (item.className == 'nickname') {
str += item.innerText
} else if (item.data) {
str += item.data
}
})
console.log(str)
this.textInput(str)
})
} }
} }
</script> </script>
...@@ -385,6 +331,7 @@ export default { ...@@ -385,6 +331,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
color: #999; color: #999;
line-height: 20px;
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
border-left: 1px solid #dcdfe6; border-left: 1px solid #dcdfe6;
...@@ -431,6 +378,10 @@ export default { ...@@ -431,6 +378,10 @@ export default {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
} }
img {
width: 16px;
height: 16px;
}
.el-link { .el-link {
position: absolute; position: absolute;
width: 100%; width: 100%;
...@@ -522,4 +473,44 @@ export default { ...@@ -522,4 +473,44 @@ export default {
margin-right: 8px; margin-right: 8px;
} }
} }
// 编辑器
.editor-container {
border: 1px solid #dcdfe6;
min-height: 165px;
/deep/ {
.w-e-text {
background-color: #f7f7f7;
}
}
}
.text-editor {
outline: 0;
width: 100%;
min-height: 200px;
max-height: 200px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
padding: 5px;
line-height: 20px;
font-size: 12px;
word-wrap: break-word;
overflow-x: hidden;
overflow-y: auto;
_overflow-y: visible;
}
/deep/.nickname {
display: inline;
// width: 64px;
// height: 20px;
border-radius: 2px;
background-color: #fff;
font-size: 14px;
color: #5850ff;
line-height: 20px;
padding: 2px;
margin: 0 5px;
i {
font-size: 10px;
}
}
</style> </style>
...@@ -70,8 +70,8 @@ export default { ...@@ -70,8 +70,8 @@ export default {
console.log(val) console.log(val)
const xData = val.map(i => i.dataDateStr) const xData = val.map(i => i.dataDateStr)
const yData = val.map(i => i.amount) const yData = val.map(i => i.amount)
this.option.xAxis.data = xData.reverse() this.option.xAxis.data = xData
this.option.series[0].data = yData.reverse() this.option.series[0].data = yData
this.option.series[0].count = val.map(i => i.count) this.option.series[0].count = val.map(i => i.count)
this.option && this.myChart.setOption(this.option) this.option && this.myChart.setOption(this.option)
} }
......
...@@ -366,21 +366,24 @@ export default { ...@@ -366,21 +366,24 @@ export default {
switch (name) { switch (name) {
case 'week': case 'week':
startTime = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek) startTime = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek)
endTime = new Date(nowYear, nowMonth, nowDay + 6 - nowDayOfWeek) endTime = new Date()
// endTime = new Date(nowYear, nowMonth, nowDay + 6 - nowDayOfWeek)
this.$set(this.date, 0, startTime) this.$set(this.date, 0, startTime)
this.$set(this.date, 1, endTime) this.$set(this.date, 1, endTime)
this.dateChange(this.date) this.dateChange(this.date)
break break
case 'month': case 'month':
startTime = new Date(nowYear, nowMonth, 1) startTime = new Date(nowYear, nowMonth, 1)
endTime = new Date(nowYear, nowMonth + 1, 0) endTime = new Date()
// endTime = new Date(nowYear, nowMonth + 1, 0)
this.$set(this.date, 0, startTime) this.$set(this.date, 0, startTime)
this.$set(this.date, 1, endTime) this.$set(this.date, 1, endTime)
this.dateChange(this.date) this.dateChange(this.date)
break break
case 'year': case 'year':
startTime = new Date(nowYear, 0, 1) startTime = new Date(nowYear, 0, 1)
endTime = new Date(nowYear, 11, 31) endTime = new Date()
// endTime = new Date(nowYear, 11, 31)
this.$set(this.date, 0, startTime) this.$set(this.date, 0, startTime)
this.$set(this.date, 1, endTime) this.$set(this.date, 1, endTime)
this.dateChange(this.date) this.dateChange(this.date)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!