Browse Source

商品资料part1

Aslee 3 years ago
parent
commit
789733ac6c

+ 9 - 1
src/main/java/com/caimei/modules/archive/dao/CmProductArchiveContentDao.java

@@ -1,9 +1,12 @@
 package com.caimei.modules.archive.dao;
 
+import com.caimei.modules.archive.entity.CmProductArchiveFile;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.archive.entity.CmProductArchiveContent;
 
+import java.util.List;
+
 /**
  * 商品资料内容DAO接口
  * @author Aslee
@@ -11,5 +14,10 @@ import com.caimei.modules.archive.entity.CmProductArchiveContent;
  */
 @MyBatisDao
 public interface CmProductArchiveContentDao extends CrudDao<CmProductArchiveContent> {
-	
+
+    List<CmProductArchiveFile> getImageList(String id);
+
+    void deleteFile(String archiveContentId);
+
+    void insertFile(CmProductArchiveFile file);
 }

+ 13 - 2
src/main/java/com/caimei/modules/archive/entity/CmProductArchiveContent.java

@@ -2,6 +2,8 @@ package com.caimei.modules.archive.entity;
 
 import org.hibernate.validator.constraints.Length;
 import java.util.Date;
+import java.util.List;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 import com.thinkgem.jeesite.common.persistence.DataEntity;
@@ -18,7 +20,9 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	private String title;		// 资料标题
 	private Integer type;		// 资料类型:1图片资料,2视频资料,3文件资料
 	private Date addTime;		// 添加时间
-	
+
+	private List<CmProductArchiveFile> imageList;	//图片列表
+
 	public CmProductArchiveContent() {
 		super();
 	}
@@ -60,5 +64,12 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	public void setAddTime(Date addTime) {
 		this.addTime = addTime;
 	}
-	
+
+	public List<CmProductArchiveFile> getImageList() {
+		return imageList;
+	}
+
+	public void setImageList(List<CmProductArchiveFile> imageList) {
+		this.imageList = imageList;
+	}
 }

+ 70 - 0
src/main/java/com/caimei/modules/archive/entity/CmProductArchiveFile.java

