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:flex-end; /* راست چین */
     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<option value="رهبری و مدیریت">رهبری و مدیریت</option>
    <option value="مراقبت و درمان">مراقبت و درمان</option>
    <option value="حمایت از گیرنده خدمت">حمایت از گیرنده خدمت</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>
</div>

   
 
<!-- جدول آرشیو -->
<table id="archiveTable">
    <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>
#archiveTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: Vazir, Tahoma;
    direction: rtl;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

#archiveTable thead {
    background: linear-gradient(90deg, #4facfe, #00f2fe);
    color: #fff;
    font-weight: 600;
    text-align: center;
}

#archiveTable thead th {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
}

#archiveTable tbody td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fff;
    transition: background-color 0.3s;
}

/*#archiveTable ردیف های زوج کمی روشن تر */
#archiveTable tbody tr:nthtbody tr:nth-child(even) td {
    background-color: #f9f9f9;
}

/* هاور روی سطر */
#archiveTable tbody tr:hover td {
    background-color: #e0f7ff;
}

/* گوشه های جدول */
#archiveTable thead tr:first-child th:first-child {#archiveTable tbody tr td a {
    color: #007bff;
    text-decoration: none;
    border-top-right-radiusfont-weight: 12px500;
}
#archiveTable theadtbody tr:first-child th:last-child td a:hover {
    border-top-left-radiustext-decoration: 12pxunderline;
}
#archiveTable tbody tr:last-child td:first-child</style>

<script>
// زیرمحورها
const zirmohvarOptions = {
  "رهبری  border-bottom-right-radius: 12px;
}
#archiveTable tbody tr:last-child td:last-child {
    border-bottom-left-radius: 12px;
}

#archiveTable tbody tr td a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}
#archiveTable tbody tr td a:hover {
    text-decoration: underline;
}
</style>

<script>
// آرشیو زیرمحورها
const zirmohvarOptions = {
  "رهبری و مدیریت": [
    "رهبری و مدیریت کیفیت",
    "مدیریت خطر، حوادث و بلایا",
    "مدیریت منابع انسانی و سلامت حرفه‌ای",
    "مدیریت خدمات پرستاری",
    "فناوری و مدیریت اطلاعات سلامت",
    "بهداشت محیط",
    "مدیریت تجهیزات پزشکی"
  ],
  "مراقبت و درمان": [
    "مراقبت‌های عمومی بالینی",
    "مراقبت‌های حاد و اورژانس",
    "مراقبت‌های جراحی و بیهوشی",
    "مراقبت‌های مادر و نوزاد",
    "پیشگیری و کنترل عفونت",
    "مدیریت دارویی",
    "خدمات تصویربرداری",
    "خدمات آزمایشگاه",
    "طب انتقال خون",
    "خدمات سرپایی"
  ],
  "حمایت از گیرنده خدمت": [
    "تأمین تسهیلات برای گیرنده خدمت",
    "احترام به حقوق گیرنده خدمت"
  ]
};

// آپدیت زیرمحورها بر اساس محور انتخابی
function updateSubAxis() {
    const filterAxis = document.getElementById("filterAxis");
    const filterSubAxis = document.getElementById("filterSubAxis");
    const selectedAxis = filterAxis.value;

    filterSubAxis.innerHTML = `<option value="">انتخاب زیرمحور</option>`;

    if (selectedAxis && zirmohvarOptions[selectedAxis]) {
        zirmohvarOptions[selectedAxis].forEach(sub => {
            const opt = document.createElement("option");
            opt.value = sub;
            opt.textContent = sub;
            filterSubAxis.appendChild(opt);
        });
    }

    filterSubAxis.value = ""; // ریست زیرمحور
}

// فیلتر جدول با مقادیر فارسی
function filterTable() {
    const axis = document.getElementById("filterAxis").value;
    const subAxis = document.getElementById("filterSubAxis").value;

    const rows = document.querySelectorAll("#archiveBody tr");
    rows.forEach(row => {
        const rowAxis = row.cells[0].textContent.trim();
        const rowSub = row.cells[1].textContent.trim();

        let show = true;
        if (axis && rowAxis !== axis) show = false;
        if (subAxis && rowSub !== subAxis) show = false;

        row.style.display = show ? "" : "none";
    });
}

// بارگذاری داده آرشیو از فایل JSON
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 txt = await fetch(data.results[0]._links.download, {
        credentials: 'include'
    }).then(r => r.text());

    return JSON.parse(txt);
}

