This commit is contained in:
Viet An
2026-06-07 11:25:43 +07:00
parent ee914cc382
commit 605b016a5f
18 changed files with 156 additions and 141 deletions

View File

@@ -47,7 +47,7 @@ export default {
} }
}, },
watch: { watch: {
record: function (newVal) { record() {
this.value = this.$numtoString(this.record[this.attr]); this.value = this.$numtoString(this.record[this.attr]);
}, },
}, },

View File

@@ -99,10 +99,10 @@ export default {
}, },
computed: { computed: {
login: { login: {
get: function () { get() {
return this.$store.login; return this.$store.login;
}, },
set: function (val) { set(val) {
this.$store.commit("updateLogin", { login: val }); this.$store.commit("updateLogin", { login: val });
}, },
}, },

View File

@@ -517,11 +517,11 @@ const initData = function () {
condition = conditions.find((v) => v.code === "no"); condition = conditions.find((v) => v.code === "no");
}; };
/*watch: { /*watch: {
expression: function(newVal) { expression(newVal) {
if($empty(newVal)) return if($empty(newVal)) return
elsecheckExpression() elsecheckExpression()
}, },
tab: function(newVal, oldVal) { tab(newVal, oldVal) {
if(oldVal===undefined) return if(oldVal===undefined) return
if(newVal.code==='template') { if(newVal.code==='template') {
let value = '<div>' let value = '<div>'

View File

@@ -110,17 +110,17 @@
</tbody> </tbody>
</table> </table>
<DatatablePagination <DatatablePagination
v-bind="{ data: data, perPage: perPage }"
@changepage="changePage"
v-if="showPaging" v-if="showPaging"
></DatatablePagination> v-bind="{ data, perPage }"
@changepage="changePage"
/>
</div> </div>
<Modal <Modal
v-if="showmodal"
v-bind="showmodal"
@close="close" @close="close"
@selected="doSelect" @selected="doSelect"
@confirm="confirmRemove" @confirm="confirmRemove"
v-bind="showmodal"
v-if="showmodal"
/> />
</template> </template>
<script setup> <script setup>

View File

@@ -169,33 +169,33 @@ export default {
this.tagsField.push(this.pageData.fields.find((v) => v.name === this.field.name)); this.tagsField.push(this.pageData.fields.find((v) => v.name === this.field.name));
}, },
watch: { watch: {
expression: function (newVal) { expression(newVal) {
if (this.$empty(newVal)) return; if (this.$empty(newVal)) return;
else this.changeStyle(); else this.changeStyle();
}, },
}, },
computed: { computed: {
colorscheme: { colorscheme: {
get: function () { get() {
return this.$store.state.colorscheme; return this.$store.colorscheme;
}, },
set: function (val) { set(val) {
this.$store.commit("updateColorScheme", { colorscheme: val }); this.$store.commit("updateColorScheme", { colorscheme: val });
}, },
}, },
pageData: { pageData: {
get: function () { get() {
return this.$store.state[this.pagename]; return this.$store[this.pagename];
}, },
set: function (val) { set(val) {
this.$store.commit("updateStore", { name: this.pagename, data: val }); this.$store.commit("updateStore", { name: this.pagename, data: val });
}, },
}, },
colorchoice: { colorchoice: {
get: function () { get() {
return this.$store.state.colorchoice; return this.$store.colorchoice;
}, },
set: function (val) { set(val) {
this.$store.commit("updateColorChoice", { colorchoice: val }); this.$store.commit("updateColorChoice", { colorchoice: val });
}, },
}, },

View File

@@ -295,7 +295,7 @@ export default {
}, },
computed: { computed: {
lang: function () { lang() {
return this.store.lang; return this.store.lang;
}, },
}, },

View File

@@ -133,13 +133,13 @@ export default {
this.showDate(); this.showDate();
}, },
watch: { watch: {
date: function (newVal) { date(newVal) {
if (newVal) this.showDate(); if (newVal) this.showDate();
}, },
vmonth: function (newVal) { vmonth() {
this.showDate(); this.showDate();
}, },
events: function (newVal) { events() {
this.showDate(); this.showDate();
}, },
}, },

View File

@@ -142,10 +142,10 @@ export default {
this.showDate(); this.showDate();
}, },
watch: { watch: {
date: function (newVal) { date(newVal) {
if (newVal) this.showDate(); if (newVal) this.showDate();
}, },
events: function (newVal) { events(newVal) {
this.showDate(); this.showDate();
}, },
}, },

View File

@@ -46,10 +46,10 @@ export default {
}, },
computed: { computed: {
approvalcode: { approvalcode: {
get: function () { get() {
return this.$store.state["approvalcode"]; return this.$store.state["approvalcode"];
}, },
set: function (val) { set(val) {
this.$store.commit("updateStore", { name: "approvalcode", data: val }); this.$store.commit("updateStore", { name: "approvalcode", data: val });
}, },
}, },

View File

@@ -1,20 +1,21 @@
<template> <template>
<div> <div>
<div class="block">
<p v-html="content"></p> <p v-html="content"></p>
<p class="border-bottom mt-4 mb-5"></p> </div>
<div class="field is-grouped"> <div class="is-flex">
<div class="control is-expanded"> <div class="buttons mb-0">
<button <button
class="button is-danger" class="button is-danger"
@click="remove()" @click="remove"
> >
Đồng ý Đồng ý
</button> </button>
<button <button
class="button is-dark ml-5" class="button is-white"
@click="cancel()" @click="cancel"
> >
Hủy bỏ Hủy
</button> </button>
</div> </div>
<div <div
@@ -22,9 +23,9 @@
v-if="duration" v-if="duration"
> >
<CountDown <CountDown
v-bind="{ duration: duration }" :duration="duration"
@close="cancel()" @close="cancel"
></CountDown> />
</div> </div>
</div> </div>
</div> </div>
@@ -38,7 +39,7 @@ export default {
}, },
async remove() { async remove() {
let pagename = this.vbind.pagename; let pagename = this.vbind.pagename;
let pagedata = this.$store.state[pagename]; let pagedata = this.$store[pagename];
let name = pagedata.origin_api.name || this.vbind.api; let name = pagedata.origin_api.name || this.vbind.api;
let id = this.vbind.row.id; let id = this.vbind.row.id;
let result; let result;
@@ -50,7 +51,7 @@ export default {
if (result === "error") return this.$dialog("Đã xảy ra lỗi, xóa dữ liệu thất bại", "Lỗi", "Error"); if (result === "error") return this.$dialog("Đã xảy ra lỗi, xóa dữ liệu thất bại", "Lỗi", "Error");
this.$snackbar("Dữ liệu đã được xoá khỏi hệ thống", "Success"); this.$snackbar("Dữ liệu đã được xoá khỏi hệ thống", "Success");
let arr = Array.isArray(id) ? id : [{ id: id }]; let arr = Array.isArray(id) ? id : [{ id: id }];
let copy = this.$copy(this.$store.state[pagename].data); let copy = this.$copy(this.$store[pagename].data);
arr.map((x) => { arr.map((x) => {
let index = copy.findIndex((v) => v.id === x.id); let index = copy.findIndex((v) => v.id === x.id);
index >= 0 ? this.$delete(copy, index) : false; index >= 0 ? this.$delete(copy, index) : false;

View File

@@ -40,10 +40,10 @@ export default {
}, },
computed: { computed: {
pagedata: { pagedata: {
get: function () { get() {
return this.$store.state[this.pagename1]; return this.$store.state[this.pagename1];
}, },
set: function (val) { set(val) {
this.$store.commit("updateStore", { name: this.pagename1, data: val }); this.$store.commit("updateStore", { name: this.pagename1, data: val });
}, },
}, },

View File

@@ -72,10 +72,10 @@ export default {
}, },
computed: { computed: {
viewport: { viewport: {
get: function () { get() {
return this.$store.state.viewport; return this.$store.viewport;
}, },
set: function (val) { set(val) {
this.$store.commit("updateViewPort", { viewport: val }); this.$store.commit("updateViewPort", { viewport: val });
}, },
}, },

View File

@@ -295,7 +295,7 @@ export default {
{ name: "image", icon: "material-symbols:grid-view-outline-rounded" }, { name: "image", icon: "material-symbols:grid-view-outline-rounded" },
], ],
timer: undefined, timer: undefined,
vbind: { api: "file", setting: "image-fields" }, vbind: { api: "file", setting: "image-fields", pagename: "image-fields" },
dataFiles: [], dataFiles: [],
files: [], files: [],
docid: this.$id(), docid: this.$id(),
@@ -314,7 +314,7 @@ export default {
this.data = result[0].data.rows; this.data = result[0].data.rows;
}, },
watch: { watch: {
data: function () { data() {
this.group = []; this.group = [];
for (let index = 0; index < this.data.length / (this.type === "video" ? 4 : 5); index++) { for (let index = 0; index < this.data.length / (this.type === "video" ? 4 : 5); index++) {
this.group.push(index); this.group.push(index);
@@ -323,18 +323,18 @@ export default {
}, },
computed: { computed: {
login: { login: {
get: function () { get() {
return this.$store.login; return this.$store.login;
}, },
set: function (val) { set(val) {
this.$store.commit("updateLogin", { login: val }); this.$store.commit("updateLogin", { login: val });
}, },
}, },
media: { media: {
get: function () { get() {
return this.$store.media; return this.$store.media;
}, },
set: function (val) { set(val) {
this.$store.commit("updateMedia", { media: val }); this.$store.commit("updateMedia", { media: val });
}, },
}, },

View File

@@ -1,71 +1,84 @@
<template> <template>
<div> <div>
<b-tooltip <button
label="Mở file"
position="is-left"
type="is-link"
>
<a
class="mr-3"
@click="openFile(row)" @click="openFile(row)"
class="button is-small is-ghost"
> >
<SvgIcon v-bind="{ name: 'open.svg', type: 'dark', size: 16 }"></SvgIcon> <span class="icon">
</a> <Icon
</b-tooltip> name="material-symbols:open-in-new-rounded"
<!-- <b-tooltip label="Tải xuống" position="is-left" type="is-link"> :size="18"
<a class="mr-3" @click="download(row)"> />
<SvgIcon v-bind="{name: 'download1.svg', type: 'dark', size: 16}"></SvgIcon> </span>
</a> </button>
</b-tooltip> --> <button
<b-tooltip @click="download(row)"
label="Xóa" class="button is-small is-ghost"
position="is-left"
type="is-danger"
v-if="disable ? !disable.delete : true"
> >
<a @click="remove()"> <span class="icon">
<SvgIcon v-bind="{ name: 'bin1.svg', type: 'dark', size: 16 }"></SvgIcon> <Icon
</a> name="material-symbols:download-rounded"
</b-tooltip> :size="18"
/>
</span>
</button>
<button
@click="remove"
class="button is-small is-ghost"
>
<span class="icon">
<Icon
name="material-symbols:delete-outline-rounded"
:size="18"
class="has-text-danger"
/>
</span>
</button>
<Modal
v-if="showModal"
v-bind="showModal"
@close="showModal = undefined"
/>
</div> </div>
</template> </template>
<script> <script setup>
export default { import Modal from "~/components/Modal.vue";
props: ["api", "pagename", "row", "disable"],
methods: { const { $getpath } = useNuxtApp();
async openFile(row) {
const url = `${this.$getpath()}static/files/${row.file__file || row.file}`; const showModal = ref();
const props = defineProps(["api", "pagename", "row", "disable"]);
const emit = defineEmits(["open"]);
async function openFile(row) {
const url = `${$getpath()}static/files/${row.file__file || row.file}`;
window.open(url, "_blank"); window.open(url, "_blank");
}, }
async downloadFile(url, fileName) {
// const response = await fetch(url, { method: "GET" }); async function download(row) {
// const blob = await response.blob(); const url = `${$getpath()}static/files/${row.file__file || row.file}`;
const urlDownload = url; //window.URL.createObjectURL(blob);
const link = document.createElement("a"); const link = document.createElement("a");
link.href = urlDownload; link.href = url;
link.setAttribute("download", fileName); link.target = "_blank";
link.setAttribute("download", row.file);
link.click(); link.click();
}, }
async download(row) {
let url = `${this.$getpath()}static/files/${row.file__file || row.file}`; function remove() {
await this.downloadFile(url, row.file__file || row.file); showModal.value = {
},
remove() {
let text = "Bạn có muốn xóa file <b>#file</b> không?";
text = text.replace("#file", this.row.file__name);
let obj = {
component: "dialog/Delete", component: "dialog/Delete",
title: this.$store.lang === "en" ? "Delete file" : "Xóa file", title: "Xóa file",
width: "500px", width: "500px",
height: "100px", height: "auto",
vbind: { vbind: {
content: text, content: `Bạn có muốn xóa file <b>${props.row.name}</b> không?`,
duration: 10, duration: 10,
vbind: { row: this.row, api: this.api, pagename: this.pagename }, vbind: {
}, row: props.row,
}; api: props.api,
this.$emit("open", { name: "dataevent", data: { modal: obj } }); pagename: props.pagename,
}, },
}, },
}; };
}
</script> </script>

View File

@@ -180,10 +180,10 @@ export default {
}, },
computed: { computed: {
pagedata: { pagedata: {
get: function () { get() {
return this.$store[this.pagename]; return this.$store[this.pagename];
}, },
set: function (val) { set(val) {
this.$store.commit(this.pagename, val); this.$store.commit(this.pagename, val);
}, },
}, },

View File

@@ -102,26 +102,26 @@ export default {
}, },
computed: { computed: {
pagedata1: { pagedata1: {
get: function () { get() {
return this.$store[this.pagename1]; return this.$store[this.pagename1];
}, },
set: function (val) { set(val) {
this.$store.commit(this.pagename1, val); this.$store.commit(this.pagename1, val);
}, },
}, },
pagedata2: { pagedata2: {
get: function () { get() {
return this.$store[this.pagename2]; return this.$store[this.pagename2];
}, },
set: function (val) { set(val) {
this.$store.commit(this.pagename2, val); this.$store.commit(this.pagename2, val);
}, },
}, },
pagedata3: { pagedata3: {
get: function () { get() {
return this.$store[this.pagename3]; return this.$store[this.pagename3];
}, },
set: function (val) { set(val) {
this.$store.commit(this.pagename3, val); this.$store.commit(this.pagename3, val);
}, },
}, },

View File

@@ -187,50 +187,50 @@ export default {
}, },
computed: { computed: {
common: { common: {
get: function () { get() {
return this.$store.state.common; return this.$store.common;
}, },
set: function (val) { set(val) {
this.$store.commit("updateCommon", { common: val }); this.$store.commit("updateCommon", { common: val });
}, },
}, },
registermethod: { registermethod: {
get: function () { get() {
return this.$store.state.registermethod; return this.$store.registermethod;
}, },
set: function (val) { set(val) {
this.$store.commit("updateRegisterMethod", { registermethod: val }); this.$store.commit("updateRegisterMethod", { registermethod: val });
}, },
}, },
authmethod: { authmethod: {
get: function () { get() {
return this.$store.state.authmethod; return this.$store.authmethod;
}, },
set: function (val) { set(val) {
this.$store.commit("updateAuthMethod", { authmethod: val }); this.$store.commit("updateAuthMethod", { authmethod: val });
}, },
}, },
authstatus: { authstatus: {
get: function () { get() {
return this.$store.state.authstatus; return this.$store.authstatus;
}, },
set: function (val) { set(val) {
this.$store.commit("updateAuthStatus", { authstatus: val }); this.$store.commit("updateAuthStatus", { authstatus: val });
}, },
}, },
usertype: { usertype: {
get: function () { get() {
return this.$store.state.usertype; return this.$store.usertype;
}, },
set: function (val) { set(val) {
this.$store.commit("updateUserType", { usertype: val }); this.$store.commit("updateUserType", { usertype: val });
}, },
}, },
dialog: { dialog: {
get: function () { get() {
return this.$store.state["dialog"]; return this.$store.dialog;
}, },
set: function (val) { set(val) {
this.$store.commit("updateStore", { name: "dialog", data: val }); this.$store.commit("updateStore", { name: "dialog", data: val });
}, },
}, },

View File

@@ -18,6 +18,7 @@ dayjs.locale("vi");
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
const route = useRoute(); const route = useRoute();
const { $id, $empty, $store } = nuxtApp; const { $id, $empty, $store } = 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);
const vtitle = const vtitle =