From 05b6bbac68c13e3f5a8a15d663fe11a8b8b193fc Mon Sep 17 00:00:00 2001 From: "kin.rinzen" Date: Tue, 14 Oct 2025 09:49:07 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B7=A8=E9=9B=86=E7=94=BB=E9=9D=A2=E3=81=AB?= =?UTF-8?q?=E7=99=BB=E9=8C=B2=E3=83=BB=E5=89=8A=E9=99=A4=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E7=A2=BA=E8=AA=8D=E3=83=80=E3=82=A4=E3=82=A2?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/public/js/app.js b/public/js/app.js index 555cc96..d4a7d41 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1572,4 +1572,91 @@ var jconfirm, Jconfirm; // removed by extract-text-webpack-plugin /***/ }) -/******/ ]); \ No newline at end of file +/******/ ]); + +// 編集画面専用 登録ボタン +$('#register_edit').on('click', function (e) { + e.preventDefault(); + $.confirm({ + title: '確認ダイアログ', + content: '登録してよろしいですか?', + buttons: { + ok: { + text: "はい", + btnClass: 'btn-primary', + action: function () { + $("#form_edit").submit(); // 更新処理 + } + }, + いいえ: function () {} + } + }); +}); + +// 編集画面専用 削除ボタン +$('#delete_edit').on('click', function (e) { + e.preventDefault(); + $.confirm({ + title: '削除確認ダイアログ', + content: '削除してよろしいですか?', + buttons: { + ok: { + text: "はい", + btnClass: 'btn-primary', + action: function () { + $("#form_delete").submit(); // 削除処理 + } + }, + いいえ: function () {} + } + }); +}); + +$(function () { + // ▼ 「アップロード」ボタンを押すと、ファイル選択ダイアログを開く + $(document).on('click', '.upload-file', function () { + $(this).siblings('input[type=file]').click(); + }); + + // ▼ ファイル選択後、自動でAJAXアップロード処理を行う + $(document).on('change', 'input[name=company_image_file]', function () { + const file = this.files[0]; + if (!file) return; + + const formData = new FormData(); + formData.append('company_image_file', file); + formData.append('_token', $('input[name=_token]').val()); + + $.ajax({ + url: '/inv_settings/upload', // ルート:アップロード先 + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function (res) { + // 成功時:ファイル名を表示・hidden項目に反映 + $('input[name=company_image_path]').val(res.path); + $('.filename').text(res.file_name); + + // プレビューを更新 + const previewHtml = `
+ 社判画像 +
`; + $('.uploaded-file').after(previewHtml); + + alert('アップロードが完了しました。'); + }, + error: function (xhr) { + alert('アップロードに失敗しました。'); + } + }); + }); + + // ▼ 削除ボタン(✕)をクリックしたらファイル情報をクリア + $(document).on('click', '.delete-file', function () { + $('input[name=company_image_path]').val(''); + $('.filename').text(''); + $('img[alt="社判画像"]').remove(); + }); +});