123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- var fd_id = (window.location.href).split('?')[1];
- $(function(){
- //应急制度文件分类FILE_CLASSIFY_230
- $("#FILE_CLASSIFY_230").initCanstSelect('BM_FILE_CLASSIFY');
- $("#FILE_CLASSIFY_230").render();
- //$('#fileDiv').getUploadFileContent();
-
- $('#CHANGE_TYPE').data("data",changetype);
- $("#CHANGE_TYPE").render();
-
- var opts = {
- //swf: 'baiduUpload/Uploader.swf',
- //server: 'Upload',
- fileNumLimit: 1,
- fileSizeLimit: 200 * 1024 * 1024, // 200 M
- fileSingleSizeLimit: 50 * 1024 * 1024, // 50 M
- pick: {
- id: '#filePicker',
- label: '点击选择文件',
- name : 'file'
- },
- dnd: '#dndArea',
- paste: '#uploader',
- chunked: false,
- chunkSize: 512 * 1024,
- disableGlobalDnd: true
- };
-
- $('#fileDiv').getAsyncUploadFileContent(opts);
-
-
- getFileList(fd_id,1);
- });
- //单位ID
- var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
- var getUser_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id()+""; //登录人ID
- var parent_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- var changetype = {"list":[
- {value:"2",key:"更新",suggest:""},
- {value:"3",key:"撤销",suggest:""}]
- };
- var time = "";
- var COLUMN_1_230="0";
-
- //修改表单信息,获取记录
- if((window.location.href).indexOf('?')>-1){
- var fd_id = (window.location.href).split('?')[1];
- var url = $.pathname() + '/ws/crud/CRUDService/getDataById/';
- var params = {
- classid : '230',
- objectID : fd_id
- };
-
- $.ajax({
- url : url,
- type : 'post',
- timeout : 60000,
- data : params,
- dataType : 'json',
- success : function(data){
- var dataNow = data.FILE_ADD_DATE_230;
- COLUMN_1_230 = data.COLUMN_1_230;//版本标志
- COLUMN_3_230 = data.COLUMN_3_230;//上传标志
- COLUMN_4_230 = data.COLUMN_4_230;//上个文件ID
-
- //新增文件,控制必传附件
- if(COLUMN_1_230=="0"){
- getFileList(fd_id,1);
- }
-
- //修改文件后新增预案的情况,也必有附件
- if(COLUMN_3_230=="1"&&COLUMN_4_230!="0"){
- getFileList(fd_id,1);
- }
-
- //纯修改
- if(COLUMN_3_230=="0"&&COLUMN_1_230!="0"){
- getFileList(COLUMN_4_230,1);
- }
- $("#FILE_ADD_DATE_230").val(dataNow);
- $('#fillForm').ajaxWrite({data:data});
- $('#fillForm input[name="classid"]').val('230');
- $form=$("#fillForm");
-
- },
- error : function(e){
- $.messager.alert('系统提示信息', '访问服务失败!', 'error');
- }
- });
- }
-
-
- var $form ="";
- var file ="";
-
- //取系统时间:年月日时分秒
- var date = allGetServerTime();
- var seperator1 = "";
- var seperator2 = "";
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- time = date.getFullYear() + seperator1 + month + seperator1 + strDate
- + "" + date.getHours() + seperator2 + date.getMinutes()
- + seperator2 + date.getSeconds();
-
- //删除原来信息
- function del(){
- // 删除记录
- $.post($.pathname() +"/ws/crud/CRUDService/delete/", {
- "objectIDs" : fd_id,
- classid : 230
- }, function(result) {
- if (result.Msg.sucsess == true) {
- //$.messager.alert("废止上一版本制度文件",null,null,null,-1);
- // 刷新表格数据
- g.rend();
- } else {
- top.Dialog.alert("废止失败!");
- }
- }, "json");
- }
- //表单验证
- function validateForm(containerId){
- var title = $("#FILE_TITLE_230").val();
- var classify = $("#FILE_CLASSIFY_230").val();
- var filedate = $("#FILE_ADD_DATE_230").val();
-
- var valid = $(containerId).validationEngine({returnIsValid: true});
- if(valid == true){
- var change = $('#CHANGE_TYPE').val();
- if(change=="3"){
- var ids = (window.location.href).split('?')[1]; //获取的主键ID
- top.Dialog.confirm("确定要撤销吗?|撤销", function() {
- // 删除记录
- $.post($.pathname() +"/ws/crud/CRUDService/delete/", {
- "objectIDs" : ids,
- classid : 230
- }, function(result) {
- if (result.Msg.sucsess == true) {
- $.messager.alert("撤销成功",null,null,null,-1);
- var url = "/nwyj/page/business/am/file/"+"FileList_AM.jsp";
- top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
- //parent.document.getElementById("iframeChild2").setAttribute("src", ""+encodeURI(url));
- } else {
- top.Dialog.alert("删除失败!");
- }
- }, "json");
-
- });
- return;
- }else{
- //取上传附件容器的值,如果为空,则为单纯修改预案基本信息。如不为空,则为修订预案,重新上传预案。
- var file = $("#uploaderFileName").val();
- if(file!=null&&file!=undefined&&file!=""){
- //先删除原来记录。
- del();
- $("#fd_id230").val("");
- //再新增记录
- add();
-
- }else{
-
- //变更类型
- $('#CHANGE_TYPE_214').val(change);
- //单位ID
- $("#UNITS_214").val(parent_id);
- //发布状态、上报状态写死为0
- edit();
- }
- }
- }else{
- // top.Dialog.alert('请检查标红输入框!');
- if(title==""){
- top.Dialog.alert('标题填写不正确,请按要求填写!');
- return;
- }
- if(classify==""){
- top.Dialog.alert('日期填写不正确,请按要求填写!');
- return;
- }
- if(filedate==""){
- top.Dialog.alert('标题填写不正确,请按要求填写!');
- return;
- }
- }
- }
- function add(containerId){
-
- var file = $("#uploaderFileName").val();
- var ldot = file.lastIndexOf(".");
- var type ="."+ file.substring(ldot + 1);
- var pos=file.lastIndexOf("\\");
- var filename = file.substring(pos+1,ldot);
-
- var valid = $(containerId).validationEngine({returnIsValid: true});
- if(valid == true){
-
- $("#COLUMN_3_230").val("1");
- $("#COLUMN_4_230").val(fd_id);
- $("#VERSION_ID_230").val(filename+time+type);
- $("#FILE_STATUS_230").val(2);
- //存上一个预案的主键 PLAN_BIAOZHI_214
- if(COLUMN_1_230=="0"){
- $("#COLUMN_1_230").val(fd_id);
- }else{
- $("#COLUMN_1_230").val(COLUMN_1_230);
- }
-
- var $form=$("#fillForm");
- var formValue = $form.serialize();
- var url = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
- //fileToSaveAdd($form,null,null,url);
- $.request.add(url,formValue,function(data){
- closeProgress();
- top.Dialog.alert("修改成功!");
- var url = "/nwyj/page/business/am/file/"+"FileList_AM.jsp";
- top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
- });
- }else{
-
- top.Dialog.alert('请检查标红输入框!');
- }
- }
-
- //修改
- function edit(){
- $("#COLUMN_3_230").val("0");
- //上一个版本的预案的ID
- $("#COLUMN_4_230").val(fd_id);
- var formValue = $('#fillForm').serialize();
- var url = $.pathname() + '/ws/crud/CRUDService/update';
-
- $.ajax({
- url : url,
- type : 'post',
- data : formValue,
- dataType : 'text',
- timeout : 60000,
- success : function(data){
- top.Dialog.alert('修改成功!',null,null,null,-1);
- var url = "/nwyj/page/business/am/file/"+"FileList_AM.jsp";
- top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
- /* window.location.href="FileList_AM.jsp";
- var url = "/nwyj/page/business/am/file/"+"FileList_AM.jsp";
- document.getElementById("iframeChild2").setAttribute("src", ""+encodeURI(url));*/
- },
- error : function(){
- $.messager.alert('操作失败');
- }
- });
- }
-
- function goBack() {
- var url = "/nwyj/page/business/am/file/"+"FileList_AM.jsp";
- top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
- }
-
- //重置
- function resetSearch(){
- document.location.reload();
- }
- $.messager=top.Dialog;
|