import{B as D}from"./BasicForm-dL_oCSPM.js";import{L as O,an as T}from"./template-rpthWlT9.js";import{cO as g,cq as y,fm as b,d as G,r as x,V as R,f as S,u as z,aw as $,h as j,o as A,j as n,w as f,M,ao as N,l as m,U as k}from"./index-9PRMimni.js";import{u as q}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";function P(u){return{schemas:[{field:"deficiency",label:"",component:"ImageUpload",componentProps:i=>({disabled:u?.readOnly,action:`${y().urlPrefix}/files`,headers:{timestamp:new Date().getTime(),authorization:`${g.get(b)}`},onUploadChange:a=>{console.log("file",a)}})}],schemas2:[{field:"correct",label:"",component:"ImageUpload",componentProps:i=>({disabled:u?.readOnly,action:`${y().urlPrefix}/files`,headers:{timestamp:new Date().getTime(),authorization:`${g.get(b)}`},onUploadChange:a=>{console.log("file",a)}})}]}}const de=G({__name:"index",setup(u,{expose:h}){const p=x([]),i=x([]),{t:a}=R(),s=S(),v=z(),[w,{setFieldsValue:F,getFieldsValue:I}]=q({schemas:p,labelWidth:"auto",layout:"horizontal",collapsed:!0,gridProps:{cols:1,xGap:15},showActionButtonGroup:!1}),[U,{setFieldsValue:E,getFieldsValue:V}]=q({schemas:i,labelWidth:"auto",layout:"horizontal",collapsed:!0,gridProps:{cols:1,xGap:15},showActionButtonGroup:!1});async function B(){if(console.log(s.query.id),s.query.id){const e=await O(Number(s.query.id));let r=[];e?.deficiency&&e?.deficiency.forEach(t=>{r.push(t?.photoUrl)});let c=[];e?.correct&&e?.correct.forEach(t=>{c.push(t?.photoUrl)}),F({deficiency:r||[]}),E({correct:c||[]})}if(s.query.isEdit){const e=P({readOnly:!1});p.value=e.schemas,i.value=e.schemas2}else{const e=P({readOnly:!0});p.value=e.schemas,i.value=e.schemas2}}async function C(){let e=I(),r=[];e.deficiency.forEach(d=>{let o={};o.photoUrl=d,o.photoType="deficiency",o.reportId=s.query.reportId,o.deficiencyId=s.query.id,r.push(o)});let c=V(),t=[];c.correct.forEach(d=>{let o={};o.photoUrl=d,o.photoType="correct",o.reportId=s.query.reportId,o.deficiencyId=s.query.id,t.push(o)});const l=[...r,...t];console.log(l),await T(l)&&v.success(a("common.saveSuccessText"))}return $(()=>{B()}),h({submit:C}),(e,r)=>{const c=N,t=D,l=M,_=k;return A(),j("div",null,[n(_,{cols:"1 s:1 m:1 l:2 xl:2 2xl:2",responsive:"screen","x-gap":12},{default:f(()=>[n(l,{span:"1",class:"mb-4"},{default:f(()=>[n(c,{title:m(a)("hsqe.deficiency.deficiencyPhotos")},null,8,["title"]),n(t,{onRegister:m(w),"label-placement":"top"},null,8,["onRegister"])]),_:1}),n(l,{span:"1",class:"mb-4"},{default:f(()=>[n(c,{title:m(a)("hsqe.deficiency.correctivePhotos")},null,8,["title"]),n(t,{onRegister:m(U),"label-placement":"top"},null,8,["onRegister"])]),_:1})]),_:1})])}}});export{de as default};
