<template>
  <div>
    <div class="inner--headers">
      <h2>{{ pageId }}</h2>
      <div class="bread--crumbs--wrap">
        <span>홈</span>
        <span>{{ pageId }}</span>
        <span v-if="pageIdSub">{{ pageIdSub }}</span>
      </div>
    </div>
    <div class="data--list--wrap">
      <div class="table--wrap">
        <div class="table--t">
          <h3>요약 연결 재무상태표</h3>
          <span>단위 : 백만원</span>
        </div>
        <table>
          <colgroup>
            <col width="30%" />
            <col width="20%" />
            <col width="20%" />
            <col width="20%" />
          </colgroup>
          <thead>
            <tr>
              <th>구분</th>
              <th>
                <v-text-field
                  maxlength="4"
                  class="custom-input mini"
                  v-model="form.year1"
                  placeholder="연도를 입력하세요"
                ></v-text-field>
              </th>
              <th>
                <v-text-field
                  maxlength="4"
                  class="custom-input mini"
                  v-model="form.year2"
                  placeholder="연도를 입력하세요"
                ></v-text-field>
              </th>
              <th>
                <v-text-field
                  maxlength="4"
                  class="custom-input mini"
                  v-model="form.year3"
                  placeholder="연도를 입력하세요"
                ></v-text-field>
              </th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>유동자산</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_1')"
                  class="custom-input mini"
                  v-model="form.value1_1"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_1')"
                  class="custom-input mini"
                  v-model="form.value2_1"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_1')"
                  class="custom-input mini"
                  v-model="form.value3_1"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>비유동자산</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_2')"
                  class="custom-input mini"
                  v-model="form.value1_2"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_2')"
                  class="custom-input mini"
                  v-model="form.value2_2"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_2')"
                  class="custom-input mini"
                  v-model="form.value3_2"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td class="bg">자산총계</td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_3')"
                  class="custom-input mini"
                  v-model="form.value1_3"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_3')"
                  class="custom-input mini"
                  v-model="form.value2_3"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_3')"
                  class="custom-input mini"
                  v-model="form.value3_3"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>유동부채</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_4')"
                  class="custom-input mini"
                  v-model="form.value1_4"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_4')"
                  class="custom-input mini"
                  v-model="form.value2_4"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_4')"
                  class="custom-input mini"
                  v-model="form.value3_4"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>비유동부채</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_5')"
                  class="custom-input mini"
                  v-model="form.value1_5"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_5')"
                  class="custom-input mini"
                  v-model="form.value2_5"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_5')"
                  class="custom-input mini"
                  v-model="form.value3_5"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td class="bg">부채총계</td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_6')"
                  class="custom-input mini"
                  v-model="form.value1_6"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_6')"
                  class="custom-input mini"
                  v-model="form.value2_6"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_6')"
                  class="custom-input mini"
                  v-model="form.value3_6"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>자본금</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_7')"
                  class="custom-input mini"
                  v-model="form.value1_7"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_7')"
                  class="custom-input mini"
                  v-model="form.value2_7"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_7')"
                  class="custom-input mini"
                  v-model="form.value3_7"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>주식발행 초과금</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_8')"
                  class="custom-input mini"
                  v-model="form.value1_8"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_8')"
                  class="custom-input mini"
                  v-model="form.value2_8"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_8')"
                  class="custom-input mini"
                  v-model="form.value3_8"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>기타자본 구성요소</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_9')"
                  class="custom-input mini"
                  v-model="form.value1_9"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_9')"
                  class="custom-input mini"
                  v-model="form.value2_9"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_9')"
                  class="custom-input mini"
                  v-model="form.value3_9"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>이익잉여금</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_10')"
                  class="custom-input mini"
                  v-model="form.value1_10"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_10')"
                  class="custom-input mini"
                  v-model="form.value2_10"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_10')"
                  class="custom-input mini"
                  v-model="form.value3_10"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td class="bg">자본총계</td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_11')"
                  class="custom-input mini"
                  v-model="form.value1_11"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_11')"
                  class="custom-input mini"
                  v-model="form.value2_11"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_11')"
                  class="custom-input mini"
                  v-model="form.value3_11"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="table--wrap">
        <di class="table--t">
          <h3>요약 연결 손익계산서</h3>
          <span>단위 : 백만원</span>
        </di>
        <table>
          <colgroup>
            <col width="30%" />
            <col width="20%" />
            <col width="20%" />
            <col width="20%" />
          </colgroup>
          <thead>
            <tr>
              <th>구분</th>
              <th>
                <v-text-field
                  maxlength="4"
                  class="custom-input mini"
                  v-model="form.year1_1"
                  placeholder="연도를 입력하세요"
                ></v-text-field>
              </th>
              <th>
                <v-text-field
                  maxlength="4"
                  class="custom-input mini"
                  v-model="form.year2_1"
                  placeholder="연도를 입력하세요"
                ></v-text-field>
              </th>
              <th>
                <v-text-field
                  maxlength="4"
                  class="custom-input mini"
                  v-model="form.year3_1"
                  placeholder="연도를 입력하세요"
                ></v-text-field>
              </th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="bg">매출액</td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_12')"
                  class="custom-input mini"
                  v-model="form.value1_12"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_12')"
                  class="custom-input mini"
                  v-model="form.value2_12"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_12')"
                  class="custom-input mini"
                  v-model="form.value3_12"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>매출원가</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_13')"
                  class="custom-input mini"
                  v-model="form.value1_13"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_13')"
                  class="custom-input mini"
                  v-model="form.value2_13"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_13')"
                  class="custom-input mini"
                  v-model="form.value3_13"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>매출총이익</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_14')"
                  class="custom-input mini"
                  v-model="form.value1_14"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_14')"
                  class="custom-input mini"
                  v-model="form.value2_14"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_14')"
                  class="custom-input mini"
                  v-model="form.value3_14"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>판매비와 관리비</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_15')"
                  class="custom-input mini"
                  v-model="form.value1_15"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_15')"
                  class="custom-input mini"
                  v-model="form.value2_15"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_15')"
                  class="custom-input mini"
                  v-model="form.value3_15"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td class="bg">영업이익</td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_16')"
                  class="custom-input mini"
                  v-model="form.value1_16"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_16')"
                  class="custom-input mini"
                  v-model="form.value2_16"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_16')"
                  class="custom-input mini"
                  v-model="form.value3_16"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td>법인세 차감전순이익</td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_17')"
                  class="custom-input mini"
                  v-model="form.value1_17"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_17')"
                  class="custom-input mini"
                  v-model="form.value2_17"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td>
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_17')"
                  class="custom-input mini"
                  v-model="form.value3_17"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
            <tr>
              <td class="bg">당기순이익</td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value1_18')"
                  class="custom-input mini"
                  v-model="form.value1_18"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value2_18')"
                  class="custom-input mini"
                  v-model="form.value2_18"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
              <td class="bg">
                <v-text-field
                  maxlength="12"
                  @input="(e) => formatNumber(e, 'value3_18')"
                  class="custom-input mini"
                  v-model="form.value3_18"
                  placeholder="금액을 입력하세요"
                ></v-text-field>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="view-btm-btn">
        <div class="btn-l"></div>
        <div class="btn-r">
          <v-btn class="custom-btn btn-blue2" @click="fnUpdEvt"
            ><i class="ico"></i>저장</v-btn
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
/************************************************************************
|    레이아웃
************************************************************************/
definePageMeta({
  layout: "default",
});

