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