PageSourceSearch

https://seitai.co.jp/_nuxt/hmgx4Zib.js

js seitai.co.jp collected 2026-10-08 16:22:55 UTC 13,299 bytes, 1 lines download raw bytes

1import{d as le,a as ae,r as u,h as z,j as oe,k as re,l as o,m as t,n as d,E as m,G as h,f as L,I as Q,F as A,v as M,t as n,C as ne,p as R,R as q,o as r}from"#entry";import{u as ue}from"./BpJd073O.js";import"./BawYfsl-.js";import"./i1t3RLeJ.js";const ie={class:"p-6"},de={class:"mb-6 flex gap-4"},pe=["value"],ce={class:"bg-white rounded-lg shadow overflow-hidden"},ve={key:0,class:"p-8 text-center"},me={key:1,class:"p-8 text-center text-red-600"},ge={key:2},be={class:"min-w-full divide-y divide-gray-200"},xe={class:"bg-gray-50"},ye={key:0,class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},fe={class:"bg-white divide-y divide-gray-200"},_e={key:0,class:"px-6 py-4 whitespace-nowrap text-sm text-gray-500"},he={class:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"},we={class:"flex items-center gap-2"},ke={class:"px-6 py-4 whitespace-nowrap text-sm text-gray-500"},Se={class:"px-6 py-4 whitespace-nowrap"},Ce={class:"px-6 py-4 whitespace-nowrap text-sm text-gray-500"},Ue={class:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium"},Ve=["onClick"],Ae=["onClick"],Me={key:0,class:"px-6 py-4 flex items-center justify-between border-t border-gray-200"},$e={class:"text-sm text-gray-700"},je={class:"flex gap-2"},De=["disabled"],Te=["disabled"],Be={key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},Le={class:"bg-white rounded-lg p-6 w-full max-w-md max-h-[90vh] overflow-y-auto"},qe={class:"text-2xl font-bold mb-4"},Ee={class:"mb-4"},Oe=["value"],Ne=["value"],Fe={key:2,class:"mt-1 text-sm text-red-600"},Ie={class:"mb-4"},ze=["disabled"],Qe=["value","disabled"],Re={class:"text-sm text-gray-700"},Ge={key:0,class:"text-sm text-gray-500 text-center py-2"},Je={key:1,class:"absolute inset-0 flex items-center justify-center bg-white/70 rounded"},He={key:0,class:"mt-1 text-sm text-red-600"},Ke={class:"mb-4"},We={key:0,class:"mt-1 text-sm text-red-600"},Xe={class:"mb-4"},Ye={key:0,class:"mt-1 text-sm text-red-600"},Ze={class:"mb-4"},Pe={key:0,class:"mt-1 text-sm text-red-600"},et={class:"mb-4"},tt={class:"flex items-center"},st={class:"mb-4"},lt={class:"flex items-center"},at={class:"flex gap-4"},ot=["disabled"],pt=le({__name:"areas",setup(rt){const{get:$,post:G,put:J,delete:H}=ae(),{user:j,fetchUser:K}=ue(),E=u([]),D=u([]),g=u([]),T=u(!0),y=u(!1),w=u(null),p=u(null),k=u(""),S=u(1),C=u(""),i=u({}),_=z(()=>j.value?.role==="super_admin"),b=u(""),U=u(!1),x=u(null),V=u(!1),a=u({tenant_id:null,name:"",slug:"",description:"",is_published:!0,is_noindex:!1,store_ids:[]}),O=z(()=>{const s=b.value.trim().toLowerCase();return s?g.value.filter(e=>(e.name||"").toLowerCase().includes(s)):g.value}),W=s=>s?s.errors&&typeof s.errors=="object"?Object.entries(s.errors).reduce((e,[l,c])=>{const v=Array.isArray(c)?c[0]:c;return v&&(e[l]=String(v)),e},{}):s.message?{general:String(s.message)}:{}:{},f=async()=>{T.value=!0,w.value=null;try{const s=new URLSearchParams({page:S.value.toString(),per_page:"15"});k.value&&s.append("search",k.value),C.value&&s.append("tenant_id",String(C.value));const e=await $(`/master/areas?${s.toString()}`);E.value=e.data,p.value={current_page:e.current_page,last_page:e.last_page,from:e.from,to:e.to,total:e.total}}catch(s){w.value=s.message||"エリアの取得に失敗しました"}finally{T.value=!1}},X=async()=>{try{const s=await $("/master/tenants?per_page=200");D.value=s.data||[]}catch(s){console.error(s)}},B=async s=>{y.value=!0;try{const e=await $(`/master/area/stores?tenant_id=${s}`);g.value=e||[]}catch(e){g.value=[],console.error(e)}finally{y.value=!1}},N=(()=>{let s;return()=>{clearTimeout(s),s=setTimeout(()=>{S.value=1,f()},500)}})(),Y=()=>{S.value=1,f()};oe(()=>a.value.tenant_id,(s,e)=>{if(s===e)return;b.value="",!!x.value&&s===x.value?.tenant_id||(a.value.store_ids=[]),s?B(s):g.value=[]});const F=s=>{S.value=s,f()},Z=()=>{x.value=null,a.value={tenant_id:j?.value?.tenant_id??null,name:"",slug:"",description:"",is_published:!0,is_noindex:!1,store_ids:[]},b.value="",i.value={},U.value=!0,a.value.tenant_id?B(a.value.tenant_id):g.value=[]},P=s=>{x.value=s,a.value={tenant_id:s.tenant_id,name:s.name,slug:s.slug,description:s.description||"",is_published:!!s.is_published,is_noindex:!!s.is_noindex,store_ids:(s.stores||[]).map(e=>e.id)},b.value="",i.value={},U.value=!0,a.value.tenant_id?B(a.value.tenant_id):g.value=[]},I=()=>{U.value=!1,x.value=null,i.value={},g.value=[],b.value=""},ee=async()=>{V.value=!0,i.value={};
1try{const s=new Set(a.value.store_ids.map(v=>Number(v))),e=g.value.map(v=>Number(v.id)).filter(v=>s.has(v)),l=Array.from(s).filter(v=>!e.includes(v)),c={...a.value,tenant_id:a.value.tenant_id??null,store_ids:[...e,...l]};x.value?await J(`/master/areas/${x.value.id}`,c):await G("/master/areas",c),I(),f()}catch(s){const e=s.response?._data??s.response?.data,l=W(e);Object.keys(l).length>0?i.value=l:alert(s.message||"保存に失敗しました")}finally{V.value=!1}},te=async s=>{if(confirm(`エリア「${s.name}」を削除してもよろしいですか?`))try{await H(`/master/areas/${s.id}`),f()}catch(e){alert(e.message||"削除に失敗しました")}},se=s=>new Date(s).toLocaleDateString("ja-JP");return re(async()=>{await K(),_.value&&await X(),f()}),(s,e)=>(r(),o("div",ie,[e[30]||(e[30]=t("div",{class:"mb-6"},[t("h1",{class:"text-3xl font-bold text-gray-900"},"エリア管理"),t("p",{class:"mt-2 text-gray-600"},"エリアの作成・編集・削除を行います")],-1)),t("div",de,[m(t("input",{"onUpdate:modelValue":e[0]||(e[0]=l=>k.value=l),type:"text",placeholder:"エリア名またはスラッグで検索...",class:"flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",onInput:e[1]||(e[1]=(...l)=>L(N)&&L(N)(...l))},null,544),[[h,k.value]]),_.value?m((r(),o("select",{key:0,"onUpdate:modelValue":e[2]||(e[2]=l=>C.value=l),class:"min-w-[200px] px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",onChange:Y},[e[13]||(e[13]=t("option",{value:""},"全テナント",-1)),(r(!0),o(A,null,M(D.value,l=>(r(),o("option",{key:l.id,value:String(l.id)},n(l.name),9,pe))),128))],544)),[[Q,C.value]]):d("",!0),t("button",{onClick:Z,class:"px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"}," + 新規作成 ")]),t("div",ce,[T.value?(r(),o("div",ve,[...e[14]||(e[14]=[t("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"},null,-1),t("p",{class:"mt-4 text-gray-600"},"読み込み中...",-1)])])):w.value?(r(),o("div",me,n(w.value),1)):(r(),o("div",ge,[t("table",be,[t("thead",xe,[t("tr",null,[_.value?(r(),o("th",ye,"テナント名")):d("",!0),e[15]||(e[15]=t("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"エリア名",-1)),e[16]||(e[16]=t("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"スラッグ",-1)),e[17]||(e[17]=t("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"公開状況",-1)),e[18]||(e[18]=t("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"作成日",-1)),e[19]||(e[19]=t("th",{class:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"},"操作",-1))])]),t("tbody",fe,[(r(!0),o(A,null,M(E.value,l=>(r(),o("tr",{key:l.id,class:"hover:bg-gray-50"},[_.value?(r(),o("td",_e,n(l.tenant.name),1)):d("",!0),t("td",he,[t("div",we,[t("span",null,n(l.name),1)])]),t("td",ke,n(l.slug),1),t("td",Se,[t("span",{class:R([l.is_published?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800","px-2 py-1 text-xs font-semibold rounded-full"])},n(l.is_published?"公開":"非公開"),3)]),t("td",Ce,n(se(l.created_at)),1),t("td",Ue,[t("button",{onClick:c=>P(l),class:"text-blue-600 hover:text-blue-900 mr-4"},"編集",8,Ve),t("button",{onClick:c=>te(l),class:"text-red-600 hover:text-red-900"},"削除",8,Ae)])]))),128))])]),p.value?(r(),o("div",Me,[t("div",$e,n(p.value.from)+" - "+n(p.value.to)+" / "+n(p.value.total)+"ä»¶ ",1),t("div",je,[t("button",{onClick:e[3]||(e[3]=l=>F(p.value.current_page-1)),disabled:p.value.current_page===1,class:"px-4 py-2 border border-gray-300 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50"}," 前へ ",8,De),t("button",{onClick:e[4]||(e[4]=l=>F(p.value.current_page+1)),disabled:p.value.current_page===p.value.last_page,class:"px-4 py-2 border border-gray-300 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50"}," 次へ ",8,Te)])])):d("",!0)]))]),U.value?(r(),o("div",Be,[t("div",Le,[t("h2",qe,n(x.value?"ã
1‚¨ãƒªã‚¢ç·¨é›†":"エリア作成"),1),t("form",{onSubmit:ne(ee,["prevent"])},[t("div",Ee,[e[21]||(e[21]=t("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"テナント *",-1)),_.value?m((r(),o("select",{key:0,"onUpdate:modelValue":e[5]||(e[5]=l=>a.value.tenant_id=l),required:"",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"},[e[20]||(e[20]=t("option",{value:"",disabled:""},"選択してください",-1)),(r(!0),o(A,null,M(D.value,l=>(r(),o("option",{key:l.id,value:l.id},n(l.name),9,Oe))),128))],512)),[[Q,a.value.tenant_id,void 0,{number:!0}]]):(r(),o("input",{key:1,value:L(j)?.tenant?.name||"",type:"text",required:"",disabled:"",class:"w-full px-4 py-2 border border-gray-300 rounded-lg bg-gray-100 text-gray-600"},null,8,Ne)),i.value.tenant_id?(r(),o("p",Fe,n(i.value.tenant_id),1)):d("",!0)]),t("div",Ie,[e[23]||(e[23]=t("label",{class:"block text-sm font-medium text-gray-700 mb-2"}," 店舗(複数選択可) ",-1)),m(t("input",{"onUpdate:modelValue":e[6]||(e[6]=l=>b.value=l),type:"text",placeholder:"店舗名で検索...",class:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent mb-2",disabled:!a.value.tenant_id||y.value},null,8,ze),[[h,b.value]]),t("div",{class:R(["relative border border-gray-300 rounded-lg p-3 max-h-48 overflow-y-auto",{"opacity-50 pointer-events-none":y.value}])},[(r(!0),o(A,null,M(O.value,l=>(r(),o("label",{key:l.id,class:"flex items-center mb-2 cursor-pointer select-none"},[m(t("input",{type:"checkbox",value:l.id,"onUpdate:modelValue":e[7]||(e[7]=c=>a.value.store_ids=c),disabled:!a.value.tenant_id||y.value,class:"mr-2 accent-blue-500 cursor-pointer"},null,8,Qe),[[q,a.value.store_ids]]),t("span",Re,n(l.name),1)]))),128)),a.value.tenant_id&&!y.value&&O.value.length===0?(r(),o("div",Ge,n(b.value.trim()?"該当する店舗がありません":"店舗がありません"),1)):d("",!0),y.value?(r(),o("div",Je,[...e[22]||(e[22]=[t("span",{class:"text-sm text-gray-500"},"読み込み中...",-1)])])):d("",!0)],2),i.value.store_ids?(r(),o("p",He,n(i.value.store_ids),1)):d("",!0)]),t("div",Ke,[e[24]||(e[24]=t("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"エリア名 *",-1)),m(t("input",{"onUpdate:modelValue":e[8]||(e[8]=l=>a.value.name=l),type:"text",required:"",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"},null,512),[[h,a.value.name]]),i.value.name?(r(),o("p",We,n(i.value.name),1)):d("",!0)]),t("div",Xe,[e[25]||(e[25]=t("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"スラッグ *",-1)),m(t("input",{"onUpdate:modelValue":e[9]||(e[9]=l=>a.value.slug=l),type:"text",required:"",class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"test-storeなど"},null,512),[[h,a.value.slug]]),e[26]||(e[26]=t("p",{class:"mt-1 text-xs text-gray-500"}," ※ https://hub_cook.com/test-tenant/area/{slug} の {slug} の部分になります。 ",-1)),i.value.slug?(r(),o("p",Ye,n(i.value.slug),1)):d("",!0)]),t("div",Ze,[e[27]||(e[27]=t("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"説明",-1)),m(t("textarea",{"onUpdate:modelValue":e[10]||(e[10]=l=>a.value.description=l),class:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",rows:"3"},null,512),[[h,a.value.description]]),i.value.description?(r(),o("p",Pe,n(i.value.description),1)):d("",!0)]),t("div",et,[t("label",tt,[m(t("input",{"onUpdate:modelValue":e[11]||(e[11]=l=>a.value.is_published=l),type:"checkbox",class:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"},null,512),[[q,a.value.is_published]]),e[28]||(e[28]=t("span",{class:"ml-2 text-sm text-gray-700"},"公開する",-1))])]),t("div",st,[t("label",lt,[m(t("input",{"onUpdate:modelValue":e[12]||(e[12]=l=>a.value.is_noindex=l),type:"checkbox",class:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"},null,512),[[q,a.value.is_noindex]]),e[29]||(e[29]=t("span",{class:"ml-2 text-sm text-gray-700"},"noindex設定",-1))])]),t("div",at,[t("button",{type:"button",onClick:I,class:"flex-1 px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50"}," キャンセル "),t("button",{type:"submit",disabled:V.value,class:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},n(V.value?"保存中...":"保存"),9,ot)])],32)])])):d("",!0)]))}});
1export{pt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.