\documentclass{book}
\usepackage{titlesec,xcolor}
\usepackage{ptext}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}

\usepackage{xepersian}
\newcommand\titlebar{%
\tikz[baseline]{\node (a) at (-.93\textwidth,0) {a};
    \node [fill=red %,anchor=base east
   , minimum height=4ex ] {\setRTL
        \textbf{\color{white}\arabic{chapter}-\arabic{section}}
    };
}%
}
\titleformat{\section}[block]{\setRTL\Large\bfseries\color{red}}{\titlebar}{1.5cm}{\vspace*{-17mm}}[ color{red}\hrule height .3ex]%
\makeatletter
\renewcommand\@seccntformat[1]{\csname the#1\endcsname-\quad}
\renewcommand \thesection {\thechapter-\@arabic\c@section}
\renewcommand\thesubsection   {\thesection-\@arabic\c@subsection}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries\color{red}}}
\makeatother
\begin{document}
%\tableofcontents
\chapter{اولی}
\section{یک}\label{a1}
\ptext[1]
\section{دومی}
\ptext[2]
\subsection{سلام}\label{a2}
لینک به
 \ref{a1} and \ref{a2} ...
\end{document}