@@ -0,0 +1,70 @@
+package com.caimei.modules.archive.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+/**
+ * 商品资料图片Entity
+ * @author Aslee
+ * @version 2021-09-06
+ */
+public class CmProductArchiveFile extends DataEntity<CmProductArchiveFile> {
+
+	private static final long serialVersionUID = 1L;
+	private Integer archiveContentId;		// 资料库内容id
+	private String fileName;		// 文件名称
+	private String ossName;		// oss名称
+	private String ossUrl;		// oss链接
+	private Date uploadTme;		// 上传时间
+
+	public CmProductArchiveFile() {
+		super();
+	}
+
+	public CmProductArchiveFile(String id){
+		super(id);
+	}
+
+	public Integer getArchiveContentId() {
+		return archiveContentId;
+	}
+
+	public void setArchiveContentId(Integer archiveContentId) {
+		this.archiveContentId = archiveContentId;
+	}
+
+	public String getFileName() {
+		return fileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+
+	public String getOssName() {
+		return ossName;
+	}
+
+	public void setOssName(String ossName) {
+		this.ossName = ossName;
+	}
+
+	public String getOssUrl() {
+		return ossUrl;
+	}
+
+	public void setOssUrl(String ossUrl) {
+		this.ossUrl = ossUrl;
+	}
+
+	public Date getUploadTme() {
+		return uploadTme;
+	}
+
+	public void setUploadTme(Date uploadTme) {
+		this.uploadTme = uploadTme;
+	}
+}

+ 54 - 1
src/main/java/com/caimei/modules/archive/service/CmProductArchiveContentService.java

@@ -2,6 +2,13 @@ package com.caimei.modules.archive.service;
 
 import java.util.List;
 
+import com.caimei.dfs.image.beens.ImageUploadInfo;
+import com.caimei.modules.archive.entity.CmProductArchiveFile;
+import com.caimei.modules.common.utils.UploadUtils;
+import com.caimei.modules.sys.utils.UploadImageUtils;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.utils.Encodes;
+import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -10,6 +17,8 @@ import com.thinkgem.jeesite.common.service.CrudService;
 import com.caimei.modules.archive.entity.CmProductArchiveContent;
 import com.caimei.modules.archive.dao.CmProductArchiveContentDao;
 
+import javax.annotation.Resource;
+
 /**
  * 商品资料内容Service
  * @author Aslee
@@ -18,6 +27,8 @@ import com.caimei.modules.archive.dao.CmProductArchiveContentDao;
 @Service
 @Transactional(readOnly = true)
 public class CmProductArchiveContentService extends CrudService<CmProductArchiveContentDao, CmProductArchiveContent> {
+    @Resource
+    CmProductArchiveContentDao cmProductArchiveContentDao;
 
 	public CmProductArchiveContent get(String id) {
 		return super.get(id);
@@ -34,11 +45,53 @@ public class CmProductArchiveContentService extends CrudService<CmProductArchive
 	@Transactional(readOnly = false)
 	public void save(CmProductArchiveContent cmProductArchiveContent) {
 		super.save(cmProductArchiveContent);
+		cmProductArchiveContentDao.deleteFile(cmProductArchiveContent.getId());
+		if (1 == cmProductArchiveContent.getType()) {
+			//保存图片
+			List<CmProductArchiveFile> imageList = cmProductArchiveContent.getImageList();
+			//上传图片
+			imageList.forEach(image->{
+				if (StringUtils.isNotEmpty(image.getOssUrl())) {
+					if (!image.getOssUrl().startsWith("http")) {
+						image.setOssUrl(getImageUrl(image.getOssUrl()));
+					}
+					image.setArchiveContentId(Integer.parseInt(cmProductArchiveContent.getId()));
+					cmProductArchiveContentDao.insertFile(image);
+				}
+			});
+		}
+
 	}
 	
 	@Transactional(readOnly = false)
 	public void delete(CmProductArchiveContent cmProductArchiveContent) {
 		super.delete(cmProductArchiveContent);
 	}
-	
+
+    public List<CmProductArchiveFile> getImageList(String id) {
+        return cmProductArchiveContentDao.getImageList(id);
+    }
+
+	/**
+	 * 获取商品图片服务器全路径
+	 *
+	 * @param imageUrl
+	 * @return
+	 */
+	public String getImageUrl(String imageUrl) {
+		String photoServer = Global.getConfig("photoServer");//获取文件服务器地址
+		ImageUploadInfo saveImageSerivce = new ImageUploadInfo();
+		if (StringUtils.isNotBlank(imageUrl) && !imageUrl.startsWith("http:") && !imageUrl.startsWith("https:")) {
+			imageUrl = Encodes.urlDecode(imageUrl);
+			String realPath = UploadImageUtils.getAbsolutePath(imageUrl);
+			int pointerIndex = realPath.lastIndexOf(".");
+			try {
+				saveImageSerivce = UploadUtils.saveImageSerivce(realPath, pointerIndex, realPath);
+				imageUrl = photoServer + saveImageSerivce.getSource();
+			} catch (Exception e) {
+				logger.error("图片上传错误:" + e.toString(), e);
+			}
+		}
+		return imageUrl;
+	}
 }

+ 27 - 12
src/main/java/com/caimei/modules/archive/web/CmProductArchiveContentController.java

@@ -3,6 +3,7 @@ package com.caimei.modules.archive.web;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.caimei.modules.archive.entity.CmProductArchiveFile;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -19,8 +20,11 @@ import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.caimei.modules.archive.entity.CmProductArchiveContent;
 import com.caimei.modules.archive.service.CmProductArchiveContentService;
 
+import java.util.List;
+
 /**
  * 商品资料内容Controller
+ *
  * @author Aslee
  * @version 2021-09-06
  */
