12 |
- import{_ as e,W as a,n as t,r as l,a as i,o as s,c as n,w as d,i as o,b as u,d as r,e as p,f as c,A as f,a5 as g,g as h,j as m,k as _,l as y,F as b,I as P,m as R,t as x,u as C}from"./index-BAMs4g2N.js";import{_ as I}from"./uni-stat-breadcrumb.BZcF2zJw.js";import{_ as k}from"./uni-data-select.UeW2d6Yw.js";import{_ as $}from"./uni-pagination.7SrZmsZK.js";import{_ as w}from"./unicloud-db.BGC9uZmF.js";import{_ as z}from"./uni-notice-bar.DFNPNQTK.js";const v={};const D=a.database(),V=["title","path"],L={ascending:"asc",descending:"desc"};const j=e({data:()=>({collectionList:"uni-stat-pages",appid:"",query:"",where:"",orderby:"",orderByFieldName:"",selectedIndexs:[],errorMessage:"",options:{pageSize:20,pageCurrent:1,filterData:{},...v},imageStyles:{width:64,height:64},exportExcel:{filename:"uni-stat-pages.xls",type:"xls",fields:{title:"title",path:"path"}},exportExcelData:[],pageInfo:{_id:"",page_rules:[]},editRulePopup:{loading:!1,tips:"页面规则说明:\n1. 用于生成内容统计 url 的规则。通过设置页面有效参数,通过带参数的 url 对内容进行标识。例如有一个详情页面的请求有三个参数 page/detail/detail?id=1&type=1&t=1565943419,其中 t 为时间戳或随机数,则 id 和 type 为有效参数,需要在页面规则 page/detail/detail 中添加 id,type 这两个参数。\n2. 每条规则可以添加多个参数,进行匹配时,每条规则单独生效。\n3. 每个页面可以添加多个规则(最多 5 个规则),进行匹配时,后添加的规则优先级较高\n4. 目前的匹配规则只能处理通过 url 显式传递参数,且参数形式为上述示例中的键值对格式。",isAddParam:!1,addParamInfo:{index1:"",value:""}}}),onLoad(){this._filter={}},onReady(){this.$refs.appListRef&&(this.appid=this.$refs.appListRef.getCache(),this.search())},methods:{onqueryload(e){this.exportExcelData=e},getWhere(){const e=this.query.trim();let a="";if(e){const t=new RegExp(e,"i");a=V.map((e=>t+".test("+e+")")).join(" || ")}return this.appid&&(a=e?`appid=='${this.appid}' && (${a})`:`appid=='${this.appid}'`),a},search(){this.errorMessage="";const e=this.getWhere();this.where=e,this.$nextTick((()=>{this.loadData()}))},loadData(e=!0){this.$refs.udb.loadData({clear:e})},onPageChanged(e){this.selectedIndexs.length=0,this.$refs.table.clearSelection(),this.$refs.udb.loadData({current:e.current})},navigateTo(e,a){t({url:e,events:{refreshData:()=>{this.loadData(a)}}})},sortChange(e,a){this.orderByFieldName=a,e.order?this.orderby=a+" "+L[e.order]:this.orderby="",this.$refs.table.clearSelection(),this.$nextTick((()=>{this.$refs.udb.loadData()}))},filterChange(e,a){this._filter[a]={type:e.filterType,value:e.filter};let t=function(e,a){let t={};for(let l in e){let{type:i,value:s}=e[l];switch(i){case"search":"string"==typeof s&&s.length&&(t[l]=new RegExp(s));break;case"select":if(s.length){let e=[];for(let t of s)e.push(a.eq(t));t[l]=a.or(e)}break;case"range":if(s.length){let e=s[0],i=s[1];t[l]=a.and([a.gte(e),a.lte(i)])}break;case"date":if(s.length){let[e,i]=s,n=new Date(e),d=new Date(i);t[l]=a.and([a.gte(n),a.lte(d)])}break;case"timestamp":if(s.length){let[e,i]=s;t[l]=a.and([a.gte(e),a.lte(i)])}}}return t}(this._filter,D.command);Object.keys(t).length?this.where=t:this.where="",this.$nextTick((()=>{this.$refs.udb.loadData()}))},editRule(e){this.$refs.editRulePopup.open(),e.page_rules&&e.page_rules.length||(e.page_rules=[[]]),this.pageInfo={_id:e._id,page_rules:JSON.parse(JSON.stringify(e.page_rules))}},addRulesItem(){this.pageInfo.page_rules.unshift([])},deleteRulesItem(e){this.pageInfo.page_rules.splice(e,1)},addParamItem(e){this.editRulePopup.isAddParam=!0,this.editRulePopup.addParamInfo.value="",this.editRulePopup.addParamInfo.index1=e},confirmAddParamItem(e){this.editRulePopup.addParamInfo.value&&this.pageInfo.page_rules[e].push(this.editRulePopup.addParamInfo.value),this.editRulePopup.isAddParam=!1},deleteParamItem(e,a){this.pageInfo.page_rules[e].splice(a,1)},closeEditRulePopup(){this.$refs.editRulePopup.close()},saveRule(){this.editRulePopup.loading=!0;let e=JSON.parse(JSON.stringify(this.pageInfo.page_rules));e=e.filter((e=>e.length>0)),this.$refs.udb.update(this.pageInfo._id,{page_rules:e},{showToast:!1,needLoading:!1,success:()=>{this.$refs.udb.dataList.forEach((a=>{a._id===this.pageInfo._id&&(a.page_rules=e)})),this.closeEditRulePopup()},complete:()=>{this.editRulePopup.loading=!1}})}}},[["render",function(e,a,t,v,D,V){const L=l(i("uni-stat-breadcrumb"),I),j=P,E=R,S=o,A=l(i("uni-data-select"),k),T=l(i("uni-th"),u),q=l(i("uni-tr"),r),F=l(i("uni-td"),p),N=l(i("uni-table"),c),U=l(i("uni-pagination"),$),O=l(i("unicloud-db"),w),B=l(i("uni-notice-bar"),z),J=C,M=l(i("uni-icons"),f),W=l(i("uni-popup"),g);return s(),n(S,null,{default:d((()=>[h(S,{class:"uni-header"},{default:d((()=>[h(L,{class:"uni-stat-breadcrumb-on-phone"}),h(S,{class:"uni-group"},{default:d((()=>[h(j,{class:"uni-search",type:"text",modelValue:D.query,"onUpdate:modelValue":a[0]||(a[0]=e=>D.query=e),onConfirm:V.search,placeholder:"请输入搜索内容"},null,8,["modelValue","onConfirm"]),h(E,{class:"uni-button",type:"default",size:"mini",onClick:V.search},{default:d((()=>[m("搜索")])),_:1},8,["onClick"])])),_:1})])),_:1}),h(S,{class:"uni-container"},{default:d((()=>[h(S,{class:"uni-stat--x flex p-1015"},{default:d((()=>[h(S,{class:"uni-stat--app-select",style:{width:"500px"}},{default:d((()=>[h(A,{ref:"appListRef",collection:"opendb-app-list",field:"appid as value, name as text",orderby:"text asc",label:"应用选择",modelValue:D.appid,"onUpdate:modelValue":a[1]||(a[1]=e=>D.appid=e),onChange:V.search},null,8,["modelValue","onChange"])])),_:1})])),_:1}),h(O,{ref:"udb",collection:D.collectionList,field:"title,path,page_rules,appid",where:D.where,"page-data":"replace",orderby:D.orderby,getcount:!0,"page-size":D.options.pageSize,"page-current":D.options.pageCurrent,options:D.options,loadtime:"manual",onLoad:V.onqueryload},{default:d((({data:e,pagination:t,loading:l,error:i,options:o})=>[h(N,{ref:"table",loading:l,emptyText:D.errorMessage||i.message||"没有更多数据",border:"",stripe:""},{default:d((()=>[h(q,null,{default:d((()=>[h(T,{align:"center"},{default:d((()=>[m("序号")])),_:1}),h(T,{align:"center","filter-type":"search",onFilterChange:a[2]||(a[2]=e=>V.filterChange(e,"title"))},{default:d((()=>[m("页面标题")])),_:1}),h(T,{align:"left","filter-type":"search",onFilterChange:a[3]||(a[3]=e=>V.filterChange(e,"path"))},{default:d((()=>[m("页面URL")])),_:1}),h(T,{align:"center","filter-type":"search",onFilterChange:a[4]||(a[4]=e=>V.filterChange(e,"appid"))},{default:d((()=>[m("appid")])),_:1}),h(T,{align:"center"},{default:d((()=>[m("操作")])),_:1})])),_:1}),(s(!0),_(b,null,y(e,((e,a)=>(s(),n(q,{key:a},{default:d((()=>[h(F,{align:"center"},{default:d((()=>[m(x((t.current-1)*t.size+(a+1)),1)])),_:2},1024),h(F,{align:"center"},{default:d((()=>[m(x(e.title),1)])),_:2},1024),h(F,{align:"left"},{default:d((()=>[m(x(e.path),1)])),_:2},1024),h(F,{align:"center"},{default:d((()=>[m(x(e.appid),1)])),_:2},1024),h(F,{align:"center"},{default:d((()=>[h(S,{class:"uni-group"},{default:d((()=>[h(E,{onClick:a=>V.editRule(e),class:"uni-button",size:"mini",type:"primary"},{default:d((()=>[m("编辑规则")])),_:2},1032,["onClick"])])),_:2},1024)])),_:2},1024)])),_:2},1024)))),128))])),_:2},1032,["loading","emptyText"]),h(S,{class:"uni-pagination-box"},{default:d((()=>[h(U,{"show-icon":"","page-size":t.size,modelValue:t.current,"onUpdate:modelValue":e=>t.current=e,total:t.count,onChange:V.onPageChanged},null,8,["page-size","modelValue","onUpdate:modelValue","total","onChange"])])),_:2},1024)])),_:1},8,["collection","where","orderby","page-size","page-current","options","onLoad"])])),_:1}),h(W,{ref:"editRulePopup",type:"center"},{default:d((()=>[h(S,{class:"edit-rule-popup"},{default:d((()=>[h(S,{class:"uni-title"},{default:d((()=>[m("页面规则")])),_:1}),h(S,{class:"edit-rule-popup-tips"},{default:d((()=>[h(B,{"font-size":12,text:D.editRulePopup.tips},null,8,["text"])])),_:1}),h(S,{class:"edit-rule-popup-list"},{default:d((()=>[(s(!0),_(b,null,y(D.pageInfo.page_rules,((e,t)=>(s(),n(S,{class:"edit-rule-popup-item",key:t},{default:d((()=>[h(S,{class:"name"},{default:d((()=>[m(" 规则 "+x(D.pageInfo.page_rules.length-t),1)])),_:2},1024),h(S,{class:"tags"},{default:d((()=>[(s(!0),_(b,null,y(e,((e,a)=>(s(),n(S,{class:"tags-item tags-item-text",key:a},{default:d((()=>[h(J,{class:"text"},{default:d((()=>[m(x(e),1)])),_:2},1024),m(),h(M,{class:"pointer",type:"closeempty",size:"12",color:"#42b983",onClick:e=>V.deleteParamItem(t,a)},null,8,["onClick"])])),_:2},1024)))),128)),h(S,{class:"tags-item tags-item-add"},{default:d((()=>[D.editRulePopup.addParamInfo.index1===t&&D.editRulePopup.isAddParam?(s(),n(j,{key:0,class:"tags-item-add-input",type:"text",modelValue:D.editRulePopup.addParamInfo.value,"onUpdate:modelValue":a[5]||(a[5]=e=>D.editRulePopup.addParamInfo.value=e),modelModifiers:{trim:!0},focus:D.editRulePopup.addParamInfo.index1===t&&D.editRulePopup.isAddParam,onBlur:e=>V.confirmAddParamItem(t),placeholder:"输入参数名"},null,8,["modelValue","focus","onBlur"])):(s(),n(E,{key:1,size:"mini",class:"tags-item-add-btn",onClick:e=>V.addParamItem(t)},{default:d((()=>[m(" + 添加参数 ")])),_:2},1032,["onClick"]))])),_:2},1024)])),_:2},1024),h(S,{class:"btn"},{default:d((()=>[0===t&&D.pageInfo.page_rules.length<5?(s(),n(M,{key:0,type:"plus",size:"28",class:"pointer",color:"#606266",onClick:V.addRulesItem},null,8,["onClick"])):(s(),n(M,{key:1,type:"minus",size:"28",class:"pointer",color:"#606266",onClick:e=>V.deleteRulesItem(t)},null,8,["onClick"]))])),_:2},1024)])),_:2},1024)))),128))])),_:1}),h(S,{class:"edit-rule-popup-btn"},{default:d((()=>[h(E,{class:"uni-button btn",type:"primary",size:"default",loading:D.editRulePopup.loading,disabled:D.editRulePopup.loading,onClick:V.saveRule},{default:d((()=>[m("保存")])),_:1},8,["loading","disabled","onClick"]),h(E,{class:"uni-button btn",type:"default",size:"default",onClick:V.closeEditRulePopup},{default:d((()=>[m("取消")])),_:1},8,["onClick"])])),_:1})])),_:1})])),_:1},512)])),_:1})}],["__scopeId","data-v-f9da5cce"]]);export{j as default};
|