박정하 박정하 03-05
250305 박정하 데이터 활용 관리 내 데이터 초기화 수정
@0e278d41baebb6a933b143e5e4bbafbb581fc5e0
client/views/component/SplitterLayout.vue
--- client/views/component/SplitterLayout.vue
+++ client/views/component/SplitterLayout.vue
@@ -1,11 +1,11 @@
 <template>
   <Splitter :class="{ 'content-box': true, active: splitInfo.layout_nm == selectLayout.layout_nm }" :layout="splitInfo.layout_type" @resizeend="updateSizes" @Click.stop="clickLayout(splitInfo)">
-    <SplitterPanel class="content-box" v-if="splitInfo.children.length < 1">
+    <SplitterPanel class="content-box padding-1" v-if="splitInfo.children.length < 1" :style="$createStyleSheet(splitInfo.styleSheet)">
       <ComponentTitle v-if="splitInfo.useSj" :title="splitInfo.layoutSj" />
       <BaseComponent v-else-if="splitInfo.se == 'component'" :component="splitInfo.component" @onChange="onChange" @Click.stop="clickLayout(splitInfo)" />
     </SplitterPanel>
     <template v-else>
-      <SplitterPanel class="content-box" v-for="(item, idx) of splitInfo.children" :key="idx">
+      <SplitterPanel class="content-box" v-for="(item, idx) of splitInfo.children" :key="idx" :style="$createStyleSheet(splitInfo.styleSheet)">
         <SplitterLayout :splitInfo="item" :selectLayout="selectLayout" @onChange="onChange" />
       </SplitterPanel>
     </template>
