Aslee 3 роки тому
батько
коміт
c8bbd7d4e5

+ 13 - 0
src/main/java/com/caimei/modules/baike/dao/CmBaikeProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.baike.dao;
 
+import com.caimei.modules.baike.entity.CmBaikeProductFile;
 import com.caimei.modules.baike.entity.CmBaikeProductParam;
 import com.caimei.modules.baike.entity.CmBaikeProductQuestion;
 import com.caimei.modules.user.entity.NewCmShop;
@@ -57,4 +58,16 @@ public interface CmBaikeProductDao extends CrudDao<CmBaikeProduct> {
     void offline(Integer id);
 
     void updateEmptyNum(@Param("id") String id,@Param("emptyNum") Integer emptyNum);
+
+    Integer checkFileName(@Param("fileName") String fileName, @Param("productId") Integer productId, @Param("fileIds") String fileIds);
+
+    void insertProductFile(CmBaikeProductFile productFile);
+
+    CmBaikeProductFile getProductFileById(Integer fileId);
+
+    void deleteProductFile(Integer fileId);
+
+    void updateProductFile(@Param("fileId") Integer fileId, @Param("productId") Integer productId);
+
+    List<CmBaikeProductFile> findFileList(String id);
 }

+ 18 - 0
src/main/java/com/caimei/modules/baike/entity/CmBaikeProduct.java

@@ -58,6 +58,7 @@ public class CmBaikeProduct extends DataEntity<CmBaikeProduct> {
 	private List<String> authImageList;			// 产品认证图片列表
 	private List<String> displayImageList;		// 效果展示图片列表
 	private List<CmBaikeProductQuestion> questionList;		//问题列表
+	private List<CmBaikeProductFile> videoList;		//视频列表
 	private List<NewCmShop> shopList;		//供应商列表
 	private String shopName;		//供应商名称
 	private Integer marketYear;		//上市年
@@ -67,6 +68,7 @@ public class CmBaikeProduct extends DataEntity<CmBaikeProduct> {
 	private Integer nmpaMonth;		// nmpa月
 	private Integer nmpaDay;		// nmpa日
 	private Integer auditFlag;		// 是否审核保存,1是
+	private String fileIds;			// 文件id,以,隔开
 
 	public CmBaikeProduct() {
 		super();
@@ -461,4 +463,20 @@ public class CmBaikeProduct extends DataEntity<CmBaikeProduct> {
 	public void setEmptyNum(Integer emptyNum) {
 		this.emptyNum = emptyNum;
 	}
+
+	public String getFileIds() {
+		return fileIds;
+	}
+
+	public void setFileIds(String fileIds) {
+		this.fileIds = fileIds;
+	}
+
+	public List<CmBaikeProductFile> getVideoList() {
+		return videoList;
+	}
+
+	public void setVideoList(List<CmBaikeProductFile> videoList) {
+		this.videoList = videoList;
+	}
 }

+ 69 - 0
src/main/java/com/caimei/modules/baike/entity/CmBaikeProductFile.java

@@ -0,0 +1,69 @@
+package com.caimei.modules.baike.entity;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+import java.util.Date;
+
+/**
+ * 订单资料文件Entity
+ * @author Aslee
+ * @version 2021-07-30
+ */
+public class CmBaikeProductFile extends DataEntity<CmBaikeProductFile> {
+
+	private static final long serialVersionUID = 1L;
+	private Integer productId;		// 产品/仪器id
+	private String fileTitle;			// 文件标题
+	private String fileName;			// 文件名称
+	private String ossName;			// oss名称
+	private String ossUrl;			// oss链接
+	private Date uploadTime;		//上传时间
+
+	public Integer getProductId() {
+		return productId;
+	}
+
+	public void setProductId(Integer productId) {
+		this.productId = productId;
+	}
+
+	public String getFileTitle() {
+		return fileTitle;
+	}
+
+	public void setFileTitle(String fileTitle) {
+		this.fileTitle = fileTitle;
+	}
+
+	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 Date getUploadTime() {
+		return uploadTime;
+	}
+
+	public void setUploadTime(Date uploadTime) {
+		this.uploadTime = uploadTime;
+	}
+
+	public String getOssUrl() {
+		return ossUrl;
+	}
+
+	public void setOssUrl(String ossUrl) {
+		this.ossUrl = ossUrl;
+	}
+}

+ 70 - 3
src/main/java/com/caimei/modules/baike/service/CmBaikeProductService.java

@@ -1,13 +1,17 @@
 package com.caimei.modules.baike.service;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.io.File;
+import java.util.*;
 
+import com.caimei.modules.archive.entity.CmOrderArchiveFile;
+import com.caimei.modules.archive.utils.OssArchiveUtil;
+import com.caimei.modules.baike.entity.CmBaikeProductFile;
 import com.caimei.modules.baike.entity.CmBaikeProductParam;
 import com.caimei.modules.baike.entity.CmBaikeProductQuestion;
 import com.caimei.modules.info.entity.Info;
 import com.caimei.modules.miniprogram.utils.UploadPicUtils;
+import com.caimei.modules.oss.utils.OSSUtils;
+import com.caimei.utils.StringUtil;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -16,6 +20,7 @@ import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
 import com.caimei.modules.baike.entity.CmBaikeProduct;
 import com.caimei.modules.baike.dao.CmBaikeProductDao;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 
@@ -111,6 +116,14 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
             }
 		}
 		super.save(cmBaikeProduct);
+		String fileIds = cmBaikeProduct.getFileIds();
+		if (StringUtils.isNotEmpty(fileIds)) {
+			for (String id : fileIds.split(",")) {
+				if (StringUtil.isNotBlank(id)) {
+					cmBaikeProductDao.updateProductFile(Integer.valueOf(id),Integer.valueOf(cmBaikeProduct.getId()));
+				}
+			}
+		}
 		if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
 			Integer emptyNum = checkComplete(cmBaikeProduct);
 			cmBaikeProductDao.updateEmptyNum(cmBaikeProduct.getId(), emptyNum);
@@ -299,4 +312,58 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
 		}
 		return emptyNum;
 	}
