1320 lines
37 KiB
Vue
1320 lines
37 KiB
Vue
<template>
|
||
<div class="container-fluid">
|
||
<div class="row">
|
||
<!-- <div class="col-auto">
|
||
<div class="scroll-needed">
|
||
<ul class="sidebar-menu">
|
||
<li>
|
||
<a
|
||
href="javascript:void(0)"
|
||
@click.prevent="updateListSpecial('my_rules')"
|
||
class="text__14 sidebar-menu-link"
|
||
:class="{ active: activeMenu == 'my_rules' }"
|
||
>احکام من</a
|
||
>
|
||
</li>
|
||
|
||
<li>
|
||
<a
|
||
href="javascript:void(0)"
|
||
@click.prevent="updateListSpecial('modeled_rules')"
|
||
class="text__14 sidebar-menu-link"
|
||
:class="{ active: activeMenu == 'modeled_rules' }"
|
||
>احکام مدل شده</a
|
||
>
|
||
</li>
|
||
<li>
|
||
<a
|
||
href="javascript:void(0)"
|
||
@click.prevent="updateListSpecial('unmodeled_rules')"
|
||
class="text__14 sidebar-menu-link"
|
||
:class="{ active: activeMenu == 'unmodeled_rules' }"
|
||
>احکام مدل نشده</a
|
||
>
|
||
</li>
|
||
<li class="sidebar-menu-item">
|
||
<a
|
||
href="javascript:void(0)"
|
||
@click.prevent="updateListSpecial('all_rules')"
|
||
class="text__14 sidebar-menu-link"
|
||
:class="{ active: activeMenu == 'all_rules' }"
|
||
>همه احکام</a
|
||
>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div> -->
|
||
|
||
<div class="col">
|
||
<div class="container-fluid">
|
||
<!-- <div class="row">
|
||
<div class="col-12">
|
||
<div
|
||
class="problem-detail__header p-0"
|
||
id="title"
|
||
style="background-color: #eee"
|
||
>
|
||
<div class="d-flex align-items-center">
|
||
<button-component
|
||
title="کپی لینک"
|
||
buttonText=""
|
||
classes="color-1 ms-2"
|
||
@click="copyToClipboard()"
|
||
>
|
||
<svg class="icon icon-copy2 fz-8">
|
||
<use xlink:href="#icon-copy2"></use>
|
||
</svg>
|
||
</button-component>
|
||
<div class="col-9 pe-0">
|
||
<bread-crumb
|
||
class="mb-0"
|
||
:keyName="'key'"
|
||
:key="filterListKey"
|
||
:filters="breadCrumbGetter"
|
||
@remove-filter="delFilter"
|
||
>
|
||
</bread-crumb>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div> -->
|
||
<div
|
||
v-if="qruleActiveTabGetter.items_headers.length"
|
||
class="row align-items-center"
|
||
>
|
||
<span class="me-3 text__13 text__green"
|
||
>تنظمیات مختص پالایش فهرست {{ qruleActiveTabGetter.title }}</span
|
||
>
|
||
<div
|
||
class="col-auto"
|
||
v-for="(comboItem, index) in qruleActiveTabGetter.items_headers"
|
||
:key="index"
|
||
>
|
||
<label for="hardnessRange">{{ comboItem.label }}</label>
|
||
<select
|
||
class="text__13 form-control"
|
||
@change="updateFilters"
|
||
v-model="filters[comboItem.key]"
|
||
>
|
||
<option
|
||
v-for="(optionItem, index2) in comboItem.options"
|
||
:key="index2"
|
||
:value="optionItem.value"
|
||
>
|
||
{{ optionItem.title }}
|
||
</option>
|
||
</select>
|
||
</div>
|
||
<div class="col"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="firefox-scrollbar">
|
||
<div class="row">
|
||
<div
|
||
class="col-lg-2 filter-list-container"
|
||
:class="{ expanded: showFilter }"
|
||
>
|
||
<div class="mobile-mode">
|
||
<button class="btn" @click.prevnet="showFilter = !showFilter">
|
||
<svg
|
||
v-if="showFilter"
|
||
class="icon icon-chevron-double-right ms-1"
|
||
>
|
||
<use xlink:href="#icon-chevron-double-right"></use>
|
||
</svg>
|
||
<svg v-else class="icon icon-chevron-double-left">
|
||
<use xlink:href="#icon-chevron-double-left"></use>
|
||
</svg>
|
||
<!-- بستن فیلتر -->
|
||
</button>
|
||
</div>
|
||
<filter-list-search
|
||
:lastSearchInListMode="lastSearchInListMode"
|
||
:changePageFilter="changePageFilter"
|
||
:activeTabGetter="qruleActiveSchemaGetter"
|
||
@filterUpdate="filterListUpdate"
|
||
ref="filterlist"
|
||
class="filterList"
|
||
></filter-list-search>
|
||
</div>
|
||
<div class="col">
|
||
<the-content-loading v-if="fetchingData"></the-content-loading>
|
||
<div v-if="!fetchingData">
|
||
<!-- #region rendering entity content -->
|
||
<my-table
|
||
height="auto"
|
||
:hasSearch="false"
|
||
:hasEdit="false"
|
||
:hasDetails="false"
|
||
:fetchingData="fetchingData"
|
||
:items="qModelRuleItems"
|
||
:tableActions="tableActions"
|
||
:tableColumns="qruleActiveTabGetter.table_columns"
|
||
:paginationInfo="pagination"
|
||
:sortingInfo="sorting"
|
||
@new-item="newItem"
|
||
@show-sub-item="showRuleLogic"
|
||
@on-linked-title-click="onLinkedTitleClick"
|
||
@page-limit-changed="pageLimitChanged"
|
||
@page-changed="pageChanged"
|
||
@sort-changed="sortChanged"
|
||
/>
|
||
|
||
<!-- #endregion rendering entity content -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<base-modal-v2
|
||
v-if="showEditForm"
|
||
modalSize="modal-xl"
|
||
:modalTitle="entityContent_title"
|
||
:hasFooter="true"
|
||
:showLoadButton="lastRecordGetter[qruleActiveTabGetter.key]"
|
||
:showCopyButton="true"
|
||
:showSaveButton="true"
|
||
:showCloseButton="true"
|
||
:showDeleteButton="true"
|
||
@close="closeEditModal"
|
||
@save="saveEditModal"
|
||
@delete="deleteEditModal"
|
||
@loadFromVuexClipboard="loadFromVuexClipboard"
|
||
@copyToVuexClipboard="copyToVuexClipboard"
|
||
>
|
||
<slot> {{ entityContent_title }}</slot>
|
||
|
||
<slot name="header-actions"> </slot>
|
||
|
||
<!-- <slot v-slot:body="{formData}"> -->
|
||
<slot name="body">
|
||
<FormBuilder
|
||
:key="formBuilderRerenderer"
|
||
:readOnly="false"
|
||
:formElements="formElements"
|
||
:formData="selectRuleObject"
|
||
@saveComponentValue="changedBaseModalValues"
|
||
displayMode="default"
|
||
></FormBuilder>
|
||
</slot>
|
||
|
||
<!-- <slot v-slot:footer> This is a new modal footer. </slot> -->
|
||
</base-modal-v2>
|
||
|
||
<base-modal-v2
|
||
v-if="showList"
|
||
modalSize="modal-xl"
|
||
modalTitle="فهرست مادهها"
|
||
:hasFooter="false"
|
||
@close="closeListModal"
|
||
>
|
||
<slot name="default">فهرست مادههای قانون </slot>
|
||
|
||
<slot name="body">
|
||
<MajlesQaSectionContent
|
||
ref="SearchContent"
|
||
:summeryKeys="['content', 'mindex', 'mintro']"
|
||
:pagination="modalPagination"
|
||
:displayMode="qruleActiveTabGetter?.key"
|
||
:qruleText="activeRowItem.key"
|
||
@changePage="changePage"
|
||
@select-item="selectItem"
|
||
class="component"
|
||
>
|
||
</MajlesQaSectionContent>
|
||
</slot>
|
||
|
||
<!-- <template v-slot:footer> This is a new modal footer. </template> -->
|
||
</base-modal-v2>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import repoApi from "~/apis/repoApi";
|
||
import searchApi from "~/apis/searchApi";
|
||
|
||
import { mapActions, mapState } from "pinia";
|
||
|
||
export default {
|
||
props: {
|
||
// slug: {
|
||
// default: "mqsection",
|
||
// },
|
||
schemaItems: {
|
||
default() {
|
||
return {};
|
||
},
|
||
},
|
||
routeEntityid: "",
|
||
},
|
||
|
||
beforeMount() {
|
||
this.httpService = useNuxtApp()["$http"];
|
||
},
|
||
mounted() {
|
||
this.filters = {};
|
||
this.qruleActiveTabGetter?.items_headers.forEach((item) => {
|
||
this.filters[item.key] = item.options[0].value;
|
||
});
|
||
|
||
this.formElements = this.qruleActiveTabGetter.items;
|
||
this.myRoute = this.$route;
|
||
|
||
this.getListInfo();
|
||
this.getEntityQModelInfo();
|
||
},
|
||
|
||
data() {
|
||
return {
|
||
httpService:undefined,
|
||
changePageFilter: "",
|
||
lastSearchInListMode: true,
|
||
showFilter: true,
|
||
|
||
formElements: [],
|
||
showNewRuleLogicForm: false,
|
||
showNewRuleTripleForm: false,
|
||
formBuilderRerenderer: 1,
|
||
filterListKey: 1,
|
||
|
||
activeRowItem: undefined,
|
||
listSelectedPoint: "",
|
||
showList: false,
|
||
reRender: 1,
|
||
modalPagination: {
|
||
page: 1,
|
||
pages: 0,
|
||
total: 0,
|
||
offset: 0,
|
||
limit: 20,
|
||
},
|
||
|
||
filterUrl: "",
|
||
activeMenu: "my_rules",
|
||
filters: {},
|
||
hardnessRange: "",
|
||
|
||
hardnessRangeValue: [3],
|
||
|
||
formData: undefined,
|
||
selectRuleObject: undefined,
|
||
selectRuleText: undefined,
|
||
selectRuleLogic: undefined,
|
||
selectRuleTriple: undefined,
|
||
qModelRuleItems: undefined,
|
||
entity: {},
|
||
entityQs: {},
|
||
entity_id: undefined,
|
||
mainEntityid: this.routeEntityid,
|
||
showBaseModal: false,
|
||
showEditForm: false,
|
||
currentEntityContent: {},
|
||
currentItemsSchema: {},
|
||
currentItemEntity: {},
|
||
currentItemEntity_index: -1,
|
||
currentItemEntity_changed: {},
|
||
displayMode: "accordion",
|
||
entityContent_title: "",
|
||
|
||
tableActions: [
|
||
{
|
||
showOutside: true,
|
||
|
||
show: false,
|
||
icon: "tavasi tavasi-eye",
|
||
title: "مشاهده گزارههای این حکم",
|
||
to: {
|
||
name: "undefined",
|
||
},
|
||
selected: false,
|
||
disabled: false,
|
||
howToOpen: "",
|
||
href: "",
|
||
class: "edit-btn",
|
||
action: "show-sub-item",
|
||
// can: "subject-",
|
||
},
|
||
{
|
||
showOutside: true,
|
||
|
||
show: false,
|
||
icon: "tavasi tavasi-Component-133--1",
|
||
title: "ایجاد گزاره جدید",
|
||
to: {
|
||
name: "undefined",
|
||
},
|
||
selected: false,
|
||
disabled: false,
|
||
howToOpen: "",
|
||
href: "",
|
||
class: "add-btn",
|
||
action: "new-item",
|
||
// can: "subject-",
|
||
},
|
||
],
|
||
sorting: {
|
||
sortby: "created",
|
||
sortorder: undefined, // asc | none
|
||
},
|
||
pagination: {
|
||
page: 1,
|
||
pages: 0,
|
||
total: 0,
|
||
offset: 0,
|
||
limit: 20,
|
||
},
|
||
|
||
myRoute: undefined,
|
||
render: 1,
|
||
|
||
fetchingData: false,
|
||
};
|
||
},
|
||
computed: {
|
||
...mapState("entity", [
|
||
"qruleActiveTabGetter",
|
||
"qruleActiveSchemaGetter",
|
||
"breadCrumbGetter",
|
||
"vuexEntityGetter",
|
||
]),
|
||
...mapState("common", ["lastRecordGetter"]),
|
||
|
||
repoUrl() {
|
||
return import.meta.env.VITE_REPO + "/";
|
||
},
|
||
// formElements: {
|
||
// get() {
|
||
// return this.qruleActiveTabGetter.items;
|
||
// },
|
||
// set(newVal) {
|
||
// return newVal;
|
||
// },
|
||
// },
|
||
},
|
||
methods: {
|
||
...mapActions("entity", [
|
||
"qruleActiveSchemaSetter",
|
||
"qruleSchemaSetter",
|
||
"qruleActiveTabSetter",
|
||
"breadCrumbSetter",
|
||
"vuexEntitySetter",
|
||
]),
|
||
...mapActions(["checkPermissions"]),
|
||
...mapActions("common", ["lastRecordSetter"]),
|
||
|
||
filterListUpdate(filter) {
|
||
// console.log("🚀 ~ filterUpdate ~ event:", event);
|
||
this.filterUrl = filter;
|
||
this.getListInfo();
|
||
},
|
||
newItem(rowIndex) {
|
||
// برای اینکه بعد از کلیک بر روی "انتخاب و ادامه طبق همین ماده "
|
||
// ، به صفحه گزاره ها برود.
|
||
this.showNewRuleLogicForm = true;
|
||
|
||
let rowData = {
|
||
rowItem: this.qModelRuleItems[rowIndex],
|
||
index: rowIndex,
|
||
};
|
||
|
||
this.onLinkedTitleClick(rowData);
|
||
},
|
||
|
||
loadFromVuexClipboard() {
|
||
let lastObj = this.lastRecordGetter[this.qruleActiveTabGetter.key];
|
||
if (lastObj.id) delete lastObj.id;
|
||
|
||
this.formData = lastObj;
|
||
this.renderBody++;
|
||
},
|
||
copyToVuexClipboard() {
|
||
this.lastRecordSetter({
|
||
[this.qruleActiveTabGetter.key]: structuredClone(this.selectRuleObject),
|
||
});
|
||
},
|
||
|
||
emptyFilter: function () {
|
||
this.breadCrumbSetter();
|
||
// this.searchfilter();
|
||
this.filterListKey++;
|
||
},
|
||
delFilter({ key }) {
|
||
if (this.breadCrumbGetter?.has(key)) {
|
||
this.breadCrumbGetter?.delete(key);
|
||
// this.searchfilter();
|
||
}
|
||
this.filterListKey++;
|
||
},
|
||
addFilter({ key, doc_count }) {
|
||
let filter = {};
|
||
filter.key = key;
|
||
filter.doc_count = doc_count;
|
||
filter.tab = this.qruleActiveTabGetter.key;
|
||
|
||
let hasItem = this.breadCrumbGetter.filter(
|
||
(item) => item.key == key
|
||
).length;
|
||
|
||
if (!hasItem) {
|
||
this.breadCrumbSetter(filter);
|
||
// this.searchfilter();
|
||
}
|
||
this.filterListKey++;
|
||
},
|
||
|
||
onLinkedTitleClick(data) {
|
||
this.activeRowItem = data.rowItem;
|
||
let index = data.index;
|
||
|
||
if (this.qruleActiveTabGetter.key == "rulesection") {
|
||
let item = this.qModelRuleItems[index];
|
||
|
||
let name = "detail";
|
||
let key = "qsection";
|
||
let hash = "#qmodel";
|
||
let id = item.ref_id;
|
||
const routeData = this.$router.resolve({
|
||
name: name,
|
||
params: {
|
||
id: id,
|
||
key: key,
|
||
},
|
||
hash: hash,
|
||
query: {},
|
||
});
|
||
window.open(routeData.href, "_blank");
|
||
return;
|
||
}
|
||
|
||
// if (data.rowItem.doc_count > 1)
|
||
// {
|
||
this.getQSectionList().then((res) => {
|
||
this.showList = true;
|
||
|
||
setTimeout(() => {
|
||
this.$refs.SearchContent.setAnswer(
|
||
res.hits.hits,
|
||
res.hits.total.value,
|
||
res.hits.total.relation
|
||
);
|
||
}, 500);
|
||
});
|
||
// }
|
||
// else {
|
||
// this.showBaseModal = true;
|
||
// }
|
||
},
|
||
newQRule() {
|
||
// this.showBaseModal = true;
|
||
},
|
||
newLogicalStatement() {
|
||
let rulelogic = this.qruleActiveSchemaGetter?.tabs.find(
|
||
(i) => i.key == "rulelogic"
|
||
);
|
||
this.$emit("set-active-tab", rulelogic);
|
||
},
|
||
async getQSectionList() {
|
||
let type = "qmodel";
|
||
|
||
let url =
|
||
repoUrl() +
|
||
searchApi.navigation.reportItem +
|
||
"/search/{{index_key}}/{{offset}}/{{limit}}";
|
||
var filter =
|
||
this.qruleActiveTabGetter.key_filter + "=" + this.activeRowItem.key;
|
||
|
||
url = url.replace("{{index_key}}", type);
|
||
|
||
url = url.replace("{{offset}}", this.pagination.offset);
|
||
url = url.replace("{{limit}}", this.pagination.limit);
|
||
|
||
let payload = {
|
||
filter: filter,
|
||
};
|
||
// url = url.replace("{{filter}}", filter);
|
||
|
||
return await this.httpService
|
||
.postRequest(url, payload)
|
||
.then((res) => {
|
||
return res;
|
||
});
|
||
},
|
||
changePage(item) {
|
||
this.pagination = item;
|
||
this.getQSectionList();
|
||
},
|
||
|
||
async closeModal() {
|
||
this.selectedItem = {};
|
||
|
||
$("#base-modal").modal({
|
||
show: false,
|
||
});
|
||
|
||
return await setTimeout(() => {
|
||
this.showList = false;
|
||
}, 50);
|
||
},
|
||
|
||
updateListSpecial(item) {
|
||
this.activeMenu = item;
|
||
},
|
||
|
||
updateFilters() {
|
||
this.getListInfo();
|
||
},
|
||
deleteItem(tableRowItemIndex) {
|
||
// const data = {
|
||
// id: this.selectedItemGetter.id,
|
||
// subject_id: this.itemSubject[tableRowItemIndex].id,
|
||
// subject_title: this.itemSubject[tableRowItemIndex].title,
|
||
// };
|
||
this.mySwalConfirm({
|
||
title: "هشدار",
|
||
html: "از حذف حکم مطمئن هستید؟",
|
||
icon: "warning",
|
||
}).then((result) => {
|
||
if (result.isConfirmed) {
|
||
// this.httpServiceBase
|
||
// .formDataRequest(repoApi.subject.delete, data)
|
||
// .then((res) => {
|
||
// this.itemSubject.splice(tableRowItemIndex, 1);
|
||
this.mySwalToast({
|
||
title: "با موفقیت حذف شد.",
|
||
html: undefined,
|
||
icon: "success",
|
||
});
|
||
// });
|
||
}
|
||
});
|
||
},
|
||
prevItem() {
|
||
this.getNextEntity(-1);
|
||
},
|
||
nextItem() {
|
||
this.getNextEntity(1);
|
||
},
|
||
getNextEntity(step = 1) {
|
||
if (this.fetchingData) return;
|
||
|
||
let self = this;
|
||
//ابتدا بعدی را از مخزن اصلی پیدا می کند و بعد معادلش را در مخزن مدل می گردد و اگر ایجاد نشده بود، ایجاد می کند
|
||
this.getEntityQSectionNext(step).then((response) => {
|
||
if (!response) return;
|
||
|
||
// console.log(response);
|
||
this.fetchingData = true;
|
||
|
||
// get qmodel
|
||
let entityQsId = response;
|
||
let url = repoUrl() + repoApi.public.getRef_id;
|
||
let key = "qmodel";
|
||
url = url.replace("{{index_key}}", key);
|
||
url = url.replace("{{filed}}", "ref_id");
|
||
url = url.replace("{{filed_id}}", entityQsId);
|
||
|
||
// console.log(url);
|
||
this.httpService.getRequest(url).then((res) => {
|
||
// console.log(res);
|
||
|
||
self.entity = res?._source;
|
||
this.fetchingData = false;
|
||
if (!self.entity)
|
||
self.entity = this.createBaseEntityModel(self.entityQs, entityQsId);
|
||
});
|
||
});
|
||
},
|
||
|
||
async getEntityQSectionNext(step = 1) {
|
||
if (this.fetchingData) return;
|
||
|
||
let self = this;
|
||
if (this.entity) {
|
||
this.fetchingData = true;
|
||
|
||
let url = repoUrl() + repoApi.public.next;
|
||
let key = this.$route.params.key;
|
||
url = url.replace("{{index_key}}", key);
|
||
url = url.replace("{{parent_id}}", this.entity?.qanon_id);
|
||
url = url.replace("{{order}}", this.entity?.child_order);
|
||
url = url.replace("{{step}}", step);
|
||
|
||
// console.log(url);
|
||
return await this.httpService.getRequest(url).then((res) => {
|
||
this.fetchingData = false;
|
||
|
||
if (res?.hits?.hits[0]) {
|
||
self.entityQs = res.hits.hits[0]._source;
|
||
|
||
let newRoute = this.urlResolver(res.hits.hits[0]._id);
|
||
history.pushState({}, document.title, newRoute);
|
||
self.mainEntityid = res.hits.hits[0]._id;
|
||
//چون روت ، تغییر با هیستوری را نمی فهمد!!!!!
|
||
self.$emit("changeEntityid", self.mainEntityid);
|
||
|
||
return self.mainEntityid;
|
||
}
|
||
return null;
|
||
});
|
||
}
|
||
return null;
|
||
},
|
||
|
||
urlResolver(_id) {
|
||
const routeData = this.$router.resolve({
|
||
name: "detail",
|
||
params: {
|
||
id: _id,
|
||
key: this.$route.params.key,
|
||
},
|
||
query: {},
|
||
});
|
||
return routeData.href;
|
||
},
|
||
|
||
async getEntityQSection() {
|
||
if (this.fetchingData) return;
|
||
|
||
let entityQsId = this.mainEntityid; //.$route.params?.id;
|
||
|
||
let self = this;
|
||
if (entityQsId) {
|
||
this.fetchingData = true;
|
||
|
||
let url = repoUrl() + repoApi.public.get;
|
||
let key = this.$route.params.key;
|
||
url = url.replace("{{index_key}}", key);
|
||
url = url.replace("{{entity_id}}", entityQsId);
|
||
|
||
return await this.httpService.getRequest(url).then((res) => {
|
||
this.fetchingData = false;
|
||
|
||
self.entity = res._source;
|
||
});
|
||
}
|
||
},
|
||
async getEntityQModelInfo() {
|
||
if (this.fetchingData) return;
|
||
|
||
let entityQsId = this.mainEntityid; //.$route.params?.id;
|
||
if (!entityQsId) return;
|
||
this.fetchingData = true;
|
||
|
||
//console.log(entityQsId)
|
||
let self = this;
|
||
let url = repoUrl() + repoApi.public.getRef_id;
|
||
|
||
let key = "qmodel";
|
||
url = url.replace("{{index_key}}", key);
|
||
url = url.replace("{{filed}}", "ref_id");
|
||
url = url.replace("{{filed_id}}", entityQsId);
|
||
|
||
// console.log(url);
|
||
return await this.httpService.getRequest(url).then((res) => {
|
||
self.entity = res?._source; // @depreacted use vuexEntitySetter instead.
|
||
this.vuexEntitySetter(res?._source);
|
||
this.fetchingData = false;
|
||
|
||
if (!self.entity) {
|
||
this.getEntityQSection().then((res) => {
|
||
self.entity = this.createBaseEntityModel(self.entityQs);
|
||
});
|
||
}
|
||
});
|
||
},
|
||
|
||
async getListInfo() {
|
||
if (this.fetchingData) return;
|
||
|
||
this.fetchingData = true;
|
||
let self = this;
|
||
|
||
let filters = this.filterUrl;
|
||
Object.keys(this.filters).forEach((key) => {
|
||
if (this.filters[key] != "همه موارد") {
|
||
let value = this.filters[key];
|
||
if (value == "ref_id") {
|
||
if (this.$route.params?.id)
|
||
filters += `&${value}=${this.$route.params?.id}`;
|
||
}
|
||
|
||
if (value == "qanon_id") {
|
||
if (this.entity?.qanon_id)
|
||
filters += `&${value}=${this.entity?.qanon_id}`;
|
||
} else filters += `&${key}=${this.filters[key]}`;
|
||
}
|
||
});
|
||
|
||
let url = "";
|
||
if (this.qruleActiveTabGetter.key == "rulesection") {
|
||
url = repoUrl() + searchApi.search.default;
|
||
url = url.replace("{{appname}}", buildName());
|
||
url = url.replace("{{index_key}}", "qmodel");
|
||
url = url.replace("{{sortKey}}", "lasttitle");
|
||
} else {
|
||
url = repoUrl() + repoApi.public.qmodel;
|
||
}
|
||
|
||
url = url.replace(
|
||
"{{key_filter}}",
|
||
this.qruleActiveTabGetter?.key_filter
|
||
);
|
||
url = url.replace("{{offset}}", this.pagination.offset);
|
||
url = url.replace("{{limit}}", this.pagination.limit);
|
||
if (filters) url = url.replace("{{filter}}", filters);
|
||
else url = url.replace("/{{filter}}", "");
|
||
|
||
return await this.httpService.getRequest(url).then((res) => {
|
||
this.fetchingData = false;
|
||
// self.entity = res?._source;
|
||
|
||
this.$refs.filterlist?.setAnswer(res.aggregations);
|
||
|
||
if (this.qruleActiveTabGetter.key == "rulesection") {
|
||
this.qModelRuleItems = [];
|
||
res?.hits?.hits.forEach((el) => {
|
||
this.qModelRuleItems.push(el._source);
|
||
});
|
||
} else this.qModelRuleItems = res.aggregations.result.buckets;
|
||
|
||
this.fetchingData = false;
|
||
|
||
let total = res.hits.total.value;
|
||
if (res?.aggregations?.unique_result)
|
||
total = res?.aggregations?.unique_result.value;
|
||
|
||
const pages = Math.ceil(total / this.pagination.limit);
|
||
const pagination = {
|
||
total: total,
|
||
pages: pages == 0 ? 1 : pages,
|
||
};
|
||
|
||
this.pagination = { ...this.pagination, ...pagination };
|
||
});
|
||
},
|
||
|
||
showRuleLogic(rowIndex) {
|
||
// this.emptyFilter();
|
||
|
||
this.newLogicalStatement();
|
||
this.addFilter(this.qModelRuleItems[rowIndex]);
|
||
|
||
// this.currentEntityContent = entityContent;
|
||
// this.currentItemsSchema = entityContent?.items;
|
||
// this.currentItemEntity = itemEntity;
|
||
// this.currentItemEntity_changed = itemEntity;
|
||
// this.entityContent_title = entityContent?.title;
|
||
// this.currentItemEntity_index = index;
|
||
// this.displayMode =
|
||
// entityContent?.group == "accordion" ? "accordion" : "default";
|
||
|
||
// this.showBaseModal = true;
|
||
//this.openBaseModal().then(() => {});
|
||
},
|
||
|
||
saveEditModal() {
|
||
this.closeEditModal();
|
||
|
||
// console.log(this.currentItemEntity_changed);
|
||
this.saveEntityProperty(
|
||
this.currentItemEntity_changed,
|
||
this.currentItemEntity_index
|
||
);
|
||
this.render++;
|
||
},
|
||
|
||
deleteEditModal() {
|
||
this.closeEditModal();
|
||
this.deleteEntityProperty(
|
||
this.currentItemEntity,
|
||
this.currentItemEntity_index
|
||
);
|
||
this.render++;
|
||
},
|
||
closeListModal() {
|
||
this.showList = false;
|
||
},
|
||
closeEditModal() {
|
||
this.showEditForm = false;
|
||
},
|
||
selectItem(item) {
|
||
this.closeListModal();
|
||
|
||
// ایجاد گزاره جدید
|
||
if (this.showNewRuleLogicForm) {
|
||
this.prepareRuleLogicData(item);
|
||
} else if (this.showNewRuleTripleForm) {
|
||
this.prepareRuleTripleData(item);
|
||
}
|
||
// ویرایش حکم جاری
|
||
else {
|
||
// item
|
||
if (this.qruleActiveTabGetter.key == "rulelist") {
|
||
this.prepareRuleListData(item);
|
||
} else if (this.qruleActiveTabGetter.key == "rulelogic") {
|
||
this.prepareRuleLogicData(item);
|
||
} else if (this.qruleActiveTabGetter.key == "ruletriple") {
|
||
this.prepareRuleTripleData(item);
|
||
}
|
||
}
|
||
|
||
this.entityContent_title =
|
||
item._source.content.split(" ").slice(0, 5).join(" ") + "...";
|
||
this.showEditForm = true;
|
||
this.formBuilderRerenderer++;
|
||
this.closeListModal();
|
||
},
|
||
prepareRuleLogicData(item) {
|
||
let rulelogic = this.qruleActiveSchemaGetter?.tabs.find(
|
||
(i) => i.key == "rulelogic"
|
||
);
|
||
|
||
this.formElements = rulelogic.items;
|
||
// یافتن شناسه حکم مرتبط با گزاره منطقی جاری
|
||
this.selectRuleLogic = undefined;
|
||
item._source?.rules_logics.forEach((el) => {
|
||
if (el.text == this.activeRowItem.key) {
|
||
this.selectRuleLogic = el;
|
||
return;
|
||
}
|
||
});
|
||
|
||
// یافتن شیء حکم اصلی با شناسه بالا
|
||
this.selectRuleText = undefined;
|
||
if (this.selectRuleLogic) {
|
||
item._source?.rules.forEach((el) => {
|
||
if (el.id == this.selectRuleLogic.rule_text_id) {
|
||
this.selectRuleText = el;
|
||
return;
|
||
}
|
||
});
|
||
}
|
||
|
||
if (this.selectRuleLogic) {
|
||
this.selectRuleObject = this.selectRuleLogic;
|
||
this.showEditForm = true;
|
||
} else {
|
||
// خطا ...!!!
|
||
}
|
||
},
|
||
prepareRuleTripleData(item) {
|
||
// یافتن شناسه حکم مرتبط با سهتایی جاری
|
||
this.selectRuleTriple = undefined;
|
||
item._source?.rules_logics_triples.forEach((el) => {
|
||
if (el.text == this.activeRowItem.key) {
|
||
this.selectRuleTriple = el;
|
||
return;
|
||
}
|
||
});
|
||
|
||
// یافتن شناسه حکم مرتبط با گزاره منطقی جاری
|
||
this.selectRuleLogic = undefined;
|
||
if (this.selectRuleTriple) {
|
||
item._source?.rules_logics.forEach((el) => {
|
||
if (el.id == this.selectRuleTriple.rule_logic_id) {
|
||
this.selectRuleLogic = el;
|
||
return;
|
||
}
|
||
});
|
||
}
|
||
|
||
// یافتن شیء حکم اصلی با شناسه بالا
|
||
this.selectRuleText = undefined;
|
||
if (this.selectRuleLogic) {
|
||
item._source?.rules.forEach((el) => {
|
||
if (el.id == this.selectRuleLogic.rule_text_id) {
|
||
this.selectRuleText = el;
|
||
return;
|
||
}
|
||
});
|
||
}
|
||
|
||
if (this.selectRuleTriple) {
|
||
this.selectRuleObject = this.selectRuleTriple;
|
||
this.showEditForm = true;
|
||
} else {
|
||
// خطا ...!!!
|
||
}
|
||
},
|
||
prepareRuleListData(item) {
|
||
// یافتن حکم مرتبط
|
||
this.selectRuleText = undefined;
|
||
item._source?.rules.forEach((el) => {
|
||
if (el.text == this.activeRowItem.key) {
|
||
this.selectRuleText = el;
|
||
return;
|
||
}
|
||
});
|
||
// console.log(item._source?.rules)
|
||
|
||
if (this.selectRuleText) {
|
||
this.selectRuleObject = this.selectRuleText;
|
||
this.formData = this.selectRuleObject;
|
||
this.showEditForm = true;
|
||
} else {
|
||
// خطا ...!!!
|
||
}
|
||
},
|
||
changedBaseModalValues(data) {
|
||
// console.log("data");
|
||
// console.log(data);
|
||
|
||
let self = this;
|
||
Object.keys(data).forEach((key, index) => {
|
||
self.currentItemEntity_changed[key] = data[key];
|
||
});
|
||
|
||
// this.currentItemEntity_changed = data;
|
||
},
|
||
|
||
createBaseEntityModel(entity, entityQsId = undefined) {
|
||
entityQsId = entityQsId ? entityQsId : this.mainEntityid; //.$route.params?.id;
|
||
let key = this.$route.params?.key;
|
||
let data = {
|
||
// id: entityQsId.replace('qs', 'mqs'), // علامت موقت بودن - هر وقت در بک ایجاد شد مقدار واقعی می گیرد
|
||
content: entity?.content,
|
||
qanon_title: entity?.qanon_title,
|
||
ts_date: entity?.ts_date,
|
||
ts_ref: entity?.ts_ref,
|
||
ref_key: key,
|
||
ref_id: entityQsId,
|
||
qanon_id: entity?.qanon_id,
|
||
state_etebar: entity?.state_etebar,
|
||
state_tanghih: entity?.state_tanghih,
|
||
other_info: entity?.other_info,
|
||
child_order: entity?.child_order,
|
||
parent_id: entity?.parent_id,
|
||
sort_date_timestamp: Date.now(),
|
||
};
|
||
|
||
return data;
|
||
},
|
||
|
||
saveEntityProperty(itemOfEntity, index) {
|
||
if (!itemOfEntity) return;
|
||
|
||
let field_key = this.currentEntityContent.key;
|
||
let payload = {};
|
||
let url = "";
|
||
let item_data = [];
|
||
|
||
if (this.entity?.id) {
|
||
//edit model entity
|
||
|
||
if (this.entity[this.currentEntityContent.key])
|
||
item_data = this.entity[this.currentEntityContent.key];
|
||
|
||
if (this.currentEntityContent?.isarray) {
|
||
let isEditState = false;
|
||
if (itemOfEntity?.id) {
|
||
//edit state
|
||
let index = item_data.findIndex(
|
||
(item) => item?.id == itemOfEntity.id
|
||
);
|
||
if (index != -1) {
|
||
item_data[index] = itemOfEntity;
|
||
isEditState = true;
|
||
}
|
||
} else if (index != -1 && index < item_data.length) {
|
||
item_data[index] = itemOfEntity;
|
||
isEditState = true;
|
||
}
|
||
|
||
// add state
|
||
if (!isEditState) {
|
||
///////////////////////////////////////////////
|
||
//بررسی افزودن چندتایی با یک درخواست با توجه به \n
|
||
if (itemOfEntity?.text && itemOfEntity?.text.includes("\n")) {
|
||
itemOfEntity?.text.split("\n").forEach((element) => {
|
||
if (element.trim() != "") {
|
||
let new1 = itemOfEntity;
|
||
new1.text = element;
|
||
item_data.push(new1);
|
||
}
|
||
});
|
||
} else item_data.push(itemOfEntity);
|
||
////////////////////////////////////////////////
|
||
}
|
||
} else item_data = itemOfEntity;
|
||
|
||
payload[field_key] = item_data;
|
||
this.entity[field_key] = item_data;
|
||
|
||
// public/@index_key/edit/@id/@property/index/full
|
||
url = repoApi.public.updateProperty_full;
|
||
url = url.replace("{{index_key}}", "qmodel");
|
||
url = url.replace("{{entity_id}}", this.entity?.id);
|
||
url = url.replace("{{property}}", this.currentEntityContent.key);
|
||
} else {
|
||
// new model entity
|
||
// public/@index_key/add
|
||
if (this.currentEntityContent?.isarray) {
|
||
item_data.push(itemOfEntity);
|
||
} else item_data = itemOfEntity;
|
||
|
||
payload = this.createBaseEntityModel(this.entityQs);
|
||
payload[field_key] = item_data;
|
||
this.entity = payload;
|
||
this.entity.id = this.entity.ref_id.replace("qs", "mqs");
|
||
|
||
url = repoUrl() + repoApi.public.addEntity;
|
||
url = url.replace("{{index_key}}", "qmodel");
|
||
}
|
||
|
||
let vm = this;
|
||
this.httpService
|
||
.postRequest(url, payload)
|
||
.then((res) => {
|
||
// console.log(res);
|
||
|
||
vm.entity.id = res._id;
|
||
|
||
this.mySwalToast({
|
||
title: "موفق",
|
||
html: res.message,
|
||
icon: "success",
|
||
});
|
||
})
|
||
.catch((err) => {
|
||
this.mySwalToast({
|
||
title: "خطا!!!",
|
||
html: err?.message,
|
||
icon: "error",
|
||
});
|
||
})
|
||
.finally(() => {
|
||
this.showNewRuleLogicForm = false;
|
||
});
|
||
},
|
||
deleteEntityProperty(itemOfEntity, index) {
|
||
// console.log("saveEntityProperty");
|
||
//console.log(itemOfEntity);
|
||
if (!itemOfEntity) return;
|
||
|
||
let field_key = this.currentEntityContent.key;
|
||
let payload = {};
|
||
let url = "";
|
||
let item_data = [];
|
||
|
||
if (!this.entity?.id || !this.entity[this.currentEntityContent.key])
|
||
return;
|
||
|
||
item_data = this.entity[this.currentEntityContent.key];
|
||
|
||
if (this.currentEntityContent?.isarray) {
|
||
if (itemOfEntity?.id) {
|
||
url = repoUrl() + repoApi.public.deleteProperty_byid;
|
||
url = url.replace("{{prop_id}}", itemOfEntity?.id);
|
||
|
||
//edit state
|
||
let index = item_data.findIndex(
|
||
(item) => item?.id == itemOfEntity.id
|
||
);
|
||
if (index != -1) {
|
||
item_data.splice(index, 1);
|
||
}
|
||
} else {
|
||
url =
|
||
repoUrl() + repoApi.public.deleteProperty_byindex;
|
||
url = url.replace("{{index}}", index);
|
||
|
||
if (index != -1 && index < item_data.length)
|
||
item_data.splice(index, 1);
|
||
//error
|
||
else return;
|
||
}
|
||
} else {
|
||
url = repoUrl() + repoApi.public.deleteProperty;
|
||
item_data = "";
|
||
}
|
||
|
||
payload[field_key] = item_data;
|
||
this.entity[field_key] = item_data;
|
||
|
||
url = url.replace("{{index_key}}", "qmodel");
|
||
url = url.replace("{{entity_id}}", this.entity?.id);
|
||
url = url.replace("{{property}}", this.currentEntityContent.key);
|
||
|
||
let vm = this;
|
||
this.httpService
|
||
.postRequest(url, payload)
|
||
.then((res) => {
|
||
// console.log(res);
|
||
|
||
vm.entity.id = res._id;
|
||
|
||
this.mySwalToast({
|
||
title: "موفق",
|
||
html: res.message,
|
||
icon: "success",
|
||
});
|
||
})
|
||
.catch((err) => {
|
||
this.mySwalToast({
|
||
title: "خطا!!!",
|
||
html: err?.message,
|
||
icon: "error",
|
||
});
|
||
});
|
||
},
|
||
/**
|
||
* تابعی برای تغییر تعداد سطرها در صفحه.
|
||
* @param {Object} paging - اطلاعات مربوط به صفحهبندی
|
||
*/
|
||
//تعداد سطرها
|
||
pageLimitChanged(paging) {
|
||
console.log(paging);
|
||
this.pagination.limit = paging.limit;
|
||
this.getListInfo();
|
||
},
|
||
|
||
//زمانی که روی عدد کلیک میشه
|
||
/**
|
||
* تابعی برای تغییر صفحه.
|
||
* @param {Object} paging - اطلاعات مربوط به صفحهبندی
|
||
*/
|
||
pageChanged(paging) {
|
||
let page = paging.pageNumber;
|
||
page -= 1;
|
||
this.pagination.offset = page * paging.limit;
|
||
this.pagination.limit = paging.limit;
|
||
this.pagination.page = paging.pageNumber;
|
||
this.getListInfo();
|
||
|
||
// this.$emit("changePage", this.pag);
|
||
},
|
||
/**
|
||
* تابعی برای تغییر مرتبسازی.
|
||
* @param {Object} sorting - اطلاعات مربوط به مرتبسازی
|
||
*/
|
||
sortChanged(sorting) {
|
||
this.pagination.page = this.pagination.offset = 0;
|
||
this.sorting = sorting;
|
||
this.getQSectionList();
|
||
|
||
// this.$emit("changePage", this.sorting);
|
||
},
|
||
/**
|
||
* تابعی برای تنظیم مجدد صفحهبندی و لیست موجودیتها.
|
||
*/
|
||
resetPagination() {
|
||
this.list = [];
|
||
this.pagination = {
|
||
pages: 0,
|
||
total: 0,
|
||
page: 1,
|
||
offset: 0,
|
||
limit: 20,
|
||
};
|
||
},
|
||
},
|
||
|
||
|
||
};
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.show-reports-button {
|
||
opacity: 0.6;
|
||
color: #92a2b2;
|
||
}
|
||
|
||
.text-title-QSection1 {
|
||
color: #00abff !important;
|
||
&:hover {
|
||
// color: blue !important;
|
||
text-decoration: underline !important;
|
||
}
|
||
}
|
||
.text-title-nextItem {
|
||
color: #00abff !important;
|
||
&:hover {
|
||
color: blue !important;
|
||
}
|
||
}
|
||
.text-title-prevItem {
|
||
color: #00abff !important;
|
||
&:hover {
|
||
color: blue !important;
|
||
}
|
||
}
|
||
.text-title-QSection2 {
|
||
color: #00abff !important;
|
||
&:hover {
|
||
// color: blue !important;
|
||
text-decoration: underline !important;
|
||
}
|
||
}
|
||
.sidebar-menu {
|
||
padding-top: 2em;
|
||
list-style: none;
|
||
li {
|
||
display: flex;
|
||
margin-bottom: 16px;
|
||
.sidebar-menu-link {
|
||
color: #bbc4ce;
|
||
|
||
&:hover,
|
||
&.active {
|
||
color: #1e1e1e;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.filter-list-container {
|
||
.mobile-mode {
|
||
display: none;
|
||
}
|
||
}
|
||
@media screen and (max-width: 61.998em) {
|
||
.filter-list-container {
|
||
padding-top: 0.5em;
|
||
position: fixed;
|
||
right: 0;
|
||
margin-right: var(--sidebar-collapsed-width);
|
||
z-index: 9;
|
||
width: auto;
|
||
|
||
.main-filter {
|
||
display: none;
|
||
}
|
||
.mobile-mode {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
|
||
.btn {
|
||
border-radius: 50%;
|
||
// font-size: 0.7rem;
|
||
width: 2.5em;
|
||
height: 2.5em;
|
||
box-shadow: -6px 0px 7px 1px #eee;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
transform: translateX(1.5em);
|
||
background-color: #eee;
|
||
|
||
&:hover {
|
||
filter: brightness(0.8);
|
||
}
|
||
}
|
||
}
|
||
|
||
&.expanded {
|
||
top: 0;
|
||
bottom: 0;
|
||
background: #fff;
|
||
justify-content: center;
|
||
box-shadow: -1px 0px 7px 1px #eee;
|
||
|
||
.main-filter {
|
||
display: block;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|