Sfoglia il codice sorgente

メッセージ対応

develop
sosuke.iwabuchi 2 anni fa
parent
commit
5c485e814e
4 ha cambiato i file con 27 aggiunte e 10 eliminazioni
  1. +10
    -3
      src/apps/定期申込予約/index.tsx
  2. +7
    -7
      src/apps/定期申込予約/自動承認.ts
  3. +1
    -0
      src/exception/index.ts
  4. +9
    -0
      src/middleware/swal.ts

+ 10
- 3
src/apps/定期申込予約/index.tsx Vedi File

@@ -1,7 +1,8 @@
import { AppID } from "@/common/appids"; import { AppID } from "@/common/appids";
import { setHeaderButton } from "@/common/header-button"; import { setHeaderButton } from "@/common/header-button";
import { CancelError } from "@/exception";
import { CancelError, Message } from "@/exception";
import { import {
ErrorDialog,
ShowConfirmDialog, ShowConfirmDialog,
SuccessDialog, SuccessDialog,
WarningDialog, WarningDialog,
@@ -52,9 +53,15 @@ import { 申込 } from "./自動承認";
} catch (e) { } catch (e) {
if (e instanceof CancelError) { if (e instanceof CancelError) {
console.log("canceled"); console.log("canceled");
} else {
throw e;
return;
} else if (e instanceof Message) {
ErrorDialog.fire({
text: e.message,
});
return;
} }
ErrorDialog.fire();
throw e;
} }
}); });
} }


+ 7
- 7
src/apps/定期申込予約/自動承認.ts Vedi File

@@ -28,7 +28,7 @@ import { 車室契約情報, 車室契約情報フィールド名 } from "@/type
import { 車室情報2 } from "@/types/車室情報2"; import { 車室情報2 } from "@/types/車室情報2";
import { 顧客マスタフィールド名 } from "@/types/顧客マスタ"; import { 顧客マスタフィールド名 } from "@/types/顧客マスタ";
import { sprintf } from "sprintf"; import { sprintf } from "sprintf";
import { CancelError } from "../../exception";
import { CancelError, Message } from "../../exception";
import { 入金予定結果フィールド名 } from "@/types/入金予定結果"; import { 入金予定結果フィールド名 } from "@/types/入金予定結果";
import { dateParse, now } from "@/common/datetime"; import { dateParse, now } from "@/common/datetime";


@@ -93,7 +93,7 @@ export class 申込 {


private async 契約対象車室取得() { private async 契約対象車室取得() {
if (!this.定期申込予約.駐車場.value) { if (!this.定期申込予約.駐車場.value) {
throw new Error("駐車場名の設定をしてください");
throw new Message("駐車場名の設定をしてください");
} }


this.車室一覧 = await get車室情報一覧({ this.車室一覧 = await get車室情報一覧({
@@ -102,7 +102,7 @@ export class 申込 {
} }
private async 契約情報取得() { private async 契約情報取得() {
if (!this.定期申込予約.駐車場.value) { if (!this.定期申込予約.駐車場.value) {
throw new Error("駐車場名の設定をしてください");
throw new Message("駐車場名の設定をしてください");
} }
this.契約一覧 = await get車室契約情報一覧({ this.契約一覧 = await get車室契約情報一覧({
駐車場名: this.定期申込予約.駐車場.value, 駐車場名: this.定期申込予約.駐車場.value,
@@ -111,7 +111,7 @@ export class 申込 {
} }
private async 自動承認グループ取得() { private async 自動承認グループ取得() {
if (!this.定期申込予約.定期駐車場プラン.value) { if (!this.定期申込予約.定期駐車場プラン.value) {
throw new Error("プラン名の設定をしてください");
throw new Message("プラン名の設定をしてください");
} }
this.自動承認グループ = await get自動承認グループ( this.自動承認グループ = await get自動承認グループ(
this.定期申込予約.定期駐車場プラン.value this.定期申込予約.定期駐車場プラン.value
@@ -143,7 +143,7 @@ export class 申込 {
.find(() => true); .find(() => true);


if (!target) { if (!target) {
throw new Error("空き車室がありません");
throw new Message("空き車室がありません");
} }


const 車室番号 = Number(target.value.車室番号.value); const 車室番号 = Number(target.value.車室番号.value);
@@ -151,7 +151,7 @@ export class 申込 {
return Number(room.車室番号.value) === 車室番号; return Number(room.車室番号.value) === 車室番号;
}); });
if (!車室) { if (!車室) {
throw new Error("車室がありません");
throw new Message("車室がありません");
} }


return 車室; return 車室;
@@ -240,7 +240,7 @@ export class 申込 {


private get契約開始日() { private get契約開始日() {
const 利用開始希望日 = this.定期申込予約.利用開始希望日.value; const 利用開始希望日 = this.定期申込予約.利用開始希望日.value;
if (!利用開始希望日) throw new Error("利用開始希望日不正");
if (!利用開始希望日) throw new Message("利用開始希望日不正");
return 利用開始希望日; return 利用開始希望日;
} }




+ 1
- 0
src/exception/index.ts Vedi File

@@ -1 +1,2 @@
export class CancelError extends Error {} export class CancelError extends Error {}
export class Message extends Error {}

+ 9
- 0
src/middleware/swal.ts Vedi File

@@ -6,11 +6,17 @@ export const SuccessDialog = Swal.mixin({
timer: 1000, timer: 1000,
title: "成功しました", title: "成功しました",
showConfirmButton: false, showConfirmButton: false,
didOpen: () => {
Swal.hideLoading();
},
}); });


export const ErrorDialog = Swal.mixin({ export const ErrorDialog = Swal.mixin({
icon: "error", icon: "error",
title: "エラーが発生しました", title: "エラーが発生しました",
didOpen: () => {
Swal.hideLoading();
},
}); });
export const WarningDialog = Swal.mixin({ export const WarningDialog = Swal.mixin({
icon: "warning", icon: "warning",
@@ -21,6 +27,9 @@ export const ConfirmDialog = Swal.mixin({
showCancelButton: true, showCancelButton: true,
confirmButtonText: "実行", confirmButtonText: "実行",
cancelButtonText: "キャンセル", cancelButtonText: "キャンセル",
didOpen: () => {
Swal.hideLoading();
},
}); });


export const ShowConfirmDialog = (param: SweetAlertOptions) => { export const ShowConfirmDialog = (param: SweetAlertOptions) => {


Loading…
Annulla
Salva