@@ -30,22 +34,22 @@ public class CmProductArchiveContentController extends BaseController {
 
 	@Autowired
 	private CmProductArchiveContentService cmProductArchiveContentService;
-	
+
 	@ModelAttribute
-	public CmProductArchiveContent get(@RequestParam(required=false) String id) {
+	public CmProductArchiveContent get(@RequestParam(required = false) String id) {
 		CmProductArchiveContent entity = null;
-		if (StringUtils.isNotBlank(id)){
+		if (StringUtils.isNotBlank(id)) {
 			entity = cmProductArchiveContentService.get(id);
 		}
-		if (entity == null){
+		if (entity == null) {
 			entity = new CmProductArchiveContent();
 		}
 		return entity;
 	}
-	
+
 	@RequestMapping(value = {"list", ""})
 	public String list(CmProductArchiveContent cmProductArchiveContent, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmProductArchiveContent> page = cmProductArchiveContentService.findPage(new Page<CmProductArchiveContent>(request, response), cmProductArchiveContent); 
+		Page<CmProductArchiveContent> page = cmProductArchiveContentService.findPage(new Page<CmProductArchiveContent>(request, response), cmProductArchiveContent);
 		model.addAttribute("page", page);
 		return "modules/archive/cmProductArchiveContentList";
 	}
@@ -53,24 +57,35 @@ public class CmProductArchiveContentController extends BaseController {
 	@RequestMapping(value = "form")
 	public String form(CmProductArchiveContent cmProductArchiveContent, Model model) {
 		model.addAttribute("cmProductArchiveContent", cmProductArchiveContent);
-		return "modules/archive/cmProductArchiveContentForm";
+		List<CmProductArchiveFile> imageList = null;
+		Integer type = cmProductArchiveContent.getType();
+		if (StringUtils.isNotEmpty(cmProductArchiveContent.getId()) && 1 == type) {
+			imageList = cmProductArchiveContentService.getImageList(cmProductArchiveContent.getId());
+		}
+		cmProductArchiveContent.setImageList(imageList);
+		if (1 == type) {
+			return "modules/archive/cmProductArchiveContentForm";
+		} else if (2 == type) {
+			return "modules/archive/addVedioForm";
+		}else {
+			return "modules/archive/addFileForm";
+		}
 	}
 
 	@RequestMapping(value = "save")
 	public String save(CmProductArchiveContent cmProductArchiveContent, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmProductArchiveContent)){
+		if (!beanValidator(model, cmProductArchiveContent)) {
 			return form(cmProductArchiveContent, model);
 		}
 		cmProductArchiveContentService.save(cmProductArchiveContent);
 		addMessage(redirectAttributes, "保存资料成功");
-		return "redirect:"+Global.getAdminPath()+"/archive/cmProductArchiveContent/?repage";
+		return "redirect:" + Global.getAdminPath() + "/archive/cmProductArchiveContent/?repage&type=" + cmProductArchiveContent.getType();
 	}
-	
+
 	@RequestMapping(value = "delete")
 	public String delete(CmProductArchiveContent cmProductArchiveContent, RedirectAttributes redirectAttributes) {
 		cmProductArchiveContentService.delete(cmProductArchiveContent);
 		addMessage(redirectAttributes, "删除资料成功");
-		return "redirect:"+Global.getAdminPath()+"/archive/cmProductArchiveContent/?repage";
+		return "redirect:" + Global.getAdminPath() + "/archive/cmProductArchiveContent/?repage&type=" + cmProductArchiveContent.getType();
 	}
-
 }

+ 15 - 5
src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml

@@ -63,8 +63,11 @@
 			</otherwise>
 		</choose>
 	</select>
-	
-	<insert id="insert" parameterType="CmProductArchiveContent"  keyProperty="id" useGeneratedKeys="true">
+    <select id="getImageList" resultType="com.caimei.modules.archive.entity.CmProductArchiveFile">
+        select * from cm_product_archive_file where archiveContentId = #{id}
+    </select>
+
+    <insert id="insert" parameterType="CmProductArchiveContent"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_product_archive_content(
 			productArchiveId,
 			title,
@@ -74,10 +77,14 @@
 			#{productArchiveId},
 			#{title},
 			#{type},
-			#{addTime}
+			now()
 		)
 	</insert>
-	
+	<insert id="insertFile">
+		insert into cm_product_archive_file(archiveContentId, fileName, ossName, ossUrl, uploadTime)
+		values (#{archiveContentId}, #{fileName}, #{ossName}, #{ossUrl}, now())
+	</insert>
+
 	<update id="update">
 		UPDATE cm_product_archive_content SET 	
 			title = #{title}
@@ -88,5 +95,8 @@
 		DELETE FROM cm_product_archive_content
 		WHERE id = #{id}
 	</delete>
-	
+	<delete id="deleteFile">
+		delete from cm_product_archive_file where archiveContentId = #{archiveContentId}
+	</delete>
+
 </mapper>

+ 198 - 0
src/main/webapp/WEB-INF/views/modules/archive/addVedioForm.jsp

@@ -0,0 +1,198 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>添加视频资料</title>
+    <meta name="decorator" content="default"/>
+    <style>
+        .controls .new-tag {
+            display: inline-block;
+            width: 78px;
+            height: 30px;
+            border: 1px solid #e5e5e5;
+            border-radius: 5px;
+            margin: 7px;
+            text-align: center;
+            line-height: 30px;
+            font-size: 14px;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
+            cursor: pointer;
+        }
+
+        .controls .new-tag.active {
+            border-color: #e15616;
+            color: #e15616;
+        }
+
+        #tagInput {
+            width: 263px;
+            margin: 7px;
+            display: inline-block;
+            height: 30px;
+        }
+
+        .controls .tags-operate .tag-add {
+            height: 40px;
+            line-height: 40px;
+            vertical-align: middle;
+        }
+
+        .upload {
+            position: relative;
+            display: inline-block;
+            background: #D0EEFF;
+            border: 1px solid #99D3F5;
+            border-radius: 4px;
+            padding: 4px 12px;
+            color: #1E88C7;
+            text-decoration: none;
+            text-indent: 0;
+            line-height: 20px;
+            margin-left: 20px;
+            cursor: pointer;
+            width: 52px;
+            height: 20px;
+        }
+
+        .upload input {
+            position: absolute;
+            width: 170px;
+            font-size: 20px;
+            right: 0;
+            top: 0;
+            opacity: 0;
+            cursor: pointer;
+        }
+
+        .upload:hover {
+            background: #AADFFD;
+            border-color: #78C3F3;
+            color: #004974;
+            text-decoration: none;
+        }
+
+        .add-submit {
+            position: relative;
+            display: inline;
+            background: #D0EEFF;
+            border: 1px solid #99D3F5;
+            border-radius: 4px;
+            padding: 4px 12px;
+            color: #1E88C7;
+            text-decoration: none;
+            text-indent: 0;
+            line-height: 20px;
+            margin-left: 20px;
+            cursor: pointer;
+            width: 52px;
+            height: 30px;
+        }
+
+        .add-submit input {
+            position: absolute;
+            width: 50px;
+            font-size: 20px;
+            right: 0;
+            top: 0;
+            opacity: 0;
+            cursor: pointer;
+        }
+
+        .add-submit:hover {
+            background: #AADFFD;
+            border-color: #78C3F3;
+            color: #004974;
+            text-decoration: none;
+        }
+
+        .upload-loading{
+            display: none;
+            width: 32px;
+            height: 32px;
+            margin-left: 10px;
+        }
+        .upload-loading img{
+            width: 16px;
+            height: 16px;
+            margin: 0 auto 0;
+        }
+
+        #file-list-display {
+            width: 600px;
+            height: auto;
+            float: left;
+            margin-left: 20px;
+        }
+
+        #file-list-display p {
+            line-height: 30px;
+            font-size: 14px;
+            color: #333333;
+            margin: 0;
+        }
+
+        #file-list-display p .del {
+            color: #2fa4e7;
+            font-size: 12px;
+            cursor: pointer;
+            margin-left: 20px;
+        }
+
+        .Main-content{
+            height: 100px;
+        }
+    </style>
+
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $("#searchForm").validate({
+                submitHandler: function (form) {
+                    var isSubMitFlag = true;
+                    var productID = $("#productID").val();
+                    if (isNaN(productID) || productID.indexOf('0') == 0 ) {
+                        alertx("请输入正确的商品ID");
+                        isSubMitFlag = false;
+                        return false;
+                    }
+                    if (isSubMitFlag) {
+                        form.submit();
+                    }
+                }
+            })
+        });
+    </script>
+</head>
+<body>
+<form:form id="inputForm" modelAttribute="cmOrderArchiveContent" action="${ctx}/archive/cmOrderArchiveContent/save" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="type" value="1"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>标题:</label>
+        <div class="controls">
+            <form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "  style="position:relative"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">视频路径:</label>
+        <input id="uploadFileName" type="text" style="display: inline;margin-left:20px" placeholder="视频大小不超过50M" class="input-xlarge required" />
+        <div class="upload">
+            <input type="file" name="file" id="archiveFile" accept=".mp4">选择文件
+        </div>
+        <div class="add-submit">
+            <input id="addSubmit" type="button" value="上传"/>上传&nbsp;
+        </div>
+        <div class="upload-loading">
+            <img alt="gif" src="/static/images/upload.gif" width="32px" border="none">
+        </div>
+    </div>
+    <div class="form-actions">
+        <input id="btnCancel" class="btn" type="button" value="取 消" onclick="history.go(-1)"/>
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
+    </div>
+</form:form>
+</body>
+</html>
+

