Просмотр исходного кода

李剑-节假日信息维护功能开发-完成列表显示、新增表单、编辑表单、导入表格解析成假日配置数据。

lijian 4 лет назад
Родитель
Сommit
2ebeb43145

+ 16 - 16
pom.xml

@@ -21,7 +21,7 @@
         <thymeleaf.version>3.0.0.RELEASE</thymeleaf.version>
         <thymeleaf-layout-dialect.version>2.0.0</thymeleaf-layout-dialect.version>
         <shiro.version>1.3.2</shiro.version>
-<!--        <poi.version>3.9</poi.version>-->
+        <poi.version>3.17</poi.version>
         <thymeleaf-shiro.version>2.0.0</thymeleaf-shiro.version>
         <hutool.version>2.16.0</hutool.version>
         <commons-io.version>2.4</commons-io.version>
@@ -250,21 +250,21 @@
             <version>1.2.44</version>
         </dependency>
         <!-- poi office -->
-<!--        <dependency>-->
-<!--            <groupId>org.apache.poi</groupId>-->
-<!--            <artifactId>poi</artifactId>-->
-<!--            <version>${poi.version}</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.apache.poi</groupId>-->
-<!--            <artifactId>poi-ooxml</artifactId>-->
-<!--            <version>${poi.version}</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.apache.poi</groupId>-->
-<!--            <artifactId>poi-ooxml-schemas</artifactId>-->
-<!--            <version>${poi.version}</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.projectlombok</groupId>

+ 7 - 2
src/main/java/platform/RootApplication.java

@@ -38,8 +38,10 @@ public class RootApplication
     /**
      * 文件上传临时路径
      */
-    /*@Bean
+    /*
+    @Bean
     MultipartConfigElement multipartConfigElement() {
+
         MultipartConfigFactory factory = new MultipartConfigFactory();
         String location = System.getProperty("user.dir") + "/data/tmp";
         File tmpFile = new File(location);
@@ -48,5 +50,8 @@ public class RootApplication
         }
         factory.setLocation(location);
         return factory.createMultipartConfig();
-    }*/
+
+    }
+
+     */
 }

+ 1 - 0
src/main/java/platform/common/base/service/BaseService.java

@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import platform.common.base.mapper.BaseMapper;
 import platform.common.base.model.BaseEntity;
+import platform.common.base.model.Template;
 import platform.common.util.DateUtil;
 import platform.common.util.ShiroUtils;
 import tk.mybatis.mapper.entity.Example;

+ 3 - 0
src/main/java/platform/common/base/service/TemplateService.java

@@ -57,6 +57,9 @@ public class TemplateService extends BaseService<Template> {
             criteria.andLike("name", "%" +  WebUtil.covertData(keyword) + "%");
         }
         criteria2.andEqualTo("del_flag", 0);
+
+
+
         //倒序
         example.and(criteria2);
         example.setOrderByClause("create_time desc");

+ 4 - 0
src/main/java/platform/common/util/DateUtil.java

@@ -607,4 +607,8 @@ public class DateUtil {
 
         return days;
     }
+
+    protected static int absoluteDay(Calendar cal, boolean use1904windowing) {
+        return 0;
+    }
 }

+ 107 - 0
src/main/java/platform/common/util/ExcelUtil.java

