var h=(i,u,a)=>new Promise((l,n)=>{var p=o=>{try{c(a.next(o))}catch(r){n(r)}},m=o=>{try{c(a.throw(o))}catch(r){n(r)}},c=o=>o.done?l(o.value):Promise.resolve(o.value).then(p,m);c((a=a.apply(i,u)).next())});import{u as L}from"./useEntityForm-CMwp7TbN.js";import{b6 as t}from"./bootstrap-Bqxdt4iG.js";import{u as _}from"./customers-CYPE-oGV.js";import{u as k}from"./quotations-CYticOiT.js";import{u as R}from"./users-CtrZlEEf.js";import{c as F,C as N}from"./costing-sheets-CYsvWkOQ.js";import{a1 as x,L as d,aa as B,E,ai as A,aj as D,a9 as T}from"../jse/index-index-BUJ_4tQs.js";const J=x({__name:"costing-sheet-form",props:{costingSheet:{default:null},mode:{}},emits:["cancel","submit"],setup(i,{expose:u,emit:a}){const l=i,n=a,{isWarehouseScoped:p}=useRoleAccess(),m=_(),c=R(),o=k(),r=d([]),f=d([]),S=d([]);B(()=>h(null,null,function*(){const[e,s,y]=yield Promise.all([p?m.fetchOptionsByCurrentWarehouses():m.fetchOptions(),c.fetchSalesmanOptions(),o.fetchOptions()]);r.value=e,f.value=s,S.value=y}));const g={quotationId:"",customerId:"",salesmanId:"",status:N.DRAFT,remarks:""},b=F.map(e=>({label:e.label,value:e.value})),w=E(()=>[{component:"Select",componentProps:{placeholder:t("page.costingSheets.form.quotationPlaceholder"),options:S.value,allowClear:!0,showSearch:!0,filterOption:(e,s)=>s.label.toLowerCase().includes(e.toLowerCase())},fieldName:"quotationId",label:t("page.costingSheets.form.quotation")},{component:"Select",componentProps:{id:"costing-sheet-form-customer-select",placeholder:t("page.costingSheets.form.customerPlaceholder"),options:r.value,showSearch:!0,filterOption:(e,s)=>s.label.toLowerCase().includes(e.toLowerCase())},fieldName:"customerId",label:t("page.costingSheets.form.customer"),rules:"selectRequired"},{component:"Select",componentProps:{placeholder:t("page.costingSheets.form.salesmanPlaceholder"),options:f.value,showSearch:!0,filterOption:(e,s)=>s.label.toLowerCase().includes(e.toLowerCase())},fieldName:"salesmanId",label:t("page.costingSheets.form.salesman"),rules:"selectRequired"},{component:"Select",componentProps:{placeholder:t("page.costingSheets.form.statusPlaceholder"),options:b},fieldName:"status",label:t("page.costingSheets.form.status"),rules:"selectRequired"},{component:"Textarea",componentProps:{placeholder:t("page.costingSheets.form.remarksPlaceholder"),autoSize:{minRows:2}},fieldName:"remarks",label:t("page.costingSheets.form.remarks")}]),{Form:C,focus:O,isDirty:P,resetForm:q,submitForm:v,watchEntity:I}=L({emptyValues:g,firstInputId:"costing-sheet-form-customer-select",schema:w,wrapperClass:"grid-cols-1"});return I(()=>l.costingSheet,()=>l.mode),u({cancel:()=>{n("cancel")},focus:O,isDirty:P,resetForm:q,submit:()=>h(null,null,function*(){const e=yield v();e&&n("submit",e)})}),(e,s)=>(D(),A(T(C)))}});export{J as _};
