chore: install prettier

This commit is contained in:
Viet An
2026-05-04 15:22:27 +07:00
parent 93d29ca7d8
commit bd58e2b847
267 changed files with 22950 additions and 13581 deletions

View File

@@ -1,23 +1,22 @@
<script setup>
import { getLayerNames } from '@/components/viewer/utils/aps-viewer';
import { getLayerNames } from "@/components/viewer/utils/aps-viewer";
const store = useStore();
const { layersetting } = store;
const emit = defineEmits('close');
const emit = defineEmits("close");
const { $insertapi, $patchapi, $snackbar } = useNuxtApp();
const radioSave = ref(layersetting ? "overwrite" : "new");
const name = ref(radioSave === 'new' ? '' : layersetting ? layersetting.name : '');
const name = ref(radioSave === "new" ? "" : layersetting ? layersetting.name : "");
const errors = ref([]);
watch(radioSave, (val) => {
name.value = val === 'new' ? '' : layersetting.name;
name.value = val === "new" ? "" : layersetting.name;
errors.value = [];
});
function switchRadioSave(newVal) {
if (newVal === 'overwrite' && !layersetting)
return;
if (newVal === "overwrite" && !layersetting) return;
radioSave.value = newVal;
}
@@ -25,29 +24,36 @@ async function saveLayerSetting() {
const layerNames = getLayerNames();
const user = store.login.id;
if (!name.value) {
errors.value.push({ name: "name", msg: "Tên thiết lập không được bỏ trống" })
errors.value.push({
name: "name",
msg: "Tên thiết lập không được bỏ trống",
});
return;
}
const payload = {
user,
name: name.value,
detail: layerNames
}
detail: layerNames,
};
if (radioSave.value === 'overwrite') {
if (radioSave.value === "overwrite") {
payload.id = layersetting.id;
}
const res = radioSave.value === 'new' ? await $insertapi('layersetting', payload) : await $patchapi('layersetting', payload);
if (res === 'error') {
$snackbar(isVietnamese.value ? `Có lỗi xảy ra khi ${radioSave.value === 'new' ? 'tạo' : 'cập nhật' } thiết lập` : `Error ${radioSave.value === 'new' ? 'creating' : 'updating' } layer setting`,
const res =
radioSave.value === "new" ? await $insertapi("layersetting", payload) : await $patchapi("layersetting", payload);
if (res === "error") {
$snackbar(
isVietnamese.value
? `Có lỗi xảy ra khi ${radioSave.value === "new" ? "tạo" : "cập nhật"} thiết lập`
: `Error ${radioSave.value === "new" ? "creating" : "updating"} layer setting`,
"Lỗi",
"Error"
"Error",
);
} else {
store.commit('layersetting', res);
emit('close');
store.commit("layersetting", res);
emit("close");
}
}
</script>
@@ -55,23 +61,34 @@ async function saveLayerSetting() {
<div class="field">
<label class="label fs-14">Chọn chế độ lưu</label>
<div class="control">
<button class="button is-white fs-14 px-2 py-1" @click="switchRadioSave('overwrite')" :disabled="layersetting === undefined">
<button
class="button is-white fs-14 px-2 py-1"
@click="switchRadioSave('overwrite')"
:disabled="layersetting === undefined"
>
<span class="icon-text">
<SvgIcon v-bind="{
name: `radio-${radioSave === 'new' ? 'unchecked' : 'checked'}.svg`,
type: 'gray',
size: 22,
}" />
<SvgIcon
v-bind="{
name: `radio-${radioSave === 'new' ? 'unchecked' : 'checked'}.svg`,
type: 'gray',
size: 22,
}"
/>
Ghi đè
</span>
</button>
<button class="button is-white fs-14 px-2 py-1" @click="switchRadioSave('new')">
<button
class="button is-white fs-14 px-2 py-1"
@click="switchRadioSave('new')"
>
<span class="icon-text">
<SvgIcon v-bind="{
name: `radio-${radioSave === 'new' ? 'checked' : 'unchecked'}.svg`,
type: 'gray',
size: 22
}" />
<SvgIcon
v-bind="{
name: `radio-${radioSave === 'new' ? 'checked' : 'unchecked'}.svg`,
type: 'gray',
size: 22,
}"
/>
Tạo mới
</span>
</button>
@@ -82,22 +99,29 @@ async function saveLayerSetting() {
<div class="control">
<input
class="input"
style="box-sizing: border-box;"
style="box-sizing: border-box"
type="text"
placeholder="e.g. Đường, Mặt hồ"
v-model="name"
@keydown.enter="saveLayerSetting"
/>
</div>
<div class="help has-text-danger" v-if="errors.find((v) => v.name === 'name')">
<div
class="help has-text-danger"
v-if="errors.find((v) => v.name === 'name')"
>
{{ errors.find((v) => v.name === "name").msg }}
</div>
</div>
<div class="field">
<p class="control">
<button class="button is-primary" @click="saveLayerSetting()">Lưu lại</button>
<button
class="button is-primary"
@click="saveLayerSetting()"
>
Lưu lại
</button>
</p>
</div>
</template>
<style>
</style>
<style></style>