index.7c0c6789.js 9.2 KB

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