PageSourceSearch

https://ottisk.com/wp-content/themes/wp-ottisk/assets/PriceTable-oceD4jb6-task13751-urg13746v3.js

js ottisk.com collected 2026-10-08 21:59:12 UTC 19,535 bytes, 33 lines download raw bytes

1var ve=Object.defineProperty,we=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var ne=(e,r,n)=>r in e?ve(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,y=(e,r)=>{for(var n in r||(r={}))re.call(r,n)&&ne(e,n,r[n]);if(L)for(var n of L(r))ie.call(r,n)&&ne(e,n,r[n]);return e},w=(e,r)=>we(e,Ce(r));var A=(e,r)=>{var n={};for(var i in e)re.call(e,i)&&r.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&L)for(var i of L(e))r.indexOf(i)<0&&ie.call(e,i)&&(n[i]=e[i]);return n};var j=(e,r,n)=>new Promise((i,a)=>{var s=c=>{try{m(n.next(c))}catch(b){a(b)}},f=c=>{try{m(n.throw(c))}catch(b){a(b)}},m=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,f);m((n=n.apply(e,r)).next())});import{b8 as xe,b9 as De,r as S,ba as ae,bb as Ie,a2 as _e,a as t,bc as ue,j as h,g as ke,bd as M,I as P,be as Be,F as V,o as Fe,n as Pe,bf as Ne,am as oe,bg as Te,$ as he,bh as q,bi as Re,bj as me,bk as Oe,bl as Ee,v as ge,af as He,ai as N,bm as se,bn as ze,bo as Ae,T as J,bp as je,bq as qe,br as $e,bs as Le,bt as Je,ae as ee}from"./main-qYKO7pVA-task13751-urg13746v3.js";import{u as fe}from"./AdminPageSelector-psD5m2fx-task13751-urg13746v3.js";import{SelSpan as Ue}from"./promopage-BgSm1zDU-task13751-urg13746v3.js";import{T as be,d as ye,b as B,a as T}from"./TableElements-z4KxRjx4-task13751-urg13746v3.js";import{O as Ge}from"./FloatingForm-CyaJ8rzE-task13751-urg13746v3.js";import{D as ce}from"./decimal-DdqQRotv-task13751-urg13746v3.js";import{H as Me}from"./chunk-O7JH6DZT-DzCf-U6J-task13751-urg13746v3.js";import"./FAButton-C26iVK0A-task13751-urg13746v3.js";var Ve={horizontal:{"> *:first-of-type:not(:last-of-type)":{borderEndRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderStartRadius:0}},vertical:{"> *:first-of-type:not(:last-of-type)":{borderBottomRadius:0},"> *:not(:first-of-type):not(:last-of-type)":{borderRadius:0},"> *:not(:first-of-type):last-of-type":{borderTopRadius:0}}},We={horizontal:e=>({"& > *:not(style) ~ *:not(style)":{marginStart:e}}),vertical:e=>({"& > *:not(style) ~ *:not(style)":{marginTop:e}})},Se=xe(function(r,n){const F=r,{size:i,colorScheme:a,variant:s,className:f,spacing:m="0.5rem",isAttached:c,isDisabled:b,orientation:C="horizontal"}=F,x=A(F,["size","colorScheme","variant","className","spacing","isAttached","isDisabled","orientation"]),p=De("chakra-button__group",f),I=S.useMemo(()=>({size:i,colorScheme:a,variant:s,isDisabled:b}),[i,a,s,b]);let D=y({display:"inline-flex"},c?Ve[C]:We[C](m));const E=C==="vertical";return ae.jsx(Ie,{value:I,children:ae.jsx(_e.div,y({ref:n,role:"group",__css:D,className:p,"data-attached":c?"":void 0,"data-orientation":C,flexDir:E?"column":void 0},x))})});Se.displayName="ButtonGroup";const Ye="_tableHolder_113q6_1",Ke="_selectionHolder_113q6_10",Qe="_printHidden_113q6_18",Xe="_underButton_113q6_23",Ze="_underDiv_113q6_40",et="_tableee_113q6_48",O={tableHolder:Ye,selectionHolder:Ke,printHidden:Qe,underButton:Xe,underDiv:Ze,tableee:et},tt=({children:e})=>t("div",{className:O.tableHolder,children:e}),nt=({children:e})=>t("div",{className:O.selectionHolder,children:e}),rt=({children:e})=>t("div",{className:O.printHidden,children:e}),it=({children:e})=>t("div",{className:O.underDiv,children:e}),Z=i=>{var a=i,{children:e,className:r=""}=a,n=A(a,["children","className"]);return t("button",w(y({},n),{className:ue(O.underButton,r),children:e}))},at=i=>{var a=i,{children:e,className:r=""}=a,n=A(a,["children","className"]);return t("table",w(y({className:ue(O.tableee,r)},n),{children:e}))},ot=({values:e,onChange:r})=>h("table",{style:{marginBottom:0,width:"100%",border:`${ke.primary} thin solid`},children:[t("thead",{children:h(be,{children:[t("th",{children:"Кол-во"}),t("th",{children:"Наценка, %"})]})}),t("tbody",{children:Object.entries(e).map(([n,i])=>h(ye,{children:[t(B,{children:n}),t(B,{style:{width:"100px"},children:t(M,{className:"FormInput FormInput-text",type:"text",onChange:a=>{r(n,a.target.value)},value:i})})]}))})]}),st=e=>e.type==="price"||!("origprice"in e),U=e=>e.type==="count"||"origprice"in e,ct=e=>{switch(e){case"printers":return"Стоимость печати";case"paperdigital":return"Бумага для цифровой печати";case"paperwide":return"Бумага для ш/форматной печати";case"paperpagewide":return"Бумага для Pagewide";case"postservice":return"Стоимость постпечатных материалов";case"postmaterial":return"Стоимость постпечатных услуг";case"lamination":return"Пакетное ламинирование";case"other":return"Другие услуги";case"paperdesign":return"Дизайнерская бумага";case"opt":return"Оптовые наценки";case"cardCutPercent":return"Процент за резку визиток";case"launch-and-packaging":return"Запуск и упаковка заказа";case"deadline-prices":return"Доплата за срочность";default:return e}},R=e=>e.replace(",",".").replace(/[^0-9.]/,""),te=(e,r)=>{var a,s;const n=new ce(parseFloat((a=e==null?void 0:e.toString())!=null?a:0)),i=new ce(parseFloat((s=r==null?void 0:r.toString())!=null?s:0));return n.mul(i).mul(100).ceil().div(100).toString()},le=e=>e?parseFloat(e.toString()):0,lt=({label:e,value:r,onChange:n,required:i=!1})=>{const[a,s]=S.useState(r),f=c=>{s(c.replace(/[^0-9.,]/g,""))};return S.useEffect(()=>{s(r)},[r]),t(P,{label:e,value:a,onChange:f,onBlur:()=>{n==null||n(parseFloat(a.replace(",",".")).toFixed(2)||"0")},required:i,type:"number"})},dt=(e,r)=>{const n=e||{id:"",name:"",price:0,type:r};if(n.type)return n;if(r==="count"){const{origprice:f=0,addition:m=1}=n;return w(y({},n),{type:r,origprice:f,addition:m,price:le(f)*le(m)})}const{id:i,name:a,price:s}=n;return{id:i,name:a,price:s,type:"price"}},pt=({item:e=void 0,type:r="price",action:n="add",onSubmit:i})=>{var b,C,x;const[a,s]=S.useState(dt(e,r)),f=()=>{i(a)};S.useEffect(()=>
1{s(p=>p.type==="count"?w(y({},p),{price:te(p.origprice,p.addition)}):p)},[a.origprice,a.addition,a.type]);const m=(p,I)=>{s(D=>w(y({},D),{[p]:I}))},c=n==="edit";return h(V,{children:[t(P,{label:"id",value:a.id,onChange:p=>m("id",p),required:!0,readonly:c}),t(P,{label:"Наименование",value:a.name,onChange:p=>m("name",p),required:!0}),t(Be,{label:"Тип",options:[{name:"Расчётная цена",id:"count"},{name:"Стандартная цена",id:"price"}],onChange:p=>m("type",p),value:a.type}),a.type==="price"&&t(lt,{label:"Цена",value:a.price.toString(),onChange:p=>m("price",R(p)),required:!0}),a.type==="count"&&h(V,{children:[t(P,{label:"Цена закупки",value:(b=a.origprice)==null?void 0:b.toString(),onChange:p=>m("origprice",R(p)),required:!0}),t(P,{label:"Множитель наценки",value:(C=a.addition)==null?void 0:C.toString(),onChange:p=>m("addition",R(p)),required:!0}),t(P,{label:"Цена",value:(x=a.price)==null?void 0:x.toString(),readonly:!0,required:!0})]}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:t(Fe,{onClick:f,children:"Сохранить"})})]})},ut=Pe.select`
2    background-color: #7e62b3;
3    color: white;
4    padding: 8px 12px;
5    border-radius: 5px;
6    border: none;
7    margin-left: 16px;
8    cursor: pointer;
9    font-size: 14px;
10    min-width: 200px;
11    appearance: none;
12    position: relative;
13    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
14    background-repeat: no-repeat;
15    background-position: right 12px top 50%;
16    background-size: 12px auto;
17
18    &:focus {
19        outline: none;
20        box-shadow:
21            0 0 0 2px white,
22            0 0 0 4px #7e62b3;
23    }
24
25    & option {
26        background-color: white;
27        color: #333;
28    }
29`,ht=({values:e,id:r,onChange:n})=>{const[i,a]=S.useState(!1),[s,f]=S.useState({field:"original",direction:"asc"}),m=r==="paperdigital"||r==="paperdesign",[c,b]=S.useState(null),[C,x]=S.useState(!1),[p,I]=S.useState(""),{user:D}=fe(),E=[...e].sort((o,u)=>{const g=s.direction==="asc"?1:-1;switch(s.field){case"name":return g*o.name.localeCompare(u.name);case"price":return g*(Number(o.price)-Number(u.price));case"id":return g*o.id.localeCompare(u.id);default:return 0}}),F=(o,u)=>{const g=[];for(const d of e)st(d)&&d.id===o&&(d.price=u),g.push(d);n(r,g)},_=(o,u)=>{const g=[];for(const d of e)U(d)&&d.id===o&&(d.origprice=u,d.price=te(d.origprice,d.addition)),g.push(d);n(r,g)},$=(o,u)=>{const g=[];for(const d of e)U(d)&&d.id===o&&(d.addition=u,d.price=te(d.origprice,d.addition)),g.push(d);n(r,g)},v=o=>{const u=[...e],g=e.findIndex(d=>d.id===o.id);g!==-1?u.splice(g,1,o):u.push(o),b(null),n(r,u)},W=o=>{const u=e.filter(g=>g.id!==o);n(r,u)},Y=o=>{b(o),console.log(o)},K=()=>{b({id:"",name:"",price:0,type:"price"}),console.log("creating")},H=(c==null?void 0:c.id)!=="",z=()=>{const u=p.split(`
30`).map(d=>d.trim()).filter(Boolean).map(d=>{const[Q,...l]=d.split(" ");return{id:Q,name:l.join(" "),price:0,type:"price"}}).filter(d=>d.id&&d.name),g=[...e,...u];b(null),I(""),x(!1),n(r,g)};return h("div",{children:[c&&h(Ge,{header:H?"Редактирование позиции в таблице":"Добавление позиции в таблицу",closeRequest:()=>{b(null),x(!1),I("")},children:[(D==null?void 0:D.admin)&&t(oe,{mb:4,children:t(Ne,{isChecked:C,onChange:o=>x(o.target.checked),colorScheme:"blue",children:"Массив позиций"})}),C&&(D!=null&&D.admin)?h(oe,{children:[t(Te,{children:"Перечислите id позиций и их названия, по одной на каждую строчку"}),t(he,{value:p,onChange:o=>I(o.target.value),placeholder:`kon3070-4+0 Konica 3070 SRA3 4+0
31kon3070-4+4 Konica 3070 SRA3 4+4`,rows:6,mb:4}),t(Z,{onClick:z,children:"Добавить позиции"})]}):t(pt,{onSubmit:v,type:m?"count":"price",action:H?"edit":"add",item:c})]}),h(at,{children:[h("colgroup",{children:[t("col",{width:i?"200px":"0",style:{width:i?"200px":"0",overflow:"hidden",transition:"width 0.3s ease",fontSize:.01}}),t("col",{}),t("col",{width:100}),t("col",{width:100}),t("col",{width:100}),t("col",{width:90})]}),t("thead",{children:h(be,{children:[t(T,{style:{fontSize:i?"1em":"0.001em",transition:"all 0.3s ease"},children:"ID"}),t(T,{children:"Наименование"}),t(T,{children:"Зак.цена"}),t(T,{children:"Множ.наценки"}),t(T,{children:"Цена"}),t(T,{children:"Действия"})]})}),t("tbody",{children:E.map(o=>h(ye,{children:[t(B,{style:{fontSize:i?"1em":"0.001em",transition:"all 0.3s ease"},children:o.id}),t(B,{children:o.name}),t(B,{children:U(o)&&t(M,{id:o.id,className:"FormInput FormInput-text",type:"text",onCh
31ange:u=>{_(o.id,R(u.target.value))},value:o.origprice})}),t(B,{children:U(o)&&t(M,{id:o.id,className:"FormInput FormInput-text",type:"text",onChange:u=>{$(o.id,R(u.target.value))},value:o.addition})}),t(B,{children:t(M,{id:o.id,className:"FormInput FormInput-text",type:"text",onChange:u=>{F(o.id,R(u.target.value))},readOnly:o.type==="count",value:o.price})}),t(B,{children:r!=="paperdesign"&&h(V,{children:[t(q,{size:"sm","aria-label":"Редактировать",title:"Редактировать",colorScheme:"yellow",onClick:()=>Y(o),children:t(Re,{})}),i&&t(q,{size:"sm","aria-label":"Удалить",title:"Удалить",colorScheme:"red",onClick:()=>W(o.id),ml:2,children:t(me,{})})]})})]}))})]}),h(it,{children:[h(Z,{onClick:()=>{a(!i)},children:[t(Oe,{style:{transition:"transform 0.2s ease",transform:i?"rotate(180deg)":"rotate(0deg)"}}),i?"Спрятать ID":"Показать ID"]}),h(ut,{value:s.field==="original"?"original":`${s.field}-${s.direction}`,onChange:o=>{if(o.target.value==="original")f({field:"original",direction:"asc"});else{const[u,g]=o.target.value.split("-");f({field:u,direction:g})}},children:[t("option",{value:"name-asc",children:"Наименование (по возр.)"}),t("option",{value:"name-desc",children:"Наименование (по убыв.)"}),t("option",{value:"price-asc",children:"Цена (по возр.)"}),t("option",{value:"price-desc",children:"Цена (по убыв.)"}),t("option",{value:"id-asc",children:"ID (по возр.)"}),t("option",{value:"id-desc",children:"ID (по убыв.)"}),t("option",{value:"original",children:"Исходная"})]}),r!=="paperdesign"&&h(Z,{onClick:K,children:[t(Ee,{}),"Добавить запись"]})]})]})},mt="_tabentry_14g5n_1",gt="_buttonstyle_14g5n_9",ft="_redbutton_14g5n_16",bt="_yellowbutton_14g5n_21",yt="_iconButton_14g5n_26",G={tabentry:mt,buttonstyle:gt,redbutton:ft,yellowbutton:bt,iconButton:yt},de=["printers","paperdigital","paperwide","paperpagewide","postservice","postmaterial","lamination","other","paperdesign","opt","cardCutPercent"],pe={printers:[],paperdigital:[],paperwide:[],paperpagewide:[],postservice:[],postmaterial:[],lamination:[],paperdesign:[],other:[],cardCutPercent:[],opt:{500:0,1e3:0,2e3:0,3e3:0,4e3:0,5e3:0,6e3:0,8e3:0,1e4:0,2e4:0,3e4:0,4e4:0,5e4:0,6e4:0,8e4:0,1e5:0}},St=()=>{const[e,r]=S.useState(null),[n,i]=S.useState(!1),{showSuccess:a,showError:s}=ge(),f=S.useCallback(()=>j(void 0,null,function*(){i(!0);try{const c=yield ee.get("/getPrices");c.status===200&&c.data&&r(wt(c.data)),i(!1)}catch(c){s("Не удалось получить данные"),i(!1)}}),[]);return{prices:e,setPrices:r,loading:n,fetchData:f,saveData:()=>j(void 0,null,function*(){if(e){i(!0);try{yield ee.post("/savePrices",{data:JSON.stringify(e)}),a("Цены успешно сохранены"),i(!1)}catch(c){s("Не удалось сохранить цены. Попробуйте ещё раз."),i(!1)}}})}},vt=(e,r)=>Array.isArray(e)?e.map(n=>{if(!Object.hasOwn(n,"type")){if(r==="paperdigital"||r==="paperdesign"){const{origprice:a=0,addition:s=1}=n;return w(y({},n),{type:"count",origprice:a,addition:s})}return w(y({},n),{type:"price"})}if(n.type==="count"){const a=n;return w(y({},n),{addition:a.addition||1})}return w(y({},n),{price:n.price.toString()})}):[],wt=e=>{const s=y(y({},pe),e),{opt:n}=s,i=A(s,["opt"]),a=Object.entries(i).reduce((f,[m,c])=>(f[m]=vt(c,m),f),{});return w(y(y({},pe),a),{opt:n})},Ct=()=>{const{prices:e,setPrices:r,loading:n,fetchData:i,saveData:a}=St(),[s,f]=S.useState("printers"),[m,c]=S.useState(!1),[b,C]=S.useState(""),[x,p]=S.useState(""),[I,D]=S.useState(!1),[E,F]=S.useState(!1),{showError:_,showSuccess:$}=ge(),{user:v}=fe(),W=window.location.hostname!=="ottisk.com";S.useEffect(()=>{i()},[i]);const Y=(l,k)=>{r(X=>w(y({},X),{[l]:k}))};//! Для оптовой таблицы
32//! Нужно добавть отдельно кнопку на добавление новых переменных в таблицу оптовых цен
33const K=(l,k)=>{e&&r(w(y({},e),{opt:w(y({},e.opt),{[l]:k})}))},H=e&&Object.keys(e).filter(l=>l!=="_titles").map(l=>({key:l,title:ct(l)})),z=e?e[s]:null,o=S.useCallback(l=>{f(l)},[]),u=()=>
33{if(!b.trim()){_("Введите id категории");return}if(e&&Object.keys(e).includes(b)){_("Такая категория уже есть");return}r(l=>w(y({},l),{[b]:[]})),f(b),c(!1),C("")},g=l=>{if(de.includes(l)){_("Эту категорию нельзя удалить");return}if(e){const k=y({},e);delete k[l],r(k),s===l&&f("printers"),$("Категория успешно удалена")}},d=()=>j(void 0,null,function*(){if(!x.trim()){_("Введите данные для замены цен");return}try{const l=JSON.parse(x);D(!0),yield ee.post("/replacePrices",{data:JSON.stringify(l)}),$("Цены успешно заменены"),yield i(),p("")}catch(l){_("Ошибка при замене цен. Проверьте формат данных.")}finally{D(!1)}}),Q=()=>j(void 0,null,function*(){if(!(!e||!(v!=null&&v.admin)))try{yield navigator.clipboard.writeText(JSON.stringify(e,null,2)),F(!0),setTimeout(()=>F(!1),2e3)}catch(l){_("Не удалось скопировать данные")}});return h(rt,{children:[n&&t(He,{}),h(nt,{children:[H&&H.map(({key:l,title:k})=>h("div",{style:{display:"inline-block",position:"relative",margin:"0.1em"},children:[t(Ue,{className:G.tabentry,onClick:()=>{o(l)},selected:s===l,children:k}),!de.includes(l)&&(v==null?void 0:v.admin)&&t(q,{icon:t(me,{}),"aria-label":"Удалить категорию",size:"xs",colorScheme:"red",position:"absolute",top:"-8px",right:"-8px",borderRadius:"full",onClick:X=>{X.stopPropagation(),g(l)}})]},l)),(v==null?void 0:v.admin)&&t(V,{children:m?h("div",{style:{display:"flex",alignItems:"center",marginLeft:8},children:[t("div",{style:{width:120,marginRight:4},children:t(P,{value:b,onChange:l=>C(l),placeholder:"id категории"})}),t(N,{className:G.tabentry,style:{height:32},onClick:u,children:"Сохранить"}),t(N,{className:G.tabentry,style:{height:32,marginLeft:4},onClick:()=>{c(!1),C("")},children:"Отмена"})]}):t(N,{className:G.tabentry,style:{marginLeft:8,height:32,alignSelf:"center"},onClick:()=>c(!0),children:"+ Новая категория"})})]}),z&&t(tt,{children:s==="opt"?t(ot,{values:z,onChange:K}):t(ht,{values:z,id:s,onChange:Y})}),W&&h(se,{spacing:4,marginY:4,p:4,border:"1px solid",borderColor:"gray.200",borderRadius:"md",children:[h(ze,{status:"warning",children:[t(Ae,{}),t(J,{fontSize:"sm",children:"Внимание: Эта функция доступна только на тестовом домене"})]}),h(se,{spacing:3,width:"100%",maxWidth:"800px",children:[t(J,{fontWeight:"bold",fontSize:"lg",children:"Заменить все цены"}),t(J,{fontSize:"sm",color:"gray.600",children:"Вставьте JSON-данные из запроса getPrices для полной замены всех цен"}),t(he,{value:x,onChange:l=>p(l.target.value),placeholder:"Вставьте JSON-данные для замены цен...",height:"200px",fontFamily:"mono",fontSize:"sm"}),h(Me,{spacing:3,children:[t(N,{colorScheme:"orange",onClick:d,isLoading:I,isDisabled:!x.trim()||I,leftIcon:t(je,{}),children:"Заменить все цены"}),t(N,{variant:"outline",onClick:()=>p(""),isDisabled:I,children:"Очистить"})]})]})]}),h(Se,{marginY:4,spacing:4,justifyContent:"center",mx:"auto",display:"flex",children:[t(q,{colorScheme:"red","aria-label":"Вернуть изменения (если не сохранены)",title:"Вернуть изменения (если не сохранены)",onClick:i,isDisabled:n,children:t(qe,{})}),h(N,{colorScheme:"brand",onClick:a,isDisabled:n,isLoading:n,children:[t(Le,{as:$e,mr:2})," Сохранить"]}),(v==null?void 0:v.admin)&&t(q,{colorScheme:"blue","aria-label":"Скопировать все цены",title:"Скопировать все цены в буфер обмена",onClick:Q,isDisabled:n||!e,children:t(Je,{})})]}),E&&(v==null?void 0:v.admin)&&t(J,{color:"green.500",fontSize:"sm",textAlign:"center",mt:2,children:"Скопированы все цены в буфер обмена"})]})},Tt=Ct;export{Tt as PriceManagerComponent,Ct as TablePage,Tt 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.