feat: Conformance Save Log Done.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Swal from 'sweetalert2';
|
||||
import AllMapDataStore from '@/stores/allMapData.js';
|
||||
import ConformanceStore from '@/stores/conformance.js';
|
||||
import LoginStore from '@/stores/login.js';
|
||||
|
||||
const customClass = {
|
||||
@@ -12,18 +13,20 @@ const customClass = {
|
||||
confirmButton: '!inline-block !rounded-full !text-sm !font-medium !text-center !align-middle !transition-colors !duration-300 !px-5 !py-2 !w-[100px] !h-[40px]',
|
||||
cancelButton: '!inline-block !rounded-full !text-sm !font-medium !text-center !align-middle !transition-colors !duration-300 !px-5 !py-2 !w-[100px] !h-[40px] ',
|
||||
};
|
||||
|
||||
// 帶入參數 pinia aciton this.sweetVal
|
||||
/**
|
||||
* Map Saved
|
||||
* @param { function } addFilterId
|
||||
*/
|
||||
export async function saveFilter(addFilterId) {
|
||||
let filterName = '';
|
||||
let fileName = '';
|
||||
const { value, isConfirmed } = await Swal.fire({
|
||||
title: 'SAVE NEW FILTER',
|
||||
input: 'text',
|
||||
inputPlaceholder: 'Enter Filter Name.',
|
||||
inputValue: filterName,
|
||||
inputValue: fileName,
|
||||
inputValidator: (value) => {
|
||||
if (!value) return 'You need to write something!';
|
||||
filterName = value;
|
||||
fileName = value;
|
||||
},
|
||||
icon: 'info',
|
||||
iconHtml: '<span class="material-symbols-outlined text-[58px]">cloud_upload</span>',
|
||||
@@ -35,13 +38,16 @@ export async function saveFilter(addFilterId) {
|
||||
customClass: customClass,
|
||||
});
|
||||
// 存檔成功
|
||||
if(isConfirmed) await addFilterId(filterName);
|
||||
if(isConfirmed) await addFilterId(fileName);
|
||||
// 顯示儲存完成
|
||||
if (value) savedSuccessfully(value);
|
||||
// 清空欄位
|
||||
filterName = '';
|
||||
fileName = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Saved Success
|
||||
* @param { string } value
|
||||
*/
|
||||
export async function savedSuccessfully(value) {
|
||||
value = value ? value : '';
|
||||
await Swal.fire({
|
||||
@@ -54,7 +60,12 @@ export async function savedSuccessfully(value) {
|
||||
customClass: customClass
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* leave Map page
|
||||
* @param { function } next
|
||||
* @param { function } addFilterId
|
||||
* @param { string } toPath
|
||||
*/
|
||||
export async function leaveFilter(next, addFilterId, toPath) {
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const result = await Swal.fire({
|
||||
@@ -80,7 +91,69 @@ export async function leaveFilter(next, addFilterId, toPath) {
|
||||
next(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Conformance Saved
|
||||
* @param { function } addConformanceCreateCheckId
|
||||
*/
|
||||
export async function saveConformance(addConformanceCreateCheckId) {
|
||||
let fileName = '';
|
||||
const { value, isConfirmed } = await Swal.fire({
|
||||
title: 'SAVE NEW RULE',
|
||||
input: 'text',
|
||||
inputPlaceholder: 'Enter Rule Name.',
|
||||
inputValue: fileName,
|
||||
inputValidator: (value) => {
|
||||
if (!value) return 'You need to write something!';
|
||||
fileName = value;
|
||||
},
|
||||
icon: 'info',
|
||||
iconHtml: '<span class="material-symbols-outlined text-[58px]">cloud_upload</span>',
|
||||
iconColor: '#0099FF',
|
||||
reverseButtons:true,
|
||||
confirmButtonColor: '#0099FF',
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: '#94a3b8',
|
||||
customClass: customClass,
|
||||
});
|
||||
// 存檔成功
|
||||
if(isConfirmed) await addConformanceCreateCheckId(fileName);
|
||||
// 顯示儲存完成
|
||||
if (value) savedSuccessfully(value);
|
||||
// 清空欄位
|
||||
fileName = '';
|
||||
}
|
||||
/**
|
||||
* leave Conformance page
|
||||
* @param { function } next
|
||||
* @param { function } addConformanceCreateCheckId
|
||||
* @param { string } toPath
|
||||
*/
|
||||
export async function leaveConformance(next, addConformanceCreateCheckId, toPath) {
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const result = await Swal.fire({
|
||||
title: 'SAVE YOUR RULE?',
|
||||
icon: 'warning',
|
||||
iconColor: '#FF3366',
|
||||
reverseButtons:true,
|
||||
confirmButtonText: 'Yes',
|
||||
confirmButtonColor: '#FF3366',
|
||||
showCancelButton: true,
|
||||
cancelButtonText: 'No',
|
||||
cancelButtonColor: '#94a3b8',
|
||||
customClass: customClass
|
||||
})
|
||||
if(result.isConfirmed) {
|
||||
await saveFilter(addConformanceCreateCheckId)
|
||||
next(toPath);
|
||||
} else if(result.dismiss === 'cancel') {
|
||||
ConformanceStore.conformanceFilterTempCheckId = null;
|
||||
ConformanceStore.conformanceLogTempCheckId = null;
|
||||
next(toPath);
|
||||
} else if(result.dismiss === 'backdrop') {
|
||||
next(false);
|
||||
}
|
||||
};
|
||||
// 登出 button 規則,暫時沒用到
|
||||
export async function logoutLeave(addFilterId) {
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const loginStore = LoginStore();
|
||||
|
||||
Reference in New Issue
Block a user