fs-danaus
2024-02-21 0a4f165eec7585da85a0bd58444efb5eac06d35f
提交 | 用户 | age
7f7112 1 <%@ page import="com.yc.sdk.shopping.util.SettingKey" %><%--
X 2   Created by IntelliJ IDEA.
3   User: xinyb_
4   Date: 2022-02-28
5   Time: 16:34
6   To change this template use File | Settings | File Templates.
7 --%>
8 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 <%
10     String hostUrl = SettingKey.getHostUrl(request);
11 %>
12 <html>
13 <head>
adafe0 14     <title>格线附件上传控件</title>
7f7112 15     <link rel="stylesheet" type="text/css"
X 16           href="<%=hostUrl%>/js/bootstrap/v5.1.3/css/bootstrap.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/v5.1.3/css/bootstrap.css")%>">
17     <link rel="stylesheet" type="text/css"
18           href="<%=hostUrl%>/js/bootstrap/v5.1.3/icons/font/bootstrap-icons.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/v5.1.3/icons/font/bootstrap-icons.css")%>">
19     <link rel="stylesheet" type="text/css"
20           href="<%=hostUrl%>/js/bootstrap/fileinput/css/fileinput.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/fileinput/css/fileinput.css")%>">
21     <link rel="stylesheet" type="text/css"
22           href="/general/Viewer/css/viewer.min.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/general/Viewer/css/viewer.min.css")%>">
23     <script type="text/javascript"
24             src="<%=hostUrl%>/help/js/JQuery-3.6.0.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/help/js/JQuery-3.6.0.js")%>"></script>
25     <script type="text/javascript"
26             src="<%=hostUrl%>/js/bootstrap/v5.1.3/js/bootstrap.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/v5.1.3/js/bootstrap.js")%>"></script>
27     <script type="text/javascript"
28             src="<%=hostUrl%>/js/bootstrap/fileinput/js/fileinput.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/fileinput/js/fileinput.js")%>"></script>
29     <script type="text/javascript"
30             src="<%=hostUrl%>/js/bootstrap/fileinput/js/locales/zh.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/fileinput/js/locales/zh.js")%>"></script>
31     <script type="text/javascript"
32             src="/general/Viewer/js/viewer.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/general/Viewer/js/viewer.min.js")%>"></script>
33     <style>
34         .image {
35             text-align: center;
36             /*width: calc(100% - 100px);*/
37             height: calc(100% - 150px);
38             margin-top: 50px;
39         }
40
41         .image img {
42             /*max-width: calc(100% - 200px);*/
43             height: 100%;
44         }
45
46         .hide {
47             display: none;
48         }
49
50         .fileInput {
51             margin: 30px;
52         }
53
54         /*.krajee-default.file-preview-frame .kv-file-content {*/
55         /*    width: auto !important;*/
56         /*    height: 110px !important;*/
57         /*}*/
58
59         .file-preview {
60             min-height: 150px;
61         }
62
63         .file-drop-zone {
64             min-height: auto !important;
65             border: 0px dashed white !important;
66             cursor: pointer;
67         }
68
69         .file-drop-zone .file-drop-zone-title {
70             padding: 30px 10px !important;
71             font-size: 1em;
72         }
73
74         .file-drop-zone div {
75             cursor: pointer !important;
76         }
77
78         .file-footer-buttons .btn-sm {
79             padding: 0.1rem 0.1rem !important;
80             margin-top: 5px !important;
81         }
82
83         .kv-file-content html {
84             overflow: hidden;
85         }
86
87         .file-drop-zone .file-preview-thumbnails .kv-preview-thumb {
88             margin: 0px 5px !important;
89             border-radius: 6px;
90         }
96ac61 91         .batchDowCss{
X 92             width: 100%;
93             height: 24px;
94             line-height:0px!important;
9826b3 95             font-size: 0.8rem!important;
96ac61 96         }
ffddb0 97         /*  控制附件浏览现在次数的样式  */
X 98         .kv-zoom-actions{
99             max-width: 500px;
100             display: flex;
101             justify-content: space-between;
102             align-items: center;
103             flex-direction: row;
104         }
7f7112 105     </style>
X 106 </head>
107 <body>
108 <div style="margin: 5px;padding: 5px">
109     <div class="image hide">
110         <img id="bimges" src="" alt="">
111     </div>
112     <div class="fileInput hide">
113         <input id="file-input" name="file-input" value="" type="file">
114         <input id="file-inputv" type="hidden" value="">
115     </div>
116 </div>
117 <script>
118     //加密
27db5c 119     var isFileInputImage;
7f7112 120     const rsakey = {
X 121         pubkey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkRupiYcKVGGUtDBDoR1t/1zm3ZtZgnte39iTJW6hlqjdY0UagKjpNiIv7J6XjtgfX7SgsR4AWnivqQHAICIvdPKfGZZzIs62OQ19MqrDTMoB/LvK5teNWhClv23WMUfRbP+EHgprT6hTw8U5apw1IB6i/y57NkLav792wiYBYRU4X45NoTaT+aiTSLFEflbfm94EXnhSS3vFkBmrZGy5BRNI8gmzafroslGx2Hk90CqlNdeKYxgZQ6xtvj+u33yrszWvPT6F9fsJT8aMjtvH050iYKRVct+x6Q7VRJgCI4MgvAexnTKdxW54YzvXCuO5bDiy5la7CgerWkTAq9dzXwIDAQAB"
122     };
e44ea2 123     let arrayFileType = {};//保存上传返回的附件uuid;seq及文件类型
0a4f16 124     let arrayFileSeq = {};//保存上传返回的附件uuid;seq及文件名称,用于删除时根据文件名称匹配到seq
F 125     var fileUploadCount = 0;//保存附件总数
7f7112 126     //渲染出附件界面出来9,19
X 127     const BootstrapFileInputOption = function (g) {
128         let o = {
129             e: $('#file-input'),
130             grid: g,
131             option: {//属性
132                 uploadUrl: '#',   // String,用于上传处理操作的URL(通常是基于Ajax的处理)
133                 language: 'zh',   // 语言
134                 uploadAsync: false,   // bool是否多文件批量上传将并行异步/。默认为true
135                 showCaption: false,//是否显示被选文件的简介
136                 showBrowse: false,//是否显示文件浏览按钮
96ac61 137                 showBatchDownload:true,//是否显示批量下载按钮
7f7112 138                 showUpload: false,//是否显示上传按钮
X 139                 showCancel: false,//是否显示取消按钮
140                 showRemove: false,//是否显示移除按钮
141                 showDrag: false,//是否显示拖动按钮
142                 showClose: false,//是否显示关闭按钮
143                 dropZoneEnabled: true,   //是否显示拖拽区域
144                 browseOnZoneClick: true,   //布尔值,是否在点击预览区域时触发文件浏览/选择。默认为false
145                 showUploadedThumbs: true,   // 是否在预览窗口中持续显示已经上传的文件缩略图(用于ajax上传),直到按下删除/清除按钮
146                 maxFilesNum: 10,   // 上传最大的文件数量
147                 maxFileCount: 0,   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
148                 isNine: false,   // 19类型就为false,9类型就为true,下面有判断
149                 validateInitialCount: false,   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
150                 overwriteInitial: true,   // 是否要覆盖初始预览内容和标题设置
151                 initialPreviewAsData: true,
152                 allowedFileExtensions: null,//允许上传的文件扩展名列表。默认情况下设置为 null
153                 dropZoneTitle: '点击或拖拽文件',
154                 dropZoneClickTitle: '',
0a4f16 155                 multiple: g.type == 9 ? false : true,//by danaus 2024-02-19 17:39
7f7112 156                 layoutTemplates: {
X 157                     indicator: ''//去掉上传状态图标
158                     , actionUpload: ''//去除缩略图中文件上传操作按钮的模板
159                     , actionDrag: ''//去掉缩略图拖动图标
160                     , footer: '<div class="file-thumbnail-footer" style="height: auto">\n' +
161                         '    {actions}\n' +
162                         '</div>'
27db5c 163                 },
X 164                 preferIconicPreview: true,
165                 previewFileIconSettings: {
166                     'doc': '<i class="bi bi-filetype-doc" style="color: #3b93e7"></i>',
167                     'xls': '<i class="bi bi-filetype-exe" style="color: #479347"></i>',
168                     'ppt': '<i class="bi bi-filetype-ppt" style="color: #ea500a"></i>',
169                     'pdf': '<i class="bi bi-filetype-pdf" style="color: red"></i>',
170                     'zip': '<i class="bi bi-file-earmark-zip" style="color: #2a7e77"></i>',
171                     'htm': '<i class="bi bi-filetype-html" style="color:#369584"></i>',
172                     'txt': '<i class="bi bi-filetype-txt" style="color: #5d5a5a"></i>',
173                     'mov': '<i class="bi bi-film"></i>',
174                     'mp3': '<i class="bi bi-filetype-mp3"></i>'
175                 },
176                 previewFileExtSettings: {
177                     'doc': function (ext) {
178                         return ext.match(/(doc|docx)$/i);
179                     },
180                     'xls': function (ext) {
181                         return ext.match(/(xls|xlsx)$/i);
182                     },
183                     'ppt': function (ext) {
184                         return ext.match(/(ppt|pptx)$/i);
185                     },
186                     'zip': function (ext) {
187                         return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
188                     },
189                     'htm': function (ext) {
190                         return ext.match(/(htm|html)$/i);
191                     },
192                     'txt': function (ext) {
193                         return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
194                     },
195                     'mov': function (ext) {
196                         return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
197                     },
198                     'mp3': function (ext) {
199                         return ext.match(/(mp3|wav)$/i);
200                     }
7f7112 201                 },
879d54 202                 isNodragging:false,//自定义属性,在只读状态是否可以执行拖拽
7f7112 203                 //自定义按钮(权限)
X 204                 otherActionButtons: '<button type="button" onclick="top.mylockFile(this)" ' +
205                     'class="kv-file-lock btn btn-sm btn-kv btn-default btn-outline-secondary"' +
206                     'title="权限"{dataKey}><i class="bi-shield-lock"></i></button>',
207                 fileActionSettings: {//用于在预览窗口中为新选择的文件缩略图设置文件操作的配置
208                     showUpload: false,//是否在缩略图中显示上传按钮
209                     showZoom: true
210                 },
211                 // usePdfRenderer: true,//启动自定义的内部插件,false值或不设置这个属性将是默认的插件
212                 // pdfRendererUrl: '/general/pdf/web/viewer.jsp',//预览pdf格式的插件路径
213                 initialPreview: [],   // 字符串或者数组,要显示的初始预览内容
214                 initialPreviewConfig: [],   // 数组,为每个initialPreview条目(就是initialPreview中的每个预览)设置重要属性的配置
215                 showPreview: true,   // 布尔值,是否显示文件预览。默认值为true
216                 maxFileSize: 0//允许上传的文件大小(默认为0,不限制)
217             },
218             fileInput: function () {//渲染,并且绑定事件
219                 let F = this.e;
220                 let g = this.grid;
009fd3 221                 let Event=this;
7f7112 222                 F.fileinput(this.option).on("filebatchselected", function (event, files) {
X 223                     //触发上传功能
224                     F.fileinput('upload');
225                 }).on('filebatchuploadsuccess', function (event, data) {
226                     // 此事件仅在ajax上传且文件批量上传成功之后触发
0a4f16 227                     //debugger;
7f7112 228                     if (g) {
0a4f16 229                         fileUploadCount += data.files.length;
7f7112 230                         let tmp = {};
X 231                         let v = $('#file-inputv');
232                         let oldKey = v.val();// 旧的值
233                         let newKey = data.response.uuid ? data.response.uuid + ";" : "";   // 新的值
0a4f16 234                         arrayFileSeq = JSON.parse(data.response.seqMap);
F 235                         arrayFileType = JSON.parse(data.response.fileExtMap);
7f7112 236                         if (oldKey != "") {
X 237                             let keys = oldKey.split(";");
238                             for (let i = 1; i < keys.length; i++) {
239                                 newKey = newKey.replace(";" + keys[i] + ";", ";");
240                             }
241                         }
242                         tmp.key = newKey;
243                         tmp.type = data.response.type;
244                         // tmp.filedId = name;
245                         tmp.oldKey = oldKey;
246                         v.val(data.response.uuid ? data.response.uuid + ";" : "")
247                         data.thumbs.attr("data-key", JSON.stringify(tmp));
248                         let unId = data.response.uuid ? data.response.uuid : "";
249                         let grid = g.id;
e44ea2 250                         let obj = unId + ";" + data.response.fileType;//  by danaus 2020/4/30 11:32
7f7112 251                         grid.SetValue(g.row, g.col, obj, 0);
X 252                         grid.RefreshCell(g.row, g.col);
253                     }
254                 }).on('filebeforedelete', function (event, params) {
255                     // 在删除initialPreview内容集中的每个缩略图文件之前触发此事件
256                     let e = !confirm("您确定要删除吗?");
257                     return e;
258                 }).on('filedeleted', function (event, key) {
259                     // 在删除initialPreview内容集中的每个缩略图文件之后触发此事件
260                     if (g) {
a6c1ad 261                         fileUploadCount--;
7f7112 262                         let grid = g.id;
X 263                         let obj = "";
e44ea2 264                         if (g.type == 19) {
F 265                             if (key != g.row[g.col + "_Img"]) {
266                                 //表示19类型且有多个附件
267                                 let delseq = key.split(";")[1];
268                                 let orgUnId = g.row[g.col + "_Img"];
269                                 orgUnId = orgUnId.replace(";" + delseq, "");//在原值中去掉相关的seq
270                                 g.row[g.col + "_Img"] = orgUnId;
271                                 let arrayUnid = orgUnId.split(";");
272                                 delete arrayFileType[key];
273                                 if (arrayUnid.length > 1) {
274                                     let newKey = arrayUnid[0] + ";" + arrayUnid[1];
275                                     let newUnid = newKey + ";" + (arrayFileType[newKey] != undefined ? arrayFileType[newKey] : "jpg");
276                                     obj = g.id.createPicPath(newUnid);
277                                 }
278                             }
279                         }
7f7112 280                         grid.SetValue(g.row, g.col, obj, 0);
X 281                         grid.RefreshCell(g.row, g.col);
282                     }
283                 }).on('filesuccessremove', function (event, val) {
284                     // 使用缩略图删除按钮删除成功上传的缩略图后,会触发此事件
0a4f16 285                     let title = val.title;//文件名称,用于查找对应的seq
F 286                     let delSeq = arrayFileSeq[title];//对应删除的seq
7f7112 287                     let uuid = val.key.split(";")[0];
0a4f16 288                     //let seq = val.key.split(";")[1];
e44ea2 289                     let hd = 0;//主从表标记,0表示从表
F 290                     let formidType = g.id.gType;
291                     if (formidType == 3 || formidType == 301 || formidType == 304 || formidType == 4 || formidType == 7 || formidType == 1) {
292                         hd = 2;
293                     }//表示是面板但是在格线显示上传,3,7,4.等类型
294                     //--496类型
295                     if ((formidType == 496 || formidType == 498 || formidType == 497 || formidType == 499) && g.id.formidType.split("|")[0] == 1) {
296                         hd = 2;
297                     }
7f7112 298                     $.ajax({
X 299                         type: "POST",
300                         dataType: 'json',
e44ea2 301                         url: '/attachment/deleteOwnerAttachment.do?type=' + val.type + '&unid='
0a4f16 302                             + uuid + '&seq=' + delSeq + '&ishd=' + hd + '&fieldid=' + g.col + '&formid=' + g.id.formid,   // 删除路径
7f7112 303                         success: function (data) {
X 304                             if (data.status == 'success') {
305                                 if (g) {
a6c1ad 306                                     fileUploadCount--;
0a4f16 307                                     delete arrayFileSeq[title];
7f7112 308                                     var grid = g.id;
X 309                                     var obj = "";
0a4f16 310                                     let key = uuid + ";" + delSeq;
e44ea2 311                                     if (g.type == 19) {
0a4f16 312                                         if (key != g.row[g.col + "_Img"] || fileUploadCount != 0) {
e44ea2 313                                             //表示19类型且有多个附件
F 314                                             let orgUnId = g.row[g.col + "_Img"];
0a4f16 315                                             orgUnId = orgUnId.replace(";" + delSeq, "");//在原值中去掉相关的seq
e44ea2 316                                             g.row[g.col + "_Img"] = orgUnId;
F 317                                             let arrayUnid = orgUnId.split(";");
318
319                                             delete arrayFileType[key];
320                                             if (arrayUnid.length > 1) {
321                                                 let newKey = arrayUnid[0] + ";" + arrayUnid[1];
322                                                 let newUnid = newKey + ";" + (arrayFileType[newKey] != undefined ? arrayFileType[newKey] : "jpg");
323                                                 g.row[g.col] = g.id.createPicPath(newUnid);
0a4f16 324                                                 let tmp = {};
F 325                                                 tmp.key = newUnid;
326                                                 $('#file-inputv').val(newKey);
327                                                 // data.thumbs.attr("data-key", JSON.stringify(tmp));
e44ea2 328                                             }
F 329                                         } else {
330                                             //当前只有一个附件,直接清空
331                                             grid.SetValue(g.row, g.col, obj, 0);
332                                         }
333                                     } else {
334                                         grid.SetValue(g.row, g.col, obj, 0);
335                                     }
7f7112 336                                     grid.RefreshCell(g.row, g.col);
X 337                                 }
338                             }
339                         }
340                     })
341                 }).on('filezoomshown', function (event, params) {
342                     //此事件在模态对用户可见后触发(将等待 CSS 转换完成)
e91f77 343                     Event.imageEvent(params);
7f7112 344                 }).on('filezoomprev', function (event, params) {
X 345                     //事件在缩放预览模式下,当点击上一个导航按钮查看上一个文件时触发(也在缩放模式下按下键盘左箭头时触发)
e91f77 346                     setTimeout(function(){//这个事件不是渲染完进入,导致提前渲染图片查看器。 没什么决绝办法用setTimeout吧
X 347                         Event.imageEvent(params)
348                     },300);
7f7112 349                 }).on('filezoomnext', function (event, params) {
X 350                     //该事件在缩放预览模式下,当点击下一个导航按钮查看下一个文件时触发(也在缩放模式下按下键盘右箭头时触发)。
e91f77 351                     setTimeout(function(){
X 352                         Event.imageEvent(params)
353                     },300);
6a7088 354                 }).on('filezoomhidden',function (event,params) {
X 355                     top.$('.layui-layer-setwin').show();//隐藏图片的时候打开弹出层的关闭按钮 xin 2022-10-28 09:08:24
7f7112 356                 });
e91f77 357             },imageEvent:function (param) {
X 358                 try {
359                     isFileInputImage = new Viewer(param.modal.find('ul')[0], {
360                         title: true, inline: true, button: false
6a7088 361                         , viewed: function () {// 图片渲染完后进入,旋转大图片
95c8cc 362                             param.modal.css('overflow-y','hidden');
6a7088 363                             top.$('.layui-layer-setwin').hide();//打开图片的时候隐藏弹出层的关闭按钮 xin 2022-10-28 09:07:59
X 364                         }
e91f77 365                     });
X 366                     isFileInputImage.imageCurrent = 0
367                     isFileInputImage.view(param.viewerIndex || 0);
368                 } catch (e) {
369                     isFileInputImage = null;
009fd3 370                 }
7f7112 371             }
X 372         }
373         return o;
374     }
375     //附件控件类型9,19
376     const getFile = function (value, g) {
377         let controlType = 9;  // 专用于格线
378         let encrypt = new top.JSEncrypt();
379         encrypt.setPublicKey(rsakey.pubkey);
a6c1ad 380         // debugger;
7f7112 381         let param = {};
d8e3cb 382         if ((value.uuid == undefined || value.uuid == '') && (value.oldgrid != null &&
X 383             value.oldgrid != undefined && value.oldgrid != '')) {
384             let unid = value.oldgrid.split(';');
385             if (unid.length >= 2) {
386                 value.uuid = unid[0] + ";" + unid[1];//uuid+seq
387             }
388             if (unid.length >= 4 && unid[0].indexOf('.do') != -1) {
389                 if (unid.length > 4) {
390                     if (unid[unid.length - 2] != null && !isNaN(unid[unid.length - 2])) {
391                         controlType = 19;//存在多个seq,表示是多附件
7f7112 392                     }
d8e3cb 393                 } else {
X 394                     //是图片后缀的
395                     if (g.type == 40 && 'jpge;jpg;png;gif'.indexOf(unid[unid.length - 1].toLowerCase()) != -1) {
396                         getImage(value, g);
397                         return;
398                     }
7f7112 399                 }
d8e3cb 400                 value.uuid = unid[1] + ";" + unid[2];//uuid+seq
7f7112 401             }
d8e3cb 402             param.unid = value.uuid.replace("|48|48|", "");
X 403         }
404         param.fieldid = value.fieldid;
e44ea2 405         param.controltype = g.type;//9,19
d8e3cb 406         param.formid = value.formid;
X 407         param.ishd = value.ishd;
565d5f 408         let strIs = "";//判断更新单据字段值需要到
d8e3cb 409         if (value.is1 != null && value.is1 != "") {
X 410             strIs = "&is1=" + value.is1 + "&ishd=" + value.ishd;
411         } else if (value.is8 != null && value.is8 != "") {
412             strIs = "&is8=" + value.is8 + "&ishd=" + value.ishd;
e44ea2 413         } else if (value.ishd == 2) {
565d5f 414             strIs = "&is16=1&ishd=" + value.ishd;
e44ea2 415         } else {
d8e3cb 416             strIs = "&ishd=" + value.ishd;
X 417         }
418         param.docstatus = value.docstatus == null ? 0 : value.docstatus;
4442a8 419         param.rowid = value.rowid;
d8e3cb 420         param.usercode = value.usercode;
X 421         param.doccode = value.doccode;
422         param.headflag = (value.ishd == 0) ? 1 : 0;
423         let readerUserCodes = top.$('#readerusercodes').val();
424         try {
425             if (param.doccode == null) {
426                 param.doccode = top.$('#doccode').val();
427                 if (param.doccode == null)
428                     param.doccode = top.panMain[top.panIndex].panelAuditValue.doccode;
7f7112 429             }
9bd2e8 430             if ((value.doccode == 'undefined' || value.doccode == '') && g.row != null) {//在没有单号的情况下(个别系统没有doccode值),找matcode作为doccode值 xin 2023-2-10 15:41:07
56df6c 431                 let matCode = g.row.matcode;
X 432                 matCode = matCode ? top.encodeText(matCode) : ''
433                 strIs = "&ishd=" + value.ishd + "&matCode=" + matCode;//后台需要matCode更新对应数据图片信息
434                 param.doccode = matCode;
9bd2e8 435                 value.doccode = '';
X 436             }
d8e3cb 437             if (param.doccode && readerUserCodes != null && readerUserCodes != '') {
X 438                 param.readerusercodes = readerUserCodes;
7f7112 439             }
d8e3cb 440         } catch (e) {
X 441             param.doccode = "";
442         }
443         // 赋值
444         $('#file-inputv').val(param.unid);//赋值
445         let fileInput = BootstrapFileInputOption(g); // 加载图片需要的属性(固定ID)
446         try {
7f7112 447             // 图片显示的方法
X 448             $.ajax({
449                 url: '/attachment/getAttachmentList.do',
450                 type: "POST",
451                 async: false,
452                 data: {pant: JSON.stringify(param)},
453                 dataType: 'json',
454                 success: function (jsons) {
455                     if ((value.uuid != null && value.uuid != '') ||
456                         (value.oldgrid != null && value.oldgrid != null && value.oldgrid != '')) {
a6c1ad 457                         fileUploadCount = jsons.length;
7f7112 458                         for (var i = 0; i < jsons.length; i++) {
X 459                             // 图片属性
460                             if (param.usercode == "") {
461                                 param.usercode = jsons[i].userCode;
462                                 value.usercode = jsons[i].userCode;
463                             }
464                             if (i == 0) {
465                                 param.username = jsons[i].userName;
466                                 param.dbid = jsons[i].dbid;
467                                 param.domain = jsons[i].domain;
468                                 value.username = jsons[i].userName;
469                                 value.dbid = jsons[i].dbid;
470                                 value.domain = jsons[i].domain;
471                             }
472                             //文件路径
473                             let fileURL = top.getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid,
474                                 jsons[i].unid + "@p@" + jsons[i].seq, jsons[i].domain, jsons[i].dbid,
475                                 false, 60, 60, jsons[i].orgFileType);
476                             //文件显示信息
477                             let title = '文件名:' + jsons[i].originalFileName +
478                                 ' \n类型:' + jsons[i].fileType +
479                                 ' \n大小:' + jsons[i].fileSizeStr +
480                                 ' \n上传者:' + jsons[i].authorName +
481                                 ' \n上传时间:' + jsons[i].uploadTimeStr;
e44ea2 482                             arrayFileType[jsons[i].unid + ";" + jsons[i].seq] = jsons[i].orgFileType
7f7112 483                             //删除地址
e44ea2 484                             let is496 = param.ishd;
F 485                             if (g.id.gType == 497 && value.is1 == 1) {
486                                 //多表且是格线的情况,需要和3类型一样的处理,设置为2,取格线的控件类型 by danaus 2024-01-26 16:17
487                                 is496 = 2;
488                             }
7f7112 489                             let deleURL = jsons[i].domain + '/attachment/deleteAttachmentV2.do?' +
e44ea2 490                                 'type=' + (param.controltype == 9 ? '1' : '3') + '&formid=' + param.formid +
7f7112 491                                 '&doccode=' + param.doccode + '&fieldid=' + jsons[i].fieldid + '&unid=' + jsons[i].unid +
e44ea2 492                                 '&seq=' + jsons[i].seq + '&docstatus=' + param.docstatus + '&ishd=' + is496 +
7f7112 493                                 '&usercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].authorCode)) +
X 494                                 '&readerusercodes=' + readerUserCodes +
495                                 '&dbid=' + encodeURIComponent(encrypt.encrypt(jsons[i].dbid)) +
496                                 '&curUsername=' + encodeURIComponent(encrypt.encrypt(jsons[i].userName)) +
497                                 '&curUsercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].userCode));
498                             //下载地址
499                             let Down = jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" +
500                                 jsons[i].unid + "@p@" + jsons[i].seq + "_" + jsons[i].dbid + "_" +
501                                 jsons[i].formid + "_" + jsons[i].orgFileType;
502                             //pdf格式调用插件
503                             if (jsons[i].orgFileType == 'pdf') {
ffa28f 504                                 fileURL = jsons[i].domain + '/general/pdf/web/viewer.jsp?file=' + fileURL;
7f7112 505                             }
X 506                             //设置office文件
507                             if (jsons[i].orgFileType == 'doc' || jsons[i].orgFileType == 'docx' || jsons[i].orgFileType == 'xls'
508                                 || jsons[i].orgFileType == 'xlsx' || jsons[i].orgFileType == 'ppt' || jsons[i].orgFileType == 'pptx') {
509                                 jsons[i].fileType = 'office';
510                             }
511                             //填充
512                             fileInput.option.initialPreview.push(fileURL);
513                             fileInput.option.initialPreviewConfig.push({
514                                 'caption': jsons[i].originalFileName,   // 上传的图片名称
515                                 'filename': jsons[i].physicalFile,   // 上传文件名
516                                 'time': jsons[i].uploadTimeStr,  //上传开始时间
517                                 'name': jsons[i].authorName,  //作者名称
518                                 'size': jsons[i].fileSizeStr,   // 上传的图片大小
519                                 'type': jsons[i].fileType,   // 上传的图片类型
520                                 'filetype': jsons[i].fileType + '/' + jsons[i].orgFileType,
521                                 'key': jsons[i].unid + ';' + jsons[i].seq,
899da7 522                                 'seq': jsons[i].seq,
7f7112 523                                 'title': title,//title
X 524                                 'downloadUrl': jsons[i].allowDownload ? Down : false,//jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" + fileURL,//top.getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid, jsons[i].unid + "@p@" + jsons[i].seq, "", jsons[i].dbid, false, 60, 60, jsons[i].orgFileType, true),
525                                 'url': deleURL,//删除
526                                 'hasZoom': jsons[i].allowView,//是否能查看
527                                 // 'hasDwn': jsons[i].allowDownload,//是否能下载
528                                 'hasDel': jsons[i].allowDelete,//是否能删除
529                                 'hasLock': jsons[i].authorCode != null && jsons[i].authorCode == param.usercode ? true : false//是否能显示权限
530                             });
531                         }
532                     }
a1a3cb 533                     //上传地址
7f7112 534                     let upURL = value.domain + '/attachment/uploadAttachmentV2.do?type=' +
e44ea2 535                         (param.controltype == 9 ? '1' : '3') + '&formid=' + value.formid
7f7112 536                         + '&doccode=' + value.doccode + '&fieldid=' + value.fieldid
X 537                         + '&usercode=' + encodeURIComponent(encrypt.encrypt(value.usercode)) +
538                         '&username=' + encodeURIComponent(encrypt.encrypt(value.username)) +
e44ea2 539                         '&dbid=' + encodeURIComponent(encrypt.encrypt(value.dbid)) +
F 540                         '&detailrowid=' + (value.detailrowid || '') + '&rowid=' + (value.rowid || '') +
541                         '&uuid=' + (value.uuid == undefined ? "" : value.uuid) + strIs;
7f7112 542                     fileInput.option.uploadUrl = upURL; // 附件上传路径
05260d 543                     // fileInput.option.maxFileCount = 1;   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
e44ea2 544                     fileInput.option.maxTotalFileCount = g.type == 9 ? 1 : 0;  // 允许的总文件数。如果设置为0,则意味着允许的总文件数是无限的。默认值为0。
0a4f16 545                     fileInput.option.isNine = g.type == 9 ? true : false;
7f7112 546                     fileInput.option.validateInitialCount = true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
X 547                     fileInput.option.overwriteInitial = false;   // 是否要覆盖初始预览内容和标题设置
548                     if (jsons.length > 0) {
549                         let size = jsons[0].allowMaxFileSize != '' ? jsons[0].allowMaxFileSize : 0;
550                         fileInput.option.maxFileSize = size;//从后台取数回来 by danaus 2020/8/7 10:47
551                     }
552                 }
553             });
554         } catch (e) {
555             alert(e);
556         } finally {
0a4f16 557             fileInput.fileInput({multiple: g.type == 9 ? false : true});// 加载图片显示
7f7112 558             $(".image").addClass("hide");
X 559             $(".fileInput").removeClass("hide");
560         }
561     }
562     //图片类型控件 40
563     const getImage = function (value, g) {
564         if (value.oldgrid != null) {
565             let srcURL = '';
566             if (value.oldgrid.indexOf('http') != -1) {   //判断http协议,有无地址
567                 srcURL = value.oldgrid.split(";")[1]; //显示网址图片
568             } else {
569                 // let src = value.oldgrid.replace(".do;",".do?type="+(controlType == 9?"1":"3")+"&uuid=");
570                 let obj = value.oldgrid.split(";");
571                 let unid = obj[1];
572                 let seq = obj[2];
573                 let fileExt = obj[obj.length - 1];
574                 if (obj.length > 4) {
575                     fileExt = "unknown";
576                 }
577                 if ('jpge;jpg;png;gif'.indexOf(fileExt.toLowerCase()) == -1) {//不是图片后缀的
578                     //执行9 19类型控件
579                     getFile(value, g);
580                     return;
581                 }
582                 if (seq != null && seq != undefined && seq != "") {
583                     unid = unid + "@p@" + seq;
584                 }
585                 srcURL = top.getAttachmentUrl(value.staticUrl, value.formid, unid, value.domain, value.dbid, false, 80, 80, fileExt);
586             }
587             $("#bimges").attr("src", srcURL);
588         }
589         $(".image").removeClass("hide");
590         $(".fileInput").addClass("hide");
27db5c 591         let kv = $('#bimges');
X 592         if (kv.length == 1) {
593             new Viewer(kv[0], {title: false});
594         }
7f7112 595     }
X 596     //拆分
597     const getSplit = function () {
598         let v = {};
599         let value = top.gridFileInputVal;
600         if (value != null) {
601             let pant = value.split("?")[1];
602             let pants = pant.split("&");
603             for (var i = 0; i < pants.length; i++) {
604                 let c = pants[i].split("=");
605                 v[c[0]] = c[1];
606             }
607         }
608         return v;
609     }
610     $(function () {
611         let g = top.gridFileInputRow;
612         let value = getSplit();
613         if (value != null && g != null) {
e44ea2 614             if (g.type == 9 || g.type == 19) {
7f7112 615                 getFile(value, g);//附件控件类型9,19
X 616             } else if (g.type == 40) {
617                 getImage(value, g);//图片类型控件 40
618             } else {
619                 return;
620             }
621         } else {
622             alert('获取不到文件解析内容');
623         }
624     })
625 </script>
626 </body>
627 </html>