client/views/component/chart/chartDataTransform.js
--- client/views/component/chart/chartDataTransform.js
+++ client/views/component/chart/chartDataTransform.js
@@ -1,136 +1,153 @@
 
 const chartDataTransform = {
-    /**
-     * rowdata를 사용자 선택에 맞게 반환
-     * @param rowdata : 원본 데이터
-     * @param x : x축 객체 데이터
-     * @param yArr : y축 배열 데이터
-     */
-    createData: function(rowdata, xAxisList, yAxisList, group){
-        let resultArr = [];
-        let x;
-        //x축 객체 배열 데이터를 가져와서 columnNm 값을 가져옴
-        if(xAxisList.length !== 0){
-            x = xAxisList[0].columnIdx;
+  selectColumnIndex(dataTable, column) {
+    for (let i = 0; i < dataTable.columnDatas.length; i++) {
+      if (column == dataTable.columnDatas[i]) {
+        return i;
+      }
+    }
+    return null;
+  },
+  /**
+   * rowdata를 사용자 선택에 맞게 반환
+   * @param rowdata : 원본 데이터
+   * @param x : x축 객체 데이터
+   * @param yArr : y축 배열 데이터
+   */
+  createData: function (dataTable, xAxisList, yAxisList, group) {
+    let xAxis = null;
+    let yAxisArr = [];
+    let result = [];
+
+    if (dataTable.rowData.length > 0 && xAxisList.length > 0 && yAxisList.length > 0) {
+      xAxis = this.selectColumnIndex(dataTable, xAxisList[0]);
+      if (xAxis == null) {
+        return [];
+      }
+
+      for (let yAxis of yAxisList) {
+        let index = this.selectColumnIndex(dataTable, yAxis);
+        if (index == null) {
+          return [];
         }
 
-        //y축 객체 배열 데이터를 가져와서 columnNm 값을 배열로 가져옴
-        let yArr = yAxisList.map(field => {
-            return {
-                valNm: field.columnNm,
-                valIndex: field.columnIdx
-            }
-        });
+        yAxisArr.push(
+          {
+            key: yAxis.columnNm,
+            idx: index,
+          }
+        );
+      }
 
-        if (yArr.length > 0) {
-            // 반복문을 통해 y축의 데이터를 가져와서 datalist에 추가
-            for(let i = 0; i < rowdata.length; i++) {
-                let data = {
-                    categoryData: rowdata[i][x]
-                }
-                // data에 y축의 다중데이터 추가
-                yArr.forEach(field => {
-                    const fieldName = field.valNm;
-                    if(!data[fieldName]) {
-                        data[fieldName] = 0;
-                    }
-                    data[fieldName] += Number(rowdata[i][field.valIndex]);
-                });
-                // group 추가
-                if(group !== undefined && group !== ""){
-                data.group = rowdata[i][group];}
-                resultArr.push(data);
-            }
+      for (let row of dataTable.rowData) {
+        let data = {
+          categoryData: row[xAxis],
         }
-        return resultArr;
 
-    },
-    /**
-     * 변환된 데이터 그룹화
-     * @param data : 변환된 데이터
-     * @param yArr : y축 카테고리 배열 데이터
-     */
-    dataGrouping: function(data, yArr){
-        if (!Array.isArray(data) || !data) {
-            return {};
+        for (let yArr of yAxisArr) {
+          if (!data[yArr.key]) {
+            data[yArr.key] = 0;
+          }
+          data[yArr.key] += Number(row[yArr.idx]);
         }
-        return data.reduce((acc, cur) => {
-            if (!acc[cur.categoryData]) {
-                acc[cur.categoryData] = {};
-                // 각 필드 초기화
-                yArr.forEach(field => {
-                    acc[cur.categoryData][field.valNm] = { values: [], sum: 0, min: Infinity, max: -Infinity, count: 0 };
-                });
-            }
 
-            // 각 필드별 합계 계산
-            yArr.forEach(field => {
-                const fieldName = field.valNm;
-                // cur[fieldName]이 배열인지 확인하고, 아니라면 배열로 만듦
-                let values = Array.isArray(cur[fieldName]) ? cur[fieldName] : [cur[fieldName]];
-                values.forEach(value => {
-                    acc[cur.categoryData][fieldName].values.push(value);
-                    acc[cur.categoryData][fieldName].sum += value;
-                    acc[cur.categoryData][fieldName].min = Math.min(acc[cur.categoryData][fieldName].min, value);
-                    acc[cur.categoryData][fieldName].max = Math.max(acc[cur.categoryData][fieldName].max, value);
-                    acc[cur.categoryData][fieldName].count += 1;
-                });
-            });
+        if (group != null && group !== undefined && group !== "") {
+          data.group = row[group];
+        }
 
-            return acc;
-        }, {});
-    },
+        result.push(data);
+      }
+    }
 
-    /**
-     * 데이터 계산 값으로 가공 (min, max, sum, avg)
-     * @param groupData : 그룹화된 데이터
-     * @param selectedCal : 사용자가 선택한 계산 값
-     */
-    calculateSetting: function(groupData, selectedCal) {
-        let result = Object.keys(groupData).map(categoryData => {
-            const result = { categoryData: categoryData };
-            Object.keys(groupData[categoryData]).forEach(fieldName => {
-                const fieldData = groupData[categoryData][fieldName];
-                switch (selectedCal) {
-                    case "sum":
-                        result[fieldName] = fieldData.sum;
-                        break;
-                    case "avg":
-                        result[fieldName] = fieldData.sum / fieldData.count;
-                        break;
-                    case "min":
-                        result[fieldName] = fieldData.min;
-                        break;
-                    case "max":
-                        result[fieldName] = fieldData.max;
-                        break;
-                }
-            });
-            return result;
+    return result;
+  },
+
+  /**
+   * 변환된 데이터 그룹화
+   * @param data : 변환된 데이터
+   * @param yArr : y축 카테고리 배열 데이터
+   */
+  dataGrouping: function (data, yArr) {
+    if (!Array.isArray(data) || !data) {
+      return {};
+    }
+    return data.reduce((acc, cur) => {
+      if (!acc[cur.categoryData]) {
+        acc[cur.categoryData] = {};
+        // 각 필드 초기화
+        yArr.forEach(field => {
+          acc[cur.categoryData][field.valNm] = { values: [], sum: 0, min: Infinity, max: -Infinity, count: 0 };
         });
-        return result;
-    },
+      }
 
-    /**
-     * 데이터 필터링
-     * 선택 된 그룹의 데이터로 가공
-     */
-    setFilteringData : function(dataList ,subGroupArr, selectedSubGroup){
-        // groupSubArr에서 selectedSubGroup의 index를 찾아서 그 columnNm을 찾아옴
-        const selectedSubGroupNm = subGroupArr.find(column => column.index === Number(selectedSubGroup)).columnNm;
-        return dataList.filter(data => data.group === selectedSubGroupNm);
-    },
-    /**
-     * 음수 차트 데이터 처리
-     */
-    convertValuesToNegative: function(data, fieldNm){
-        // 데이터 리스트를 순회하며 각 객체의 값을 확인
-        let test = data.forEach(obj => {
-            obj[fieldNm] = -Math.abs(obj[fieldNm]);
+      // 각 필드별 합계 계산
+      yArr.forEach(field => {
+        const fieldName = field.valNm;
+        // cur[fieldName]이 배열인지 확인하고, 아니라면 배열로 만듦
+        let values = Array.isArray(cur[fieldName]) ? cur[fieldName] : [cur[fieldName]];
+        values.forEach(value => {
+          acc[cur.categoryData][fieldName].values.push(value);
+          acc[cur.categoryData][fieldName].sum += value;
+          acc[cur.categoryData][fieldName].min = Math.min(acc[cur.categoryData][fieldName].min, value);
+          acc[cur.categoryData][fieldName].max = Math.max(acc[cur.categoryData][fieldName].max, value);
+          acc[cur.categoryData][fieldName].count += 1;
         });
-        return test;
-    },
-    
+      });
+
+      return acc;
+    }, {});
+  },
+
+  /**
+   * 데이터 계산 값으로 가공 (min, max, sum, avg)
+   * @param groupData : 그룹화된 데이터
+   * @param selectedCal : 사용자가 선택한 계산 값
+   */
+  calculateSetting: function (groupData, selectedCal) {
+    let result = Object.keys(groupData).map(categoryData => {
+      const result = { categoryData: categoryData };
+      Object.keys(groupData[categoryData]).forEach(fieldName => {
+        const fieldData = groupData[categoryData][fieldName];
+        switch (selectedCal) {
+          case "sum":
+            result[fieldName] = fieldData.sum;
+            break;
+          case "avg":
+            result[fieldName] = fieldData.sum / fieldData.count;
+            break;
+          case "min":
+            result[fieldName] = fieldData.min;
+            break;
+          case "max":
+            result[fieldName] = fieldData.max;
+            break;
+        }
+      });
+      return result;
+    });
+    return result;
+  },
+
+  /**
+   * 데이터 필터링
+   * 선택 된 그룹의 데이터로 가공
+   */
+  setFilteringData: function (dataList, subGroupArr, selectedSubGroup) {
+    // groupSubArr에서 selectedSubGroup의 index를 찾아서 그 columnNm을 찾아옴
+    const selectedSubGroupNm = subGroupArr.find(column => column.index === Number(selectedSubGroup)).columnNm;
+    return dataList.filter(data => data.group === selectedSubGroupNm);
+  },
+  /**
+   * 음수 차트 데이터 처리
+   */
+  convertValuesToNegative: function (data, fieldNm) {
+    // 데이터 리스트를 순회하며 각 객체의 값을 확인
+    let test = data.forEach(obj => {
+      obj[fieldNm] = -Math.abs(obj[fieldNm]);
+    });
+    return test;
+  },
+
 }
 
 export default chartDataTransform;
(파일 끝에 줄바꿈 문자 없음)
client/views/component/elementComponent/BaseComponent.vue
--- client/views/component/elementComponent/BaseComponent.vue
+++ client/views/component/elementComponent/BaseComponent.vue
@@ -32,9 +32,8 @@
   },
   mounted() {
     let changeData = this.component.component_itm;
-    let rowData = changeData.dataTable.rowData;
     if (this.component.component_itm.data_list == null) {
-      this.component.component_itm.data_list = chartDataTransform.createData(rowData, changeData.categoryAxis, changeData.valueAxis, "null");
+      this.component.component_itm.data_list = chartDataTransform.createData(changeData.dataTable, changeData.categoryAxis, changeData.valueAxis, "null");
     }
   },
 }
client/views/pages/custom/InsertDataAnalytics.vue
--- client/views/pages/custom/InsertDataAnalytics.vue
+++ client/views/pages/custom/InsertDataAnalytics.vue
@@ -184,7 +184,7 @@
                             <div v-for="(column, idx) of this.currentDataTable.columnDatas" :key="idx" :class="{
                               item: true,
                               mb5: idx < currentDataTable.columnDatas.length - 1,
-                            }" draggable="true" @dragstart="startDrag($event, column, idx)">
+                            }" draggable="true" @dragstart="startDrag(column)">
                               <p>
                                 <b>{{ column.displyColumnNm }}</b> ({{ column.columnNm }}) : [{{ column.dataTy }}]
                               </p>
@@ -201,7 +201,7 @@
                         <div class="flex30 mb10">
                           <div class="editor-box content-box pd10">
                             <p class="object-title mb5">항목(Category)</p>
-                            <div class="overflow-y" style="height: calc(100% - 22px)" @drop.prevent="onDrop($event, 'xdata')" @dragenter.prevent @dragover.prevent>
+                            <div class="overflow-y" style="height: calc(100% - 22px)" @drop.prevent="onDrop('xdata')" @dragenter.prevent @dragover.prevent>
                               <template v-if="dataX.length > 0">
                                 <div v-for="(column, indx) of dataX" :key="indx" :class="{
                                   'item flex justify-between align-center': true,
@@ -227,7 +227,7 @@
                                 <option v-for="(item, idx) of calcList" :key="idx" :value="item.key">{{ item.value }}</option>
                               </select>
                             </div>
-                            <div class="overflow-y" style="height: calc(100% - 22px)" @drop.prevent="onDrop($event, 'ydata')" @dragenter.prevent @dragover.prevent>
+                            <div class="overflow-y" style="height: calc(100% - 22px)" @drop.prevent="onDrop('ydata')" @dragenter.prevent @dragover.prevent>
                               <template v-if="dataY.length > 0">
                                 <div v-for="(column, indx) of dataY" :key="indx" :class="{
                                   'item flex justify-between align-center': true,
@@ -299,7 +299,7 @@
                   <span v-else>수정</span>
                 </button>
                 <button class="blue-border-btn small-btn" @click="fnInit"> 초기화 </button>
-                <button class="darkg-btn small-btn" @click="moveBack"> 취소 </button>
+                <button class="darkg-btn small-btn" @click="fnGotoList">취소</button>
               </div>
             </div>
           </div>
@@ -482,23 +482,22 @@
           name: "라인 백그라운드 차트",
         },
       ],
+      calcList: [
+        { key: "default", value: "기본" },
+        { key: "sum", value: "합계" },
+        { key: "avg", value: "평균" },
+        { key: "min", value: "최솟값" },
+        { key: "max", value: "최댓값" },
+      ],
 
       pageId: this.$route.query.page_id,
-
-      activeTab: "pageInfo",
-      activeOption: "LAYOUT",
 
       isModalOpen: false,
       isTabZoneOpen: false,
       isAttributeOpen: false,
 
-      // 최상위 레이아웃 정보 담는 객체
-      splitInfo: _.cloneDeep(this.$getDefaultJobGroup().customSplitter),
-      splitInfo_dumy: _.cloneDeep(this.$getDefaultJobGroup().customSplitter),
-
-      dragData: {},
-      dataX: [],
-      dataY: [],
+      activeTab: "pageInfo",
+      activeOption: "LAYOUT",
 
       // 페이지정보 탭
       customTitle: null, // 제목
@@ -506,17 +505,8 @@
       customComment: null, // 설명
 
       activeIndex: null,
-      createChartData: _.cloneDeep(this.$getDefaultJobGroup().componentData), // x, y축 (객체 형식으로 데이터 수정 필요)
 
-      // 레이아웃 및 컴포넌트
-      // 레이아웃
-      // 타이틀
-      layoutSj: Object.assign({}, this.$getDefaultObject().layoutSj),
-
-      // 컴포넌트
-
-
-      // 잡그룹목록
+      splitInfo: _.cloneDeep(this.$getDefaultJobGroup().customSplitter),
       jobGroupList: [],
 
       // 현재 작업 객체
@@ -526,24 +516,19 @@
       currentCalc: "default",
       currentDataTable: Object.assign({}, this.$getDefaultObject().dataTable),
 
-      // 컬럼정보
-      calcList: [
-        { key: "default", value: "기본" },
-        { key: "sum", value: "합계" },
-        { key: "avg", value: "평균" },
-        { key: "min", value: "최솟값" },
-        { key: "max", value: "최댓값" },
-      ],
+      dragData: {},
+      dataX: [],
+      dataY: [],
     };
   },
 
   created() {
     this.activeTab = "pageInfo";
 
-    if (this.pageId != null && this.pageId != undefined) {
-      this.getCustomData(); // 기존 데이터 가져오기
-    } else {
+    if (this.$isEmpty(this.pageId)) {
       this.init();
+    } else {
+      this.getCustomData(); // 기존 데이터 가져오기
     }
   },
 
@@ -552,6 +537,140 @@
   watch: {},
 
   methods: {
+    // 초기화
+    async init() {
+      // 탭, 옵션 초기화
+      this.$activeTab = "pageInfo";
+      this.activeOption = "LAYOUT";
+      this.activeIndex = null;
+
+      // 페이지 정보 초기화
+      this.initPageInfo();
+
+      // 레이아웃 초기화
+      let splitInfo = _.cloneDeep(this.$getDefaultJobGroup().customSplitter);
+      splitInfo.se = "splitter";
+      splitInfo.depth = 0;
+      splitInfo.layout_nm = "LAY_" + this.generateShortUUID();
+      splitInfo.position_idx = 1;
+      splitInfo.styleSheet.borderStyle = Object.assign({}, this.$getDefaultJobGroup().borderStyle);
+      splitInfo.styleSheet.background_style = Object.assign({}, this.$getDefaultJobGroup().background_style);
+      this.splitInfo = splitInfo;
+
+      // 데이터 초기화
+      this.jobGroupList = [];
+
+      this.initCurrent(this.splitInfo); // 현재 작업 객체 초기화
+    },
+
+    // 페이지 정보 초기화
+    initPageInfo() {
+      this.customTitle = null;
+      this.customComment = null;
+      this.public_at = true;
+    },
+
+    // 현재 작업 객체 초기화
+    initCurrent(layout) {
+      this.currentLayout = layout;
+
+      // 레이어에 컴포넌트를 생성한 경우
+      let component = layout.component;
+      if (component != null) {
+        // 컴포넌트 선택
+        this.activeIndex = null; // 초기화
+        this.chartComponent.forEach((item, idx) => {
+          if (item.id === component.component_itm.chart_knd) {
+            this.activeIndex = idx;
+          }
+        });
+
+        // 컬럼 정보 변경
+        this.dataX = component.component_itm.categoryAxis;
+        this.dataY = component.component_itm.valueAxis;
+        this.currentCalc = component.component_itm.chart_cal;
+
+        // 현재 잡그룹 변경
+        if (component.jobInfo.length > 0) {
+          this.currentJobGroupIdx = null;
+          this.currentJobGroup = component.jobInfo[0];
+
+          // 현재 데이터테이블 변경
+          if (this.currentJobGroup.jobItms.length === 0) {
+            this.currentDataTable = Object.assign({}, this.$getDefaultObject().dataTable);
+          } else {
+            const index = this.currentJobGroup.jobItms.length - 1;
+            this.currentDataTable = this.currentJobGroup.jobItms[index].dataTable;
+          }
+
+          this.onChangeChartData(); // 차트 데이터 수정
+
+          return;
+        }
+      }
+
+      this.currentJobGroupIdx = null;
+      this.currentJobGroup = Object.assign({}, this.$getDefaultObject().jobGroup);
+      this.initColumnInfo(); // 현재 컬럼 정보 초기화
+    },
+
+    // 현재 컬럼 정보 초기화
+    initColumnInfo() {
+      // 현재 데이터테이블 변경
+      if (this.currentJobGroup.jobItms.length === 0) {
+        this.currentDataTable = Object.assign({}, this.$getDefaultObject().dataTable);
+      } else {
+        const index = this.currentJobGroup.jobItms.length - 1;
+        this.currentDataTable = this.currentJobGroup.jobItms[index].dataTable;
+      }
+
+      // 컬럼 정보 초기화
+      this.dragData = {};
+      this.dataX = [];
+      this.dataY = [];
+      this.currentCalc = "default";
+
+      // 컴포넌트가 있는 경우 컴포넌트 데이터 초기화
+      let component = this.currentLayout.component;
+      if (component != null) {
+        component.component_itm.dataTable = this.currentJobGroup;
+        component.component_itm.data_list = [];
+      }
+
+      this.onChangeChartData(); // 차트 데이터 수정
+    },
+
+    // 기존 데이터 가져오기
+    getCustomData() {
+      const vm = this;
+      axios({
+        url: "/custom/customPageUpdateSelect",
+        method: "post",
+        headers: { "Content-Type": "application/json; charset=UTF-8" },
+        data: { page_id: vm.pageId },
+      })
+        .then((response) => {
+          // 페이지정보
+          let resPageInfo = response.data.resultData.pageInfo;
+          vm.customTitle = resPageInfo.ttl;
+          vm.customComment = resPageInfo.cn;
+          vm.public_at = resPageInfo.public_at;
+
+          // 레이아웃
+          let resSplitterInfo = response.data.resultData.splitterInfo;
+          vm.splitInfo = resSplitterInfo;
+          vm.currentLayout = vm.splitInfo;
+
+          // 데이터 목록
+          let resjobGroupList = response.data.resultData.jobGroupList;
+          vm.jobGroupList = resjobGroupList;
+        })
+        .catch((error) => {
+          vm.$showAlert("오류", "데이터 현황관리 차트 연결 오류, 관리자에게 문의하세요.");
+          vm.fnGotoList();
+        });
+    },
+
     // 현재 탭 변경
     fnChangeTab(type, current) {
       if (type == "nav") {
@@ -591,7 +710,7 @@
       }
 
       if (this.currentLayout.children.length > 0) {
-        this.$showAlert("메세지", "선택된 레이아웃이 비어있지 않습니다.<br>선택된 레이아웃 내부를 비우거나 다른 레이아웃을 선택해 주세요.");
+        this.$showAlert("메세지", "선택된 레이아웃이 분할되어 있습니다.<br>선택된 레이아웃 내부를 하나로 합치거나 다른 레이아웃을 선택해 주세요.");
         return true;
       }
 
@@ -604,12 +723,18 @@
 
       // 유효성 검사
       if (this.validationByCreateComponent(id)) {
-        return
+        return;
       };
 
-      let isCheck = await this.$showConfirm("컴포넌트 추가", name + " 컴포넌트를 추가하시겠습니까?");
+      let message;
+      if (this.currentLayout.component == null) {
+        message = name + " 컴포넌트를 추가하시겠습니까?";
+      } else {
+        message = "선택된 레이아웃이 비어있지 않습니다.<br>선택한 컴포넌트로 덮어쓰기 하시겠습니까?";
+      }
+
+      let isCheck = await this.$showConfirm("메세지", message);
       if (isCheck) {
-        let jobGroup = _.cloneDeep(this.$getDefaultJobGroup().jobGroup);
         let chartData = _.cloneDeep(this.$getDefaultJobGroup().componentData);
         chartData.chart_knd = id;
         chartData.component_nm = "ChartCmmn";
@@ -617,13 +742,14 @@
 
         let component = _.cloneDeep(this.$getDefaultJobGroup().component);
         component.component_itm = chartData;
+
+        let jobGroup = Object.assign({}, this.$getDefaultJobGroup().jobGroup);
+
         component.jobInfo = [];
         component.jobInfo.push(jobGroup);
 
         this.currentLayout.se = "component";
         this.currentLayout.component = component;
-
-        this.getSelectLayoutChart(); // 선택한 레이아웃의 차트 정보 조회
       }
     },
 
@@ -632,7 +758,6 @@
       console.log("layout: ", layout);
 
       this.currentLayout = layout;
-      this.getSelectLayoutChart(); // 선택한 레이아웃의 차트 정보 조회
 
       this.optionList = [
         { id: "LAYOUT", name: "레이아웃", useAt: true },
@@ -640,31 +765,7 @@
         { id: "COMPONENT", name: "컴포넌트", useAt: !this.$isEmpty(layout.component) },
       ];
 
-      if (this.$isEmpty(layout.component)) {
-        this.dataX = [];
-        this.dataY = [];
-        this.currentCalc = null;
-      } else {
-        this.dataX = layout.component.component_itm.categoryAxis;
-        this.dataY = layout.component.component_itm.valueAxis;
-        this.currentCalc = layout.component.component_itm.chart_cal;
-      }
-    },
-
-    // 선택한 레이아웃의 차트 정보 조회
-    getSelectLayoutChart() {
-      if (this.currentLayout.se == "component") {
-        let chartId = this.currentLayout.component.component_itm.chart_knd;
-        if (this.$isEmpty(chartId)) {
-          this.chartComponent.forEach((item, idx) => {
-            if (item.id === chartId) {
-              this.activeIndex = idx;
-            }
-          });
-        } else {
-          this.activeIndex = null;
-        }
-      }
+      this.initCurrent(layout); // 현재 작업 객체 초기화
     },
 
     findLoop(item) {
@@ -692,7 +793,6 @@
       }
 
       let copy = _.cloneDeep(this.currentLayout);
-      copy.se = "splitter";
       copy.parents_splitter_id = this.currentLayout.layout_nm;
       copy.depth = this.currentLayout.depth + 1;
       copy.indx = 0;
@@ -802,22 +902,6 @@
       return fullUUID.replace(/-/g, '').substring(0, 8);
     },
 
