This commit is contained in:
Viet An
2026-05-21 09:45:01 +07:00
parent a52c33706a
commit 8f95fee8a7
18 changed files with 70 additions and 45 deletions

View File

@@ -26,7 +26,7 @@
@blur="lostFocus" @blur="lostFocus"
@keyup.enter="pressEnter" @keyup.enter="pressEnter"
@keyup.esc="lostFocus" @keyup.esc="lostFocus"
@input="(e) => debouncedGetSuggestions(e.target.value)" @input="debouncedGetSuggestions($event.target.value)"
v-model="value" v-model="value"
:placeholder="placeholder" :placeholder="placeholder"
/> />
@@ -96,7 +96,7 @@
> >
<button <button
class="button is-primary is-light" class="button is-primary is-light"
@click="viewInfo()" @click="viewInfo"
style="height: 100%" style="height: 100%"
type="button" type="button"
> >
@@ -167,9 +167,18 @@ const showmodal = ref();
const params = ref(props.api && $findapi(props.api).params); const params = ref(props.api && $findapi(props.api).params);
const orgdata = ref(); const orgdata = ref();
const focused = ref(false); const focused = ref(false);
const pos = ref(); const pos = computed(() => {
switch (props.position) {
getPos(); case "is-top-left":
return "is-up is-left";
case "is-top-right":
return "is-up is-right";
case "is-bottom-left":
return "is-right";
case "is-bottom-right":
return "is-right";
}
});
if (props.vdata) { if (props.vdata) {
orgdata.value = props.vdata; orgdata.value = props.vdata;
@@ -357,23 +366,6 @@ function viewInfo() {
vbind: { row: selected.value }, vbind: { row: selected.value },
}; };
} }
function getPos() {
switch (props.position) {
case "is-top-left":
pos.value = "is-up is-left";
break;
case "is-top-right":
pos.value = "is-up is-right";
break;
case "is-bottom-left":
pos.value = "is-right";
break;
case "is-bottom-right":
pos.value = "is-right";
break;
}
}
</script> </script>
<style scoped> <style scoped>
.control.is-loading::after { .control.is-loading::after {

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Battery", body.value); const newRow = await $insertapi("Battery", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("CPU", body.value); const newRow = await $insertapi("CPU", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Camera_System", body.value); const newRow = await $insertapi("Camera_System", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Charging_Technology", body.value); const newRow = await $insertapi("Charging_Technology", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Color", body.value); const newRow = await $insertapi("Color", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Design", body.value); const newRow = await $insertapi("Design", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -9,7 +10,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("External_Storage", body.value); const newRow = await $insertapi("External_Storage", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -9,7 +10,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("GPU", body.value); const newRow = await $insertapi("GPU", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -9,7 +10,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("IP_Rating", body.value); const newRow = await $insertapi("IP_Rating", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -2,6 +2,7 @@
import InputNumber from "@/components/common/InputNumber.vue"; import InputNumber from "@/components/common/InputNumber.vue";
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -11,7 +12,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Internal_Storage", body.value); const newRow = await $insertapi("Internal_Storage", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -9,7 +10,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Manufacturer", body.value); const newRow = await $insertapi("Manufacturer", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -9,7 +10,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Network_Technology", body.value); const newRow = await $insertapi("Network_Technology", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -10,7 +11,9 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("OS", body.value); const newRow = await $insertapi("OS", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -2,6 +2,7 @@
import InputNumber from "@/components/common/InputNumber.vue"; import InputNumber from "@/components/common/InputNumber.vue";
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -11,7 +12,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("RAM", body.value); const newRow = await $insertapi("RAM", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -2,6 +2,7 @@
import InputNumber from "@/components/common/InputNumber.vue"; import InputNumber from "@/components/common/InputNumber.vue";
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -12,7 +13,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("SIM", body.value); const newRow = await $insertapi("SIM", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
const { $empty, $insertapi } = useNuxtApp(); const { $empty, $insertapi } = useNuxtApp();
const emit = defineEmits(["modalevent"]);
const isLoading = ref(false); const isLoading = ref(false);
const body = ref({ const body = ref({
@@ -15,7 +16,8 @@ const body = ref({
async function submit() { async function submit() {
isLoading.value = true; isLoading.value = true;
await $insertapi("Screen", body.value); const newRow = await $insertapi("Screen", body.value);
emit("modalevent", { name: "dataevent", data: newRow });
isLoading.value = false; isLoading.value = false;
} }
</script> </script>

View File

@@ -1197,18 +1197,18 @@ export default defineNuxtPlugin((nuxtApp) => {
const found = findapi(name); const found = findapi(name);
const curpath = found.path ? paths.find((x) => x.name === found.path).url : path; const curpath = found.path ? paths.find((x) => x.name === found.path).url : path;
let rs; let rs;
if (!Array.isArray(data)) { if (Array.isArray(data)) {
rs = await $fetch(`${curpath}${found.url}`, {
method: "POST",
body: data,
params: { values },
});
} else {
rs = await $fetch(`${curpath}import-data/${found.url.substring(5, found.url.length - 1)}/`, { rs = await $fetch(`${curpath}import-data/${found.url.substring(5, found.url.length - 1)}/`, {
method: "POST", method: "POST",
body: data, body: data,
params: { values, action: "import" }, params: { values, action: "import" },
}); });
} else {
rs = await $fetch(`${curpath}${found.url}`, {
method: "POST",
body: data,
params: { values },
});
} }
// update store // update store
if (found.commit) { if (found.commit) {