uepGetConflictDoc

This commit is contained in:
hsafaei 2026-02-14 13:30:05 +03:30
parent f88deee0c3
commit 79826b4a46
6 changed files with 135 additions and 30 deletions

View File

@ -23,5 +23,8 @@ export default {
},
data_entry:{
getSchema:"elp/schema/get"
},
conflict:{
get:"elp/conflict/{{type_name}}/get/text/{{doc_id}}"
}
};

View File

@ -129,7 +129,7 @@
</template>
<script setup>
import { ref, nextTick, onMounted, onBeforeUnmount } from "vue";
import { ref, nextTick, onMounted, onBeforeUnmount, watch } from "vue";
import {
Details,
DetailsContent,
@ -155,7 +155,7 @@ function isList(text) {
(line) =>
line.trim().startsWith("*") ||
line.trim().startsWith("-") ||
/^\d+\./.test(line.trim()),
/^\d+\./.test(line.trim())
);
}
@ -240,7 +240,16 @@ function formatContent(content) {
function generateDetailsHtml(item) {
let html = `<details class="custom-details" ${item.isOpen ? "open" : ""}>`;
html += `<summary>${escapeHtml(item.title) || "بدون عنوان"}</summary>`;
html += `<summary>`;
if (item.tag) {
html += `<span href="${item.tag}"/>`;
}
html += `${escapeHtml(item.title) || "بدون عنوان"}`;
if (item.link_url) {
html += `<a href="${item.link_url}">${item.link_label}</a>`;
}
html += "</summary>";
const formattedContent = formatContent(item.content || "");
html += `<div class="details-content">${formattedContent}</div>`;
@ -261,7 +270,7 @@ function loadFromJson() {
if (!editor.value) return;
let html =
'<p style="margin-bottom: 1.5rem; color: var(--color-dark-primary-700);">✨ اطلاعات محصول</p>';
'<p style="margin-bottom: 1.5rem; color: var(--color-dark-primary-700);"></p>';
props.accordionData.forEach((item) => {
html += generateDetailsHtml(item);
@ -269,7 +278,20 @@ function loadFromJson() {
editor.value.commands.setContent(html);
}
watch(
() => props.accordionData,
(newVal) => {
if (!editor.value) return;
if (!newVal || newVal.length === 0) return;
console.log("accordionData updated:", newVal);
nextTick(() => {
loadFromJson();
});
},
{ deep: true, immediate: true }
);
onMounted(() => {
editor.value = new Editor({
extensions: [
@ -313,8 +335,8 @@ onBeforeUnmount(() => {
/* فقط متغیرهای غیررنگ (سایه، انحنا، RGB اصلی) رنگ‌ها در main.css تعریف شده‌اند */
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
--shadow-md:
0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
--radius: 0.75rem;
--radius-sm: 0.5rem;
--radius-lg: 1rem;
@ -404,14 +426,8 @@ onBeforeUnmount(() => {
}
.tiptap {
font-family:
"Vazir",
"Inter",
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
sans-serif;
font-family: "Vazir", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, sans-serif;
color: var(--color-dark-primary-700);
line-height: 1.7;

View File

@ -6,25 +6,84 @@
</template>
<script setup>
import { ref, watch, onMounted } from "vue";
import { useElpService } from "~/composables/useElpService";
const { uepGetConflictDoc } = useElpService();
const props = defineProps({
listConflicts: {
type: Array,
default: () => [],
},
conflictSelected: {
type: Object,
default: () => {},
conflict_id: {
type: String,
default: () => "",
},
});
const accordionItems = [
let accordionItems = ref([
{
id: 1,
tag: "",
title: "عنوان",
link_label: "منبع",
link_url: "",
content: "متن",
isOpen: true,
children: [],
},
];
]);
const setDataEditor = async () => {
let response = await uepGetConflictDoc(props.conflict_id);
console.log("setDataEditor ", response);
let _source = response._source;
let base_url =
window.location.origin +
"/entity/show/view/qasection/{{qanon_id}}?jump_id={{section_id}}";
accordionItems.value = [];
if (_source.previous_info) {
let item = _source.previous_info;
accordionItems.value.push({
isOpen: false,
id: item.section_mom_id,
title: "قانون مقدم : " + item.qanon_title + " > " + item.full_path,
tag: item.state_etebar,
content: _source.content1,
link_label: "«منبع»",
link_url: base_url
.replace("{{qanon_id}}", item.qanon_id)
.replace("{{section_id}}", item.section_mom_id),
});
}
if (_source.next_info) {
let item = _source.next_info;
accordionItems.value.push({
isOpen: false,
id: item.section_mom_id,
title: "قانون موخر : " + item.qanon_title + " > " + item.full_path,
tag: item.state_etebar,
content: _source.content2,
link_label: "«منبع»",
link_url: base_url
.replace("{{qanon_id}}", item.qanon_id)
.replace("{{section_id}}", item.section_mom_id),
});
}
console.log("accordionItems", accordionItems.value);
};
// #region Lifecycle
onMounted(() => {
setDataEditor();
});
// #endregion
</script>
<style></style>

View File

@ -69,10 +69,37 @@ export function useElpService(props, emit) {
});
}
///-----------------------------------------------------
///--- با توجه به یک فیلد، مقدار محاسبه شده ای بر میگردند مثلا : بیشترین مقدار یا مجموع یا ...
///-----------------------------------------------------
async function uepGetConflictDoc(
doc_id,
key = "qaconflict"
) {
let url = elpApi.conflict.get;
url = url.replace("{{type_name}}", key);
url = url.replace("{{doc_id}}", doc_id);
return await httpService
.getRequest(url)
.then((res) => {
return res;
})
.catch(() => {
toast.add({
title: "خطا",
description: "خطا در انجام عملیات، دوباره تلاش کنید",
color: "red",
});
return undefined;
});
}
///-----------------------------------------------------
///-----------------------------------------------------
return {
uepUpdateField,
uepGetComputeField,
uepGetConflictDoc,
};
}

View File

@ -6,16 +6,16 @@ export const isLoginRemoved = () => process.env.VUE_APP_LOGIN_REMOVE == 1;
// util to export to excel file using plugin
// https://github.com/zheeeng/export-from-json
export const convertJsonToExcelUsingPlugin = async (
data,
fileName = "download"
) => {
// 'txt'(default), 'css', 'html', 'json', 'csv', 'xls', 'xml'
const exportType = exportFromJSON.types.xls;
const withBOM = true;
// export const convertJsonToExcelUsingPlugin = async (
// data,
// fileName = "download"
// ) => {
// // 'txt'(default), 'css', 'html', 'json', 'csv', 'xls', 'xml'
// const exportType = exportFromJSON.types.xls;
// const withBOM = true;
return await exportFromJSON({ data, fileName, exportType, withBOM });
};
// return await exportFromJSON({ data, fileName, exportType, withBOM });
// };
// util to export to excel file manually
export const exportJsonToExcelManually = (JSONData, FileTitle, ShowLabel) => {

View File

@ -14,7 +14,7 @@
v-if="currentComponent"
:activeTabKey="activeTabKey"
:listConflicts="listConflicts"
:conflictSelected="conflictSelected"
:conflict_id="conflictSelected?._id"
@conflict-details="conflictDetails"
/>
</div>
@ -136,7 +136,7 @@ const getListConflict = async (textSearch = "", filterExtended = "") => {
}
};
function conflictDetails(event) {
conflictSelected.value = event;
conflictSelected.value = event.item;
activeTabKey.value = "RelationEdit";
console.log("event", event);
}