123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /**
- * Created by Administrator on 2018/1/3 0003.
- */
- function getparam(e) {
- e = e.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var t = "[\\?&]" + e + "=([^&#]*)", n = new RegExp(t), a = n.exec(window.location.search);
- return null == a ? "" : decodeURIComponent(a[1].replace(/\+/g, " "))
- }
- $(document).ready(function(){
- loadPage();
- $(".titleInput").val(" "+getparam("title"));
- $("#iUserLoginForm").submit(function () {
- $("#iUserLoginForm").ajaxSubmit({
- success: function (data) {
- if(data.status == "SUCCESS"){
- var htmlStr='';
- htmlStr='<div class="pptimgcontentDiv">'+
- '<img src="'+data.record.imgurl+'"/>';
- if(data.record.filepath == null || data.record.filepath== "javascript:void(0)"){
- htmlStr+= '<input type="text" value="" class="input_text" id="'+data.record.id+'" name="filepath">';
- }else{
- htmlStr+= '<input type="text" value="'+data.record.filepath+'" class="input_text" id="'+data.record.id+'" name="filepath">';
- }
- htmlStr+= '<button class="btn-self" onclick="toDelete(\''+data.record.id+'\',this)">删除</button>'+
- '</div>';
- $(".imgContent").prepend(htmlStr);
- $("#sc").prepend(","+data.record.id);
- if($(".pptimgcontentDiv").size()>=3){
- $(".pptimgcontentDivPlus").remove();
- }
- $("#iUserLogin").dialog("close");
- $("#img1").val("");
- }
- }
- });
- return false;
- });
- $("#iUserLogin").dialog({
- modal: true,
- autoOpen:false,
- closeable:false,
- bgiframe:true,
- height:300,
- width:500,
- closeOnEscape:false,
- draggable:false,
- resizable:false,
- title:"上传图片",
- open:function (event, ui) {
- $(".ui-dialog-titlebar-close").hide();
- },
- buttons:{
- "保存":function () {
- if($("#img1").val()==""){
- alert("上传图片不能为空!");
- return false;
- }
- document.getElementById("iUserLoginForm").action=" "+baseConfig.URL.addImgList + "";
- $("#iUserLoginForm").submit();
- },
- "关闭":function () {
- $(this).dialog("close");
- }
- }
- })
- });
- function loadPage(obj) {
- $.ajax({
- url: " "+baseConfig.URL.pptimgList + "",
- type: "POST",
- async: false,
- cache: false,
- data: {name:getparam("name")},
- success:function (data) {
- if(data.status=="SUCCESS"){
- $(".imgContent").html('');
- $("#sc").html('');
- $("#sc").html('');
- $.each(data.list,function (name,value){
- var htmlStr='';
- htmlStr='<div class="pptimgcontentDiv">'+
- '<img src="'+value.imgurl+'"/>';
- if(value.filepath == null || value.filepath == "javascript:void(0)"){
- htmlStr+= '<input type="text" value="" class="input_text" id="'+value.id+'" name="filepath">';
- }else{
- htmlStr+= '<input type="text" value="'+value.filepath+'" class="input_text" id="'+value.id+'" name="filepath">';
- }
- htmlStr+= '<button class="btn-self" onclick="toDelete(\''+value.id+'\',this)">删除</button>'+
- '</div>';
- $(".imgContent").append(htmlStr);
- $("#sc").prepend(","+value.id);
- });
- if (data.list.length<3){
- $(".imgContent").append('<div class="pptimgcontentDivPlus" onclick="showFileuploadDiv()">+</div>');
- }
- }
- }
- });
- }
- function toDelete(id,btn) {
- $.ajax({
- url: " "+baseConfig.URL.deleteList + "",
- type: "POST",
- async: false,
- cache: false,
- data: {id:id},
- success:function (data) {
- if(data.status=="SUCCESS"){
- if($(".pptimgcontentDivPlus")[0] == undefined ){
- $(".imgContent").append('<div class="pptimgcontentDivPlus" onclick="showFileuploadDiv()">+</div>');
- }
- $(btn).parent("div").remove();
- }
- }
- });
- }
- function toHrefPage() {
- if($(".titleInput").val()==""){
- alert("标题不能为空!");
- return;
- }
- var filePath="";
- var ids = $("#sc").text();
- var arr = ids.split(",");
- for(var i=0;i<arr.length;i++){
- if($("#"+arr[i]).val() ==""){
- if(i==0){
- filePath+="undefined";
- }else{
- filePath+=",undefined";
- }
- }else{
- if(i==0){
- filePath+=$("#"+arr[i]).val();
- }else{
- filePath+=","+$("#"+arr[i]).val();
- }
- }
- }
- location.href = baseConfig.URL.hrefPage + "?ids=" + ids+ "&title=" + $(".titleInput").val()+"&filePath="+filePath;
- }
- function showFileuploadDiv() {
- $("#name").val(getparam("name"));
- $("#iUserLogin").dialog("open");
- }
|