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