/************************************************************************
|   PROPS
 ************************************************************************/
const props = defineProps({
  propsData: {
    type: Object,
    default: () => {},
  },
});

/************************************************************************
|    스토어
 ************************************************************************/
const useDtStore = useDetailStore();
/************************************************************************
|    전역
 ************************************************************************/
const { $toast, $log, $dayjs, $eventBus } = useNuxtApp();
const router = useRouter();
const pageId = ref("재무제표");
const pageIdSub = ref();
/* eslint-disable */
const form = ref({
  year1: "",
  year2: "",
  year3: "",
  year1_1: "",
  year2_1: "",
  year3_1: "",
  value1_1: "",
  value1_2: "",
  value1_3: "",
  value1_4: "",
  value1_5: "",
  value1_6: "",
  value1_7: "",
  value1_8: "",
  value1_9: "",
  value1_10: "",
  value1_11: "",
  value1_12: "",
  value1_13: "",
  value1_14: "",
  value1_15: "",
  value1_16: "",
  value1_17: "",
  value1_18: "",
  value2_1: "",
  value2_2: "",
  value2_3: "",
  value2_4: "",
  value2_5: "",
  value2_6: "",
  value2_7: "",
  value2_8: "",
  value2_9: "",
  value2_10: "",
  value2_11: "",
  value2_12: "",
  value2_13: "",
  value2_14: "",
  value2_15: "",
  value2_16: "",
  value2_17: "",
  value2_18: "",
  value3_1: "",
  value3_2: "",
  value3_3: "",
  value3_4: "",
  value3_5: "",
  value3_6: "",
  value3_7: "",
  value3_8: "",
  value3_9: "",
  value3_10: "",
  value3_11: "",
  value3_12: "",
  value3_13: "",
  value3_14: "",
  value3_15: "",
  value3_16: "",
  value3_17: "",
  value3_18: "",
});
/* eslint-disable */
/* prettier-ignore */

