123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- /**
- * Created by 14381 on 2017/12/04.
- */
- var editor;
- $(document).ready(function() {
- editor=UE.getEditor('content', {
- toolbars: [
- ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript',
- 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor',
- 'backcolor', 'insertorderedlist', 'insertunorderedlist','simpleupload',
- 'selectall', 'cleardoc',
- 'justifyleft', 'justifyright','justifycenter', 'justifyjustify',
- 'fontfamily', 'fontsize', 'paragraph']
- ]
- });
- $("#qa_form").submit(function () {
- var flad = checkForm();
- if(!flad){
- return false;
- }
- $("#changeTJ").attr("style","display: none");
- $("#addIJ").attr("style", "display: none");
- $("#projectBtn").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- $("#qa_form").ajaxSubmit({
- success: function (data) {
- if(data.status == "SUCCESS"){
- Showbo.Msg.alert("操作成功");
- setTimeout('myrefresh()',1000); //指定1秒刷新一次
- } else if(data.status == "ERROR"){
- Showbo.Msg.alert("操作失败");
- var thisURL = document.URL
- var version = thisURL.substring(thisURL.indexOf('=') + 1);
- if (version == thisURL) {
- $("#changeTJ").attr("style", "display: none");
- $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- } else {
- $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- $("#addIJ").attr("style", "display: none");
- }
- $("#projectBtn").attr("style", "display: none");
- } else if(data.status == "BEYOND"){
- Showbo.Msg.alert(data.desc);
- }
- },
- });
- return false;
- });
- typeSelectList($("#atype").val(),"atype",-1);
- getmanu();
- });
- function myrefresh(){
- window.location.href ="/iflytek/activitynews.html"
- }
- function getmanu() {
- var thisURL = document.URL
- var version = thisURL.substring(thisURL.indexOf('=') + 1);
- if (version == thisURL) {
- $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
- $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- } else {
- $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
- }
- $("#changeid").val(version);
- $.ajax({
- url: " " + baseConfig.URL.findByid + "",
- type: "POST",
- async: false,
- cache: false,
- data: {id: version},
- success: function (data) {
- if (data.status == "SUCCESS") {
- $("#title").val(data.rec.title);
- $("#atype").val(data.rec.atype);
- $("#creattime").val(data.rec.creattime);
- $("#content").html(data.rec.content);
- typeSelectList("01","atype",data.rec.atype);
- var getfileurl = data.rec.fileurl;
- var imgurl = data.rec.imgurl;
- if (imgurl != null && imgurl != "") {
- var indeximg = imgurl.lastIndexOf("/");
- var fileimgname = imgurl.substr(indeximg + 1);
- $("#firstimg").val(fileimgname);
- }
-
- if (getfileurl != null && getfileurl != "") {
- var index = getfileurl.lastIndexOf("/");
- var filename = getfileurl.substr(index + 1);
- $("#other0").val(filename);
- }
- }
- }
- });
-
- }
- function addnoticenews() {
- document.getElementById("qa_form").action=" "+baseConfig.URL.addnews + "";
- $("#qa_form").submit();
- }
- function changenoticenews() {
- document.getElementById("qa_form").action=" "+baseConfig.URL.updatenews + "";
- $("#qa_form").submit();
- }
- function checkForm(){
- var content= editor.getContentTxt();
- if (content == "" || content==null) {
- Showbo.Msg.alert("请填写内容!");
- return false;
- }
- if ($.trim($('#title').val()) == "" ||$('#title').val()==null) {
- Showbo.Msg.alert("请填写标题!");
- return false;
- }
- if ($.trim($('#atype').val()) == "" ||$('#atype').val()==null) {
- Showbo.Msg.alert("请选择分类!");
- return false;
- }
- return true;
- }
- var count = 0;
- var num = 0;
- function PreviewImage(imgFile) {
- var length = $("#sc").children("div").length;
- if(length >=6){
- $("#csgo1").html("附件只可以上传5张");
- $("#csgo0").attr("style", "display:block");
- return false;
- }
- //定义路径var path;
- var name= $(imgFile).val().split("\\").pop();
- document.getElementById("other"+count+"").style.display="none";
- //添加显示图片的HTML元素
- count += 1;
- $(".img-cont"+num).append("<input id='img"+count+"' width='220' height='110' value='"+name+"' " +
- " style='width:300px;border:none;' /><button onclick='del("+num+")' " +
- "style='background: #fff;color: #1d4795;height: 20px;padding: 0 20px;margin-left: 40px;'>删除</button>");
- num += 1;
- $("#sc").append(" <div class='img-cont"+num+" img_up ad-btn'><input style='color: #fff;border:none;' " +
- "type='file' name='other"+count+"' id='other"+count+"' class='upload-input' onchange='PreviewImage(this)'/>" +"</div>");
- }
- function del(cl) {
- $(".img-cont"+cl).remove();
- }
- function checkFileExt(filename)
- {
- var flag = false; //状态
- var arr = ["jpg","png","jpeg","bmp"];
- //取出上传文件的扩展名
- var index = filename.lastIndexOf(".");
- var ext = filename.substr(index+1);
- //循环比较
- for(var i=0;i<arr.length;i++)
- {
- if(ext == arr[i])
- {
- flag = true; //一旦找到合适的,立即退出循环
- break;
- }
- }
- //条件判断
- if(!flag){
- Showbo.Msg.alert("请上传正确的图片格式(jpg jpeg png bmp)!");
- return false;
- }
- }
- function onChangeSelect(){
- typeSelectList($("#atype").val(),"atype",-1);
- }
- function typeSelectList(fcode,objid,objval){//
- $.ajax({
- url: baseConfig.URL.selectType + "",
- type: "POST",
- data:{fcode:fcode},
- cache: false,
- success:function (res) {
- var options = "";
- $.each(res.selectList, function (i, value) {
- options += "<option value=\"" + value.code + "\">" +value.name + "</option>";
- });
- $("#"+objid).html(options);
- if(objval!=-1){
- $("#"+objid).val(objval);
- }
- delete options;
- },
- complete:function (XHR, TS) {
- // $('.ui-dialog-buttonpane').find('button:contains("保存添加信息")').removeAttr("disabled");
- },
- error:function (XMLHttpRequest, textStatus, errorThrown) {
- alert(textStatus);
- }
- });
- }
|