Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

910 linhas
29 KiB

  1. <template>
  2. <div class="box-center">
  3. <!-- 头 -->
  4. <div class="app-top">
  5. <div class="app-titel" style="margin-top: 5px">
  6. <div
  7. class="label"
  8. style="color: #32363d; font-weight: 400"
  9. v-if="orgType != 3"
  10. >
  11. 项目选择:
  12. </div>
  13. <div v-if="orgType != 3">
  14. <el-select
  15. v-model="houseId"
  16. @change="houseChange"
  17. placeholder="请选择"
  18. filterable
  19. >
  20. <el-option
  21. v-for="item in houseList"
  22. :key="item.id"
  23. :label="item.propertyName"
  24. :value="item.id"
  25. >
  26. </el-option>
  27. </el-select>
  28. </div>
  29. <div class="label">敏感词:</div>
  30. <div>
  31. <el-input
  32. v-model="words"
  33. placeholder="敏感词"
  34. maxlength="8"
  35. clearable
  36. ></el-input>
  37. </div>
  38. <div style="margin-left: 20px">
  39. <el-button type="primary" @click="screening()">筛选</el-button>
  40. </div>
  41. <div
  42. style="margin-left: auto; margin-right: 10px"
  43. v-if="tem_tab_downLoad"
  44. >
  45. <el-button v-if="tem_tab_add" @click="editorinfo()" type="primary"
  46. >新增</el-button
  47. >
  48. <el-button @click="downLoad" icon="el-icon-download">导出</el-button>
  49. </div>
  50. </div>
  51. </div>
  52. <!-- 表格 -->
  53. <div class="cen-tab">
  54. <avue-crud
  55. ref="crud"
  56. :page.sync="page"
  57. :data="tableData"
  58. :table-loading="tableLoading"
  59. :option="tableOption"
  60. :show-column.sync="showColumn"
  61. @size-change="handleSizeChange"
  62. @current-change="handleCurrentChange"
  63. >
  64. <template slot-scope="{ row }" slot="menu">
  65. <el-button v-if="tem_tab_edit" type="text" @click="bianji(row)"
  66. >编辑</el-button>
  67. <el-button v-if="tem_tab_del" type="text" @click="del(row)">删除</el-button>
  68. <el-button type="text" @click="editFun(row.id)">模型匹配</el-button>
  69. </template>
  70. </avue-crud>
  71. </div>
  72. <el-dialog
  73. :title="editFlag ? '编辑' : '新增'"
  74. :center="true"
  75. width="600px"
  76. :visible.sync="dialogVisible"
  77. @close="$refs.ruleForm.resetFields()"
  78. >
  79. <el-form
  80. :model="ruleForm"
  81. label-position="labelPosition"
  82. :rules="ruleser"
  83. ref="ruleForm"
  84. label-width="80px"
  85. style="width: 100%; margin: 0 auto"
  86. >
  87. <el-form-item label="敏感词" prop="words">
  88. <el-input
  89. v-model="ruleForm.words"
  90. placeholder="敏感词"
  91. maxlength="8"
  92. clearable
  93. ></el-input>
  94. </el-form-item>
  95. <el-form-item label="场景描述" prop="sceneDesc">
  96. <el-input
  97. type="textarea"
  98. v-model="ruleForm.sceneDesc"
  99. placeholder="敏感词"
  100. maxlength="100"
  101. show-word-limit
  102. clearable
  103. ></el-input>
  104. <div>增加场景描述有利于标签命中,场景越丰富触达越精准;例如:送家具 ,场景:现在买房我们送家具;</div>
  105. </el-form-item>
  106. </el-form>
  107. <div
  108. slot="footer"
  109. class="dialog-footer"
  110. style="
  111. border-top: 1px solid #eee;
  112. padding-top: 20px;
  113. display: flex;
  114. justify-content: end;">
  115. <el-button @click="dialogVisible = false">取 消</el-button>
  116. <el-button type="primary" :loading="loadingFlag" @click="editor()">保存</el-button >
  117. </div>
  118. </el-dialog>
  119. <el-dialog
  120. title="编辑模型"
  121. @open="openModel"
  122. :close-on-click-modal="false"
  123. :visible.sync="modelVisible"
  124. >
  125. <el-dialog
  126. title="匹配规则"
  127. :visible.sync="innerVisible"
  128. append-to-body>
  129. <div style="max-height: 430px;overflow: auto">
  130. <p><b>匹配距离</b>:关键字匹配字数距离,主要针对near/after/w- 生效,w- 的字数统计从挖掘话术后,客户的第一句话开始统计;</p>
  131. <p style="padding-left: 15px">例如:设置为10,面积 after 140</br>
  132. 命中话术:"想买一个面积在140平的"</br>
  133. 超出10个字,有关键字不命中话术参考:“房屋面积啊,你们这边有多大的,有没有140平左右的”;</p>
  134. <p><b>or(或)</b>:多个关键词,匹配上1个就行</p>
  135. <p style="padding-left: 15px">例如标签:自住</br>
  136. 匹配模型:自己住 or 给自己</br>
  137. 命中话术:我们自己住/给自己买的</p>
  138. <p><b>and not(非)</b>:排除反面意思</p>
  139. <p style="padding-left: 15px">例如:北京户口,</br>
  140. 匹配模型:是北京户口 and not 不是北京户口</br>
  141. 命中话术:我是北京户口;</br>
  142. 反面话术:我不是北京户口</p>
  143. <p><b>near ( 临近)</b>:1个关键词前后一定范围出现过另一个关键词就算命中,有距离限制</p>
  144. <p style="padding-left: 15px">例如标签:购房预算 140w</br>
  145. 匹配模型:预算 near 140</br>
  146. 命中话术:我的预算是140w或大概140w的购房预算</p>
  147. <p><b>after(后面)</b>:一段文本出现2个关键词,并且按照先后的顺序即算命中,有距离限制</p>
  148. <p style="padding-left: 15px">例如标签:意向面积 140平</br>
  149. 匹配模型: 面积 after 140 ,140在面积后面才算生效;</br>
  150. 命中话术:想买一个面积在140平的;</p>
  151. <p><b>answer(挖掘话术业务)</b>:顾问执行了挖掘话术,客户回答结果,有距离限制,从客户话术文本开始</p>
  152. <p style="padding-left: 15px">例如标签:北京户口</br>
  153. 匹配模型:(w-是 or w-有) and not (w-不是 or w-没有)</br>
  154. 命中话术:销售:你有北京户口吗?</br>
  155. 客户:有的;</p>
  156. <p><b>-n(命中距离)</b>:near/after-n ,单个near/after的匹配距离,n大于0,小于500</p>
  157. <p style="padding-left: 15px">例如 :面积 after-10 140</br>
  158. 10个字内,命中话术参考:"想买一个面积在140平的"</br>
  159. 超出10个字,有关键字不命中话术参考:“房屋面积啊,你们这边有多大的,有没有140平左右的”;</p>
  160. <p><b>注意</b>:-n 与 near/after/answer 之间<b>不能有空格</b>;</p></br>
  161. <p><b>注意</b>:优先匹配关键词可以排在前面;</p>
  162. </div>
  163. </el-dialog>
  164. <el-form ref="form" size="mini" :inline="true" :model="form" label-position="right">
  165. <el-form-item label="敏感词:">
  166. <div style="max-width:400px;min-width: 200px;font-weight: bold">{{form.keywordsName||'XXX'}}</div>
  167. </el-form-item>
  168. <el-form-item label="场景描述:">
  169. <div v-if="form.sceneDesc" style="width:500px;border: 1px dashed #ccc;padding:5px 10px;line-height: 25px"> {{form.sceneDesc}}</div>
  170. <div v-else>暂无描述</div>
  171. </el-form-item>
  172. <el-form-item label="after,near,answer 匹配距离:">
  173. <el-input-number v-model="form.distance" controls-position="right" :min="0" :max="500"></el-input-number>
  174. <span style="color:red;margin-left:10px">*请输入0~500内的整数</span>
  175. <el-button type="text" style="margin-left:30px" @click="innerVisible=true">规则说明</el-button>
  176. </el-form-item>
  177. <div contentEditable="true"
  178. @click="myeditorenter($event)"
  179. @keypress.enter="myeditorenter($event)"
  180. @blur="saveRange"
  181. @paste="onPaste"
  182. class="editDiv"
  183. id="huashuModel">
  184. </div>
  185. <el-form-item label="插入节点:">
  186. <el-button size="mini" type="primary" style="margin-left:8px;" v-for="(item,index) in taglist" :key="index" @click="insertTag(item,index)">{{item.label}}</el-button>
  187. </el-form-item>
  188. </el-form>
  189. <span slot="footer" class="dialog-footer">
  190. <el-button @click="modelVisible = false">取 消</el-button>
  191. <el-button type="primary" @click="saveFun">保 存</el-button>
  192. </span>
  193. </el-dialog>
  194. </div>
  195. </template>
  196. <script>
  197. import { mapGetters } from "vuex";
  198. import { exportMethodPost } from "@/util/util";
  199. export default {
  200. data() {
  201. return {
  202. dynamiclist: [],
  203. taglist:[
  204. {
  205. label: 'or (或)',
  206. value: 'or'
  207. },
  208. {
  209. label: 'near (临近)',
  210. value: 'near'
  211. },
  212. {
  213. label: 'after (后面)',
  214. value: 'after'
  215. },
  216. {
  217. label: 'and not (非)',
  218. value: 'andnot'
  219. },
  220. // {
  221. // label: '~ (至)',
  222. // value: '~'
  223. // },
  224. ],
  225. form: {
  226. keywordsName: '',
  227. id: '',
  228. keywordsId: '',
  229. distance: 10,
  230. sceneDesc:'',
  231. originalExpression: ''
  232. },
  233. modelVisible:false,
  234. innerVisible:false,
  235. innerVisible1:false,
  236. dialogVisible: false,
  237. tableIdName: "TemplateTaboo", // 当前页面需要的变量
  238. tableOption: this.$tableOption.TemplateTaboo, // 当前table配置项
  239. tableLoading: false, // 是否显示加载中
  240. showColumn: [], // 监听的显示列的变量
  241. page: {
  242. total: 0, // 总页数
  243. currentPage: 1, // 当前页数
  244. pageSize: 10, // 每页显示多少条
  245. },
  246. currentPage4: 1,
  247. value: "",
  248. input: "",
  249. tableData: [],
  250. multipleSelection: [],
  251. loadingFlag: false,
  252. orgType: localStorage.getItem("orgType"),
  253. ruleForm: {
  254. words: "",
  255. sceneDesc: '',
  256. id: "",
  257. },
  258. houseId: "",
  259. houseList: [],
  260. words: "",
  261. ruleser: {
  262. words: [{ required: true, message: "请填写禁忌词", trigger: "blur" }],
  263. },
  264. editFlag: false,
  265. hasOwn: [], // 是否拥有敏感词
  266. };
  267. },
  268. computed: {
  269. ...mapGetters(["permissions"]),
  270. },
  271. watch: {
  272. showColumn(nowV) {
  273. let params = {
  274. tableIdName: this.tableIdName,
  275. optionData: nowV,
  276. };
  277. this.$db.upDate(params);
  278. },
  279. },
  280. created() {
  281. this.houseId=localStorage.getItem("houseId");
  282. // 获取显隐的列表
  283. this.setTableOption();
  284. this.tem_tab_add = this.permissions["tem_tab_add"];
  285. this.tem_tab_del = this.permissions["tem_tab_del"];
  286. this.tem_tab_edit = this.permissions["tem_tab_edit"];
  287. this.tem_tab_downLoad = this.permissions["tem_tab_downLoad"];
  288. },
  289. mounted() {
  290. this.zkhousePage();
  291. },
  292. methods: {
  293. // 插入节点
  294. insertTag(item,index){
  295. if(window._range){
  296. this.insertContent("<span contentEditable='false' style='color:red'>"+item.value+"</span><text>&nbsp;</text>");
  297. }else{
  298. this.insertHtmlAtCaret("<span contentEditable='false' style='color:red'>"+item.value+"</span><text>&nbsp;</text>");
  299. }
  300. },
  301. // 处理标签,删除不需要的标签格式
  302. delMark(str) {
  303. const hasStr = (str) => {
  304. let index = str.indexOf('<')
  305. let index1 = str.indexOf('>')
  306. if(index>0&&index1>0){
  307. let replaceStr= str.substring(index, index1+1)
  308. str= str.replace(replaceStr,'')
  309. hasStr(str)
  310. }
  311. }
  312. hasStr(str)
  313. },
  314. // 确认插入选择的话术
  315. clickOK(){
  316. this.innerVisible1 = false
  317. if(!this.huashu) {this.$message.error('请选择话术'); return ;}
  318. this.insertContent("<text>"+this.huashu+"</text><span contentEditable='false' style='color:red'>answer</span><text>&nbsp;</text>");
  319. },
  320. //点击编辑按钮
  321. editFun(id){
  322. this.form.keywordsId = id
  323. this.form.keywordsName = ''
  324. this.form.id = ''
  325. // 获取模型数据回显
  326. axios({
  327. url: `/autoSR/zk/keymodel/findById`,
  328. method: 'get',
  329. params: {
  330. houseId: this.houseId,
  331. keyType: 3,
  332. keywordsId: id
  333. }
  334. }).then(res => {
  335. this.modelVisible = true
  336. if (res.code == 0) {
  337. let obj = res.data
  338. if(obj!=null){
  339. this.form.distance = obj.distance||10
  340. this.form.originalExpression = obj.originalExpression
  341. this.form.id = obj.id
  342. this.form.sceneDesc = obj.desc||''
  343. this.form.keywordsName = obj.level1Name
  344. }else{
  345. this.form.distance=10
  346. this.form.id = ''
  347. this.form.originalExpression=''
  348. }
  349. }else{
  350. this.form.distance = 10
  351. this.form.originalExpression = ''
  352. this.form.id = ''
  353. }
  354. this.$nextTick(()=>{
  355. let huashuModel = document.getElementById('huashuModel')
  356. huashuModel.innerHTML = this.form.originalExpression
  357. })
  358. }).catch((e)=>{
  359. this.modelVisible = true
  360. })
  361. },
  362. // 处理模型 关键词加#号
  363. replaceFun(str){
  364. let temp = str
  365. temp = temp.replace(/<text>\&nbsp\;<\/text>/g,'');
  366. temp = temp.replace(/\&nbsp\;/g,'');
  367. temp = temp.replace(/<text>/g,'');
  368. temp = temp.replace(/<\/text>/g,'');
  369. temp = temp.replace(/<span contenteditable="false" style="color:red">/g,' #');// 后台返回是这样的,变了,需要也处理一下
  370. temp = temp.replace(/<span style="color:red" contenteditable="false">/g,' #');
  371. temp = temp.replace(/<\/br>/g,'')
  372. temp = temp.replace(/<br>/g,'')
  373. temp = temp.replace(/<\/span>/g,'#')
  374. // console.log('处理前temp',temp);
  375. this.delMark(temp);
  376. // console.log(temp);
  377. return temp
  378. },
  379. // 模型保存
  380. saveFun(){
  381. let text = document.getElementById('huashuModel');
  382. // console.log(text.innerHTML);
  383. // console.log(text.innerText);
  384. let temp = text.innerHTML
  385. if(this.form.distance=='') {this.$message.error('请输入距离'); return;}
  386. if(text.innerText=='') {this.$message.error('请输入标签模型'); return;}
  387. axios({
  388. url: `/autoSR/zk/keymodel/updateKeywordsModel`,
  389. method: 'post',
  390. data: {
  391. id: this.form.id||"",
  392. houseId: this.houseId,
  393. level: 1,
  394. keywordsId: this.form.keywordsId,
  395. keywordsName: this.form.keywordsName,
  396. answerList: [],
  397. keyType: 3,
  398. formatExpression: this.replaceFun(temp),// 问题表达式
  399. originalExpression: temp,// html数据
  400. showFormatExpression: text.innerText,
  401. distance: this.form.distance, // * 距离
  402. desc: this.form.sceneDesc//场景描述
  403. }
  404. }).then(res => {
  405. this.dialogVmodelVisibleisible = false
  406. if(res.code==0){
  407. this.$message.success(res.data)
  408. this.getorgCode()
  409. }else{
  410. this.$message.error(res.msg)
  411. }
  412. }).catch((e)=>{
  413. this.modelVisible = false
  414. })
  415. },
  416. // 失去焦点时保存光标位置,记录光标位置
  417. saveRange: () => {
  418. let selection = window.getSelection ? window.getSelection() : document.selection;
  419. if (!selection.rangeCount) return;
  420. let range = selection.createRange ? selection.createRange() : selection.getRangeAt(0);
  421. window._range = range;
  422. },
  423. // 回显模型数据,Dialog 的内容是懒渲染的,即在第一次被打开之前,传入的默认 slot 不会被渲染到 DOM 上,so在 open 事件回调中进行
  424. openModel(){
  425. this.$nextTick(()=>{
  426. let huashuModel = document.getElementById('huashuModel')
  427. huashuModel.innerHTML = this.form.originalExpression
  428. })
  429. },
  430. //格式化粘贴文本方法
  431. onPaste(event) {
  432. // var e = event || window.event
  433. // // 阻止默认粘贴
  434. // e.preventDefault();
  435. // // 粘贴事件有一个clipboardData的属性,提供了对剪贴板的访问
  436. // // clipboardData的getData(fomat) 从剪贴板获取指定格式的数据
  437. // var text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本');
  438. // //清除回车
  439. // text = text.replace(/\[\d+\]|\n|\r/ig,"")
  440. // // 插入
  441. // document.execCommand("insertText", false, text);
  442. let e = event || window.event
  443. let types = event.clipboardData.types
  444. // 粘贴事件有一个clipboardData的属性,提供了对剪贴板的访问
  445. let flag = false
  446. if (types && types.length > 0) {
  447. types.forEach(ele => {
  448. if (ele == 'Files') {
  449. flag = true
  450. }
  451. })
  452. }
  453. if (flag) {
  454. event.preventDefault()
  455. }
  456. },
  457. myeditorenter(e) {
  458. e.preventDefault();
  459. },
  460. // 插入节点
  461. insertHtmlAtCaret(html) {
  462. document.getElementById('huashuModel').focus();
  463. var sel, range;
  464. if (window.getSelection) {
  465. // IE9 and non-IE
  466. sel = window.getSelection();
  467. if (sel.getRangeAt && sel.rangeCount) {
  468. range = sel.getRangeAt(0);
  469. range.deleteContents();
  470. // Range.createContextualFragment() would be useful here but is
  471. // non-standard and not supported in all browsers (IE9, for one)
  472. var el = document.createElement("div");
  473. el.innerHTML = html;
  474. var frag = document.createDocumentFragment(),
  475. node, lastNode;
  476. while ((node = el.firstChild)) {
  477. lastNode = frag.appendChild(node);
  478. }
  479. range.insertNode(frag);
  480. // Preserve the selection
  481. if (lastNode) {
  482. range = range.cloneRange();
  483. range.setStartAfter(lastNode);
  484. range.collapse(true);
  485. sel.removeAllRanges();
  486. sel.addRange(range);
  487. }
  488. }
  489. } else if (document.selection && document.selection.type != "Control") {
  490. // IE < 9
  491. document.selection.createRange().pasteHTML(html);
  492. }
  493. },
  494. // 校验是否已经选择过此标签
  495. checkrepeat(){
  496. this.wajueList.forEach(item=>{
  497. item.disabled = false
  498. })
  499. this.wajueList.forEach(item=>{
  500. this.dynamiclist.forEach(obj=>{
  501. if(item.id==obj.markid){
  502. item.disabled = true
  503. }
  504. })
  505. })
  506. },
  507. addItemFun(){
  508. this.dynamiclist.push({
  509. editValue: '',//匹配模型正则表达式
  510. markid:'',
  511. level: '',
  512. name:''
  513. })
  514. },
  515. delItemFun(index){
  516. this.wajueList.forEach(item=>{
  517. if(item.id==this.dynamiclist[index].markid){
  518. item.disabled = false
  519. }
  520. })
  521. this.dynamiclist.splice(index,1)
  522. document.getElementById('huashuModel').focus(); // 防止插入到外面,造成不可删除的操作
  523. },
  524. // 基于保存的光标插入内容 --用于失去焦点后再继续插入内容
  525. insertContent(str) {
  526. let selection, range = window._range;// 当前光标位置对象
  527. if (!window.getSelection) {
  528. range.pasteHTML(str);
  529. range.collapse(false);
  530. range.select();
  531. } else {
  532. selection = window.getSelection ? window.getSelection() : document.selection;
  533. range.collapse(false);
  534. let hasR = range.createContextualFragment(str);
  535. let hasR_lastChild = hasR.lastChild;
  536. while (hasR_lastChild && hasR_lastChild.nodeName.toLowerCase() == "br" && hasR_lastChild.previousSibling && hasR_lastChild.previousSibling.nodeName.toLowerCase() == "br") {
  537. let e = hasR_lastChild;
  538. hasR_lastChild = hasR_lastChild.previousSibling;
  539. hasR.removeChild(e);
  540. }
  541. range.insertNode(hasR);
  542. if (hasR_lastChild) {
  543. range.setEndAfter(hasR_lastChild);
  544. range.setStartAfter(hasR_lastChild);
  545. }
  546. selection.removeAllRanges();
  547. selection.addRange(range);
  548. }
  549. },
  550. // 失去焦点时保存光标位置,记录光标位置
  551. saveRange: () => {
  552. let selection = window.getSelection ? window.getSelection() : document.selection;
  553. if (!selection.rangeCount) return;
  554. let range = selection.createRange ? selection.createRange() : selection.getRangeAt(0);
  555. window._range = range;
  556. },
  557. // 回显模型数据,Dialog 的内容是懒渲染的,即在第一次被打开之前,传入的默认 slot 不会被渲染到 DOM 上,so在 open 事件回调中进行
  558. openModel(){
  559. this.$nextTick(()=>{
  560. let huashuModel = document.getElementById('huashuModel')
  561. huashuModel.innerHTML = this.form.originalExpression
  562. })
  563. },
  564. //格式化粘贴文本方法
  565. onPaste(event) {
  566. // var e = event || window.event
  567. // // 阻止默认粘贴
  568. // e.preventDefault();
  569. // // 粘贴事件有一个clipboardData的属性,提供了对剪贴板的访问
  570. // // clipboardData的getData(fomat) 从剪贴板获取指定格式的数据
  571. // var text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本');
  572. // //清除回车
  573. // text = text.replace(/\[\d+\]|\n|\r/ig,"")
  574. // // 插入
  575. // document.execCommand("insertText", false, text);
  576. let e = event || window.event
  577. let types = event.clipboardData.types
  578. // 粘贴事件有一个clipboardData的属性,提供了对剪贴板的访问
  579. let flag = false
  580. if (types && types.length > 0) {
  581. types.forEach(ele => {
  582. if (ele == 'Files') {
  583. flag = true
  584. }
  585. })
  586. }
  587. if (flag) {
  588. event.preventDefault()
  589. }
  590. },
  591. myeditorenter(e) {
  592. e.preventDefault();
  593. },
  594. // 插入节点
  595. insertHtmlAtCaret(html) {
  596. document.getElementById('huashuModel').focus();
  597. var sel, range;
  598. if (window.getSelection) {
  599. // IE9 and non-IE
  600. sel = window.getSelection();
  601. if (sel.getRangeAt && sel.rangeCount) {
  602. range = sel.getRangeAt(0);
  603. range.deleteContents();
  604. // Range.createContextualFragment() would be useful here but is
  605. // non-standard and not supported in all browsers (IE9, for one)
  606. var el = document.createElement("div");
  607. el.innerHTML = html;
  608. var frag = document.createDocumentFragment(),
  609. node, lastNode;
  610. while ((node = el.firstChild)) {
  611. lastNode = frag.appendChild(node);
  612. }
  613. range.insertNode(frag);
  614. // Preserve the selection
  615. if (lastNode) {
  616. range = range.cloneRange();
  617. range.setStartAfter(lastNode);
  618. range.collapse(true);
  619. sel.removeAllRanges();
  620. sel.addRange(range);
  621. }
  622. }
  623. } else if (document.selection && document.selection.type != "Control") {
  624. // IE < 9
  625. document.selection.createRange().pasteHTML(html);
  626. }
  627. },
  628. // 获取当前页面的显隐
  629. setTableOption() {
  630. this.$db.getDataByKey(this.tableIdName).then((res) => {
  631. if (res.tableIdName == this.tableIdName) {
  632. this.showColumn = res.optionData;
  633. }
  634. });
  635. },
  636. downLoad() {
  637. let obj = {
  638. houseId: this.houseId,
  639. words: this.words,
  640. };
  641. exportMethodPost("autoSR/sensitivewords/export", "禁忌话术", obj);
  642. },
  643. houseChange() {
  644. this.page.currentPage = 1;
  645. this.words = "";
  646. this.taboofindbypagelist();
  647. },
  648. zkhousePage() {
  649. this.$api.api
  650. .findHouseByUser({
  651. orgType: localStorage.getItem("orgType"),
  652. })
  653. .then((res) => {
  654. this.houseList = res.data;
  655. if (localStorage.getItem("orgType") == 3) {
  656. this.houseId = localStorage.getItem("houseId");
  657. } else {
  658. this.houseId = res.data[0].id;
  659. }
  660. this.taboofindbypagelist();
  661. });
  662. },
  663. taboofindbypagelist() {
  664. let obj = {
  665. current: this.page.currentPage,
  666. size: this.page.pageSize,
  667. houseId: this.houseId,
  668. words: this.words,
  669. };
  670. this.$api.http.taboofindbypage(obj).then((res) => {
  671. console.log(res);
  672. this.tableData = res.data.records;
  673. this.hasOwn = res.data.records.map((item) => {
  674. return item.words;
  675. });
  676. this.page.total = res.data.total;
  677. // 表格中设置ref属性,在数据渲染之后或者updated()之后
  678. this.$nextTick(() => {
  679. this.$refs.crud.doLayout();
  680. });
  681. });
  682. },
  683. screening() {
  684. this.page.currentPage = 1;
  685. this.taboofindbypagelist();
  686. },
  687. //删除
  688. del(item) {
  689. this.$confirm("此操作将永久删除, 是否继续?", "提示", {
  690. confirmButtonText: "确定",
  691. cancelButtonText: "取消",
  692. distinguishCancelAndClose: true,
  693. type: "warning",
  694. })
  695. .then(() => {
  696. this.$api.http.taboodelete({ id: item.id,houseId:this.houseId }).then((res) => {
  697. if (res.code == 0) {
  698. this.$message({
  699. type: "success",
  700. message: "删除成功!",
  701. });
  702. this.page.currentPage = 1;
  703. this.words = "";
  704. this.taboofindbypagelist();
  705. } else {
  706. this.$message.error(res.msg);
  707. }
  708. });
  709. })
  710. .catch(() => {
  711. // this.$message({
  712. // type: "info",
  713. // message: "已取消删除",
  714. // });
  715. });
  716. },
  717. //编辑
  718. bianji(row) {
  719. this.ruleForm.id = row.id;
  720. this.dialogVisible = true;
  721. this.ruleForm.words = row.words;
  722. this.ruleForm.sceneDesc = row.desc;
  723. this.editFlag = true;
  724. },
  725. editorinfo() {
  726. this.dialogVisible = true;
  727. this.editFlag = false;
  728. this.ruleForm.words = "";
  729. },
  730. editor() {
  731. this.$refs.ruleForm.validate((valid) => {
  732. if (valid) {
  733. if (this.hasOwn.indexOf(this.ruleForm.words) != -1) {
  734. this.$message.error("该敏感词已存在");
  735. return;
  736. }
  737. this.loadingFlag = true;
  738. if (this.editFlag == false) {
  739. this.$api.http
  740. .tabooadd({
  741. houseId: this.houseId,
  742. words: this.ruleForm.words,
  743. desc: this.ruleForm.sceneDesc// 场景描述
  744. })
  745. .then((res) => {
  746. if (res.code == 0) {
  747. this.dialogVisible = false;
  748. this.$refs.ruleForm.resetFields();
  749. this.page.currentPage = 1;
  750. this.words = "";
  751. this.taboofindbypagelist();
  752. this.$message.success(res.data);
  753. } else {
  754. this.$message.error(res.msg);
  755. }
  756. setTimeout(() => {
  757. this.loadingFlag = false;
  758. }, 1);
  759. })
  760. .catch((e) => {
  761. setTimeout(() => {
  762. this.loadingFlag = false;
  763. }, 1);
  764. });
  765. } else {
  766. this.$api.http
  767. .tabooupdate({
  768. id: this.ruleForm.id,
  769. desc: this.ruleForm.sceneDesc,
  770. words: this.ruleForm.words,
  771. })
  772. .then((res) => {
  773. if (res.code == 0) {
  774. this.dialogVisible = false;
  775. this.$refs.ruleForm.resetFields();
  776. this.page.currentPage = 1;
  777. this.words = "";
  778. this.taboofindbypagelist();
  779. this.$message.success(res.data);
  780. } else {
  781. this.$message.error(res.msg);
  782. }
  783. setTimeout(() => {
  784. this.loadingFlag = false;
  785. }, 1);
  786. })
  787. .catch((e) => {
  788. setTimeout(() => {
  789. this.loadingFlag = false;
  790. }, 1);
  791. });
  792. }
  793. } else {
  794. return false;
  795. }
  796. });
  797. },
  798. handleSizeChange(val) {
  799. console.log(`每页 ${val} 条`);
  800. this.page.pageSize = val;
  801. this.taboofindbypagelist();
  802. },
  803. handleCurrentChange(val) {
  804. console.log(`当前页: ${val}`);
  805. this.page.currentPage = val;
  806. this.taboofindbypagelist();
  807. },
  808. },
  809. };
  810. </script>
  811. <style scoped="scoped" lang="scss" >
  812. .editDiv{
  813. width:100%;
  814. min-height:60px;
  815. max-height:120px;
  816. overflow:auto;
  817. margin-bottom:10px;
  818. padding: 15px;
  819. outline: none;
  820. border:1px solid #409EFF;
  821. border-radius: 10px;
  822. }
  823. .box-center {
  824. width: 100%;
  825. padding: 5px 15px 20px;
  826. min-width: 1000px;
  827. }
  828. .cen-tab {
  829. width: 100%;
  830. padding: 15px;
  831. background: #ffffff;
  832. margin-top: 15px;
  833. }
  834. .tophove {
  835. color: #ffffff;
  836. background: #2671e2;
  837. }
  838. .app-top {
  839. width: 100%;
  840. background: #ffffff;
  841. box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.04);
  842. border-radius: 4px;
  843. padding-top: 15px;
  844. padding-bottom: 15px;
  845. .app-titel {
  846. width: 100%;
  847. display: flex;
  848. align-items: center;
  849. .label {
  850. font-size: 14px;
  851. font-weight: 400;
  852. color: #32363d;
  853. line-height: 14px;
  854. margin-left: 15px;
  855. }
  856. .toptimeqhuan {
  857. height: 30px;
  858. background: #ffffff;
  859. display: flex;
  860. align-items: center;
  861. }
  862. .toptimeqhuan div {
  863. padding-left: 20px;
  864. padding-right: 20px;
  865. text-align: center;
  866. line-height: 30px;
  867. font-size: 14px;
  868. margin-right: 15px;
  869. border-radius: 4px;
  870. border: 1px solid #e0e0e0;
  871. }
  872. }
  873. }
  874. /deep/ .el-table__header-wrapper {
  875. thead {
  876. tr {
  877. th {
  878. background: #f5f7fa;
  879. color: #333333;
  880. }
  881. }
  882. }
  883. }
  884. /deep/ .el-dialog--center {
  885. border-radius: 8px;
  886. .el-dialog__title {
  887. font-weight: bold;
  888. }
  889. }
  890. /deep/ .el-button--primary {
  891. background: #2671e2 !important;
  892. border: 1px solid #2671e2 !important;
  893. }
  894. /deep/ .el-button--text {
  895. color: #2671e2;
  896. }
  897. </style>