changes
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
<div class="control is-expanded is-flex is-gap-0.5 fs-14">
|
||||
<button
|
||||
:class="['button', radioSave === 'overwrite' ? 'is-primary is-light' : 'is-white']"
|
||||
v-if="isOverwrite()"
|
||||
@click="changeType('overwrite')"
|
||||
>
|
||||
<span class="icon">
|
||||
@@ -33,7 +32,7 @@
|
||||
? 'material-symbols:radio-button-checked-outline'
|
||||
: 'material-symbols:radio-button-unchecked'
|
||||
"
|
||||
:size="22"
|
||||
:size="18"
|
||||
/>
|
||||
</span>
|
||||
<span>Ghi đè</span>
|
||||
@@ -49,7 +48,7 @@
|
||||
? 'material-symbols:radio-button-checked-outline'
|
||||
: 'material-symbols:radio-button-unchecked'
|
||||
"
|
||||
:size="22"
|
||||
:size="18"
|
||||
/>
|
||||
</span>
|
||||
<span>Tạo mới</span>
|
||||
@@ -88,36 +87,29 @@
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
<div class="field mt-5 px-0 mx-0">
|
||||
<label
|
||||
class="label fs-14"
|
||||
v-if="status !== undefined"
|
||||
:class="status ? 'has-text-primary' : 'has-text-danger'"
|
||||
<div class="buttons is-justify-content-flex-end">
|
||||
<button
|
||||
@click="emit('close')"
|
||||
class="button is-white"
|
||||
>
|
||||
{{ status ? "Lưu thiết lập thành công." : "Lỗi. Lưu thiết lập thất bại." }}
|
||||
</label>
|
||||
<p class="control is-expanded">
|
||||
<button
|
||||
ref="saveBtn"
|
||||
:class="['button is-primary', isLoading && 'is-loading']"
|
||||
@click="saveSetting"
|
||||
>
|
||||
<span class="icon">
|
||||
<Icon
|
||||
name="material-symbols:check-rounded"
|
||||
:size="18"
|
||||
/>
|
||||
</span>
|
||||
<span>Lưu lại</span>
|
||||
</button>
|
||||
</p>
|
||||
Huỷ
|
||||
</button>
|
||||
<button
|
||||
ref="saveBtn"
|
||||
:class="['button is-primary', isLoading && 'is-loading']"
|
||||
@click="saveSetting"
|
||||
>
|
||||
<span class="icon">
|
||||
<Icon
|
||||
name="material-symbols:check-rounded"
|
||||
:size="18"
|
||||
/>
|
||||
</span>
|
||||
<span>Lưu lại</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
const emit = defineEmits(["modalevent", "close"]);
|
||||
const store = useStore();
|
||||
const props = defineProps({
|
||||
pagename: String,
|
||||
classify: String,
|
||||
@@ -125,8 +117,9 @@ const props = defineProps({
|
||||
data: Object,
|
||||
focus: Boolean,
|
||||
});
|
||||
const emit = defineEmits(["modalevent", "close"]);
|
||||
const store = useStore();
|
||||
const { $empty, $copy, $patchapi, $insertapi, $findIndex, $snackbar } = useNuxtApp();
|
||||
const radioOption = ref();
|
||||
const login = { id: 1 };
|
||||
const errors = ref([]);
|
||||
const radioType = ref();
|
||||
@@ -134,20 +127,28 @@ const radioDefault = 0;
|
||||
const radioSave = ref("overwrite");
|
||||
const name = ref();
|
||||
const note = ref();
|
||||
const status = undefined;
|
||||
var currentsetting = undefined;
|
||||
var pagename = props.pagename;
|
||||
var pagedata = store[props.pagename];
|
||||
let currentsetting = undefined;
|
||||
const pagedata = store[props.pagename];
|
||||
const isLoading = ref(false);
|
||||
const saveBtnRef = useTemplateRef("saveBtn");
|
||||
onMounted(() => {
|
||||
saveBtnRef.value.focus();
|
||||
});
|
||||
|
||||
function initData() {
|
||||
radioType.value = store.settingtype.find((v) => v.code === "private");
|
||||
if (props.pagename) currentsetting = $copy(pagedata.setting || undefined);
|
||||
// disable temp: for now, radioSave is always 'overwrite'
|
||||
/* if (!currentsetting) radioSave.value = "new";
|
||||
else if (currentsetting.user !== login.id) radioSave.value = "new";
|
||||
else radioSave.value = "overwrite"; */
|
||||
}
|
||||
initData();
|
||||
|
||||
async function saveSetting() {
|
||||
errors.value = [];
|
||||
let detail = pagename ? { fields: pagedata.fields } : {};
|
||||
if (pagename) {
|
||||
let detail = props.pagename ? { fields: pagedata.fields } : {};
|
||||
if (props.pagename) {
|
||||
let element = pagedata.tablesetting || {};
|
||||
if (element !== store.originsetting) detail.tablesetting = element;
|
||||
if (pagedata.filters ? pagedata.filters.length > 0 : false) {
|
||||
@@ -202,22 +203,8 @@ async function saveSetting() {
|
||||
emit("close");
|
||||
}
|
||||
}
|
||||
function isOverwrite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function changeType(value) {
|
||||
radioSave.value = value;
|
||||
}
|
||||
function changeOption(v) {
|
||||
radioOption.value = v.code;
|
||||
}
|
||||
function initData() {
|
||||
radioType.value = store.settingtype.find((v) => v.code === "private");
|
||||
if (props.pagename) currentsetting = $copy(pagedata.setting ? pagedata.setting : undefined);
|
||||
// disable temp: for now, radioSave is always 'overwrite'
|
||||
/* if (!currentsetting) radioSave.value = "new";
|
||||
else if (currentsetting.user !== login.id) radioSave.value = "new";
|
||||
else radioSave.value = "overwrite"; */
|
||||
}
|
||||
initData();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user