-    // 초기화
-    async init() {
-      this.splitInfo = _.cloneDeep(this.$getDefaultJobGroup().customSplitter);
-      this.splitInfo.se = "splitter";
-      this.splitInfo.depth = 0;
-      this.splitInfo.layout_nm = "LAY_" + this.generateShortUUID();
-      this.splitInfo.position_idx = 1;
-      this.splitInfo.styleSheet.borderStyle = Object.assign({}, this.$getDefaultJobGroup().borderStyle);
-      this.splitInfo.styleSheet.background_style = Object.assign({}, this.$getDefaultJobGroup().background_style);
-
-      this.currentLayout = this.splitInfo;
-
-      // 데이터 관리 초기화
-      this.jobGroupList = [];
-    },
-
     // 초기화 버튼 동작
     async fnInit() {
       let isCheck = await this.$showConfirm("초기화", "초기화 하시겠습니까? 데이터가 모두 삭제됩니다.");
@@ -829,6 +913,7 @@
     // 컬럼정보 비우기
     fnInitColInfo() {
       this.currentJobGroup = Object.assign({}, this.$getDefaultObject().jobGroup);
+      this.initColumnInfo(); // 현재 컬럼 정보 초기화
     },
 
     // 값 계산법 변경
@@ -836,97 +921,65 @@
       this.currentLayout.component.component_itm.chart_cal = value;
     },
 
