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