import{L as h,M as g,N as y,O as v}from"./index.DLhCD1Qz.js";import{_ as S}from"./yb_admin_plugin.DNFUAscl.js";import{aZ as m,aL as n,u as a,I as s,bJ as p,v as l,t as b}from"./@vue.Da0bZ210.js";import"./vue.Bj6dTZYa.js";import"./@element-plus.pQhr8KT1.js";import"./echarts.Dms41JYJ.js";import"./tslib.BDyQ-Jie.js";import"./zrender.BueMfJu3.js";import"./axios.BjtuyMK1.js";import"./pinia.Tngw-S_5.js";import"./vue-router.DaVMGKLh.js";import"./element-plus.DC208N5p.js";import"./lodash-es.DVGGNlzX.js";import"./@vueuse.BhH-hw9p.js";import"./async-validator.9PlIezaS.js";import"./@popperjs.C5az9QE8.js";import"./@ctrl.C4Rzlq_k.js";import"./dayjs.BLMYetss.js";import"./memoize-one.BdPwpGay.js";import"./normalize-wheel-es.BQoi3Ox2.js";import"./@floating-ui.DCXYYTka.js";import"./vue-i18n.C7BagGww.js";import"./@intlify.TnaUIxGf.js";import"./moment.C5S46NFB.js";const C={name:"AiServiceInterfaceAdd",props:{edit:{type:Object,default:()=>({id:0})}},data(){return{form:{id:0,mch_id:0,shop_id:0,service_id:"",name:"",interface_flag:"",interface_type:"",deduct_type:"",deduct_base:1,deduct_num:0,status:1,setting:{}},rules:{},serviceList:[],platformOptions:[],platformConfig:[],deductTypeOptions:[],platformSettings:{}}},created(){this.loadServiceList(),this.edit.id&&this.loadInterfaceDetail()},methods:{async loadServiceList(){try{const e=await v();this.serviceList=e.data.list,this.platformSettings=e.data.platform_setting||{},this.deductTypeOptions=e.data.deduct_type_options||[],this.edit.id&&this.form.service_id&&this.handleServiceChange(this.form.service_id)}catch(e){console.error("加载服务列表失败:",e)}},async loadInterfaceDetail(){try{const t=(await y(this.edit.id)).data;this.form={...this.form,id:t.id,mch_id:t.mch_id,shop_id:t.shop_id,service_id:t.service_id,name:t.name,interface_flag:t.interface_flag,interface_type:t.interface_type,deduct_type:t.deduct_type,deduct_base:t.deduct_base,deduct_num:t.deduct_num,status:t.status,setting:JSON.parse(t.setting||"{}")},await this.loadServiceList(),this.form.interface_type&&this.handlePlatformChange(this.form.interface_type)}catch(e){console.error("加载接口详情失败:",e)}},handleServiceChange(e){const t=this.serviceList.find(o=>o.id===e);if(t)try{const o=JSON.parse(t.setting||"{}");this.platformOptions=o.platforms||[],this.platformOptions.some(d=>d.flag===this.form.interface_type)||(this.form.interface_type="",this.platformConfig=[],this.form.setting={})}catch(o){console.error("解析服务设置失败:",o),this.platformOptions=[]}else this.platformOptions=[],this.platformConfig=[],this.form.setting={}},handlePlatformChange(e){if(!e){this.platformConfig=[],this.form.setting={};return}this.platformConfig=this.platformSettings[e]||[];const t={};this.platformConfig.forEach(o=>{t[o.key]=this.form.setting[o.key]||""}),this.form.setting=t,this.$nextTick(()=>{this.$refs.form&&this.$refs.form.clearValidate()})},onSubmit(){this.$refs.form.validate(e=>{if(e){const t={...this.form,setting:JSON.stringify(this.form.setting)};(this.form.id?h:g)(t).then(d=>{this.$message.success("保存成功"),this.callBack&&this.callBack()})}else return!1})}}},V={class:"app-container"},O={key:0},k={key:1},x={key:2},L={key:3};function I(e,t,o,d,i,w){const u=m("el-input"),f=m("el-form-item"),c=m("el-input-number"),_=m("el-form");return n(),a("div",V,[s(_,{ref:"form",model:i.form,rules:i.rules,"label-width":"120px"},{default:p(()=>[s(f,{label:"接口名称",prop:"name"},{default:p(()=>[s(u,{modelValue:i.form.name,"onUpdate:modelValue":t[0]||(t[0]=r=>i.form.name=r),modelModifiers:{trim:!0},placeholder:"请输入接口名称",disabled:""},null,8,["modelValue"])]),_:1}),s(f,{label:"扣除点数",prop:"deduct_num"},{default:p(()=>[t[3]||(t[3]=l("span",null,"每",-1)),s(c,{readonly:"true",style:{margin:"0 6px"},modelValue:i.form.deduct_base,"onUpdate:modelValue":t[1]||(t[1]=r=>i.form.deduct_base=r),min:1},null,8,["modelValue"]),i.form.deduct_type==="times"?(n(),a("span",O,"次, ")):i.form.deduct_type==="words"?(n(),a("span",k,"字, ")):i.form.deduct_type==="duration_minute"?(n(),a("span",x,"分钟, ")):i.form.deduct_type==="duration_second"?(n(),a("span",L,"秒, ")):b("",!0),t[4]||(t[4]=l("span",{style:{"margin-left":"8px"}},"扣除",-1)),s(c,{style:{margin:"0 6px"},modelValue:i.form.deduct_num,"onUpdate:modelValue":t[2]||(t[2]=r=>i.form.deduct_num=r),min:0},null,8,["modelValue"]),t[5]||(t[5]=l("span",null,"点",-1))]),_:1})]),_:1},8,["model","rules"])])}const tt=S(C,[["render",I],["__scopeId","data-v-557ec258"]]);export{tt as default};
