import{V as P,d as j,r as A,aw as L,c as N,o as C,w as c,j as l,l as g,aH as D,aJ as T,X as V,cZ as q}from"./index-9PRMimni.js";import{B as M}from"./BasicForm-dL_oCSPM.js";import{u as U,f as k,h as E,i as I}from"./jobOrder-CGbsc7bp.js";import{i as J}from"./isEmpty-BUg1OsQj.js";import{u as O}from"./useForm-CKmgcynv.js";import"./Render.vue_vue_type_script_lang-DKUYY0Zw.js";import"./SingleImageUpload-CNx4b9eC.js";import"./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";import"./componentSetting-DVhNDBTO.js";import"./ImageUpload-DUsnro3W.js";import"./vuedraggable.umd-Co2xEC3p.js";import"./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";import"./tabsView-BXskTdVh.js";import"./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";import"./propTypes-CebMRUpe.js";import"./BasicSelect-C_uwzMkE.js";import"./BasicSelect.vue_vue_type_style_index_0_scoped_772d51cc_lang-Brp6PjEU.js";import"./dictionary-BRse4lkf.js";import"./index-DkvzUEqh.js";import"./index-kKnqLkWM.js";import"./AutoComplete-Dv1Bqed4.js";import"./TreeSelect-BZh2DeCh.js";import"./usePageCache-DluHn7Yy.js";const{t:w}=P();function z(){return{formSchemas:[{field:"attachment",label:w("unPlannedJob.basicDetailTab.attachment"),giProps:{span:1},slot:"attachmentSlot",showLabel:!1,rules:[{validator(u,o){return J(o)?Promise.reject(new Error(w("common.RequireTips"))):Promise.resolve(!0)}}]}]}}const fe=j({__name:"index",props:{itemParams:{},edit:{type:Boolean}},setup(p,{expose:u}){const o=p,{t:d}=P(),f=q(),{formSchemas:b}=z(),[x,{setFieldsValue:F,getFieldsValue:v,validate:y,deletePageFormCache:S}]=O({gridProps:{cols:1},layout:"horizontal",schemas:b,showActionButtonGroup:!1}),r=A([]);async function B({file:t,onFinish:e,onError:i}){try{const a=new FormData;a.append("file",t.file);const s=await U(a),n={jobPlanOrderId:Number(o.itemParams.id),fileCode:s.name,fileName:s.originalFileName};await k(n),f.success(d("common.uploadSuccessText")),await h(),e({file:t})}catch{i()}}async function h(){await E(o.itemParams.id).then(t=>{r.value=t.map(e=>({...e,url:e.url,name:e.fileName,status:"finished"})),F({attachment:r})})}async function R({index:t}){const e=r.value[t].id;await I(e),f.success(d("common.optionsDelSuccessText"))}return L(()=>{h()}),u({validate:y,getFieldsValue:v,deletePageFormCache:S}),(t,e)=>{const i=D,a=M,s=V;return C(),N(s,null,{default:c(()=>[l(a,{onRegister:g(x)},{attachmentSlot:c(({model:n,field:_})=>[l(i,{"list-type":"image-card","file-list":n[_],"onUpdate:fileList":m=>n[_]=m,accept:".jpg,.png,.jpeg","custom-request":B,onRemove:e[0]||(e[0]=({index:m})=>R({index:m})),disabled:!o.edit,"show-remove-button":!0,max:5},{default:c(()=>[l(g(T),{class:"w-[32px] h-[32px]"})]),_:2},1032,["file-list","onUpdate:fileList","disabled"])]),_:1},8,["onRegister"])]),_:1})}}});export{fe as default};