/************************************************************************
|    함수(METHODS)
************************************************************************/
const formatNumber = (event, key) => {
  // 숫자만 남기기
  const input = event.target.value.replace(/[^0-9]/g, '');
  // 3자리마다 쉼표 추가
  const formattedInput = new Intl.NumberFormat().format(input);
  // 실시간으로 업데이트
  form.value[key] = String(formattedInput);
};

const fnUpdate = () => {
  let wterGet = localStorage.getItem("tempAccess");
  let _req = {
    wter: wterGet,

    // 요약 연결 재무상태표
    dd_1: form.value.year1,
    dd_2: form.value.year2,
    dd_3: form.value.year3,

    dd_amt_1_1: form.value.value1_1,
    dd_amt_1_2: form.value.value1_2,
    dd_amt_1_3: form.value.value1_3,
    dd_amt_1_4: form.value.value1_4,
    dd_amt_1_5: form.value.value1_5,
    dd_amt_1_6: form.value.value1_6,
    dd_amt_1_7: form.value.value1_7,
    dd_amt_1_8: form.value.value1_8,
    dd_amt_1_9: form.value.value1_9,
    dd_amt_1_10: form.value.value1_10,
    dd_amt_1_11: form.value.value1_11,

    dd_amt_2_1: form.value.value2_1,
    dd_amt_2_2: form.value.value2_2,
    dd_amt_2_3: form.value.value2_3,
    dd_amt_2_4: form.value.value2_4,
    dd_amt_2_5: form.value.value2_5,
    dd_amt_2_6: form.value.value2_6,
    dd_amt_2_7: form.value.value2_7,
    dd_amt_2_8: form.value.value2_8,
    dd_amt_2_9: form.value.value2_9,
    dd_amt_2_10: form.value.value2_10,
    dd_amt_2_11: form.value.value2_11,

    dd_amt_3_1: form.value.value3_1,
    dd_amt_3_2: form.value.value3_2,
    dd_amt_3_3: form.value.value3_3,
    dd_amt_3_4: form.value.value3_4,
    dd_amt_3_5: form.value.value3_5,
    dd_amt_3_6: form.value.value3_6,
    dd_amt_3_7: form.value.value3_7,
    dd_amt_3_8: form.value.value3_8,
    dd_amt_3_9: form.value.value3_9,
    dd_amt_3_10: form.value.value3_10,
    dd_amt_3_11: form.value.value3_11,

    // 요약 연결 손익계산서
    dd_1_1: form.value.year1_1,
    dd_2_1: form.value.year2_1,
    dd_3_1: form.value.year3_1,

    dd_amt_1_12: form.value.value1_12,
    dd_amt_1_13: form.value.value1_13,
    dd_amt_1_14: form.value.value1_14,
    dd_amt_1_15: form.value.value1_15,
    dd_amt_1_16: form.value.value1_16,
    dd_amt_1_17: form.value.value1_17,
    dd_amt_1_18: form.value.value1_18,

    dd_amt_2_12: form.value.value2_12,
    dd_amt_2_13: form.value.value2_13,
    dd_amt_2_14: form.value.value2_14,
    dd_amt_2_15: form.value.value2_15,
    dd_amt_2_16: form.value.value2_16,
    dd_amt_2_17: form.value.value2_17,
    dd_amt_2_18: form.value.value2_18,

    dd_amt_3_12: form.value.value3_12,
    dd_amt_3_13: form.value.value3_13,
    dd_amt_3_14: form.value.value3_14,
    dd_amt_3_15: form.value.value3_15,
    dd_amt_3_16: form.value.value3_16,
    dd_amt_3_17: form.value.value3_17,
    dd_amt_3_18: form.value.value3_18,
  };

  _req = Object.fromEntries(
    Object.entries(_req).map(([key, value]) => [
      key,
      typeof value === "string"
        ? value.replace(/,/g, "") // 문자열인 경우에만 replace
        : value == null
        ? "" // null 또는 undefined 값은 빈 문자열로 처리
        : String(value), // 그 외 값은 문자열로 변환
    ])
  );

  useAxios()
    .post("/balance/ins", _req)
    .then((res) => {
      window.location.reload();
      //console.error(res)
    })
    .catch((error) => {});
};
const fnDetail = () => {
  let _req = {};

  useAxios()
    .post("/balance/detail", _req)
    .then((res) => {
      const formattedData = Object.fromEntries(
        Object.entries(res.data).map(([key, value]) => {
          let formattedValue = null;
          // 연도는 쉼표 제거, 금액은 쉼표 추가
          if(key !== 'dd_1' && key !== 'dd_2' && key !== 'dd_3' && key !== 'dd_1_1' && key !== 'dd_2_1' && key !== 'dd_3_1'){
            formattedValue = !isNaN(value)
            ? new Intl.NumberFormat().format(Number(value))
            : value;
          } else {
            formattedValue = value;
          }
          return [key, formattedValue];
        })
      );
      res.data = formattedData;
      form.value.year1 = res.data.dd_1;
      form.value.value1_1 = res.data.dd_amt_1_1;
      form.value.value1_2 = res.data.dd_amt_1_2;
      form.value.value1_3 = res.data.dd_amt_1_3;
      form.value.value1_4 = res.data.dd_amt_1_4;
      form.value.value1_5 = res.data.dd_amt_1_5;
      form.value.value1_6 = res.data.dd_amt_1_6;
      form.value.value1_7 = res.data.dd_amt_1_7;
      form.value.value1_8 = res.data.dd_amt_1_8;
      form.value.value1_9 = res.data.dd_amt_1_9;
      form.value.value1_10 = res.data.dd_amt_1_10;
      form.value.value1_11 = res.data.dd_amt_1_11;

      form.value.year2 = res.data.dd_2;
      form.value.value2_1 = res.data.dd_amt_2_1;
      form.value.value2_2 = res.data.dd_amt_2_2;
      form.value.value2_3 = res.data.dd_amt_2_3;
      form.value.value2_4 = res.data.dd_amt_2_4;
      form.value.value2_5 = res.data.dd_amt_2_5;
      form.value.value2_6 = res.data.dd_amt_2_6;
      form.value.value2_7 = res.data.dd_amt_2_7;
      form.value.value2_8 = res.data.dd_amt_2_8;
      form.value.value2_9 = res.data.dd_amt_2_9;
      form.value.value2_10 = res.data.dd_amt_2_10;
      form.value.value2_11 = res.data.dd_amt_2_11;

      form.value.year3 = res.data.dd_3;
      form.value.value3_1 = res.data.dd_amt_3_1;
      form.value.value3_2 = res.data.dd_amt_3_2;
      form.value.value3_3 = res.data.dd_amt_3_3;
      form.value.value3_4 = res.data.dd_amt_3_4;
      form.value.value3_5 = res.data.dd_amt_3_5;
      form.value.value3_6 = res.data.dd_amt_3_6;
      form.value.value3_7 = res.data.dd_amt_3_7;
      form.value.value3_8 = res.data.dd_amt_3_8;
      form.value.value3_9 = res.data.dd_amt_3_9;
      form.value.value3_10 = res.data.dd_amt_3_10;
      form.value.value3_11 = res.data.dd_amt_3_11;

      // 요약 연결 손익계산서
      form.value.year1_1 = res.data.dd_1_1;
      form.value.value1_12 = res.data.dd_amt_1_12;
      form.value.value1_13 = res.data.dd_amt_1_13;
      form.value.value1_14 = res.data.dd_amt_1_14;
      form.value.value1_15 = res.data.dd_amt_1_15;
      form.value.value1_16 = res.data.dd_amt_1_16;
      form.value.value1_17 = res.data.dd_amt_1_17;
      form.value.value1_18 = res.data.dd_amt_1_18;

      form.value.year2_1 = res.data.dd_2_1;
      form.value.value2_12 = res.data.dd_amt_2_12;
      form.value.value2_13 = res.data.dd_amt_2_13;
      form.value.value2_14 = res.data.dd_amt_2_14;
      form.value.value2_15 = res.data.dd_amt_2_15;
      form.value.value2_16 = res.data.dd_amt_2_16;
      form.value.value2_17 = res.data.dd_amt_2_17;
      form.value.value2_18 = res.data.dd_amt_2_18;

      form.value.year3_1 = res.data.dd_3_1;
      form.value.value3_12 = res.data.dd_amt_3_12;
      form.value.value3_13 = res.data.dd_amt_3_13;
      form.value.value3_14 = res.data.dd_amt_3_14;
      form.value.value3_15 = res.data.dd_amt_3_15;
      form.value.value3_16 = res.data.dd_amt_3_16;
      form.value.value3_17 = res.data.dd_amt_3_17;
      form.value.value3_18 = res.data.dd_amt_3_18;
    })
    .catch((error) => {});
};

const fnUpdEvt = () => {
  let param = {
    id: pageId,
    title: "재무제표 저장",
    content: "저장하시겠습니까?",
    yes: {
      text: "저장",
      isProc: true,
      event: "FN_UPDATE",
      param: "",
    },
    no: {
      text: "취소",
      isProc: false,
    },
  };
  $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
};

$eventBus.off("FN_UPDATE");
$eventBus.on("FN_UPDATE", () => {
  fnUpdate();
});

/************************************************************************
|    WATCH
************************************************************************/

watch(() => {});

onMounted(() => {
  fnDetail();
});
</script>