@@ -0,0 +1,107 @@
+package platform.common.util;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.logging.Logger;
+
+
+public class ExcelUtil {
+    private static final Logger logger = Logger.getLogger(String.valueOf(ExcelUtil.class));
+    public static final String OFFICE_EXCEL_2003_POSTFIX = "xls";
+    public static final String OFFICE_EXCEL_2010_POSTFIX = "xlsx";
+    public static final String EMPTY = "";
+    public static final String POINT = ".";
+    public static SimpleDateFormat sdf =   new SimpleDateFormat("yyyy/MM/dd");
+
+    /**
+     * 获得path的后缀名
+     * @param path
+     * @return
+     */
+    public static String getPostfix(String path){
+        if(path==null || EMPTY.equals(path.trim())){
+            return EMPTY;
+        }
+        if(path.contains(POINT)){
+            return path.substring(path.lastIndexOf(POINT)+1,path.length());
+        }
+        return EMPTY;
+    }
+    /**
+     * 单元格格式
+     * @param hssfCell
+     * @return
+     */
+    @SuppressWarnings({ "static-access", "deprecation" })
+    public static String getHValue(HSSFCell hssfCell){
+        if (hssfCell.getCellType() == hssfCell.CELL_TYPE_BOOLEAN) {
+            return String.valueOf(hssfCell.getBooleanCellValue());
+        } else if (hssfCell.getCellType() == hssfCell.CELL_TYPE_NUMERIC) {
+            String cellValue = "";
+            if(HSSFDateUtil.isCellDateFormatted(hssfCell)){
+                Date date = HSSFDateUtil.getJavaDate(hssfCell.getNumericCellValue());
+                cellValue = sdf.format(date);
+            }else{
+                DecimalFormat df = new DecimalFormat("#.##");
+                cellValue = df.format(hssfCell.getNumericCellValue());
+                String strArr = cellValue.substring(cellValue.lastIndexOf(POINT)+1,cellValue.length());
+                if(strArr.equals("00")){
+                    cellValue = cellValue.substring(0, cellValue.lastIndexOf(POINT));
+                }
+            }
+            return cellValue;
+        } else {
+            return String.valueOf(hssfCell.getStringCellValue());
+        }
+    }
+    /**
+     * 单元格格式
+     * @param xssfCell
+     * @return
+     */
+    public static String getXValue(XSSFCell xssfCell){
+        if (xssfCell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
+            return String.valueOf(xssfCell.getBooleanCellValue());
+        } else if (xssfCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+            String cellValue = "";
+            if(XSSFDateUtil.isCellDateFormatted(xssfCell)){
+                Date date = XSSFDateUtil.getJavaDate(xssfCell.getNumericCellValue());
+                cellValue = sdf.format(date);
+            }else{
+                DecimalFormat df = new DecimalFormat("#.##");
+                cellValue = df.format(xssfCell.getNumericCellValue());
+                String strArr = cellValue.substring(cellValue.lastIndexOf(POINT)+1,cellValue.length());
+                if(strArr.equals("00")){
+                    cellValue = cellValue.substring(0, cellValue.lastIndexOf(POINT));
+                }
+            }
+            return cellValue;
+        } else {
+            return String.valueOf(xssfCell.getStringCellValue());
+        }
+    }
+    /**
+     * 自定义xssf日期工具类
+     *
+     */
+    static class XSSFDateUtil extends DateUtil {
+        protected static int absoluteDay(Calendar cal, boolean use1904windowing) {
+            return DateUtil.absoluteDay(cal, use1904windowing);
+        }
+
+        public static boolean isCellDateFormatted(XSSFCell xssfCell) {
+            return false;
+        }
+
+        public static Date getJavaDate(double numericCellValue) {
+            return null;
+        }
+    }
+}

+ 154 - 0
src/main/java/platform/common/util/ReadExcelUtil.java