+
+	@Transactional(readOnly = false)
+    public Map<String, Object> upload(MultipartFile multipartFile,String fileTitle, String fileName, Integer productId, String fileIds) {
+		Map<String, Object> map = new HashMap<>();
+		if (null != productId || StringUtils.isNotEmpty(fileIds)) {
+			Integer fileIdByFileName = cmBaikeProductDao.checkFileName(fileName, productId, fileIds);
+			if (null != fileIdByFileName) {
+				map.put("success", false);
+				map.put("msg", "文件已存在");
+				return map;
+			}
+		}
+		String fileAllName = multipartFile.getOriginalFilename();
+		String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
+		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+		String filePath = uuid + "." + fileType;
+		String contentType = OssArchiveUtil.getContentType(fileAllName);
+		try {
+			//保存本地
+			File file = OSSUtils.ossUpload(multipartFile);
+			logger.info("默认路径>>>" + file.getAbsolutePath());
+			//上传oss
+			String url = OSSUtils.ossUpload(filePath, file, contentType);
+			//删除本地文件
+			OssArchiveUtil.deleteFile(file);
+			//保存关联关系
+			CmBaikeProductFile productFile = new CmBaikeProductFile();
+			productFile.setFileTitle(fileTitle);
+			productFile.setFileName(fileName);
+			productFile.setOssName(filePath);
+			productFile.setUploadTime(new Date());
+			cmBaikeProductDao.insertProductFile(productFile);
+			productFile.setOssUrl(url);
+			map.put("success", true);
+			map.put("msg", "操作成功");
+			map.put("productFile", productFile);
+		} catch (Exception e) {
+			e.printStackTrace();
+			map.put("success", false);
+			map.put("msg", "操作失败");
+			logger.info("上传异常!!!");
+		}
+		return map;
+    }
+
+	@Transactional(readOnly = false)
+	public void deleteFile(Integer fileId) {
+		CmBaikeProductFile productFile = cmBaikeProductDao.getProductFileById(fileId);
+		if (productFile != null) {
+			//删除oss服务器上的文件
+			OSSUtils.deleteSingleFile(productFile.getOssName());
+			cmBaikeProductDao.deleteProductFile(fileId);
+		}
+	}
 }

+ 24 - 4
src/main/java/com/caimei/modules/baike/web/CmBaikeProductController.java

@@ -5,12 +5,11 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.caimei.modules.baike.dao.CmBaikeProductDao;
-import com.caimei.modules.baike.entity.CmBaikeProductParam;
-import com.caimei.modules.baike.entity.CmBaikeProductQuestion;
-import com.caimei.modules.baike.entity.CmBaikeType;
+import com.caimei.modules.baike.entity.*;
 import com.caimei.modules.baike.service.CmBaikeTypeService;
 import com.caimei.modules.info.dao.InfoDao;
 import com.caimei.modules.opensearch.GenerateUtils;
