corporate.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div>
  3. <div class="inner--headers">
  4. <h2>{{ pageId }}</h2>
  5. <div class="bread--crumbs--wrap">
  6. <span>홈</span>
  7. <span>{{ pageId }}</span>
  8. <span v-if="pageIdSub">{{ pageIdSub }}</span>
  9. </div>
  10. </div>
  11. <div class="data--list--wrap">
  12. <div class="table--wrap">
  13. <di class="table--t">
  14. <h3>기 발행 주식 수</h3>
  15. </di>
  16. <table>
  17. <colgroup>
  18. <col width="20%" />
  19. <col width="80%" />
  20. </colgroup>
  21. <tbody>
  22. <tr>
  23. <th class="bg le">주식 수<span class="bul">*</span></th>
  24. <td>
  25. <v-text-field
  26. maxlength="13"
  27. @input="(e) => formatNumber(e, 'formValue1')"
  28. v-model="form.formValue1"
  29. style="width: 300px"
  30. class="custom-input mini left"
  31. placeholder="주식 수를 입력하세요"
  32. ></v-text-field>
  33. </td>
  34. </tr>
  35. <tr>
  36. <th class="bg le">
  37. 발행 주식 수 기준 일자(현재)<span class="bul">*</span>
  38. </th>
  39. <td>
  40. <div class="calendar-wrap ml--0">
  41. <div class="calendar">
  42. <VueDatePicker
  43. :format="datePickerFormat"
  44. v-model="form.formValue2"
  45. auto-apply="true"
  46. week-start="0"
  47. ></VueDatePicker>
  48. </div>
  49. </div>
  50. </td>
  51. </tr>
  52. </tbody>
  53. </table>
  54. </div>
  55. <div class="table--wrap">
  56. <di class="table--t">
  57. <h3>주주구성</h3>
  58. </di>
  59. <table>
  60. <colgroup>
  61. <col width="20%" />
  62. <col width="80%" />
  63. </colgroup>
  64. <tbody>
  65. <tr>
  66. <th class="bg le">최대주주 및 특수 관계인<span class="bul">*</span></th>
  67. <td>
  68. <div class="input--wrap">
  69. <v-text-field
  70. maxlength="10"
  71. style="width: 300px"
  72. v-model="form.formValue3"
  73. @input="(e) => formatNumber(e, 'formValue3')"
  74. class="custom-input mini left"
  75. placeholder="비율을 입력하세요"
  76. ></v-text-field>
  77. <span>%</span>
  78. </div>
  79. </td>
  80. </tr>
  81. <tr>
  82. <th class="bg le">기관<span class="bul">*</span></th>
  83. <td>
  84. <div class="input--wrap">
  85. <v-text-field
  86. maxlength="10"
  87. style="width: 300px"
  88. v-model="form.formValue4"
  89. @input="(e) => formatNumber(e, 'formValue4')"
  90. class="custom-input mini left"
  91. placeholder="비율을 입력하세요"
  92. ></v-text-field>
  93. <span>%</span>
  94. </div>
  95. </td>
  96. </tr>
  97. <tr>
  98. <th class="bg le">외국인<span class="bul">*</span></th>
  99. <td>
  100. <div class="input--wrap">
  101. <v-text-field
  102. maxlength="10"
  103. style="width: 300px"
  104. @input="(e) => formatNumber(e, 'formValue5')"
  105. v-model="form.formValue5"
  106. class="custom-input mini left"
  107. placeholder="비율을 입력하세요"
  108. ></v-text-field>
  109. <span>%</span>
  110. </div>
  111. </td>
  112. </tr>
  113. <tr>
  114. <th class="bg le">자사주<span class="bul">*</span></th>
  115. <td>
  116. <div class="input--wrap">
  117. <v-text-field
  118. maxlength="10"
  119. style="width: 300px"
  120. v-model="form.formValue6"
  121. @input="(e) => formatNumber(e, 'formValue6')"
  122. class="custom-input mini left"
  123. placeholder="비율을 입력하세요"
  124. ></v-text-field>
  125. <span>%</span>
  126. </div>
  127. </td>
  128. </tr>
  129. <tr>
  130. <th class="bg le">기타<span class="bul">*</span></th>
  131. <td>
  132. <div class="input--wrap">
  133. <v-text-field
  134. maxlength="10"
  135. v-model="form.formValue7"
  136. @input="(e) => formatNumber(e, 'formValue7')"
  137. style="width: 300px"
  138. class="custom-input mini left"
  139. placeholder="비율을 입력하세요"
  140. ></v-text-field>
  141. <span>%</span>
  142. </div>
  143. </td>
  144. </tr>
  145. </tbody>
  146. </table>
  147. </div>
  148. <div class="view-btm-btn">
  149. <div class="btn-l"></div>
  150. <div class="btn-r">
  151. <v-btn class="custom-btn btn-blue2" @click="fnUpdEvt"
  152. ><i class="ico"></i>저장</v-btn
  153. >
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </template>
  159. <script setup>
  160. import VueDatePicker from "@vuepic/vue-datepicker";
  161. import "@vuepic/vue-datepicker/dist/main.css";
  162. /************************************************************************
  163. | 레이아웃
  164. ************************************************************************/
  165. definePageMeta({
  166. layout: "default",
  167. });
  168. /************************************************************************
  169. | PROPS
  170. ************************************************************************/
  171. const props = defineProps({
  172. propsData: {
  173. type: Object,
  174. default: () => {},
  175. },
  176. });
  177. /************************************************************************
  178. | 스토어
  179. ************************************************************************/
  180. const useDtStore = useDetailStore();
  181. /************************************************************************
  182. | 전역
  183. ************************************************************************/
  184. const { $toast, $log, $dayjs, $eventBus } = useNuxtApp();
  185. const router = useRouter();
  186. const pageId = ref("기업경영구조");
  187. const pageIdSub = ref();
  188. const datePickerFormat = "yyyy-MM-dd";
  189. const form = ref({
  190. formValue1: "",
  191. formValue2: "",
  192. formValue3: "",
  193. formValue4: "",
  194. formValue5: "",
  195. formValue6: "",
  196. formValue7: "",
  197. });
  198. /* eslint-disable */
  199. /* prettier-ignore */
  200. /************************************************************************
  201. | 함수(METHODS)
  202. ************************************************************************/
  203. const formatNumber = (event, key) => {
  204. let formattedInput = "";
  205. // 숫자만 남기기
  206. const input = event.target.value.replace(/[^0-9.]/g, '');
  207. // 3자리마다 쉼표 추가
  208. formattedInput = input;
  209. if(key == 'formValue1'){
  210. formattedInput = new Intl.NumberFormat().format(input);
  211. }
  212. // 실시간으로 업데이트
  213. form.value[key] = String(formattedInput);
  214. };
  215. const formatDate = (date) => {
  216. const d = new Date(date);
  217. const year = d.getFullYear();
  218. const month = ("0" + (d.getMonth() + 1)).slice(-2);
  219. const day = ("0" + d.getDate()).slice(-2);
  220. return `${year}-${month}-${day}`;
  221. };
  222. const fnUpdate = () => {
  223. let wterGet = localStorage.getItem("tempAccess");
  224. let _req = {
  225. wter: wterGet,
  226. shar_count: form.value.formValue1,
  227. iss_shar_stan_date: form.value.formValue2,
  228. major_shar: form.value.formValue3,
  229. corp_inve: form.value.formValue4,
  230. fogn_inve: form.value.formValue5,
  231. repu_shar: form.value.formValue6,
  232. etc_shar: form.value.formValue7,
  233. };
  234. _req = Object.fromEntries(
  235. Object.entries(_req).map(([key, value]) => [
  236. key,
  237. typeof value === "string"
  238. ? value.replace(/,/g, "") // 문자열인 경우에만 replace
  239. : value == null
  240. ? "" // null 또는 undefined 값은 빈 문자열로 처리
  241. : String(value), // 그 외 값은 문자열로 변환
  242. ])
  243. );
  244. console.error(_req);
  245. useAxios()
  246. .post("/bm/ins", _req)
  247. .then((res) => {
  248. window.location.reload();
  249. })
  250. .catch((error) => {});
  251. };
  252. const fnDetail = () => {
  253. let _req = {};
  254. useAxios()
  255. .post("/bm/detail", _req)
  256. .then((res) => {
  257. console.error(res.data);
  258. // const formattedData = Object.fromEntries(
  259. // Object.entries(res.data).map(([key, value]) => {
  260. // let formattedValue = null;
  261. // // 연도는 쉼표 제거, 금액은 쉼표 추가
  262. // if(key !== shar_count){
  263. // formattedValue = !isNaN(value)
  264. // ? new Intl.NumberFormat().format(Number(value))
  265. // : value;
  266. // } else {
  267. // formattedValue = value;
  268. // }
  269. // return [key, formattedValue];
  270. // })
  271. // );
  272. // res.data = formattedData;
  273. // console.error(formattedData)
  274. form.value.formValue1 = new Intl.NumberFormat().format(res.data.shar_count);
  275. form.value.formValue2 = res.data.iss_shar_stan_date;
  276. form.value.formValue3 = res.data.major_shar; //최대주주
  277. form.value.formValue4 = res.data.corp_inve; //기관
  278. form.value.formValue5 = res.data.fogn_inve; //외국인
  279. form.value.formValue6 = res.data.repu_shar; //자사주
  280. form.value.formValue7 = res.data.etc_shar; //기타
  281. })
  282. .catch((error) => {});
  283. };
  284. const fnUpdEvt = () => {
  285. let param = {
  286. id: pageId,
  287. title: "기업경영구조 저장",
  288. content: "저장하시겠습니까?",
  289. yes: {
  290. text: "저장",
  291. isProc: true,
  292. event: "FN_UPDATE",
  293. param: "",
  294. },
  295. no: {
  296. text: "취소",
  297. isProc: false,
  298. },
  299. };
  300. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  301. };
  302. $eventBus.off("FN_UPDATE");
  303. $eventBus.on("FN_UPDATE", () => {
  304. fnUpdate();
  305. });
  306. /************************************************************************
  307. | WATCH
  308. ************************************************************************/
  309. watch(
  310. () => form.value.formValue2,
  311. (newVal) => {
  312. if (newVal) {
  313. form.value.formValue2 = formatDate(newVal);
  314. }
  315. }
  316. );
  317. onMounted(() => {
  318. fnDetail();
  319. });
  320. </script>