@@ -0,0 +1,154 @@
+package platform.common.util;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ReadExcelUtil {
+    public int totalRows; //sheet中总行数
+    public static int totalCells; //每一行总单元格数
+    /**
+     * read the Excel .xlsx,.xls
+     * @param file jsp中的上传文件
+     * @return
+     * @throws IOException
+     */
+    public List<ArrayList<String>> readExcel(MultipartFile file) throws IOException {
+        if(file==null||ExcelUtil.EMPTY.equals(file.getOriginalFilename().trim())){
+            return null;
+        }else{
+            String postfix = ExcelUtil.getPostfix(file.getOriginalFilename());
+            if(!ExcelUtil.EMPTY.equals(postfix)){
+                if(ExcelUtil.OFFICE_EXCEL_2003_POSTFIX.equals(postfix)){
+                    return readXls(file);
+                }else if(ExcelUtil.OFFICE_EXCEL_2010_POSTFIX.equals(postfix)){
+                    return readXlsx(file);
+                }else{
+                    return null;
+                }
+            }
+        }
+        return null;
+    }
+    /**
+     * read the Excel 2010 .xlsx
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    @SuppressWarnings("deprecation")
+    public List<ArrayList<String>> readXlsx(MultipartFile file){
+        List<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
+        // IO流读取文件
+        InputStream input = null;
+        XSSFWorkbook wb = null;
+        ArrayList<String> rowList = null;
+        try {
+            input = file.getInputStream();
+            // 创建文档
+            wb = new XSSFWorkbook(input);
+            //读取sheet(页)
+            for(int numSheet=0;numSheet<wb.getNumberOfSheets();numSheet++){
+                XSSFSheet xssfSheet = wb.getSheetAt(numSheet);
+                if(xssfSheet == null){
+                    continue;
+                }
+                totalRows = xssfSheet.getLastRowNum();
+                //读取Row,从第4行开始
+                for(int rowNum = 1;rowNum <= totalRows;rowNum++){
+                    XSSFRow xssfRow = xssfSheet.getRow(rowNum);
+                    if(xssfRow!=null){
+                        rowList = new ArrayList<String>();
+                        totalCells = xssfRow.getLastCellNum();
+                        //读取列,从第一列开始
+                        for(int c=0;c<=totalCells+1;c++){
+                            XSSFCell cell = xssfRow.getCell(c);
+                            if(cell==null){
+                                rowList.add(ExcelUtil.EMPTY);
+                                continue;
+                            }
+                            rowList.add(ExcelUtil.getXValue(cell).trim());
+                        }
+                        list.add(rowList);
+                    }
+                }
+            }
+            return list;
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally{
+            try {
+                input.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+
+    }
+    /**
+     * read the Excel 2003-2007 .xls
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    public List<ArrayList<String>> readXls(MultipartFile file){
+        List<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
+        // IO流读取文件
+        InputStream input = null;
+        HSSFWorkbook wb = null;
+        ArrayList<String> rowList = null;
+        try {
+            input = file.getInputStream();
+            // 创建文档
+            wb = new HSSFWorkbook(input);
+            //读取sheet(页)
+            for(int numSheet=0;numSheet<wb.getNumberOfSheets();numSheet++){
+                HSSFSheet hssfSheet = wb.getSheetAt(numSheet);
+                if(hssfSheet == null){
+                    continue;
+                }
+                totalRows = hssfSheet.getLastRowNum();
+                //读取Row,从第二行开始
+                for(int rowNum = 1;rowNum <= totalRows;rowNum++){
+                    HSSFRow hssfRow = hssfSheet.getRow(rowNum);
+                    if(hssfRow!=null){
+                        rowList = new ArrayList<String>();
+                        totalCells = hssfRow.getLastCellNum();
+                        //读取列,从第一列开始
+                        for(short c=0;c<=totalCells+1;c++){
+                            HSSFCell cell = hssfRow.getCell(c);
+                            if(cell==null){
+                                rowList.add(ExcelUtil.EMPTY);
+                                continue;
+                            }
+                            rowList.add(ExcelUtil.getHValue(cell).trim());
+                        }
+                        list.add(rowList);
+                    }
+                }
+            }
+            return list;
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally{
+            try {
+                input.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+}

+ 58 - 0
src/main/java/platform/common/util/holiday/HolidayExcelParser.java

@@ -0,0 +1,58 @@
+package platform.common.util.holiday;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HolidayExcelParser {
+    private static final Logger logger = LoggerFactory.getLogger(HolidayExcelParser.class);
+
+    public static String parse(List<ArrayList<String>> readExcel) {
+        String ret = "{";
+        // 逐行变换
+        // {"0101":2,"0102":2,"0103":2,
+        for (int i = 0; i < readExcel.size(); i++) {
+
+            String str1Row = parse1Row(readExcel.get(i));
+
+            if ("".equals(str1Row))
+            {
+                break;
+            }
+
+            ret += str1Row;
+
+            ret += ",";
+        }
+
+        ret = ret.substring(0,ret.length()-1);
+
+        ret += "}";
+        return ret;
+    }
+
+    private static String parse1Row(ArrayList<String> strings) {
+        String ret = "";
+        if (null == strings.get(1) || "".equals(strings.get(1)))
+        {
+            return ret;
+        }
+
+        ret += "\"" + parse1RowDayInfo(strings.get(1)) + "\"";
+        ret += ":" + parse1RowHolidayType(strings.get(2));
+
+
+        return ret;
+    }
+
+    private static String parse1RowHolidayType(String s) {
+        return s;
+    }
+
+    private static String parse1RowDayInfo(String s) {
+
+        return s.substring(5,7) + s.substring(8,10);
+    }
+}

+ 107 - 0
src/main/java/platform/modules/government/web/SupermeController.java

@@ -1,11 +1,14 @@
 package platform.modules.government.web;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.*;
@@ -13,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 
+import org.springframework.web.multipart.MultipartFile;
 import platform.common.Constant;
 import platform.common.annotation.OperationLog;
 import platform.common.base.controller.BaseController;
@@ -22,6 +26,8 @@ import platform.common.base.model.Template;
 import platform.common.base.service.DictionaryItemService;
 import platform.common.base.service.DictionaryTypeService;
 import platform.common.base.service.TemplateService;
+import platform.common.util.ReadExcelUtil;
+import platform.common.util.holiday.HolidayExcelParser;
 import platform.modules.build.entity.BuildInfo;
 import platform.modules.build.service.BuildInfoService;
 import platform.modules.build.service.CompanyService;
@@ -34,9 +40,13 @@ import platform.modules.government.service.AttachmentService;
 import platform.modules.government.service.BuildTypeService;
 import platform.modules.government.service.StreetService;
 import platform.modules.government.service.UserService;
+import platform.modules.sys.entity.SysConfig;
+import platform.modules.sys.service.SysConfigService;
 import platform.modules.sys.web.ResponseMessage;
 import tk.mybatis.mapper.entity.Example;
 
+import javax.servlet.http.HttpServletRequest;
+
 @Controller
 @RequestMapping(value = "/super")
 public class SupermeController extends BaseController {
@@ -67,6 +77,9 @@ public class SupermeController extends BaseController {
 
 	@Autowired
 	private AttachmentService attachmentService;
+
+	@Autowired
+	private SysConfigService sysConfigService;
 	
 	@GetMapping(value = "")
 	public String list() {
@@ -1004,4 +1017,98 @@ public class SupermeController extends BaseController {
 		return BASE_SUPER_PATH + "industry/industry_file_list";
 
 	}
+
+
+	/**
+	 * 假日信息管理列表展示
+	 *
+	 * @param pageNum
+	 * @param modelMap
+	 * @return
+	 * @throws Exception
+	 */
+	@GetMapping(value = "/holidayList")
+	public String holidayList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+							   ModelMap modelMap) throws Exception {
+
+		PageInfo<SysConfig> pageInfo = sysConfigService.findPage(pageNum, PAGESIZE,"year_");
+		modelMap.put("pageInfo", pageInfo);
+		modelMap.put("fileUrl", setFileUrl());
+		return BASE_SUPER_PATH + "holiday/holiday_list";
+	}
+
+	/**
+	 * 添加假日信息
+	 * @param pageNum
+	 * @param modelMap
+	 * @return
+	 */
+	@GetMapping(value = "/holiday/add")
+	public String addHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,ModelMap modelMap) {
+		return BASE_SUPER_PATH + "holiday/holiday_add";
+	}
+
+	/**
+	 * 修改相应假日信息
+	 * @param pageNum
+	 * @param modelMap
+	 * @return
+	 */
+	@GetMapping(value = "/holiday/edit/{id}")
+	public String editHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+								   @PathVariable("id") Integer id,ModelMap modelMap) {
+		SysConfig holidayInfo = sysConfigService.findById(id);
+
+		modelMap.put("id", holidayInfo.getId());
+		modelMap.put("configName", holidayInfo.getConfigName());
+		modelMap.put("configKey", holidayInfo.getConfigKey());
+		modelMap.put("configValue", holidayInfo.getConfigValue());
+
+		modelMap.put("fileUrl", setFileUrl());
+		return BASE_SUPER_PATH + "holiday/holiday_add";
+	}
+
+
+	@OperationLog(value = "节假日信息删除")
+	@ResponseBody
+	@DeleteMapping(value = "/holiday/delete/{id}")
+	public ResponseMessage deleteHoliday(@PathVariable("id") int id,ModelMap modelMap) {
+		SysConfig ent2Del = sysConfigService.findById(id);
+		if (null == ent2Del) {
+			return ResponseMessage.error("未找到相应的假日信息");
+		}
+		ent2Del.setDel_flag(true);
+		sysConfigService.update(ent2Del);
+
+		return ResponseMessage.success("删除成功!");
+	}
+
+	@PostMapping(value = "/holiday/import")
+	public ResponseEntity<String> importHoliday(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws IOException {
+
+		if (file.isEmpty()) {
+			return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件不能为空");
+		}
+
+		List<ArrayList<String>> readExcel = new ArrayList<>();
+		try {
+			//调用util方法拿到解析的数据集合
+			readExcel = new ReadExcelUtil().readExcel(file);
+
+			// 进一步解析
+
+			String retInfo = HolidayExcelParser.parse(readExcel);
+
+			//int a = 0;
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+
+		return ResponseEntity.status(HttpStatus.OK).body("OK");
+
+	}
+
 }

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

@@ -1,12 +1,18 @@
 package platform.modules.sys.service;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import platform.common.base.model.Template;
 import platform.common.base.service.BaseService;
 import platform.common.exception.BaseException;
 import platform.common.util.CommonUtils;
+import platform.common.util.WebUtil;
 import platform.common.util.holiday.WorkDayHandler;
 import platform.modules.sys.entity.SysConfig;
+import tk.mybatis.mapper.entity.Example;
 
 import java.util.List;
 
@@ -75,4 +81,27 @@ public class SysConfigService extends BaseService<SysConfig> {
         }
         return configEntity.getConfigValue();
     }