-    // 기존 데이터 가져오기
-    getCustomData() {
-      const vm = this;
-      axios({
-        url: "/custom/customPageUpdateSelect",
-        method: "post",
-        headers: { "Content-Type": "application/json; charset=UTF-8" },
-        data: { page_id: vm.pageId },
-      })
-        .then(function (response) {
-          let resPageInfo = response.data.resultData.pageInfo;
-          let resjobGroupList = response.data.resultData.jobGroupList;
-          let resSplitterInfo = response.data.resultData.splitterInfo;
-
-          vm.customTitle = resPageInfo.ttl;
-          vm.customComment = resPageInfo.cn;
-
-          vm.splitInfo = resSplitterInfo;
-
-          vm.splitInfo_dumy.layout_nm = "dumy";
-          vm.splitInfo_dumy.se = "splitter";
-          vm.splitInfo_dumy.children.push(vm.splitInfo);
-
-          vm.jobGroupList = resjobGroupList;
-
-          vm.currentLayout = vm.splitInfo;
-          vm.public_at = resPageInfo.public_at;
-          vm.getSelectLayoutChart();
-        })
-        .catch(function (error) {
-          vm.$showAlert(
-            "데이터 현황관리 차트 연결",
-            "데이터 현황관리 차트 연결 오류, 관리자에게 문의하세요."
-          );
-          vm.moveBack();
-        });
-    },
-
+    // 레이아웃 삭제
     async deleteSplitterLayout() {
       if (!this.currentLayout.layout_nm) {
         this.$showAlert("메세지", "삭제할 레이아웃이 없습니다.");
         return;
       }
-      if (!this.currentLayout.parents_splitter_id) {
+
+      if (this.currentLayout.layout_nm == this.splitInfo.layout_nm) {
         this.$showAlert("메세지", "최상위 레이아웃은 삭제할 수 없습니다.");
         return;
       }
-      if (
-        await this.$showConfirm(
-          "레이아웃 삭제",
-          "선택한 레이아웃을 삭제하시겠습니까?"
-        )
-      ) {
-        let parentLayout = this.findParentLayout(
-          this.splitInfo,
-          this.currentLayout.parents_splitter_id
-        );
-        //선택한 레이아웃의 형제정보 찾기
-        let otherIdx = parentLayout.children.findIndex(
-          (item) => item.layout_nm !== this.currentLayout.layout_nm
-        );
-        let otherSplit = parentLayout.children[otherIdx];
-        //otherSplit의 component, children 정보 가져오기
-        let otherComponent = otherSplit.component;
-        let otherChildren = otherSplit.children;
-        let layoutSize1 = otherSplit.layout_size1;
-        let layoutSize2 = otherSplit.layout_size2;
-        let layoutType = otherSplit.layout_type;
-        let se = otherSplit.se;
-        let size = otherSplit.size;
-        let styleSheet = otherSplit.styleSheet;
 
-        // 부모 레이아웃에 다른 split의 정보 넣어 주기
-        parentLayout.component = otherComponent;
-        parentLayout.children = otherChildren;
-        parentLayout.layout_size1 = layoutSize1;
-        parentLayout.layout_size2 = layoutSize2;
-        parentLayout.layout_type = layoutType;
-        parentLayout.se = se;
-        parentLayout.size = size;
-        parentLayout.styleSheet = styleSheet;
+      let isCheck = await this.$showConfirm(
+        "레이아웃 삭제",
+        "선택한 레이아웃을 삭제하시겠습니까?"
+      );
+      if (!isCheck) {
+        return;
+      }
 
-        // 자식에게서 가져온 자식의 자식 정보의 부모 정보 변경
-        if (parentLayout.children.length > 0) {
-          parentLayout.children.forEach((item) => {
-            item.parents_splitter_id = parentLayout.layout_nm;
-          });
-        }
+      let parentLayout = this.findParentLayout(
+        this.splitInfo,
+        this.currentLayout.parents_splitter_id
+      );
+
+      //선택한 레이아웃의 형제정보 찾기
+      let otherIdx = parentLayout.children.findIndex(
+        (item) => item.layout_nm !== this.currentLayout.layout_nm
+      );
+      let otherSplit = parentLayout.children[otherIdx];
+      //otherSplit의 component, children 정보 가져오기
+      let otherComponent = otherSplit.component;
+      let otherChildren = otherSplit.children;
+      let layoutSize1 = otherSplit.layout_size1;
+      let layoutSize2 = otherSplit.layout_size2;
+      let layoutType = otherSplit.layout_type;
+      let se = otherSplit.se;
+      let size = otherSplit.size;
+      let styleSheet = otherSplit.styleSheet;
+
+      // 부모 레이아웃에 다른 split의 정보 넣어 주기
+      parentLayout.component = otherComponent;
+      parentLayout.children = otherChildren;
+      parentLayout.layout_size1 = layoutSize1;
+      parentLayout.layout_size2 = layoutSize2;
+      parentLayout.layout_type = layoutType;
+      parentLayout.se = se;
+      parentLayout.size = size;
+      parentLayout.styleSheet = styleSheet;
+
+      // 자식에게서 가져온 자식의 자식 정보의 부모 정보 변경
+      if (parentLayout.children.length > 0) {
+        parentLayout.children.forEach((item) => {
+          item.parents_splitter_id = parentLayout.layout_nm;
+        });
       }
     },
 
+    // 부모 요소 검색
     findParentLayout(splitInfo, selectParentLayoutId) {
       // splitInfo가 배열인 경우 각 요소에 대해 재귀적으로 함수를 호출
       if (Array.isArray(splitInfo)) {
@@ -957,7 +1010,7 @@
     },
 
     // 취소 (데이터활용관리 목록으로 이동)
-    async moveBack() {
+    async fnGotoList() {
       let isCheck = await this.$showConfirm("경고", "취소할 경우 작성된 내용이 삭제됩니다.");
       if (isCheck) {
         this.$router.push({ path: "/customSelectList.page" });
@@ -965,24 +1018,43 @@
     },
 
     // 잡그룹 추가
-    fnCreateJobGroup() {
+    async fnCreateJobGroup() {
+      let component = this.currentLayout.component;
+      if (component != null) {
+        if (!this.$isEmpty(component.component_itm.data_list)) {
+          let isCheck = await this.$showConfirm("경고", "컴포넌트 컬럼 설정 후, 새 데이터를 추가할 경우 기존 정보가 삭제됩니다.<br>새 데이터를 추가하시겠습니까?");
+          if (!isCheck) {
+            return;
+          }
+        }
+      }
+
       let jobGroup = Object.assign({}, this.$getDefaultObject().jobGroup);
       jobGroup.group_nm = "데이터" + (this.jobGroupList.length + 1);
       this.jobGroupList.push(jobGroup);
-      this.fnSelectJobGroup(jobGroup); // 잡그룹 선택 (추가한 잡그룹 선택)
+      this.currentJobGroup = jobGroup;
+      this.initColumnInfo(); // 현재 컬럼 정보 초기화
     },
 
     // 잡그룹 선택
-    fnSelectJobGroup(jobGroup) {
-      this.currentJobGroup = jobGroup;
-
-      // 잡그룹 내 마지막 데이터테이블 조회
-      if (!this.currentJobGroup.jobItms || this.currentJobGroup.jobItms.length === 0) {
-        this.currentDataTable = Object.assign({}, this.$getDefaultObject().dataTable);
-      } else {
-        const index = this.currentJobGroup.jobItms.length - 1;
-        this.currentDataTable = this.currentJobGroup.jobItms[index].dataTable;
+    async fnSelectJobGroup(jobGroup) {
+      let component = this.currentLayout.component;
+      if (component != null && jobGroup.jobItms.length > 0) {
+        let index = jobGroup.jobItms.length - 1;
+        if (component.component_itm.dataTable == jobGroup.jobItms[index].dataTable) {
+          return;
+        }
       }
+
+      if (!this.$isEmpty(component.component_itm.data_list)) {
+        let isCheck = await this.$showConfirm("경고", "컴포넌트 컬럼 설정 후, 다른 데이터를 선택할 경우 기존 정보가 삭제됩니다.<br>다른 데이터를 선택하시겠습니까?");
+        if (!isCheck) {
+          return;
+        }
+      }
+
+      this.currentJobGroup = jobGroup;
+      this.initColumnInfo(); // 현재 컬럼 정보 초기화
     },
 
     // 잡그룹관리 모달 열기
@@ -1005,12 +1077,12 @@
     },
 
     // 드래그 이벤트
-    startDrag(event, data, idx) {
+    startDrag(data) {
       this.dragData = data;
     },
 
     // 드랍 이벤트
-    async onDrop(event, type) {
+    async onDrop(type) {
       // 컴포넌트가 설정되지 않은 경우 경고 후 실행 취소
       if (this.$isEmpty(this.currentLayout.component)) {
         this.$showAlert("경고", "컴포넌트 등록 후 설정할 수 있습니다.");
@@ -1040,23 +1112,33 @@
         this.dataY.push(this.dragData);
       }
 
+      this.onChangeChartData();
+    },
+
+    // 차트 데이터 수정
+    onChangeChartData() {
+      if (this.currentLayout.component == null) {
+        return;
+      }
+
       if (!this.$isEmpty(this.dataX)) {
         this.currentLayout.component.component_itm.categoryAxis = this.dataX;
       }
+
       if (!this.$isEmpty(this.dataY)) {
         this.currentLayout.component.component_itm.valueAxis = this.dataY;
       }
 
-      // 축 데이터를 이용한 차트 데이터 생성
       if (!this.$isEmpty(this.dataX) && !this.$isEmpty(this.dataY)) {
         let dataList = chartDataTransform.createData(
-          this.currentDataTable.rowData,
-          this.currentLayout.component.component_itm.categoryAxis,
-          this.currentLayout.component.component_itm.valueAxis,
+          this.currentDataTable,
+          this.dataX,
+          this.dataY,
           "null"
         );
         this.currentLayout.component.component_itm.data_list = dataList;
       }
+
       this.currentLayout.component.jobInfo[0] = this.currentJobGroup;
     },
 
Add a comment
List