Commit 497e9834 by xinla

欢迎语新增小程序,图文等功能

1 parent 8a9c5c1f
...@@ -14,7 +14,7 @@ const service = window.CONFIG.services.wecom + '/tlp' ...@@ -14,7 +14,7 @@ const service = window.CONFIG.services.wecom + '/tlp'
export function getList(params) { export function getList(params) {
return request({ return request({
url: service + '/list', url: service + '/list',
params, params
}) })
} }
...@@ -24,53 +24,59 @@ export function getList(params) { ...@@ -24,53 +24,59 @@ export function getList(params) {
*/ */
export function getScop(id) { export function getScop(id) {
return request({ return request({
url: service + '/scop/' + id, url: service + '/scop/' + id
}) })
} }
/** /**
* 编辑欢迎语模板 * 新增或更新欢迎语模板
* @param {*} data * @param {*} data
{ {
"id": "主键", "id":12312, //主键,存在为更新,不存在为新增
"mediaId": "素材的id", "welcomeMsg":"", //欢迎语
"welcomeMsg": "欢迎语", "picUrl":"", //图片
"welcomeMsgTplType": "欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语", "applet":[{ //小程序
"weMsgTlpScopes": [ "appTile":"", //小程序标题
{ "appId":"", //小程序id
"useUserId": "使用人员id" "appPath":"", //小程序路径
} "appPic":"" //小程序封面
] }],
"imageText":[{ //图文
"imageTextTile":"",//图文标题
"imageTextUrl":"" //图文路径
}],
"welcomeMsgTplType":2, //1:活码欢迎语;2:员工欢迎语;3:入群欢迎语
"userIds":"ShengXiYong,SunXiWang" //员工欢迎语使用范围,员工id用逗号隔开
} }
*/ */
export function update(data) { export function addOrUpdate(data) {
return request({ return request({
url: service, url: service + '/addorUpdate',
method: 'put',
data,
})
}
/**
* 新增欢迎语模板
* @param {*} data
{
"welcomeMsg": "欢迎语",
"mediaId": "素材的id",
"welcomeMsgTplType": "欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语 ",
"weMsgTlpScopes": {
"useUserId": "使用人的id"
}
}
*/
export function add(data) {
return request({
url: service,
method: 'POST', method: 'POST',
data, data
}) })
} }
// /**
// * 新增欢迎语模板
// * @param {*} data
// {
// "welcomeMsg": "欢迎语",
// "mediaId": "素材的id",
// "welcomeMsgTplType": "欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语 ",
// "weMsgTlpScopes": {
// "useUserId": "使用人的id"
// }
// }
// */
// export function add(data) {
// return request({
// url: service,
// method: 'POST',
// data
// })
// }
/** /**
* 删除欢迎语 * 删除欢迎语
* @param {*} ids * @param {*} ids
...@@ -78,6 +84,16 @@ export function add(data) { ...@@ -78,6 +84,16 @@ export function add(data) {
export function remove(ids) { export function remove(ids) {
return request({ return request({
url: service + '/' + ids, url: service + '/' + ids,
method: 'DELETE', method: 'DELETE'
})
}
// 预览数据
export function getPreview(id) {
return request({
url: service + '/tlp/preview',
params: {
id
}
}) })
} }
...@@ -16,7 +16,7 @@ export default { ...@@ -16,7 +16,7 @@ export default {
// }, // },
// 素材类型 0:'文本', 1:'图片' // 素材类型 0:'文本', 1:'图片'
type: { type: {
type: String, type: String | Number,
default: '0' default: '0'
}, },
// 显示哪些素材类型标签 // 显示哪些素材类型标签
...@@ -69,12 +69,7 @@ export default { ...@@ -69,12 +69,7 @@ export default {
</script> </script>
<template> <template>
<el-dialog <el-dialog title="选择素材" :visible.sync="Pvisible" width="680px" append-to-body>
title="选择素材"
:visible.sync="Pvisible"
width="680px"
append-to-body
>
<div> <div>
<el-tabs v-model="Ptype"> <el-tabs v-model="Ptype">
<el-tab-pane name="0" v-if="showArr.includes(0)"> <el-tab-pane name="0" v-if="showArr.includes(0)">
......
...@@ -8,22 +8,26 @@ export default { ...@@ -8,22 +8,26 @@ export default {
// 添加标签显隐 // 添加标签显隐
visible: { visible: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
title: { title: {
type: String, type: String,
default: '组织架构', default: '组织架构'
}, },
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点) // 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: { isOnlyLeaf: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
// 是否单选 // 是否单选
isSigleSelect: { isSigleSelect: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
defaultValues: {
type: Array,
default: () => []
}
}, },
data() { data() {
let isOnlyLeaf = this.isOnlyLeaf let isOnlyLeaf = this.isOnlyLeaf
...@@ -38,8 +42,8 @@ export default { ...@@ -38,8 +42,8 @@ export default {
}, },
isLeaf(data, node) { isLeaf(data, node) {
return !!data.userId return !!data.userId
}, }
}, }
} }
}, },
watch: {}, watch: {},
...@@ -51,15 +55,34 @@ export default { ...@@ -51,15 +55,34 @@ export default {
}, },
set(val) { set(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
}, }
}, },
defaultCheckedKeys() {
const checkedList = []
const checkedUserList = []
if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
this.userList = []
} else {
this.defaultValues.forEach((i) => {
const id = this.isOnlyLeaf ? i.userId : i.userId || i.id
if (id) {
checkedList.push(id)
checkedUserList.push(i)
}
})
this.userList = checkedUserList
}
return checkedList
}
}, },
created() {}, created() {},
mounted() {}, mounted() {},
methods: { methods: {
loadNode(node, resolve) { loadNode(node, resolve) {
if (node.level === 0) { if (node.level === 0) {
this.userList = [] if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
this.userList = []
}
getTree().then(({ data }) => { getTree().then(({ data }) => {
data.forEach((element) => { data.forEach((element) => {
element.key = createUniqueString() element.key = createUniqueString()
...@@ -73,15 +96,13 @@ export default { ...@@ -73,15 +96,13 @@ export default {
// }); // });
}) })
} else { } else {
getList({ department: node.data.id, isActivate: 1 }).then( getList({ department: node.data.id, isActivate: 1 }).then(({ rows }) => {
({ rows }) => { rows.forEach((element) => {
rows.forEach((element) => { element.key = createUniqueString()
element.key = createUniqueString() })
}) node.data.children && rows.push(...node.data.children)
node.data.children && rows.push(...node.data.children) resolve(rows)
resolve(rows) })
}
)
} }
}, },
// 选择变化 // 选择变化
...@@ -114,8 +135,8 @@ export default { ...@@ -114,8 +135,8 @@ export default {
// 取消选择 // 取消选择
cancle(key) { cancle(key) {
this.$refs.tree.setChecked(key, false) this.$refs.tree.setChecked(key, false)
}, }
}, }
} }
</script> </script>
setChecked setChecked
...@@ -137,6 +158,7 @@ setChecked ...@@ -137,6 +158,7 @@ setChecked
:expand-on-click-node="true" :expand-on-click-node="true"
:load="loadNode" :load="loadNode"
:props="defaultProps" :props="defaultProps"
:default-checked-keys="defaultCheckedKeys"
:check-strictly="!isOnlyLeaf" :check-strictly="!isOnlyLeaf"
@check-change="handleCheckChange" @check-change="handleCheckChange"
></el-tree> ></el-tree>
...@@ -148,11 +170,7 @@ setChecked ...@@ -148,11 +170,7 @@ setChecked
<el-row v-for="(item, index) in userList" :key="index"> <el-row v-for="(item, index) in userList" :key="index">
<i class="el-icon-user-solid"></i> <i class="el-icon-user-solid"></i>
{{ item.name }} {{ item.name }}
<i <i class="el-icon-minus fr cp" title="取消选择" @click="cancle(item.key)"></i>
class="el-icon-minus fr cp"
title="取消选择"
@click="cancle(item.key)"
></i>
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
......
<template>
<div class="preview">
<div class="title">{{name}}</div>
<div class="content">
<div class="item">
<div class="avatar"><img src="../assets/drainageCode/header.png"></div>
<div class="msg">
<div class="word">
{{list.welcomeMsg}}
</div>
</div>
</div>
<div class="item" v-for="(data, key) in list.materialMsgList" :key="key">
<div class="avatar"><img src="../assets/drainageCode/header.png"></div>
<div class="msg" v-if="data.msgType === 4">
<div class="word">
{{data.content}}
</div>
</div>
<div class="msg" v-if="data.msgType === 0">
<div class="image">
<img :src="data.materialUrl" />
</div>
</div>
<div class="msg" v-if="data.msgType === 7">
<div class="word-and-image">
<div>
{{data.materialName}}
</div>
<div class="sub-content">
<div>
{{data.digest}}
</div>
<div>
<img src="../assets/drainageCode/default_icon.png" />
</div>
</div>
</div>
</div>
<div class="msg" v-if="data.msgType === 8">
<div class="miniprogram">
<div class="mini-header">
<img src="../assets/drainageCode/miniprogram-icon.png" alt="">
{{data.materialName}}
</div>
<img class="mini-img" :src="data.coverUrl" >
<div class="mini-footer">
<img src="../assets/drainageCode/miniprogram-link.png" />
小程序
</div>
</div>
</div>
</div>
<!-- <div class="item">
<div class="avatar"><img src="../assets/drainageCode/header.png"></div>
<div class="msg">
<div class="image">
<img src="../assets/drainageCode/demo-img.png" />
</div>
</div>
</div> -->
<!-- <div class="item">
<div class="avatar"><img src="../assets/drainageCode/header.png"></div>
<div class="msg">
<div class="word-and-image">
<div>
全新智能电池系统,首秀小米
</div>
<div class="sub-content">
<div>
三大能力延缓电池老化
</div>
<div>
<img src="../assets/drainageCode/preview-middle-img.png" />
</div>
</div>
</div>
</div>
</div> -->
<!-- <div class="item">
<div class="avatar"><img src="../assets/drainageCode/header.png"></div>
<div class="msg">
<div class="miniprogram">
<div class="mini-header">
<img src="../assets/drainageCode/miniprogram-icon.png" alt="">
测试测试测试测试
</div>
<img class="mini-img" src="../assets/drainageCode/miniprogram-img.png" >
<div class="mini-footer">
<img src="../assets/drainageCode/miniprogram-link.png" />
小程序
</div>
</div>
</div>
</div> -->
</div>
</div>
</template>
<script>
export default {
name: 'preview-client',
components: {},
props: {
name: {
type: String,
default: "小微"
},
list: {
type: Object,
default: {}
}
},
data() {
return {}
},
watch: {
},
computed: {},
created() {},
mounted() {},
methods: {},
}
</script>
<style lang="scss" scoped>
.preview {
margin: 0 auto;
position: relative;
width: 300px;
height: 640px;
background: url(../assets/drainageCode/preview-bg.png);
background-repeat: no-repeat;
background-size: 100% 100%;
.title {
position: absolute;
top: 37px;
left: 50%;
transform: translateX(-50%);
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
}
.content {
position: absolute;
height: 545px;
width: 280px;
overflow-y: auto;
top: 70px;
left: 50%;
transform: translateX(-50%);
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
padding: 20px;
.item {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
display: flex;
margin-top: 20px;
&:first-child {
margin-top: 0;
}
.avatar {
// align-self: center;
margin-right: 5px;
}
.msg {
position: relative;
min-height: 26px;
background: #FFFFFF;
box-shadow: 0px 2px 6px 0px rgba(60, 136, 240, 0.1);
border: 1px solid #E1EDFC;
display: inline-block;
border-radius: 4px;
box-sizing: border-box;
word-break: break-all;
margin-left: 5px;
&:before {
content: ' ';
display: block;
position: absolute;
left: -5px;
box-shadow: 0px 2px 6px 0px rgba(60, 136, 240, 0.1);
border-width: 5px;
border-left: 0;
width: 0;
border-style: solid;
border-color: transparent;
border-right-color: #fff;
top: 8px;
z-index: 888;
}
.word {
padding: 5px 12px;
}
.image {
padding: 12px;
img {
width: 94px;
height: 90px;
}
}
.word-and-image {
padding: 12px;
.sub-content {
margin-top: 10px;
display: flex;
justify-content: space-between;
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
img {
height: 40px;
width: 40px;
}
}
}
.miniprogram {
padding: 12px;
.mini-header {
display: flex;
align-items: center;
img {
height: 18px;
width: 18px;
margin-right: 5px;
}
}
.mini-img {
margin: 10px 0;
width: 143px;
height: 120px;
}
.mini-footer {
display: flex;
align-items: center;
img {
height: 14px;
width: 14px;
margin-right: 5px;
}
}
}
}
}
}
}
</style>
<script> <script>
import { update, add } from '@/api/drainageCode/welcome' import { addOrUpdate, getPreview } from '@/api/drainageCode/welcome'
import PhoneDialog from '@/components/PhoneDialog'
import SelectMaterial from '@/components/SelectMaterial' import SelectMaterial from '@/components/SelectMaterial'
import WelcomeContent from '@/components/WelcomeContent.vue'
export default { export default {
components: { PhoneDialog, SelectMaterial }, components: {
SelectMaterial,
WelcomeContent
},
props: {}, props: {},
data() { data() {
return { return {
materialData: {
welcomeMsg: '',
materialMsgList: []
},
dialogVisible: false, dialogVisible: false,
// dialogVisible1: false,
dialogVisibleSelectMaterial: false, dialogVisibleSelectMaterial: false,
form: { form: {
// id: '', // id: '',
mediaId: '',
welcomeMsgTplType: '', welcomeMsgTplType: '',
welcomeMsg: '', welcomeMsg: '',
materialUrl: '', materialUrl: ''
}, },
// 遮罩层 // 遮罩层
loading: false, loading: false
} }
}, },
watch: {}, watch: {},
...@@ -27,16 +31,62 @@ export default { ...@@ -27,16 +31,62 @@ export default {
created() { created() {
this.form = Object.assign(this.form, this.$route.query) this.form = Object.assign(this.form, this.$route.query)
this.$route.meta.title = (this.form.id ? '编辑' : '新建') + '欢迎语' this.$route.meta.title = (this.form.id ? '编辑' : '新建') + '欢迎语'
this.form.id && this.getData()
}, },
mounted() {}, mounted() {},
methods: { methods: {
getData() {}, getWelData(data) {
let form = this.form
form.welcomeMsg = data.welcomeMsg
// this.form.mediaId = data.mediaId
// this.form.materialMsgList = data.materialMsgList
data.materialMsgList.forEach((element) => {
// 0 图片;4文本;7图文;8小程序
if (element.msgType == 0) {
;(form.picUrl || (form.picUrl = [])).push(element.materialUrl)
} else if (element.msgType == 7) {
;(form.imageText || (form.imageText = [])).push({
imageTextTile: element.materialName, //图文标题
imageTextUrl: element.content //图文路径
})
} else if (element.msgType == 8) {
;(form.applet || (form.applet = [])).push({
appTile: element.materialName, //小程序标题
appId: element.materialUrl, //小程序id
appPath: element.content, //小程序路径
appPic: element.coverUrl //小程序封面
})
}
})
if (form.welcomeMsgTplType === '1') {
form.userIds = data.users.map((e) => e.userId) + ''
}
form.picUrl += ''
this.submit()
},
getData() {
getPreview(this.form.id).then(({ data }) => {
this.materialData = {}
this.materialData = data
this.materialData.materialMsgList.forEach((item) => {
item.msgType = Number(item.msgType)
})
})
},
submit() { submit() {
;(this.form.id ? update : add)(this.form) debugger
addOrUpdate(this.form)
.then(({ data }) => { .then(({ data }) => {
this.msgSuccess('操作成功') this.msgSuccess('操作成功')
this.loading = false this.loading = false
this.$router.back() // this.$router.back()
// console.log(form.welcomeMsgTplType === '1')
this.$router.push({
path: '/wechat/drainageCode/welcome/',
query: {
type: this.form.welcomeMsgTplType
}
})
}) })
.catch(() => { .catch(() => {
this.loading = false this.loading = false
...@@ -54,157 +104,19 @@ export default { ...@@ -54,157 +104,19 @@ export default {
removeMaterial() { removeMaterial() {
this.form.mediaId = '' this.form.mediaId = ''
this.form.materialUrl = '' this.form.materialUrl = ''
}, }
}, }
} }
</script> </script>
<template> <template>
<div class="flex page" v-loading="loading"> <welcome-content
<el-form ref="form" :model="form" label-width="80px" class="form"> :showTemplate="false"
<el-form-item label="欢迎语"> :showMember="form.welcomeMsgTplType == 2"
<el-card shadow="never" class="card"> :showMorMaterial="true"
<div style="height: 200px;"> :baseData="materialData"
<el-input @submit="getWelData"
type="textarea" ></welcome-content>
:autosize="{ minRows: 2, maxRows: 6 }"
maxlength="100"
show-word-limit
placeholder="请输入欢迎语"
v-model="form.welcomeMsg"
></el-input>
</div>
<div class="bfc-o">
<div v-if="form.materialUrl">
<el-image
style="width: 100px; height: 100px; cursor: pointer;border-radius: 6px;"
:src="form.materialUrl"
fit="fit"
>
</el-image>
<i class="el-icon-error" @click="removeMaterial"></i>
</div>
<el-button
icon="el-icon-plus"
size="mini"
@click="dialogVisibleSelectMaterial = true"
>
添加图片
</el-button>
<el-button
type="default"
class="fr"
round
icon="el-icon-user-solid"
@click="insertName()"
>插入客户昵称</el-button
>
</div>
<!-- <el-popover placement="top-start" trigger="hover">
<div class="ac">
<Upload
><el-button>
<i class="el-icon-picture-outline"></i>
<p>图片</p>
</el-button></Upload
>
<el-button @click="dialogVisible = true">
<i class="el-icon-link"></i>
<p>网页</p>
</el-button>
<el-button @click="dialogVisible1 = true">
<i class="el-icon-link"></i>
<p>小程序</p>
</el-button>
</div>
<el-button slot="reference" icon="el-icon-plus" size="mini"
>添加图片</el-button
>
</el-popover> -->
</el-card>
</el-form-item>
<el-form-item label=" " class="ar">
<el-button type="primary" @click="submit">保存</el-button>
<el-button @click="$router.back()">取消</el-button>
</el-form-item>
</el-form>
<PhoneDialog
style="margin-left: 10%;"
:message="form.welcomeMsg || '请输入欢迎语'"
:isOther="!!form.materialUrl"
>
<el-image style="border-radius: 6px;" :src="form.materialUrl" fit="fit">
</el-image
></PhoneDialog>
<!-- 选择素材弹窗 -->
<SelectMaterial
:visible.sync="dialogVisibleSelectMaterial"
type="1"
:showArr="[1]"
@success="submitSelectMaterial"
>
</SelectMaterial>
<!-- <el-dialog title="添加网页消息" :visible.sync="dialogVisible" width="width">
<el-form :model="form" inline>
<el-form-item label="添加网页消息" label-width="200">
<el-input
style="width: 400px;"
v-model="j"
placeholder="以http或https开头"
></el-input>
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="dialogVisible = false"
>确 定</el-button
>
</div>
</el-dialog> -->
<!-- <el-dialog
title="添加小程序消息"
:visible.sync="dialogVisible1"
width="width"
>
<div class="flex filter-wrap">
<el-select v-model="model" placeholder="请选择分组">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<el-input v-model="j" style="width: 240px;"></el-input>
<el-button type="primary">搜索</el-button>
<div class="filter-right">
<i class="el-icon-arrow-left"></i> 1/1
<i class="el-icon-arrow-right"></i>
</div>
</div>
<el-divider></el-divider>
<div class="flex list-wrap">
<el-card v-for="(item, index) in 5" :key="index">
<div>2020-20-02-02 20:20:20</div>
<div>标题标题标题</div>
<img src="@/assets/image/profile.jpg" alt />
</el-card>
</div>
<div slot="footer">
<el-button @click="dialogVisible1 = false">取 消</el-button>
<el-button type="primary" @click="dialogVisible1 = false">确 定</el-button>
</div>
</el-dialog>-->
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
<style lang="scss" scoped></style>
<template> <template>
<div> <div>
<el-tabs :value="active"> <el-tabs :value="active">
...@@ -28,7 +26,7 @@ export default { ...@@ -28,7 +26,7 @@ export default {
active: '1', active: '1',
total1: 0, total1: 0,
total2: 0, total2: 0,
total3: 0, total3: 0
} }
}, },
watch: {}, watch: {},
...@@ -52,7 +50,9 @@ export default { ...@@ -52,7 +50,9 @@ export default {
methods: { methods: {
totalChange([type, total]) { totalChange([type, total]) {
this['total' + type] = total this['total' + type] = total
}, }
}, }
} }
</script> </script>
<style lang="scss" scoped></style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!