You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2 lines
12 KiB

  1. "use strict";(self["webpackChunkLightAble"]=self["webpackChunkLightAble"]||[]).push([[825],{4173:function(e,t,a){a.r(t),a.d(t,{default:function(){return ne}});var l=a(6768),o=a(5130),s=a(4232);const n={class:"col-md-12"},c={class:"card shadow-sm border-0 rounded"},r={class:"card-header d-flex justify-content-between align-items-center p-3 bg-primary text-white",dir:"rtl"},d={class:"d-flex align-items-center"},u={class:"card-body table-border-style p-0"},i={key:0,class:"table-responsive"},b={class:"table table-hover table-bordered m-0",dir:"rtl"},p=["onClick"],m=["onClick"],j={key:1,class:"filter-loader card table-card user-profile-list"};function k(e,t,a,k,v,g){const h=(0,l.g2)("addSubject"),L=(0,l.g2)("editSubject"),f=(0,l.g2)("BRow"),y=(0,l.g2)("Layout");return(0,l.uX)(),(0,l.Wv)(y,null,{default:(0,l.k6)((()=>[(0,l.bF)(f,null,{default:(0,l.k6)((()=>[(0,l.Lk)("div",n,[(0,l.Lk)("div",c,[(0,l.Lk)("div",r,[(0,l.Lk)("div",d,[(0,l.bo)((0,l.Lk)("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>k.searchQuery=e),type:"text",placeholder:"جستجو...",class:"form-control form-control-sm d-inline-block me-2",style:{width:"250px","border-radius":"15px"}},null,512),[[o.Jo,k.searchQuery]]),t[3]||(t[3]=(0,l.Lk)("button",{"data-bs-toggle":"modal","data-bs-target":"#addSubject",class:"btn btn-light text-primary btn-sm px-3"}," افزودن موضوع ",-1))])]),(0,l.Lk)("div",u,[k.filterLoading?((0,l.uX)(),(0,l.CE)("div",j)):((0,l.uX)(),(0,l.CE)("div",i,[(0,l.Lk)("table",b,[t[4]||(t[4]=(0,l.Lk)("thead",{class:"table-light"},[(0,l.Lk)("tr",null,[(0,l.Lk)("th",null,"شناسه"),(0,l.Lk)("th",null,"موضوع"),(0,l.Lk)("th",null,"موضوع به انگلیسی"),(0,l.Lk)("th",null,"تاریخ ایجاد"),(0,l.Lk)("th",null,"عملیات")])],-1)),(0,l.Lk)("tbody",null,[((0,l.uX)(!0),(0,l.CE)(l.FK,null,(0,l.pI)(k.subjects,(e=>((0,l.uX)(),(0,l.CE)("tr",{key:e.id},[(0,l.Lk)("td",null,(0,s.v_)(e.id),1),(0,l.Lk)("td",null,(0,s.v_)(e.subject),1),(0,l.Lk)("td",null,(0,s.v_)(e.subject_en),1),(0,l.Lk)("td",null,(0,s.v_)(k.convertToJalali(e.created_at)),1),(0,l.Lk)("td",null,[(0,l.Lk)("button",{onClick:t=>k.modalData(e?.subject,e?.subject_en,e?.id),"data-bs-toggle":"modal","data-bs-target":"#editSubject",class:"btn btn-sm btn-outline-warning me-1"}," ویرایش ",8,p),(0,l.Lk)("button",{onClick:t=>k.deleteLocation(e.id,e.subject),class:"btn btn-sm btn-outline-danger"}," حذف ",8,m)])])))),128))])])]))])])]),(0,l.bF)(h,{onSubjectUpdated:t[1]||(t[1]=e=>k.handleSubjectUpdate())}),(0,l.bF)(L,{subject:k.subject,en_subject:k.en_subject,id:k.subjectId,onSubjectUpdated:t[2]||(t[2]=e=>k.handleSubjectUpdate())},null,8,["subject","en_subject","id"])])),_:1})])),_:1})}var v=a(5814);const g={class:"modal fade",id:"addSubject",tabindex:"-1",role:"dialog","aria-labelledby":"exampleModalLabel","aria-hidden":"true"},h={class:"modal-dialog modal-sm",role:"document"},L={class:"modal-content"},f={class:"modal-body"},y={class:"form-group"},_={key:0,class:"text-danger"},C={class:"form-group"},x={key:0,class:"text-danger"},S={class:"d-flex justify-content-end gap-2",style:{"margin-top":"20px"}},R=["disabled"],B={key:0,class:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"};function E(e,t,a,n,c,r){const d=(0,l.g2)("BCol"),u=(0,l.g2)("BRow");return(0,l.uX)(),(0,l.CE)("div",g,[(0,l.Lk)("div",h,[(0,l.Lk)("div",L,[t[9]||(t[9]=(0,l.Lk)("div",{class:"modal-header"},[(0,l.Lk)("h5",{class:"modal-title",id:"exampleModalLabel"}," اضافه کردن موضوع جدید "),(0,l.Lk)("button",{type:"button",class:"btn-close","data-bs-dismiss":"modal","aria-label":"Close"})],-1)),(0,l.Lk)("div",f,[(0,l.Lk)("form",{onSubmit:t[4]||(t[4]=(0,o.D$)(((...e)=>n.addSubject&&n.addSubject(...e)),["prevent"]))},[(0,l.bF)(u,{class:"g-3"},{default:(0,l.k6)((()=>[(0,l.bF)(d,{class:"col-lg-6"},{default:(0,l.k6)((()=>[(0,l.Lk)("div",y,[t[5]||(t[5]=(0,l.Lk)("label",{class:"form-label"},"موضوع (فارسی)",-1)),(0,l.bo)((0,l.Lk)("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>n.subject=e),onInput:t[1]||(t[1]=e=>n.clearError("subject")),type:"text",class:"form-control",placeholder:"موضوع را وارد نمایید"},null,544),[[o.Jo,n.subject]]),n.errors.subject?((0,l.uX)(),(0,l.CE)("small",_,(0,s.v_)(n.errors.subject),1)):(0,l.Q3)("",!0)])])),_:1}),(0,l.bF)(d,{class:"col-lg-6"},{default:(0,l.k6)((()=>[(0,l.Lk)("div",C,[t[6]||(t[6]=(0,l.Lk)("label",{class:"form-label"},"موضوع (انگلیسی)",-1)),(0,l.bo)((0,l.Lk)("input",{"onUpdate:modelValue":t[2]||(t[2]=e=>n.en_subject=e),onInput:t[3]||(t[3]=e=>n.clearError("en_subject")),type:"text",class:"form-control",placeholder:"موضوع را به انگلیسی وارد نمایید"},null,544),[[o.Jo,n.en_subject]]),n.errors.en_subject?((0,l.uX)(),(0,l.CE)("small",x,(0,s.v_)(n.errors.en_subject),1)):(0,l.Q3)("",!0)])])),_:1})])),_:1}),(0,l.Lk)("div",S,[t[8]||(t[8]=(0,l.Lk)("button",{type:"button",class:"btn btn-secondary","data-bs-dismiss":"modal"}," بستن ",-1)),(0,l.Lk)("button",{type:"submit",class:"btn btn-primary",disabled:n.loading},[n.loading?((0,l.uX)(),(0,l.CE)("span",B)):(0,l.Q3)("",!0),t[7]||(t[7]=(0,l.eW)(" ذخیره "))],8,R)])],32)])])])])}var w=a(144),$=a(4373),A=a(4874),I=a.n(A),K=a(4084),X={setup(e,{emit:t}){const a=(0,w.KR)(),l=(0,w.KR)(),o=(0,w.KR)({}),s=(0,w.KR)(!1),n="https://api.nghsco.com/api",c=localStorage.getItem("token"),r=()=>(o.value={},a.value||(o.value.subject="وارد کردن موضوع ضروری می باشد"),l.value||(o.value.en_subject="وارد کردن موضوع به انگلیسی ضروری می باشد"),0===Object.keys(o.value).length),d=e=>{o.value[e]=""},u=()=>{if(!r())return;s.value=!0;const e=new FormData;e.append("subject",a.value),e.append("subject_en",l.value),$.A.post(`${n}/admin/add-subject`,e,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`}}).then((()=>{K.oR.success("موضوع با موفقیت اضافه شد!",{position:"top-right",autoClose:1e3,onClose:()=>t("subject-updated")})})).catch((e=>{console.error(e),I().fire({icon:"error",title:"خطا",text:`افزودن موضوع با مشکل مواجه شد: ${e.response?.data?.message||"خطای غیرمنتظره رخ داد."}`})})).finally((()=>{s.value=!1}))};return{errors:o,loading:s,clearError:d,addSubject:u,subject:a,en_subject:l}}},F=a(1241);const D=(0,F.A)(X,[["render",E],["__scopeId","data-v-d227fb82"]]);var U=D,Q=a(7366),M=a.n(Q);const T={class:"modal fade",id:"editSubject",tabindex:"-1",role:"dialog","aria-labelledby":"exampleModalLabel","aria-hidden":"true"},Y={class:"modal-dialog modal-sm",role:"document"},J={class:"modal-content"},V={class:"modal-body"},W={class:"form-group"},z={key:0,class:"text-danger"},q={class:"form-group"},O={key:0,class:"text-danger"},H={class:"d-flex justify-content-end gap-2",style:{"margin-top":"20px"}},G=["disabled"],N={key:0,class:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"};function P(e,t,a,n,c,r){const d=(0,l.g2)("BCol"),u=(0,l.g2)("BRow");return(0,l.uX)(),(0,l.CE)("div",T,[(0,l.Lk)("div",Y,[(0,l.Lk)("div",J,[t[9]||(t[9]=(0,l.Lk)("div",{class:"modal-header"},[(0,l.Lk)("h5",{class:"modal-title",id:"exampleModalLabel"}," ویرایش موضوع "),(0,l.Lk)("button",{type:"button",class:"btn-close","data-bs-dismiss":"modal","aria-label":"Close"})],-1)),(0,l.Lk)("div",V,[(0,l.Lk)("form",{onSubmit:t[4]||(t[4]=(0,o.D$)(((...e)=>n.editSubject&&n.editSubject(...e)),["prevent"]))},[(0,l.bF)(u,{class:"g-3"},{default:(0,l.k6)((()=>[(0,l.bF)(d,{class:"col-lg-6"},{default:(0,l.k6)((()=>[(0,l.Lk)("div",W,[t[5]||(t[5]=(0,l.Lk)("label",{class:"form-label"},"موضوع (فارسی)",-1)),(0,l.bo)((0,l.Lk)("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>n.localsubject=e),onInput:t[1]||(t[1]=e=>n.clearError("localsubject")),type:"text",class:"form-control",placeholder:"موضوع را وارد نمایید"},null,544),[[o.Jo,n.localsubject]]),n.errors.localsubject?((0,l.uX)(),(0,l.CE)("small",z,(0,s.v_)(n.errors.localsubject),1)):(0,l.Q3)("",!0)])])),_:1}),(0,l.bF)(d,{class:"col-lg-6"},{default:(0,l.k6)((()=>[(0,l.Lk)("div",q,[t[6]||(t[6]=(0,l.Lk)("label",{class:"form-label"},"موضوع (انگلیسی)",-1)),(0,l.bo)((0,l.Lk)("input",{"onUpdate:modelValue":t[2]||(t[2]=e=>n.local_en_subject=e),onInput:t[3]||(t[3]=e=>n.clearError("local_en_subject")),type:"text",class:"form-control",placeholder:"لطفا موضوع انگلیسی موقعیت را وارد نمایید"},null,544),[[o.Jo,n.local_en_subject]]),n.errors.local_en_subject?((0,l.uX)(),(0,l.CE)("small",O,(0,s.v_)(n.errors.local_en_subject),1)):(0,l.Q3)("",!0)])])),_:1})])),_:1}),(0,l.Lk)("div",H,[t[8]||(t[8]=(0,l.Lk)("button",{type:"button",class:"btn btn-secondary","data-bs-dismiss":"modal"}," بستن ",-1)),(0,l.Lk)("button",{type:"submit",class:"btn btn-primary",disabled:n.loading},[n.loading?((0,l.uX)(),(0,l.CE)("span",N)):(0,l.Q3)("",!0),t[7]||(t[7]=(0,l.eW)(" ذخیره "))],8,G)])],32)])])])])}var Z={props:{subject:{type:String,required:!0},en_subject:{type:String,required:!0},id:{type:String,required:!0}},setup(e,{emit:t}){const a=(0,w.lW)(e.subject),o=(0,w.lW)(e.en_subject),s=(0,w.lW)(e.id),n=(0,w.KR)({}),c=(0,w.KR)(!1),r="https://api.nghsco.com/api",d=localStorage.getItem("token");(0,l.wB)((()=>e.subject),(e=>a.value=e)),(0,l.wB)((()=>e.en_subject),(e=>o.value=e)),(0,l.wB)((()=>e.id),(e=>s.value=e));const u=()=>(n.value={},a.value||(n.value.localsubject="وارد کردن موضوع ضروری می باشد"),o.value||(n.value.local_en_subject="وارد کردن موضوع به انگلیسی ضروری می باشد"),0===Object.keys(n.value).length),i=e=>{n.value[e]=""},b=()=>{if(!u())return;c.value=!0;const e=new FormData;e.append("subject",a.value),e.append("subject_en",o.value),e.append("id",s.value),$.A.post(`${r}/admin/edit-subject`,e,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`}}).then((()=>{K.oR.success("موضوع با موفقیت ویرایش شد!",{position:"top-right",autoClose:1e3,onClose:()=>t("subject-updated")})})).catch((e=>{console.error(e),I().fire({icon:"error",title:"خطا",text:`ویرایش موضوع با مشکل مواجه شد: ${e.response?.data?.message||"خطای غیرمنتظره رخ داد."}`})})).finally((()=>{c.value=!1}))};return{errors:n,loading:c,clearError:i,editSubject:b,localsubject:a,local_en_subject:o}}};const ee=(0,F.A)(Z,[["render",P],["__scopeId","data-v-29d13d6c"]]);var te=ee;const ae=localStorage.getItem("token"),le="https://api.nghsco.com/api";var oe={name:"BORDER",components:{Layout:v.A,addSubject:U,editSubject:te},setup(){const e=(0,w.KR)(!1),t=(0,w.KR)(""),a=(0,w.KR)(),o=(0,w.KR)(),s=(0,w.KR)(),n=(0,w.KR)(),c=e=>M()(e,"YYYY-MM-DD HH:mm:ss").locale("fa").format("YYYY/MM/DD"),r=t=>{e.value=!0,$.A.get(`${le}/admin/subjects?search=${t?.value||""}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae} `}}).then((t=>{a.value=t.data,console.log(a.value),e.value=!1})).catch((()=>{e.value=!1}))};(0,l.wB)(t,(()=>{r(t)}));const d=()=>{location.reload()},u=(e,t)=>{I().fire({title:`می خواهید موضوع ${t} را حذف کنید ؟`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"بله!",cancelButtonText:"خیر"}).then((t=>{t.isConfirmed&&$.A.delete(`${le}/admin/delete-subject/${e}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae} `}}).then((()=>{K.oR.success("موضوع با موفقیت حذف شد",{position:"top-right",autoClose:3e3}),a.value=a.value.filter((t=>t.id!==e))})).catch((e=>{console.log(e),K.oR.error("مشکلی در حذف کردن موضوع پیش آمد",{position:"top-right",autoClose:3e3})}))}))},i=(e,t,a)=>{o.value=e,s.value=t,n.value=a};return(0,l.sV)((()=>{r()})),{subjects:a,convertToJalali:c,handleSubjectUpdate:d,modalData:i,subject:o,en_subject:s,subjectId:n,deleteLocation:u,searchQuery:t,filterLoading:e}}};const se=(0,F.A)(oe,[["render",k],["__scopeId","data-v-611f3b8f"]]);var ne=se}}]);
  2. //# sourceMappingURL=825.98a5938f.js.map