| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- <!DOCTYPE html>
- <html lang="ko"
- xmlns:th="http://www.thymeleaf.org">
- <!--
- *******************************************************************************
- * @source : goodsDealForm.html
- * @desc : 딜상상품 구성 관리
- *============================================================================
- * STYLE24
- * Copyright(C) 2019 TSIT, All rights reserved.
- *============================================================================
- * VER DATE AUTHOR DESCRIPTION
- * === =========== ========== =============================================
- * 1.0 2020.10.29 eskim 최초 작성
- *******************************************************************************
- -->
- <div class="modalPopup" data-width="1100" >
- <div class="panelStyle">
- <div class="panelTitle">
- <h2>딜 상품 구성</h2>
- <button type="button" class="close" onclick="fngoodsDealFormClose()"><i class="fa fa-times"></i></button>
- </div>
- <form id="goodsDealForm" name="goodsDealForm" th:method="post">
- <input type="hidden" id="goodsComposeList" name="goodsComposeList" />
- <div class="panelContent">
- <ul class="notice">
- <li>구성상품 등록시 기본값
- <!-- 아이콘 툴팁 -->
- <div class="iconTooltip">
- <i class="fa fa-info" aria-hidden="true"></i>
- <span class="left" style="width:450px; text-align:left;">
- * 딜상품 정보<br/>
- - 상품상태 : 정보부족<br/>
- - 정상가 : 판매가 입력값<br/>
- - 판매가 : 구성상품의 대표여부 'Y' 상품의 판매가<br/>
- - 브랜드코드 : 구성상품의 기준여부 'Y'상품의 브랜드코드<br/>
- - 품목코드 : 구성상품의 기준여부 'Y'상품의 품목코드<br/>
- - 포인트 : 구성상품의 기준여부 'Y'상품의 브랜드 포인트<br/>
- - 배송비정책 : 구성상품의 기준여부 'Y'상품의 브랜드 배송비정책<br/>
- <br/>
- * 구성상품 정보<br/>
- - 구상상품의 기준상품 : 수정 불가<br/>
- - 구상상품의 대표상품 : 수정 가능<br/>
- </span>
- </div>
- <!-- //아이콘 툴팁 -->
- </li>
- </ul>
- <table class="frmStyle">
- <colgroup>
- <col width="10%"/>
- <col/>
- <col width="10%"/>
- <col width="20%"/>
- <col width="10%"/>
- <col width="24%"/>
- </colgroup>
- <tr>
- <th>상품명<em class="required" title="필수"></em></th>
- <td><input type="text" id="goodsNm" name="goodsNm" maxlength="60"/></td>
- <th>판매가<em class="required" title="필수"></em></th>
- <td><input type="text" class="w100" id="currPrice" name="currPrice" maxlength="8" data-valid-type="numeric"/></td>
- <th>제조년월일<em class="required" title="필수"></em></th>
- <td><input type="text" class="w100" id="makeYmd" name="makeYmd" maxlength="8" data-valid-type="date"/></td>
- </tr>
- <tr>
- <th>년도/시즌<em class="required" title="필수"></em></th>
- <td><select name="styleYear" id="styleYear">
- <option value="">[전체]</option>
- <option th:if="${styleYearList}" th:each="oneData, status : ${styleYearList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
- </select>
- <select name="seasonCd" id="seasonCd">
- <option value="">[전체]</option>
- <option th:if="${seasonList}" th:each="oneData, status : ${seasonList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
- </select>
- </td>
- <th>성별<em class="required" title="필수"></em></th>
- <td><select name="sexGb" id="sexGb">
- <option value="">[전체]</option>
- <option th:if="${sexGbList}" th:each="oneData, status : ${sexGbList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
- </select>
- </td>
- <th>원산지<em class="required" title="필수"></em></th>
- <td ><select name="makeOriginCd" id="makeOriginCd">
- <option value="">[전체]</option>
- <option th:if="${makOriginList}" th:each="oneData, status : ${makOriginList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
- </select>
- <input type="hidden" id="makeNm" name="makeNm" />
- </td>
- </tr>
- </table>
- </div>
- <ul class="panelBar">
- <li class="left">
- <button type="button" class="btn btn-danger btn-lg" onclick="fnGoodsDealDeleteRow();">행삭제</button>
- </li>
- <li class="right">
- <button type="button" class="btn btnRight btn-default btn-lg" onclick="cfnDownloadSampleFile('SF003');">상품엑셀조회 양식 다운로드</button>
- <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDealSearchExcel" >엑셀조회</button>
- <button type="button" class="btn btnRight btn-base btn-lg" onclick="fnOpenGoodsDealPopup();">구상상품추가</button>
- </li>
- </ul>
- <div id="gridGoodsDealList" style="height: 450px;" class="ag-theme-balham lh60"></div>
- </form>
- <ul class="panelBar">
- <li class="right">
- <th:block th:if="${sessionInfo.roleCd == 'G001_0000' OR sessionInfo.roleCd == 'G001_A000' OR sessionInfo.roleCd == 'G001_A101' OR sessionInfo.roleCd == 'G001_A100' OR sessionInfo.roleCd == 'G001_A001'}">
- <button type="button" class="btn btnRight btn-success btn-lg" id="btnGoodsDealSave">저장</button>
- </th:block>
- </li>
- </ul>
- </div>
- </div>
- <script th:inline="javascript">
- /*<![CDATA[*/
- var useYnList = gagajf.convertToArray([[${useYnList}]]);
- var goodsStatList = gagajf.convertToArray([[${goodsStatList}]]);
- // specify the columns
- var columnGoodsDealDefs = [
- {width: 40, minWidth: 40, cellClass: 'text-center', headerCheckboxSelection: true, checkboxSelection: true, filter: false},
- {headerName: "CRUD", field: "crud", width: 75, minWidth: 75, hide: true},
- {headerName: "정렬", field: "dispOrd", width: 70 ,hide: false, cellClass: 'text-center', rowDrag: true },
- //{headerName: 'No', width: 60, cellClass: 'text-center', valueGetter: function(params) { return params.node.rowIndex + 1 }},
- {headerName: "이미지", field: "sysImgNm", width: 100, height: 60, cellClass: 'text-center'
- ,cellRenderer: function(params) {
- return '<img width="60" src="'+ _goodsUrl+ "/" + params.value + '" alt="" onerror="this.src=\'/image/no.gif\';"/>';
- }
- },
- {headerName: "구성상품코드", field: "compsGoodsCd" , width: 130, cellClass: 'text-center'},
- {headerName: "옵션명", field: "compsGoodsOptNm" , width: 250, cellClass: 'text-left',editable: true, required: true},
- {headerName: "판매가", field: "currPrice" , width: 100, cellClass: 'text-right'
- ,valueFormatter: function(params) {return params.value.addComma();}
- },
- {headerName: "기준여부(품목/전시카테)", field: "baseYn" , width: 170, cellClass: 'text-center',editable: true, required: true,
- cellEditor: 'agRichSelectCellEditor',
- cellEditorParams: { values: gagaAgGrid.extractValues(useYnList) },
- valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
- valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
- },
- {headerName: "대표여부(가격)", field: "repYn" , width: 120, cellClass: 'text-center',editable: true, required: true,
- cellEditor: 'agRichSelectCellEditor',
- cellEditorParams: { values: gagaAgGrid.extractValues(useYnList) },
- valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
- valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
- },
- {headerName: "전시여부", field: "useYn" , width: 80, cellClass: 'text-center',editable: true, required: true,
- cellEditor: 'agRichSelectCellEditor',
- cellEditorParams: { values: gagaAgGrid.extractValues(useYnList) },
- valueFormatter: function (params) { return gagaAgGrid.lookupValue(useYnList, params.value); },
- valueParser: function (params) { return gagaAgGrid.lookupKey(useYnList, params.newValue); }
- },
- {headerName: "상품상태", field: "goodsStat" , width: 100, cellClass: 'text-center',
- cellEditorParams: { values: gagaAgGrid.extractValues(goodsStatList) },
- valueFormatter: function (params) { return gagaAgGrid.lookupValue(goodsStatList, params.value); },
- valueParser: function (params) { return gagaAgGrid.lookupKey(goodsStatList, params.newValue); }
- },
- {headerName: "수량", field: "qty" , width: 80, cellClass: 'text-right',hide:true}
- ];
- // Get GridOptions
- var gridGoodsDealOptions = gagaAgGrid.getGridOptions(columnGoodsDealDefs);
- gridGoodsDealOptions.rowSelection = 'multiple';
- gridGoodsDealOptions.suppressRowClickSelection = true;
- gridGoodsDealOptions.stopEditingWhenGridLosesFocus = true; //그리드 에디터 값 저장가능
-
- // 드래그
- gridGoodsDealOptions.rowDragManaged = true;
- gridGoodsDealOptions.rowHeight = 60; //이미지가 있을경우 높이 지정해야함.
-
- //기준여부 표시
- gridGoodsDealOptions.getRowStyle = function(params) {
- if ("Y" == params.data.baseYn) {
- return { background: '#1ab394' };
- }else{
- return { background: '#ffffff' };
- }
- }
-
- // Row
- gridGoodsDealOptions.onCellValueChanged = function(event) {
- var rowIdx = null;
- var isChangColor = true;
- if (event.colDef.field == "baseYn"){
- if (event.data.baseYn == "Y"){
- rowIdx = event.rowIndex;
-
- //다른 기준여부 'Y'가 존재하는지 확인
- gridGoodsDealOptions.api.forEachNode(function(rowNode, index) {
- if (rowNode.data.baseYn == "Y" && index != rowIdx){
- event.data.baseYn = event.oldValue;
- gridGoodsDealOptions.api.updateRowData({update: [event.data]});
- isChangColor = false;
- return;
- }
- });
-
- if (!isChangColor){
- mcxDialog.alert('다른 구성상품에 기준여부가 선택되어 있습니다.');
- return;
- }
- }
- }
-
- isChangColor = true;
- if (event.colDef.field == "repYn"){
- if (event.data.repYn == "Y"){
- rowIdx = event.rowIndex;
-
- //다른 대표여부 'Y'가 존재하는지 확인
- gridGoodsDealOptions.api.forEachNode(function(rowNode, index) {
- if (rowNode.data.repYn == "Y" && index != rowIdx){
- event.data.repYn = event.oldValue;
- gridGoodsDealOptions.api.updateRowData({update: [event.data]});
- isChangColor = false;
- return;
- }
- });
-
- if (!isChangColor){
- mcxDialog.alert('다른 구성상품에 대표여부가 선택되어 있습니다.');
- return;
- }
- }
- }
- }
-
- //창종료
- var fngoodsDealFormClose = function(){
- uifnPopupClose('popupGoodsDeal');
- }
-
- $(document).ready(function() {
- gagaAgGrid.createGrid('gridGoodsDealList', gridGoodsDealOptions);
- });
-
- var fnOpenGoodsDealPopup = function() {
- cfnOpenGoodsPopup('fnCreateGoodsDeal');
- }
- // 상품추가
- var fnCreateGoodsDeal = function(goodsData) {
- if (goodsData.length < 1) return;
-
- // 기존상품
- var oldGoodsDealList = gagaAgGrid.getAllRowData(gridGoodsDealOptions);
- var idx = oldGoodsDealList.length+1;
-
- var isExist = false;
- goodsData.forEach(function(goods){
- isExist = false;
- gridGoodsDealOptions.api.forEachNode(function(rowNode, index) {
- if (goods.goodsCd == rowNode.data.compsGoodsCd){
- isExist = true;
- }
- });
- if (goods.goodsType != "G056_N"){
- isExist = true;
- }
- if(!isExist){
- var data = {
- compsGoodsCd: goods.goodsCd
- , goodsType: 'G056_D'
- , dispOrd: idx
- , qty: 1
- , compsCurrPrice: goods.currPrice
- , compsStaffCurrPrice: goods.currPrice
- , baseYn: 'N'
- , repYn: 'N'
- , goodsStat : goods.goodsStat
- , useYn: 'Y'
- , compsGoodsOptNm : goods.goodsNm
- , currPrice : goods.currPrice
- , selfGoodsYn : goods.selfGoodsYn
- , sysImgNm : goods.sysImgNm
- };
- //그리드 마지막에 추가해야함
- gridGoodsDealOptions.api.updateRowData({add: [data], addIndex: idx});
-
- idx++;
-
- }
- });
- gridGoodsDealOptions.api.refreshCells();
- }
-
- //엑셀 상품 조회
- $('#btnGoodsDealSearchExcel').on('click', function() {
- cfnExcelUploadPopup('goodsDealExcelUpload', 'goodsDealExcelUpload');
- });
- var goodsDealExcelUpload = function(result){
- var data = {procJob : result.procJob
- ,excelFileNm : result.excelFileNm
- };
- var jsonData = JSON.stringify(data);
- gagajf.ajaxJsonSubmit('/goods/search/excelupload/save', jsonData, fnGoodsDealExcelUploadCallBack);
- }
- var fnGoodsDealExcelUploadCallBack = function(result){
- gagajf.ajaxJsonSubmit('/goods/excel/upload/goods/list', '', fnExcelSearchCallBack);
- }
-
- var fnExcelSearchCallBack = function(result){
- fnCreateGoodsDeal(result.goodsExcelList);
- }
- // 저장클릭시
- $('#btnGoodsDealSave').on('click', function() {
- if(!fnGoodsDealConditionCheck()) return;
-
- mcxDialog.confirm('딜상품을 등록 하시겠습니까?', {
- cancelBtnText: "취소",
- sureBtnText: "확인",
- sureBtnClick: function(){
- var goodsComposeList = gagaAgGrid.getAllRowData(gridGoodsDealOptions);
- $("#goodsDealForm input[name=goodsComposeList]").val(JSON.stringify(goodsComposeList));
- gagajf.ajaxFormSubmit("/goods/deal/save", "#goodsDealForm", fngoodsDealFormClose);
- }
- });
- });
- //저장 조건 확인
- var fnGoodsDealConditionCheck = function(){
- var optCheck = false;
-
- if(gagajf.isNull($("#goodsDealForm input[name=goodsNm]").val())){
- mcxDialog.alertC('상품명을 입력해 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm input[name=goodsNm]").focus();
- }
- });
- return false;
- }
-
- if(gagajf.isNull($("#goodsDealForm input[name=currPrice]").val())){
- mcxDialog.alertC('판매가를 입력해 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm input[name=currPrice]").focus();
- }
- });
- return false;
- }
-
- if(Number($("#goodsDealForm input[name=currPrice]").val()) <= 0){
- mcxDialog.alertC('판매가를 바르게 입력해 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm input[name=currPrice]").focus();
- }
- });
- return false;
- }
-
- if(gagajf.isNull($("#goodsDealForm select[name=styleYear]").val())){
- mcxDialog.alertC('년도을 선택해 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm select[name=styleYear]").focus();
- }
- });
- return false;
- }
-
- if(gagajf.isNull($("#goodsDealForm select[name=seasonCd]").val())){
- mcxDialog.alertC('시즌을 선택해주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm select[name=seasonCd]").focus();
- }
- });
- return false;
- }
-
- if(gagajf.isNull($("#goodsDealForm select[name=sexGb]").val())){
- mcxDialog.alertC('성별을 선택해주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm select[name=sexGb]").focus();
- }
- });
- return false;
- }
-
- if(gagajf.isNull($("#goodsDealForm select[name=makeOriginCd]").val())){
- mcxDialog.alertC('원산지를 입력해 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm select[name=makeOriginCd]").focus();
- }
- });
- return false;
- }
-
- var makeYmd = $("#goodsDealForm input[name=makeYmd]").val();
-
- if(gagajf.isNull(makeYmd)){
- mcxDialog.alertC('제조년월일를 입력해 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm input[name=makeYmd]").focus();
- }
- });
- return;
- }
-
- if(makeYmd.length < 8){
- mcxDialog.alertC('제조년월일를 바르게 주세요.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm input[name=makeYmd]").focus();
- }
- });
- return false;
- }
-
- if(isNaN(Date.parse(makeYmd.substr(0, 4) +'-'+ makeYmd.substr(4, 2) +'-'+ makeYmd.substr(6, 2)))){
- mcxDialog.alertC('날짜형식이 아닙니다.', {
- sureBtnText: "확인",
- sureBtnClick: function() {
- $("#goodsDealForm input[name=makeYmd]").focus();
- }
- });
- return false;
- }
-
- var allData = gagaAgGrid.getAllRowData(gridGoodsDealOptions);
- // Validation
- if (!gagaAgGrid.validation(gridGoodsDealOptions, allData))
- return false;
-
- var comSupplyCompCd = '';
- var comSelfGoodsYn = '';
- //기준여부 Y 존재하는지 확인
- var checkBaseYn = false;
- //대표여부 Y 존재하는지 확인
- var checkRepYn = false;
- optCheck = false;
- $.each(allData, function(index, item) {
- if (index == 0){
- comSelfGoodsYn = item.selfGoodsYn;
- comSupplyCompCd = item.supplyCompCd;
- }
-
- if (item.baseYn == "Y"){
- checkBaseYn = true;
- }
-
- if (item.repYn == "Y"){
- checkRepYn = true;
- }
-
- if(item.goodsStat != "G008_90"){
- optCheck = true;
- mcxDialog.alertC("상품상태를 확인해 주세요.", {
- sureBtnText: "확인",
- sureBtnClick: function() {
- gridGoodsDealOptions.api.setFocusedCell(index, "goodsStat", null);
- }
- });
- return false;
- }
-
- if(Number(item.qty) <= 0){
- optCheck = true;
- mcxDialog.alertC("수량을 입력해 주세요.", {
- sureBtnText: "확인",
- sureBtnClick: function() {
- gridGoodsDealOptions.api.setFocusedCell(index, "qty", null);
- }
- });
- return false;
- }
-
- if (comSelfGoodsYn != item.selfGoodsYn){
- optCheck = true;
- mcxDialog.alertC("구상상품중 자사/입점상품 구분값이 다릅니다.\n확인해 주세요", {
- sureBtnText: "확인",
- sureBtnClick: function() {
- gridGoodsDealOptions.api.setFocusedCell(index, "goodsCd", null);
- }
- });
- return false;
- }else{
- if (comSelfGoodsYn == "N" && (comSupplyCompCd != item.supplyCompCd)){
- optCheck = true;
- mcxDialog.alertC("구상상품중 입점은 같은 업체 상품만 가능합니다.\n확인해 주세요", {
- sureBtnText: "확인",
- sureBtnClick: function() {
- gridGoodsDealOptions.api.setFocusedCell(index, "goodsCd", null);
- }
- });
- return false;
- }
- }
-
- });
-
- if(optCheck) {
- return false;
- }
-
- if (!checkBaseYn){
- mcxDialog.alert('구성상품중 기준여부를 선택해 주세요.');
- return false;
- }
-
- if (!checkRepYn){
- mcxDialog.alert('구성상품중 대표여부를 선택해 주세요.');
- return false;
- }
-
- return true;
- }
-
- //상품삭제
- var fnGoodsDealDeleteRow = function() {
- var selectedData = gagaAgGrid.selectedRowData(gridGoodsDealOptions);
-
- if (selectedData.length == 0) {
- mcxDialog.alert('선택된 행이 없습니다.');
- return;
- }
-
- //화면에서 삭제
- var removedData = gagaAgGrid.removeRowData(gridGoodsDealOptions, false);
- }
-
- /*]]>*/
- </script>
- </html>
|