+ 270 - 5
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentForm.jsp

@@ -4,6 +4,142 @@
 <head>
 	<title>资料管理</title>
 	<meta name="decorator" content="default"/>
+	<%--<style>
+		.clearfix::after{
+			content: "";
+			display: block;
+			clear: both;
+		}
+		.iconBox{
+			font-size: 0;
+		}
+		.controls{
+			margin-left: 0 !important;
+		}
+		.controls .conList{
+			display: inline-block;
+			margin-right: 15px;
+		}
+		.conList .btn:nth-of-type(1){
+			margin-left: 25px;
+		}
+		.select2-choice{
+			width: 100px;
+		}
+		.upload-content {
+			float: left;
+			margin-top: -100px;
+			margin-right: -40px;
+		}
+		.upload-content .conList .btn:nth-of-type(1) {
+			width: 90px;
+			height: 100px;
+			border: 2px solid #eee;
+			background: #fff;
+			position: relative;
+		}
+		.upload-content .conList .btn:nth-of-type(1)>div {
+			position: absolute;
+			top: 50%;
+			left: 50%;
+			transform: translate(-50%, -50%);
+			color: #666;
+		}
+		.upload-content .conList .btn:nth-of-type(1) span {
+			font-size: 35px;
+		}
+		.upload-content .conList .btn:nth-of-type(1) h5 {
+			color: #666;
+		}
+		.cancel-upload {
+			background: transparent;
+			border: none;
+			box-shadow: none;
+			position: relative;
+			top: -38px;
+			left: -25px;
+			cursor: pointer;
+			z-index: 100;
+		}
+		.upload-content .conList ol li {
+			width: 114px;
+			min-height: 80px;
+			text-align: center;
+			background: #fff;
+			position: relative;
+			top: 120px;
+			margin-left: 2px;
+		}
+		.hide-pic {
+			display: none !important;
+		}
+		.upload-image-list{
+			width: 600px;
+			float: left;
+		}
+	</style>--%>
+	<style>
+		.iconBox{
+			font-size: 0;
+		}
+		.controls .conList{
+			display: inline-block;
+			margin-right: 15px;
+		}
+		.conList .btn:nth-of-type(1){
+			margin-left: 25px;
+		}
+		.select2-choice{
+			width: 100px;
+		}
+		.upload-content {
+			float: left;
+			margin-top: -70px;
+			margin-left: 20px !important;
+		}
+		.upload-content .conList .btn:nth-of-type(1) {
+			width: 90px;
+			height: 100px;
+			border: 2px solid #eee;
+			background: #fff;
+			position: relative;
+		}
+		.upload-content .conList .btn:nth-of-type(1)>div {
+			position: absolute;
+			top: 50%;
+			left: 50%;
+			transform: translate(-50%, -50%);
+			color: #666;
+		}
+		.upload-content .conList .btn:nth-of-type(1) span {
+			font-size: 35px;
+		}
+		.upload-content .conList .btn:nth-of-type(1) h5 {
+			color: #666;
+		}
+		.cancel-upload {
+			background: transparent;
+			border: none;
+			box-shadow: none;
+			position: relative;
+			top: -38px;
+			left: -25px;
+			cursor: pointer;
+			z-index: 100;
+		}
+		.upload-content .conList ol li {
+			width: 114px;
+			min-height: 80px;
+			text-align: center;
+			background: #fff;
+			position: relative;
+			top: 120px;
+			margin-left: 2px;
+		}
+		.hide-pic {
+			display: none !important;
+		}
+	</style>
 	<script type="text/javascript">
 		$(document).ready(function() {
 			//$("#name").focus();
@@ -27,28 +163,157 @@
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/archive/cmProductArchiveContent/">资料列表</a></li>
+		<li><a href="${ctx}/archive/cmProductArchiveContent/?type=1">资料列表</a></li>
 		<li class="active"><a href="${ctx}/archive/cmProductArchiveContent/form?id=${cmProductArchiveContent.id}">资料${not empty cmProductArchiveContent.id?'编辑':'添加'}</a></li>
 	</ul><br/>
+
+
 	<form:form id="inputForm" modelAttribute="cmProductArchiveContent" action="${ctx}/archive/cmProductArchiveContent/save" method="post" class="form-horizontal">
 		<form:hidden path="id"/>
+		<form:hidden path="type" value="1"/>
 		<sys:message content="${message}"/>		
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>标题:</label>
 			<div class="controls">
-				<form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "/>
+				<form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "  style="position:relative"/>
 			</div>
 		</div>
-		<div class="control-group">
+		<div class="control-group" style="width: 1000px">
 			<label class="control-label"><font color="red">*</font>图片:</label>
-			<div class="controls">
-				<form:input path="title" htmlEscape="false" maxlength="50" class="input-xlarge "/>
+<%--				<c:if test="${not empty cmProductArchiveContent.imageList}">--%>
+			<div class="upload-image-list" style="display: flex;flex-wrap: wrap">
+				<c:forEach items="${cmProductArchiveContent.imageList}" var="image" varStatus="index">
+					<div class="controls upload-content iconBox" id="imageBox${index.index}">
+						<div class="conList">
+							<form:hidden id="pImage${index.index}" path="imageList[${index.index}].ossUrl" htmlEscape="false"
+										 maxlength="255"
+										 class="input-xlarge required"/>
+							<sys:ckfinder input="pImage${index.index}" type="images" uploadPath="/photo"
+										  selectMultiple="false"
+										  maxWidth="100" maxHeight="100"/><br>
+						</div>
+					</div>
+				</c:forEach>
+				<c:set var="size" value="${empty cmProductArchiveContent.imageList?0:cmProductArchiveContent.imageList.size()}"/>
+				<c:forEach var="emptyIndex" begin="${size}" end="${11}">
+					<div class="controls upload-content iconBox conList ${emptyIndex eq 0?'':'hide-pic'}" id="imageBox${emptyIndex}" >
+						<div class="conList">
+							<form:hidden id="pImage${emptyIndex}" path="imageList[${emptyIndex}].ossUrl" htmlEscape="false"
+										 maxlength="255"
+										 class="input-xlarge required"/>
+							<sys:ckfinder input="pImage${emptyIndex}" type="images" uploadPath="/photo"
+										  selectMultiple="false"
+										  maxWidth="100" maxHeight="100"/><br>
+						</div>
+					</div>
+				</c:forEach>
 			</div>
+
+
+<%--			</div>--%>
+
+				<%--</c:if>
+				<c:if test="${empty cmProductArchiveContent.imageList}">
+					111
+				</c:if>--%>
 		</div>
 		<div class="form-actions">
 			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
 			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
 		</div>
 	</form:form>
+<script>
+    var imageSize = 0;
+    var imageList = [];
+	$(function () {
+		<c:forEach items="${cmProductArchiveContent.imageList}" var="floorImage" varStatus="index">
+		imageList.push({
+			id: "${floorImage.id}",
+			ossUrl: "${floorImage.ossUrl}"
+		});
+		</c:forEach>
+		imageSize = imageList.length
+		$('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
+		$('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
+		$('.upload-content .conList').find('.cancel-upload').hide();
+		var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
+		var MutationObserverConfig = {
+			childList: true,
+			subtree: true,
+			characterData: true
+		};
+		var observer = new MutationObserver(function (mutations) {
+			$.each(mutations, function (index, item) {
+				if (item.type === 'childList') {
+					debugger
+					// 在创建新的 element 时调用
+					var target = $(item.target),
+							thisWrapper = target.closest('.conList'),
+							nextEle = thisWrapper.parents('.controls').next();
+					thisWrapper.find('li').css('z-index', 99);
+					thisWrapper.find('.cancel-upload').show();
+					if (nextEle.hasClass('hide-pic')) {
+						nextEle.removeClass('hide-pic');
+					}
+				}
+			})
+		});
+		var observeEle = document.getElementsByClassName('upload-image-list')[0];
+		observer.observe(observeEle, MutationObserverConfig);
+
+		$('body').on('click', '.cancel-upload',function() {
+			debugger
+			var wrapper = $(this).closest('.controls');
+			wrapper.find('li').css('z-index','-1');
+			wrapper.find('input').val('');
+			$(this).hide();
+			if ($('.cancel-upload:visible').length < 12) {
+				wrapper.addClass("hide-pic");
+			}else{
+				wrapper.removeClass("hide-pic");
+			}
+			wrapper.parent().append(wrapper.clone());
+			wrapper.remove();
+			$(".controls").each(function(i,ele){
+				if($(ele).find("input.input-xlarge").val()){
+					$(ele).next().removeClass("hide-pic")
+				}
+			})
+			console.log(--imageSize)
+		});
+
+		$('body').on('click','.upload-content li',function() {
+			var index = $(this).closest('.conList').index() + 1,
+					str = 'image'+index+'FinderOpen';
+			eval(str+'()');
+		});
+
+		$(window).on("load", function () {
+			setTimeout(function () {
+				for (var i = 0; i < 12; i++) {
+					$("#imageBox"+i).find("input.input-xlarge").each(function (i, ele) {
+						if ($(ele).val()) {
+							$(ele).next().find("li").css("z-index", "99");
+							$(ele).parents(".conList").find(".cancel-upload").show();
+							$(ele).parent().parents(".controls").next().removeClass("hide-pic")
+						}
+					})
+				}
+			}, 200);
+		});
+	});
+
+    function showImage() {
+    	var html = '';
+		imageList.forEach(function (item,index) {
+			html += appendImage(item, index);
+		})
+    }
+
+	function appendImage(item, index) {
+    	alert(1)
+	}
+
+</script>
 </body>
 </html>

+ 43 - 5
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp

@@ -69,12 +69,50 @@
 	<div class="pagination">${page}</div>
 <script>
 	function showAddForm(type) {
+		debugger
 		if (type == 1) {
-			window.location='${ctx}/archive/cmProductArchiveContent/form';
-		}else if (type == 2) {
-
-		}else if (type == 3) {
-
+			window.location='${ctx}/archive/cmProductArchiveContent/form?type=1';
+		}else {
+			//添加视频资料
+			var url = '';
+			var title = '';
+			url = "${ctx}/archive/cmProductArchiveContent/form?type=" + type;
+			title = type == 2?"添加视频文件":"添加文件资料";
+			top.$.jBox("iframe:" + url, {
+				iframeScrolling: 'yes',
+				width: $(top.document).width() - 600,
+				height: $(top.document).height() - 160,
+				persistent: true,
+				title: title,
+				buttons: {"取消": '-1', "保存": '1'},
+				submit: function (v, h, f) {
+					//确定
+					var $jboxFrame = top.$('#jbox-iframe');
+					var $mainFrame = top.$('#mainFrame');
+					if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+						var items = $jboxFrame[0].contentWindow.getCheckedItems(0);
+						if (items.length > 0) {
+							console.log(items)
+							var productId = items[0].productId;
+							var mainImage = items[0].mainImage;
+							var productName = items[0].productName;
+							var productType = items[0].commodityType;
+							$("#mainImage").attr("src", mainImage).show();
+							$("#productName").text(productName);
+							$("#productId").val(productId);
+							$("#name").val(productName);
+							$(".productInfo").show();
+							if ('' == productType ) {
+								$(".productType").show();
+							}
+						} else {
+							top.$.jBox.tip("请先勾选商品...");
+							return false;
+						}
+					}
+					return true;
+				}
+			});
 		}
 	}
 </script>

+ 2 - 0
src/main/webapp/WEB-INF/views/modules/product/cmSecondHandDetailForm.jsp

@@ -629,6 +629,7 @@
         };
         var observer = new MutationObserver(function(mutations){
             $.each(mutations, function(index,item) {
+            	debugger
                 if (item.type === 'childList') {
                     // 在创建新的 element 时调用
                     var target = $(item.target),
@@ -650,6 +651,7 @@
             eval(str+'()');
         });
         $('body').on('click', '.cancel-upload',function() {
+        	debugger
             var wrapper = $(this).closest('.conList');
             wrapper.find('li').css('z-index','-1');
             wrapper.find('input').val('');