1 |
- import{S as Ce,g as L,e as xe,a as he,b as ke,p as Re,c as Ue,d as Pe}from"./index.5ca650cf.js";import{Y as Se,d as Ne,a2 as I}from"./index.3716cebd.js";import{a as u}from"./elementPlus.5243d764.js";import{f as we,r as _,Q as F,e as $e,d as Ee,a7 as c,h as v,i as S,M as a,G as o,j as V,B as Fe,aa as Te,u as T,K as N,F as w,E as q,$ as B,L as $}from"./vue.9083513e.js";import{_ as qe}from"./_plugin-vue_export-helper.c27b6911.js";import"./echarts.594b4072.js";const ze={style:{position:"relative"}},De={class:"mx-3.5"},Le={class:"dialog-footer"},Ie=we({__name:"index",setup(Be){const z=_(null),O=_("default"),h=_(!1),C=_(),r=F({number:"",name:"",country:"",brand:"",operation:[],currency:"",currencyCodePlatform:""}),j=e=>{e&&e.resetFields()},A=F({number:[{required:!0,message:"请输入平台编号",trigger:"blur"}],name:[{required:!0,message:"请输入平台名称",trigger:"blur"}],country:[{required:!0,message:"请输入国家",trigger:"blur"}],brand:[{required:!0,message:"请输入品牌",trigger:"blur"}],operation:[{required:!0,message:"请选择运营",trigger:"change"}],currency:[{required:!0,message:"请输入回款/余额币种",trigger:"blur"}],currencyCodePlatform:[{required:!0,message:"请输入平台货币",trigger:"blur"}],line:[{required:!0,message:"请输入线路",trigger:"blur"}],ipaddress:[{required:!0,message:"请输入IP地址",trigger:"blur"}],company:[{required:!0,message:"请输入注册公司",trigger:"blur"}],platform:[{required:!0,message:"请输入平台",trigger:"blur"}]}),b=_([]),p=_(),E=new Map;let k=[];const s=F({border:"inner",keepSource:!0,height:900,loading:!1,round:!0,toolbarConfig:{zoom:{iconIn:"vxe-icon-fullscreen",iconOut:"vxe-icon-minimize"},slots:{buttons:"toolbar_buttons",tools:"toolbar_tools"}},rowConfig:{isHover:!0},columnConfig:{resizable:!0},pagerConfig:{enabled:!0,total:20,currentPage:1,pageSize:20,pageSizes:[10,20,30]},editConfig:{trigger:"manual",mode:"row",showStatus:!0,autoClear:!1},checkboxConfig:{reserve:!0,highlight:!0,range:!0},columns:[{type:"checkbox",width:50},{field:"platformNumber",title:"平台编号",editRender:{autofocus:".vxe-input--inner"},slots:{edit:"number_edit"}},{field:"platformName",title:"平台名称",editRender:{autofocus:".vxe-input--inner"},slots:{edit:"name_edit"},align:"center",width:150},{field:"country",title:"国家",editRender:{autofocus:".vxe-input--inner"},slots:{edit:"country_edit"},width:89,align:"center"},{field:"brandName",title:"品牌",editRender:{},slots:{edit:"brand_edit"},align:"center"},{field:"user_name",title:"运营",editRender:{},slots:{edit:"operation_edit"},align:"center"},{field:"currencyCode",title:"回款币种",editRender:{},slots:{edit:"currency_edit"},align:"center"},{field:"currencyCodePlatform",title:"回款/余额币种",editRender:{},slots:{edit:"currencyCodePlatform_edit"},width:130,align:"center"},{field:"line",title:"线路",editRender:{},slots:{edit:"line_edit"},align:"center"},{field:"ipaddress",title:"IP地址",editRender:{},slots:{edit:"ipaddress_edit"},width:138},{field:"company",title:"注册公司",editRender:{},slots:{edit:"company_edit"},align:"center"},{field:"platform",title:"平台",editRender:{},slots:{edit:"platform_edit"},align:"center"},{field:"status",title:"状态",editRender:{},slots:{edit:"status_edit"},align:"center"},{title:"操作",width:120,slots:{default:"operate"}}],data:[]}),R=_([]),M={pageChange({currentPage:e,pageSize:l}){s.pagerConfig&&(s.pagerConfig.currentPage=e,s.pagerConfig.pageSize=l,x())}};async function D(e=1,l=100){try{const d=await L({page:e,limit:l});k=k.concat(d.data),d.data.length===l&&await D(e+1,l)}catch(d){console.error("Error fetching all tasks:",d)}}async function x(e={}){try{s.loading=!0;const l=await L({page:s.pagerConfig.currentPage,limit:s.pagerConfig.pageSize,...e});s.data=l.data,s.pagerConfig.total=l.total,k=[],await D()}catch(l){console.error("Error fetching task data:",l)}finally{s.loading=!1}}function G(e){z.value&&(s.pagerConfig&&(s.pagerConfig.currentPage=1),x(e.value))}const H=e=>{const l=p.value;return l?l.isEditByRow(e):!1},K=e=>{const l=p.value;l&&(E.set(e.id,{...e}),(!e.user||e.user.length===0)&&(e.user=R.value.filter(d=>e.user_name.includes(d.label)).map(d=>d.value)),l.setEditRow(e))},Q=e=>{const l=p.value;if(l){const d=E.get(e.id);d&&(Object.assign(e,d),E.delete(e.id)),l.clearEdit()}};async function W(){const e=p.value;if(e){const i={keys:e.getCheckboxRecords().map(f=>f.id)};try{(await Re(i)).code===2e3&&(u({message:"删除成功",type:"success"}),await x())}catch{u({message:"删除失败",type:"error"})}}}const X=$e(()=>{const e=p.value;return!e||e.getCheckboxRecords().length===0}),Y=async()=>{const e=p.value;e&&(e.getCheckboxRecords().length>0?await I.modal.confirm("您确定要删除选中的数据?")==="confirm"&&(await W(),await e.removeCheckboxRow()):await I.modal.message({content:"请选择要删除的数据",status:"error"}))},J=[{field:"platformNumber",title:"平台编号"},{field:"platformName",title:"平台名称"},{field:"country",title:"国家"},{field:"brandName",title:"品牌"},{field:"user",title:"运营"},{field:"currencyCode",title:"回款币种"},{field:"currencyCodePlatform",title:"回款/余额币种"},{field:"line",title:"线路"},{field:"ipaddress",title:"IP地址"},{field:"company",title:"注册公司"},{field:"platform",title:"平台"},{field:"status",title:"状态"}],Z=e=>{for(const{field:l,title:d}of J)if(!e[l]||Array.isArray(e[l])&&e[l].length===0){u.error(`${d}不能为空`);return}if(!b.value.includes(e.currencyCode)){u.error("回款币种格式不正确,请重新选择");return}if(!b.value.includes(e.currencyCodePlatform)){u.error("回款/余额币种格式不正确,请重新选择");return}return!0};async function ee(e){if(p.value){const d={id:e.id,platformNumber:e.platformNumber,platformName:e.platformName,country:e.country,brandName:e.brandName,user:e.user,currencyCode:e.currencyCode,currencyCodePlatform:e.currencyCodePlatform,line:e.line,ipaddress:e.ipaddress,company:e.company,platform:e.platform,status:e.status};try{const i=await Ue(d);i.code===2e3?u.success("更新成功"):i.code==400?u.warning(`${i.data.description}`):u.error("更新失败")}catch(i){console.log("error:",i)}}}const te=async e=>{const l=p.value;if(l){if(!Z(e))return;await l.clearEdit(),await ee(e),await x(),s.loading=!0,setTimeout(()=>{s.loading=!1},300)}};async function le(){const e={country:r.country,platformNumber:r.number,platformName:r.name,brandName:r.brand,currencyCode:r.currency,currencyCodePlatform:r.currencyCodePlatform,line:r.line,ipaddress:r.ipaddress,company:r.company,platform:r.platform,user:r.operation};try{(await Pe(e)).code===2e3&&(h.value=!1,s.data.push(e),await x(),u({message:"创建成功",type:"success"}))}catch{u({message:"创建失败",type:"error"})}}const ae=async e=>{e&&await e.validate(async(l,d)=>{if(l){if(k.some(f=>String(f.platformNumber)===String(r.number))){await u({message:"平台编号已存在,请重新输入",type:"warning"});return}if(!b.value.includes(r.currency)){await u({message:"回款币种无效,请重新选择",type:"warning"});return}if(!b.value.includes(r.currencyCodePlatform)){await u({message:"回款/余额币种无效,请重新选择",type:"warning"});return}await le(),C.value.resetFields()}})};async function oe(){s.loading=!0;const e=await xe(),l=window.URL.createObjectURL(new Blob([e.data])),d=document.createElement("a");d.href=l,d.setAttribute("download","店铺数据.xlsx"),document.body.appendChild(d),d.click(),s.loading=!1,u.success("导出数据成功")}function re(e){C.value&&C.value.resetFields(),e()}async function ne(){try{const e=await he();R.value=e.data.map(l=>({value:l.id,label:l.name}))}catch(e){console.error("Failed to fetch operation select:",e)}}async function de(){try{const e=await ke();b.value=e.data}catch{u.error("请求失败")}}const U=(e,l)=>{const d=e?b.value.filter(i=>i.toLowerCase().includes(e.toLowerCase())):b.value;l(d)},se=e=>{r.currency=e},ie=e=>{r.currencyCodePlatform=e};function ue(e,l){l.currencyCode=e}function ce(e,l){l.currencyCodePlatform=e}const me=()=>({fontSize:"13px",fontWeight:"500"}),pe=()=>({fontSize:"14px"});return Ee(()=>{x(),ne(),de()}),(e,l)=>{const d=c("el-card"),i=c("el-button"),f=c("vxe-button"),g=c("vxe-input"),fe=c("vxe-option"),ge=c("vxe-select"),P=c("el-autocomplete"),ye=c("vxe-grid"),y=c("el-input"),m=c("el-form-item"),be=c("el-option"),_e=c("el-select"),ve=c("el-form"),Ve=c("el-dialog");return v(),S(w,null,[a(d,{class:"custom-card-style flex gap-1.5 justify-between mx-8"},{default:o(()=>[a(Ce,{ref_key:"selectorRef",ref:z,"onUpdate:filteredData":G},null,512)]),_:1}),a(d,{class:"mx-8 my-3"},{default:o(()=>[V("div",ze,[a(ye,Fe({ref_key:"xGrid",ref:p,"cell-style":me,"header-cell-style":pe,stripe:""},s,Te(M)),{toolbar_buttons:o(()=>[a(i,{icon:T(Se),plain:"",type:"primary",onClick:l[0]||(l[0]=t=>h.value=!0)},{default:o(()=>[N(" 添加任务")]),_:1},8,["icon"]),a(i,{disabled:T(X),icon:T(Ne),plain:"",type:"danger",onClick:Y},{default:o(()=>[N("删除 ")]),_:1},8,["disabled","icon"])]),toolbar_tools:o(()=>[V("div",De,[a(f,{circle:"",icon:"vxe-icon-download",onClick:oe})])]),operate:o(({row:t})=>[H(t)?(v(),S(w,{key:0},[a(f,{content:"取消",type:"text",onClick:n=>Q(t)},null,8,["onClick"]),a(f,{content:"保存",status:"success",type:"text",onClick:n=>te(t)},null,8,["onClick"])],64)):(v(),q(i,{key:1,icon:"Edit",type:"text",onClick:n=>K(t)},null,8,["onClick"]))]),number_edit:o(({row:t})=>[a(g,{modelValue:t.platformNumber,"onUpdate:modelValue":n=>t.platformNumber=n},null,8,["modelValue","onUpdate:modelValue"])]),name_edit:o(({row:t})=>[a(g,{modelValue:t.platformName,"onUpdate:modelValue":n=>t.platformName=n},null,8,["modelValue","onUpdate:modelValue"])]),country_edit:o(({row:t})=>[a(g,{modelValue:t.country,"onUpdate:modelValue":n=>t.country=n},null,8,["modelValue","onUpdate:modelValue"])]),brand_edit:o(({row:t})=>[a(g,{modelValue:t.brandName,"onUpdate:modelValue":n=>t.brandName=n},null,8,["modelValue","onUpdate:modelValue"])]),line_edit:o(({row:t})=>[a(g,{modelValue:t.line,"onUpdate:modelValue":n=>t.line=n},null,8,["modelValue","onUpdate:modelValue"])]),ipaddress_edit:o(({row:t})=>[a(g,{modelValue:t.ipaddress,"onUpdate:modelValue":n=>t.ipaddress=n},null,8,["modelValue","onUpdate:modelValue"])]),company_edit:o(({row:t})=>[a(g,{modelValue:t.company,"onUpdate:modelValue":n=>t.company=n},null,8,["modelValue","onUpdate:modelValue"])]),platform_edit:o(({row:t})=>[a(g,{modelValue:t.platform,"onUpdate:modelValue":n=>t.platform=n},null,8,["modelValue","onUpdate:modelValue"])]),status_edit:o(({row:t})=>[a(g,{modelValue:t.status,"onUpdate:modelValue":n=>t.status=n},null,8,["modelValue","onUpdate:modelValue"])]),operation_edit:o(({row:t})=>[a(ge,{modelValue:t.user,"onUpdate:modelValue":n=>t.user=n,multiple:""},{default:o(()=>[(v(!0),S(w,null,B(R.value,n=>(v(),q(fe,{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),currency_edit:o(({row:t})=>[a(P,{modelValue:t.currencyCode,"onUpdate:modelValue":n=>t.currencyCode=n,debounce:100,"fetch-suggestions":U,"trigger-on-focus":!1,clearable:"",onSelect:n=>ue(n,t)},{default:o(({item:n})=>[V("div",null,$(n),1)]),_:2},1032,["modelValue","onUpdate:modelValue","onSelect"])]),currencyCodePlatform_edit:o(({row:t})=>[a(P,{modelValue:t.currencyCodePlatform,"onUpdate:modelValue":n=>t.currencyCodePlatform=n,debounce:100,"fetch-suggestions":U,"trigger-on-focus":!1,clearable:"",onSelect:n=>ce(n,t)},{default:o(({item:n})=>[V("div",null,$(n),1)]),_:2},1032,["modelValue","onUpdate:modelValue","onSelect"])]),_:1},16)])]),_:1}),a(Ve,{modelValue:h.value,"onUpdate:modelValue":l[14]||(l[14]=t=>h.value=t),"before-close":re,style:{"border-radius":"10px"},title:"新建任务",width:"500"},{footer:o(()=>[V("div",Le,[a(i,{onClick:l[12]||(l[12]=t=>{h.value=!1,j(C.value)})},{default:o(()=>[N("取消")]),_:1}),a(i,{type:"primary",onClick:l[13]||(l[13]=t=>ae(C.value))},{default:o(()=>[N(" 确认")]),_:1})])]),default:o(()=>[a(ve,{ref_key:"taskRuleFormRef",ref:C,model:r,rules:A,size:O.value,class:"demo-taskRuleForm","label-width":"auto","status-icon":"",style:{"max-width":"600px"}},{default:o(()=>[a(m,{label:"平台编号",prop:"number"},{default:o(()=>[a(y,{modelValue:r.number,"onUpdate:modelValue":l[1]||(l[1]=t=>r.number=t),placeholder:"请输入平台编号"},null,8,["modelValue"])]),_:1}),a(m,{label:"平台名称",prop:"name"},{default:o(()=>[a(y,{modelValue:r.name,"onUpdate:modelValue":l[2]||(l[2]=t=>r.name=t),placeholder:"请输入平台名称"},null,8,["modelValue"])]),_:1}),a(m,{label:"国家",prop:"country"},{default:o(()=>[a(y,{modelValue:r.country,"onUpdate:modelValue":l[3]||(l[3]=t=>r.country=t),placeholder:"请输入国家"},null,8,["modelValue"])]),_:1}),a(m,{label:"品牌",prop:"brand"},{default:o(()=>[a(y,{modelValue:r.brand,"onUpdate:modelValue":l[4]||(l[4]=t=>r.brand=t),placeholder:"请输入品牌"},null,8,["modelValue"])]),_:1}),a(m,{label:"录入人员",prop:"operation"},{default:o(()=>[a(_e,{modelValue:r.operation,"onUpdate:modelValue":l[5]||(l[5]=t=>r.operation=t),"collapse-tags":"","collapse-tags-tooltip":"",multiple:"",placeholder:"请选择录入人员"},{default:o(()=>[(v(!0),S(w,null,B(R.value,t=>(v(),q(be,{key:t.value,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(m,{label:"回款币种",prop:"currency"},{default:o(()=>[a(P,{modelValue:r.currency,"onUpdate:modelValue":l[6]||(l[6]=t=>r.currency=t),debounce:100,"fetch-suggestions":U,"trigger-on-focus":!1,clearable:"",placeholder:"请输入回款币种",onSelect:se},{default:o(({item:t})=>[V("div",null,$(t),1)]),_:1},8,["modelValue"])]),_:1}),a(m,{label:"回款/余额币种",prop:"currencyCodePlatform"},{default:o(()=>[a(P,{modelValue:r.currencyCodePlatform,"onUpdate:modelValue":l[7]||(l[7]=t=>r.currencyCodePlatform=t),debounce:100,"fetch-suggestions":U,"trigger-on-focus":!1,clearable:"",placeholder:"请输入回款/余额币种",onSelect:ie},{default:o(({item:t})=>[V("div",null,$(t),1)]),_:1},8,["modelValue"])]),_:1}),a(m,{label:"线路",prop:"line"},{default:o(()=>[a(y,{modelValue:r.line,"onUpdate:modelValue":l[8]||(l[8]=t=>r.line=t),placeholder:"请输入线路"},null,8,["modelValue"])]),_:1}),a(m,{label:"IP地址",prop:"ipaddress"},{default:o(()=>[a(y,{modelValue:r.ipaddress,"onUpdate:modelValue":l[9]||(l[9]=t=>r.ipaddress=t),placeholder:"请输入IP地址"},null,8,["modelValue"])]),_:1}),a(m,{label:"注册公司",prop:"company"},{default:o(()=>[a(y,{modelValue:r.company,"onUpdate:modelValue":l[10]||(l[10]=t=>r.company=t),placeholder:"请输入注册公司"},null,8,["modelValue"])]),_:1}),a(m,{label:"平台",prop:"platform"},{default:o(()=>[a(y,{modelValue:r.platform,"onUpdate:modelValue":l[11]||(l[11]=t=>r.platform=t),placeholder:"请输入平台"},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules","size"])]),_:1},8,["modelValue"])],64)}}});const Ke=qe(Ie,[["__scopeId","data-v-b0d33a83"]]);export{Ke as default};
|