+
+
+
+    public PageInfo<SysConfig> findPage(Integer pageNum, Integer pageSize,String keyword)
+    {
+        Example example = new Example(SysConfig.class);
+        Example.Criteria criteria = example.createCriteria();
+        Example.Criteria criteria2 = example.createCriteria();
+
+        if (StringUtils.isNotBlank(keyword)) {
+            criteria.andLike("configKey", keyword + "%");
+        }
+
+        criteria2.andEqualTo("del_flag", 0);
+        //倒序
+        example.and(criteria2);
+        example.setOrderByClause("config_key desc");
+        PageHelper.startPage(pageNum, pageSize);
+        List<SysConfig> retList = this.selectByExample(example);
+
+
+        return new PageInfo<SysConfig>(retList);
+    }
 }

+ 1 - 0
src/main/java/platform/modules/sys/web/FileUploadController.java

@@ -21,6 +21,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
 import platform.common.base.controller.BaseController;
 import platform.common.util.FileValidateUtil;
 import platform.common.util.HttpClientUtil;
+import platform.common.util.ReadExcelUtil;
 import platform.modules.government.entity.Attachment;
 import platform.modules.government.entity.FileDown;
 import platform.modules.government.service.AttachmentService;

+ 7 - 70
src/main/resources/static/js/super/holiday/holiday_add.js

