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
......@@ -18,7 +18,7 @@ module.exports = {
code_message_map: {}
},
request: {
baseURL: 'http://scrm.test.glsx.com.cn/',
baseURL: 'http://scrm.dev.glsx.com.cn/',
// baseURL: 'http://192.168.2.42:8064/',
// 设置超时时间
timeout: 180000,
......
<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>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'detail',
data () {
return {
import { utils } from 'glsx-common'
export default {
name: 'detail',
data () {
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 () {
const { id, $title } = this.$route.query
this.title = $title
this.getChatGroup(id)
},
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'
})
}
},
mounted () {
/**删除 */
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)
})
},
methods: {
/**选择话术组 */
choose (val) {
this.chatForm.scriptGroup = val
this.close()
}
}
}
</script>
<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>
\ No newline at end of file
......@@ -3,7 +3,7 @@
<div class="top">
<el-button
type="primary"
@click="add"
@click="jumpDetail()"
:size="size"
>
<i class="el-icon-plus"></i>
......@@ -13,20 +13,37 @@
<div class="container">
<div class="tabelList">
<GLTable
ref="materialRef"
:hasPage="false"
ref="listRef"
:getListApi="getListApi"
:searchForm="tableSearchForm"
:noDataImg="url"
@refreshTable="getListApi"
:layout="layout"
:searchForm="searchForm"
:tableParams="tableParams"
:tableData="materialTableData"
: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
slot="auth-button"
slot-scope="scope"
......@@ -45,17 +62,21 @@
<script>
import url from '@/assets/empty.png'
import * as dayjs from 'dayjs'
import { utils } from 'glsx-common'
const CHAT_STATE = {
0: '启用',
1: '停用'
}
export default {
name: 'materialList',
components: {
},
data () {
return {
dialogVisibleImg: false, // 视频弹框
CHAT_STATE,
url,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
layout: 'sizes, prev, pager, next, jumper, ->, total',
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'data.count' },
// 表格按钮
tableButtonList: [
{
......@@ -63,23 +84,9 @@ export default {
name: '编辑',
attrs: {
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: {
click: this.handleForbid
click: row => this.jumpDetail(row.id)
}
},
{
......@@ -87,102 +94,112 @@ export default {
name: '删除',
attrs: {
type: 'text',
fn: '删除营销素材'
},
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: {
listName: 'data',
listName: 'data.data',
tableOption: true,
tableColumns: [
{
label: '话术内容',
prop: 'materialContentRpcResponse',
width: 270
prop: 'scriptContent',
addHtml: 'scriptContent'
},
{
label: '状态',
prop: 'status',
addHtml: 'status',
// width: 170
prop: 'state',
addHtml: 'state',
width: 170
},
{
label: '更新时间',
prop: 'updatedTime',
// width: 210,
width: 210,
formatter: cellVal => {
return cellVal.updatedTime
return dayjs(cellVal.createdDate).format('YYYY-MM-DD HH:mm:ss')
}
}
]
},
// 获取素材总条数
tableTotal: 0
}
}
},
mounted () {
this.getListApi()
},
methods: {
add () {
/**跳转 */
jumpDetail (id) {
this.$router.push({
path: '/ChatLibrary/detail'
path: '/ChatLibrary/detail',
query: id ? { id, $title: '编辑话术' } : { $title: '创建话术' }
})
},
// 素材详情
handleDetail (scope) {
this.$router.push({
path: '/material/materialDetail',
query: {
id: scope.id
}
})
/**搜索 */
handleSearch () {
this.$refs.listRef.refreshTable()
},
// 获取素材列表
getTableList (params) {
this.$apis.material.materialList(params).then(res => {
let data = res
let tableData = []
data.forEach(item => {
// 根据素材类型是图文处理数据
if (item.materialType == 3 || item.materialType == 4 || item.materialType == 5 || item.materialType == 6) {
let html = decodeURIComponent(item.materialContentRpcResponse.materialUrl)
let imgHtml = html.match(/<img.*?(?:>|\/>)/g)
let videoHtml = html.match(/<video.*?(?:>|\/>)/g)
if (imgHtml) {
let imgSrc = imgHtml[0].match('<img[^<>]*? src="([^<>]*?)"')
item.materialContentRpcResponse.materialUrl = imgSrc[1]
item.urlType = 'img'
item.imgCount = imgHtml.length
}
if (videoHtml) {
let videoSrc = videoHtml[0].match('<video[^<>]*? src="([^<>]*?)"')
item.materialContentRpcResponse.materialUrl = videoSrc[1]
item.urlType = 'video'
}
/**二次弹框 */
showConfirm ({
title,
txt,
apiModule,
apiName,
apiParams,
fn
}) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: utils.debounce((action) => {
if (action == 'confirm') {
this.$apis[apiModule][apiName](apiParams).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
fn && fn()
this.handleSearch()
}
})
}
tableData.push(item)
})
this.materialTableData = tableData
this.tableTotal = res.length
this.$refs.materialRef.tableHeightValues = this.tableHeight
// res.length ? (this.$refs.materialRef.tableHeightValues = this.tableHeight) : (this.$refs.materialRef.tableHeightValues = '230px')
}, 500)
})
},
// 获取所有素材
getListApi () {
let params = this.getParams()
// params.pageSize = this.$refs.materialRef.page.pageSize
// params.pageNum = this.$refs.materialRef.page.pageNum
params.pageSize = 1000000
params.pageNum = 1
params.groupId = ''
this.getTableList(params)
this.materialGroupName = '全部素材'
// })
/**改变状态 */
changeState ({
id,
state
}) {
state = state == 0 ? 1 : 0
this.showConfirm({
title: '',
txt: `确定要${CHAT_STATE[state]}此话术?`,
apiModule: 'chatLibrary',
apiName: 'updateChatLibraryState',
apiParams: {
id,
state
}
})
}
}
}
......@@ -199,6 +216,18 @@ export default {
background-color: #fff;
box-sizing: border-box;
padding: 20px;
.chat-switch {
span {
font-size: 14px;
color: #666666;
margin-left: 8px;
}
}
.tooltip-content {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!