index.501132eb.js 10.0 KB

1
  1. import{S as le,g as re,a as ne,p as ue,b as de,c as se}from"./index.80ce8513.js";import{V as x}from"./index.c1ad757b.js";import{h as _}from"./elementPlus.2ca9dd27.js";import{d as ie,r as v,Q as P,j as ce,a8 as i,o as f,c as R,M as a,G as r,a as E,B as me,ab as pe,K as N,F as h,E as w,$ as F,n as fe}from"./vue.95e072e2.js";import{_ as ge}from"./_plugin-vue_export-helper.c27b6911.js";const ye={style:{position:"relative"}},be={class:"dialog-footer"},_e=ie({__name:"index",setup(ve){const T=v("default"),V=v(!1),C=v(),l=P({number:"",name:"",country:"",brand:"",operation:[],currency:"",currencyCodePlatform:""}),S=t=>{t&&t.resetFields()},z=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:!1,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([]),q={pageChange({currentPage:t,pageSize:e}){d.pagerConfig&&(d.pagerConfig.currentPage=t,d.pagerConfig.pageSize=e,g())}};async function g(t={}){try{d.loading=!0;const e=await re({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 B(t){$.value&&g(t.value)}const D=t=>{const e=c.value;return e?e.isEditByRow(t):!1},O=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))},M=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 j(){const t=c.value;if(t){const s={keys:t.getCheckboxRecords().map(m=>m.id)};try{(await ue(s)).code===2e3&&(_({message:"删除成功",type:"success"}),await g())}catch{_({message:"删除失败",type:"error"})}}}const I=async()=>{const t=c.value;t&&(t.getCheckboxRecords().length>0?await x.modal.confirm("您确定要删除选中的数据?")==="confirm"&&(await j(),await t.removeCheckboxRow()):await x.modal.message({content:"请选择要删除的数据",status:"error"}))},A=[{field:"platformNumber",title:"平台编号"},{field:"platformName",title:"平台名称"},{field:"country",title:"国家"},{field:"brandName",title:"品牌"},{field:"user",title:"运营"},{field:"currencyCode",title:"回款币种"},{field:"currencyCodePlatform",title:"回款/余额币种"}],G=t=>{for(const{field:e,title:u}of A)if(!t[e]||Array.isArray(t[e])&&t[e].length===0){_.error(`${u}不能为空`);return}return!0};async function L(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 de(u);console.log(s),s.code===2e3?_.success("更新成功"):s.code==400?_.warning(`${s.data.description}`):_.error("更新失败")}catch(s){console.log("error:",s)}}}const H=async t=>{const e=c.value;if(e){if(!G(t))return;await e.clearEdit(),await L(t),await g(),d.loading=!0,setTimeout(()=>{d.loading=!1},300)}};async function K(){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 se(t)}catch(e){console.error("error:",e),await x.modal.message({content:"创建失败,请重试",status:"error"})}}const Q=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 K(),V.value=!1,await g(),d.loading=!0,setTimeout(()=>{d.loading=!1},300)}catch(e){console.error("Failed to save task:",e)}},X=async t=>{t&&await t.validate(async(e,u)=>{e&&(await Q(),await fe(),C.value.resetFields(),await x.modal.message({content:"创建成功",status:"success"}))})};async function J(){try{const t=await ne();k.value=t.data.map(e=>({value:e.id,label:e.name}))}catch(t){console.error("Failed to fetch operation select:",t)}}return ce(()=>{g(),J()}),(t,e)=>{const u=i("el-card"),s=i("vxe-button"),m=i("el-button"),y=i("vxe-input"),W=i("vxe-option"),Y=i("vxe-select"),Z=i("vxe-grid"),b=i("el-input"),p=i("el-form-item"),ee=i("el-option"),te=i("el-select"),oe=i("el-form"),ae=i("el-dialog");return f(),R(h,null,[a(u,{class:"custom-card-style flex gap-1.5 justify-between my-1.5 mx-2"},{default:r(()=>[a(le,{ref_key:"selectorRef",ref:$,"onUpdate:filteredData":B},null,512)]),_:1}),a(u,{class:"mx-2"},{default:r(()=>[E("div",ye,[a(Z,me({ref_key:"xGrid",ref:c},d,pe(q)),{toolbar_buttons:r(()=>[a(s,{status:"primary",icon:"vxe-icon-add",plain:"",onClick:e[0]||(e[0]=o=>V.value=!0)},{default:r(()=>[N(" 添加任务")]),_:1}),a(s,{icon:"vxe-icon-delete",onClick:I},{default:r(()=>[N("删除")]),_:1})]),operate:r(({row:o})=>[D(o)?(f(),R(h,{key:0},[a(s,{type:"text",content:"取消",onClick:n=>M(o)},null,8,["onClick"]),a(s,{type:"text",status:"success",content:"保存",onClick:n=>H(o)},null,8,["onClick"])],64)):(f(),w(m,{key:1,type:"text",icon:"Edit",onClick:n=>O(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(Y,{modelValue:o.user,"onUpdate:modelValue":n=>o.user=n,multiple:""},{default:r(()=>[(f(!0),R(h,null,F(k.value,n=>(f(),w(W,{key:n.value,value:n.value,label:n.label},null,8,["value","label"]))),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(ae,{modelValue:V.value,"onUpdate:modelValue":e[10]||(e[10]=o=>V.value=o),title:"新建任务",width:"500"},{footer:r(()=>[E("div",be,[a(m,{onClick:e[8]||(e[8]=o=>{V.value=!1,S(C.value)})},{default:r(()=>[N("取消")]),_:1}),a(m,{type:"primary",onClick:e[9]||(e[9]=o=>X(C.value))},{default:r(()=>[N(" 确认")]),_:1})])]),default:r(()=>[a(oe,{ref_key:"taskRuleFormRef",ref:C,model:l,rules:z,size:T.value,class:"demo-taskRuleForm","label-width":"auto","status-icon":"",style:{"max-width":"600px"}},{default:r(()=>[a(p,{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(p,{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(p,{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(p,{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(p,{label:"录入人员",prop:"operation"},{default:r(()=>[a(te,{modelValue:l.operation,"onUpdate:modelValue":e[5]||(e[5]=o=>l.operation=o),multiple:"","collapse-tags":"","collapse-tags-tooltip":"",placeholder:"请选择录入人员"},{default:r(()=>[(f(!0),R(h,null,F(k.value,o=>(f(),w(ee,{key:o.value,label:o.label,value:o.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(p,{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(p,{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 Ne=ge(_e,[["__scopeId","data-v-361bd68c"]]);export{Ne as default};