Commit dfff8d8b by 李伟康

提交话术库

1 parent a4f5ba62
import { http } from '@/main'
export default {
/** 查询话术库列表 */
getChatLibraryList (params = {}) {
params.method = 'marketing.api.scriptlibrary.page'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
},
/**获取话术组列表*/
getChatGroup (params = {}) {
params.method = 'marketing.api.scriptlibrary.group.list'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true
})
},
/** 根据条件删除话术库 */
delChatLibrary (params = {}) {
params.method = 'marketing.api.scriptlibrary.delete'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
},
/** 新增或更新话术库数据 */
updateOrAddChatLibrary (params = {}) {
params.method = 'marketing.api.scriptlibrary.add.or.update'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true
})
},
/** 更改话术状态 */
updateChatLibraryState (params = {}) {
params.method = 'marketing.api.scriptlibrary.state.update'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
},
/**根据id查询话术库详情 */
getChatLibraryDetail (params = {}) {
params.method = 'marketing.api.scriptlibrary.detail.get'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true
})
},
/** 编辑话术组 */
updateChatGroup (params = {}) {
params.method = 'marketing.api.scriptlibrary.group.update'
return http({
url: 'rop-scrm-marketing/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
},
}
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,7 @@ module.exports = { ...@@ -18,7 +18,7 @@ module.exports = {
code_message_map: {} code_message_map: {}
}, },
request: { request: {
baseURL: 'http://scrm.test.glsx.com.cn/', baseURL: 'http://scrm.dev.glsx.com.cn/',
// baseURL: 'http://192.168.2.42:8064/', // baseURL: 'http://192.168.2.42:8064/',
// 设置超时时间 // 设置超时时间
timeout: 180000, timeout: 180000,
......
<template> <template>
<div> <div
嘻嘻 class="container"
v-loading="loading"
>
<div class="chat-library-box">
<div class="box-title">{{ title }}</div>
<div class="form">
<el-form
ref="chatForm"
:model="chatForm"
label-width="154px"
label-position="right"
>
<el-form-item
label="选择话术组:"
prop="scriptGroup"
:rules="rules.scriptGroup"
>
<div class="flex">
<el-select
v-model="chatForm.scriptGroup"
filterable
placeholder="请选择"
>
<el-option
v-for="(item, i) in chatGroup"
:key="i"
:label="item.value"
:value="item.value"
></el-option>
</el-select>
<el-button
type="primary"
@click="groupVisible = !groupVisible"
>编辑话术组</el-button>
</div>
</el-form-item>
<el-form-item
label="话术内容:"
prop="scriptContent"
:rules="rules.scriptContent"
>
<el-input
type="textarea"
:autosize="{ minRows: 5, maxRows: 20}"
placeholder="请输入文本内容"
v-model="chatForm.scriptContent"
maxlength="300"
show-word-limit
>
</el-input>
</el-form-item>
</el-form>
</div>
</div>
<GLFooter class="gl-footer">
<el-button
@click="$router.back()"
class="btn-cancle"
>取消</el-button>
<el-button
@click="handleSubmit"
type="primary"
>确定</el-button>
</GLFooter>
<GLDialog
v-if="groupVisible"
title="话术组"
mode="small"
:visible.sync="groupVisible"
:hasFooter="false"
:before-close="close"
>
<div class="edit-group-box">
<template v-if="editGroupText.newGroup || editState">
<div class="input-box">
<el-input
class="input"
v-model="editGroupText.newGroup"
maxlength="10"
placeholder="请输入"
>
<div
slot="suffix"
class="input-btn"
>
<div @click="updateChatGroup">确定</div>
<div
class="cancel"
@click="showEditGroupInput('')"
>取消</div>
</div>
</el-input>
</div>
</template>
<template v-else>
<div
class="add-btn item"
@click.self="editState = true"
>
<i class="el-icon-circle-plus-outline"></i>
新增一项
</div>
</template>
<template v-for="(i,index) in chatGroup">
<div
:key="index"
class="item"
@click.stop="choose(i.value)"
>
{{ i.value }}
<div class="item-btn">
<i
class="el-icon-edit"
@click.stop="showEditGroupInput(i.value)"
></i>
<i
class="el-icon-circle-close"
@click.stop="delChatLibrary(i.value)"
></i>
</div>
</div>
</template>
</div>
</GLDialog>
</div> </div>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
export default { import { utils } from 'glsx-common'
export default {
name: 'detail', name: 'detail',
data () { data () {
return { return {
groupVisible: false,
editState: false,
title: '',
loading: true,
chatGroup: [],
chatForm: {
scriptGroup: '',
scriptContent: ''
},
rules: {
scriptGroup: [
{ required: true, message: '请选择话术组', trigger: 'change' },
],
scriptContent: [
{ required: true, message: '请输入话术内容', trigger: 'change' }
]
},
editGroupText: {
oldGroup: '',
newGroup: ''
}
} }
}, },
mounted () { mounted () {
const { id, $title } = this.$route.query
this.title = $title
this.getChatGroup(id)
}, },
methods: { methods: {
/**获取话术组 */
async getChatGroup (id) {
const data = await this.$apis.chatLibrary.getChatGroup()
let chatGroup = data.length && data.map(e => {
return {
value: e
}
})
this.chatGroup = chatGroup || []
if (id) this.getChatLibraryDetail(id)
else this.loading = false
},
/**提交修改 */
handleSubmit () {
const { chatForm } = this
this.$refs.chatForm.validate(async valid => {
if (valid) {
const res = await this.$apis.chatLibrary.updateOrAddChatLibrary(chatForm)
if (res) {
this.$message({
message: `${chatForm.id ? '修改' : '创建'}成功`,
type: 'success'
})
this.$router.back()
}
} }
})
},
/**详情 */
async getChatLibraryDetail (id) {
const {
scriptContent,
scriptGroup,
state
} = await this.$apis.chatLibrary.getChatLibraryDetail({ id })
this.chatForm = {
scriptContent,
scriptGroup,
state,
id
}
this.loading = false
},
/**新增话术组 */
showEditGroupInput (value) {
this.editGroupText = {
oldGroup: value,
newGroup: value
}
this.editState = false
},
/**关闭弹框 */
close () {
this.showEditGroupInput('')
this.groupVisible = false
},
/**更新新增 */
async updateChatGroup () {
const { editGroupText, editState, $message } = this
try {
if (!editGroupText.newGroup) throw '请输入话术组!'
if (editState) {
this.chatGroup.unshift({
value: editGroupText.newGroup
})
} else {
const { data, message } = await this.$apis.chatLibrary.updateChatGroup(editGroupText)
$message({
message: data ? '操作成功' : message,
type: data ? 'success' : 'error'
})
this.chatGroup.find(e => {
if (e.value == editGroupText.oldGroup) e.value = editGroupText.newGroup
})
}
this.showEditGroupInput('')
} catch (error) {
$message({
message: error,
type: 'error'
})
}
},
/**删除 */
delChatLibrary (scriptGroup) {
this.$confirm('确定要删除此话术组?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: utils.debounce((action) => {
if (action == 'confirm') {
this.$apis.chatLibrary.delChatLibrary({
scriptGroup
}).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') this.getChatGroup()
})
} }
}, 500)
})
},
/**选择话术组 */
choose (val) {
this.chatForm.scriptGroup = val
this.close()
}
}
}
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.container {
.chat-library-box {
background: #fff;
min-height: calc(100vh - 136px);
margin-bottom: 16px;
.box-title {
height: 56px;
line-height: 56px;
padding-left: 20px;
border-bottom: 1px solid #e5e5e5;
font-weight: 600;
font-size: 16px;
color: #333;
}
.form {
padding: 32px 20px;
.flex {
.el-select {
width: 474px;
}
.el-button {
margin-left: 8px;
}
}
.el-textarea {
width: 600px;
}
}
}
.edit-group-box {
width: 474px;
margin: 0 auto;
.item {
height: 32px;
margin-bottom: 4px;
padding: 0 16px;
font-size: 14px;
color: #323233;
display: flex;
align-items: center;
cursor: pointer;
&:hover {
background: #f5f7fa;
.item-btn {
display: flex;
}
}
&-btn {
display: none;
margin-left: auto;
align-items: center;
font-size: 16px;
color: #9b9b9b;
gap: 8px;
i {
&:hover {
color: #5850ff;
}
}
}
}
.add-btn {
color: #5850ff;
i {
font-size: 20px;
margin-right: 6px;
}
}
.input-box {
position: sticky;
top: 0;
margin-bottom: 4px;
padding: 0 16px;
.input {
/deep/.el-input__inner {
height: 32px;
line-height: 32px;
}
&-btn {
display: flex;
height: 100%;
align-items: center;
font-size: 12px;
color: #5850ff;
gap: 0 8px;
cursor: pointer;
.cancel {
color: #666666;
}
div:hover {
opacity: 0.75;
}
}
}
}
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="top"> <div class="top">
<el-button <el-button
type="primary" type="primary"
@click="add" @click="jumpDetail()"
:size="size" :size="size"
> >
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
...@@ -13,20 +13,37 @@ ...@@ -13,20 +13,37 @@
<div class="container"> <div class="container">
<div class="tabelList"> <div class="tabelList">
<GLTable <GLTable
ref="materialRef" ref="listRef"
:hasPage="false" :getListApi="getListApi"
:searchForm="tableSearchForm"
:noDataImg="url" :noDataImg="url"
@refreshTable="getListApi"
:layout="layout"
:searchForm="searchForm"
:tableParams="tableParams" :tableParams="tableParams"
:tableData="materialTableData"
:pageConf="pageConf" :pageConf="pageConf"
:tableTotal="tableTotal"
@sortChange="sortChange"
:isCustomHead="true"
:customHeadShowList="customHeadShowList"
> >
<div
slot-scope="scope"
slot="scriptContent"
>
<el-tooltip
placement="top"
:content="scope.scope.scriptContent"
>
<div class="tooltip-content">{{ scope.scope.scriptContent }}</div>
</el-tooltip>
</div>
<div
slot="state"
slot-scope="scope"
class="chat-switch"
>
<el-switch
:value="scope.scope.state == 0 ? true : false"
@change="changeState(scope.scope)"
></el-switch>
<span>
{{ CHAT_STATE[scope.scope.state] }}
</span>
</div>
<span <span
slot="auth-button" slot="auth-button"
slot-scope="scope" slot-scope="scope"
...@@ -45,17 +62,21 @@ ...@@ -45,17 +62,21 @@
<script> <script>
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import * as dayjs from 'dayjs'
import { utils } from 'glsx-common'
const CHAT_STATE = {
0: '启用',
1: '停用'
}
export default { export default {
name: 'materialList', name: 'materialList',
components: { components: {
}, },
data () { data () {
return { return {
dialogVisibleImg: false, // 视频弹框 CHAT_STATE,
url, url,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }, pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'data.count' },
layout: 'sizes, prev, pager, next, jumper, ->, total',
// 表格按钮 // 表格按钮
tableButtonList: [ tableButtonList: [
{ {
...@@ -63,23 +84,9 @@ export default { ...@@ -63,23 +84,9 @@ export default {
name: '编辑', name: '编辑',
attrs: { attrs: {
type: 'text', type: 'text',
fn: '编辑'
},
listeners: {
// click: row => row.createdType == 2 ? this.addMaterial(3, row) : this.addMaterial(2, row)
}
},
{
type: 'el-button',
name: row => {
return row.status == 0 ? '禁用' : '启用'
},
attrs: {
type: 'text',
fn: '禁用'
}, },
listeners: { listeners: {
click: this.handleForbid click: row => this.jumpDetail(row.id)
} }
}, },
{ {
...@@ -87,102 +94,112 @@ export default { ...@@ -87,102 +94,112 @@ export default {
name: '删除', name: '删除',
attrs: { attrs: {
type: 'text', type: 'text',
fn: '删除营销素材'
}, },
listeners: { listeners: {
click: this.handleDelete click: row => {
this.showConfirm({
title: '删除',
txt: '确定要删除此话术?',
apiModule: 'chatLibrary',
apiName: 'delChatLibrary',
apiParams: {
id: row.id
}
})
}
} }
} }
], ],
tableSearchForm: {
},
getListApi: this.$apis.chatLibrary.getChatLibraryList,
tableParams: { tableParams: {
listName: 'data', listName: 'data.data',
tableOption: true, tableOption: true,
tableColumns: [ tableColumns: [
{ {
label: '话术内容', label: '话术内容',
prop: 'materialContentRpcResponse', prop: 'scriptContent',
width: 270 addHtml: 'scriptContent'
}, },
{ {
label: '状态', label: '状态',
prop: 'status', prop: 'state',
addHtml: 'status', addHtml: 'state',
// width: 170 width: 170
}, },
{ {
label: '更新时间', label: '更新时间',
prop: 'updatedTime', prop: 'updatedTime',
// width: 210, width: 210,
formatter: cellVal => { formatter: cellVal => {
return cellVal.updatedTime return dayjs(cellVal.createdDate).format('YYYY-MM-DD HH:mm:ss')
} }
} }
] ]
}, }
// 获取素材总条数
tableTotal: 0
} }
}, },
mounted () { mounted () {
this.getListApi()
}, },
methods: { methods: {
add () { /**跳转 */
jumpDetail (id) {
this.$router.push({ this.$router.push({
path: '/ChatLibrary/detail' path: '/ChatLibrary/detail',
query: id ? { id, $title: '编辑话术' } : { $title: '创建话术' }
}) })
}, },
// 素材详情 /**搜索 */
handleDetail (scope) { handleSearch () {
this.$router.push({ this.$refs.listRef.refreshTable()
path: '/material/materialDetail',
query: {
id: scope.id
}
})
}, },
// 获取素材列表 /**二次弹框 */
getTableList (params) { showConfirm ({
this.$apis.material.materialList(params).then(res => { title,
let data = res txt,
let tableData = [] apiModule,
data.forEach(item => { apiName,
// 根据素材类型是图文处理数据 apiParams,
if (item.materialType == 3 || item.materialType == 4 || item.materialType == 5 || item.materialType == 6) { fn
let html = decodeURIComponent(item.materialContentRpcResponse.materialUrl) }) {
let imgHtml = html.match(/<img.*?(?:>|\/>)/g) this.$confirm(txt, title, {
let videoHtml = html.match(/<video.*?(?:>|\/>)/g) confirmButtonText: '确定',
if (imgHtml) { cancelButtonText: '取消',
let imgSrc = imgHtml[0].match('<img[^<>]*? src="([^<>]*?)"') type: 'warning',
item.materialContentRpcResponse.materialUrl = imgSrc[1] callback: utils.debounce((action) => {
item.urlType = 'img' if (action == 'confirm') {
item.imgCount = imgHtml.length this.$apis[apiModule][apiName](apiParams).then(res => {
} this.$message({
if (videoHtml) { message: res.code == '0' ? '操作成功' : res.message,
let videoSrc = videoHtml[0].match('<video[^<>]*? src="([^<>]*?)"') type: res.code == '0' ? 'success' : 'error'
item.materialContentRpcResponse.materialUrl = videoSrc[1]
item.urlType = 'video'
}
}
tableData.push(item)
}) })
this.materialTableData = tableData if (res.code == '0') {
this.tableTotal = res.length fn && fn()
this.$refs.materialRef.tableHeightValues = this.tableHeight this.handleSearch()
// res.length ? (this.$refs.materialRef.tableHeightValues = this.tableHeight) : (this.$refs.materialRef.tableHeightValues = '230px') }
})
}
}, 500)
}) })
}, },
// 获取所有素材 /**改变状态 */
getListApi () { changeState ({
let params = this.getParams() id,
// params.pageSize = this.$refs.materialRef.page.pageSize state
// params.pageNum = this.$refs.materialRef.page.pageNum }) {
params.pageSize = 1000000 state = state == 0 ? 1 : 0
params.pageNum = 1 this.showConfirm({
params.groupId = '' title: '',
this.getTableList(params) txt: `确定要${CHAT_STATE[state]}此话术?`,
this.materialGroupName = '全部素材' apiModule: 'chatLibrary',
// }) apiName: 'updateChatLibraryState',
apiParams: {
id,
state
}
})
} }
} }
} }
...@@ -199,6 +216,18 @@ export default { ...@@ -199,6 +216,18 @@ export default {
background-color: #fff; background-color: #fff;
box-sizing: border-box; box-sizing: border-box;
padding: 20px; padding: 20px;
.chat-switch {
span {
font-size: 14px;
color: #666666;
margin-left: 8px;
}
}
.tooltip-content {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
} }
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!