1 |
- import{S as re,g as ne,a as ue,p as de,b as se,c as ie}from"./index.d0f14c27.js";import{V as x}from"./index.ad090ffd.js";import{m as ce,a as me,h as _}from"./elementPlus.59866ea5.js";import{d as pe,r as v,Q as P,j as fe,a8 as i,o as p,c as R,M as a,G as r,a as E,B as ge,ab as ye,u as F,K as N,F as h,E as w,$ as T,n as be}from"./vue.95e072e2.js";import{_ as _e}from"./_plugin-vue_export-helper.c27b6911.js";import"./echarts.2703a7ac.js";const ve={style:{position:"relative"}},Ve={class:"dialog-footer"},Ce=pe({__name:"index",setup(ke){const S=v("default"),V=v(!1),C=v(),l=P({number:"",name:"",country:"",brand:"",operation:[],currency:"",currencyCodePlatform:""}),z=t=>{t&&t.resetFields()},q=P({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"}]}),c=v(),U=new Map,d=P({border:"inner",keepSource:!0,showOverflow:!0,height:850,loading:!1,round:!0,toolbarConfig:{zoom:{iconIn:"vxe-icon-fullscreen",iconOut:"vxe-icon-minimize"},slots:{buttons:"toolbar_buttons"}},rowConfig:{isHover:!0},columnConfig:{resizable:!0},pagerConfig:{enabled:!0,total:20,currentPage:1,pageSize:20,pageSizes:[10,20,30]},editConfig:{trigger:"click",mode:"row",showStatus:!0},checkboxConfig:{reserve:!0,highlight:!0,range:!0},columns:[{type:"checkbox",width:50},{field:"platformNumber",title:"平台编号",editRender:{autofocus:".vxe-input--inner"},slots:{edit:"number_edit"},sortable:!0},{field:"platformName",title:"平台名称",editRender:{autofocus:".vxe-input--inner"},slots:{edit:"name_edit"}},{field:"country",title:"国家",editRender:{autofocus:".vxe-input--inner"},slots:{edit:"country_edit"}},{field:"brandName",title:"品牌",editRender:{},slots:{edit:"brand_edit"}},{field:"user_name",title:"运营",editRender:{},slots:{edit:"operation_edit"}},{field:"currencyCode",title:"回款币种",editRender:{},slots:{edit:"currency_edit"}},{field:"currencyCodePlatform",title:"回款/余额币种",editRender:{},slots:{edit:"currencyCodePlatform_edit"}},{title:"操作",width:120,slots:{default:"operate"}}],data:[]}),k=v([]),B={pageChange({currentPage:t,pageSize:e}){d.pagerConfig&&(d.pagerConfig.currentPage=t,d.pagerConfig.pageSize=e,f())}};async function f(t={}){try{d.loading=!0;const e=await ne({page:d.pagerConfig.currentPage,limit:d.pagerConfig.pageSize,...t});d.data=e.data,d.pagerConfig.total=e.total}catch(e){console.error("Error fetching task data:",e)}finally{d.loading=!1}}const $=v(null);function D(t){$.value&&f(t.value)}const O=t=>{const e=c.value;return e?e.isEditByRow(t):!1},M=t=>{const e=c.value;e&&(U.set(t.id,{...t}),(!t.user||t.user.length===0)&&(t.user=k.value.filter(u=>t.user_name.includes(u.label)).map(u=>u.value)),e.setEditRow(t))},j=t=>{const e=c.value;if(e){const u=U.get(t.id);u&&(Object.assign(t,u),U.delete(t.id)),e.clearEdit()}};async function I(){const t=c.value;if(t){const s={keys:t.getCheckboxRecords().map(g=>g.id)};try{(await de(s)).code===2e3&&(_({message:"删除成功",type:"success"}),await f())}catch{_({message:"删除失败",type:"error"})}}}const A=async()=>{const t=c.value;t&&(t.getCheckboxRecords().length>0?await x.modal.confirm("您确定要删除选中的数据?")==="confirm"&&(await I(),await t.removeCheckboxRow()):await x.modal.message({content:"请选择要删除的数据",status:"error"}))},G=[{field:"platformNumber",title:"平台编号"},{field:"platformName",title:"平台名称"},{field:"country",title:"国家"},{field:"brandName",title:"品牌"},{field:"user",title:"运营"},{field:"currencyCode",title:"回款币种"},{field:"currencyCodePlatform",title:"回款/余额币种"}],L=t=>{for(const{field:e,title:u}of G)if(!t[e]||Array.isArray(t[e])&&t[e].length===0){_.error(`${u}不能为空`);return}return!0};async function H(t){if(c.value){const u={id:t.id,platformNumber:t.platformNumber,platformName:t.platformName,country:t.country,brandName:t.brandName,user:t.user,currencyCode:t.currencyCode,currencyCodePlatform:t.currencyCodePlatform};try{const s=await se(u);console.log(s),s.code===2e3?_.success("更新成功"):s.code==400?_.warning(`${s.data.description}`):_.error("更新失败")}catch(s){console.log("error:",s)}}}const K=async t=>{const e=c.value;if(e){if(!L(t))return;await e.clearEdit(),await H(t),await f(),d.loading=!0,setTimeout(()=>{d.loading=!1},300)}};async function Q(){const t={country:l.country,platformNumber:l.number,platformName:l.name,brandName:l.brand,currencyCode:l.currency,currencyCodePlatform:l.currencyCodePlatform,user:l.operation};try{const e=await ie(t)}catch(e){console.error("error:",e),await x.modal.message({content:"创建失败,请重试",status:"error"})}}const X=async()=>{const t={platformNumber:l.number,platformName:l.name,country:l.country,brandName:l.brand,user_name:l.operation,currencyCode:l.currency,currencyCodePlatform:l.currencyCodePlatform,child_user_number:""};d.data.push(t);try{await Q(),V.value=!1,await f(),d.loading=!0,setTimeout(()=>{d.loading=!1},300)}catch(e){console.error("Failed to save task:",e)}},J=async t=>{t&&await t.validate(async(e,u)=>{e&&(await X(),await be(),C.value.resetFields(),await x.modal.message({content:"创建成功",status:"success"}))})};async function W(){try{const t=await ue();k.value=t.data.map(e=>({value:e.id,label:e.name}))}catch(t){console.error("Failed to fetch operation select:",t)}}return fe(()=>{f(),W()}),(t,e)=>{const u=i("el-card"),s=i("el-button"),g=i("vxe-button"),y=i("vxe-input"),Y=i("vxe-option"),Z=i("vxe-select"),ee=i("vxe-grid"),b=i("el-input"),m=i("el-form-item"),te=i("el-option"),oe=i("el-select"),ae=i("el-form"),le=i("el-dialog");return p(),R(h,null,[a(u,{class:"custom-card-style flex gap-1.5 justify-between mx-8"},{default:r(()=>[a(re,{ref_key:"selectorRef",ref:$,"onUpdate:filteredData":D},null,512)]),_:1}),a(u,{class:"mx-8 my-3"},{default:r(()=>[E("div",ve,[a(ee,ge({ref_key:"xGrid",ref:c,stripe:""},d,ye(B)),{toolbar_buttons:r(()=>[a(s,{icon:F(ce),plain:"",type:"primary",onClick:e[0]||(e[0]=o=>V.value=!0)},{default:r(()=>[N(" 添加任务")]),_:1},8,["icon"]),a(s,{icon:F(me),type:"danger",plain:"",onClick:A},{default:r(()=>[N("删除")]),_:1},8,["icon"])]),operate:r(({row:o})=>[O(o)?(p(),R(h,{key:0},[a(g,{content:"取消",type:"text",onClick:n=>j(o)},null,8,["onClick"]),a(g,{content:"保存",status:"success",type:"text",onClick:n=>K(o)},null,8,["onClick"])],64)):(p(),w(s,{key:1,icon:"Edit",type:"text",onClick:n=>M(o)},null,8,["onClick"]))]),number_edit:r(({row:o})=>[a(y,{modelValue:o.platformNumber,"onUpdate:modelValue":n=>o.platformNumber=n},null,8,["modelValue","onUpdate:modelValue"])]),name_edit:r(({row:o})=>[a(y,{modelValue:o.platformName,"onUpdate:modelValue":n=>o.platformName=n},null,8,["modelValue","onUpdate:modelValue"])]),country_edit:r(({row:o})=>[a(y,{modelValue:o.country,"onUpdate:modelValue":n=>o.country=n},null,8,["modelValue","onUpdate:modelValue"])]),brand_edit:r(({row:o})=>[a(y,{modelValue:o.brandName,"onUpdate:modelValue":n=>o.brandName=n},null,8,["modelValue","onUpdate:modelValue"])]),operation_edit:r(({row:o})=>[a(Z,{modelValue:o.user,"onUpdate:modelValue":n=>o.user=n,multiple:""},{default:r(()=>[(p(!0),R(h,null,T(k.value,n=>(p(),w(Y,{key:n.value,label:n.label,value:n.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),currency_edit:r(({row:o})=>[a(y,{modelValue:o.currencyCode,"onUpdate:modelValue":n=>o.currencyCode=n},null,8,["modelValue","onUpdate:modelValue"])]),currencyCodePlatform_edit:r(({row:o})=>[a(y,{modelValue:o.currencyCodePlatform,"onUpdate:modelValue":n=>o.currencyCodePlatform=n},null,8,["modelValue","onUpdate:modelValue"])]),quantity_edit:r(({row:o})=>[]),_:1},16)])]),_:1}),a(le,{modelValue:V.value,"onUpdate:modelValue":e[10]||(e[10]=o=>V.value=o),title:"新建任务",width:"500",style:{"border-radius":"10px"}},{footer:r(()=>[E("div",Ve,[a(s,{onClick:e[8]||(e[8]=o=>{V.value=!1,z(C.value)})},{default:r(()=>[N("取消")]),_:1}),a(s,{type:"primary",onClick:e[9]||(e[9]=o=>J(C.value))},{default:r(()=>[N(" 确认")]),_:1})])]),default:r(()=>[a(ae,{ref_key:"taskRuleFormRef",ref:C,model:l,rules:q,size:S.value,class:"demo-taskRuleForm","label-width":"auto","status-icon":"",style:{"max-width":"600px"}},{default:r(()=>[a(m,{label:"平台编号",prop:"number"},{default:r(()=>[a(b,{modelValue:l.number,"onUpdate:modelValue":e[1]||(e[1]=o=>l.number=o),placeholder:"请输入平台编号"},null,8,["modelValue"])]),_:1}),a(m,{label:"平台名称",prop:"name"},{default:r(()=>[a(b,{modelValue:l.name,"onUpdate:modelValue":e[2]||(e[2]=o=>l.name=o),placeholder:"请输入平台名称"},null,8,["modelValue"])]),_:1}),a(m,{label:"国家",prop:"country"},{default:r(()=>[a(b,{modelValue:l.country,"onUpdate:modelValue":e[3]||(e[3]=o=>l.country=o),placeholder:"请输入国家"},null,8,["modelValue"])]),_:1}),a(m,{label:"品牌",prop:"brand"},{default:r(()=>[a(b,{modelValue:l.brand,"onUpdate:modelValue":e[4]||(e[4]=o=>l.brand=o),placeholder:"请输入品牌"},null,8,["modelValue"])]),_:1}),a(m,{label:"录入人员",prop:"operation"},{default:r(()=>[a(oe,{modelValue:l.operation,"onUpdate:modelValue":e[5]||(e[5]=o=>l.operation=o),"collapse-tags":"","collapse-tags-tooltip":"",multiple:"",placeholder:"请选择录入人员"},{default:r(()=>[(p(!0),R(h,null,T(k.value,o=>(p(),w(te,{key:o.value,label:o.label,value:o.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(m,{label:"回款币种",prop:"currency"},{default:r(()=>[a(b,{modelValue:l.currency,"onUpdate:modelValue":e[6]||(e[6]=o=>l.currency=o),placeholder:"请输入回款币种"},null,8,["modelValue"])]),_:1}),a(m,{label:"回款/余额币种",prop:"currencyCodePlatform"},{default:r(()=>[a(b,{modelValue:l.currencyCodePlatform,"onUpdate:modelValue":e[7]||(e[7]=o=>l.currencyCodePlatform=o),placeholder:"请输入回款/余额币种"},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules","size"])]),_:1},8,["modelValue"])],64)}}});const we=_e(Ce,[["__scopeId","data-v-dc26b51c"]]);export{we as default};
|