|
|
|
@ -1,5 +1,7 @@
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
|
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
|
|
|
|
|
|
import { ExternalAuthControllerService } from "@/components/service/management/ExternalAuthControllerService";
|
|
|
|
|
|
|
|
import { EdgePkgInfoVOModel } from "@/components/models/management/ExternalAuthController";
|
|
|
|
|
|
|
|
|
|
|
|
type PackageOption = { label: string; value: string; raw: any };
|
|
|
|
type PackageOption = { label: string; value: string; raw: any };
|
|
|
|
|
|
|
|
|
|
|
|
@ -8,6 +10,7 @@ const props = defineProps<{
|
|
|
|
packagesLoading?: boolean;
|
|
|
|
packagesLoading?: boolean;
|
|
|
|
packagesError?: string;
|
|
|
|
packagesError?: string;
|
|
|
|
artifactPath?: string;
|
|
|
|
artifactPath?: string;
|
|
|
|
|
|
|
|
token: string; // 로그인 후 받은 토큰
|
|
|
|
}>();
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
const emit = defineEmits<{
|
|
|
|
@ -18,7 +21,7 @@ const emit = defineEmits<{
|
|
|
|
const form = ref({
|
|
|
|
const form = ref({
|
|
|
|
package_id: "",
|
|
|
|
package_id: "",
|
|
|
|
sw_id: "",
|
|
|
|
sw_id: "",
|
|
|
|
sw_version: "",
|
|
|
|
sw_version: "1",
|
|
|
|
software_name: "",
|
|
|
|
software_name: "",
|
|
|
|
executed: true,
|
|
|
|
executed: true,
|
|
|
|
file_type: "bundle" as "bundle" | "single",
|
|
|
|
file_type: "bundle" as "bundle" | "single",
|
|
|
|
@ -33,6 +36,25 @@ const form = ref({
|
|
|
|
private_only: false,
|
|
|
|
private_only: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const saving = ref(false);
|
|
|
|
|
|
|
|
const errorMsg = ref("");
|
|
|
|
|
|
|
|
const successOpen = ref(false);
|
|
|
|
|
|
|
|
const successDialog = ref(false);
|
|
|
|
|
|
|
|
const pendingPayload = ref<any>(null);
|
|
|
|
|
|
|
|
// ---- 파일 업로드 추가 ----
|
|
|
|
|
|
|
|
const file = ref<File | null>(null);
|
|
|
|
|
|
|
|
const fileInput = ref<HTMLInputElement | null>(null);
|
|
|
|
|
|
|
|
const onFileChange = (e: Event) => {
|
|
|
|
|
|
|
|
const input = e.target as HTMLInputElement;
|
|
|
|
|
|
|
|
const f = input.files?.[0] ?? null;
|
|
|
|
|
|
|
|
file.value = f;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const clearFile = () => {
|
|
|
|
|
|
|
|
if (fileInput.value) fileInput.value.value = "";
|
|
|
|
|
|
|
|
file.value = null;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
|
|
const isWin = computed(() => form.value.os === "Windows");
|
|
|
|
const isWin = computed(() => form.value.os === "Windows");
|
|
|
|
const isLinux = computed(() => form.value.os === "Linux");
|
|
|
|
const isLinux = computed(() => form.value.os === "Linux");
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,6 +70,13 @@ const readonlyFields = computed(() => ({
|
|
|
|
packageId: selectedRaw.value?.package_id ?? "",
|
|
|
|
packageId: selectedRaw.value?.package_id ?? "",
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function confirmSuccess() {
|
|
|
|
|
|
|
|
if (pendingPayload.value) {
|
|
|
|
|
|
|
|
emit("handle-data", pendingPayload.value); // ✅ 이제 여기서 부모에 전달
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
emit("close-modal"); // ✅ 그리고 모달 닫기
|
|
|
|
|
|
|
|
successDialog.value = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
function onPickPackage() {
|
|
|
|
function onPickPackage() {
|
|
|
|
form.value.win_exe_name = selectedRaw.value?.window_exe_name ?? "";
|
|
|
|
form.value.win_exe_name = selectedRaw.value?.window_exe_name ?? "";
|
|
|
|
form.value.win_root_path = selectedRaw.value?.window_root_location ?? "";
|
|
|
|
form.value.win_root_path = selectedRaw.value?.window_root_location ?? "";
|
|
|
|
@ -74,13 +103,87 @@ watch(
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
function submit() {
|
|
|
|
const installOsCode = computed(() => {
|
|
|
|
if (!form.value.package_id) return;
|
|
|
|
if (form.value.os === "Windows") return 0;
|
|
|
|
emit("handle-data", {
|
|
|
|
if (form.value.os === "Linux") return 1;
|
|
|
|
...form.value,
|
|
|
|
return null;
|
|
|
|
resolved: readonlyFields.value,
|
|
|
|
});
|
|
|
|
artifact_path: props.artifactPath ?? "",
|
|
|
|
const archiveTypeCode = computed(() =>
|
|
|
|
});
|
|
|
|
form.value.file_type === "bundle" ? 1 : 0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getCurrentUserId(): string {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const raw = localStorage.getItem("autoflow-auth");
|
|
|
|
|
|
|
|
const obj = raw ? JSON.parse(raw) : null;
|
|
|
|
|
|
|
|
return obj?.userInfo?.username ? String(obj.userInfo.username) : "";
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const toInt = (v: unknown, fallback = 1) => {
|
|
|
|
|
|
|
|
const n = parseInt(String(v ?? "").trim(), 10);
|
|
|
|
|
|
|
|
return Number.isFinite(n) ? n : fallback;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function submit() {
|
|
|
|
|
|
|
|
errorMsg.value = "";
|
|
|
|
|
|
|
|
if (!file.value) return (errorMsg.value = "업로드할 파일을 선택하세요.");
|
|
|
|
|
|
|
|
if (!form.value.sw_id?.trim())
|
|
|
|
|
|
|
|
return (errorMsg.value = "SW ID를 입력하세요.");
|
|
|
|
|
|
|
|
if (!form.value.software_name?.trim())
|
|
|
|
|
|
|
|
return (errorMsg.value = "SW 명칭을 입력하세요.");
|
|
|
|
|
|
|
|
if (!selectedRaw.value?.ed_pkg_serial)
|
|
|
|
|
|
|
|
return (errorMsg.value = "SW 패키지를 선택하세요.");
|
|
|
|
|
|
|
|
if (!form.value.install_location?.trim())
|
|
|
|
|
|
|
|
return (errorMsg.value = "설치 위치를 입력하세요.");
|
|
|
|
|
|
|
|
if (!props.token)
|
|
|
|
|
|
|
|
return (errorMsg.value = "토큰이 없습니다. 다시 로그인하세요.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
saving.value = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params: EdgePkgInfoVOModel = {
|
|
|
|
|
|
|
|
sw_id: (form.value.sw_id || "").trim(),
|
|
|
|
|
|
|
|
sw_version: toInt(form.value.sw_version, 1), // ✅ 숫자 보정
|
|
|
|
|
|
|
|
sw_name: (form.value.software_name || "").trim(),
|
|
|
|
|
|
|
|
auth_id: props.token,
|
|
|
|
|
|
|
|
edPkgSerial: toInt(selectedRaw.value?.ed_pkg_serial, 0),
|
|
|
|
|
|
|
|
archiveType: form.value.file_type === "bundle" ? 1 : 0,
|
|
|
|
|
|
|
|
execYn: form.value.executed ? 1 : 0,
|
|
|
|
|
|
|
|
secretAt: !!form.value.private_only,
|
|
|
|
|
|
|
|
downloadLocation: (form.value.install_location || "").trim(),
|
|
|
|
|
|
|
|
user_id: getCurrentUserId() || "admin",
|
|
|
|
|
|
|
|
creation_datetime: new Date().toISOString(),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const res = await ExternalAuthControllerService.add(params, file.value!);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ success 값 판단 (둘 다 대응)
|
|
|
|
|
|
|
|
const ok =
|
|
|
|
|
|
|
|
res?.success === true || (res?.data && res?.data?.success === true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ok) {
|
|
|
|
|
|
|
|
const msg =
|
|
|
|
|
|
|
|
res?.errorMessage || res?.data?.errorMessage || "등록에 실패했습니다.";
|
|
|
|
|
|
|
|
throw new Error(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
successOpen.value = true; // ✅ 성공 스낵바 오픈
|
|
|
|
|
|
|
|
pendingPayload.value = {
|
|
|
|
|
|
|
|
...form.value,
|
|
|
|
|
|
|
|
artifact_path: props.artifactPath ?? "",
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
successDialog.value = true;
|
|
|
|
|
|
|
|
clearFile();
|
|
|
|
|
|
|
|
} catch (e: any) {
|
|
|
|
|
|
|
|
errorMsg.value =
|
|
|
|
|
|
|
|
e?.response?.data?.message ||
|
|
|
|
|
|
|
|
e?.message ||
|
|
|
|
|
|
|
|
"등록 중 오류가 발생했습니다.";
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
saving.value = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onEsc(e: KeyboardEvent) {
|
|
|
|
function onEsc(e: KeyboardEvent) {
|
|
|
|
@ -96,7 +199,7 @@ onBeforeUnmount(() => window.removeEventListener("keydown", onEsc));
|
|
|
|
class="text-white text-h6 font-weight-bold"
|
|
|
|
class="text-white text-h6 font-weight-bold"
|
|
|
|
style="background: #1976d2"
|
|
|
|
style="background: #1976d2"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
차량 지능 SW 등록
|
|
|
|
Vehicle Intelligence Software Registration
|
|
|
|
</v-card-title>
|
|
|
|
</v-card-title>
|
|
|
|
|
|
|
|
|
|
|
|
<v-defaults-provider
|
|
|
|
<v-defaults-provider
|
|
|
|
@ -180,7 +283,12 @@ onBeforeUnmount(() => window.removeEventListener("keydown", onEsc));
|
|
|
|
<v-text-field label="SW ID" v-model="form.sw_id" />
|
|
|
|
<v-text-field label="SW ID" v-model="form.sw_id" />
|
|
|
|
</v-col>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" md="6">
|
|
|
|
<v-col cols="12" md="6">
|
|
|
|
<v-text-field label="SW 버전" v-model="form.sw_version" />
|
|
|
|
<v-text-field
|
|
|
|
|
|
|
|
label="SW 버전"
|
|
|
|
|
|
|
|
v-model="form.sw_version"
|
|
|
|
|
|
|
|
type="number"
|
|
|
|
|
|
|
|
min="0"
|
|
|
|
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-text-field
|
|
|
|
<v-text-field
|
|
|
|
@ -276,6 +384,36 @@ onBeforeUnmount(() => window.removeEventListener("keydown", onEsc));
|
|
|
|
</v-col>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 파일 업로드 (추가) -->
|
|
|
|
|
|
|
|
<v-row dense class="mb-1">
|
|
|
|
|
|
|
|
<v-col cols="12">
|
|
|
|
|
|
|
|
<div class="text-body-2 font-weight-medium mb-1">업로드 파일</div>
|
|
|
|
|
|
|
|
<div class="d-flex align-center ga-3">
|
|
|
|
|
|
|
|
<v-btn size="small" color="primary" @click="fileInput?.click()"
|
|
|
|
|
|
|
|
>파일 선택</v-btn
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<span v-if="file" class="text-body-2">
|
|
|
|
|
|
|
|
{{ file.name }} ({{ file.size.toLocaleString() }} bytes)
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<v-btn
|
|
|
|
|
|
|
|
v-if="file"
|
|
|
|
|
|
|
|
size="x-small"
|
|
|
|
|
|
|
|
variant="text"
|
|
|
|
|
|
|
|
class="ml-1"
|
|
|
|
|
|
|
|
@click="clearFile"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
지우기
|
|
|
|
|
|
|
|
</v-btn>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<input
|
|
|
|
|
|
|
|
ref="fileInput"
|
|
|
|
|
|
|
|
type="file"
|
|
|
|
|
|
|
|
class="d-none"
|
|
|
|
|
|
|
|
@change="onFileChange"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</v-col>
|
|
|
|
|
|
|
|
</v-row>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 설치 위치 & 등록인만 접근 -->
|
|
|
|
<!-- 설치 위치 & 등록인만 접근 -->
|
|
|
|
<v-row dense>
|
|
|
|
<v-row dense>
|
|
|
|
<v-col cols="12" md="8">
|
|
|
|
<v-col cols="12" md="8">
|
|
|
|
@ -289,13 +427,40 @@ onBeforeUnmount(() => window.removeEventListener("keydown", onEsc));
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 에러 메시지 -->
|
|
|
|
|
|
|
|
<v-alert
|
|
|
|
|
|
|
|
v-if="errorMsg"
|
|
|
|
|
|
|
|
type="error"
|
|
|
|
|
|
|
|
variant="tonal"
|
|
|
|
|
|
|
|
class="mt-3"
|
|
|
|
|
|
|
|
density="comfortable"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{{ errorMsg }}
|
|
|
|
|
|
|
|
</v-alert>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card-text>
|
|
|
|
|
|
|
|
|
|
|
|
<v-card-actions class="py-2 px-3">
|
|
|
|
<v-card-actions class="py-2 px-3">
|
|
|
|
<v-spacer />
|
|
|
|
<v-spacer />
|
|
|
|
<v-btn color="success" @click="submit">SAVE</v-btn>
|
|
|
|
<v-btn color="success" :loading="saving" @click="submit">SAVE</v-btn>
|
|
|
|
<v-btn variant="text" @click="$emit('close-modal')">CANCEL</v-btn>
|
|
|
|
<v-btn variant="text" :disabled="saving" @click="$emit('close-modal')"
|
|
|
|
|
|
|
|
>CANCEL</v-btn
|
|
|
|
|
|
|
|
>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-defaults-provider>
|
|
|
|
</v-defaults-provider>
|
|
|
|
|
|
|
|
<v-dialog v-model="successDialog" width="360" persistent>
|
|
|
|
|
|
|
|
<v-card rounded="lg">
|
|
|
|
|
|
|
|
<v-card-title class="text-h6" style="background: #1976d2"
|
|
|
|
|
|
|
|
>등록 완료</v-card-title
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<v-card-text class="font-weight-bold text-center"
|
|
|
|
|
|
|
|
>등록이 완료되었습니다.</v-card-text
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<v-card-actions>
|
|
|
|
|
|
|
|
<v-spacer />
|
|
|
|
|
|
|
|
<v-btn color="primary" @click="confirmSuccess">확인</v-btn>
|
|
|
|
|
|
|
|
</v-card-actions>
|
|
|
|
|
|
|
|
</v-card>
|
|
|
|
|
|
|
|
</v-dialog>
|
|
|
|
</v-card>
|
|
|
|
</v-card>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|