Files
machartaa_admin_dist/dist/assets/index-0778348f.js
T
2026-06-17 14:02:02 +03:30

2 lines
23 KiB
JavaScript

import{_ as Ee}from"./BasicModal.vue_vue_type_style_index_0_lang-0a56944e.js";import{_ as ze,u as qe}from"./useBaseTable-733b78fc.js";import{_ as Ke,B as He}from"./button.vue_vue_type_style_index_0_lang-251932bc.js";import{I as se}from"./Icon-417849dc.js";import{t as Je}from"./useDataTime-c57a768a.js";import{g as q}from"./convert-67c23be8.js";import{_ as de}from"./TextPreview.vue_vue_type_script_setup_true_lang-84819e23.js";import{u as We}from"./usePrice-bc935b83.js";import{b as n,d as Ge,g as w,r as Xe,h as F,v as Qe,l as Ye,o as p,c as h,a as m,w as r,e as I,j as W,G as Ze,k as $,F as E,n as G,i as S,D as f,ab as et,J as tt,K as at,H as lt,t as oe}from"./index-a788bd53.js";import{g as nt,u as it,a as st,b as ot,d as rt}from"./products-987ec4b4.js";import{g as re}from"./index-42f5befb.js";import{g as ut}from"./category-10ba77d5.js";import{g as dt}from"./brand-5df34b4c.js";import{l as z}from"./lodash-315d8ef5.js";import{M as ct,_ as _t}from"./index-0cdee960.js";import{I as pt,_ as mt}from"./index-c82b54d0.js";import{_ as ft,a as vt}from"./index-619be9cd.js";import{_ as bt}from"./index-b49a1e10.js";import{_ as gt,F as ht}from"./index-6cf8818b.js";import{_ as yt,a as kt}from"./index-bdb5a596.js";import{S as wt}from"./fa_IR-d5b5c457.js";import{U as xt}from"./index-4acd1bcb.js";import{T as ue}from"./shallowequal-f5e87a5a.js";import{_ as Ut}from"./_plugin-vue_export-helper-dc00b431.js";import"./index-eb51b631.js";import"./vnode-cf6f01a4.js";import"./Col-c7805dec.js";import"./useState-01af796f.js";import"./FormItemContext-b811304e.js";import"./pickAttrs-81a356a6.js";import"./isPlainObject-91b090bb.js";import"./toArray-16bbe0cf.js";import"./useRefs-7f6d723f.js";const Ct=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:v=>v.index+1},{title:"تصویر ",dataIndex:"original_image",key:"original_image",customRender:v=>{const K=q(v.record.original_image);return n("img",{src:K,width:60},null)}},{title:"عنوان",dataIndex:"title_fa",key:"title_fa"},{title:"کد",dataIndex:"code",key:"code"},{title:"توضیحات",dataIndex:"description",key:"description",customRender:v=>n(de,{text:v.record.description},null)},{title:"قیمت (ریال)",dataIndex:"price",key:"price",align:"center",width:120,customRender:v=>We(v.record.price??0,!0,"")},{title:"موجودی",dataIndex:"count",key:"count",align:"center",width:120,customRender:v=>v.record.count??0},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:v=>Je(v.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}],M=v=>(tt("data-v-af7d30d2"),v=v(),at(),v),Vt={class:"flex justify-between items-center mb-4"},It=M(()=>m("h2",null,"محصولات",-1)),At={class:"gap-2 flex justify-center"},$t=M(()=>m("span",null,"حذف",-1)),Lt=M(()=>m("span",null,"ویرایش",-1)),Pt={key:0,class:"text-gray-500 text-sm mt-1"},St={class:"col-span-full grid grid-cols-1 sm:grid-cols-2 gap-4"},Mt={key:0},Bt=M(()=>m("div",{style:{"margin-top":"8px"}},"آپلود",-1)),Dt=M(()=>m("div",null,"آپلود فایل‌ها",-1)),Tt={class:"space-y-2"},Ft={class:"flex justify-between items-center gap-2 mb-2"},Ot={class:"text-sm text-gray-500"},Rt={key:3,class:"text-amber-600 text-sm mt-1"},Nt={class:"mt-2 flex flex-col sm:flex-row sm:flex-wrap gap-3"},jt={class:"space-y-3"},Et={class:"flex justify-between items-center gap-2 mb-2"},zt={class:"font-medium"},qt={class:"flex flex-col gap-2 sm:flex-row sm:items-center"},Kt=M(()=>m("span",{class:"text-gray-500 text-xs"},"نمایش این تنوع به‌عنوان پیش‌فرض در صفحه محصول",-1)),Ht={key:0,class:"mt-2 space-y-2"},Jt={key:1,class:"text-gray-500 text-sm mt-2"},Wt={class:"col-span-full grid grid-cols-1 sm:grid-cols-3 gap-4"},Gt=Ge({__name:"index",setup(v){`${re()||localStorage.getItem("tamin_token")||""}`;const[K,X]=qe(),ce=w({columns:Ct,api:nt,defaultPageLimit:20}),B=w(!1),O=w(!1),R=w(null),D=w(0),N=w(0),i=Xe({title_fa:"",title:"",price:0,body:"",is_show:!0,is_active:!0,box_size:0,sell_type:"numeric",original_image:void 0,product_attributes:[],files:[],auto_calculate:!1,is_exist:!0,created_at:void 0,updated_at:void 0,deleted_at:null,count_order:void 0,count_fav:void 0,count_view:void 0,min_price:void 0,max_price:void 0,type:"simple",owner_id:void 0,users:void 0,saved:[],variants:[],code:void 0,brand_id:void 0,collection_id:void 0,discount:void 0,discount_type:"percent",id:void 0,count:void 0,display_price:void 0,meta:void 0,seo_title:void 0,description:void 0,product_type:void 0,weight:void 0,rial_fee:void 0,percent_fee:void 0}),Q=w(),_e=F(()=>Q.value.map(t=>({value:t.id,label:t.title}))),Y=w(),pe=F(()=>Y.value.map(t=>({value:t.id,label:t.title}))),L=w([]),x=F(()=>i.type==="variant"),me=F(()=>L.value.map(t=>({value:t.id,label:t.name}))),j=F(()=>(i.product_attributes??[]).filter(t=>t.use_in_variant&&Z(t))),fe=t=>t.temp_key??(t.attribute_id!=null?`id:${t.attribute_id}`:`name:${t.attribute_name}`),Z=t=>{var e;return t.is_new?!!((e=t.attribute_name)!=null&&e.trim()):t.attribute_id!=null},ve=t=>{var e,a;return t.is_new&&((e=t.attribute_name)!=null&&e.trim())?t.attribute_name.trim():t.attribute_id!=null?((a=L.value.find(o=>o.id===t.attribute_id))==null?void 0:a.name)??"ویژگی":"ویژگی"},be=t=>{if(t.is_new||t.attribute_id==null)return[];const e=L.value.find(a=>a.id===t.attribute_id);return((e==null?void 0:e.attribute_values)??[]).map(a=>({value:a.id,label:a.value}))},ge=(t,e)=>{var o,u;if(typeof e=="string")return e;if(t.attribute_id==null)return String(e);const a=L.value.find(s=>s.id===t.attribute_id);return((u=(o=a==null?void 0:a.attribute_values)==null?void 0:o.find(s=>s.id===e))==null?void 0:u.value)??String(e)},he=t=>(t.attribute_values??[]).filter(e=>e!=null&&e!=="").map(e=>({value:e,label:ge(t,e)})),ee=(t,e)=>{const a=new Set((e.attribute_values??[]).filter(o=>o!=null&&o!==""));return(t.attribute_values??[]).find(o=>a.has(o))},ye=(t,e,a)=>{const o=new Set((e.attribute_values??[]).filter(s=>s!=null&&s!=="")),u=(t.attribute_values??[]).filter(s=>s!=null&&!o.has(s));t.attribute_values=a!=null&&a!==""?[...u,a]:u},ke=t=>new Set((i.product_attributes??[]).filter(e=>!e.is_new).map(e=>e.attribute_id).filter(e=>e!=null&&e!==t)),we=t=>{const e=ke(t);return me.value.filter(a=>!e.has(a.value))};function xe(t){t.attribute_values=[],t.is_new?t.attribute_id=void 0:t.attribute_name=""}function Ue(t){t.attribute_values=[]}function Ce(t){var o;const e=(o=t.attribute_name)==null?void 0:o.trim().toLowerCase();if(!e)return;(i.product_attributes??[]).some(u=>{var s,b,U;return u!==t&&(!u.is_new&&((b=(s=L.value.find(A=>A.id===u.attribute_id))==null?void 0:s.name)==null?void 0:b.trim().toLowerCase())===e||u.is_new&&((U=u.attribute_name)==null?void 0:U.trim().toLowerCase())===e)})&&(f.warning("این نام ویژگی قبلاً در محصول استفاده شده است"),t.attribute_name="")}function Ve(t){if(!t.use_in_variant){const e=new Set((i.variants??[]).flatMap(a=>a.attribute_values??[]));t.attribute_values=(t.attribute_values??[]).filter(a=>!e.has(a))}}const Ie=t=>{var e;(e=i.product_attributes)==null||e.splice(t,1)},te=(t,e)=>((e==null?void 0:e.label)??"").toLowerCase().includes(t.toLowerCase());function Ae(){var t;i.type==="variant"?(t=i.variants)!=null&&t.length||ae():i.variants=[]}const $e=()=>{var t;(t=i.product_attributes)==null||t.push({is_new:!1,attribute_id:void 0,attribute_name:"",temp_key:`temp_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,attribute_values:[],use_in_product_page:!x.value,use_in_variant:x.value})},ae=()=>{i.variants||(i.variants=[]),i.variants.push({id:null,sku:"",price:0,box_price:0,stock:0,discount:void 0,discount_type:"percent",is_default:i.variants.length===0,attribute_values:[],attribute_values_name:[]})},Le=t=>{var e,a;(e=i.variants)==null||e.splice(t,1),((a=i.variants)==null?void 0:a.length)===1&&(i.variants[0].is_default=!0)};function Pe(t,e){var a;(a=i.variants)!=null&&a.length&&(e?i.variants.forEach((o,u)=>{o.is_default=u===t}):i.variants.some(o=>o.is_default)||(i.variants[0].is_default=!0))}const P=w([]),Se=()=>!1,Me=()=>{};function Be(){Object.assign(i,z.cloneDeep(H),{type:"simple",product_attributes:[],variants:[],discount_type:"percent"}),P.value=[],O.value=!1,R.value=null,B.value=!0}function le(){Object.assign(i,H),B.value=!1}function De(t){return t.type.startsWith("image/")?t.size/1024/1024<5?!0:(f.error("حجم تصویر باید کمتر از 5MB باشد"),!1):(f.error("فقط فایل‌های تصویری مجاز است"),!1)}async function Te(t){const{file:e,onSuccess:a,onError:o,onProgress:u}=t,s=new FormData;s.append("file",e);const b=`${lt}/upload/machartaa-img`;N.value=0,D.value++,await new Promise((U,A)=>{const c=new XMLHttpRequest;c.open("POST",b);const J=re()||localStorage.getItem("tamin_token")||"";c.setRequestHeader("Authorization",`Bearer ${J}`),c.upload.onprogress=d=>{if(d.lengthComputable){const y=Math.round(d.loaded/d.total*100);N.value=y,u==null||u({percent:y})}},c.onload=()=>{if(N.value=100,c.status>=200&&c.status<300)try{const d=JSON.parse(c.responseText||"{}"),y=d.full_src||d.url||d.src||d.path||d.data&&(d.data.full_src||d.data.url||d.data.src||d.data.path)||"";let C=y;y!=null&&y.startsWith("http")&&(C=y.replace(/^https?:\/\/[^\/]+/,""));const V=q(C);i.original_image=C,P.value=V?[{uid:`${Date.now()}`,name:"products.jpg",status:"done",url:V,response:{path:C}}]:[],a==null||a(d,c),f.success("تصویر با موفقیت آپلود شد!"),U()}catch(d){o==null||o(d,c),A(d)}else{const d=new Error("خطا در آپلود تصویر");o==null||o(d,c),A(d)}},c.onerror=()=>{const d=new Error("خطا در آپلود کاور");o==null||o(d,c),A(d)},c.onloadend=()=>{D.value=Math.max(0,D.value-1),N.value=0},c.send(s)})}async function Fe(){var e;if(D.value>0){f.warning("لطفاً تا پایان آپلود صبر کنید");return}if((i.product_attributes??[]).find(a=>{var o;return a.is_new?!((o=a.attribute_name)!=null&&o.trim()):a.attribute_id==null})){f.error("برای هر ویژگی، نام یا انتخاب از لیست را تکمیل کنید");return}if(x.value){if(!((e=i.variants)!=null&&e.length)){f.error("حداقل یک تنوع برای محصول تعریف کنید");return}if(j.value.some(u=>{var s;return!((s=u.attribute_values)!=null&&s.filter(b=>b!=null&&b!=="").length)})){f.error("برای هر ویژگی تنوع، حداقل یک مقدار در بخش ویژگی‌ها تعریف کنید");return}if(i.variants.find(u=>!u.price||u.stock==null?!0:j.value.some(s=>ee(u,s)==null))){f.error("برای هر تنوع، قیمت، موجودی و مقادیر ویژگی‌ها الزامی است");return}}else if(!i.price){f.error("قیمت محصول را وارد کنید");return}try{const a=z.cloneDeep(i);if(x.value){const o=(i.variants??[]).map(s=>Number(s.price??0)),u=(i.variants??[]).map(s=>Number(s.stock??0));a.price=0,a.display_price=o.length?Math.min(...o):0,a.min_price=a.display_price,a.max_price=o.length?Math.max(...o):0,a.count=u.reduce((s,b)=>s+b,0),a.discount=null,a.discount_type=null,a.is_exist=u.some(s=>s>0)}else a.variants=[],a.discount_type=a.discount?"percent":null;O.value&&R.value?(await it(R.value,a),f.success("محصول با موفقیت ویرایش شد")):(await st(a),f.success("محصول با موفقیت افزوده شد")),le(),await ne(),await X()}catch(a){console.error("Error saving Product:",a),f.error("خطا در ذخیره محصول: "+(a.message||"خطای ناشناخته"))}}async function Oe(t){var e;H=z.cloneDeep(i),O.value=!0,R.value=t.id;try{const a=await ot(t.id);for(const o in i)a.hasOwnProperty(o)&&(i[o]=a[o]);i.type=(((e=a.variants)==null?void 0:e.length)??0)>0||a.type==="variant"?"variant":"simple",i.product_attributes=(a.product_attributes??[]).map(o=>{var u,s;return{...o,is_new:!1,attribute_name:((u=o.attributes)==null?void 0:u.name)??((s=o.attribute)==null?void 0:s.name)??"",temp_key:`temp_${o.attribute_id??o.id??Math.random()}`}}),i.variants=a.variants??[],i.discount_type=a.discount_type??"percent",P.value=a.original_image?[{uid:"-1",name:"original_image.jpg",status:"done",url:q(a.original_image),response:{path:a.original_image}}]:[],i.files=Array.isArray(a.files)?a.files.slice(1).map((o,u)=>({uid:`${u}`,name:`product_image${u}.jpg`,status:"done",url:q(o.url),response:{path:o.url}})):[],B.value=!0}catch(a){console.error("Error loading product:",a),f.error("خطا در بارگذاری اطلاعات محصول: "+(a.message||"خطای ناشناخته"))}}function Re(t){ct.confirm({title:"حذف محصول",content:`آیا مطمئن هستید که می‌خواهید محصول "${t.title}" را حذف کنید؟`,okText:"بله، حذف کن",cancelText:"انصراف",okType:"danger",centered:!0,onOk:async()=>{try{await rt(t.id),f.success("محصول با موفقیت حذف شد"),await X()}catch(e){console.error("Error deleting Product:",e),f.error("خطا در حذف محصول: "+(e.message||"خطای ناشناخته"))}}})}let H=z.cloneDeep(i);async function ne(){const{data:t,error:e}=await et.from("attributes").select("*, attribute_values(*)").order("id");if(e){console.error("Error loading features:",e),f.error("خطا در بارگذاری ویژگی‌ها");return}L.value=t??[]}return Qe(async()=>{Y.value=await ut(),Q.value=await dt(),await ne()}),(t,e)=>{const a=Ke,o=ze,u=pt,s=gt,b=wt,U=ft,A=vt,c=bt,J=mt,d=Ye("plus-outlined"),y=xt,C=He,V=_t,T=yt,ie=kt,Ne=ht,je=Ee;return p(),h("div",null,[m("div",Vt,[It,n(a,{type:"primary",onClick:Be},{default:r(()=>[I("افزودن محصول")]),_:1})]),n(o,Ze(ce.value,{ref:"table",onRegister:W(K)}),{text:r(({record:l})=>[n(de,{text:l.description},null,8,["text"])]),action:r(({record:l})=>[m("div",At,[n(W(ue),{class:"cursor-pointer"},{title:r(()=>[$t]),default:r(()=>[n(se,{icon:"vuesax-linear:trash",color:"#DC2626",onClick:k=>Re(l)},null,8,["onClick"])]),_:2},1024),n(W(ue),{class:"cursor-pointer"},{title:r(()=>[Lt]),default:r(()=>[n(se,{icon:"vuesax-linear:edit",color:"#1D4ED8",onClick:k=>Oe(l)},null,8,["onClick"])]),_:2},1024)])]),_:1},16,["onRegister"]),n(je,{visible:B.value,"onUpdate:visible":e[15]||(e[15]=l=>B.value=l),title:O.value?"ویرایش محصول":"افزودن محصول",onOk:Fe,onClose:e[16]||(e[16]=l=>le()),width:"80%","wrap-class-name":"product-modal-wrap",confirmLoading:D.value>0},{default:r(()=>[n(Ne,{layout:"vertical",class:"product-form grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3"},{default:r(()=>[n(s,{label:"عنوان فارسی",required:""},{default:r(()=>[n(u,{value:i.title_fa,"onUpdate:value":e[0]||(e[0]=l=>i.title_fa=l),placeholder:"عنوان فارسی محصول"},null,8,["value"])]),_:1}),n(s,{label:"عنوان انگلیسی"},{default:r(()=>[n(u,{value:i.title,"onUpdate:value":e[1]||(e[1]=l=>i.title=l),placeholder:"عنوان انگلیسی محصول"},null,8,["value"])]),_:1}),n(s,{label:"برند"},{default:r(()=>[n(b,{value:i.brand_id,"onUpdate:value":e[2]||(e[2]=l=>i.brand_id=l),placeholder:"انتخاب برند",options:_e.value,"show-search":"","filter-option":te},null,8,["value","options"])]),_:1}),n(s,{label:"کالکشن"},{default:r(()=>[n(b,{value:i.collection_id,"onUpdate:value":e[3]||(e[3]=l=>i.collection_id=l),placeholder:"انتخاب کالکشن",options:pe.value},null,8,["value","options"])]),_:1}),n(s,{label:"نوع محصول",class:"col-span-full"},{default:r(()=>[n(A,{value:i.type,"onUpdate:value":e[4]||(e[4]=l=>i.type=l),class:"product-form__radio-group",onChange:Ae},{default:r(()=>[n(U,{value:"simple"},{default:r(()=>[I("محصول ساده")]),_:1}),n(U,{value:"variant"},{default:r(()=>[I("محصول دارای تنوع")]),_:1})]),_:1},8,["value"]),x.value?(p(),h("div",Pt," در حالت تنوع، قیمت و موجودی کلی محصول استفاده نمی‌شود و برای هر تنوع جداگانه تعریف می‌شود. ")):$("",!0)]),_:1}),x.value?$("",!0):(p(),h(E,{key:0},[n(s,{label:"قیمت (تومان)"},{default:r(()=>[n(c,{value:i.price,"onUpdate:value":e[5]||(e[5]=l=>i.price=l),style:{width:"100%"},placeholder:"قیمت را وارد کنید",min:0},null,8,["value"])]),_:1}),n(s,{label:"تخفیف %"},{default:r(()=>[n(c,{value:i.discount,"onUpdate:value":e[6]||(e[6]=l=>i.discount=l),style:{width:"100%"},placeholder:"درصد تخفیف را وارد کنید",min:0,max:100},null,8,["value"])]),_:1}),n(s,{label:"تعداد موجودی محصول"},{default:r(()=>[n(c,{value:i.count,"onUpdate:value":e[7]||(e[7]=l=>i.count=l),style:{width:"100%"},placeholder:"تعداد موجودی محصول را وارد کنید",min:0},null,8,["value"])]),_:1})],64)),n(s,{label:"کد محصول"},{default:r(()=>[n(u,{value:i.code,"onUpdate:value":e[8]||(e[8]=l=>i.code=l),style:{width:"100%"},placeholder:"کد محصول را وارد کنید"},null,8,["value"])]),_:1}),n(s,{class:"col-span-full",label:"توضیحات محصول"},{default:r(()=>[n(J,{value:i.description,"onUpdate:value":e[9]||(e[9]=l=>i.description=l),rows:"4",placeholder:"توضیحات محصول"},null,8,["value"])]),_:1}),m("div",St,[n(s,{label:"تصویر اصلی",class:"mb-0"},{default:r(()=>[n(y,{"file-list":P.value,"onUpdate:fileList":e[10]||(e[10]=l=>P.value=l),"before-upload":De,"custom-request":Te,accept:"image/*","list-type":"picture-card","max-count":1},{default:r(()=>[P.value.length<1?(p(),h("div",Mt,[n(d),Bt])):$("",!0)]),_:1},8,["file-list"])]),_:1}),n(s,{label:"فایل‌های محصول",class:"mb-0"},{default:r(()=>[n(y,{"file-list":i.files,"onUpdate:fileList":e[11]||(e[11]=l=>i.files=l),"before-upload":Se,"custom-request":Me,multiple:"","list-type":"picture-card"},{default:r(()=>[Dt]),_:1},8,["file-list"])]),_:1})]),n(s,{class:"col-span-full",label:"ویژگی‌های محصول"},{default:r(()=>[m("div",Tt,[(p(!0),h(E,null,G(i.product_attributes,(l,k)=>{var _;return p(),h("div",{key:k,class:"product-form__attr-card px-3 py-2 border rounded-md"},[m("div",Ft,[m("span",Ot,"ویژگی "+oe(k+1),1),n(C,{type:"link",danger:"",size:"small",onClick:g=>Ie(k)},{default:r(()=>[I("حذف")]),_:2},1032,["onClick"])]),n(A,{value:l.is_new,"onUpdate:value":g=>l.is_new=g,size:"small",class:"product-form__radio-group mb-2",onChange:()=>xe(l)},{default:r(()=>[n(U,{value:!1},{default:r(()=>[I("انتخاب از لیست")]),_:1}),n(U,{value:!0},{default:r(()=>[I("ویژگی جدید")]),_:1})]),_:2},1032,["value","onUpdate:value","onChange"]),l.is_new?(p(),S(u,{key:1,value:l.attribute_name,"onUpdate:value":g=>l.attribute_name=g,placeholder:"نام ویژگی جدید (مثلاً رنگ، سایز، جنس)",style:{width:"100%"},onChange:()=>Ce(l)},null,8,["value","onUpdate:value","onChange"])):(p(),S(b,{key:0,value:l.attribute_id,"onUpdate:value":g=>l.attribute_id=g,options:we(l.attribute_id),placeholder:"انتخاب ویژگی","show-search":"","filter-option":te,style:{width:"100%"},onChange:()=>Ue(l)},null,8,["value","onUpdate:value","options","onChange"])),Z(l)?(p(),S(b,{key:2,value:l.attribute_values,"onUpdate:value":g=>l.attribute_values=g,options:be(l),placeholder:l.use_in_variant?"مقادیر ویژگی برای تنوع (می‌توانید مقدار جدید تایپ کنید)":"انتخاب مقدار ویژگی",mode:"tags",style:{width:"100%"},class:"mt-2"},null,8,["value","onUpdate:value","options","placeholder"])):$("",!0),l.use_in_variant&&!((_=l.attribute_values)!=null&&_.length)?(p(),h("div",Rt," حداقل یک مقدار برای این ویژگی تعریف کنید تا در تنوع‌ها قابل انتخاب باشد. ")):$("",!0),m("div",Nt,[n(V,{checked:l.use_in_product_page,"onUpdate:checked":g=>l.use_in_product_page=g,checkedChildren:"نمایش در صفحه محصول",unCheckedChildren:"مخفی"},null,8,["checked","onUpdate:checked"]),x.value?(p(),S(V,{key:0,checked:l.use_in_variant,"onUpdate:checked":g=>l.use_in_variant=g,checkedChildren:"استفاده در تنوع",unCheckedChildren:"بدون تنوع",onChange:()=>Ve(l)},null,8,["checked","onUpdate:checked","onChange"])):$("",!0)])])}),128)),n(C,{type:"dashed",block:"",onClick:$e},{default:r(()=>[I("+ افزودن ویژگی")]),_:1})])]),_:1}),x.value?(p(),S(s,{key:1,class:"col-span-full",label:"تنوع‌های محصول"},{default:r(()=>[m("div",jt,[(p(!0),h(E,null,G(i.variants,(l,k)=>(p(),h("div",{key:k,class:"product-form__variant-card border rounded-md p-3 bg-gray-50"},[m("div",Et,[m("span",zt,"تنوع "+oe(k+1),1),n(C,{type:"link",danger:"",onClick:_=>Le(k)},{default:r(()=>[I("حذف")]),_:2},1032,["onClick"])]),n(ie,{gutter:[12,12]},{default:r(()=>[n(T,{xs:24,sm:24,md:8},{default:r(()=>[n(s,{label:"قیمت (تومان)",class:"mb-0"},{default:r(()=>[n(c,{value:l.price,"onUpdate:value":_=>l.price=_,style:{width:"100%"},min:0,placeholder:"قیمت"},null,8,["value","onUpdate:value"])]),_:2},1024)]),_:2},1024),n(T,{xs:24,sm:24,md:8},{default:r(()=>[n(s,{label:"تخفیف %",class:"mb-0"},{default:r(()=>[n(c,{value:l.discount,"onUpdate:value":_=>l.discount=_,style:{width:"100%"},min:0,max:100,placeholder:"تخفیف"},null,8,["value","onUpdate:value"])]),_:2},1024)]),_:2},1024),n(T,{xs:24,sm:24,md:8},{default:r(()=>[n(s,{label:"موجودی",class:"mb-0"},{default:r(()=>[n(c,{value:l.stock,"onUpdate:value":_=>l.stock=_,style:{width:"100%"},min:0,placeholder:"موجودی"},null,8,["value","onUpdate:value"])]),_:2},1024)]),_:2},1024)]),_:2},1024),n(ie,{gutter:[12,12],class:"mt-0"},{default:r(()=>[n(T,{xs:24,md:12},{default:r(()=>[n(s,{label:"کد SKU",class:"mb-0"},{default:r(()=>[n(u,{value:l.sku,"onUpdate:value":_=>l.sku=_,placeholder:"کد SKU"},null,8,["value","onUpdate:value"])]),_:2},1024)]),_:2},1024),n(T,{xs:24,md:12},{default:r(()=>[n(s,{label:"تنوع پیش‌فرض",class:"mb-0"},{default:r(()=>[m("div",qt,[n(V,{checked:l.is_default,"onUpdate:checked":_=>l.is_default=_,"checked-children":"بله","un-checked-children":"خیر",onChange:_=>Pe(k,_)},null,8,["checked","onUpdate:checked","onChange"]),Kt])]),_:2},1024)]),_:2},1024)]),_:2},1024),j.value.length?(p(),h("div",Ht,[(p(!0),h(E,null,G(j.value,_=>(p(),S(s,{key:fe(_),label:ve(_),class:"mb-0"},{default:r(()=>[n(b,{value:ee(l,_),options:he(_),style:{width:"100%"},placeholder:"انتخاب مقدار","allow-clear":"","onUpdate:value":g=>ye(l,_,g)},null,8,["value","options","onUpdate:value"])]),_:2},1032,["label"]))),128))])):(p(),h("div",Jt," ابتدا در بخش ویژگی‌ها، ویژگی با گزینه «استفاده در تنوع» و مقادیرش را تعریف کنید. "))]))),128)),n(C,{type:"dashed",block:"",onClick:ae},{default:r(()=>[I("+ افزودن تنوع")]),_:1})])]),_:1})):$("",!0),m("div",Wt,[n(s,{label:"نمایش",class:"mb-0"},{default:r(()=>[n(V,{checked:i.is_show,"onUpdate:checked":e[12]||(e[12]=l=>i.is_show=l)},null,8,["checked"])]),_:1}),n(s,{label:"فعال",class:"mb-0"},{default:r(()=>[n(V,{checked:i.is_active,"onUpdate:checked":e[13]||(e[13]=l=>i.is_active=l)},null,8,["checked"])]),_:1}),n(s,{label:"موجود",class:"mb-0"},{default:r(()=>[n(V,{checked:i.is_exist,"onUpdate:checked":e[14]||(e[14]=l=>i.is_exist=l),disabled:x.value},null,8,["checked","disabled"])]),_:1})])]),_:1})]),_:1},8,["visible","title","confirmLoading"])])}}});const $a=Ut(Gt,[["__scopeId","data-v-af7d30d2"]]);export{$a as default};