企微助手 ,仓库名 短剧

createChannelCode.vue 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <template>
  2. <div>
  3. <div class="backBox" @click="$router.go(-1)">
  4. <div class="back">
  5. <i class="el-icon-back"></i>
  6. <span>返回</span>
  7. </div>
  8. </div>
  9. <div v-loading="loading" class="bg-ffffff createMassMsg" style="padding: 15px 30px;">
  10. <div class="self-hint" style="margin-top:10px;width:730px">
  11. <i class="el-icon-message-solid"></i>
  12. <div>
  13. <div>1.新建渠道活码最多可发送10条消息(包含1条文字消息和9条附加消息)</div>
  14. <div>2.附加消息包括图片、连接、小程序</div>
  15. <div>3.渠道欢迎语将在客户加为好友后20秒内发送,网络延迟可能造成发送失败</div>
  16. </div>
  17. </div>
  18. <div class="line" style="margin-top:20px"></div>
  19. <h3 class="bigTitle">基础信息</h3>
  20. <div class="regulations">
  21. <label><em>*</em>渠道名称</label>
  22. <el-input placeholder="请输入渠道名称" style="width:300px" v-model.trim="channelName"
  23. maxlength="32"
  24. show-word-limit
  25. clearable size="small"></el-input>
  26. </div>
  27. <div class="regulations" style="align-items: center">
  28. <label><em style="opacity: 0;">*</em>选择分组</label>
  29. <el-select v-model="group_val" size="small" clearable filterable placeholder="请选择分组" style="width: 300px">
  30. <el-option
  31. v-for="item in groupArrs"
  32. :key="item.id"
  33. :label="item.name"
  34. :value="item.id">
  35. </el-option>
  36. </el-select>
  37. <div class="newGroupCss" @click="$refs.dialogGroupRef.dialogVisible = true">新建分组</div>
  38. </div>
  39. <div class="regulations">
  40. <label><em>*</em>使用客服</label>
  41. <self-customerservice v-if="detialFlag" title='' width="300px"
  42. source="channelCode"
  43. ref="selfKefu"
  44. :afferent_users='user_id_list'
  45. @customerDefine="(val,arrName)=>{user_id_list=val;user_idName=arrName}" style="margin:0;"></self-customerservice>
  46. </div>
  47. <div class="regulations">
  48. <label><em style="opacity: 0;">*</em>选择标签</label>
  49. <enterprise-tag v-if="detialFlag" title="" width="300px"
  50. ref="tagRef"
  51. :afferent_obj='afferent_tag_obj'
  52. :reset='resetFlag' @tagDefine="tagDefine" style="margin:0;"></enterprise-tag>
  53. </div>
  54. <div class="regulations">
  55. <label><em>*</em>渠道欢迎语</label>
  56. <edit-con v-if="detialFlag" source="welcom"
  57. :afferent_content='main_msg_data.content'
  58. :afferent_attachments='main_msg_data.attachments'
  59. @editContent="(val)=>{main_msg_data.content = val}"
  60. @changeAttachment='getAttachment'></edit-con>
  61. </div>
  62. <h3 class="bigTitle" style="margin-top:20px">
  63. 分时段欢迎语:
  64. <el-switch v-model="is_day_parting"
  65. @change="switchChange" active-color="#13ce66"
  66. inactive-color="#ddd"></el-switch>
  67. </h3>
  68. <template v-if="is_day_parting">
  69. <div class="self-hint" style="margin-top:10px;width:750px;margin-left:70px;margin-top:20px">
  70. <p>分时段欢迎语 :</p>
  71. <div>
  72. <p>1、员工上下班不同时间段可设置不同欢迎语;</p>
  73. <p>2、分时段之外的时间将发送欢迎语。</p>
  74. </div>
  75. </div>
  76. <div class="regulations regulations2" v-for="(item,index) in timeIntervalList" :key="item.key_val">
  77. <label style="margin-top:30px;text-align:right">时段{{index+1}}:</label>
  78. <welcom-edit :deleteFlag='timeIntervalList.length==1?false:true'
  79. :editInfo="item"
  80. @welcomEditCon='(val)=>{getWelcomEdit(val,index)}'
  81. @deleteWelcomCon='deleteWelcomCon(item.key_val,item)'></welcom-edit>
  82. </div>
  83. <div class="add_welcom_hint" @click="addWelcom">
  84. <i class="el-icon-circle-plus-outline"></i>
  85. <span>添加分时段欢迎语</span>
  86. </div>
  87. </template>
  88. <div class="line" style="margin-top:20px"></div>
  89. <h3 class="bigTitle" style="margin-top:20px">高级设置: </h3>
  90. <div class="regulations">
  91. <label><em>*</em>客户备注</label>
  92. <customerNote v-if="detialFlag" :propsVal="{'noteVal':customerNote_val,'radioval':customer_prefix_type}"
  93. @changeVal="(noteVal,radioVal)=>{customerNote_val=noteVal;customer_prefix_type=radioVal}"></customerNote>
  94. </div>
  95. <div class="regulations" style="align-items: center">
  96. <label>客服添加上限</label>
  97. <div @click="tipsClick" class="limitBox">
  98. <el-switch v-model="add_limit"
  99. :disabled="user_id_list&&user_id_list.length==0"
  100. @change="switchLimit" active-color="#13ce66"
  101. inactive-color="#ddd"></el-switch>
  102. </div>
  103. </div>
  104. <div v-if="add_limit&&detialFlag">
  105. <div class="regulations">
  106. <label><em>*</em>预警人</label>
  107. <customerServiceCorp title=''
  108. :afferent_users='warn_user'
  109. :icon_arrow_bg='false'
  110. width="300px"
  111. style="margin:0;width:100%"
  112. @customerDefine="(val)=>{get_djuser_list=val}"></customerServiceCorp>
  113. </div>
  114. <div class="listBox">
  115. <el-button type="primary" size="mini" @click="batch_setting" style="margin: 5px 0">批量设置</el-button>
  116. <el-table v-loading="loading" ref="multipleTable"
  117. border
  118. :data="tableData"
  119. tooltip-effect="dark"
  120. @selection-change="handleSelectionChange"
  121. :header-cell-style="()=>{return { backgroundColor: '#f9f9f9 !important' }}"
  122. style="width: 100%">
  123. <el-table-column width="40px" type="selection"></el-table-column>
  124. <el-table-column label="全部成员" align="center">
  125. <template slot-scope="scope">
  126. <div>{{scope.row.name ? scope.row.name : '-'}}</div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="每日添加客户上限" align="center">
  130. <template slot-scope="scope">
  131. <el-input size="mini" v-model="scope.row.toplimit"></el-input>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="今日添加客户数" align="center">
  135. <template slot-scope="scope">
  136. <div>{{scope.row.assign_count||scope.row.assign_count==0 ? scope.row.assign_count : '-'}}</div>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="是否分配客户" align="center">
  140. <template slot-scope="scope">
  141. <el-switch v-model="scope.row.is_open"
  142. :active-value="1"
  143. :inactive-value="0"
  144. active-color="#13ce66"
  145. inactive-color="#ddd"></el-switch>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="操作" align="center" width="80px">
  149. <template slot-scope="scope">
  150. <div class="c-00B38A pointer lMar8" @click="deleKefu(scope.row.user_id)">删除</div>
  151. </template>
  152. </el-table-column>
  153. </el-table>
  154. </div>
  155. <el-dialog
  156. title="设置添加上限"
  157. :center="true"
  158. :visible.sync="dialogVisible"
  159. width="20%">
  160. <div style="display: flex;align-items: center;justify-content: center">
  161. <div>每日添加客户上限: </div>
  162. <div style="width: 100px;margin-left: 20px"><el-input size="mini" v-model="batchVal"></el-input></div>
  163. </div>
  164. <span slot="footer" class="dialog-footer">
  165. <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
  166. <el-button size="mini" type="primary" @click="batchValSave">确 定</el-button>
  167. </span>
  168. </el-dialog>
  169. </div>
  170. <!-- <addLimit v-if="add_limit&&detialFlag"-->
  171. <!-- :user_id_list="user_id_list"-->
  172. <!-- :afferentVal="afferent_limit"-->
  173. <!-- :afferent_warn_val="warn_user"-->
  174. <!-- @deleUserId="(val)=>{deleUserId(val)}"-->
  175. <!-- @getTableData="(val)=>{afferent_limit=val}"-->
  176. <!-- @getVal="(val)=>{warn_user=val}"></addLimit>-->
  177. <div class="line" style="margin-top:20px"></div>
  178. <div style="margin-top: 20px">
  179. <!-- <el-button type="primary" @click="newCode_click">{{$route.query.id ? ($route.query.type =='copy' ? '复制' : '编辑') : '新建'}}活码</el-button>-->
  180. <el-button type="primary" @click="newCode_click">保存</el-button>
  181. </div>
  182. </div>
  183. <dialogGroup
  184. ref="dialogGroupRef"
  185. @init="initGroupList"
  186. :propsData="{
  187. dialogTitle:'新建'
  188. }"></dialogGroup>
  189. </div>
  190. </template>
  191. <script>
  192. import dialogGroup from './dialogGroup.vue'
  193. // import addLimit from './addLimit.vue'
  194. import customerNote from './customerNote.vue'
  195. import selfCustomerservice from '@/components/assembly/screen/customerService.vue'
  196. import enterpriseTag from '@/components/assembly/screen/enterpriseTagFC.vue'
  197. import editCon from '@/components/assembly/editCon.vue'
  198. import welcomEdit from '@/components/assembly/welcom_edit.vue'
  199. import customerServiceCorp from '@/components/assembly/screen/customerServiceCorp.vue'
  200. export default {
  201. name: "createChannelCode",
  202. components:{
  203. dialogGroup,
  204. selfCustomerservice,
  205. enterpriseTag,
  206. editCon,
  207. welcomEdit,
  208. // addLimit,
  209. customerNote,
  210. customerServiceCorp
  211. },
  212. data(){
  213. return{
  214. loading:false,
  215. channelName:'',
  216. is_day_parting: false,
  217. group_val:'',
  218. groupArrs:[],
  219. user_id_list: [],
  220. user_idName: [],
  221. afferent_tag_obj: {
  222. tag_id_list: []
  223. },
  224. resetFlag: false,
  225. init_welcom_con: {
  226. is_day_parting: 1,//是否为分时段欢迎语 0:否 1:是
  227. weeks: [1, 2, 3, 4, 5, 6, 0],
  228. start_time: '',
  229. end_time: '',
  230. content: '',
  231. attachments: [],
  232. msg_id:''
  233. },
  234. main_msg_data: {
  235. "is_day_parting": 0,
  236. "weeks": [],
  237. "start_time": "",
  238. "end_time": "",
  239. "content": '',
  240. "attachments": []
  241. },
  242. deleteTimeIntervalList: [],//删除的分时段列表
  243. timeIntervalList: [],//分时段列表
  244. add_limit:false,
  245. customerNote_val:'',
  246. customer_prefix_type:'',
  247. warn_user:[],
  248. tag_info:[],
  249. detialFlag:false,
  250. afferent_limit:[],
  251. tableData:[],
  252. noChooseFlag:false,
  253. user_ids:[],
  254. dialogVisible:false,
  255. batchVal:'',
  256. get_djuser_list: []
  257. }
  258. },
  259. watch:{
  260. user_id_list:{
  261. immediate:false,
  262. handler(newVal,oldVal){
  263. if(this.user_id_list&&this.user_id_list.length==0){
  264. this.add_limit=false
  265. }else{
  266. // this.add_limit=true
  267. let uids=[]
  268. let new_table_data=[]
  269. this.tableData.forEach(item=>{
  270. uids.push(item.user_id)
  271. })
  272. this.user_id_list.forEach((user,uidx)=>{
  273. let idx = uids.indexOf(user)
  274. if(idx>-1){
  275. new_table_data.push(this.tableData[idx])
  276. }else{
  277. new_table_data.push({
  278. toplimit:'',
  279. user_id:user,
  280. assign_count:0,
  281. is_open:1,
  282. name:this.user_idName[uidx]
  283. })
  284. }
  285. })
  286. this.tableData = new_table_data
  287. }
  288. }
  289. },
  290. },
  291. created(){
  292. this.initGroupList()
  293. },
  294. methods:{
  295. deleKefu(user_id){
  296. this.tableData.forEach((item,idx)=>{
  297. if(user_id == item.user_id){
  298. this.tableData.splice(idx,1)
  299. }
  300. })
  301. // this.$emit('deleUserId',user_id)
  302. this.deleUserId(user_id)
  303. },
  304. batchValSave(){
  305. if(this.batchVal==''){
  306. this.$message({
  307. type: 'error',
  308. message: '上限不能为空!'
  309. });
  310. return
  311. }
  312. this.user_ids.forEach((item,idx)=>{
  313. item.toplimit = this.batchVal
  314. })
  315. this.dialogVisible = false
  316. },
  317. noChooseCustomeTips(){//没有选择客户提示
  318. this.noChooseFlag = false
  319. if( this.user_ids){
  320. if(this.user_ids.length==0){
  321. this.$message({
  322. type: 'error',
  323. message: '请选择成员!'
  324. });
  325. this.noChooseFlag = true
  326. }
  327. if(this.user_ids.length>=4){
  328. this.$message({
  329. type: 'error',
  330. message: '最多可选3个成员!'
  331. });
  332. this.noChooseFlag = true
  333. }
  334. }
  335. },
  336. handleSelectionChange(val){//列表选择人员
  337. this.user_ids = val
  338. },
  339. batch_setting(){//批量设置
  340. this.noChooseCustomeTips()
  341. if(this.noChooseFlag){return}
  342. this.dialogVisible = true
  343. },
  344. goDataAanlyse(id){
  345. this.$router.push('/dataAnalyse/'+id)
  346. },
  347. //分割线,以上是客服上限
  348. deleUserId(id){
  349. this.user_id_list.splice(this.user_id_list.indexOf(id),1)
  350. this.$refs.selfKefu.afferent_init()
  351. },
  352. initGroupList(){//分组列表
  353. this.loading = true;
  354. this.$axios.get(this.URL.BASEURL + this.URL.channel_groupList, {
  355. params:{
  356. page: 1,
  357. pagesize: 500,
  358. }
  359. }).then((res) => {
  360. var res = res.data
  361. if (res && res.errno == 0) {
  362. this.groupArrs = res.rst.data
  363. if (this.$route.query.id) {//详情
  364. this.detail()
  365. } else {
  366. this.detialFlag = true
  367. this.loading = false;
  368. }
  369. } else if (res.errno != 4002) {
  370. this.$message({
  371. message: res.err,
  372. type: "warning"
  373. })
  374. this.loading = false
  375. }
  376. })
  377. },
  378. detail () {//详情
  379. this.loading = true
  380. this.$axios.get(this.URL.BASEURL + this.URL.channel_codeDetial, {
  381. params: {
  382. id: this.$route.query.id
  383. }
  384. }).then((res) => {
  385. var res = res.data
  386. if (res && res.errno == 0) {
  387. let dataInfo = res.rst
  388. this.channelName = dataInfo.name;
  389. this.customerNote_val = dataInfo.customer_prefix
  390. this.customer_prefix_type = dataInfo.customer_prefix_type
  391. let groupIds = []
  392. this.groupArrs.forEach(item=>{
  393. groupIds.push(Number(item.id))
  394. })
  395. if(groupIds.indexOf(Number(dataInfo.group_id))>-1){
  396. this.group_val = Number(dataInfo.group_id)
  397. }else{
  398. this.group_val = ''
  399. }
  400. if(dataInfo.staff_users&&dataInfo.staff_users.length>0){
  401. dataInfo.staff_users.forEach(item=>{
  402. this.user_id_list.push(item.user_id)
  403. // this.afferent_limit.push({
  404. // toplimit:item.toplimit,
  405. // user_id:item.user_id,
  406. // assign_count:item.user_add_count,
  407. // is_open:item.is_open
  408. // })
  409. this.tableData.push({
  410. toplimit:item.toplimit,
  411. user_id:item.user_id,
  412. name:item.staff_name,
  413. assign_count:item.user_add_count,
  414. is_open:item.is_open
  415. })
  416. })
  417. }
  418. if(dataInfo.up_toplimit==1){
  419. this.add_limit = true
  420. if(JSON.parse(dataInfo.warn_user)&&JSON.parse(dataInfo.warn_user).length>0){
  421. this.warn_user = JSON.parse(dataInfo.warn_user)
  422. this.get_djuser_list = JSON.parse(dataInfo.warn_user)
  423. }
  424. }else{
  425. this.add_limit = false
  426. }
  427. this.afferent_tag_obj.tag_id_list = JSON.parse(dataInfo.tag_list)
  428. this.tag_info = JSON.parse(dataInfo.tag_list)
  429. let msg_list = dataInfo.welcomeMsg;
  430. msg_list.forEach((item) => {
  431. item.content = item.content ? item.content.replace('%NICKNAME%', '「客户昵称」') : '';
  432. item.attachments = item.attachments && item.attachments != '' ? JSON.parse(item.attachments) : [];
  433. if(item.weeks){
  434. item.weeks = item.weeks.split(',')
  435. }else{
  436. item.weeks = []
  437. }
  438. // item.weeks = item.weeks ? item.weeks.split(',') : []
  439. })
  440. let main_msg_data = msg_list.filter((v) => {//特定有一个主欢迎语内容
  441. return v.is_day_parting == 0
  442. })
  443. this.main_msg_data = main_msg_data && main_msg_data.length > 0 ? main_msg_data[0] : {};
  444. this.timeIntervalList = msg_list.filter((v) => {//分时段欢迎语内容
  445. return v.is_day_parting == 1
  446. })
  447. if (msg_list.length > 1) {
  448. this.is_day_parting = true
  449. }
  450. this.detialFlag = true//等待详情接口加载完毕后,再加载子组件created,否则无数据
  451. this.loading = false
  452. } else if (res.errno != 4002) {
  453. this.$message({
  454. message: res.err,
  455. type: "warning"
  456. })
  457. this.$router.go(-1)
  458. }
  459. }).catch((err) => {
  460. this.loading = false
  461. });
  462. },
  463. tipsClick(){//添加客服上限前的提示
  464. if(this.user_id_list&&this.user_id_list.length==0){
  465. this.$message({
  466. type: 'error',
  467. message: '请先选择使用客服!'
  468. })
  469. }
  470. },
  471. newCode_click(){//新建活码
  472. if(this.channelName == ''){
  473. this.$message({
  474. type: 'error',
  475. message: '渠道名称不能为空!'
  476. });
  477. return
  478. }
  479. if(this.user_id_list&&this.user_id_list.length==0){
  480. this.$message({
  481. type: 'error',
  482. message: '使用客服不能为空!'
  483. });
  484. return
  485. }
  486. if(this.customerNote_val==''){
  487. this.$message({
  488. type: 'error',
  489. message: '客户备注不能为空!'
  490. });
  491. return
  492. }
  493. if (this.main_msg_data.content == '' && (!this.main_msg_data.attachments || this.main_msg_data.attachments == '' || this.main_msg_data.attachments.length == 0)) {
  494. this.$message({
  495. message: '请输入【主】欢迎语内容!',
  496. type: "warning"
  497. })
  498. return
  499. }
  500. if (this.main_msg_data.content != '' && this.$getStrBytes(this.main_msg_data.content) > 4000) {
  501. this.$message({
  502. message: '请检查【主】欢迎语内容,最多4000个字节,已超出!',
  503. type: "error"
  504. })
  505. return
  506. }
  507. if(this.add_limit){
  508. if(this.get_djuser_list&&this.get_djuser_list.length==0){
  509. this.$message({
  510. message: '预警人不能为空',
  511. type: "error"
  512. })
  513. return
  514. }
  515. }
  516. let warn_user_json = []//预警人
  517. this.get_djuser_list.forEach(item=>{
  518. warn_user_json.push({
  519. corpid:item.corpid,
  520. user_id:item.user_id
  521. })
  522. })
  523. let user_json=[]//客服数据
  524. if(this.add_limit){//如果有客服上限
  525. // user_json = this.afferent_limit
  526. user_json = this.tableData
  527. }else{
  528. this.user_id_list.forEach(item=>{
  529. user_json.push({
  530. toplimit:0,
  531. is_open:1,
  532. user_id:item
  533. })
  534. })
  535. }
  536. //时段欢迎语和分时段欢迎语
  537. let msg_data = []
  538. if (this.is_day_parting) {//开启分段欢迎语
  539. for (let i = 0; i < this.timeIntervalList.length; i++) {
  540. let item = this.timeIntervalList[i];
  541. if (item.content == '' && (!item.attachments || item.attachments == '' || item.attachments.length == 0)) {
  542. this.$message({
  543. message: `请输入【时段${i + 1}】欢迎语内容!`,
  544. type: "warning"
  545. })
  546. return
  547. }
  548. if (item.content != '' && this.$getStrBytes(item.content) > 4000) {
  549. this.$message({
  550. message: `请检查【时段${i + 1}】欢迎语内容,最多4000个字节,已超出!`,
  551. type: "error"
  552. })
  553. return
  554. }
  555. if (!item.weeks || item.weeks.length == 0) {
  556. this.$message({
  557. message: `请选择【时段${i + 1}】发送日期!`,
  558. type: "warning"
  559. })
  560. return
  561. }
  562. if (!item.start_time || item.start_time == '') {
  563. this.$message({
  564. message: `请输入【时段${i + 1}】发送开始时间!`,
  565. type: "warning"
  566. })
  567. return
  568. }
  569. if (!item.end_time || item.end_time == '') {
  570. this.$message({
  571. message: `请输入【时段${i + 1}】发送结束时间!`,
  572. type: "warning"
  573. })
  574. return
  575. }
  576. if (this.$date_compatible(('2020-04-01 ' + item.start_time)).getTime() > this.$date_compatible(('2020-04-01 ' + item.end_time)).getTime()) {
  577. this.$message({
  578. message: `请正确输入【时段${i + 1}】发送时间!`,
  579. type: "warning"
  580. })
  581. return
  582. }
  583. }
  584. if(this.$route.query.type =='copy'){ //复制的时候,清空id
  585. this.timeIntervalList.forEach(timeItem=>{
  586. timeItem.id=''
  587. timeItem.msg_id=''
  588. timeItem.sq_id=''
  589. })
  590. }
  591. msg_data = msg_data.concat(this.timeIntervalList)
  592. } else {//关闭分段欢迎语
  593. let delete_arr = JSON.parse(JSON.stringify(this.timeIntervalList));
  594. delete_arr = delete_arr.filter((v) => {
  595. return v.msg_id
  596. })
  597. delete_arr.forEach((item) => {
  598. item.operate = 'del'
  599. })
  600. this.deleteTimeIntervalList = this.deleteTimeIntervalList.concat(delete_arr)
  601. }
  602. msg_data = msg_data.concat(this.deleteTimeIntervalList);//删除的分时段内容
  603. if(this.$route.query.type =='copy'){//复制的时候,清空id
  604. this.main_msg_data.id=''
  605. this.main_msg_data.msg_id=''
  606. this.main_msg_data.sq_id=''
  607. }
  608. msg_data.push(this.main_msg_data)
  609. msg_data.forEach((item) => {
  610. if(item.weeks&&item.weeks.length>0){
  611. if(typeof item.weeks == 'string'){
  612. item.weeks = item.weeks.split(',')
  613. }
  614. let now_weeks=''
  615. item.weeks.forEach(n=>{
  616. now_weeks += n +','
  617. })
  618. item.weeks = now_weeks.slice(0,now_weeks.length-1)
  619. }else{
  620. item.weeks = ''
  621. }
  622. item.content = item.content.replaceAll('「客户昵称」', '%NICKNAME%')
  623. item.attachments = item.attachments == '' || item.attachments&&item.attachments.length == 0 ? '' : JSON.stringify(item.attachments)
  624. })
  625. this.$loading(this.$loadingConfig)
  626. let api
  627. if(!this.$route.query.type&&this.$route.query.id){
  628. api = this.URL.channel_codeEdit
  629. }else{
  630. api = this.URL.channel_createCode
  631. }
  632. this.$axios.post(this.URL.BASEURL + api, {
  633. id: this.$route.query.id ? (this.$route.query.type =='copy' ? '' : this.$route.query.id) : '',
  634. name: this.channelName,
  635. group_id:this.group_val,
  636. user_json:JSON.stringify(user_json),
  637. tag_list:JSON.stringify(this.tag_info),
  638. customer_prefix:this.customerNote_val,
  639. customer_prefix_type:this.customer_prefix_type,
  640. msg_data: msg_data,
  641. warn_user:JSON.stringify(warn_user_json),
  642. up_toplimit:this.add_limit ? 1 : 0
  643. }).then((res) => {
  644. var res = res.data
  645. this.$loading(this.$loadingConfig).close()
  646. if (res && res.errno == 0) {
  647. this.$router.go(-1)
  648. } else if (res.errno != 4002) {
  649. this.$message({
  650. message: res.err,
  651. type: "warning"
  652. })
  653. }
  654. this.welcomEditShow=true
  655. }).catch((err) => {
  656. this.$loading(this.$loadingConfig).close()
  657. });
  658. },
  659. tagDefine (data) {//标签选择回调
  660. if (data.tag_id_list && data.tag_id_list.length != 0) {
  661. this.tag_info = data.tag_id_list
  662. } else {
  663. this.tag_info = []
  664. }
  665. },
  666. getAttachment (val) {
  667. this.main_msg_data.attachments = val;
  668. },
  669. switchChange () {//分时段开关打开
  670. if (this.is_day_parting && this.timeIntervalList.length == 0) {
  671. let addMsg_id = new Date().getTime()
  672. let obj = {
  673. is_day_parting: 1,//是否为分时段欢迎语 0:否 1:是
  674. weeks: [1, 2, 3, 4, 5, 6, 0],
  675. start_time: '',
  676. end_time: '',
  677. content: '',
  678. attachments: [],
  679. key_val:addMsg_id,
  680. }
  681. this.timeIntervalList.push(obj)
  682. }
  683. },
  684. getWelcomEdit (val, index) {//分时段编辑
  685. this.$set(this.timeIntervalList, index, val)
  686. },
  687. deleteWelcomCon (key_val,item) {//删除分时段
  688. if (this.$route.query.id && item.msg_id) {//删除的分时段内容
  689. let obj = JSON.parse(JSON.stringify(item))
  690. obj.operate = 'del';
  691. this.deleteTimeIntervalList.push(obj)
  692. }
  693. this.timeIntervalList.forEach((item,index)=>{
  694. if(item.key_val == key_val){
  695. this.timeIntervalList.splice(index, 1)
  696. }
  697. })
  698. },
  699. addWelcom () {//添加分时段
  700. let addMsg_id = new Date().getTime()
  701. let obj = {
  702. is_day_parting: 1,//是否为分时段欢迎语 0:否 1:是
  703. weeks: [1, 2, 3, 4, 5, 6, 0],
  704. start_time: '',
  705. end_time: '',
  706. content: '',
  707. attachments: [],
  708. key_val:addMsg_id,
  709. }
  710. this.timeIntervalList.push(obj)
  711. },
  712. switchLimit(){
  713. if(this.user_id_list&&this.user_id_list.length==0){
  714. this.$message({
  715. type: 'error',
  716. message: '使用客服不能为空!'
  717. });
  718. return
  719. }
  720. }
  721. }
  722. }
  723. </script>
  724. <style lang="scss">
  725. .appendOnly{
  726. .el-input-group__append{
  727. padding: 0 20px;
  728. }
  729. }
  730. .limitBox{
  731. .el-switch.is-disabled .el-switch__core{
  732. cursor: pointer;
  733. }
  734. }
  735. </style>
  736. <style lang="scss" scoped>
  737. @import "../customOperate/create.scss";
  738. .listBox{
  739. margin-left: 90px;
  740. width: 730px;
  741. margin-top: 10px;
  742. background-color: #fbfbfb;
  743. padding: 10px;
  744. }
  745. .newGroupCss{
  746. color: #00b38a;
  747. font-size: 14px;
  748. margin-left: 10px;
  749. cursor: pointer;
  750. }
  751. .add_welcom_hint {
  752. color: #00b38a;
  753. font-size: 16px;
  754. font-weight: bold;
  755. margin-left: 90px;
  756. margin-top: 10px;
  757. margin-bottom: 20px;
  758. cursor: pointer;
  759. display: inline-block;
  760. }
  761. </style>