Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML
<!-- فونت وزیر -->
<link href="https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/font-face.css" rel="stylesheet" type="text/css" />



<!-- فیلترهای زیبا -->
<div id="search-filters" style="
     display:flex; justify-content:center; flex-wrap:wrap; 
     gap:10px; margin:25px 0; direction:rtl;">

  <select id="filterAxis" onchange="updateSubAxis(); filterTable()"
          style="flex:0 1 160px; padding:10px 15px; border-radius:25px; 
          border:1px solid #ccc; font-family:Vazir, Tahoma; font-size:14px;
          background:#fff; cursor:pointer;">
    <option value="">انتخاب محور</option>
    <option value="modiriyat">رهبری و مدیریت</option>
    <option value="mored">مراقبت و درمان</option>
    <option value="hemayat">حمایت از گیرنده خدمت</option>
  </select>

  <select id="filterSubAxis" onchange="filterTable()"
          style="flex:0 1 160px; padding:10px 15px; border-radius:25px; 
          border:1px solid #ccc; font-family:Vazir, Tahoma; font-size:14px;
          background:#fff; cursor:pointer;">
    <option value="">انتخاب زیرمحور</option>
  </select>
<table id="archiveTable" border="1" style="width:100%; border-collapse:collapse; text-align:center;">
    <thead>
        <tr>
            <th>محور</th>
            <th>زیرمحور</th>
            <th>کمیته</th>
            <th>عنوان سند</th>
            <th>نوع سند</th>
            <th>تاریخ ثبت اولیه</th>
            <th>تاریخ آخرین بازنگری</th>
            <th>تاریخ ویرایش</th>
            <th>کد ویرایش</th>
            <th>فایل</th>
        </tr>
    </thead>
    <tbody id="archiveBody"></tbody>
</table>


<!-- CSS جدول زیبا -->
<style>
#myTable {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: Vazir, Tahoma;
  direction: rtl;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 10px;
  overflow: hidden;
}
#myTable thead th {
  background-color: #f2f2f2;
  padding: 10px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid #ddd;
}
#myTable tbody td {
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid #eee;
}
#myTable tbody tr:nth-child(even) {
  background-color: #fafafa;
}
#myTable tbody tr:hover {
  background-color: #e6f7ff;
  transition: background-color 0.3s;
}
#myTable thead tr:first-child th:first-child { border-top-right-radius: 10px; }
#myTable thead tr:first-child th:last-child { border-top-left-radius: 10px; }
#myTable tbody tr:last-child td:first-child { border-bottom-right-radius: 10px; }
#myTable tbody tr:last-child td:last-child { border-bottom-left-radius: 10px; }
#search-filters select { transition: all 0.3s; }
#search-filters select:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
</style>

<script>

// نگاشت محورها به فارسی
const axisMap = {
    modiriyat: "رهبری و مدیریت",
    mored: "مراقبت و درمان",
    hemayat: "حمایت از گیرنده خدمت"
};

// وقتی محور انتخاب شد، زیرمحورها و جدول را آپدیت می‌کنیم
function updateSubAxis() {async function loadArchive() {
    const pageIdArchive = "85045557";
    const archiveName = "archive.json";

    const res = await fetch(`/rest/api/content/${pageIdArchive}/child/attachment?filename=${archiveName}`, {
        credentials: 'include',
        headers: { 'Accept': 'application/json' }
    });

    const data = await res.json();
    if (!data.results || !data.results.length) return [];

    const axisSelecttxt = document.getElementById('filterAxis'); await fetch(data.results[0]._links.download, {
        credentials: 'include'
    }).then(r => r.text());

    return JSON.parse(txt);
}

async function populateArchiveTable() {
    const subAxisSelecttbody = document.getElementById('filterSubAxisarchiveBody');
    tbody.innerHTML = "";

    //const مقدارarchive انتخاب= شدهawait loadArchive(کد محور);

    const selectedAxisaxisMap = axisSelect.value;

{
     // پر کردن زیرمحورهاmodiriyat: متناسب"رهبری باو محورمدیریت",
      subAxisSelect.innerHTML = '<optionmored: value="">انتخاب زیرمحور</option>';
مراقبت و درمان",
      // می‌توانید یکhemayat: map"حمایت برایاز زیرمحورهاگیرنده همخدمت"
 بسازید اگر لازم باشد
};

// فیلتر کردن جدول
function filterTable() archive.forEach(r => {
        const axisSelecttr = document.getElementById('filterAxis'createElement("tr");
        const subAxisSelectmahvarTitle = document.getElementById('filterSubAxis');
axisMap[r.mahvar] || "-";

       const tbodytr.innerHTML = document.getElementById('archiveBody');

`
            <td>${mahvarTitle}</td>
         const selectedAxis = axisSelect.value;<td>${r.zirmohvar || "-"}</td>
    const  selectedSubAxis = subAxisSelect.value;

    Array.from(tbody.rows).forEach(row => {
<td>${r.komiteh || "-"}</td>
         const mahvarCell = row.cells[0].textContent; // ستون محور فارسی
<td>${r.document_name || "-"}</td>
           const zirmohvarCell = row.cells[1].textContent; <td>${r.noe_sanad || "-"}</td>

        // چک کردن تطابق با محور و زیرمحور
 <td>${r.date_initial || "-"}</td>
         const show = (!selectedAxis <td>${r.date_revision || axisMap[selectedAxis] === mahvarCell)
"-"}</td>
            <td>${r.date_update || "-"}</td>

       && (!selectedSubAxis     <td>${r.revision_code || selectedSubAxis === zirmohvarCell);

 "00"}</td>
             row.style.display = show ? '' : 'none';<td><a href="${r.file}" target="_blank">دانلود</a></td>
        `;

    });
}

// وقتی DOM آماده شد جدول را پر می‌کنیم tbody.appendChild(tr);
    });
}

document.addEventListener("DOMContentLoaded", populateArchiveTable);
</script>