Przeglądaj źródła

李剑-节假日信息维护功能开发-完成保存新增(有报错,但功能实现完整)。

lijian 4 lat temu
rodzic
commit
94af361dfa

+ 74 - 8
src/main/java/platform/modules/government/web/SupermeController.java

@@ -1027,6 +1027,7 @@ public class SupermeController extends BaseController {
 	 * @return
 	 * @throws Exception
 	 */
+	@OperationLog(value = "读取假日信息列表")
 	@GetMapping(value = "/holidayList")
 	public String holidayList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
 							   ModelMap modelMap) throws Exception {
@@ -1043,6 +1044,7 @@ public class SupermeController extends BaseController {
 	 * @param modelMap
 	 * @return
 	 */
+	@OperationLog(value = "新增假日信息")
 	@GetMapping(value = "/holiday/add")
 	public String addHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,ModelMap modelMap) {
 		return BASE_SUPER_PATH + "holiday/holiday_add";
@@ -1054,6 +1056,7 @@ public class SupermeController extends BaseController {
 	 * @param modelMap
 	 * @return
 	 */
+	@OperationLog(value = "编辑假日信息")
 	@GetMapping(value = "/holiday/edit/{id}")
 	public String editHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
 								   @PathVariable("id") Integer id,ModelMap modelMap) {
@@ -1083,9 +1086,10 @@ public class SupermeController extends BaseController {
 		return ResponseMessage.success("删除成功!");
 	}
 
+	@OperationLog(value = "导入假日信息")
 	@PostMapping(value = "/holiday/import")
 	public ResponseEntity<String> importHoliday(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws IOException {
-
+		String retInfo = "";
 		if (file.isEmpty()) {
 			return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件不能为空");
 		}
@@ -1094,21 +1098,83 @@ public class SupermeController extends BaseController {
 		try {
 			//调用util方法拿到解析的数据集合
 			readExcel = new ReadExcelUtil().readExcel(file);
-
 			// 进一步解析
-
-			String retInfo = HolidayExcelParser.parse(readExcel);
-
-			//int a = 0;
+			retInfo = HolidayExcelParser.parse(readExcel);
 
 		} catch (IOException e) {
-			// TODO Auto-generated catch block
+
 			e.printStackTrace();
 		}
 
+		return ResponseEntity.status(HttpStatus.OK).body(retInfo);
 
-		return ResponseEntity.status(HttpStatus.OK).body("OK");
+	}
+
+
+	@OperationLog(value = "假日信息保存")
+	@PostMapping(value = "/holiday/save")
+	public ResponseMessage saveHoliday(@RequestParam(value = "id", defaultValue = "-1") int id,
+									   @RequestParam(value = "configName", defaultValue = "") String configName,
+									   @RequestParam(value = "configKey", defaultValue = "") String configKey,
+									   @RequestParam(value = "configValue", defaultValue = "") String configValue) throws Exception {
+
+		if(IsTooFrequently()) {
+			return ResponseMessage.success("操作过于频繁,请稍后再试!");
+		}
+
+		SysConfig ent2Save;
+		if (-1 < id)
+		{
+			ent2Save = sysConfigService.findById(id);
+		}else{
+			ent2Save = new SysConfig();
+		}
+
+		ent2Save.setConfigName(configName);
+		ent2Save.setConfigKey(configKey);
+		ent2Save.setConfigValue(configValue.replace("&quot;","\""));
+		ent2Save.setDel_flag(false);
+
+
+		if (-1 < id)
+		{
+			sysConfigService.update(ent2Save);
+		}else{
+			sysConfigService.save(ent2Save);
+		}
+
+		return ResponseMessage.success("保存成功!");
 
 	}
 
+	///super/isExistHoliday
+	/**
+	 * 同一年份假日信息是否存在
+	 *
+	 * @param configKey
+	 * @return
+	 */
+	@OperationLog(value = "同一年份假日信息是否存在")
+	@ResponseBody
+	@GetMapping(value = "/isExistHoliday")
+	public Boolean isExistHoliday(String id, String configKey) throws Exception {
+		boolean flag = true;
+		log.debug("检验同一年份假日信息是否存在参数! id= {}, configKey= {}", id, configKey);
+		SysConfig entExist = sysConfigService.getByKey(configKey);
+
+		if (null != entExist) {
+			if (StringUtils.isBlank(id)) {
+				flag = false;
+
+			} else {
+				if (entExist.getId() != (Integer.parseInt(id))) {
+					flag = false;
+				}
+			}
+
+		}
+		log.info("检验假日信息年份是否存在结果! flag = {}", flag);
+		return flag;
+	}
 }
+

+ 1 - 1
src/main/java/platform/modules/sys/service/SysConfigService.java

@@ -60,7 +60,7 @@ public class SysConfigService extends BaseService<SysConfig> {
         return this.findOne(sysConfig);
     }
 
-    private SysConfig getByKey(String key) {
+    public SysConfig getByKey(String key) {
         SysConfig sysConfig = new SysConfig();
         sysConfig.setConfigKey(key);
         return this.findOne(sysConfig);

+ 0 - 1
src/main/resources/static/js/super/dictionary/dictionary_type_add.js

@@ -1,5 +1,4 @@
 $(function () {
-
     $("#form-dictionarytype-add").validate({
         rules: {
             name: {

+ 12 - 13
src/main/resources/static/js/super/holiday/holiday_add.js

@@ -1,37 +1,36 @@
 $(function () {
-	$("#form-holidayFile-add").validate({
+	$("#form-holiday-add").validate({
         rules: {
-            name: {
+            configKey: {
                 required: true,
                 minlength: 1,
-                maxlength: 64,
+                maxlength: 60,
                 remote: {
-                    url: pagePath + "/super/isExistholidayName",
+                    url: pagePath + "/super/isExistHoliday",
                     type: "get",
                     data: {
-                        name: function () {
-                            return $("#configName").val();
+                        configKey: function () {
+                            return $("#configKey").val();
                         },
                         id: ''
                     }
                 }
             },
-            value: {
-                required: true,
+            remark: {
                 minlength: 1,
-                maxlength: 64
+                maxlength: 200
             }
         },
         messages: {
-            name: {
-                remote: "假日信息已存在!"
+            configKey: {
+                remote: "该年份假日信息已存在!"
             }
         },
         onkeyup: false,
         focusCleanup: true,
+        focusInvalid:false,
         success: "valid",
         submitHandler: function (form) {
-
             $(form).ajaxSubmit({
                 type: 'post',
                 url: pagePath + "/super/holiday/save",
@@ -39,7 +38,7 @@ $(function () {
                 success: function (data) {
                     if (data.success) {
                         succeedMessage(data.message);
-                        setShortTimeClose();
+                        setTimeClose();
                     } else {
                         // $(form).find(":submit").attr("disabled", false);
                         errorMessage(data.message);

+ 6 - 4
src/main/resources/static/js/super/holiday/holiday_list.js

@@ -12,14 +12,16 @@ $(function () {
  */
 /*模板-增加*/
 function holiday_add(title,url,w,h){
-    var index = layer_show(title,pagePath+url,w,h);
-    layer.full(index);
+    layer_show(title,pagePath+url,w,h);
+    //var index = layer_show(title,pagePath+url,w,h);
+    //layer.full(index);
 }
 
 /*模板--编辑*/
 function holiday_edit(title,url,w,h){
-	var index = layer_show(title,pagePath+url,w,h);
-    layer.full(index);
+    layer_show(title,pagePath+url,w,h);
+	//var index = layer_show(title,pagePath+url,w,h);
+    //layer.full(index);
 }
 
 /*模板--删除*/

+ 21 - 5
src/main/resources/templates/admin/super/holiday/holiday_add.html

@@ -33,21 +33,30 @@
 		</div>
 
 		<div class="row cl">
-			<div class="formControls col-xs-8 col-sm-9">
+			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
 				<div class="uploader-thum-container">
-					<div id="fileListPre" class="uploader-list">
+					<div id="fileListPre" style="display:none;">
 					</div>
 					<div id="filePicker">导入假日信息</div>
 				</div>
 			</div>
 		</div>
 
+
+		<div class="row cl">
+			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
+				<button class="btn btn-primary radius" type="submit" ><i class="Hui-iconfont">&#xe632;</i>
+					保存
+				</button>
+
+			</div>
+		</div>
+
     </form>
 </article>
 <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
 <script type="text/javascript" th:src="@{/js/super/holiday/holiday_add.js}"></script>
 <script th:inline="javascript">
-
 	/**
 	 * 初始化上传控件
 	 */
@@ -61,11 +70,18 @@
 		fileSizeLimit: 100 * 1024 * 1024,
 		fileSingleSizeLimit: 100 * 1024 * 1024,
 		//fileNumLimit: 1,
-		serverUrl:'/myboot/super/holiday/import'
+		serverUrl:'/myboot/super/holiday/import' // TODO: 这个地方要改的,不然发布到生产环境无法上传
 	};
 
 	var webUploadDoc = new $WebUploadDoc(options);
-	webUploadDoc.init();
+	var objUploader = webUploadDoc.init();
+
+
+	// 文件上传成功,给item添加成功class, 用样式标记上传成功。
+	objUploader.on('uploadSuccess', function (file, response) {
+		succeedMessage("导入成功");
+		$("#configValue").val(response._raw);
+	});
 
     /**
      * 取消