Files
tehran_taj/apps/admin-panel/dist/assets/cityList-DvHC9HZ5.js
T
2026-09-15 17:06:27 +03:30

2 lines
3.5 KiB
JavaScript

import{a as P,b as p,X as L}from"./model-B5c8wFLh.js";import{d as h,b as j,i as K,c as l,g as o,e as i,o as v,n as x,f as N,E as R,j as S,D as q,h as z,l as w,t as T,r as b,v as A,s as m,y,M as F}from"./index-Q3FR3cGM.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";function G(){const c=new P("admin/misc/cities/list","لیست شهر ها");return c.add(new p("title","نام شهر").filterKey("name").filterText()),c.add(new p("level","سطح").filterNumber().noSort()),c.add(new p("percent","درصد مشتری عمده").renderSlot("percent").noSort()),c.add(new p("percent_aux","درصد کارشناس فروش").renderSlot("percent_aux").noSort()),c.add(new p("opt","عملیات").noSort().renderSlot("opt")),c}const H={id:"page-user-list"},W=h({__name:"cityList",setup(c){const $=j(),k=t=>!!$.hasPermission(t),B=G(),_=b(null),d=b(!1),g=b(void 0),n=A({title:"",percent:null,percent_aux:null});async function U(t){g.value=t,n.title=t.title??"";try{const[e,s]=await Promise.all([m.get(`cities/get-percent/${t.id}`),m.get(`cities/get-percent-aux/${t.id}`)]);n.percent=e.data===null?null:Number(e.data),n.percent_aux=s.data===null?null:Number(s.data)}catch{n.percent=t.percent===null?null:Number(t.percent),n.percent_aux=t.percent_aux===null?null:Number(t.percent_aux)}d.value=!0}async function D(){var t,e,s,u;try{await m.put(`cities/${(t=g.value)==null?void 0:t.id}`,{title:n.title,percent:n.percent,percent_aux:n.percent_aux}),y.success("تغییرات ثبت شد"),d.value=!1,(e=_.value)==null||e.fetch()}catch(r){y.error(((u=(s=r==null?void 0:r.response)==null?void 0:s.data)==null?void 0:u.message)??"خطا در ثبت تغییرات")}}async function V(t){var e,s,u;try{await m.delete(`cities/${t}`),y.success("شهر حذف شد"),(e=_.value)==null||e.fetch()}catch(r){F.error({title:((u=(s=r==null?void 0:r.response)==null?void 0:s.data)==null?void 0:u.message)??"خطا در حذف شهر",okText:"بستن"})}}return(t,e)=>{const s=i("a-tooltip"),u=i("a-popconfirm"),r=i("a-input"),f=i("a-form-item"),C=i("a-input-number"),X=i("a-form"),E=i("a-modal"),M=i("a-card");return v(),K("div",H,[l(M,{title:"لیست شهر ها"},{default:o(()=>[l(L,{ref_key:"citiesTable",ref:_,model:x(B)},{percent:o(({text:a})=>[w(T(a??"-"),1)]),percent_aux:o(({text:a})=>[w(T(a??"-"),1)]),opt:o(({record:a})=>[k("cities.list.view.edit")?(v(),N(s,{key:0,title:"ویرایش"},{default:o(()=>[l(x(R),{class:"cursor-pointer mx-1 text-primary",onClick:O=>U(a)},null,8,["onClick"])]),_:2},1024)):S("",!0),k("cities.list.remove")?(v(),N(s,{key:1,title:"حذف"},{default:o(()=>[l(u,{placement:"top","ok-text":"بله","cancel-text":"خیر",onConfirm:O=>V(a.id)},{title:o(()=>[...e[4]||(e[4]=[z("p",null,"آیا مطمئن به حذف شهر مورد نظر هستید ؟",-1)])]),default:o(()=>[l(x(q),{class:"cursor-pointer mx-1 text-danger"})]),_:1},8,["onConfirm"])]),_:2},1024)):S("",!0)]),_:1},8,["model"]),l(E,{open:d.value,"onUpdate:open":e[3]||(e[3]=a=>d.value=a),title:"ویرایش شهر",onOk:D},{default:o(()=>[l(X,{layout:"vertical"},{default:o(()=>[l(f,{label:"نام شهر"},{default:o(()=>[l(r,{value:n.title,"onUpdate:value":e[0]||(e[0]=a=>n.title=a)},null,8,["value"])]),_:1}),l(f,{label:"درصد مشتری عمده"},{default:o(()=>[l(C,{value:n.percent,"onUpdate:value":e[1]||(e[1]=a=>n.percent=a),class:"w-full",step:.1},null,8,["value"])]),_:1}),l(f,{label:"درصد کارشناس فروش"},{default:o(()=>[l(C,{value:n.percent_aux,"onUpdate:value":e[2]||(e[2]=a=>n.percent_aux=a),class:"w-full",step:.1},null,8,["value"])]),_:1})]),_:1})]),_:1},8,["open"])]),_:1})])}}});export{W as default};