changes
This commit is contained in:
@@ -65,7 +65,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const isVietnamese = computed(() => store.lang === "vi");
|
const isVietnamese = computed(() => store.lang === "vi");
|
||||||
|
|||||||
@@ -199,7 +199,6 @@
|
|||||||
import InputPhone from "~/components/common/InputPhone";
|
import InputPhone from "~/components/common/InputPhone";
|
||||||
import InputEmail from "~/components/common/InputEmail";
|
import InputEmail from "~/components/common/InputEmail";
|
||||||
import SearchBox from "~/components/SearchBox";
|
import SearchBox from "~/components/SearchBox";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
var props = defineProps({
|
var props = defineProps({
|
||||||
pagename: String,
|
pagename: String,
|
||||||
row: Object,
|
row: Object,
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ import { useNuxtApp } from "#app";
|
|||||||
import CustomerForm from "~/components/customer/CustomerForm.vue";
|
import CustomerForm from "~/components/customer/CustomerForm.vue";
|
||||||
import CustomerView from "~/components/customer/CustomerView.vue";
|
import CustomerView from "~/components/customer/CustomerView.vue";
|
||||||
import Modal from "~/components/Modal.vue";
|
import Modal from "~/components/Modal.vue";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
import ImageGallery from "~/components/media/ImageGallery.vue";
|
import ImageGallery from "~/components/media/ImageGallery.vue";
|
||||||
const nuxtApp = useNuxtApp();
|
const nuxtApp = useNuxtApp();
|
||||||
const { $dialog } = nuxtApp;
|
const { $dialog } = nuxtApp;
|
||||||
|
|||||||
@@ -241,7 +241,6 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { isEqual, pick } from "es-toolkit";
|
import { isEqual, pick } from "es-toolkit";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
import InputPhone from "~/components/common/InputPhone";
|
import InputPhone from "~/components/common/InputPhone";
|
||||||
import InputEmail from "~/components/common/InputEmail";
|
import InputEmail from "~/components/common/InputEmail";
|
||||||
import SearchBox from "~/components/SearchBox";
|
import SearchBox from "~/components/SearchBox";
|
||||||
|
|||||||
@@ -98,7 +98,6 @@
|
|||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import InputPhone from "~/components/common/InputPhone.vue";
|
import InputPhone from "~/components/common/InputPhone.vue";
|
||||||
import InputEmail from "~/components/common/InputEmail.vue";
|
import InputEmail from "~/components/common/InputEmail.vue";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
import { isNotNil, pickBy } from "es-toolkit";
|
import { isNotNil, pickBy } from "es-toolkit";
|
||||||
|
|
||||||
const emit = defineEmits(["close", "update", "modalevent"]);
|
const emit = defineEmits(["close", "update", "modalevent"]);
|
||||||
|
|||||||
@@ -296,7 +296,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -428,9 +428,8 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
import ScrollBox from "~/components/datatable/ScrollBox.vue";
|
import ScrollBox from "~/components/datatable/ScrollBox.vue";
|
||||||
import { cloneDeep, isEqual } from "es-toolkit";
|
import { cloneDeep } from "es-toolkit";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
pagename: String,
|
pagename: String,
|
||||||
|
|||||||
@@ -454,7 +454,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $id, $copy, $empty, $stripHtml, $calc, $remove, $copyToClipboard } = useNuxtApp();
|
const { $id, $copy, $empty, $stripHtml, $calc, $remove, $copyToClipboard } = useNuxtApp();
|
||||||
var props = defineProps({
|
var props = defineProps({
|
||||||
|
|||||||
@@ -135,7 +135,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { createApp } from "vue/dist/vue.esm-bundler.js";
|
import { createApp } from "vue/dist/vue.esm-bundler.js";
|
||||||
import { isEmpty } from "es-toolkit/compat";
|
import { isEmpty } from "es-toolkit/compat";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
|
|
||||||
const emit = defineEmits(["edit", "insert", "dataevent"]);
|
const emit = defineEmits(["edit", "insert", "dataevent"]);
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
v-if="timeopt"
|
v-if="timeopt"
|
||||||
v-bind="{
|
v-bind="{
|
||||||
pagename: vpagename,
|
pagename: vpagename,
|
||||||
api: api,
|
api,
|
||||||
timeopt: timeopt,
|
timeopt,
|
||||||
filter: optfilter,
|
filter: optfilter,
|
||||||
importdata: props.importdata,
|
importdata,
|
||||||
newDataAvailable: newDataAvailable,
|
newDataAvailable,
|
||||||
params: vparams,
|
params: vparams,
|
||||||
}"
|
}"
|
||||||
ref="timeopt"
|
ref="timeopt"
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import TimeOption from "~/components/datatable/TimeOption";
|
import TimeOption from "~/components/datatable/TimeOption";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
// [FIX] Thêm onActivated, onDeactivated để xử lý KeepAlive
|
// [FIX] Thêm onActivated, onDeactivated để xử lý KeepAlive
|
||||||
import { ref, watch, onBeforeUnmount, onActivated, onDeactivated } from "vue";
|
import { ref, watch, onBeforeUnmount, onActivated, onDeactivated } from "vue";
|
||||||
import DataTable from "~/components/datatable/DataTable.vue";
|
import DataTable from "~/components/datatable/DataTable.vue";
|
||||||
|
|||||||
@@ -109,7 +109,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
|
|
||||||
const emit = defineEmits(["modalevent", "close"]);
|
const emit = defineEmits(["modalevent", "close"]);
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -258,7 +258,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { cloneDeep } from "es-toolkit";
|
import { cloneDeep } from "es-toolkit";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
const emit = defineEmits(["modalevent"]);
|
const emit = defineEmits(["modalevent"]);
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $id, $copy, $empty, $stripHtml, $createField, $calc, $isNumber } = useNuxtApp();
|
const { $id, $copy, $empty, $stripHtml, $createField, $calc, $isNumber } = useNuxtApp();
|
||||||
|
|||||||
@@ -198,7 +198,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import TimeOption from "~/components/datatable/TimeOption";
|
import TimeOption from "~/components/datatable/TimeOption";
|
||||||
import { ref, computed, watch, onMounted, onBeforeUnmount, defineComponent } from "vue";
|
import { ref, computed, watch, onMounted, onBeforeUnmount, defineComponent } from "vue";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
import { cloneDeep } from "es-toolkit";
|
import { cloneDeep } from "es-toolkit";
|
||||||
|
|
||||||
const emit = defineEmits(["modalevent", "dataevent", "dataUpdated", "edit", "insert"]);
|
const emit = defineEmits(["modalevent", "dataevent", "dataUpdated", "edit", "insert"]);
|
||||||
|
|||||||
@@ -78,7 +78,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { cloneDeep } from "es-toolkit";
|
import { cloneDeep } from "es-toolkit";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
const emit = defineEmits(["close"]);
|
const emit = defineEmits(["close"]);
|
||||||
const { $stripHtml, $arrayMove, $remove } = useNuxtApp();
|
const { $stripHtml, $arrayMove, $remove } = useNuxtApp();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -170,8 +170,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -44,8 +44,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const emit = defineEmits(["clickevent"]);
|
const emit = defineEmits(["clickevent"]);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@@ -257,7 +257,6 @@ import InputEmail from "~/components/common/InputEmail";
|
|||||||
import SearchBox from "~/components/SearchBox";
|
import SearchBox from "~/components/SearchBox";
|
||||||
import Datepicker from "~/components/datepicker/Datepicker";
|
import Datepicker from "~/components/datepicker/Datepicker";
|
||||||
|
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
var props = defineProps({
|
var props = defineProps({
|
||||||
pagename: String,
|
pagename: String,
|
||||||
row: Object,
|
row: Object,
|
||||||
|
|||||||
@@ -178,7 +178,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
import Info from "~/components/snackbar/Info.vue";
|
import Info from "~/components/snackbar/Info.vue";
|
||||||
import Success from "~/components/snackbar/Success.vue";
|
import Success from "~/components/snackbar/Success.vue";
|
||||||
import Error from "~/components/snackbar/Error.vue";
|
import Error from "~/components/snackbar/Error.vue";
|
||||||
|
|||||||
@@ -55,7 +55,6 @@
|
|||||||
import Logout from "~/components/user/Logout";
|
import Logout from "~/components/user/Logout";
|
||||||
import UserInfo from "~/components/user/UserInfo";
|
import UserInfo from "~/components/user/UserInfo";
|
||||||
import ChangePass from "~/components/user/ChangePass";
|
import ChangePass from "~/components/user/ChangePass";
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const lang = computed(() => store.lang);
|
const lang = computed(() => store.lang);
|
||||||
const isVietnamese = computed(() => lang.value === "vi");
|
const isVietnamese = computed(() => lang.value === "vi");
|
||||||
|
|||||||
@@ -48,7 +48,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { useStore } from "~/stores/index";
|
|
||||||
export default {
|
export default {
|
||||||
props: ["userId"],
|
props: ["userId"],
|
||||||
setup() {
|
setup() {
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ dayjs.locale("vi");
|
|||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { $id, $empty, $store } = nuxtApp;
|
const store = useStore();
|
||||||
|
const { $id, $empty } = nuxtApp;
|
||||||
|
|
||||||
const dialog = function (content, title, type, duration, width, height, vbind) {
|
const dialog = function (content, title, type, duration, width, height, vbind) {
|
||||||
content = typeof content === "string" ? content : JSON.stringify(content);
|
content = typeof content === "string" ? content : JSON.stringify(content);
|
||||||
@@ -38,11 +39,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
height: height || "100px",
|
height: height || "100px",
|
||||||
};
|
};
|
||||||
|
|
||||||
$store.commit("showmodal", data);
|
store.commit("showmodal", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const snackbar = function (content, component = "Info") {
|
const snackbar = function (content, component = "Info") {
|
||||||
$store.commit("snackbar", {
|
store.commit("snackbar", {
|
||||||
component,
|
component,
|
||||||
vbind: {
|
vbind: {
|
||||||
content: typeof content === "string" ? content : JSON.stringify(content),
|
content: typeof content === "string" ? content : JSON.stringify(content),
|
||||||
@@ -315,8 +316,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const lang = function (code) {
|
const lang = function (code) {
|
||||||
let field = $store.common.find((v) => v.code === code);
|
let field = store.common.find((v) => v.code === code);
|
||||||
return field ? field[$store.lang] : "";
|
return field ? field[store.lang] : "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const createMeta = function (metainfo) {
|
const createMeta = function (metainfo) {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { $copy, $updateSeriesFields, $snackbar, $store, $remove, $dialog } = nuxtApp;
|
const { $copy, $updateSeriesFields, $snackbar, $remove, $dialog } = nuxtApp;
|
||||||
|
|
||||||
const requestLogin = function () {
|
const requestLogin = function () {
|
||||||
$store.commit("login", undefined);
|
store.commit("login", undefined);
|
||||||
window.location.href = `https://${mode === "dev" ? "dev." : ""}login.utopia.com.vn/signin?module=${module}&link=${window.location.origin}`;
|
window.location.href = `https://${mode === "dev" ? "dev." : ""}login.utopia.com.vn/signin?module=${module}&link=${window.location.origin}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
if (found) {
|
if (found) {
|
||||||
const apiWithReady = {
|
const apiWithReady = {
|
||||||
...$copy(found),
|
...$copy(found),
|
||||||
ready: Boolean($store[apiName]),
|
ready: Boolean(store[apiName]),
|
||||||
};
|
};
|
||||||
apisWithReady.push(apiWithReady);
|
apisWithReady.push(apiWithReady);
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
const api = apis.find((api) => api.name === v.name);
|
const api = apis.find((api) => api.name === v.name);
|
||||||
const url = getpath(v.path) + (v.url || api.url);
|
const url = getpath(v.path) + (v.url || api.url);
|
||||||
const params = v.params || api.params || {};
|
const params = v.params || api.params || {};
|
||||||
params.login = $store.login?.id;
|
params.login = store.login?.id;
|
||||||
return { url, params };
|
return { url, params };
|
||||||
});
|
});
|
||||||
const data = await Promise.all(arr.map(({ url, params }) => $fetch(url, { params })));
|
const data = await Promise.all(arr.map(({ url, params }) => $fetch(url, { params })));
|
||||||
@@ -69,7 +69,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
list[i].data = v;
|
list[i].data = v;
|
||||||
if (list[i].commit) {
|
if (list[i].commit) {
|
||||||
const data = v.rows ? v.rows : v;
|
const data = v.rows ? v.rows : v;
|
||||||
$store.commit(list[i].commit, data);
|
store.commit(list[i].commit, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
@@ -85,8 +85,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
const insertapi = async function (name, { data, values, notify = true } = {}) {
|
const insertapi = async function (name, { data, values, notify = true } = {}) {
|
||||||
try {
|
try {
|
||||||
const api = findapi(name);
|
const api = findapi(name);
|
||||||
const curpath = api.path ? paths.find((x) => x.name === api.path).url : path;
|
const curpath = getpath(api.path);
|
||||||
let rs;
|
let rs;
|
||||||
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
rs = await $fetch(`${curpath}import-data/${api.url.substring(5, api.url.length - 1)}/`, {
|
rs = await $fetch(`${curpath}import-data/${api.url.substring(5, api.url.length - 1)}/`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -102,8 +103,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
}
|
}
|
||||||
// update store
|
// update store
|
||||||
if (api.commit) {
|
if (api.commit) {
|
||||||
if ($store[api.commit]) {
|
if (store[api.commit]) {
|
||||||
const copy = $copy($store[api.commit]);
|
const copy = $copy(store[api.commit]);
|
||||||
const rows = Array.isArray(rs) ? rs : [rs];
|
const rows = Array.isArray(rs) ? rs : [rs];
|
||||||
rows.forEach((v) => {
|
rows.forEach((v) => {
|
||||||
if (v.id && !v.error) {
|
if (v.id && !v.error) {
|
||||||
@@ -112,12 +113,12 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
else copy.push(v);
|
else copy.push(v);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$store.commit(api.commit, copy);
|
store.commit(api.commit, copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notify) {
|
if (notify) {
|
||||||
$snackbar(
|
$snackbar(
|
||||||
$store.lang === "en" ? "Data has been successfully saved to the system." : "Dữ liệu đã được lưu vào hệ thống",
|
store.lang === "en" ? "Data has been successfully saved to the system." : "Dữ liệu đã được lưu vào hệ thống",
|
||||||
"Success",
|
"Success",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -144,9 +145,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (api.commit) {
|
if (api.commit) {
|
||||||
const index = $store[api.commit] ? $store[api.commit].findIndex((v) => v.id === rs.id) : -1;
|
const index = store[api.commit] ? store[api.commit].findIndex((v) => v.id === rs.id) : -1;
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
const copy = $copy($store[api.commit]);
|
const copy = $copy(store[api.commit]);
|
||||||
if (Array.isArray(rs)) {
|
if (Array.isArray(rs)) {
|
||||||
rs.forEach((r) => {
|
rs.forEach((r) => {
|
||||||
const index = copy.findIndex((v) => v.id === r.id);
|
const index = copy.findIndex((v) => v.id === r.id);
|
||||||
@@ -155,13 +156,13 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
} else {
|
} else {
|
||||||
copy[index] = rs;
|
copy[index] = rs;
|
||||||
}
|
}
|
||||||
$store.commit(api.commit, copy);
|
store.commit(api.commit, copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notify) {
|
if (notify) {
|
||||||
$snackbar(
|
$snackbar(
|
||||||
$store.lang === "en" ? "Data has been successfully saved to the system." : "Dữ liệu đã được lưu vào hệ thống",
|
store.lang === "en" ? "Data has been successfully saved to the system." : "Dữ liệu đã được lưu vào hệ thống",
|
||||||
"Success",
|
"Success",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -173,7 +174,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const findpage = function (arr) {
|
const findpage = function (arr) {
|
||||||
var copy = $copy($store.pagetrack);
|
var copy = $copy(store.pagetrack);
|
||||||
var doFind = function () {
|
var doFind = function () {
|
||||||
let found = undefined;
|
let found = undefined;
|
||||||
for (let i = 1; i <= 30; i++) {
|
for (let i = 1; i <= 30; i++) {
|
||||||
@@ -196,7 +197,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
} else {
|
} else {
|
||||||
result = doFind(copy);
|
result = doFind(copy);
|
||||||
}
|
}
|
||||||
$store.commit("pagetrack", copy);
|
store.commit("pagetrack", copy);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -221,7 +222,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
const setpage = function (pagename, row, api) {
|
const setpage = function (pagename, row, api) {
|
||||||
let json = row.detail;
|
let json = row.detail;
|
||||||
let fields = $updateSeriesFields(json.fields);
|
let fields = $updateSeriesFields(json.fields);
|
||||||
let copy = $store[pagename] || getpage();
|
let copy = store[pagename] || getpage();
|
||||||
copy.fields = fields;
|
copy.fields = fields;
|
||||||
copy.setting = $copy(row);
|
copy.setting = $copy(row);
|
||||||
if (json.filters) copy.filters = $copy(json.filters);
|
if (json.filters) copy.filters = $copy(json.filters);
|
||||||
@@ -234,7 +235,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
copy.api = copyApi;
|
copy.api = copyApi;
|
||||||
copy.origin_api = copy;
|
copy.origin_api = copy;
|
||||||
}
|
}
|
||||||
$store.commit(pagename, copy);
|
store.commit(pagename, copy);
|
||||||
return copy;
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -303,19 +304,19 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
|
|
||||||
const insertrow = async function (name, data, values, pagename, notify) {
|
const insertrow = async function (name, data, values, pagename, notify) {
|
||||||
let result = await insertapi(name, { data, values, notify });
|
let result = await insertapi(name, { data, values, notify });
|
||||||
if (result === "error" || !pagename || !$store[pagename]) return result;
|
if (result === "error" || !pagename || !store[pagename]) return result;
|
||||||
let copy = cloneDeep($store[pagename]);
|
let copy = cloneDeep(store[pagename]);
|
||||||
copy.update = { refresh: true };
|
copy.update = { refresh: true };
|
||||||
$store.commit(pagename, copy);
|
store.commit(pagename, copy);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updaterow = async function (name, data, values, pagename, notify) {
|
const updaterow = async function (name, data, values, pagename, notify) {
|
||||||
let result = await patchapi(name, data, values, notify);
|
let result = await patchapi(name, data, values, notify);
|
||||||
if (result === "error" || !pagename || !$store[pagename]) return result;
|
if (result === "error" || !pagename || !store[pagename]) return result;
|
||||||
let copy = cloneDeep($store[pagename]);
|
let copy = cloneDeep(store[pagename]);
|
||||||
copy.update = { refresh: true };
|
copy.update = { refresh: true };
|
||||||
$store.commit(pagename, copy);
|
store.commit(pagename, copy);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -335,7 +336,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (api.commit) {
|
if (api.commit) {
|
||||||
const copy = $copy($store[api.commit]);
|
const copy = $copy(store[api.commit]);
|
||||||
if (Array.isArray(id)) {
|
if (Array.isArray(id)) {
|
||||||
rs.forEach((element) => {
|
rs.forEach((element) => {
|
||||||
const index = copy.findIndex((v) => v.id === element.id);
|
const index = copy.findIndex((v) => v.id === element.id);
|
||||||
@@ -345,7 +346,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
const index = copy.findIndex((v) => v.id === id);
|
const index = copy.findIndex((v) => v.id === id);
|
||||||
if (index >= 0) $remove(copy, index);
|
if (index >= 0) $remove(copy, index);
|
||||||
}
|
}
|
||||||
$store.commit(api.name, copy);
|
store.commit(api.name, copy);
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -375,16 +376,16 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
|
|
||||||
const deleterow = async function (name, id, pagename) {
|
const deleterow = async function (name, id, pagename) {
|
||||||
const result = await deleteapi(name, id);
|
const result = await deleteapi(name, id);
|
||||||
if (result === "error" || !pagename || !$store[pagename]) return result;
|
if (result === "error" || !pagename || !store[pagename]) return result;
|
||||||
const copy = cloneDeep($store[pagename]);
|
const copy = cloneDeep(store[pagename]);
|
||||||
copy.update = { refresh: true };
|
copy.update = { refresh: true };
|
||||||
$store.commit(pagename, copy);
|
store.commit(pagename, copy);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// update page
|
// update page
|
||||||
const updatepage = function (pagename, row, action) {
|
const updatepage = function (pagename, row, action) {
|
||||||
let copy = cloneDeep($store[pagename]);
|
let copy = cloneDeep(store[pagename]);
|
||||||
let rows = Array.isArray(row) ? row : [row];
|
let rows = Array.isArray(row) ? row : [row];
|
||||||
rows.map((x) => {
|
rows.map((x) => {
|
||||||
let idx = copy.data.findIndex((v) => v.id === x.id);
|
let idx = copy.data.findIndex((v) => v.id === x.id);
|
||||||
@@ -395,7 +396,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
copy.update = { data: copy.data };
|
copy.update = { data: copy.data };
|
||||||
$store.commit(pagename, copy);
|
store.commit(pagename, copy);
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildFileUrl = (file) => {
|
const buildFileUrl = (file) => {
|
||||||
@@ -476,31 +477,32 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
const getEditRights = (right = "edit", { code, category } = {}) => {
|
const getEditRights = (right = "edit", { code, category } = {}) => {
|
||||||
|
return true;
|
||||||
if (!["edit", "view"].includes(right)) throw new Error(`right ${right} is not one of ['edit', 'view']`);
|
if (!["edit", "view"].includes(right)) throw new Error(`right ${right} is not one of ['edit', 'view']`);
|
||||||
|
|
||||||
const getRight = (rightObj) => {
|
const getRight = (rightObj) => {
|
||||||
return right === "edit" ? rightObj && rightObj.is_edit : Boolean(rightObj);
|
return right === "edit" ? rightObj && rightObj.is_edit : Boolean(rightObj);
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($store.rights.length === 0) return true; // full rights
|
if (store.rights.length === 0) return true; // full rights
|
||||||
|
|
||||||
if (code && category) {
|
if (code && category) {
|
||||||
// if passed, must pass both
|
// if passed, must pass both
|
||||||
const foundRight = $store.rights.find(
|
const foundRight = store.rights.find(
|
||||||
({ setting__category, setting__code }) => setting__category === category && setting__code === code,
|
({ setting__category, setting__code }) => setting__category === category && setting__code === code,
|
||||||
);
|
);
|
||||||
return getRight(foundRight);
|
return getRight(foundRight);
|
||||||
} else {
|
} else {
|
||||||
const { tab, subtab } = $store.tabinfo;
|
const { tab, subtab } = store.tabinfo;
|
||||||
let isTabEdit;
|
let isTabEdit;
|
||||||
let isSubTabEdit;
|
let isSubTabEdit;
|
||||||
|
|
||||||
const tabRight = $store.rights.find((rights) => rights.setting === tab.id);
|
const tabRight = store.rights.find((rights) => rights.setting === tab.id);
|
||||||
isTabEdit = getRight(tabRight);
|
isTabEdit = getRight(tabRight);
|
||||||
|
|
||||||
if (!subtab) isSubTabEdit = false;
|
if (!subtab) isSubTabEdit = false;
|
||||||
else {
|
else {
|
||||||
const subTabRight = $store.rights.find((rights) => rights.setting === subtab.id);
|
const subTabRight = store.rights.find((rights) => rights.setting === subtab.id);
|
||||||
isSubTabEdit = getRight(subTabRight);
|
isSubTabEdit = getRight(subTabRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user