Merge branch 'master-mj-joke' into 'master-mj'
fix:工作日志附件预览及下载功能优化,禅道bug#1587,1589 fix:工作日志附件预览及下载功能优化,禅道bug#1587,1589 See merge request !1110
Showing
5 changed files
with
61 additions
and
23 deletions
@@ -16,6 +16,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | @@ -16,6 +16,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | ||
16 | exports('workReportAdd', function (data) { | 16 | exports('workReportAdd', function (data) { |
17 | // var accessToken = session.getToken()['access_token'] | 17 | // var accessToken = session.getToken()['access_token'] |
18 | var accessToken = common.getMjToken(); | 18 | var accessToken = common.getMjToken(); |
19 | + var tokenKey = common.getMjTokenKey(); | ||
19 | var userSelect = {} | 20 | var userSelect = {} |
20 | var currentDate = {} | 21 | var currentDate = {} |
21 | var uploadInst = {} | 22 | var uploadInst = {} |
@@ -351,9 +352,10 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | @@ -351,9 +352,10 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | ||
351 | function initUploadPlus() { | 352 | function initUploadPlus() { |
352 | var param = {"access_token": accessToken} | 353 | var param = {"access_token": accessToken} |
353 | var fileName = [] | 354 | var fileName = [] |
355 | + | ||
354 | uploadInst = upload.render({ | 356 | uploadInst = upload.render({ |
355 | elem: '#attachment', //绑定元素 | 357 | elem: '#attachment', //绑定元素 |
356 | - url: common.domainName + '/api-web/workreport/upload?accessToken='+accessToken, | 358 | + url: common.domainName + `/api-web/workreport/upload?${tokenKey}=${accessToken}`, |
357 | data: param, | 359 | data: param, |
358 | multiple: true, | 360 | multiple: true, |
359 | auto: false, //选择文件后不自动上传 | 361 | auto: false, //选择文件后不自动上传 |
@@ -388,8 +390,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | @@ -388,8 +390,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | ||
388 | //初始化用户下拉列表框 | 390 | //初始化用户下拉列表框 |
389 | function initUserSelect() { | 391 | function initUserSelect() { |
390 | $.ajax({ | 392 | $.ajax({ |
391 | - url: domainName + '/mj/user/page?username=&nickname=&enabled=&perPage=10000&page=1&accessToken=' + common.getMjToken(), | ||
392 | - // url: domainName + '/api-user/users/getAll?access_token=' + accessToken, | 393 | + url: domainName + `/mj/user/page?username=&nickname=&enabled=&perPage=10000&page=1&${tokenKey}=${accessToken}`, |
393 | success: function (res) { | 394 | success: function (res) { |
394 | userSelect = xmSelect.render({ | 395 | userSelect = xmSelect.render({ |
395 | el: '.reportUser', | 396 | el: '.reportUser', |
@@ -520,7 +521,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | @@ -520,7 +521,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | ||
520 | var id = $(this).data('id') | 521 | var id = $(this).data('id') |
521 | var suffix = $(this).data('suffix') | 522 | var suffix = $(this).data('suffix') |
522 | if (suffix == 'jpg' || suffix == 'png' || suffix == 'JPG' || suffix == 'PNG') { //图片类型 | 523 | if (suffix == 'jpg' || suffix == 'png' || suffix == 'JPG' || suffix == 'PNG') { //图片类型 |
523 | - var srcUrl = domainName + `/api-web/openoffice/readImage/${id}?access_token=` + accessToken | 524 | + var srcUrl = domainName + `/api-web/openoffice/readImage/${id}?${tokenKey}=${accessToken}`; |
524 | layer.open({ | 525 | layer.open({ |
525 | type: 1, | 526 | type: 1, |
526 | content: `<div><img src="${srcUrl}" width="100%" height="100%" /></div>`, | 527 | content: `<div><img src="${srcUrl}" width="100%" height="100%" /></div>`, |
@@ -558,20 +559,18 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | @@ -558,20 +559,18 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect | ||
558 | layer.confirm('附件删除后将无法恢复,您确定要删除吗?', { | 559 | layer.confirm('附件删除后将无法恢复,您确定要删除吗?', { |
559 | btn: ['确定', '取消'] //按钮 | 560 | btn: ['确定', '取消'] //按钮 |
560 | }, function () { | 561 | }, function () { |
561 | - $.ajax({ | ||
562 | - url: domainName + `/api-web/workreport/deleteAttachment/${id}/${attachId}?access_token=` + accessToken, | ||
563 | - type: "get", | ||
564 | - }).done(function (res) { | ||
565 | - layer.msg('删除成功', { | ||
566 | - offset: '15px' | ||
567 | - , icon: 1 | ||
568 | - , time: 1000 | ||
569 | - }, function () { | ||
570 | - $("#tags_span_" + attachId).remove(); | ||
571 | - }); | ||
572 | - }).error(function (error) { | ||
573 | - console.log(error); | ||
574 | - }); | 562 | + admin.req({ |
563 | + url: domainName + `/api-web/workreport/deleteAttachment/${id}/${attachId}`, | ||
564 | + done: function (res) { | ||
565 | + layer.msg('删除成功', { | ||
566 | + offset: '15px' | ||
567 | + , icon: 1 | ||
568 | + , time: 1000 | ||
569 | + }, function () { | ||
570 | + $("#tags_span_" + attachId).remove(); | ||
571 | + }); | ||
572 | + } | ||
573 | + }) | ||
575 | }); | 574 | }); |
576 | }); | 575 | }); |
577 | } | 576 | } |
@@ -11,7 +11,8 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function | @@ -11,7 +11,8 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function | ||
11 | 11 | ||
12 | //对外暴露的接口 | 12 | //对外暴露的接口 |
13 | exports("workReportList", function (d) { | 13 | exports("workReportList", function (d) { |
14 | - var accessToken = session.getToken()['access_token'] | 14 | + var accessToken = common.getMjToken(); |
15 | + var tokenKey = common.getMjTokenKey(); | ||
15 | if (d.type == 'attachment') { | 16 | if (d.type == 'attachment') { |
16 | $('#attachmentTable').show() | 17 | $('#attachmentTable').show() |
17 | $('#reportUserTable').hide() | 18 | $('#reportUserTable').hide() |
@@ -121,7 +122,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function | @@ -121,7 +122,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function | ||
121 | var suffix = $(this).data('suffix') | 122 | var suffix = $(this).data('suffix') |
122 | var filepath = $(this).data('path') | 123 | var filepath = $(this).data('path') |
123 | if (suffix == 'jpg' || suffix == 'png' || suffix == 'JPG' || suffix == 'PNG') { //图片类型 | 124 | if (suffix == 'jpg' || suffix == 'png' || suffix == 'JPG' || suffix == 'PNG') { //图片类型 |
124 | - var srcUrl = domainName + `/api-web/openoffice/readImage/${id}?access_token=` + accessToken | 125 | + var srcUrl = domainName + `/api-web/openoffice/readImage/${id}?${tokenKey}=${accessToken}`; |
125 | layer.open({ | 126 | layer.open({ |
126 | type: 1, | 127 | type: 1, |
127 | content: `<div><img src="${srcUrl}" width="100%" height="100%" /></div>`, | 128 | content: `<div><img src="${srcUrl}" width="100%" height="100%" /></div>`, |
@@ -129,15 +130,44 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function | @@ -129,15 +130,44 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function | ||
129 | area: ['60%', '90%'] | 130 | area: ['60%', '90%'] |
130 | }) | 131 | }) |
131 | } else { | 132 | } else { |
133 | + var loadIndex = layer.load(1, {shade: [0.3], content: ''}); | ||
134 | + let name = Base64.encode(filepath, true); | ||
135 | + admin.req({ | ||
136 | + url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`, | ||
137 | + type: 'get' | ||
138 | + }).done(function (res) { | ||
139 | + layer.close(loadIndex); | ||
140 | + if (res && res.success) { | ||
141 | + let win = window.parent; | ||
142 | + if (win) { | ||
143 | + window.parent.postMessage({ | ||
144 | + type: "previewFile", | ||
145 | + message: { | ||
146 | + params: { | ||
147 | + url: res.str | ||
148 | + } | ||
149 | + } | ||
150 | + }, '*') | ||
151 | + } | ||
152 | + } else { | ||
153 | + layer.confirm("文档不支持预览,是否下载!", function () { | ||
154 | + const url = domainName + `/api-web/openoffice/download/${id}?${tokenKey}=${accessToken}`; | ||
155 | + window.open(url) | ||
156 | + }); | ||
157 | + } | ||
158 | + }).error(function (error) { | ||
159 | + layer.close(loadIndex); | ||
160 | + console.log(error) | ||
161 | + }) | ||
132 | //附件为文档类型 | 162 | //附件为文档类型 |
133 | - common.fileviewer(filepath); | 163 | + // common.fileviewer(filepath); |
134 | } | 164 | } |
135 | }) | 165 | }) |
136 | 166 | ||
137 | $('.attachment-download-btn').on('click', function () { | 167 | $('.attachment-download-btn').on('click', function () { |
138 | var id = $(this).data('id') | 168 | var id = $(this).data('id') |
139 | var suffix = $(this).data('suffix') | 169 | var suffix = $(this).data('suffix') |
140 | - var url = domainName + `/api-web/openoffice/download/${id}?access_token=` + accessToken | 170 | + var url = domainName + `/api-web/openoffice/download/${id}?${tokenKey}=${accessToken}`; |
141 | window.open(url) | 171 | window.open(url) |
142 | }) | 172 | }) |
143 | } | 173 | } |
@@ -330,7 +330,7 @@ layui.define(['table', 'form', 'sessions', 'admin', 'common', 'echarts', 'laydat | @@ -330,7 +330,7 @@ layui.define(['table', 'form', 'sessions', 'admin', 'common', 'echarts', 'laydat | ||
330 | url: domainName + '/mj/user/page?username=&nickname=&enabled=&perPage=10000&page=1&accessToken=' + common.getMjToken(), | 330 | url: domainName + '/mj/user/page?username=&nickname=&enabled=&perPage=10000&page=1&accessToken=' + common.getMjToken(), |
331 | success: function (response) { | 331 | success: function (response) { |
332 | var options = "<option value=''>=选择汇报人=</option>"; | 332 | var options = "<option value=''>=选择汇报人=</option>"; |
333 | - $.each(response, function (i, v) { | 333 | + $.each(response.data.rows, function (i, v) { |
334 | options += "<option value='" + v.username + "'>" + v.nickname + "</option>" | 334 | options += "<option value='" + v.username + "'>" + v.nickname + "</option>" |
335 | }); | 335 | }); |
336 | $('#slt-workreport-user').html(options); | 336 | $('#slt-workreport-user').html(options); |
1 | +/** | ||
2 | + * Minified by jsDelivr using Terser v5.15.1. | ||
3 | + * Original file: /npm/js-base64@3.7.5/base64.js | ||
4 | + * | ||
5 | + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files | ||
6 | + */ | ||
7 | +!function(t,n){var r,e;"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=t.Base64,(e=n()).noConflict=function(){return t.Base64=r,e},t.Meteor&&(Base64=e),t.Base64=e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this,(function(){"use strict";var t,n="3.7.5",r="function"==typeof atob,e="function"==typeof btoa,o="function"==typeof Buffer,u="function"==typeof TextDecoder?new TextDecoder:void 0,i="function"==typeof TextEncoder?new TextEncoder:void 0,f=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),c=(t={},f.forEach((function(n,r){return t[n]=r})),t),a=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,d=String.fromCharCode.bind(String),s="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},l=function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))},h=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},p=function(t){for(var n,r,e,o,u="",i=t.length%3,c=0;c<t.length;){if((r=t.charCodeAt(c++))>255||(e=t.charCodeAt(c++))>255||(o=t.charCodeAt(c++))>255)throw new TypeError("invalid character found");u+=f[(n=r<<16|e<<8|o)>>18&63]+f[n>>12&63]+f[n>>6&63]+f[63&n]}return i?u.slice(0,i-3)+"===".substring(i):u},y=e?function(t){return btoa(t)}:o?function(t){return Buffer.from(t,"binary").toString("base64")}:p,A=o?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var n=[],r=0,e=t.length;r<e;r+=4096)n.push(d.apply(null,t.subarray(r,r+4096)));return y(n.join(""))},b=function(t,n){return void 0===n&&(n=!1),n?l(A(t)):A(t)},g=function(t){if(t.length<2)return(n=t.charCodeAt(0))<128?t:n<2048?d(192|n>>>6)+d(128|63&n):d(224|n>>>12&15)+d(128|n>>>6&63)+d(128|63&n);var n=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return d(240|n>>>18&7)+d(128|n>>>12&63)+d(128|n>>>6&63)+d(128|63&n)},B=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,x=function(t){return t.replace(B,g)},C=o?function(t){return Buffer.from(t,"utf8").toString("base64")}:i?function(t){return A(i.encode(t))}:function(t){return y(x(t))},m=function(t,n){return void 0===n&&(n=!1),n?l(C(t)):C(t)},v=function(t){return m(t,!0)},U=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,F=function(t){switch(t.length){case 4:var n=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return d(55296+(n>>>10))+d(56320+(1023&n));case 3:return d((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return d((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},w=function(t){return t.replace(U,F)},S=function(t){if(t=t.replace(/\s+/g,""),!a.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var n,r,e,o="",u=0;u<t.length;)n=c[t.charAt(u++)]<<18|c[t.charAt(u++)]<<12|(r=c[t.charAt(u++)])<<6|(e=c[t.charAt(u++)]),o+=64===r?d(n>>16&255):64===e?d(n>>16&255,n>>8&255):d(n>>16&255,n>>8&255,255&n);return o},E=r?function(t){return atob(h(t))}:o?function(t){return Buffer.from(t,"base64").toString("binary")}:S,D=o?function(t){return s(Buffer.from(t,"base64"))}:function(t){return s(E(t).split("").map((function(t){return t.charCodeAt(0)})))},R=function(t){return D(T(t))},z=o?function(t){return Buffer.from(t,"base64").toString("utf8")}:u?function(t){return u.decode(D(t))}:function(t){return w(E(t))},T=function(t){return h(t.replace(/[-_]/g,(function(t){return"-"==t?"+":"/"})))},Z=function(t){return z(T(t))},j=function(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}},I=function(){var t=function(t,n){return Object.defineProperty(String.prototype,t,j(n))};t("fromBase64",(function(){return Z(this)})),t("toBase64",(function(t){return m(this,t)})),t("toBase64URI",(function(){return m(this,!0)})),t("toBase64URL",(function(){return m(this,!0)})),t("toUint8Array",(function(){return R(this)}))},O=function(){var t=function(t,n){return Object.defineProperty(Uint8Array.prototype,t,j(n))};t("toBase64",(function(t){return b(this,t)})),t("toBase64URI",(function(){return b(this,!0)})),t("toBase64URL",(function(){return b(this,!0)}))},P={version:n,VERSION:"3.7.5",atob:E,atobPolyfill:S,btoa:y,btoaPolyfill:p,fromBase64:Z,toBase64:m,encode:m,encodeURI:v,encodeURL:v,utob:x,btou:w,decode:Z,isValid:function(t){if("string"!=typeof t)return!1;var n=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(n)||!/[^\s0-9a-zA-Z\-_]/.test(n)},fromUint8Array:b,toUint8Array:R,extendString:I,extendUint8Array:O,extendBuiltins:function(){I(),O()},Base64:{}};return Object.keys(P).forEach((function(t){return P.Base64[t]=P[t]})),P})); | ||
8 | +//# sourceMappingURL=/sm/555281732ed54ee1693a772f485329378d8ea5052ffa4370e9c2e9947eb42d22.map |
@@ -24,6 +24,7 @@ | @@ -24,6 +24,7 @@ | ||
24 | <body> | 24 | <body> |
25 | <div id="LAY_app"></div> | 25 | <div id="LAY_app"></div> |
26 | <script src="/monitor-web/start/layui/layui.js"></script> | 26 | <script src="/monitor-web/start/layui/layui.js"></script> |
27 | +<script src="/monitor-web/src/lib/extend/js/base64.min.js"></script> | ||
27 | <script> | 28 | <script> |
28 | layui.use(['jquery', 'layer','config'], function () { | 29 | layui.use(['jquery', 'layer','config'], function () { |
29 | var $ = layui.jquery; | 30 | var $ = layui.jquery; |
-
Please register or login to post a comment