// پر کردن جدول با داده‌ها
async function populateArchiveTable() {
    const tbody = document.getElementById('archiveBody');
    tbody.innerHTML = "";

    const archive = await loadArchive();

    archive.forEach(r => {
        const tr = document.createElement("tr");

       tr.innerHTML = `
    <td>${r.mahvar || "-"}</td>
    <td>${r.zirmohvar || "-"}</td>
    <td>${r.komiteh || "-"}</td>
    <td>${r.document_name || "-"}</td>
    <td>${r.noe_sanad || "-"}</td>
    <td>${r.date_last_edit || "-"}</td> <!-- تغییر داده شد -->
    <td>${r.date_revision || "-"}</td>
    <td>${r.date_update || "-"}</td> <!-- تغییر داده شد -->
    <td>${و مدیریت": ["رهبری و مدیریت کیفیت","مدیریت خطر، حوادث و بلایا","مدیریت منابع انسانی و سلامت حرفه‌ای","مدیریت خدمات پرستاری","فناوری و مدیریت اطلاعات سلامت","بهداشت محیط","مدیریت تجهیزات پزشکی"],
  "مراقبت و درمان": ["مراقبت‌های عمومی بالینی","مراقبت‌های حاد و اورژانس","مراقبت‌های جراحی و بیهوشی","مراقبت‌های مادر و نوزاد","پیشگیری و کنترل عفونت","مدیریت دارویی","خدمات تصویربرداری","خدمات آزمایشگاه","طب انتقال خون","خدمات سرپایی"],
  "حمایت از گیرنده خدمت": ["تأمین تسهیلات برای گیرنده خدمت","احترام به حقوق گیرنده خدمت"]
};

// بروزرسانی زیرمحورها
function updateSubAxis() {
    const filterAxis = document.getElementById("filterAxis");
    const filterSubAxis = document.getElementById("filterSubAxis");
    const selectedAxis = filterAxis.value;
    filterSubAxis.innerHTML = `<option value="">انتخاب زیرمحور</option>`;
    if (selectedAxis && zirmohvarOptions[selectedAxis]) {
        zirmohvarOptions[selectedAxis].forEach(sub => {
            const opt = document.createElement("option");
            opt.value = sub;
            opt.textContent = sub;
            filterSubAxis.appendChild(opt);
        });
    }
    filterSubAxis.value = "";
    filterTable();
}

// فیلتر جدول
function filterTable() {
    const axis = document.getElementById("filterAxis").value;
    const subAxis = document.getElementById("filterSubAxis").value;
    const rows = document.querySelectorAll("#archiveBody tr");
    rows.forEach(row => {
        const rowAxis = row.cells[0].textContent.trim();
        const rowSub = row.cells[1].textContent.trim();
        let show = true;
        if (axis && rowAxis !== axis) show = false;
        if (subAxis && rowSub !== subAxis) show = false;
        row.style.display = show ? "" : "none";
    });
}

// بارگذاری JSON آرشیو
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 txt = await fetch(data.results[0]._links.download, { credentials: 'include' }).then(r => r.text());
    return JSON.parse(txt);
}

// آپدیت جدول بدون اضافه کردن ردیف جدید
async function populateOrUpdateArchiveTable() {
    const tbody = document.getElementById('archiveBody');
    const archive = await loadArchive();

    archive.forEach(r => {
        // جستجو ردیف موجود بر اساس عنوان سند
        let tr = Array.from(tbody.rows).find(row => row.cells[3].textContent.trim() === r.document_name);

        if (!tr) {
            // اگر ردیف وجود نداشت، بساز
            tr = document.createElement("tr");
            tbody.appendChild(tr);
            tr.innerHTML = `
                <td>${r.mahvar || "-"}</td>
                <td>${r.zirmohvar || "-"}</td>
                <td>${r.komiteh || "-"}</td>
                <td>${r.document_name || "-"}</td>
                <td>${r.noe_sanad || "-"}</td>
                <td>${r.date_last_edit || "-"}</td>
                <td>${r.date_revision || "-"}</td>
                <td>${r.date_update || "-"}</td>
                <td>${r.standard_no || "00"}</td>
                <td><a href="${r.document_file}" target="_blank">دانلود</a></td>
            `;
        } else {
            // اگر ردیف موجود بود، فقط مقادیر سلول‌ها را آپدیت کن
            tr.cells[0].textContent = r.mahvar || "-";
            tr.cells[1].textContent = r.zirmohvar || "-";
            tr.cells[2].textContent = r.komiteh || "-";
            tr.cells[4].textContent = r.noe_sanad || "-";
            tr.cells[5].textContent = r.date_last_edit || "-";
            tr.cells[6].textContent = r.date_revision || "-";
            tr.cells[7].textContent = r.date_update || "-";
            tr.cells[8].textContent = r.standard_no || "00"}</td>
;
           <td><a href="${ tr.cells[9].querySelector("a").href = r.document_file}" target="_blank">دانلود</a></td>
`;

        tbody.appendChild(tr); || "#";
        }
    });

    // بعد از آپدیت، فیلتر را اعمال کن
    }filterTable();
}

// بارگذاری اولیه
document.addEventListener("DOMContentLoaded", populateArchiveTablepopulateOrUpdateArchiveTable);

</script>