import{U as m,a2 as C,ad as w,af as s,k as l,V as k,a4 as b,az as q,aA as z,G as N,d as Q,f as g,r as D}from"./vue-vendor-CxLCUzY4.js";import{B as W}from"./index-D2AmS0aU.js";import"./index-ARbUvvsq.js";import{J as L}from"./useOnlineTest-e4bd8be3-BYcho5AC.js";import{u as X,E as Y}from"./EnhanceJsHistory-9c4acdaf-DreSu-8a.js";import{b as Z,q as ee}from"./enhance.api-138e6826-C1bLj3W2.js";import{c9 as te,a8 as se,a9 as ae,u as ie}from"./index-B_2CoVdl.js";import{T as oe,bz as le}from"./antd-vue-vendor-CDWW6V_M.js";import re from"./JCodeEditor-esTLnfS3.js";import"./BasicModal-D3g2CFhF.js";import"./ModalHeader-C-C0dUi_.js";import"./useTimeout-CB9F1PLu.js";import"./vxe-table-vendor-B5h3MVdD.js";import"./index-DAURrYyA.js";import"./useWindowSizeFn-C3WExEpc.js";import"./index-Dz2zbQB_.js";import"./index-exs4VcBw.js";import"./index-ByLO0zSl.js";import"./useIntersectionObserver-FVRzwlSd.js";import"./useForm-CcjrODHR.js";import"./componentMap-CzCGDP7x.js";import"./useFormItem-CWa0w7fA.js";import"./download-2tYEzlDW.js";import"./base64Conver-24EVOS6V.js";import"./index-Cgt544dC.js";import"./index-BZ9ST2iq.js";import"./useCountdown-ImUE7YaG.js";import"./useFormItemSingle-DM34aWgK.js";import"./JSelectUser-BQIJUcBR.js";import"./props-BCVPj-bG.js";import"./JSelectBiz-CJyWq5s2.js";import"./JAddInput-YFlAniYT.js";import"./areaDataUtil-DFHnz1wu.js";import"./china-area-data-vendor-D0sJ9kfX.js";import"./index-CkL00Q0a.js";import"./index-BKs2x_To.js";import"./bem-C6eT35UB.js";import"./props-BLY2qIO5.js";import"./useContextMenu-CSt5a1-F.js";import"./depart.api-0qTriT9h.js";import"./JDictSelectTag-CxpDdimB.js";import"./JSelectDept-wKz_Qtmc.js";import"./JPopup-BJBYqoWe.js";import"./JEllipsis-Cn7GCKHR.js";import"./JUpload-DzM-D4DX.js";import"./index-khU3p_On.js";import"./index-DPEnuI0R.js";import"./index-Cnb8BkwG.js";import"./JAreaLinkage-CSgDAlrn.js";import"./EasyCronInput-DclSHT47.js";import"./htmlmixed-DRe7JlAp.js";import"./vue-B0b3nX1K.js";/* empty css             */var S=(e,a,c)=>new Promise((f,x)=>{var i=o=>{try{u(c.next(o))}catch(n){x(n)}},r=o=>{try{u(c.throw(o))}catch(n){x(n)}},u=o=>o.done?f(o.value):Promise.resolve(o.value).then(i,r);u((c=c.apply(e,a)).next())});const V={list:[{text:".acceptHrefParams",displayText:"acceptHrefParams",superiors:"this",desc:"获取地址栏上的条件"},{text:".currentPage",displayText:"currentPage",superiors:"this",desc:"获取当前页数，默认1"},{text:".currentTableName",displayText:"currentTableName",desc:"获取当前表名"},{text:".description",displayText:"description",superiors:"this",desc:"获取当前表描述"},{text:".hasChildrenField",displayText:"hasChildrenField",superiors:"this",desc:"如果是树形列表，获取是否有子节点字段名"},{text:".ID",displayText:"ID",superiors:"this",desc:"获取当前表的配置ID"},{text:".pageSize",displayText:"pageSize",superiors:"this",desc:"获取当前每页条数，默认10"},{text:".queryParam",displayText:"queryParam",superiors:"this",desc:"获取查询表单的查询条件"},{text:".selectedRowKeys",displayText:"selectedRowKeys",superiors:"this",desc:"获取选中行的id的数组"},{text:".selectedRows",displayText:"selectedRows",superiors:"this",desc:"获取选中行的数据数组"},{text:".sortField",displayText:"sortField",superiors:"this",desc:"获取排序字段，默认‘id’"},{text:".sortType",displayText:"sortType",superiors:"this",desc:"获取排序类型，默认升序‘asc’"},{text:".total",displayText:"total",superiors:"this",desc:"获取总条数"},{text:".loadData()",displayText:"loadData()",superiors:"this",desc:"加载数据"},{text:".clearSelectedRow()",displayText:"clearSelectedRow()",superiors:"this",desc:"清除选中的行"},{text:".getLoadDataParams()",displayText:"getLoadDataParams()",superiors:"this",desc:"获取所有的查询条件，返回一个对象，包括：查询表单，高级查询，地址栏参数，分页信息，排序信息等"},{text:".isTree()",displayText:"isTree()",superiors:"this",desc:"判断当前表是不是树，返回布尔值"},{text:`beforeEdit(row){
  return new Promise((resolve, reject) => {
    if(row.字段名 == '字段值'){
      reject('测试~');
    }else{
      resolve();
    }
  })     
}`,displayText:"beforeEdit(row){}",desc:"点击操作列下的编辑按钮触发，返回promise对象"},{text:`beforeDelete(row){
	return new Promise((resolve, reject) => {
  	if(row.字段名 == '字段值'){
    	reject('测试~');
    }else{
    	resolve();
    }
  })     
}`,displayText:"beforeDelete(row){}",desc:"点击操作列下的删除按钮触发，返回promise对象"},{text:"console.log()",displayText:"console.log()",desc:"打印日志"}],form:[{text:".loading",displayText:"loading",superiors:"this",desc:"是否加载中，返回的是一个ref对象"},{text:".isUpdate",displayText:"isUpdate",superiors:"this",desc:"是否是编辑页面，返回的是一个ref对象"},{text:".onlineFormRef",displayText:"onlineFormRef",superiors:"this",desc:"主表/单表表单的ref对象"},{text:".refMap",displayText:"refMap",superiors:"this",desc:"子表表单/子表table的ref对象map，key为子表表名"},{text:".subActiveKey",displayText:"subActiveKey",desc:"子表的激活的tab索引值对应的字符串，从‘0’开始，返回的是一个ref对象"},{text:".sh",displayText:"sh",superiors:"this",desc:"单表/主表字段的显示隐藏状态"},{text:".submitFlowFlag",displayText:"submitFlowFlag",superiors:"this",desc:"是否提交表单后自动提交流程，返回一个ref对象"},{text:".subFormHeight",displayText:"subFormHeight",superiors:"this",desc:"一对一子表表单的高度，不需要设置，返回一个ref对象"},{text:".subTableHeight",displayText:"subTableHeight",superiors:"this",desc:"一对多子表table的高度，不需要设置，返回一个ref对象"},{text:".tableName",displayText:"tableName",superiors:"this",desc:"当前表名，返回的是一个ref对象"},{text:".$nextTick",displayText:"$nextTick",superiors:"this",desc:"调用的是vue3的nextTick"},{text:".字段名_load",displayText:"字段名_load",superiors:"this",desc:"控制字段的加载与否，设置为false表示当前字段不加载"},{text:".字段名_disabled",displayText:"字段名_disabled",superiors:"this",desc:"控制字段的禁用与否，设置为true表示当前字段禁用"},{text:".addSubRows(tableName, rows)",displayText:"addSubRows(tableName, rows)",superiors:"this",desc:"往一对多子表table里添加数据"},{text:".changeOptions(field, options)",texdisplayTextt:"changeOptions(field, options)",superiors:"this",desc:"改变单表/主笔 下拉控件的下拉选项"},{text:".clearSubRows(tableName)",displayText:"clearSubRows(tableName)",superiors:"this",desc:"清空一对多子表table的数据"},{text:".clearThenAddRows(tableName, rows)",displayText:"clearThenAddRows(tableName, rows)",superiors:"this",desc:"先清空一对多子表table的数据，再往里添加数据"},{text:".getFieldsValue()",displayText:"getFieldsValue()",superiors:"this",desc:"获取主表/单表 所有字段的值"},{text:".getSubTableInstance(tableName)",displayText:"getSubTableInstance(tableName)",superiors:"this",desc:"获取子表的实例对象，这个对象可以调用子表table的方法"},{text:".setFieldsValue(row)",displayText:"setFieldsValue(row)",superiors:"this",desc:"设置主表/单表 字段的值"},{text:".triggleChangeValues(values,id,target)",displayText:"triggleChangeValues(values,id,target)",superiors:"this",desc:"改变单表/主表/子表 字段的值，一般用于change事件，其中id，target需要通过change事件的内置参数获取，如果不传id，target的值，则改变的是主表的字段"},{text:".triggleChangeValue(field, value)",displayText:"triggleChangeValue(field, value)",superiors:"this",desc:"设置单表/主表 字段的值"},{text:".onlineFormValueChange(field, value, otherValus)",displayText:"onlineFormValueChange(field, value, otherValus)",superiors:"this",desc:"定义后，当表单值改变的时候会触发该方法（因js增强hook方式不支持原来的onlChange，所以定义此方法）"},{text:".changeSubTableOptions(tableName，field，options)",displayText:"changeSubTableOptions(tableName，field，options)",superiors:"this",desc:"改变一对一子表下拉框options"},{text:".changeSubFormbleOptions(tableName，field，options)",displayText:"changeSubFormbleOptions(tableName，field，options)",superiors:"this",desc:"改变一对多子表下拉框options"},{text:".changeRemoteOptions({ field, dict, label, type?, subTableName? })",displayText:"changeRemoteOptions({ field, dict, label, type?, subTableName? })",superiors:"this",desc:"改变动态下拉框options"},{text:`beforeSubmit(row){
	return new Promise((resolve, reject)=>{
    //此处模拟等待时间，可能需要发起请求
    setTimeout(()=>{
      if(row.字段名 == '字段值'){
        // 当某个字段不满足要求的时候可以reject 
        reject('测试~');
      }else{
        resolve();
      }
    },3000)
  })
}`,displayText:"beforeSubmit(row){}",desc:"提交前置事件"},{text:`loaded(){
  this.$nextTick(()=>{
    // let text = '测试js增强设置默认值';
    // if(this.isUpdate.value === true){
    //   text = '测试js增强修改表单值';
    // }
    this.setFieldsValue({
      字段名: 修改的值
    })
  })
}`,displayText:"loaded(){}",desc:"表单加载事件"},{text:`onlChange(){
  return {
    字段名(){
      let value = event.value
      console.log(value)
      this.triggleChangeValues({'字段名': '修改后的值'})
    }
  }
 }`,displayText:"onlChange(){}",desc:"单表#表单值改变事件"},{text:`子表名_onlChange(){
  return {
    字段名(){
      let value = event.value;
      console.log(value);
      let row = {'字段名': '测试一对多值改变：'+value};
      this.triggleChangeValues(row, event.row.id, event.target)
  }
  }
}`,displayText:"子表名_onlChange(){}",desc:"子表#表单值改变事件"},{text:`子表名_onlChange(){
  return {
    子表字段01(){
      this.getSubTableInstance('子表名').getValues((err,values)=>{
        this.triggleChangeValues({'主表字段名': '修改后的值'})
      }) 
    },
  }
}
`,displayText:"子表名_onlChange(){}",desc:"子改主#表单值改变事件"},{text:`onlChange(){
  return {
    字段名01(){
      let value = event.value
      this.changeOptions('字段名02', '修改后的值');
    }
    字段名02(){
      let value = event.value
      this.changeOptions('字段名03', '修改后的值');
    }
  }
}`,displayText:"changeOptions()",desc:"js增强实现下拉联动"},{text:`getAction('请求url', { 'key': 'value'}).then(res => {
  console.log(res)
})`,displayText:"getAction(url, param)",desc:"get请求"},{text:`postAction('请求url', { 'key': 'value'}).then(res => {
  console.log(res)
})`,displayText:"postAction(url, param)",desc:"post请求"},{text:`putAction('请求url', { 'key': 'value'}).then(res => {
  console.log(res)
})`,displayText:"putAction(url, param)",desc:"put请求"},{text:`deleteAction('请求url', { 'key': 'value'}).then(res => {
  console.log(res)
})`,displayText:"deleteAction(url, param)",desc:"delete请求"},{text:"console.log()",displayText:"console.log()",desc:"打印日志"}],common:[{text:"this",displayText:"this",desc:"上下文"},{text:".openCustomModal({title,width,row,formComponent,requestUrl,hide,show})",displayText:"openCustomModal({title,width,row,formComponent,requestUrl,hide,show})",desc:"打开一个弹窗-参考 Js增强打开自定义弹窗"}]},ne=Q({name:"EnhanceJs",components:{BasicModal:W,JCodeEditor:re,EnhanceJsHistory:Y,QuestionCircleOutlined:le,Tooltip:oe},emits:["register"],setup(){const{createMessage:e}=ie(),a=X(),c=g(),f=g(),x=D({form:{},list:{}}),i=g("list"),r=g(""),u=g(!1),o=g(!1),n=g(""),y=D({form:"",list:""}),p={form:!1,list:!1},T=g(!1),J=[...V.list,...V.common],F=[...V.form,...V.common],[h,{closeModal:M}]=se(t=>S(this,null,function*(){K(t.row)})),[H,P]=ae(),{aiTestMode:A,genEnhanceJsData:_}=L();function K(t){r.value=t.id,o.value=!1,n.value=t.tableName;let d=a.getEnhanceJs(r.value);(d==null?void 0:d.length)>0?(i.value=d[d.length-1].type,u.value=!0):u.value=!1,p.form=!1,p.list=!1,i.value?j(i.value):j("form"),T.value=!0,setTimeout(()=>T.value=!1,150)}function I(){return S(this,null,function*(){yield Promise.all([E("form"),E("list")]),M(),e.success("保存成功")})}function E(t){return S(this,null,function*(){let d=x[t],v={cgJs:y[t],cgJsType:t};if(!p[t]||d.cgJs===v.cgJs)return;let O=!!d.id;O&&(v=Object.assign({},d,v)),yield ee(r.value,v,O),a.addEnhanceJs({code:r.value,str:v.cgJs,type:v.cgJsType,date:new Date().getTime()})})}function B(){M()}function j(t){return S(this,null,function*(){i.value=t;try{if(!p[t]){let d=yield Z(r.value,t);Object.assign(x[t],{id:null},d),y[t]=x[t].cgJs,p[t]=!0}}catch(d){}setTimeout(()=>{t=="list"?f.value.refresh():c.value.refresh()},150)})}function U(){P.openModal(!0,{code:r.value,type:i.value})}function $(t){y[i.value]!=t&&(o.value=!0,y[i.value]=t)}function G(){i.value==="form"?_(n.value,i.value,c.value):_(n.value,i.value,f.value)}return{formEditorRef:c,listEditorRef:f,reloading:T,enhanceValues:y,enhanceType:i,showHistory:u,aiTestMode:A,tableName:n,genEnhanceJsData:_,onGenTestData:G,onChangeType:j,onCodeChange:$,onShowHistory:U,onSubmit:I,onCancel:B,registerModal:h,registerEnhanceJsHistory:H,listKeyWords:J,formKeyWords:F,handleGo:t=>{window.open(`https://help.jeecg.com/online/enhanceJs/${t}.html`)}}}}),R=e=>(q("data-v-f6eb0967"),e=e(),z(),e),de={class:"titleBox"},ue=R(()=>b("span",{class:"title"},"form",-1)),pe=R(()=>b("span",null,"表单js增强文档",-1)),ce={class:"titleBox"},he=R(()=>b("span",{class:"title"},"list",-1)),me=R(()=>b("span",null,"列表js增强文档",-1));function ge(e,a,c,f,x,i){const r=m("QuestionCircleOutlined"),u=m("Tooltip"),o=m("JCodeEditor"),n=m("a-tab-pane"),y=m("a-tabs"),p=m("a-button"),T=m("a-space"),J=m("EnhanceJsHistory"),F=m("BasicModal");return C(),w(F,{onRegister:e.registerModal,title:"JS增强",width:800,bodyStyle:{height:"360px"}},{footer:s(()=>[l(T,null,{default:s(()=>[l(p,{onClick:e.onCancel},{default:s(()=>[N("关闭")]),_:1},8,["onClick"]),l(p,{type:"primary",onClick:e.onSubmit},{default:s(()=>[N("确定")]),_:1},8,["onClick"])]),_:1}),l(T,{style:{float:"left"}},{default:s(()=>[e.showHistory?(C(),w(p,{key:0,onClick:e.onShowHistory},{default:s(()=>[N("查看历史版本")]),_:1},8,["onClick"])):k("",!0),e.aiTestMode?(C(),w(p,{key:1,onClick:e.onGenTestData},{default:s(()=>[N("生成测试数据")]),_:1},8,["onClick"])):k("",!0)]),_:1})]),default:s(()=>[l(y,{activeKey:e.enhanceType,"onUpdate:activeKey":a[4]||(a[4]=h=>e.enhanceType=h),onChange:e.onChangeType},{default:s(()=>[l(n,{key:"form",forceRender:""},{tab:s(()=>[b("div",de,[ue,l(u,null,{title:s(()=>[pe]),default:s(()=>[l(r,{onClick:a[0]||(a[0]=h=>e.handleGo("form"))})]),_:1})])]),default:s(()=>[!e.reloading&&e.enhanceType==="form"?(C(),w(o,{key:0,ref:"formEditorRef",value:e.enhanceValues.form,"onUpdate:value":a[1]||(a[1]=h=>e.enhanceValues.form=h),language:"javascript",fullScreen:!0,lineNumbers:!1,height:"240px","language-change":!1,onChange:e.onCodeChange,keywords:e.formKeyWords},null,8,["value","onChange","keywords"])):k("",!0)]),_:1}),l(n,{key:"list",forceRender:""},{tab:s(()=>[b("div",ce,[he,l(u,null,{title:s(()=>[me]),default:s(()=>[l(r,{onClick:a[2]||(a[2]=h=>e.handleGo("list"))})]),_:1})])]),default:s(()=>[!e.reloading&&e.enhanceType==="list"?(C(),w(o,{key:0,ref:"listEditorRef",value:e.enhanceValues.list,"onUpdate:value":a[3]||(a[3]=h=>e.enhanceValues.list=h),language:"javascript",fullScreen:!0,lineNumbers:!1,height:"240px","language-change":!1,onChange:e.onCodeChange,keywords:e.listKeyWords},null,8,["value","onChange","keywords"])):k("",!0)]),_:1})]),_:1},8,["activeKey","onChange"]),l(J,{onRegister:e.registerEnhanceJsHistory},null,8,["onRegister"])]),_:1},8,["onRegister"])}const gt=te(ne,[["render",ge],["__scopeId","data-v-f6eb0967"]]);export{gt as default};