+import com.caimei.modules.oss.utils.OSSUtils;
 import com.caimei.modules.user.entity.NewCmShop;
 import com.google.common.collect.Maps;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,13 +19,13 @@ import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.web.BaseController;
 import com.thinkgem.jeesite.common.utils.StringUtils;
-import com.caimei.modules.baike.entity.CmBaikeProduct;
 import com.caimei.modules.baike.service.CmBaikeProductService;
 
 import java.util.ArrayList;
@@ -110,6 +109,12 @@ public class CmBaikeProductController extends BaseController {
 		// 问题列表
 		List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(cmBaikeProduct.getId());
 		cmBaikeProduct.setQuestionList(questionList);
+		// 视频列表
+		List<CmBaikeProductFile> videoList = cmBaikeProductDao.findFileList(cmBaikeProduct.getId());
+		videoList.forEach(video->{
+			OSSUtils.getOssUrl(video.getOssName());
+		});
+		cmBaikeProduct.setVideoList(videoList);
 		// 供应商列表
 		List<NewCmShop> shopList = cmBaikeProductDao.findShopList();
 		cmBaikeProduct.setShopList(shopList);
@@ -293,4 +298,19 @@ public class CmBaikeProductController extends BaseController {
         cmBaikeProductService.offlineInfo(id);
         return true;
     }
+
+	@ResponseBody
+	@RequestMapping(value = "upload")
+	public Map<String, Object> upload(@RequestParam("file") MultipartFile file, @RequestParam("fileTitle") String fileTitle, @RequestParam("fileName") String fileName,
+									  @RequestParam("productId") Integer productId, @RequestParam("fileIds") String fileIds) {
+		return cmBaikeProductService.upload(file, fileTitle, fileName, productId, fileIds);
+	}
+
+    /**
+     * 文件删除
+     */
+    @RequestMapping(value = "deleteFile")
+    public void deleteFile(Integer fileId) {
+        cmBaikeProductService.deleteFile(fileId);
+    }
 }

+ 8 - 2
src/main/java/com/caimei/modules/oss/utils/OSSUtils.java

