Files
machartaa_admin_dist/dist/assets/index-4d3a2841.js
T
2026-06-18 17:05:42 +03:30

2 lines
26 KiB
JavaScript

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