You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

584 lines
21 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EBook_ImgUploadPrice.aspx.cs" Inherits="TradeManageNew.EBOOK.EBook_ImgUploadPrice" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图片库</title>
<meta name="referrer" content="no-referrer">
</head>
<script src="js/jquery.js"></script>
<script src="js/upload.js"></script>
<link rel="stylesheet" type="text/css" href="css2/New2.css?a=162344" />
<link href="css2/ListNew2.css?a=133" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css3/style.css" />
<script src="js/jquery-2.0.3.min.js" iconfont="true"></script>
<script src="js/Jsequencing.js?a=62" iconfont="true"></script>
<script src="../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../Scripts/Global.js" type="text/javascript"></script>
<script src="../Scripts/WindowLoad.js?t=1" type="text/javascript"></script>
<script src="../Scripts/ajaxfileupload.js" type="text/javascript"></script>
<script src="../Scripts/jquery.url.js" type="text/javascript"></script>
<body>
<script type="text/javascript">
var dragImgUpload = null;
var dragImgUpload2 = null;
function blobToDataURL(blob, callback) {
let a = new FileReader();
a.onload = function (e) { callback(e.target.result); }
a.readAsDataURL(blob);
}
var imgulp = null;
var imgulp2 = null;
var imglist = null;
var id = 0;
var Model = null;
$(document).ready(function () {
ajaxInit(null);
jQuery.extend({
handleError: function (s, xhr, status, e) {
if (s.error) {
s.error.call(s.context || s, xhr, status, e);
}
if (s.global) {
(s.context ? jQuery(s.context) : jQuery.event).trigger("ajaxError", [xhr, s, e]);
}
},
httpData: function (xhr, type, s) {
var ct = xhr.getResponseHeader("content-type"),
xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
data = xml ?
xhr.responseXML : xhr.responseText;
if (xml && data.documentElement.tagName == "parsererror")
throw "parsererror";
if (s && s.dataFilter)
data = s.dataFilter(data, type);
if (typeof data === "string") {
if (type == "script")
jQuery.globalEval(data);
if (type == "json")
data = window["eval"]("(" + data + ")");
}
return data;
}
});
// Is_GYSDept();
id = $.url.param("id");
if (id == undefined) {
id = 0;
}
$("#fileToUploadAppendix").bind("change", function () {
ajaxFileUpload_fileToUploadAppendix();
});
$("#Radio2").bind("click", function () {
$("#tr_pdf").show();
$("#tr_img").hide();
});
$("#Radio1").bind("click", function () {
$("#tr_img").show();
$("#tr_pdf").hide();
});
$("#chk_all2").bind("click", function () {
if ($(this).is(":checked") == true) {
$("#img_ul2 input").prop("checked", true);
$("#img_ul2 input").each(function () {
var index = parseInt($(this).parents(".item").attr("item"));
var thisid = $(this).parents(".item").attr("id");
imgulp2.selectall(thisid, index,1);
});
}
else {
$("#img_ul2 input").prop("checked", false);
$("#img_ul2 input").each(function () {
var index = parseInt($(this).parents(".item").attr("item"));
var thisid = $(this).parents(".item").attr("id");
imgulp2.selectall(thisid, index,0);
});
}
});
$("#chk_all").bind("click", function () {
if ($(this).is(":checked") == true) {
$("#img_ul input").prop("checked", true);
$("#img_ul input").each(function () {
var index = parseInt($(this).parents(".item").attr("item"));
var thisid = $(this).parents(".item").attr("id");
imgulp.selectall(thisid, index,1);
});
}
else {
$("#img_ul input").prop("checked", false);
$("#img_ul input").each(function () {
var index = parseInt($(this).parents(".item").attr("item"));
var thisid = $(this).parents(".item").attr("id");
imgulp.selectall(thisid, index,0);
});
}
});
//dragImgUpload = new DragImgUpload("#drop_area", {
// callback: function (files) {
// //回调函数,可以传递给后台等等
// for (var i = 0; i < files.length; i++) {
// var file = files[i];
// // var img = window.URL.createObjectURL(file);
// let reader = new FileReader() //新建一个FileReader对象
// reader.readAsDataURL(file) //将读取的文件转换成base64格式
// var imgbase64 = "";
// reader.onload = function (e) {
// //将img标签的src换成base64格式并显示出来
// imgbase64 = e.target.result;
// var param = new Object();
// param.umgbase=imgbase64;
// $.ajax({
// type: "POST",
// url: "cp_productservice.asmx/GetImg",
// data: Sys.Serialization.JavaScriptSerializer.serialize(param),
// dataType: 'json',
// success: function (data, status) {
// addimg2(data.d, 0);
// }
// });
// }
// }
// }
//});
dragImgUpload2 = new DragImgUpload("#drop_area2", {
callback: function (files) {
//回调函数,可以传递给后台等等
for (var i = 0; i < files.length; i++) {
var file = files[i];
let reader = new FileReader() //新建一个FileReader对象
reader.readAsDataURL(file) //将读取的文件转换成base64格式
var imgbase64 = "";
reader.onload = function (e) {
//将img标签的src换成base64格式并显示出来
imgbase64 = e.target.result;
var param = new Object();
param.umgbase=imgbase64;
$.ajax({
type: "POST",
url: "EBookService.asmx/GetImg",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: 'json',
success: function (data, status) {
addimg3(data.d, 0);
}
});
}
}
}
});
imgulp2 = new Jsequencing({
listid: "img_ul2",//页面图片列表ID
thumbherf: "",//列表图片前缀
bigherf: "",//原图前缀[同列表图相同时,省略]
jsondata: true,
imgsrcarr: [//图片数据数组
],
});
if (id > 0) {
GetBooksModel();
GetBooksImg();
}
});
var isgys = 0;
function Is_GYSDept() {
$.ajax({
url: "cp_productservice.asmx/Is_GYSDept",
// data: Sys.Serialization.JavaScriptSerializer.serialize(param),
async: false,
success: function (data) {
if (data.d > 0) {
isgys = 1;
$("#img_del,#img_del2").show();
}
}
});
}
var pdfurl = "";
//#region 上传附件
function ajaxFileUpload_fileToUploadAppendix() {
var filename = $("#fileToUploadAppendix").val();
if (filename == "" || filename == undefined) return;
// WindowLoadModel.Show();
$.ajaxFileUpload({
url: '../GlobalAshx/AjaxFileUpLoad.ashx?DirectoryName=ebook',
secureurl: false,
fileElementId: 'fileToUploadAppendix',
dataType: 'json',
success: function (data, status) {
// WindowLoadModel.Hide();
// $("#fileToUploadAppendix").hide();
// console.log(data);
$("#a_pdf").html(data.FileName);
pdfurl = data.FileUrl;
//这里绑定附件列表
$("#fileToUploadAppendix").bind("change", function () {
ajaxFileUpload_fileToUploadAppendix();
});
// alert($("#fileToUploadAppendix").val());
},
error: function (xhr, status) {
if (status != "success") alert("上传失败" + xhr.responseText);
}
});
return false;
}
function GetBooksModel() {
var param = new Object();
param.id=id;
$.ajax({
url: "EBookService.asmx/GetModel_Book",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: "json",
async:false,
success: function (data) {
Model = data.d;
if (data.d != null) {
$("#txt_name").val(Model.bookname);
if (Model.pagetype == "image") {
$("#Radio1").attr("checked","checked");
}
else {
$("#Radio2").attr("checked", "checked");
$("#tr_pdf").show();
$("#tr_img").hide();
}
}
}
});
}
function GetBooksImg() {
var param = new Object();
param.BookId=id;
$.ajax({
url: "EBookService.asmx/GetListBookPagesPrice",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: "json",
async:false,
success: function (data) {
if (data.d != null) {
$(data.d).each(function () {
addimg3(this.pageimg, 0);
});
}
}
});
}
function addimg2(ig, id) {
imgulp.addimgarr([
{ src: ig, title: "", id: id }
])
}
function addimg3(ig, id) {
imgulp2.addimgarr([
{ src: ig, title: "", id: id }
])
}
function GetSort() {
if ($("#txt_name").val() == "") {
alert("请填写样本名称");
return;
}
if ($("#txt_sort").val() == "") {
alert("请填写产品分类");
return;
}
if (Model == null) {
Model = new Object();
Model.id = 0;
}
Model.bookname = $("#txt_name").val();
Model.sortid = $("#txt_sort").val();
Model.remark = $("#txt_remark").val();
Model.pagetype = "image";
if ($("#Radio2").is(":checked") == true)
Model.pagetype = "pdf";
Model.sort = 1;
Model.isuse = 1;
var arr2 = imgulp2.getnewarr();
var sort = 1;
var simlist = new Array();
$(arr2).each(function () {
var smd = new Object();
smd.id = 0;
smd.pageimg = this.src;
smd.Type = 2;
smd.sort = sort;
sort++;
Array.add(simlist, smd);
// alert(this.id);
});
var param = new Object();
param.model = Model;
param.list2=simlist;
$.ajax({
url: "EBookService.asmx/Save_BooksImgPrice",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: "json",
async:false,
success: function (data) {
alert("保存成功");
window.location = "EBookList.aspx";
}
});
}
function addimg() {
imgulp.addimgarr([
{ src: 'a1.png?id=1' }
])
}
function deleteimg() {
if ($("#img_ul input:checked").length == 0) {
alert("请选择要删除的图片");
return;
}
if (window.confirm('确定要删除这些图片吗?') == false) return;
imgulp.datadel();
}
function deleteimg2() {
if ($("#img_ul2 input:checked").length == 0) {
alert("请选择要删除的图片");
return;
}
if (window.confirm('确定要删除这些图片吗?') == false) return;
imgulp2.datadel();
}
function SaveImgList2() {
if ($("#img_ul input:checked").length == 0) {
alert("请选择要下载的图片");
return;
}
var list = new Array();
$("#img_ul input:checked").each(function () {
var url = $(this).parent().find("img").attr("src");
if (url!= "") {
var md = new Object();
md.Img_url = url;
Array.add(list, md);
}
});
$("#a_tp2").hide();
var param = new Object();
param.list = list;
param.code = $("#txt_code").val();
$.ajax({
url: "cp_productservice.asmx/SaveImgRar",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: "json",
//async:false,
success: function (data) {
if (data.d != null) {
alert("打包完成,可以点击下载");
$("#a_tp2").show();
$("#a_tp2").attr("href", data.d);
// var params = { FilePath: data.d, FileName: "图片导出.rar" };
// Window.location ="../GlobalAshx/DownFile.ashx?" + jQuery.param(params);
}
}
});
}
function SaveImgList() {
if ($("#img_ul2 input:checked").length == 0) {
alert("请选择要下载的图片");
return;
}
var list = new Array();
$("#img_ul2 input:checked").each(function () {
var url = $(this).parent().find("img").attr("src");
if (url!= "") {
var md = new Object();
md.Img_url = url;
Array.add(list, md);
}
});
$("#a_tp").hide();
var param = new Object();
param.list = list;
param.code = $("#txt_code").val();
$.ajax({
url: "cp_productservice.asmx/SaveImgRar",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: "json",
//async:false,
success: function (data) {
if (data.d != null) {
alert("打包完成,可以点击下载");
$("#a_tp").show();
$("#a_tp").attr("href", data.d);
// var params = { FilePath: data.d, FileName: "图片导出.rar" };
// Window.location ="../GlobalAshx/DownFile.ashx?" + jQuery.param(params);
}
}
});
}
function GetListPDFImg() {
if (pdfurl == "") {
alert("请先选择上传的pdf");
return;
}
var param = new Object();
param.url = pdfurl;
$.ajax({
url: "EBookService.asmx/GetListPDFImg",
data: Sys.Serialization.JavaScriptSerializer.serialize(param),
dataType: "json",
//async:false,
success: function (data) {
if (data.d != null) {
$(data.d).each(function () {
addimg3(this.pageimg, 0);
});
}
}
});
}
function GetBack() {
window.location = "EBookList.aspx";
}
</script>
<table width="100%" class="tableAll">
<tr>
<td colspan="2" align="center">
<h3><font color="blue" style="font-size:20pt">报价单</font></h3>
</td>
</tr>
<tr>
<td class="f1" width="20%">样本名称:</td>
<td>
<input id="txt_name" type="text" disabled="disabled" />
</td>
</tr>
<tr>
<td class="f1" width="20%">上传资料类型:</td>
<td>
<input id="Radio1" checked="true" name="lx" type="radio" value="V1"/>图片上传<input id="Radio2" name="lx" type="radio" value="V1" />PDF文件上传 </td>
</tr>
<tr id="tr_img"><td class="f1" >详情图:</td>
<td>
<h3><font color="red">可将要上传的图片拖拽到下框中,图片可以拖动排序</font></h3>
<div id="drop_area2"></div>
</td>
</tr>
<tr id="tr_pdf" style="display:none"><td class="f1" >选择pdf文件</td>
<td>
<input id="fileToUploadAppendix" accept="pdf" type="file" name="fileToUploadAppendix" />
<a id="a_pdf" style="display:none"></a>
<button onclick="GetListPDFImg();" class="layui-btnblue" id="img_pdf">转成图片</button>
</td>
</tr>
<tr>
<td colspan="2"> <div class=""><input class="checkbox" name="" type="checkbox" value="全选" id="chk_all2" />全选 <button onclick="deleteimg2();" class="layui-btnblue" id="img_del2">批量删除</button> <button onclick="SaveImgList();" class="layui-btnblue" style="display:none">打包图片</button> <a id="a_tp" href="#" style="color:blue;cursor:pointer;display:none">点击下载图片</a> <font color="red">图片可以左右拖动保存后改变顺序</font>
</div>
<div id="img_ul2" class="cl imglist" ></div>
</td>
</tr>
<tr><td align="center" colspan="2"> <button onclick="GetSort()" class="layui-btnblue">保存</button> &nbsp;&nbsp;&nbsp;&nbsp; <button onclick="GetBack()" class="layui-btnblue">返回</button></td></tr>
</table>
</body>
</html>