@@ -90,12 +90,18 @@ public class OSSUtils {
         if (".vsd".equalsIgnoreCase(fileExtension)) {
             return "application/vnd.visio";
         }
-        if (".ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) {
+        if (".ppt".equalsIgnoreCase(fileExtension)  ) {
             return "application/vnd.ms-powerpoint";
         }
-        if (".doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) {
+        if (".pptx".equalsIgnoreCase(fileExtension)) {
+            return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
+        }
+        if (".doc".equalsIgnoreCase(fileExtension)) {
             return "application/msword";
         }
+        if ("docx".equalsIgnoreCase(fileExtension)) {
+            return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
+        }
         if (".xml".equalsIgnoreCase(fileExtension)) {
             return "text/xml";
         }

+ 1 - 1
src/main/resources/mappings/modules/archive/CmOrderArchiveMapper.xml

@@ -138,7 +138,7 @@
             fileName = #{fileName}
             <if test="orderArchiveId != null || (fileIds != null and fileIds != '')">
                 and(
-                <if test="orderArchiveId != null || (fileIds != null and fileIds != '')">
+                <if test="orderArchiveId != null">
                     orderArchiveId = #{orderArchiveId}
                 </if>
                 <if test="fileIds != null and fileIds != ''">

+ 44 - 1
src/main/resources/mappings/modules/baike/CmBaikeProductMapper.xml

@@ -148,8 +148,38 @@
 		select s.shopID,u.name from shop s
 						 LEFT JOIN user u ON u.userID = s.userID where s.status = 90 order by s.shopID desc;
 	</select>
+    <select id="checkFileName" resultType="java.lang.Integer">
+		select id from cm_baike_product_file
+		<where>
+			fileName = #{fileName}
+			<if test="productId != null || (fileIds != null and fileIds != '')">
+				and(
+				<if test="productId != null">
+					productId = #{productId}
+				</if>
+				<if test="fileIds != null and fileIds != ''">
+					or id in
+					<foreach collection="fileIds.split(',')" item="fileId" index="index" open="(" separator=","
+							 close=")">
+						#{fileId}
+					</foreach>
+				</if>
+				)
+			</if>
+		</where>
+	</select>
+	<select id="getProductFileById" resultType="com.caimei.modules.baike.entity.CmBaikeProductFile">
+		select productId, fileTitle, fileName, ossName, uploadTime
+		from cm_baike_product_file
+		where id = #{fileId}
+	</select>
+	<select id="findFileList" resultType="com.caimei.modules.baike.entity.CmBaikeProductFile">
+		select id, productId, fileTitle, fileName, ossName, uploadTime
+		from cm_baike_product_file
+		where productId = #{id}
+	</select>
 
-    <insert id="insert" parameterType="CmBaikeProduct"  keyProperty="id" useGeneratedKeys="true">
+	<insert id="insert" parameterType="CmBaikeProduct"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_baike_product(
 			commodityType,
 			name,
@@ -223,6 +253,11 @@
 		values (#{productId}, #{question}, #{answer})
 	</insert>
 
+	<insert id="insertProductFile" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
+		insert into cm_baike_product_file(fileTitle, fileName, ossName, uploadTime)
+		values (#{fileTitle}, #{fileName}, #{ossName}, #{uploadTime})
+	</insert>
+
 	<update id="update">
 		UPDATE cm_baike_product SET 	
 			name = #{name},
@@ -284,6 +319,11 @@
 	<update id="updateEmptyNum">
 		update cm_baike_product set emptyNum = #{emptyNum} where id = #{id}
 	</update>
+	<update id="updateProductFile">
+		update cm_baike_product_file
+		set productId = #{productId}
+		where id = #{fileId}
+	</update>
 
 	<delete id="delete">
 		DELETE FROM cm_baike_product
@@ -298,5 +338,8 @@
 	<delete id="deleteQuestionsByProductId">
 		delete from cm_baike_product_question where productId = #{id}
 	</delete>
+	<delete id="deleteProductFile">
+		delete from cm_baike_product_file where id = #{fileId}
+	</delete>
 
 </mapper>

+ 269 - 0
src/main/webapp/WEB-INF/views/modules/baikePage/cmBaikeProductForm.jsp

@@ -155,6 +155,113 @@
 		.red {
 			color: red;
 		}
+
+
+
+		.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() {
@@ -337,6 +444,7 @@
 	</ul><br/>
 	<form:form id="inputForm" modelAttribute="cmBaikeProduct" action="${ctx}/baike/cmBaikeProduct/save" method="post" class="form-horizontal">
 		<form:hidden path="id"/>
+		<form:hidden path="fileIds" id="fileIds"/>
 		<form:hidden path="commodityType"/>
 		<form:hidden path="emptyNum"/>
 		<sys:message content="${message}"/>
@@ -394,6 +502,43 @@
                 </div>
             </div>
 		</div>
+		<div class="control-group">
+			<div class="control-group">
+				<label class="control-label keyClass">相关视频(各视频大小不超过50M,最多上传6个)</label>
+			</div>
+			<div class="control-group">
+				<label class="control-label">标题:</label>
+				<div class="controls">
+					<input id="fileTitle" style="width: 457px" htmlEscape="false" >
+				</div>
+				<label class="control-label" style="margin-top:10px">视频路径:</label>
+				<div class="controls" style="margin-top:10px">
+					<input id="uploadFileName" type="text" style="display: inline;" placeholder="支持mp4" disabled="true" class="input-xlarge required" />
+					<div class="upload">
+						<input type="file" name="file" id="productFile" 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>
+			<div class="control-group">
+				<div id='file-list-display' style="margin-left:180px">
+					<c:if test="${not empty cmBaikeProduct.videoList}">
+						<c:forEach items="${cmBaikeProduct.videoList}" var="videoFile" varStatus="statusIndex">
+							<p>${videoFile.fileTitle}
+								<span class="del"><a onclick="previewVideo('${videoFile.ossUrl}')">预览</a></span>
+								<span class="del" onclick="dataDelete(this,'${videoFile.id}')">删除</span>
+							</p>
+						</c:forEach>
+					</c:if>
+				</div>
+			</div>
+		</div>
+
         <div style="${cmBaikeProduct.commodityType eq 2?'':'display:none'}" >
             <div class="control-group">
                 <label class="control-label titleClass">正品识别</label>
@@ -895,6 +1040,101 @@
 			$('input[name="' + questionInput + '"]').val(questionArray[i]);
 			$('input[name="' + answerInput + '"]').val(answerArray[i]);
 		}
+
+		//点击上传按钮后上传文件
+		$('#addSubmit').click(function () {
+			var filesById = document.getElementById('productFile');
+			var files = $('#productFile');
+			var fileList = files.prop('files');
+			var fileTitle = $('#fileTitle').val();
+			var fileName = $('#uploadFileName').val();
+			if (fileTitle == '') {
+				alertx('请输入视频标题')
+				return;
+			}
+			if (files === '' || files.length == 0 || fileName == '') {
+				alertx('请选择上传文件');
+				return;
+			}
+			$("#uploadFileName").val("");
+			var data = new FormData();
+			var productId = $("#id").val();
+			var fileIds = $("#fileIds").val();
+			data.append('file', fileList[0]);
+			data.append('fileTitle', fileTitle);
+			data.append('fileName', fileName);
+			data.append('productId', productId);
+			data.append('fileIds', fileIds);
+			$('.upload-loading').css("display", "inline");
+			$.ajax({
+				url: "${ctx}/baike/cmBaikeProduct/upload",
+				data: data,
+				type: "POST",
+				processData: false,
+				contentType: false,
+				dataType: "json",
+				success: function (res) {
+					if (res.success) {
+						filesById.value = '';
+						renderFileList(res.productFile);
+						$('.upload-loading').hide();
+					} else {
+						$.jBox.tip(res.msg, 'error');
+						$("#uploadFileName").val(fileName);
+						$('.upload-loading').hide();
+					}
+
+				},
+				error: function (json) {
+
+				}
+			});
+		})
+
+		var fileList = [];
+		var fileIds = '';
+		var files = document.getElementById("productFile"), renderFileList;
+		//选择上传文件后显示文件名称
+		files.addEventListener("change", function (event) {
+			var name = event.target.files[0].name;
+			console.log(name)
+			$('#uploadFileName').val(name);
+		});
+		var fileListDisplay = document.getElementById('file-list-display');
+		renderFileList = function (data) {
+			fileIds += data.id + ',';
+			console.log(fileIds);
+			$('#fileIds').val(fileIds);
+			fileList.push({fileTitle: data.fileTitle, id: data.id, ossUrl: data.ossUrl});
+			fileList.forEach(function (file, index) {
+				var fileDisplayEl = document.createElement("p");
+				var deleteFile = document.createElement("span");
+				var viewFile = document.createElement("span");
+				var viewFileUrl = document.createElement("a");
+				//预览链接
+				viewFileUrl.innerHTML = '预览';
+				viewFileUrl.setAttribute("onclick", "previewVideo('" + file.ossUrl + "')");
+				viewFileUrl.setAttribute("target", "_blank");
+				//预览按钮
+				viewFile.className = 'viewFile';
+				console.log(viewFile);
+				viewFile.setAttribute("class","del");
+				viewFile.appendChild(viewFileUrl);
+				//删除按钮
+				deleteFile.innerHTML = '删除';
+				deleteFile.className = 'deleteFile';
+				console.log(deleteFile);
+				deleteFile.setAttribute("class","del");
+				deleteFile.setAttribute("onclick", "dataDelete(this, " + file.id + ")");
+
+				fileDisplayEl.setAttribute("id", file.id);
+				fileDisplayEl.innerHTML = file.fileTitle;
+				fileDisplayEl.appendChild(viewFile);
+				fileDisplayEl.appendChild(deleteFile);
+				fileListDisplay.appendChild(fileDisplayEl);
+			});
+			fileList.splice(0, fileList.length);
+		};
 	})
 
 	//删除参数
@@ -1024,6 +1264,35 @@
 	function onlynum(obj) {
 		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
 	}
+
+	//删除文件
+	function dataDelete(that, id) {
+		console.log($(that).text());
+		$(that).parent().remove();
+		/*var fileIds = $("#fileIds").val();
+		if (fileIds.indexOf(id)) {
+			fileIds.replace(id + ",", "");
+		}*/
+		$.ajax({
+			url: "${ctx}/baike/cmBaikeProduct/deleteFile",
+			data: {"fileId": id},
+			async: false,
+			type: "POST"
+		});
+	}
+
+	function previewVideo(url) {
+		var url = "${ctx}/archive/cmProductArchiveContent/preview?url=" + encodeURIComponent(url);
+		var title = "视频播放";
+		top.$.jBox("iframe:" + url, {
+			iframeScrolling: 'yes',
+			width: 1000,
+			height: 750,
+			persistent: true,
+			title: title,
+			buttons: {"关闭": '-1'}
+		});
+	}
 </script>
 </body>
 </html>