From f032b3aa7b0bfeb1acbbd19ab0ac148bd4227668 Mon Sep 17 00:00:00 2001 From: corala <18339694416@163.com> Date: Tue, 3 Jan 2023 11:01:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=96=E6=8E=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/api.js | 81 ++ src/views/Customer/label.vue | 18 +- src/views/Template/modelTodo.vue | 1495 +++++++++++++------------- src/views/Template/requiremining.vue | 210 ++-- 4 files changed, 919 insertions(+), 885 deletions(-) diff --git a/src/api/modules/api.js b/src/api/modules/api.js index 6fdda7f..475655f 100644 --- a/src/api/modules/api.js +++ b/src/api/modules/api.js @@ -1319,5 +1319,86 @@ export function getResultsList(data) { data: data }) } +//需求挖掘话术配置- 树图,设置初始选中值及分数回显 +export function findSelectedWordMiningTemplate(data) { + return request({ + url: `/autoSR/keywords/findSelectedWordMiningTemplate`, + method: 'GET', + data: data + }) +} +//需求挖掘话术配置- 编辑提交 +export function updateQuestion(data) { + return request({ + url: `/autoSR/keywords/updateQuestion`, + method: 'GET', + data: data + }) +} +//需求挖掘话术配置-排序提交 +export function updateSort(data) { + return request({ + url: `/autoSR/marketing/updateSort`, + method: 'POST', + data: data + }) +} +//需求挖掘话术配置- 评分保存 +export function saveWordTemplate(data) { + return request({ + url: `/autoSR/keywords/saveWordTemplate`, + method: 'POST', + data: data + }) +} +//需求挖掘话术配置-获取模型数据回显 +export function keymodelfindById(data) { + return request({ + url: `/autoSR/keymodel/findById`, + method: 'GET', + data: data + }) +} +//需求挖掘话术配置-设置话术等级 +export function setWordLevel(data) { + return request({ + url: `/autoSR/keywords/setWordLevel`, + method: 'GET', + data: data + }) +} +//需求挖掘话术配置-添加问题保存 +export function addQuestion(data) { + return request({ + url: `/autoSR/keywords/addQuestion`, + method: 'POST', + data: data + }) +} +//模型提醒 +export function todolist(data) { + return request({ + url: `/autoSR/todo/list`, + method: 'GET', + data: data + }) +} +//需求挖掘话术配置-修改保存标签模型 +export function updateKeywordsModel(data) { + return request({ + url: `/autoSR/keymodel/updateKeywordsModel`, + method: 'POST', + data: data + }) +} +//需求挖掘话术配置-拿问题获取所在的标签数据 +export function findKeywordsById(data) { + return request({ + url: `/autoSR/keywords/findKeywordsById`, + method: 'GET', + data: data + }) +} + diff --git a/src/views/Customer/label.vue b/src/views/Customer/label.vue index 92b0252..9732672 100644 --- a/src/views/Customer/label.vue +++ b/src/views/Customer/label.vue @@ -249,13 +249,21 @@ - - + + + + + + + + @@ -402,7 +410,8 @@ export default { endName: "", }, addForm2:{ - name:'' + name:'', + mustSelected:0 }, level: 0, pid: "", @@ -663,12 +672,13 @@ export default { data: { pid: 0, name: this.addForm2.name, + mustSelected: this.addForm2.mustSelected, level:1, orgCode:orgCode, }, }).then((res) => { this.dialogVisible2=false; - this.getHouse() + this.getHouse() }) }else{ this.$message({ diff --git a/src/views/Template/modelTodo.vue b/src/views/Template/modelTodo.vue index 61795b2..bb92fb8 100644 --- a/src/views/Template/modelTodo.vue +++ b/src/views/Template/modelTodo.vue @@ -1,196 +1,205 @@ @@ -198,514 +207,542 @@ export default { data() { return { - huashu: '', - wajueList: [], - level: '', - innerVisible:false, - dialogVisible: false, - dynamiclist: [], - taglist:[ - { - label: 'or (或)', - value: 'or' - }, - { - label: 'near (临近)', - value: 'near' - }, - { - label: 'after (后面)', - value: 'after' - }, - { - label: 'and not (非)', - value: 'andnot' - }, - // { - // label: '~ (至)', - // value: '~' - // }, - ], - form: { - keywordsName: '', - id: '', - keywordsId: '', - distance: 10, - sceneDesc:'', - originalExpression: '' - }, - searchForm:{ - updateUserName: '', - houseName: '', - name:'', - customtime: [], - startTime:'',//搜索开始时间 - endTime:'' //搜索结束时间 - }, - tableData: [{}], - type: 1, - keyType: '', - pageSize: 10, - total: 0, - pageNum: 1, - currentHouseId: '' + huashu: "", + wajueList: [], + level: "", + innerVisible: false, + dialogVisible: false, + dynamiclist: [], + taglist: [ + { + label: "or (或)", + value: "or", + }, + { + label: "near (临近)", + value: "near", + }, + { + label: "after (后面)", + value: "after", + }, + { + label: "and not (非)", + value: "andnot", + }, + // { + // label: '~ (至)', + // value: '~' + // }, + ], + form: { + keywordsName: "", + id: "", + keywordsId: "", + distance: 10, + sceneDesc: "", + originalExpression: "", + }, + searchForm: { + updateUserName: "", + houseName: "", + name: "", + customtime: [], + startTime: "", //搜索开始时间 + endTime: "", //搜索结束时间 + }, + tableData: [{}], + type: 1, + keyType: "", + pageSize: 10, + total: 0, + pageNum: 1, + currentHouseId: "", }; }, mounted() { - // this.houseId = localStorage.getItem("AitemId"); - // this.gettableList() - }, - methods: { - // keytype =0,获取需求挖掘类型的数据回显接口 - wajuehuixian(){ - // 获取模型数据回显 - axios({ - url: `${jypath}/zk/keymodel/findById`, - method: 'get', - params: { - houseId: this.currentHouseId, - level: this.level, - keyType: 0, - questionId: this.questionId, - keywordsId: this.form.keywordsId - } - }).then(res => { - this.dialogVisible = true - if (res.data.res == 1) { - let obj = res.data.obj - if(obj!=null){ - this.form.distance=obj.distance||10 - this.form.originalExpression= obj.originalExpression - this.form.id = obj.id - this.form.sceneDesc = obj.desc||'' - - // 回显标签模型数据 - if(obj.answerList&&obj.answerList.length){ - this.dynamiclist = obj.answerList.map(obj1=>{ - return { - id: obj1.id, - mark: obj1.name, - level: obj1.level3Id?3:2, - editValue: obj1.originalExpression, - markid:obj1.level3Id?obj1.level3Id:obj1.level2Id - } - }) - this.wajueList.forEach(item=>{ - this.dynamiclist.forEach(obj=>{ - if(item.id==obj.markid){ - item.disabled = true - } - }) - }) - // console.log(this.dynamiclist) - }else{ - this.dynamiclist = [] - } - }else{ - this.form.distance=10 - this.form.originalExpression= '' - this.form.id ='' - this.form.sceneDesc = '' - this.dynamiclist = [] - } - }else{ - this.form.sceneDesc = '' - this.form.distance = 10 - this.form.originalExpression = data.name - } - this.$nextTick(()=>{ - let huashuModel = document.getElementById('huashuModel') - huashuModel.innerHTML = this.form.originalExpression - }) - }).catch((e)=>{ - this.dialogVisible = true - }) - }, - otherhuixian(type){ - // 获取模型数据回显 - axios({ - url: `${jypath}/zk/keymodel/findById`, - method: 'get', - params: { - houseId: this.currentHouseId, - level: type==3?1:this.level, - keyType: type, - keywordsId: this.form.keywordsId - } - }).then(res => { - this.dialogVisible = true - if (res.data.res == 1) { - let obj = res.data.obj - if(obj!=null){ - this.form.distance=obj.distance||10 - this.form.originalExpression= obj.originalExpression||'' - this.form.id =obj.id||'' - this.form.sceneDesc = obj.desc||'' - // 回显标签模型数据 - if(obj.answerList&&obj.answerList.length){ - this.dynamiclist = obj.answerList.map(cont=>{ - return { - question: cont.question, - editValue: cont.originalExpression - } - }) - console.log(this.dynamiclist) - }else{ - this.dynamiclist = [] - } - }else{ - this.form.distance=10 - this.form.originalExpression= '' - this.form.id ='' - this.form.sceneDesc = '' - } - }else{ - this.form.distance = 10 - this.form.originalExpression = '' - this.form.sceneDesc = '' - } - this.$nextTick(()=>{ - let huashuModel = document.getElementById('huashuModel') - huashuModel.innerHTML = this.form.originalExpression - }) - }).catch((e)=>{ - this.dialogVisible = true - }) - }, - //点击编辑按钮 - async editFun(item){ - this.keyType = item.type - this.todoId = item.id - this.level = item.level - this.form.keywordsId = item.keywordsId - this.currentHouseId = item.houseId - this.form.distance = item.distance||10 - let level1Id = item.level1 - this.form.keywordsName = item.name - await this.findKeywordsById(level1Id)// 获取标签下拉数据 - if(item.type==0){// 挖掘话术类型 - this.questionId = item.wordId - this.wajuehuixian(level1Id) - }else{ - this.otherhuixian(item.type) - } - }, - // 处理标签,删除不需要的标签格式 - delMark(str) { - const hasStr = (str) => { - let index = str.indexOf('<') - let index1 = str.indexOf('>') - if(index>0&&index1>0){ - let replaceStr= str.substring(index, index1+1) - str= str.replace(replaceStr,'') - hasStr(str) - } - } - hasStr(str) - }, - // 处理模型 关键词加#号 - replaceFun(str){ - let temp = str - temp = temp.replace(/\ \;<\/text>/g,''); - temp = temp.replace(/\ \;/g,''); - temp = temp.replace(//g,''); - temp = temp.replace(/<\/text>/g,''); - temp = temp.replace(//g,' #');// 后台返回是这样的,变了,需要也处理一下 - temp = temp.replace(//g,' #'); - temp = temp.replace(/<\/span>/g,'#') - // console.log(temp); - // console.log('截取前',temp); - this.delMark(temp); - return temp - }, - //修改保存标签模型 - saveFun(){ - if(this.cansave) return ; // 防止多次点击 - this.cansave = true; - let text = document.getElementById('huashuModel'); - let answerList = [] - // console.log(text.innerHTML); - // console.log(text.innerText); - let temp = text.innerHTML - if(this.form.distance=='') {this.$message.error('请输入距离'); return;} - if(text.innerText=='') {this.$message.error('请输入标签模型'); return;} - if(this.keyType==0){ - for (var i=0;i{ - if(item1.id==this.dynamiclist[i].markid){ - this.dynamiclist[i].level = item1.level - this.dynamiclist[i].name = item1.name - } - }) - let huashuModel = document.getElementById('huashuModel'+i); - if(huashuModel.innerText=='') {this.$message.error('请完善选择的标签模型'); return ;} - this.dynamiclist[i].editValue = huashuModel.innerHTML - this.dynamiclist[i].editText = huashuModel.innerText - } - answerList = this.dynamiclist.map(item=>{ - return { - keyType: 2, - id: item.id||null, - level: item.level, - keywordsId: item.markid, - showFormatExpression: item.editText,//文本形式 - formatExpression: this.replaceFun(item.editValue),// 问题表达式,关键词加#号 - originalExpression: item.editValue // html==带span标签 - } - }) - } - axios({ - url: `${jypath}/zk/keymodel/updateKeywordsModel`, - method: 'post', - data: { - id:this.form.id, - questionId: this.keyType==0?this.questionId:'', - houseId:this.currentHouseId, - keyType: this.keyType, - level: this.keyType==3?1:this.level, - todoId: this.todoId, - keywordsId: this.form.keywordsId, - keywordsName: this.form.keywordsName, - formatExpression: this.replaceFun(temp),// 问题表达式,关键词加#号 - originalExpression: temp, // html==带span标签 - answerList: answerList, - showFormatExpression: text.innerText, - } - }).then(data => { - this.cansave = false; - this.dialogVisible = false - if(data.data.res==1){ - this.$message.success(data.data.obj) - this.gettableList() - }else{ - this.$message.error(data.data.resMsg) - } - }).catch((e)=>{ - this.cansave = false; - this.dialogVisible = false - }) - }, - // 校验是否已经选择过此标签 - checkrepeat(){ - this.wajueList.forEach(item=>{ - item.disabled = false - }) - this.wajueList.forEach(item=>{ - this.dynamiclist.forEach(obj=>{ - if(item.id==obj.markid){ - item.disabled = true - } - }) - }) - }, - addItemFun(){ - this.dynamiclist.push({ - editValue: '',//匹配模型正则表达式 - markid:'', - level: '', - name:'' - }) - }, + // this.houseId = localStorage.getItem("AitemId"); + // this.gettableList() + }, + methods: { + // keytype =0,获取需求挖掘类型的数据回显接口 + wajuehuixian() { + // 获取模型数据回显 + this.$api.api + .keymodelfindById({ + houseId: this.currentHouseId, + level: this.level, + keyType: 0, + questionId: this.questionId, + keywordsId: this.form.keywordsId, + }) + .then((res) => { + this.dialogVisible = true; + if (res.data.res == 1) { + let obj = res.data.obj; + if (obj != null) { + this.form.distance = obj.distance || 10; + this.form.originalExpression = obj.originalExpression; + this.form.id = obj.id; + this.form.sceneDesc = obj.desc || ""; - delItemFun(index){ - this.wajueList.forEach(item=>{ - if(item.id==this.dynamiclist[index].markid){ - item.disabled = false - } - }) - this.dynamiclist.splice(index,1); - document.getElementById('huashuModel').focus(); - }, - // 基于保存的光标插入内容 --用于失去焦点后再继续插入内容 - insertContent(str) { - let selection, range = window._range;// 当前光标位置对象 - if (!window.getSelection) { - range.pasteHTML(str); - range.collapse(false); - range.select(); - } else { - selection = window.getSelection ? window.getSelection() : document.selection; - range.collapse(false); - let hasR = range.createContextualFragment(str); - let hasR_lastChild = hasR.lastChild; - while (hasR_lastChild && hasR_lastChild.nodeName.toLowerCase() == "br" && hasR_lastChild.previousSibling && hasR_lastChild.previousSibling.nodeName.toLowerCase() == "br") { - let e = hasR_lastChild; - hasR_lastChild = hasR_lastChild.previousSibling; - hasR.removeChild(e); - } - range.insertNode(hasR); - if (hasR_lastChild) { - range.setEndAfter(hasR_lastChild); - range.setStartAfter(hasR_lastChild); - } - selection.removeAllRanges(); - selection.addRange(range); - } - }, - // 失去焦点时保存光标位置,记录光标位置 - saveRange: () => { - let selection = window.getSelection ? window.getSelection() : document.selection; - if (!selection.rangeCount) return; - let range = selection.createRange ? selection.createRange() : selection.getRangeAt(0); - window._range = range; - }, - // 回显模型数据,Dialog 的内容是懒渲染的,即在第一次被打开之前,传入的默认 slot 不会被渲染到 DOM 上,so在 open 事件回调中进行 - openModel(){ - this.$nextTick(()=>{ - let huashuModel = document.getElementById('huashuModel') - huashuModel.innerHTML = this.form.originalExpression - }) - }, - //格式化粘贴文本方法 - onPaste(event) { - var e = event || window.event - // 阻止默认粘贴 - e.preventDefault(); - // 粘贴事件有一个clipboardData的属性,提供了对剪贴板的访问 - // clipboardData的getData(fomat) 从剪贴板获取指定格式的数据 - var text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本'); - //清除回车 - text = text.replace(/\[\d+\]|\n|\r/ig,"") - // 插入 - document.execCommand("insertText", false, text); - }, - myeditorenter(e) { - e.preventDefault(); - }, - // 插入节点 - insertHtmlAtCaret(html) { - document.getElementById('huashuModel').focus(); - var sel, range; - if (window.getSelection) { - // IE9 and non-IE - sel = window.getSelection(); - if (sel.getRangeAt && sel.rangeCount) { - range = sel.getRangeAt(0); - range.deleteContents(); - // Range.createContextualFragment() would be useful here but is - // non-standard and not supported in all browsers (IE9, for one) - var el = document.createElement("div"); - el.innerHTML = html; - var frag = document.createDocumentFragment(), - node, lastNode; - while ((node = el.firstChild)) { - lastNode = frag.appendChild(node); - } - range.insertNode(frag); - // Preserve the selection - if (lastNode) { - range = range.cloneRange(); - range.setStartAfter(lastNode); - range.collapse(true); - sel.removeAllRanges(); - sel.addRange(range); - } - } - } else if (document.selection && document.selection.type != "Control") { - // IE < 9 - document.selection.createRange().pasteHTML(html); - } - }, - // 拿问题获取所在的标签数据 - findKeywordsById(level1Id){ - this.wajueList = [] - axios({ - url: `${jypath}/zk/keywords/findKeywordsById`, - method: 'get', - params: { - houseId: this.currentHouseId, - keywordsId: level1Id, - level: 1 - } - }).then(res => { - if (res.data.res == 1){ - console.log(res.data) - this.wajueList = res.data.obj - if(this.wajueList&&this.wajueList.length){ - this.wajueList.forEach(item=>{ - item.disabled = false - }) - // this.wajueList.forEach(item=>{ - // this.dynamiclist.forEach(obj=>{ - // if(item.id==obj.markid){ - // item.disabled = true - // } - // }) - // }) - } - } + // 回显标签模型数据 + if (obj.answerList && obj.answerList.length) { + this.dynamiclist = obj.answerList.map((obj1) => { + return { + id: obj1.id, + mark: obj1.name, + level: obj1.level3Id ? 3 : 2, + editValue: obj1.originalExpression, + markid: obj1.level3Id ? obj1.level3Id : obj1.level2Id, + }; }); - }, - // 插入节点 - insertTag(item,index){ - if(window._range){ - this.insertContent(""+item.value+" "); - }else{ - this.insertHtmlAtCaret(""+item.value+" "); - } - }, - searchFun(){ - this.tableData = [] - this.pageNum = 1 - this.gettableList() - }, - //时间选择 - confirmtime() { - this.searchForm.startTime = this.searchForm.customtime[0]; - this.searchForm.endTime = this.searchForm.customtime[1]; - }, - Emptycondition(){ - this.searchForm.updateUserName = '' - this.searchForm.houseName = '' - this.searchForm.name = '' - this.searchForm.startTime = '' - this.searchForm.endTime = '' - this.searchForm.customtime = [] - this.gettableList() - }, - changeType(){ - this.searchFun() - }, - gettableList() { - axios({ - url: `${jypath}/zk/todo/list`, - method: "get", - params: { - pageNum: this.pageNum, - pageSize: this.pageSize, - houseName: this.searchForm.houseName, - updateUserName: this.searchForm.updateUserName, - name: this.searchForm.name, - status: this.type, //status 状态 0已处理 1未处理 - startTime: this.searchForm.startTime, - endTime: this.searchForm.endTime - }, - }).then((data) => { - console.log(data); - if (data.data.res == 1) { - this.tableData = data.data.obj.results||[] - this.total = data.data.obj.totalRecord - }else{ - this.tableData = [] + this.wajueList.forEach((item) => { + this.dynamiclist.forEach((obj) => { + if (item.id == obj.markid) { + item.disabled = true; } + }); }); - }, - handleSizeChange(val) { - console.log("每页条" + val); - this.pageSize = val; - this.gettableList(); - }, - handleCurrentChange(val) { - console.log("当前页" + val); - this.pageNum = val; - this.gettableList(); + // console.log(this.dynamiclist) + } else { + this.dynamiclist = []; + } + } else { + this.form.distance = 10; + this.form.originalExpression = ""; + this.form.id = ""; + this.form.sceneDesc = ""; + this.dynamiclist = []; + } + } else { + this.form.sceneDesc = ""; + this.form.distance = 10; + this.form.originalExpression = data.name; + } + this.$nextTick(() => { + let huashuModel = document.getElementById("huashuModel"); + huashuModel.innerHTML = this.form.originalExpression; + }); + }) + .catch((e) => { + this.dialogVisible = true; + }); + }, + otherhuixian(type) { + // 获取模型数据回显 + this.$api.api + .keymodelfindById({ + houseId: this.currentHouseId, + level: type == 3 ? 1 : this.level, + keyType: type, + keywordsId: this.form.keywordsId, + }) + .then((res) => { + this.dialogVisible = true; + if (res.data.res == 1) { + let obj = res.data.obj; + if (obj != null) { + this.form.distance = obj.distance || 10; + this.form.originalExpression = obj.originalExpression || ""; + this.form.id = obj.id || ""; + this.form.sceneDesc = obj.desc || ""; + // 回显标签模型数据 + if (obj.answerList && obj.answerList.length) { + this.dynamiclist = obj.answerList.map((cont) => { + return { + question: cont.question, + editValue: cont.originalExpression, + }; + }); + console.log(this.dynamiclist); + } else { + this.dynamiclist = []; + } + } else { + this.form.distance = 10; + this.form.originalExpression = ""; + this.form.id = ""; + this.form.sceneDesc = ""; } + } else { + this.form.distance = 10; + this.form.originalExpression = ""; + this.form.sceneDesc = ""; + } + this.$nextTick(() => { + let huashuModel = document.getElementById("huashuModel"); + huashuModel.innerHTML = this.form.originalExpression; + }); + }) + .catch((e) => { + this.dialogVisible = true; + }); + }, + //点击编辑按钮 + async editFun(item) { + this.keyType = item.type; + this.todoId = item.id; + this.level = item.level; + this.form.keywordsId = item.keywordsId; + this.currentHouseId = item.houseId; + this.form.distance = item.distance || 10; + let level1Id = item.level1; + this.form.keywordsName = item.name; + await this.findKeywordsById(level1Id); // 获取标签下拉数据 + if (item.type == 0) { + // 挖掘话术类型 + this.questionId = item.wordId; + this.wajuehuixian(level1Id); + } else { + this.otherhuixian(item.type); + } + }, + // 处理标签,删除不需要的标签格式 + delMark(str) { + const hasStr = (str) => { + let index = str.indexOf("<"); + let index1 = str.indexOf(">"); + if (index > 0 && index1 > 0) { + let replaceStr = str.substring(index, index1 + 1); + str = str.replace(replaceStr, ""); + hasStr(str); } + }; + hasStr(str); + }, + // 处理模型 关键词加#号 + replaceFun(str) { + let temp = str; + temp = temp.replace(/\ \;<\/text>/g, ""); + temp = temp.replace(/\ \;/g, ""); + temp = temp.replace(//g, ""); + temp = temp.replace(/<\/text>/g, ""); + temp = temp.replace( + //g, + " #" + ); // 后台返回是这样的,变了,需要也处理一下 + temp = temp.replace( + //g, + " #" + ); + temp = temp.replace(/<\/span>/g, "#"); + // console.log(temp); + // console.log('截取前',temp); + this.delMark(temp); + return temp; + }, + //修改保存标签模型 + saveFun() { + if (this.cansave) return; // 防止多次点击 + this.cansave = true; + let text = document.getElementById("huashuModel"); + let answerList = []; + // console.log(text.innerHTML); + // console.log(text.innerText); + let temp = text.innerHTML; + if (this.form.distance == "") { + this.$message.error("请输入距离"); + return; + } + if (text.innerText == "") { + this.$message.error("请输入标签模型"); + return; + } + if (this.keyType == 0) { + for (var i = 0; i < this.dynamiclist.length; i++) { + if (!this.dynamiclist[i].markid) { + this.$message.error("请完善要选择的标签"); + return; + } + this.wajueList.map((item1) => { + if (item1.id == this.dynamiclist[i].markid) { + this.dynamiclist[i].level = item1.level; + this.dynamiclist[i].name = item1.name; + } + }); + let huashuModel = document.getElementById("huashuModel" + i); + if (huashuModel.innerText == "") { + this.$message.error("请完善选择的标签模型"); + return; + } + this.dynamiclist[i].editValue = huashuModel.innerHTML; + this.dynamiclist[i].editText = huashuModel.innerText; + } + answerList = this.dynamiclist.map((item) => { + return { + keyType: 2, + id: item.id || null, + level: item.level, + keywordsId: item.markid, + showFormatExpression: item.editText, //文本形式 + formatExpression: this.replaceFun(item.editValue), // 问题表达式,关键词加#号 + originalExpression: item.editValue, // html==带span标签 + }; + }); + } + this.$api.api + .updateKeywordsModel({ + id: this.form.id, + questionId: this.keyType == 0 ? this.questionId : "", + houseId: this.currentHouseId, + keyType: this.keyType, + level: this.keyType == 3 ? 1 : this.level, + todoId: this.todoId, + keywordsId: this.form.keywordsId, + keywordsName: this.form.keywordsName, + formatExpression: this.replaceFun(temp), // 问题表达式,关键词加#号 + originalExpression: temp, // html==带span标签 + answerList: answerList, + showFormatExpression: text.innerText, + }) + .then((res) => { + this.cansave = false; + this.dialogVisible = false; + if (data.data.res == 1) { + this.$message.success(data.data.obj); + this.gettableList(); + } else { + this.$message.error(data.data.resMsg); + } + }) + .catch((e) => { + this.cansave = false; + this.dialogVisible = false; + }); + }, + // 校验是否已经选择过此标签 + checkrepeat() { + this.wajueList.forEach((item) => { + item.disabled = false; + }); + this.wajueList.forEach((item) => { + this.dynamiclist.forEach((obj) => { + if (item.id == obj.markid) { + item.disabled = true; + } + }); + }); + }, + addItemFun() { + this.dynamiclist.push({ + editValue: "", //匹配模型正则表达式 + markid: "", + level: "", + name: "", + }); + }, + + delItemFun(index) { + this.wajueList.forEach((item) => { + if (item.id == this.dynamiclist[index].markid) { + item.disabled = false; + } + }); + this.dynamiclist.splice(index, 1); + document.getElementById("huashuModel").focus(); + }, + // 基于保存的光标插入内容 --用于失去焦点后再继续插入内容 + insertContent(str) { + let selection, + range = window._range; // 当前光标位置对象 + if (!window.getSelection) { + range.pasteHTML(str); + range.collapse(false); + range.select(); + } else { + selection = window.getSelection + ? window.getSelection() + : document.selection; + range.collapse(false); + let hasR = range.createContextualFragment(str); + let hasR_lastChild = hasR.lastChild; + while ( + hasR_lastChild && + hasR_lastChild.nodeName.toLowerCase() == "br" && + hasR_lastChild.previousSibling && + hasR_lastChild.previousSibling.nodeName.toLowerCase() == "br" + ) { + let e = hasR_lastChild; + hasR_lastChild = hasR_lastChild.previousSibling; + hasR.removeChild(e); + } + range.insertNode(hasR); + if (hasR_lastChild) { + range.setEndAfter(hasR_lastChild); + range.setStartAfter(hasR_lastChild); + } + selection.removeAllRanges(); + selection.addRange(range); + } + }, + // 失去焦点时保存光标位置,记录光标位置 + saveRange: () => { + let selection = window.getSelection + ? window.getSelection() + : document.selection; + if (!selection.rangeCount) return; + let range = selection.createRange + ? selection.createRange() + : selection.getRangeAt(0); + window._range = range; + }, + // 回显模型数据,Dialog 的内容是懒渲染的,即在第一次被打开之前,传入的默认 slot 不会被渲染到 DOM 上,so在 open 事件回调中进行 + openModel() { + this.$nextTick(() => { + let huashuModel = document.getElementById("huashuModel"); + huashuModel.innerHTML = this.form.originalExpression; + }); + }, + //格式化粘贴文本方法 + onPaste(event) { + var e = event || window.event; + // 阻止默认粘贴 + e.preventDefault(); + // 粘贴事件有一个clipboardData的属性,提供了对剪贴板的访问 + // clipboardData的getData(fomat) 从剪贴板获取指定格式的数据 + var text = + (e.originalEvent || e).clipboardData.getData("text/plain") || + prompt("在这里输入文本"); + //清除回车 + text = text.replace(/\[\d+\]|\n|\r/gi, ""); + // 插入 + document.execCommand("insertText", false, text); + }, + myeditorenter(e) { + e.preventDefault(); + }, + // 插入节点 + insertHtmlAtCaret(html) { + document.getElementById("huashuModel").focus(); + var sel, range; + if (window.getSelection) { + // IE9 and non-IE + sel = window.getSelection(); + if (sel.getRangeAt && sel.rangeCount) { + range = sel.getRangeAt(0); + range.deleteContents(); + // Range.createContextualFragment() would be useful here but is + // non-standard and not supported in all browsers (IE9, for one) + var el = document.createElement("div"); + el.innerHTML = html; + var frag = document.createDocumentFragment(), + node, + lastNode; + while ((node = el.firstChild)) { + lastNode = frag.appendChild(node); + } + range.insertNode(frag); + // Preserve the selection + if (lastNode) { + range = range.cloneRange(); + range.setStartAfter(lastNode); + range.collapse(true); + sel.removeAllRanges(); + sel.addRange(range); + } + } + } else if (document.selection && document.selection.type != "Control") { + // IE < 9 + document.selection.createRange().pasteHTML(html); + } + }, + // 拿问题获取所在的标签数据 + findKeywordsById(level1Id) { + this.wajueList = []; + this.$api.api + .keymodelfindById({ + houseId: this.currentHouseId, + keywordsId: level1Id, + level: 1, + }) + .then((res) => { + if (res.data.res == 1) { + console.log(res.data); + this.wajueList = res.data.obj; + if (this.wajueList && this.wajueList.length) { + this.wajueList.forEach((item) => { + item.disabled = false; + }); + } + } + }); + }, + // 插入节点 + insertTag(item, index) { + if (window._range) { + this.insertContent( + "" + + item.value + + " " + ); + } else { + this.insertHtmlAtCaret( + "" + + item.value + + " " + ); + } + }, + searchFun() { + this.tableData = []; + this.pageNum = 1; + this.gettableList(); + }, + //时间选择 + confirmtime() { + this.searchForm.startTime = this.searchForm.customtime[0]; + this.searchForm.endTime = this.searchForm.customtime[1]; + }, + Emptycondition() { + this.searchForm.updateUserName = ""; + this.searchForm.houseName = ""; + this.searchForm.name = ""; + this.searchForm.startTime = ""; + this.searchForm.endTime = ""; + this.searchForm.customtime = []; + this.gettableList(); + }, + changeType() { + this.searchFun(); + }, + gettableList() { + this.$api.api + .todolist({ + pageNum: this.pageNum, + pageSize: this.pageSize, + houseName: this.searchForm.houseName, + updateUserName: this.searchForm.updateUserName, + name: this.searchForm.name, + status: this.type, //status 状态 0已处理 1未处理 + startTime: this.searchForm.startTime, + endTime: this.searchForm.endTime, + }) + .then((res) => { + console.log(data); + if (data.data.res == 1) { + this.tableData = data.data.obj.results || []; + this.total = data.data.obj.totalRecord; + } else { + this.tableData = []; + } + }); + }, + handleSizeChange(val) { + console.log("每页条" + val); + this.pageSize = val; + this.gettableList(); + }, + handleCurrentChange(val) { + console.log("当前页" + val); + this.pageNum = val; + this.gettableList(); + }, + }, }; - diff --git a/src/views/Template/requiremining.vue b/src/views/Template/requiremining.vue index ea651e4..7715c21 100644 --- a/src/views/Template/requiremining.vue +++ b/src/views/Template/requiremining.vue @@ -3,7 +3,7 @@
* 选择楼盘: - + @@ -343,17 +343,11 @@ export default { }, created() { this.allTreeListId = [] // 存储的当前树图所有的接单的ID集合,如:[1,3,4,6,7] - this.noIds = []// 左侧树没有,但右侧有的数据id - this.rateMap = new Map() - this.sortMap = new Map() - this.formDataMap = new Map() }, mounted() { - this.houseId=localStorage.getItem("AitemId"); - let menuObj = localStorage.getItem("JumpParams").split(','); - this.menuid = menuObj[0] + this.houseId=localStorage.getItem("houseId"); //获取项目 - this.getHouse() + // this.getHouse() }, computed: { dragOptions() { @@ -375,17 +369,13 @@ export default { this.level1 = data.level1 this.findKeywordsById(data.level1) // 获取模型数据回显 - axios({ - url: `${jypath}/zk/keymodel/findById`, - method: 'get', - params: { - houseId: this.houseId, - level: this.level1, - keyType: 0, - questionId: this.questionId, - keywordsId: data.keywordsId - } - }).then(res => { + this.$api.api.findKeywordsById({ + houseId: this.houseId, + level: this.level1, + keyType: 0, + questionId: this.questionId, + keywordsId: data.keywordsId + }).then((res) => { this.moxingVisible = true if (res.data.res == 1) { let obj = res.data.obj @@ -471,11 +461,8 @@ export default { originalExpression: item.editValue // html,带span标签 } }) - axios({ - url: `${jypath}/zk/keymodel/updateKeywordsModel`, - method: 'post', - data: { - id: this.form.id, + this.$api.api.updateKeywordsModel({ + id: this.form.id, questionId: this.questionId, houseId:this.houseId, keyType: 0, @@ -486,8 +473,7 @@ export default { originalExpression: temp, // html==带span标签 answerList: answerList, showFormatExpression: text.innerText - } - }).then(data => { + }).then((res) => { this.cansave = false; this.moxingVisible = false if(data.data.res==1){ @@ -500,7 +486,6 @@ export default { this.cansave = false; this.moxingVisible = false }) - }, // 确认插入选择的话术 clickOK(){ @@ -667,16 +652,12 @@ export default { // 拿问题获取所在的标签数据 findKeywordsById(level){ this.wajueList = [] - axios({ - url: `${jypath}/zk/keywords/findKeywordsById`, - method: 'get', - params: { - houseId: this.houseId, - keyType:0,//挖掘 - keywordsId: this.form.keywordsId, - level: level - } - }).then(res => { + this.$api.api.findKeywordsById({ + houseId: this.houseId, + keyType:0,//挖掘 + keywordsId: this.form.keywordsId, + level: level + }).then((res) => { if (res.data.res == 1){ console.log(res.data) this.wajueList = res.data.obj @@ -745,16 +726,12 @@ export default { } if(!this.flag){ this.flag = true - axios({ - url: `${jypath}/zk/keywords/addQuestion`, - method: 'post', - data: { - houseId: this.houseId, - level: this.level, - keywordsId: this.frosasd.id, - question: this.dynamicTags.join(';') - } - }).then(res => { + this.$api.api.addQuestion({ + houseId: this.houseId, + level: this.level, + keywordsId: this.frosasd.id, + question: this.dynamicTags.join(';') + }).then((res) => { this.flag = false if (res.data.res === 1) { // console.log(res.data) @@ -776,11 +753,12 @@ export default { }, // 设置需求话术等级 saveSet() { - axios({ - url: `${jypath}/zk/keywords/setWordLevel?houseId=` + this.houseId + '&level=' + this.frosasd.setVal + '&keywordId=' + this.frosasd.id, - method: 'get', - params: {} - }).then(res => { + this.$api.api.setWordLevel({ + houseI: this.houseId, + level: this.frosasd.setVal, + keywordId: this.frosasd.id + }).then((res) => { + if (res.data.res === 1) { // console.log(res.data) this.$message({ @@ -800,11 +778,10 @@ export default { }, // 删除问题 remove(node, data) { - axios({ - url: `${jypath}/zk/keywords/delQuestion?houseId=` + this.houseId + '&id=' + (data.id).substring(1), - method: 'get', - params: {} - }).then(res => { + this.$api.api.delQuestion({ + houseI: this.houseId, + id: (data.id).substring(1) + }).then((res) => { if (res.data.res === 1) { console.log(res.data) this.$message({ @@ -822,13 +799,10 @@ export default { }, // 获取项目下拉的数据 getHouse() { - axios({ - url: `${jypath}/template/getHouse`, - method: 'get', - params: {} - }).then(res => { - if (res.data.res === 1) { - this.houseList = res.data.obj.map(item => { + this.$api.api.findHouseByUser({ + orgType: localStorage.getItem("orgType"), + }).then((res) => { + this.houseList = res.data.map(item => { return { value: item.id, label: item.propertyName @@ -837,23 +811,18 @@ export default { if (this.houseId == '') { this.houseId = this.houseList[0].value; } - this.getTreeData() - this.setInitCheck() - } + this.getTreeData() + this.setInitCheck() }); }, // 树图,设置初始选中值及分数回显 setInitCheck() { this.defaultCheck = [] - axios({ - url: `${jypath}/zk/keywords/findSelectedWordMiningTemplate`, - method: 'get', - params: { - houseId: this.houseId, - selected:0,//selected 0选中 1未选中 - menu:this.menuid - } - }).then(res => { + this.$api.api.findSelectedWordMiningTemplate({ + houseId: this.houseId, + selected:0,//selected 0选中 1未选中 + menu:this.menuid + }).then((res) => { if (res.data.res === 1) { let data = res.data.obj.list data = JSON.stringify(data).replace(/name/g, 'label') @@ -911,15 +880,11 @@ export default { }, // 获取层级树 getTreeData() { - axios({ - url: `${jypath}/zk/keywords/findSelectedWordMiningTemplate`, - method: 'get', - params: { - houseId: this.houseId, - selected:1,//selected 0选中 1未选中 - menu:this.menuid - } - }).then(res => { + this.$api.api.findSelectedWordMiningTemplate({ + houseId: this.houseId, + selected:1,//selected 0选中 1未选中 + menu:this.menuid + }).then((res) => { if (res.data.res === 1) { let data = res.data.obj.list if(res.data.obj.permitBtn.length){ @@ -1022,15 +987,11 @@ export default { }, //编辑提交 submiadd() { - axios({ - url: `${jypath}/zk/keywords/updateQuestion`, - method: 'get', - params: { - id: this.frosasd.id, - houseId: this.houseId, - question: this.frosasd.name - } - }).then(res => { + this.$api.api.updateQuestion({ + id: this.frosasd.id, + houseId: this.houseId, + question: this.frosasd.name + }).then((res) => { if (res.data.res == 1) { this.$message({ message: '修改成功', @@ -1056,7 +1017,6 @@ export default { //拖拽排序 Peerdrag(before) { let arr = []; - this.treeList.forEach((item, index) => { if (before.data.pid == item.pid) { arr.push(item) @@ -1101,15 +1061,9 @@ export default { }, //排序提交 dragSort(list) { - axios({ - url: `${jypath}/marketing/updateSort`, - method: 'post', - data: { - children: list - } - }).then(res => { - - }); + this.$api.api.updateSort({ + children: list + }).then((res) => {}) }, //控制那个可拖拽节点 allowDrag(draggingNode, dropNode, type) { @@ -1153,14 +1107,6 @@ export default { Deletecategories(item, index) { if (this.newlist[index].children.length == 0) { this.newlist.splice(index, 1) - // 取消左侧的勾选 - // let number = this.defaultCheck.indexOf(item.id) - // if(number>0){ - // this.defaultCheck.splice(number,1) - // } - // // console.log('删除评分一级',item.id) - // // console.log(this.defaultCheck) - // this.$refs.tree.setCheckedKeys(this.defaultCheck) } else { this.$message({ message: '请先清空子级', @@ -1172,15 +1118,6 @@ export default { Removethesecondary(index, idx, asd) { if (this.newlist[index].children[idx].children == null || this.newlist[index].children[idx].children.length == 0) { this.newlist[index].children.splice(idx, 1) - // 取消左侧的勾选 - // let number = this.defaultCheck.indexOf(asd.id) - // if(number>0){ - // this.defaultCheck.splice(number,1) - // } - // // console.log('删除评分二级') - // // console.log(this.defaultCheck,asd.id) - // this.$refs.tree.setCheckedKeys(this.defaultCheck) - } else { this.$message({ message: '请先清空子级', @@ -1191,31 +1128,10 @@ export default { //删除 二级下的问题 Deletethelevel2(index, idx, indx, sanji) { this.newlist[index].children[idx].children.splice(indx, 1); - // 取消左侧的勾选 - // if((sanji.id+'').indexOf('q')<0){ - // sanji.id= 'q'+sanji.id - // } - // console.log(this.defaultCheck) - // let number = this.defaultCheck.indexOf(sanji.id) - // if(number>0){ - // this.defaultCheck.splice(number,1) - // } - // console.log('二级下的问题',sanji.id) - // console.log(this.defaultCheck) - // this.$refs.tree.setCheckedKeys(this.defaultCheck) }, // 删除 一级下的问题,没有二级 Deletethelevel1(index, idx, sanji) { this.newlist[index].children.splice(idx, 1); - // 取消左侧的勾选 - // if((sanji.id+'').indexOf('q')<0){ - // sanji.id= 'q'+sanji.id - // } - // let number = this.defaultCheck.indexOf(sanji.id) - // if(number>0){ - // this.defaultCheck.splice(number,1) - // } - // this.$refs.tree.setCheckedKeys(this.defaultCheck) }, // ------获取选中的节点 getCheckedNode() { @@ -1334,8 +1250,6 @@ export default { }); return } - ; - //一级 for (var i = 0; i < list.length; i++) { if (list[i].fraction == '') { @@ -1485,11 +1399,7 @@ export default { }, // 评分保存 saveRate(params) { - axios({ - url: `${jypath}/zk/keywords/saveWordTemplate`, - method: 'post', - data: params, - }).then(res => { + this.$api.api.saveWordTemplate(params).then((res) => { if (res.data.res === 1) { this.$message({ message: '保存成功',