Browse Source

공급업체 SELECTBOX -> 팝업으로 변경

gagamel 4 năm trước cách đây
mục cha
commit
1bfaad2647

+ 14 - 0
src/main/java/com/style24/admin/biz/web/TsaSystemController.java

@@ -2,6 +2,7 @@ package com.style24.admin.biz.web;
 
 import java.util.Collection;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.env.Environment;
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.style24.admin.biz.service.TsaRendererService;
 import com.style24.admin.biz.service.TsaSystemService;
 import com.style24.admin.support.controller.TsaBaseController;
@@ -61,6 +63,9 @@ public class TsaSystemController extends TsaBaseController {
 	@Autowired
 	private GagaPasswordEncoder passwordEncoder;
 
+	@Autowired
+	private ObjectMapper mapper;
+
 	@Value("${upload.default.target.path}")
 	private String uploadTargetPath;
 
@@ -95,6 +100,15 @@ public class TsaSystemController extends TsaBaseController {
 	@PostMapping("/user/list")
 	@ResponseBody
 	public Collection<User> getUserList(@RequestBody User user) {
+		if (!StringUtils.isBlank(user.getSupplyCompList())) {
+			try {
+				String[] arrSupplyComp = mapper.readValue(user.getSupplyCompList(), String[].class);
+				user.setMultiSupplyComp(arrSupplyComp);
+			} catch (Exception e) {
+				throw new IllegalStateException("업체코드 검색중 오류로 인해 조회되지 않았습니다.");
+			}
+		}
+
 		return systemService.getUserList(user);
 	}
 

+ 4 - 0
src/main/java/com/style24/persistence/domain/User.java

@@ -1,5 +1,6 @@
 package com.style24.persistence.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.style24.persistence.TscBaseDomain;
@@ -54,6 +55,9 @@ public class User extends TscBaseDomain {
 	private String searchGb;
 	private String searchTxt;
 	private String callBackFun;
+	private String supplyCompList;
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] multiSupplyComp;
 
 	// 권한변경여부
 	private String roleChangeYn;

+ 6 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsaSystem.xml

@@ -71,6 +71,12 @@
 		<if test="supplyCompCd != null and supplyCompCd != ''">
 		AND    A.ROLE_REF_VAL = #{supplyCompCd}
 		</if>
+		<if test="multiSupplyComp != null and multiSupplyComp != ''">
+		AND    A.ROLE_REF_VAL IN
+		    <foreach collection="multiSupplyComp" item="item" index="index"  open="(" close=")" separator=",">
+		    #{item}
+		    </foreach>
+		</if>
 		<if test="roleCd != null and roleCd != ''">
 		AND    A.ROLE_CD  = #{roleCd}
 		</if>

+ 41 - 5
src/main/webapp/WEB-INF/views/system/UserForm.html

@@ -42,10 +42,14 @@
 					<tr>
 						<th>업체</th>
 						<td>
-							<select name="supplyCompCd">
-								<option th:if="${sessionInfo.supplyCompCd == null}" value="">[전체]</option>
-								<option th:if="${supplyCompList}" th:each="oneData, status : ${supplyCompList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
-							</select>
+<!-- 							<select name="supplyCompCd"> -->
+<!-- 								<option th:if="${sessionInfo.supplyCompCd == null}" value="">[전체]</option> -->
+<!-- 								<option th:if="${supplyCompList}" th:each="oneData, status : ${supplyCompList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option> -->
+<!-- 							</select> -->
+							<input type="text" class="w100" name="supplyCompSearchTxt" id="supplyCompSearchTxt" maxlength="20"/>
+							<button type="button" class="btn icn" onclick="cfnOpenCompanyListPopup('fnSetSupplyCompInfo', 'M');"><i class="fa fa-search"></i></button>
+							<span id="supplyCompTxt"></span>
+							<input type="hidden" name="supplyCompList"/>
 						</td>
 						<th>권한</th>
 						<td>
@@ -77,7 +81,7 @@
 				<ul class="panelBar">
 					<li class="center">
 						<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
-						<button type="button" class="btn btn-gray btn-lg" onclick="$('#searchForm')[0].reset();">초기화</button>
+						<button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
 					</li>
 				</ul>
 			</form>
@@ -155,6 +159,38 @@
 	
 	gridOptions.rowSelection = 'multiple';
 	
+	// 업체 조회 팝업에서 호출
+	var fnSetSupplyCompInfo = function(result) {
+		var arrSupplyComp = [];
+		var supplyCompTxt = "";
+		var sIndex = 0;
+		$('#supplyCompTxt').html('');
+		$('#searchForm input[name=supplyCompSearchTxt]').val('');
+		
+		result.forEach(function(supplyComp) {
+			sIndex++; 
+			arrSupplyComp.push(supplyComp.supplyCompCd);
+		});
+
+		// 조회 값이 하나일 경우 화면에 코드 노출. 그 외는 갯수 처리 
+		if (sIndex == 1) {
+			$('#searchForm input[name=supplyCompSearchTxt]').val(arrSupplyComp[0]);
+		} else {
+			supplyCompTxt = sIndex + " 개";
+			$('#supplyCompTxt').html(supplyCompTxt);
+		}
+		
+		var jsonData = JSON.stringify(arrSupplyComp);
+		$("#searchForm input[name=supplyCompList]").val(jsonData);
+	}
+	
+	// 초기화 클릭시
+	$('#btnInit').on('click', function() {
+		$('#searchForm')[0].reset();
+		$('#searchForm input[name=supplyCompList]').val('');
+		$('#supplyCompTxt').html('');
+	});
+	
 	// 조회
 	$('#btnSearch').on('click', function() {
 		// Fetch data