@@ -1,24 +1,18 @@
 $(function () {
-	$("#form-templateFile-add").validate({
+	$("#form-holidayFile-add").validate({
         rules: {
             name: {
                 required: true,
                 minlength: 1,
                 maxlength: 64,
                 remote: {
-                    url: pagePath + "/super/isExistTemplateName",
+                    url: pagePath + "/super/isExistholidayName",
                     type: "get",
                     data: {
                         name: function () {
-                            return $("#name").val();
+                            return $("#configName").val();
                         },
-                        id: '',
-                        typeId :function(){
-                            return $("#typeId").val();
-                        },
-                        itemId: function () {
-                            return $("#itemId").val();
-                        }
+                        id: ''
                     }
                 }
             },
@@ -30,21 +24,17 @@ $(function () {
         },
         messages: {
             name: {
-                remote: "该模板已存在!"
+                remote: "假日信息已存在!"
             }
         },
         onkeyup: false,
         focusCleanup: true,
         success: "valid",
         submitHandler: function (form) {
-            // $(form).find(":submit").attr("disabled", true);
-        	/*if($("#fileListPre").find("input[name='fileDown.file_id']").length==0){
-        		errorMessage('请上传模板文件!');
-        		return false;
-        	}*/
+
             $(form).ajaxSubmit({
                 type: 'post',
-                url: pagePath + "/super/template/save",
+                url: pagePath + "/super/holiday/save",
                 dataType: "json",
                 success: function (data) {
                     if (data.success) {
@@ -65,57 +55,4 @@ $(function () {
 	
 });
 
-//添加模板文件
-function template_addFile(title,url,w,h){
-	var typeId = $("#typeList").val()==null?0:$("#typeList").val();
-	var itemId = $("#itemList").val()==null?0:$("#itemList").val();
-	
-	url += "/"+ typeId+"/"+ itemId;
-	layer_show(title,pagePath+url,w,h);
-}
-
-//编辑模板文件
-function template_editFile(title,url,w,h){
-	layer_show(title,pagePath+url,w,h);
-}
-
-/*模板--删除*/
-function template_del( url){
-	
-    layer.confirm('确认要删除吗?',function(index){
-        //此处请求后台程序,下方是成功后的前台处理……
-        $.ajax({
-            type:"DELETE",
-            dataType:"json",
-            url: pagePath+url,
-            data:{
-                "timestamp":new Date().getTime()
-            },
-            success: function (result) {
-                if (result.success) {
-                    smileMessage(result.message)
-                    setTime();
-
-                } else {
-                    errorMessage(result.message);
-                }
-            },
-         	error: function () {
-         		errorMessage('系统错误!');
-         	}
-        });
-    });
-}
 
-//重新加载模板列表
-//changeType : 0 改变type,1改变item
-function reloadTemplateList(changeType){
-	var typeId = $("#typeList").val()==null?0:$("#typeList").val();
-	var itemId = $("#itemList").val()==null?0:$("#itemList").val();
-	if(0==changeType){
-		//改变类型的时候清空item子类型
-		itemId = 0;
-	}
-	var url = pagePath + "/super/template/add/"+ typeId+"/"+ itemId;
-	location.replace(url);
-}

+ 0 - 83
src/main/resources/static/js/super/holiday/holiday_edit.js

@@ -1,83 +0,0 @@
-$(function () {
-	$("#form-templateFile-edit").validate({
-        rules: {
-            name: {
-                required: true,
-                minlength: 1,
-                maxlength: 64,
-                remote: {
-                    url: pagePath + "/super/isExistTemplateName",
-                    type: "get",
-                    data: {
-                        name: function () {
-                            return $("#name").val();
-                        },
-                        id: function () {
-                            return $("#id").val();
-                        },
-                        typeId :function(){
-                            return $("#typeId").val();
-                        },
-                        itemId: function () {
-                            return $("#itemId").val();
-                        },
-                    }
-                }
-            },
-            value: {
-                required: true,
-                minlength: 1,
-                maxlength: 64
-            }
-        },
-        messages: {
-            name: {
-                remote: "该模板已存在!"
-            }
-        },
-        onkeyup: false,
-        focusCleanup: true,
-        success: "valid",
-        submitHandler: function (form) {
-            // $(form).find(":submit").attr("disabled", true);
-        	/*if($("#fileListPre").find("input[name='fileDown.file_id']").length==0 && $("input[name='file_url']").length==0){
-        		errorMessage('请上传模板文件!');
-        		return false;
-        	}*/
-            $(form).ajaxSubmit({
-                type: 'post',
-                url: pagePath + "/super/template/save",
-                dataType: "json",
-                success: function (data) {
-                    if (data.success) {
-                        succeedMessage(data.message);
-                        setShortTimeClose();
-                    } else {
-                        // $(form).find(":submit").attr("disabled", false);
-                        errorMessage(data.message);
-                    }
-                },
-                error: function () {
-                    errorMessage('系统错误!');
-                }
-            });
-            return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
-        }
-    });
-	
-});
-
-function template_addFile(title,url,w,h){
-	var typeId = $("#typeList").val()==null?0:$("#typeList").val();
-	var itemId = $("#itemList").val()==null?0:$("#itemList").val();
-	url += "/"+ typeId+"/"+ itemId;
-	layer_show(title,pagePath+url,w,h);
-}
-
-//重新加载模板列表
-function reloadTemplateList(){
-	var typeId = $("#typeList").val()==null?0:$("#typeList").val();
-	var itemId = $("#itemList").val()==null?0:$("#itemList").val();
-	var url = pagePath + "/super/template/add/"+ typeId+"/"+ itemId;
-	location.replace(url);
-}

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

@@ -11,19 +11,19 @@ $(function () {
  h		弹出层高度(缺省调默认值)
  */
 /*模板-增加*/
-function template_add(title,url,w,h){
+function holiday_add(title,url,w,h){
     var index = layer_show(title,pagePath+url,w,h);
     layer.full(index);
 }
 
 /*模板--编辑*/
-function template_edit(title,url,w,h){
+function holiday_edit(title,url,w,h){
 	var index = layer_show(title,pagePath+url,w,h);
     layer.full(index);
 }
 
 /*模板--删除*/
-function template_del( url){
+function holiday_del( url){
 	
     layer.confirm('确认要删除吗?',function(index){
         //此处请求后台程序,下方是成功后的前台处理……

+ 2 - 1
src/main/resources/templates/admin/government/content_add.html

@@ -155,6 +155,7 @@
             }
         });
     });
+    /*
     // 初始化图片上传
     var options = {
         auto: false,
@@ -172,7 +173,7 @@
         //fileNumLimit: 3
     };
     var webUploadPicture = new $WebUploadPicture(options);
-
+    */
     /**
      * 取消
      */

+ 51 - 54
src/main/resources/templates/admin/super/holiday/holiday_add.html

@@ -10,66 +10,63 @@
 
 <article class="page-container">
     <form class="form form-horizontal" id="form-holiday-add">
-    	<input type="hidden" id="typeId" th:value="${typeId}" th:name="tid"/>
-        
-        <div class="row cl">
-        	<div class="pd-15 col-xs-8 col-sm-12">
-	            <span class="l">
-	                <a href="javascript:;" th:onclick="'javascript:holiday_addFile(\'添加模板文件\',\'/super/holiday/addFile\',\'800\',\'500\');'" class="btn btn-primary radius">添加模板文件</a>
-	            </span>
-	        </div>
-            <div class="col-xs-8 col-sm-12">
+		<input type="hidden" id="id" th:value="${id}" th:name="id"/>
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>假日信息名称:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" required value="" th:value="${configName}"  th:id="configName" th:name="configName"/>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>年份:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" required value="" th:value="${configKey}"  th:id="configKey" th:name="configKey"/>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>假日信息配置:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" required value="" th:value="${configValue}"  th:id="configValue" th:name="configValue"/>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<div class="formControls col-xs-8 col-sm-9">
+				<div class="uploader-thum-container">
+					<div id="fileListPre" class="uploader-list">
+					</div>
+					<div id="filePicker">导入假日信息</div>
+				</div>
+			</div>
+		</div>
 
-                <table class="table table-border table-bordered table-bg table-hover">
-                    <thead>
-                    <tr class="text-c">
-                        <th>序号</th>
-						<th>名称</th>
-						<th>年份</th>
-						<th>配置信息</th>
-                        <th>有效标记</th>
-                        <th>创建时间</th>
-                        <th width="100">操作</th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr class="text-c" th:each="model,iterStat:${pageInfo.list}" th:object="${model}">
-		                <td><input type="hidden" th:id="*{id}" value="" name=""/><span th:text="${iterStat.index+1}" ></span></td>
-		                <td th:text="*{name}"></td>
-		                <td>
-		                	<th:block th:unless="${model.fileDown} == null">
-		                	<th:block th:unless="${model.fileDown.file_url} == null">
-		                    	<a th:href="${fileUrl} + ${model.fileDown.file_url}" target="_blank">[[${model.fileDown.file_name}]]</a>
-		                    </th:block>
-		                    </th:block>
-		                </td>
-		                <td class="td-status">
-		                	<span class="label radius" th:if="*{is_active==false}">否</span>
-		                    <span class="label radius label-success" th:unless="*{is_active==false}">是</span>
-		                </td>
-                        <td th:text="*{create_time}"></td>
-		                <td class="td-manage">
-		                    <a title="编辑" href="javascript:;"  th:onclick="'javascript:holiday_editFile(\'编辑模板文件\',\'/super/holiday/editFile/'+*{id}+'\',\'800\',\'500\');'" class="ml-5" style="text-decoration:none">编辑</a>
-		                    <a title="删除" href="javascript:;"  th:onclick="'javascript:holiday_del(\'/super/holiday/delete/'+*{id}+'\');'" class="ml-5" style="text-decoration:none">删除</a>
-		                </td>
-		            </tr>
-                    </tbody>
-                </table>
-            </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>
-                <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;返回&nbsp;&nbsp;</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">
 
+	/**
+	 * 初始化上传控件
+	 */
+	var options = {
+		uploadBtnId: '#filePicker',
+		picturePreId: 'fileListPre',
+		hiddenPictureUrl: 'img',
+		hiddenPictureName: 'imgName',
+		width: 81,
+		height: 81,
+		fileSizeLimit: 100 * 1024 * 1024,
+		fileSingleSizeLimit: 100 * 1024 * 1024,
+		//fileNumLimit: 1,
+		serverUrl:'/myboot/super/holiday/import'
+	};
+
+	var webUploadDoc = new $WebUploadDoc(options);
+	webUploadDoc.init();
+
     /**
      * 取消
      */

+ 4 - 4
src/main/resources/templates/admin/super/holiday/holiday_list.html

@@ -26,7 +26,7 @@
 	     </div> -->
         <div class="cl pd-5 bg-1 bk-gray mt-20">
             <span class="l">
-                <a href="javascript:;" th:onclick="'javascript:holiday_add(\'新增模板\',\'/super/holiday/add/0/0\',\'800\',\'500\');'" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>新增</a>
+                <a href="javascript:;" th:onclick="'javascript:holiday_add(\'新增假日信息\',\'/super/holiday/add\',\'800\',\'500\');'" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>新增</a>
             </span>
             <span class="r">共有数据:<strong th:text="${pageInfo?.total}" id="total">54</strong> 条</span>
         </div>
@@ -43,9 +43,9 @@
             <tbody>
             <tr class="text-c" th:each="model,iterStat:${pageInfo.list}" th:object="${model}">
                 <td><input type="hidden" th:id="*{id}" value="" name=""/><span th:text="${iterStat.index+1}" ></span></td>
-                <td th:text="*{config_name}"></td>
-                <td th:text="*{config_key}"></td>
-                <td th:text="*{config_value}"></td>
+                <td th:text="*{configName}"></td>
+                <td th:text="*{configKey}"></td>
+                <td th:text="*{configValue}"></td>
                 <td class="td-manage">
                     <a title="修改" href="javascript:;"  th:onclick="'javascript:holiday_edit(\'修改假日数据\',\'/super/holiday/edit/'+*{id}+'\',\'800\',\'500\');'" class="ml-5" style="text-decoration:none">修改</a>
                     <a title="废弃" href="javascript:;"  th:onclick="'javascript:holiday_del(\'/super/holiday/delete/'+*{id}+'\');'" class="ml-5" style="text-decoration:none">废弃</a>