This commit is contained in:
yaosen 2024-07-03 18:01:39 +08:00
parent ad40d07dc1
commit ec65dba79d
7 changed files with 10 additions and 8 deletions

View File

@ -86,7 +86,7 @@ export default {
if (!val) return ''; // undefined
let replaceReg = new RegExp(this.dataForm.keyword, "ig");
let replaceString = `<span style="color: #fca104">${this.dataForm.keyword}</span>`;
let replaceString = `<span style="color: #fff;background-color: #FC0421FF;">${this.dataForm.keyword}</span>`;
return val.replace(replaceReg, replaceString);
},
handleprantHtml(val) {
@ -95,10 +95,11 @@ export default {
let p = this.dataForm.keyword;
let regexp = new RegExp(p, "g");
let replacedHtml = val.replace(/(?<=>)[^>]+(?=<[/]?\w+.*>)/g, (v) => {
return v.replace(regexp, `<span style='color: #fca104'>${p}</span>`);
return v.replace(regexp, `<span style='color: #fff;background-color: #FC0421FF;'>${p}</span>`);
});
//
if (replacedHtml === val) {
// handleprant
return this.handleprant(val);
}
return replacedHtml;

View File

@ -27,12 +27,13 @@ class QaController extends base
$qaIds = QaQuestions::whereRaw("title LIKE ? OR content LIKE ?", ['%'.$keyword.'%', '%'.$keyword.'%'])
->column('qa_id');
$listQuery->when(!empty($qaIds), function ($query) use ($qaIds) {
$query->whereIn('id', $qaIds); // 请将 'qa_id_field' 替换为实际的关联字段名
$query->whereIn('id', $qaIds);
});
}
$list = $listQuery->order('id', 'desc')
->with(['qaQuestions' => function ($query) {
->with(['qaQuestions' => function ($query) use ($keyword) {
$query->whereRaw("title LIKE ? OR content LIKE ?", ['%'.$keyword.'%', '%'.$keyword.'%']);
$query->order('sort', 'desc');
}])
->paginate($limit);

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
@font-face{font-family:PingFang;src:url(../../static/fonts/PingFang\ SC.212ada59.ttf);font-weight:400;font-style:normal}body[data-v-1e0c4d6f]{font-family:PingFang!important}.infinite-list[data-v-1e0c4d6f]{list-style-type:none;height:calc(100vh - 154px);padding:0;margin:0}.desc_container+.desc_container[data-v-1e0c4d6f]{margin-top:10px;padding-top:10px}.desc_container .desc_title[data-v-1e0c4d6f]{font-size:18px;font-weight:500;color:#333;line-height:25px;margin-bottom:10px}.desc_container .desc_content[data-v-1e0c4d6f]{font-size:14px;font-weight:300}.problem .problem_form[data-v-1e0c4d6f]{margin-top:10px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.problem .problem_container[data-v-1e0c4d6f],.problem .problem_form[data-v-1e0c4d6f]{display:-webkit-box;display:-ms-flexbox;display:flex}.problem .problem_container .problem_left[data-v-1e0c4d6f]{font-family:PingFang,sans-serif;font-weight:300;width:18%;background:#fff;padding:0 20px;border-right:2px solid #46a6ff;height:calc(100vh - 154px)}.problem .problem_container .problem_left .btn[data-v-1e0c4d6f]{color:#fff;padding:10px 20px;cursor:pointer;text-align:center;background:#46a6ff;border-radius:10px}.problem .problem_container .problem_left .btn+.btn[data-v-1e0c4d6f]{margin-top:10px}.problem .problem_container .problem_right[data-v-1e0c4d6f]{width:100%;background:#fff;padding:0 20px}.problem .problem_container .problem_right .problem_right_container+.problem_right_container[data-v-1e0c4d6f]{margin-top:20px}.problem .problem_container .problem_right .problem_right_container .title[data-v-1e0c4d6f]{font-size:20px;font-weight:600;margin-bottom:10px;color:#46a6ff}.problem .problem_container .problem_right .problem_right_container .title[data-v-1e0c4d6f]>:first-child{margin-right:40px}.problem .problem_container .problem_right .problem_right_container .desc[data-v-1e0c4d6f]{font-size:14px;color:#666;line-height:24px}
@font-face{font-family:PingFang;src:url(../../static/fonts/PingFang\ SC.212ada59.ttf);font-weight:400;font-style:normal}body[data-v-5eb66a1f]{font-family:PingFang!important}.infinite-list[data-v-5eb66a1f]{list-style-type:none;height:calc(100vh - 154px);padding:0;margin:0}.desc_container+.desc_container[data-v-5eb66a1f]{margin-top:10px;padding-top:10px}.desc_container .desc_title[data-v-5eb66a1f]{font-size:18px;font-weight:500;color:#333;line-height:25px;margin-bottom:10px}.desc_container .desc_content[data-v-5eb66a1f]{font-size:14px;font-weight:300}.problem .problem_form[data-v-5eb66a1f]{margin-top:10px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.problem .problem_container[data-v-5eb66a1f],.problem .problem_form[data-v-5eb66a1f]{display:-webkit-box;display:-ms-flexbox;display:flex}.problem .problem_container .problem_left[data-v-5eb66a1f]{font-family:PingFang,sans-serif;font-weight:300;width:18%;background:#fff;padding:0 20px;border-right:2px solid #46a6ff;height:calc(100vh - 154px)}.problem .problem_container .problem_left .btn[data-v-5eb66a1f]{color:#fff;padding:10px 20px;cursor:pointer;text-align:center;background:#46a6ff;border-radius:10px}.problem .problem_container .problem_left .btn+.btn[data-v-5eb66a1f]{margin-top:10px}.problem .problem_container .problem_right[data-v-5eb66a1f]{width:100%;background:#fff;padding:0 20px}.problem .problem_container .problem_right .problem_right_container+.problem_right_container[data-v-5eb66a1f]{margin-top:20px}.problem .problem_container .problem_right .problem_right_container .title[data-v-5eb66a1f]{font-size:20px;font-weight:600;margin-bottom:10px;color:#46a6ff}.problem .problem_container .problem_right .problem_right_container .title[data-v-5eb66a1f]>:first-child{margin-right:40px}.problem .problem_container .problem_right .problem_right_container .desc[data-v-5eb66a1f]{font-size:14px;color:#666;line-height:24px}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2f2fadde"],{3526:function(t,a,e){"use strict";e("9241")},9241:function(t,a,e){},e132:function(t,a,e){"use strict";e.r(a);var i=function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"problem"},[e("el-row",[e("el-col",{attrs:{span:24}},[e("div",{staticClass:"problem_form"},[e("el-form",{ref:"form",attrs:{inline:!0,model:t.dataForm,"label-width":"60px"}},[e("el-form-item",{attrs:{label:"关键字:"}},[e("el-input",{staticClass:"filter-item",staticStyle:{width:"400px"},attrs:{placeholder:"请输入搜索关键字"},model:{value:t.dataForm.keyword,callback:function(a){t.$set(t.dataForm,"keyword",a)},expression:"dataForm.keyword"}})],1),e("el-form-item",[e("el-button",{attrs:{type:"success"},on:{click:t.onSubmit}},[t._v("查询")])],1)],1)],1)])],1),e("div",{staticClass:"problem_container"},[e("div",{staticClass:"problem_left"},t._l(t.getQaCityList,(function(a){return e("div",{staticClass:"btn",on:{click:function(e){return t.handleQacityl(a.city_id)}}},[t._v(t._s(a.city_name))])})),0),e("div",{staticClass:"problem_right"},[e("ul",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.load,expression:"load"}],staticClass:"infinite-list",staticStyle:{overflow:"auto"},attrs:{"infinite-scroll-immediate":!1}},t._l(t.getQaLists,(function(a){return e("li",{staticClass:"problem_right_container"},[e("div",{staticClass:"title"},[e("span",{domProps:{innerHTML:t._s(t.handleprant(a.title))}}),e("el-button",{attrs:{type:"primary"},on:{click:function(e){return t.handleZip(a.img_zip)}}},[t._v("下载图片")]),e("el-button",{attrs:{type:"primary"},on:{click:function(e){return t.handleZip(a.trip_zip)}}},[t._v("下载行程")])],1),t._l(a.qaQuestions,(function(a){return e("div",{staticClass:"desc_container"},[e("div",{staticClass:"desc",staticStyle:{"font-weight":"700",color:"#46a6ff"},domProps:{innerHTML:t._s(t.handleprant(a.title))}}),e("div",{staticClass:"desc",domProps:{innerHTML:t._s(t.handleprantHtml(a.content))}})])}))],2)})),0)])])],1)},n=[],s=(e("4d63"),e("ac1f"),e("2c3e"),e("25f0"),e("5319"),e("85a8")),r={data:function(){return{getQaCityList:[],getQaLists:[],dataForm:{keyword:"",city_id:""}}},created:function(){var t=this;Object(s["a"])().then((function(a){t.getQaCityList=a.data}))},watch:{"dataForm.keyword":function(t){t&&this.onSubmit()}},methods:{handleQacityl:function(t){var a=this;Object(s["b"])({city_id:t}).then((function(t){a.getQaLists=t.data.data}))},handleZip:function(t){t?window.open(t):this.$message({showClose:!0,message:"暂无下载链接"})},load:function(){console.log("load")},handleprant:function(t){if(!t)return"";var a=new RegExp(this.dataForm.keyword,"ig"),e='<span style="color: #fff;background-color: #FC0421FF;">'.concat(this.dataForm.keyword,"</span>");return t.replace(a,e)},handleprantHtml:function(t){if(!t)return"";var a=this.dataForm.keyword,e=new RegExp(a,"g"),i=t.replace(/(?<=>)[^>]+(?=<[/]?\w+.*>)/g,(function(t){return t.replace(e,"<span style='color: #fff;background-color: #FC0421FF;'>".concat(a,"</span>"))}));return i===t?this.handleprant(t):i},onSubmit:function(){var t=this;Object(s["b"])(this.dataForm).then((function(a){t.getQaLists=a.data.data}))}}},o=r,l=(e("3526"),e("2877")),c=Object(l["a"])(o,i,n,!1,null,"5eb66a1f",null);a["default"]=c.exports}}]);

View File

@ -1 +0,0 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7157a291"],{"5cf3":function(t,e,a){},e132:function(t,e,a){"use strict";a.r(e);var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"problem"},[a("el-row",[a("el-col",{attrs:{span:24}},[a("div",{staticClass:"problem_form"},[a("el-form",{ref:"form",attrs:{inline:!0,model:t.dataForm,"label-width":"60px"}},[a("el-form-item",{attrs:{label:"关键字:"}},[a("el-input",{staticClass:"filter-item",staticStyle:{width:"400px"},attrs:{placeholder:"请输入搜索关键字"},model:{value:t.dataForm.keyword,callback:function(e){t.$set(t.dataForm,"keyword",e)},expression:"dataForm.keyword"}})],1),a("el-form-item",[a("el-button",{attrs:{type:"success"},on:{click:t.onSubmit}},[t._v("查询")])],1)],1)],1)])],1),a("div",{staticClass:"problem_container"},[a("div",{staticClass:"problem_left"},t._l(t.getQaCityList,(function(e){return a("div",{staticClass:"btn",on:{click:function(a){return t.handleQacityl(e.city_id)}}},[t._v(t._s(e.city_name))])})),0),a("div",{staticClass:"problem_right"},[a("ul",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.load,expression:"load"}],staticClass:"infinite-list",staticStyle:{overflow:"auto"},attrs:{"infinite-scroll-immediate":!1}},t._l(t.getQaLists,(function(e){return a("li",{staticClass:"problem_right_container"},[a("div",{staticClass:"title"},[a("span",{domProps:{innerHTML:t._s(t.handleprant(e.title))}}),a("el-button",{attrs:{type:"primary"},on:{click:function(a){return t.handleZip(e.img_zip)}}},[t._v("下载图片")]),a("el-button",{attrs:{type:"primary"},on:{click:function(a){return t.handleZip(e.trip_zip)}}},[t._v("下载行程")])],1),t._l(e.qaQuestions,(function(e){return a("div",{staticClass:"desc_container"},[a("div",{staticClass:"desc",staticStyle:{"font-weight":"700",color:"#46a6ff"},domProps:{innerHTML:t._s(t.handleprant(e.title))}}),a("div",{staticClass:"desc",domProps:{innerHTML:t._s(t.handleprantHtml(e.content))}})])}))],2)})),0)])])],1)},n=[],s=(a("4d63"),a("ac1f"),a("2c3e"),a("25f0"),a("5319"),a("85a8")),r={data:function(){return{getQaCityList:[],getQaLists:[],dataForm:{keyword:"",city_id:""}}},created:function(){var t=this;Object(s["a"])().then((function(e){t.getQaCityList=e.data}))},watch:{"dataForm.keyword":function(t){t&&this.onSubmit()}},methods:{handleQacityl:function(t){var e=this;Object(s["b"])({city_id:t}).then((function(t){e.getQaLists=t.data.data}))},handleZip:function(t){t?window.open(t):this.$message({showClose:!0,message:"暂无下载链接"})},load:function(){console.log("load")},handleprant:function(t){if(!t)return"";var e=new RegExp(this.dataForm.keyword,"ig"),a='<span style="color: #fca104">'.concat(this.dataForm.keyword,"</span>");return t.replace(e,a)},handleprantHtml:function(t){if(!t)return"";var e=this.dataForm.keyword,a=new RegExp(e,"g"),i=t.replace(/(?<=>)[^>]+(?=<[/]?\w+.*>)/g,(function(t){return t.replace(a,"<span style='color: #fca104'>".concat(e,"</span>"))}));return i===t?this.handleprant(t):i},onSubmit:function(){var t=this;Object(s["b"])(this.dataForm).then((function(e){t.getQaLists=e.data.data}))}}},o=r,l=(a("e550"),a("2877")),c=Object(l["a"])(o,i,n,!1,null,"1e0c4d6f",null);e["default"]=c.exports},e550:function(t,e,a){"use strict";a("5cf3")}}]);